/// <summary> /// 获取我的竞猜列表 /// </summary> /// <param name="managerId"></param> /// <returns></returns> public GetMyEuropeGambleResponse GetMyGamble(Guid managerId) { GetMyEuropeGambleResponse response = new GetMyEuropeGambleResponse(); try { var managerList = EuropeGamblerecordMgr.GambleRecord(managerId); response.Data = new GetMyEuropeGamble(); foreach (var item in managerList) { var match = EuropeConfig.Instance.GetOneMatch(item.MatchId); if (match != null) { item.HomeName = match.HomeName; item.AwayName = match.AwayName; item.TimeTick = ShareUtil.GetTimeTick(item.RowTime); } } response.Data.GambleList = managerList; } catch (Exception ex) { SystemlogMgr.Error("获取我的竞猜列表", ex); response.Code = (int)MessageCode.NbParameterError; } return(response); }
public void SendPrize(int matchId, string zoneId) { DateTime date = DateTime.Now; var match = EuropeMatchMgr.GetById(matchId); var _season = EuropeSeasonMgr.GetSeason(date, zoneId); if (match == null) { return; } var season = EuropeSeasonMgr.GetSeason(date, zoneId); //获取未发奖的竞猜 var sendPrizeList = EuropeGamblerecordMgr.GetNotPrize(matchId, zoneId); foreach (var item in sendPrizeList) { if (item.IsSendPrize) { continue; } item.IsSendPrize = true; item.UpdateTime = date; MailBuilder mail = null; EuropeGambleEntity gambleInfo = null; bool isInsertInfo = false; if (item.GambleType == match.ResultType) //竞猜正确 { item.IsGambleCorrect = true; item.ReturnPoint = item.Point * 2; //发邮件 mail = new MailBuilder(item.ManagerId, EnumMailType.Europe, item.ReturnPoint, match.HomeName, match.AwayName); gambleInfo = EuropeGambleMgr.GetById(item.ManagerId, zoneId); if (gambleInfo == null) { isInsertInfo = true; gambleInfo = new EuropeGambleEntity(item.ManagerId, 1, "0,0,0,0", date, date, season.Idx); } else { if (_season != null && gambleInfo.SeasonId != _season.Idx) { //插入记录 EuropeRecordMgr.Insert(new EuropeRecordEntity(0, gambleInfo.ManagerId, gambleInfo.SeasonId, gambleInfo.CorrectNumber, gambleInfo.PrizeRecord, date), null, zoneId); //更新活动 gambleInfo.CorrectNumber = 0; gambleInfo.PrizeRecord = "0,0,0,0"; gambleInfo.SeasonId = _season.Idx; } gambleInfo.CorrectNumber++; gambleInfo.UpdateTime = date; } } else { item.IsGambleCorrect = false; } MessageCode code = MessageCode.FailUpdate; if (mail != null) { if (!mail.Save(zoneId)) { ShowMessage("发送邮件失败"); return; } } if (gambleInfo != null) { if (isInsertInfo) { if (!EuropeGambleMgr.Insert(gambleInfo, null, zoneId)) { code = MessageCode.NbUpdateFail; } } else { if (!EuropeGambleMgr.Update(gambleInfo, null, zoneId)) { code = MessageCode.NbUpdateFail; } } } if (!EuropeGamblerecordMgr.Update(item, null, zoneId)) { code = MessageCode.NbUpdateFail; } if (code != MessageCode.Success) { ShowMessage("保存失败"); } } }
public void SendPrize(EuropeMatchEntity match) { DateTime date = DateTime.Now; //获取未发奖的竞猜 var sendPrizeList = EuropeGamblerecordMgr.GetNotPrize(match.MatchId); foreach (var item in sendPrizeList) { if (item.IsSendPrize) { continue; } item.IsSendPrize = true; item.UpdateTime = date; MailBuilder mail = null; EuropeGambleEntity gambleInfo = null; bool isInsertInfo = false; if (item.GambleType == match.ResultType) //竞猜正确 { item.IsGambleCorrect = true; item.ReturnPoint = item.Point * 2; //发邮件 mail = new MailBuilder(item.ManagerId, EnumMailType.Europe, item.ReturnPoint, match.HomeName, match.AwayName); gambleInfo = EuropeGambleMgr.GetById(item.ManagerId); if (gambleInfo == null) { isInsertInfo = true; gambleInfo = new EuropeGambleEntity(item.ManagerId, 1, "0,0,0,0", date, date, this.Season); } else { if (gambleInfo.SeasonId != this.Season) { //插入记录 EuropeRecordMgr.Insert(new EuropeRecordEntity(0, gambleInfo.ManagerId, gambleInfo.SeasonId, gambleInfo.CorrectNumber, gambleInfo.PrizeRecord, date)); //更新活动 gambleInfo.CorrectNumber = 0; gambleInfo.PrizeRecord = "0,0,0,0"; gambleInfo.SeasonId = this.Season; } gambleInfo.CorrectNumber++; gambleInfo.UpdateTime = date; } } else { item.IsGambleCorrect = false; } using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault())) { transactionManager.BeginTransaction(); MessageCode code = MessageCode.FailUpdate; do { if (mail != null) { if (!mail.Save(transactionManager.TransactionObject)) { break; } } if (gambleInfo != null) { if (isInsertInfo) { if (!EuropeGambleMgr.Insert(gambleInfo, transactionManager.TransactionObject)) { break; } } else { if (!EuropeGambleMgr.Update(gambleInfo, transactionManager.TransactionObject)) { break; } } } if (!EuropeGamblerecordMgr.Update(item, transactionManager.TransactionObject)) { break; } code = MessageCode.Success; } while (false); if (code != MessageCode.Success) { transactionManager.Rollback(); } else { transactionManager.Commit(); } } } }
/// <summary> /// 竞猜比赛 /// </summary> /// <param name="managerId"></param> /// <param name="matchId"></param> /// <param name="gambleType"></param> /// <param name="pointType"></param> /// <returns></returns> public EuropeGambleMatchResponse GambleMatch(Guid managerId, int matchId, int gambleType, int pointType) { EuropeGambleMatchResponse response = new EuropeGambleMatchResponse(); try { DateTime date = DateTime.Now; var manager = ManagerCore.Instance.GetManager(managerId); if (manager == null) { response.Code = (int)MessageCode.MissManager; return(response); } var match = EuropeConfig.Instance.GetOneMatch(matchId); if (match == null) { response.Code = (int)MessageCode.NotHaveMatch; return(response); } if (match.States != (int)EnumEuropeStatus.Gamble || match.MatchTime < date)//不可以竞猜 { response.Code = (int)MessageCode.HaveGambleTime; return(response); } var gambleRecord = EuropeGamblerecordMgr.GambleRecord(managerId, matchId); if (gambleRecord != null)//已经竞猜过 { response.Code = (int)MessageCode.HaveGamble; return(response); } var pointConfig = EuropeConfig.Instance.GetGamblePoint(pointType); if (pointConfig == null || pointConfig.VipLevel > manager.VipLevel)//竞猜点卷有误 { response.Code = (int)MessageCode.PointConfigNotHave; return(response); } var managerPoint = PayCore.Instance.GetPoint(managerId); if (managerPoint < pointConfig.Point)//钻石不足 { response.Code = (int)MessageCode.NbPointShortage; return(response); } gambleRecord = new EuropeGamblerecordEntity(0, managerId, matchId, gambleType, pointConfig.Point, 0, false, false, date, date); using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault())) { transactionManager.BeginTransaction(); MessageCode code = MessageCode.FailUpdate; do { if (!EuropeGamblerecordMgr.Insert(gambleRecord, transactionManager.TransactionObject)) { break; } code = PayCore.Instance.GambleTrueMatch(managerId, pointConfig.Point, ShareUtil.GenerateComb().ToString(), transactionManager.TransactionObject); } while (false); if (code != MessageCode.Success) { transactionManager.Rollback(); response.Code = (int)code; return(response); } transactionManager.Commit(); response.Data = new EuropeGambleMatch(); response.Data.Point = managerPoint - pointConfig.Point; } } catch (Exception ex) { SystemlogMgr.Error("欧洲杯竞猜", ex); response.Code = (int)MessageCode.NbParameterError; } return(response); }
/// <summary> /// 获取比赛列表 /// </summary> /// <param name="managerId"></param> /// <param name="matchDate">比赛日期</param> /// <returns></returns> public GetEuropeMatchListResponse GetMatchList(Guid managerId, DateTime matchDate, int isDefault) { GetEuropeMatchListResponse response = new GetEuropeMatchListResponse(); try { DateTime date = DateTime.Now; var list = EuropeConfig.Instance.GetMatchDay(matchDate); List <EuropeMatchEntity> matchList = new List <EuropeMatchEntity>(); if (isDefault == 1) { var notMatchList = list.FindAll(r => r.MatchTime > date); for (int i = 0; i < 5; i++) { if (notMatchList.Count > 0) { break; } matchDate = matchDate.AddDays(1); notMatchList = EuropeConfig.Instance.GetMatchDay(matchDate); } matchList.AddRange(notMatchList); } else { matchList.AddRange(list); } var gambleRecord = EuropeGamblerecordMgr.GambleRecord(managerId); List <EuropeMatchEntity> resultList = new List <EuropeMatchEntity>(); foreach (var item in matchList) { var entity = new EuropeMatchEntity(); entity.AwayGoals = item.AwayGoals; entity.AwayLogo = item.AwayLogo; entity.AwayName = item.AwayName; entity.HomeGoals = item.HomeGoals; entity.HomeLogo = item.HomeLogo; entity.HomeName = item.HomeName; entity.IsAlreadyGamble = false; entity.MatchDate = item.MatchDate; entity.MatchId = item.MatchId; entity.MatchTimeTick = item.MatchTimeTick; entity.ResultType = item.ResultType; entity.States = item.States; if (gambleRecord.Exists(r => r.MatchId == item.MatchId)) { entity.IsAlreadyGamble = true; } resultList.Add(entity); } response.Data = new GetEuropeMatchList(); response.Data.MatchList = resultList; response.Data.MatchDateTick = ShareUtil.GetTimeTick(matchDate); } catch (Exception ex) { SystemlogMgr.Error("获取欧洲杯比赛列表", ex); response.Code = (int)MessageCode.NbParameterError; } return(response); }