/// <summary> /// 获取我的竞猜活动 /// </summary> /// <param name="managerId"></param> /// <returns></returns> public EuropeGambleResponse GetMyActivity(Guid managerId) { EuropeGambleResponse response = new EuropeGambleResponse(); try { var info = GetMyGambleInfo(managerId); var prizeList = info.PrizeRecord.Split(','); int setp = EuropeConfig.Instance.GetStepByWin(info.CorrectNumber); bool isUpdate = false; for (int i = 1; i <= 4; i++) { if (prizeList.Length < i) { isUpdate = true; prizeList[i - 1] = "0"; } if (prizeList[i - 1] == "0" && setp >= i) { isUpdate = true; prizeList[i - 1] = "1"; } } info.PrizeRecord = String.Join(",", prizeList); if (isUpdate) { info.UpdateTime = DateTime.Now; EuropeGambleMgr.Update(info); } info.ActivityEndTime = ShareUtil.GetTimeTick(EuropeConfig.Instance.EndTime); response.Data = info; } catch (Exception ex) { SystemlogMgr.Error("欧洲杯获取我的竞猜活动", ex); response.Code = (int)MessageCode.NbParameterError; } return(response); }
/// <summary> /// 获取我的竞猜信息 /// </summary> /// <param name="managerId"></param> /// <returns></returns> private EuropeGambleEntity GetMyGambleInfo(Guid managerId) { DateTime date = DateTime.Now; var gambleInfo = EuropeGambleMgr.GetById(managerId); if (gambleInfo == null) { gambleInfo = new EuropeGambleEntity(managerId, 0, "0,0,0,0", date, date, this.Season); EuropeGambleMgr.Insert(gambleInfo); } 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.UpdateTime = date; EuropeGambleMgr.Update(gambleInfo); } return(gambleInfo); }
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="step"></param> /// <returns></returns> public EuropeGambleMatchResponse DrawPrize(Guid managerId, int step) { EuropeGambleMatchResponse response = new EuropeGambleMatchResponse(); response.Data = new EuropeGambleMatch(); try { var manager = ManagerCore.Instance.GetManager(managerId); if (manager == null) { response.Code = (int)MessageCode.MissManager; return(response); } var info = GetMyGambleInfo(managerId); var prizeList = info.PrizeRecord.Split(','); if (prizeList.Length < step || prizeList[step - 1] == "0") { response.Code = (int)MessageCode.TourNoPassPrize; return(response); } if (prizeList[step - 1] == "2") { response.Code = (int)MessageCode.NbPrizeRepeat; return(response); } var prizeConfig = EuropeConfig.Instance.GetPrize(step); if (prizeConfig.Count <= 0) { response.Code = (int)MessageCode.ActivityNoConfigPrize; return(response); } ItemPackageFrame package = null; prizeList[step - 1] = "2"; info.PrizeRecord = String.Join(",", prizeList); info.UpdateTime = DateTime.Now; int addPoint = 0; int addCoin = 0; foreach (var prize in prizeConfig) { switch (prize.PrizeType) { case 1: addPoint += prize.PrizeCount; break; case 2: addCoin += prize.PrizeCount; break; case 3: if (package == null) { package = ItemCore.Instance.GetPackage(managerId, Entity.Enums.Shadow.EnumTransactionType.EuropeConfig); if (package == null) { return(ResponseHelper.Create <EuropeGambleMatchResponse>(MessageCode.NbNoPackage)); } } package.AddItems(prize.PrizeCode, prize.PrizeCount); break; } } if (addCoin > 0) { ManagerUtil.AddManagerData(manager, 0, addCoin, 0, EnumCoinChargeSourceType.Eruope, ShareUtil.GenerateComb().ToString()); } using (var transactionManager = new TransactionManager(Dal.ConnectionFactory.Instance.GetDefault())) { transactionManager.BeginTransaction(); var code = MessageCode.FailUpdate; do { if (addPoint > 0) { code = PayCore.Instance.AddBonus(managerId, addPoint, EnumChargeSourceType.Europe, ShareUtil.GenerateComb().ToString(), transactionManager.TransactionObject); if (code != MessageCode.Success) { break; } } if (addCoin > 0) { if (!ManagerUtil.SaveManagerData(manager, null, transactionManager.TransactionObject)) { break; } } if (package != null) { if (!package.Save(transactionManager.TransactionObject)) { break; } package.Shadow.Save(); } if (!EuropeGambleMgr.Update(info, transactionManager.TransactionObject)) { break; } code = MessageCode.Success; } while (false); if (code != MessageCode.Success) { transactionManager.Rollback(); response.Code = (int)MessageCode.GamblePayError; return(response); } transactionManager.Commit(); response.Data.Point = PayCore.Instance.GetPoint(managerId); } } catch (Exception ex) { SystemlogMgr.Error("领取竞猜正确活动奖励", ex); response.Code = (int)MessageCode.NbParameterError; } return(response); }