示例#1
0
        /// <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);
        }
示例#2
0
        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("保存失败");
                }
            }
        }
示例#3
0
        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();
                    }
                }
            }
        }