예제 #1
0
        /// <summary>
        /// 计算投注结果
        /// </summary>
        /// <param name="issueCode">当前期号</param>
        /// <param name="openResult">开奖结果</param>
        private void CalculateBetting(string lotteryCode, string issueCode, string openResult)
        {
            //获取本期所有投注数据,进行计算
            var source = this.mBetDetailService.GetIssuesBetDetail(lotteryCode, issueCode);

            if (null == source)
            {
                return;
            }

            //循环进行计算
            foreach (var item in source)
            {
                int code = item.PalyRadioCode;
                try
                {
                    ICalculate calculate = RadioContentFactory.CreateInstance(code);
                    LogManager.Info(string.Format("创建ICalculate code={0}; 对象为{1}", code, calculate.GetType().ToString()));
                    calculate.Calculate(issueCode, ManagerOpenResult(openResult), item);
                    item.OpenResult = openResult;
                    if (item.IsMatch)
                    {
                        item.Stauts = BasicModel.BetResultType.Winning;
                        //记录,更新用户余额
                        this.mRebateHelper.UpdateUserBanance(item.UserId, item.WinMoney, TradeType.奖金派送, item.BetCode, 0);

                        //插入中奖消息
                        mMessageService.Create(CreateMsg(item.BetCode, item.WinMoney, item.UserId, 0));
                        this.mMessageService.Save();
                    }
                    else
                    {
                        item.Stauts = BasicModel.BetResultType.NotWinning;
                    }
                    //计算返点
                    //if (item.PrizeType == 1)
                    //{
                    this.mRebateHelper.BettingCalculate(item.PrizeType, item.UserId, item.TotalAmt, item.BetCode, mRebateHelper.GetRadioMaxRemo(item.PalyRadioCode, item.BonusLevel));
                    //}
                }
                catch (Exception ex)
                {
                    LogManager.Error(string.Format("第{0}期,投注明细项id为{1} 计算过程中发生异常;Exception={2}", issueCode, item.Id, ex.Message));
                }
            }
            this.mBetDetailService.Save();
        }
예제 #2
0
        /// <summary>
        /// 计算投注结果
        /// </summary>
        /// <param name="issueCode">当前开奖期号</param>
        /// <param name="openResult">当前开奖结果</param>
        private void CalculateCatchNums(string lotteryCode, string issueCode, string openResult)
        {
            //获取所有未完成的追号记录
            var source = this.mSysCatchNumService.GetNotCompledCatchNumList(lotteryCode, issueCode);

            if (null == source)
            {
                return;
            }
            //循环进行计算
            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 catchNumItem = this.mSysCatchNumIssueService.Get(item.CuiId);
                    if (betDetail.IsMatch)
                    {
                        catchNumItem.Stauts   = BasicModel.BetResultType.Winning;
                        catchNumItem.WinMoney = betDetail.WinMoney;

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

                    //计算返点 游戏返点
                    //if ( == 1)
                    this.mRebateHelper.BettingCalculate(item.PrizeType, item.UserId, item.TotalAmt, catchNumItem.CatchNumIssueCode, mRebateHelper.GetRadioMaxRemo(item.PalyRadioCode, item.BonusLevel));
                    //
                    catchNumItem.IsMatch    = betDetail.IsMatch;
                    catchNumItem.OpenResult = openResult;

                    //获取追号信息
                    var catchItem = this.mSysCatchNumService.Get(item.Id);
                    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;

                    //修改信息
                    this.mSysCatchNumIssueService.Save();
                    this.mSysCatchNumService.Save();

                    if (catchItem.Stauts == CatchNumType.Compled)
                    {
                        //结束本次追号,对未完成追号的撤单
                        var exitNums = this.mSysCatchNumIssueService.GetLastCatchNum(item.CatchNumCode, catchNumItem.IssueCode);
                        if (null == exitNums)
                        {
                            return;
                        }
                        //用户余额

                        int exitCount = exitNums.Count;
                        catchItem.SysCannelIssue = exitCount;//保存中奖后结束期数
                        this.mSysCatchNumService.Save();

                        for (var i = 0; i < exitCount; i++)
                        {
                            var exit = exitNums[i];
                            if (catchItem.PrizeType == 1)
                            {
                                mRebateHelper.BettingCannelIssue(item.UserId, exit.TotalAmt, exit.CatchNumIssueCode, mRebateHelper.GetRadioMaxRemo(item.PalyRadioCode, item.BonusLevel));//处理返点
                            }
                            else
                            {
                                this.mRebateHelper.UpdateUserBanance(item.UserId, item.TotalAmt, TradeType.追号返款, exit.CatchNumIssueCode, 0);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogManager.Error(string.Format("第{0}期,追号项id为{1} 计算过程中发生异常;Exception={2}", issueCode, item.Id, ex.Message));
                }
            }
        }
        /// <summary>
        /// 分分彩必须保证利润,目前的做法是随机五个号码,计算中奖金额然后保证利润后才开指定数字
        /// </summary>
        /// <param name="lotteryType"></param>
        /// <param name="issueCode"></param>
        /// <param name="openResult"></param>
        public override string Calculate(string lotteryType, string issueCode, string openResult)
        {
            //获取本期所有投注数据,进行计算
            var source = this.mBetDetailService.GetIssuesBetDetail(lotteryType, issueCode);
            //获取追号数据,进行计算
            var zhuiHaoSource = this.mSysCatchNumService.GetNotCompledCatchNumList(lotteryType, issueCode);

            if ((source == null || source.Count < 1) && (zhuiHaoSource == null || zhuiHaoSource.Count < 1))
            {
                //没有投注,随机开
                openResult = RandomResult(lotteryType);
                LogManager.Info(string.Format("自主开奖=====没有投注和追号项,随机开奖={0}", openResult));
                return(openResult);
            }
            int  sourceCount  = source.Count + zhuiHaoSource.Count;
            bool isMaxBaseAmt = false;//投注金额是否大于奖金

            decimal[] models = { 1M, 0.1M, 0.01M, 0.001M };
            //计算本期最低保证利润
            var sum = source.Sum(c => c.TotalAmt) + zhuiHaoSource.Sum(c => c.TotalAmt);

            var total = sum * (1 - ConfigHelper.ProfitMargin) + OpendHistoryLogic.CreateInstance().GetWinMonery(lotteryType);//当期可以释放的金额

            LogManager.Error(lotteryType + "利润空间:" + total);
            List <string> openHistory = new List <string>();//开奖历史记录,开过的不冲去计算

            string bettMsg = "";
            /***检测代码,正式上线注释**/
            Stopwatch stopwatch = new Stopwatch(); //计时

            stopwatch.Start();                     //  开始监视代码运行时间
            /***检测代码,正式上线注释**/

            int whileCount = 0;

            while (true)
            {
                string randomOpen = RandomResult(lotteryType);
                if (openHistory.Contains(randomOpen))
                {
                    continue;
                }
                openHistory.Add(randomOpen);

                //投注中奖金额
                var bettingWinTotal = 0m;
                openResult = randomOpen; //string.Join(",", randomOpen.Select(c => c.ToString()));

                //循环进行计算普通投注中奖金额
                foreach (var item in source)
                {
                    int code = item.PalyRadioCode;
                    item.WinMoney = 0;
                    item.IsMatch  = false;
                    Ytg.Scheduler.Comm.Bets.ICalculate calculate = Ytg.Scheduler.Comm.Bets.RadioContentFactory.CreateInstance(code);
                    calculate.Calculate(issueCode, openResult, item);
                    item.OpenResult = openResult;
                    if (item.IsMatch)
                    {
                        item.Stauts      = BasicModel.BetResultType.Winning;
                        bettingWinTotal += item.WinMoney;
                    }
                    else
                    {
                        item.Stauts = BasicModel.BetResultType.NotWinning;
                    }
                    isMaxBaseAmt = item.TotalAmt >= calculate.GetBaseAmt(item) * models[item.Model];
                }
                //追号
                foreach (var item in zhuiHaoSource)
                {
                    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,
                    };
                    ICalculate calculate = RadioContentFactory.CreateInstance(betDetail.PalyRadioCode);
                    calculate.Calculate(issueCode, openResult, betDetail);
                    item.OpenResult = openResult;
                    item.WinMoney   = betDetail.WinMoney;
                    if (betDetail.IsMatch)
                    {
                        bettingWinTotal += betDetail.WinMoney;
                    }
                    isMaxBaseAmt = item.TotalAmt >= calculate.GetBaseAmt(betDetail);
                }

                LogManager.Error(string.Format("尝试自主开奖 issueCode:{0} bettingWinTotal:{1} total:{2} isMaxBaseAmt:{3} sourceCount:{4} whileCount:{5} lotteryType:{6}", issueCode, bettingWinTotal, total, isMaxBaseAmt, source, whileCount, lotteryType));
                whileCount++;

                if (
                    (total - bettingWinTotal > 0) ||
                    (isMaxBaseAmt && sourceCount < 1) ||
                    (whileCount > 50 && sum >= bettingWinTotal)) //符合指定利润,开奖
                {                                                //=开奖信息=返钱:33218.00000000RMB  投注总额:4250.0000RMB  最低40%利润:-21768.00000000RMB
                    bettMsg = "返钱:" + bettingWinTotal + "RMB  投注总额:" + sum + "RMB  最低40%利润:" + (total - bettingWinTotal) + "RMB  wileCount" + whileCount + " " + lotteryType + " \t\n";
                    //修改期数
                    //处理开奖逻辑 普通投注
                    CalculateBetting(source, issueCode, openResult);
                    //追号
                    CalculateCatchNums(zhuiHaoSource, issueCode, openResult);
                    OpendHistoryLogic.CreateInstance().PutLotteryData(lotteryType, sum, bettingWinTotal);
                    LogManager.Error(string.Format("自主开奖成功,开奖结果={0}=========开奖信息={1}", openResult, bettMsg));
                    break;
                }
                if (whileCount > 50)
                {
                    sum += 500;
                }
            }
            /***检测代码,正式上线注释**/
            TimeSpan timespan     = stopwatch.Elapsed;          //  获取当前实例测量得出的总时间
            double   milliseconds = timespan.TotalMilliseconds; //  总毫秒数

            stopwatch.Stop();
            /***检测代码,正式上线注释**/

            //bettMsg += "分分彩:" + lotteryType + " 期数:" + issueCode + " 总毫秒数:" + milliseconds;
            //  LogManager.Error(bettMsg);

            return(openResult);
        }
        /// <summary>
        /// 计算投注结果
        /// </summary>
        /// <param name="issueCode">当前开奖期号</param>
        /// <param name="openResult">当前开奖结果</param>
        private void CalculateCatchNums(List <NotCompledCatchNumListDTO> source, string issueCode, string openResult)
        {
            //循环进行计算
            foreach (var item in source)
            {
                try
                {
                    item.WinMoney = 0;
                    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,
                    };
                    ICalculate calculate = RadioContentFactory.CreateInstance(betDetail.PalyRadioCode);
                    calculate.Calculate(issueCode, openResult, betDetail);
                    item.OpenResult = openResult;
                    item.WinMoney   = betDetail.WinMoney;
                    item.IsMatch    = betDetail.IsMatch;

                    //获取追号信息
                    var catchItem = this.mSysCatchNumService.Get(item.Id);
                    // //获取追号当期信息
                    var catchNumItem = this.mSysCatchNumIssueService.Get(item.CuiId);
                    if (item.IsMatch)
                    {
                        catchNumItem.Stauts   = BasicModel.BetResultType.Winning;
                        catchNumItem.WinMoney = item.WinMoney;
                        catchItem.WinIssue   += 1;

                        this.mRebateHelper.UpdateUserBanance(item.UserId, item.WinMoney, TradeType.奖金派送, catchNumItem.CatchNumIssueCode, 0);

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

                    //计算返点 游戏返点
                    //if (item.PrizeType == 1)
                    this.mRebateHelper.BettingCalculate(item.PrizeType, item.UserId, item.TotalAmt, catchNumItem.CatchNumIssueCode, mRebateHelper.GetRadioMaxRemo(item.PalyRadioCode, item.BonusLevel));
                    //
                    //catchNumItem.OccDate = DateTime.Now;
                    catchNumItem.IsMatch    = item.IsMatch;
                    catchNumItem.OpenResult = item.OpenResult;


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


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

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


                    if (catchItem.Stauts == CatchNumType.Compled)
                    {
                        //结束本次追号,对未完成追号的撤单
                        var exitNums = this.mSysCatchNumIssueService.GetLastCatchNum(item.CatchNumCode, catchNumItem.IssueCode);
                        if (null == exitNums)
                        {
                            return;
                        }

                        int exitCount = exitNums.Count;
                        catchItem.SysCannelIssue = exitCount;//保存中奖后结束期数
                        //this.mSysCatchNumService.Save();

                        for (var i = 0; i < exitCount; i++)
                        {
                            var exit = exitNums[i];
                            exit.Stauts = BetResultType.SysCancel;
                            catchItem.UserCannelMonery += exit.TotalAmt;
                            this.mRebateHelper.UpdateUserBanance(item.UserId, exit.TotalAmt, TradeType.追号返款, exit.CatchNumIssueCode, 0);
                        }
                    }
                    else if ((catchItem.CompledIssue + catchItem.SysCannelIssue + catchItem.UserCannelIssue) >= catchItem.CatchIssue)
                    {
                        //验证是否有剩余期数,若无剩余期数,本次追号完成
                        catchItem.Stauts = CatchNumType.Compled;
                    }
                    mSysCatchNumIssueService.Save();//保存状态
                    this.mSysCatchNumService.Save();
                }
                catch (Exception ex)
                {
                    LogManager.Error("分分彩异常" + ex.Message);
                }
            }
        }
예제 #5
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);
            }
        }
예제 #6
0
        private void CalculatePage(object obj)
        {
            PoolParam param = obj as PoolParam;
            string    key   = param.lotteryCode + "_" + param.Issue;

            if (param == null)
            {
                LogManager.Info("PoolParam 为null,直接返回!");
                return;
            }
            if (param.WhileIndex > 3)
            {
                string betCodes = "";
                param.Details.ForEach(x => betCodes += x.BetCode);
                LogManager.Error("投注超过三次计算,结束计算:" + betCodes);
                return;
            }
            string issueCode  = param.Issue;
            string openResult = param.openResult;

            LogManager.Info("开始计算结果:" + param.ToString());
            //IDbContextFactory factory = new DbContextFactory();
            //var betDetailService = new BetDetailService(new Repo<BetDetail>(factory));
            //var messageService = new MessageService(new Repo<Message>(factory));

            List <BetDetail> source      = param.Details;
            List <BetDetail> errorSource = new List <BetDetail>();

            //循环进行计算
            foreach (var item in source)
            {
                int code = item.PalyRadioCode;
                try
                {
                    ICalculate calculate = RadioContentFactory.CreateInstance(code);
                    LogManager.Info(string.Format("创建ICalculate code={0}; 对象为{1}", code, calculate.GetType().ToString()));
                    calculate.Calculate(issueCode, openResult, item);
                    item.OpenResult = openResult;
                    if (item.IsMatch)
                    {
                        item.Stauts = BasicModel.BetResultType.Winning;
                        //插入中奖消息
                        // messageService.Create(CreateMsg(item.BetCode, item.WinMoney, item.UserId, 0));
                        //messageService.Save();
                        LotteryIssuesData.CreateMessage(CreateMsg(item.BetCode, item.WinMoney, item.UserId, 0));
                    }
                    else
                    {
                        item.Stauts = BasicModel.BetResultType.NotWinning;
                        if (item.IsBuyTogether == 1)
                        {
                            //修改子项为未中奖
                            LotteryIssuesData.UpdateBuyTogerher(item.Id, 2, 0m);
                        }
                    }

                    OpenOfficialQueue.CreateInstance().Put(item);//添加至更新队列 计算返点以及余额
                    //保存状态
                    // betDetailService.UpdateOpenState(item);
                    if (!LotteryIssuesData.UpdateOpenState(item))
                    {
                        errorSource.Add(item);
                    }
                }
                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 + " 系统将继续计算!");
            }

            //betDetailService.Save();
            LogManager.Info("计算结果结束:" + param.ToString());


            //完成计算
            IssueBettingNumsing.CreateInstance().CompledRunning(key, param.pageIndex);
        }