Ejemplo n.º 1
0
        protected readonly MessageService mMessageService;                           //消息处理类
        public BetDetailsCalculate_Auto()
        {
            IDbContextFactory factory = new DbContextFactory();

            this.mBetDetailService        = new BetDetailService(new Repo <BetDetail>(factory));
            this.mSysCatchNumService      = new SysCatchNumService(new Repo <CatchNum>(factory));
            this.mSysCatchNumIssueService = new SysCatchNumIssueService(new Repo <CatchNumIssue>(factory));

            Ytg.Comm.IHasher hasher = new Ytg.Comm.Hasher();

            var sysUser = new SysUserService(new Repo <SysUser>(factory), hasher);

            mMessageService = new MessageService(new Repo <Message>(factory));

            this.mSysUserBalanceService       = new SysUserBalanceService(new Repo <SysUserBalance>(factory), hasher, sysUser);
            this.mSysUserBalanceDetailService = new SysUserBalanceDetailService(new Repo <SysUserBalanceDetail>(factory), this.mSysUserBalanceService);

            mRebateHelper = new Service.Logic.RebateHelper(sysUser, this.mSysUserBalanceService, this.mSysUserBalanceDetailService);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 追号处理模块
        /// </summary>
        /// <param name="obj"></param>
        protected void CalculateCatchPage(object obj)
        {
            PoolCatchParam param = obj as PoolCatchParam;

            if (param.WhileIndex > 3)
            {
                string betCodes = "";
                param.Details.ForEach(x => betCodes += x.CatchNumCode);
                LogManager.Error("追号超过三次计算,结束计算:" + betCodes);
                return;
            }

            string issueCode  = param.Issue;
            string openResult = param.openResult;
            string key        = param.lotteryCode + "_" + param.Issue;

            List <BasicModel.LotteryBasic.DTO.NotCompledCatchNumListDTO> source      = param.Details;
            List <BasicModel.LotteryBasic.DTO.NotCompledCatchNumListDTO> errorSource = new List <NotCompledCatchNumListDTO>();

            IDbContextFactory factory   = new DbContextFactory();
            var sysCatchNumIssueService = new SysCatchNumIssueService(new Repo <CatchNumIssue>(factory));
            var sysCatchNumService      = new SysCatchNumService(new Repo <CatchNum>(factory));

            foreach (var item in source)
            {
                int code = item.PalyRadioCode;
                try
                {
                    ICalculate calculate = RadioContentFactory.CreateInstance(code);

                    var betDetail = new BetDetail()
                    {
                        BackNum       = item.BackNum,
                        BetContent    = item.BetContent,
                        BetCount      = item.BetCount,
                        BonusLevel    = item.BonusLevel,
                        IsMatch       = item.IsMatch,
                        IssueCode     = item.IssueCode,
                        Model         = item.Model,
                        Multiple      = item.Multiple,
                        OpenResult    = item.OpenResult,
                        PalyRadioCode = item.PalyRadioCode,
                        PrizeType     = item.PrizeType,
                        TotalAmt      = item.TotalAmt,
                        UserId        = item.UserId,
                        // WinMoney = item.WinMoney,
                    };
                    calculate.Calculate(issueCode, openResult, betDetail);
                    //获取追号信息
                    var catchItem = sysCatchNumService.Get(item.Id);
                    //获取追号当期信息
                    var catchNumItem = sysCatchNumIssueService.Get(item.CuiId);
                    if (betDetail.IsMatch)
                    {
                        catchNumItem.Stauts   = BasicModel.BetResultType.Winning;
                        catchNumItem.WinMoney = betDetail.WinMoney;
                        catchItem.WinIssue   += 1;

                        string content = string.Format("\t编号为【{0}】的方案已中奖 <span style=\"color:red;\">{1}</span> 元,请注意查看您的帐变信息,如有任何疑问请联系在线客服。\t\n", item.CatchNumCode, string.Format("{0:N}", catchNumItem.WinMoney));
                        //messageService.Create();
                        //messageService.Save();
                        LotteryIssuesData.CreateMessage(CreateMsg(content, 0, item.UserId, 1));
                    }
                    else
                    {
                        catchNumItem.Stauts = BasicModel.BetResultType.NotWinning;
                    }

                    //
                    //catchNumItem.OccDate = DateTime.Now;
                    catchNumItem.IsMatch    = betDetail.IsMatch;
                    catchNumItem.OpenResult = openResult;



                    if (betDetail.IsMatch && item.IsAutoStop)//中奖,并且设置为中奖后自动结束
                    {
                        catchItem.Stauts = BasicModel.CatchNumType.Compled;
                    }

                    catchItem.WinMoney      = catchItem.WinMoney + betDetail.WinMoney;
                    catchItem.CompledIssue  = catchItem.CompledIssue + 1;
                    catchItem.CompledMonery = catchItem.CompledMonery + catchNumItem.TotalAmt;

                    //修改信息
                    sysCatchNumIssueService.Save();
                    // sysCatchNumService.Save();
                    //修改未开奖追号期数occdate时间
                    sysCatchNumIssueService.UpdateNoOpenOccDateTime(item.CatchNumCode);

                    OpenOfficialCatchQueueParam queqeParam = new OpenOfficialCatchQueueParam(); //处理队列
                    queqeParam.CatchDetail   = item;
                    queqeParam.CatchNumIssue = catchNumItem;                                    //当前追号期数
                    if (catchItem.Stauts == CatchNumType.Compled)
                    {
                        //结束本次追号,对未完成追号的撤单
                        var exitNums = sysCatchNumIssueService.GetLastCatchNum(item.CatchNumCode, catchNumItem.IssueCode);
                        if (null == exitNums)
                        {
                            return;
                        }
                        int exitCount = exitNums.Count;
                        catchItem.SysCannelIssue = exitCount;//保存中奖后结束期数

                        //修改结束期数状态
                        foreach (var exit in exitNums)
                        {
                            exit.Stauts = BetResultType.SysCancel;
                            catchItem.UserCannelMonery += exit.TotalAmt;
                        }
                        sysCatchNumIssueService.Save();         //保存状态
                        queqeParam.ExitCatNumIssues = exitNums; //终止追号期数
                    }
                    else if ((catchItem.CompledIssue + catchItem.SysCannelIssue + catchItem.UserCannelIssue) >= catchItem.CatchIssue)
                    {
                        //验证是否有剩余期数,若无剩余期数,本次追号完成
                        catchItem.Stauts = CatchNumType.Compled;
                    }
                    sysCatchNumService.Save();
                    //添加至队列
                    OpenOfficialCatchQueue.CreateInstance().Put(queqeParam);
                }
                catch (Exception ex)
                {
                    LogManager.Error(string.Format("第{0}期,追号项id为{1} 计算过程中发生异常;", issueCode, item.Id), ex);
                    errorSource.Add(item);
                }

                int errorCount = errorSource.Count;
                if (errorCount > 0)
                {
                    param.Details = errorSource;
                    //继续计算
                    param.WhileIndex += 1;
                    CalculatePage(param);
                    LogManager.Info("追号计算失败项总数为" + errorCount + " 系统将继续计算!");
                }
                //完成计算
                IssueCatchNumsing.CreateInstance().CompledRunning(key, param.pageIndex);
            }
        }