Ejemplo n.º 1
0
        public CommonActionResult Sports_Betting(Sports_BetingInfo info, string password, decimal redBagMoney, string userid)
        {
            try
            {
                //检查彩种是否暂停销售
                KaSon.FrameWork.ORM.Helper.BusinessHelper.CheckGameEnable(info.GameCode.ToUpper());
                BettingHelper.CheckGameCodeAndType(info.GameCode, info.GameType);
                // 验证用户身份及权限
                //var userId = GameBizAuthBusiness.ValidateUserAuthentication(userToken);

                //栓查是否实名
                //if (!BusinessHelper.IsUserValidateRealName(userId))
                //    throw new LogicException("未实名认证用户不能购买彩票");

                CheckJCRepeatBetting(userid, info);
                //检查投注内容,并获取投注注数
                var totalCount = BusinessHelper.CheckBetCode(userid, info.GameCode.ToUpper(), info.GameType.ToUpper(), info.SchemeSource, info.PlayType, info.Amount, info.TotalMoney, info.AnteCodeList);
                //检查投注的比赛,并获取最早结束时间
                var stopTime = RedisMatchBusiness.CheckGeneralBettingMatch(info.GameCode.ToUpper(), info.GameType.ToUpper(), info.PlayType, info.AnteCodeList, info.IssuseNumber, info.BettingCategory);

                string schemeId = string.Empty;
                //lock (UsefullHelper.moneyLocker)
                //{
                schemeId = new Sports_Business().SportsBetting(info, userid, password, "Bet", totalCount, stopTime, redBagMoney);
                //}
                //! 执行扩展功能代码 - 提交事务后
                BusinessHelper.ExecPlugin <IBettingSport_AfterTranCommit>(new object[] { userid, info, schemeId });

                return(new CommonActionResult
                {
                    IsSuccess = true,
                    ReturnValue = schemeId + "|" + info.TotalMoney,
                    Message = "足彩投注成功",
                });
            }
            //catch (AggregateException ex)
            //{
            //    throw new AggregateException(ex.Message);
            //}
            catch (LogicException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new Exception("订单投注异常,请重试 ", ex);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 查询宝单详情
        /// </summary>
        public BDFXOrderDetailInfo QueryBDFXOrderDetailBySchemeId(string schemeId)
        {
            var BDFXManager    = new BDFXManager();
            var sportsBusiness = new Sports_Business();

            var orderDetailInfo = BDFXManager.QueryBDFXOrderDetailBySchemeId(schemeId);

            if (orderDetailInfo != null && !string.IsNullOrEmpty(orderDetailInfo.SchemeId))
            {
                orderDetailInfo.AnteCodeCollection           = new Sports_AnteCodeQueryInfoCollection();
                orderDetailInfo.AnteCodeList                 = new List <AnteCodeInfo>();
                orderDetailInfo.NearTimeProfitRateCollection = new NearTimeProfitRate_Collection();
                var anteCodeCollection = sportsBusiness.QuerySportsOrderAnteCodeList(schemeId);
                if (anteCodeCollection != null)
                {
                    orderDetailInfo.AnteCodeCollection = anteCodeCollection;
                }
                var nearTimeProfitInfo = BDFXManager.QueryNearTimeProfitRate(orderDetailInfo.UserId);
                if (nearTimeProfitInfo != null)
                {
                    orderDetailInfo.NearTimeProfitRateCollection.NearTimeProfitRateList.AddRange(nearTimeProfitInfo);
                }

                var currTime = DateTime.Now;
                int day      = Convert.ToInt32(currTime.DayOfWeek) - 1;
                if (currTime.DayOfWeek != 0)
                {
                    currTime = currTime.AddDays(-day);
                }
                else
                {
                    currTime = currTime.AddDays(-6);
                }
                var startTime  = currTime.AddDays(-7).Date;
                var endTime    = currTime.Date;
                var rankNumber = BDFXManager.QueryRankNumber(orderDetailInfo.UserId);
                orderDetailInfo.RankNumber = rankNumber;
                var anteCodeList = BDFXManager.QueryAnteCodeListBySchemeId(schemeId);
                if (anteCodeList != null && anteCodeList.Count > 0)
                {
                    orderDetailInfo.AnteCodeList = anteCodeList;
                }
            }

            return(orderDetailInfo);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 足彩投注,用户保存的订单
        /// </summary>
        public CommonActionResult SaveOrderSportsBettingByResult(Sports_BetingInfo info, string userid)
        {
            // 验证用户身份及权限
            //var userId = GameBizAuthBusiness.ValidateUserAuthentication(userToken);

            try
            {
                //栓查是否实名
                //if (!BusinessHelper.IsUserValidateRealName(userId))
                //    throw new LogicException("未实名认证用户不能购买彩票");

                CheckDisableGame(info.GameCode, info.GameType);
                BettingHelper.CheckGameCodeAndType(info.GameCode, info.GameType);

                // 检查订单基本信息
                BettingHelper.CheckSchemeOrder(info);

                string schemeId = new Sports_Business().SaveOrderSportsBetting(info, userid);

                //! 执行扩展功能代码 - 提交事务后
                BusinessHelper.ExecPlugin <IBettingSport_AfterTranCommit>(new object[] { userid, info, schemeId });

                return(new CommonActionResult
                {
                    IsSuccess = true,
                    ReturnValue = schemeId + "|" + info.TotalMoney,
                    Message = "保存订单成功",
                });
            }
            catch (LogicException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw new Exception("保存订单异常,请重试 ", ex);
            }
        }
Ejemplo n.º 4
0
        public void PrizeBJDCTicket_OrderId(string orderId)
        {
            using (var biz = new GameBizBusinessManagement())
            {
                biz.BeginTran();

                var manager        = new Sports_Manager();
                var ticketListInfo = manager.QueryPrizeTicket_OrderIdList("BJDC", orderId);
                var ticketStrSql   = string.Empty;
                foreach (var ticket in ticketListInfo.TicketList)
                {
                    if (ticket.TicketStatus != TicketStatus.Ticketed)
                    {
                        continue;
                    }

                    var preTaxBonusMoney   = 0M;
                    var afterTaxBonusMoney = 0M;

                    var bonusCount = 0;
                    var collection = new GatewayAnteCodeCollection_Sport();
                    var codeList   = new List <Ticket_AnteCode_Running>();
                    //100_3/101_1
                    foreach (var item in ticket.BetContent.Split('/'))
                    {
                        var oneMatch = item.Split('_');
                        codeList.Add(new Ticket_AnteCode_Running
                        {
                            MatchId      = oneMatch[0],
                            IssuseNumber = ticket.IssuseNumber,
                            AnteNumber   = oneMatch[1],
                            IsDan        = false,
                            GameType     = ticket.GameType,
                        });
                        collection.Add(new GatewayAnteCode_Sport
                        {
                            AnteCode = oneMatch[1],
                            MatchId  = oneMatch[0],
                            GameType = ticket.GameType,
                            IsDan    = false
                        });
                    }

                    var n = int.Parse(ticket.PlayType.Replace("P", "").Split('_')[1]);
                    if (n > 1)
                    {
                        #region M串N
                        var orderEntity = new Sports_Business().AnalyzeOrder_Sport_Prize <Ticket_Order_Running, Ticket_Ticket_Running, Ticket_AnteCode_Running>(new GatewayTicketOrder_Sport
                        {
                            Amount         = ticket.Amount,
                            AnteCodeList   = collection,
                            Attach         = string.Empty,
                            GameCode       = ticket.GameCode,
                            GameType       = ticket.GameType,
                            IssuseNumber   = ticket.IssuseNumber,
                            IsVirtualOrder = false,
                            OrderId        = ticket.SchemeId,
                            PlayType       = ticket.PlayType.Replace("P", ""),
                            Price          = 2,
                            UserId         = string.Empty,
                            TotalMoney     = ticket.BetMoney
                        }, "LOCAL", "agentId");

                        foreach (var ticket_cp in orderEntity.GetTicketList())
                        {
                            var matchIdL = (from c in ticket_cp.GetAnteCodeList() select c.MatchId).ToArray();
                            var codeL    = codeList.Where(p => matchIdL.Contains(p.MatchId)).ToArray();

                            var analyzer    = AnalyzerFactory.GetSportAnalyzer(ticket_cp.GameCode, ticket_cp.GameType, int.Parse(ticket_cp.PlayType.Replace("P", "").Split('_')[0]));
                            var bonusResult = analyzer.CaculateBonus(codeL.ToArray(), ticketListInfo.MatchList.ToArray());
                            if (bonusResult.IsWin)
                            {
                                bonusCount += bonusResult.BonusCount;
                                for (var i = 0; i < bonusResult.BonusCount; i++)
                                {
                                    var matchIdList         = bonusResult.BonusHitMatchIdListCollection[i];
                                    var sps                 = GetSPs(ticket_cp.GameCode, ticket_cp.GameType, ticket_cp.IssuseNumber, matchIdList);
                                    var oneBeforeBonusMoney = 2M;
                                    var isTrue              = false;
                                    var num                 = 0;
                                    foreach (var item in sps)
                                    {
                                        if (item.Value == 1M)
                                        {
                                            num++;
                                            var entity        = codeL.Where(p => p.MatchIndex == int.Parse(item.Key)).FirstOrDefault();
                                            var anteCodeCount = entity.AnteCode.Split(',').Count();
                                            oneBeforeBonusMoney *= anteCodeCount;
                                            if (sps.Count == 1)
                                            {
                                                isTrue = true;
                                            }
                                        }
                                        else
                                        {
                                            oneBeforeBonusMoney *= item.Value;
                                        }
                                    }
                                    if (!isTrue && num != sps.Count)
                                    {
                                        oneBeforeBonusMoney *= 0.65M;    // 官方扣点 - 65%
                                    }
                                    oneBeforeBonusMoney = Math.Truncate(oneBeforeBonusMoney * 100) / 100;
                                    var oneAfterBonusMoney = oneBeforeBonusMoney;

                                    //北单奖金小于2元的 按2元计算
                                    if (oneBeforeBonusMoney < 2M)
                                    {
                                        oneBeforeBonusMoney = 2M;
                                        oneAfterBonusMoney  = 2M;
                                    }

                                    if (oneBeforeBonusMoney >= 10000)
                                    {
                                        oneAfterBonusMoney = oneBeforeBonusMoney * (1M - 0.2M);
                                    }
                                    oneBeforeBonusMoney *= ticket_cp.Amount;
                                    oneAfterBonusMoney  *= ticket_cp.Amount;

                                    preTaxBonusMoney   += oneBeforeBonusMoney;
                                    afterTaxBonusMoney += oneAfterBonusMoney;
                                }
                            }
                        }

                        //单票金额上限
                        if (afterTaxBonusMoney >= 5000000M)
                        {
                            afterTaxBonusMoney = 5000000M;
                        }

                        #endregion
                    }
                    else
                    {
                        #region M串1
                        var analyzer    = AnalyzerFactory.GetSportAnalyzer(ticket.GameCode, ticket.GameType, int.Parse(ticket.PlayType.Replace("P", "").Split('_')[0]));
                        var bonusResult = analyzer.CaculateBonus(codeList.ToArray(), ticketListInfo.MatchList.ToArray());
                        if (bonusResult.IsWin)
                        {
                            bonusCount += bonusResult.BonusCount;
                            for (var i = 0; i < bonusResult.BonusCount; i++)
                            {
                                var matchIdList         = bonusResult.BonusHitMatchIdListCollection[i];
                                var sps                 = GetSPs(ticket.GameCode, ticket.GameType, ticket.IssuseNumber, matchIdList);
                                var oneBeforeBonusMoney = 2M;
                                var isTrue              = false;
                                var num                 = 0;
                                foreach (var item in sps)
                                {
                                    if (item.Value == 1M)
                                    {
                                        num++;
                                        var entity        = codeList.Where(p => p.MatchIndex == int.Parse(item.Key)).FirstOrDefault();
                                        var anteCodeCount = entity.AnteCode.Split(',').Count();
                                        oneBeforeBonusMoney *= anteCodeCount;
                                        if (sps.Count == 1)
                                        {
                                            isTrue = true;
                                        }
                                    }
                                    else
                                    {
                                        oneBeforeBonusMoney *= item.Value;
                                    }
                                }
                                if (!isTrue && num != sps.Count)
                                {
                                    oneBeforeBonusMoney *= 0.65M;    // 官方扣点 - 65%
                                }
                                oneBeforeBonusMoney = Math.Truncate(oneBeforeBonusMoney * 100) / 100;
                                var oneAfterBonusMoney = oneBeforeBonusMoney;

                                //北单奖金小于2元的 按2元计算
                                if (oneBeforeBonusMoney < 2M)
                                {
                                    oneBeforeBonusMoney = 2M;
                                    oneAfterBonusMoney  = 2M;
                                }

                                if (oneBeforeBonusMoney >= 10000)
                                {
                                    oneAfterBonusMoney = oneBeforeBonusMoney * (1M - 0.2M);
                                }
                                oneBeforeBonusMoney *= ticket.Amount;
                                oneAfterBonusMoney  *= ticket.Amount;

                                //单票金额上限
                                if (oneAfterBonusMoney >= 5000000M)
                                {
                                    oneAfterBonusMoney = 5000000M;
                                }

                                preTaxBonusMoney   += oneBeforeBonusMoney;
                                afterTaxBonusMoney += oneAfterBonusMoney;
                            }
                        }

                        #endregion
                    }

                    ticketStrSql += string.Format("update C_Sports_Ticket set PreTaxBonusMoney={0},AfterTaxBonusMoney={1},BonusStatus={2} where TicketId='{3}' {4}"
                                                  , preTaxBonusMoney, afterTaxBonusMoney, afterTaxBonusMoney > 0M ? Convert.ToInt32(BonusStatus.Win) : Convert.ToInt32(BonusStatus.Lose), ticket.TicketId, Environment.NewLine);
                }
                manager.ExecSql(ticketStrSql);

                biz.CommitTran();
            }
        }
Ejemplo n.º 5
0
        public string PrizeBJDCTicket(int num)
        {
            var successCount = 0;
            var failCount    = 0;
            var log          = new List <string>();

            try
            {
                var manager        = new Sports_Manager();
                var ticketListInfo = manager.QueryPrizeTicketList("BJDC", num);
                var prizeList      = new List <TicketBatchPrizeInfo>();
                //var ticketStrSql = string.Empty;
                foreach (var ticket in ticketListInfo.TicketList)
                {
                    try
                    {
                        if (ticket.TicketStatus != TicketStatus.Ticketed)
                        {
                            continue;
                        }

                        var preTaxBonusMoney   = 0M;
                        var afterTaxBonusMoney = 0M;
                        var bonusCount         = 0;
                        var codeList           = new List <Ticket_AnteCode_Running>();
                        var collection         = new GatewayAnteCodeCollection_Sport();
                        //100_3/101_1
                        foreach (var item in ticket.BetContent.Split('/'))
                        {
                            var oneMatch = item.Split('_');
                            codeList.Add(new Ticket_AnteCode_Running
                            {
                                MatchId      = oneMatch[0],
                                IssuseNumber = ticket.IssuseNumber,
                                AnteNumber   = oneMatch[1],
                                IsDan        = false,
                                GameType     = ticket.GameType,
                            });
                            collection.Add(new GatewayAnteCode_Sport
                            {
                                AnteCode = oneMatch[1],
                                MatchId  = oneMatch[0],
                                GameType = ticket.GameType,
                                IsDan    = false
                            });
                        }
                        var n = int.Parse(ticket.PlayType.Replace("P", "").Split('_')[1]);
                        if (n > 1)
                        {
                            #region M串N
                            var orderEntity = new Sports_Business().AnalyzeOrder_Sport_Prize <Ticket_Order_Running, Ticket_Ticket_Running, Ticket_AnteCode_Running>(new GatewayTicketOrder_Sport
                            {
                                Amount         = ticket.Amount,
                                AnteCodeList   = collection,
                                Attach         = string.Empty,
                                GameCode       = ticket.GameCode,
                                GameType       = ticket.GameType,
                                IssuseNumber   = ticket.IssuseNumber,
                                IsVirtualOrder = false,
                                OrderId        = ticket.SchemeId,
                                PlayType       = ticket.PlayType.Replace("P", ""),
                                Price          = 2,
                                UserId         = string.Empty,
                                TotalMoney     = ticket.BetMoney
                            }, "LOCAL", "agentId");

                            foreach (var ticket_cp in orderEntity.GetTicketList())
                            {
                                var matchIdL = (from c in ticket_cp.GetAnteCodeList() select c.MatchId).ToArray();
                                var codeL    = codeList.Where(p => matchIdL.Contains(p.MatchId)).ToArray();

                                var analyzer    = AnalyzerFactory.GetSportAnalyzer(ticket_cp.GameCode, ticket_cp.GameType, int.Parse(ticket_cp.PlayType.Replace("P", "").Split('_')[0]));
                                var bonusResult = analyzer.CaculateBonus(codeL.ToArray(), ticketListInfo.MatchList.ToArray());
                                if (bonusResult.IsWin)
                                {
                                    bonusCount += bonusResult.BonusCount;
                                    for (var i = 0; i < bonusResult.BonusCount; i++)
                                    {
                                        var matchIdList         = bonusResult.BonusHitMatchIdListCollection[i];
                                        var sps                 = GetSPs(ticket_cp.GameCode, ticket_cp.GameType, ticket_cp.IssuseNumber, matchIdList);
                                        var oneBeforeBonusMoney = 2M;
                                        var isTrue              = false;
                                        var num_q               = 0;
                                        foreach (var item in sps)
                                        {
                                            if (item.Value == 1M)
                                            {
                                                num_q++;
                                                var entity        = codeL.Where(p => p.MatchIndex == int.Parse(item.Key)).FirstOrDefault();
                                                var anteCodeCount = entity.AnteCode.Split(',').Count();
                                                oneBeforeBonusMoney *= anteCodeCount;
                                                if (sps.Count == 1)
                                                {
                                                    isTrue = true;
                                                }
                                            }
                                            else
                                            {
                                                oneBeforeBonusMoney *= item.Value;
                                            }
                                        }
                                        if (!isTrue && num_q != sps.Count)
                                        {
                                            oneBeforeBonusMoney *= 0.65M;    // 官方扣点 - 65%
                                        }
                                        oneBeforeBonusMoney = Math.Truncate(oneBeforeBonusMoney * 100) / 100;
                                        var oneAfterBonusMoney = oneBeforeBonusMoney;

                                        //北单奖金小于2元的 按2元计算
                                        if (oneBeforeBonusMoney < 2M)
                                        {
                                            oneBeforeBonusMoney = 2M;
                                            oneAfterBonusMoney  = 2M;
                                        }

                                        if (oneBeforeBonusMoney >= 10000)
                                        {
                                            oneAfterBonusMoney = oneBeforeBonusMoney * (1M - 0.2M);
                                        }
                                        oneBeforeBonusMoney *= ticket_cp.Amount;
                                        oneAfterBonusMoney  *= ticket_cp.Amount;

                                        preTaxBonusMoney   += oneBeforeBonusMoney;
                                        afterTaxBonusMoney += oneAfterBonusMoney;
                                    }
                                }
                            }

                            //单票金额上限
                            if (afterTaxBonusMoney >= 5000000M)
                            {
                                afterTaxBonusMoney = 5000000M;
                            }

                            #endregion
                        }
                        else
                        {
                            #region M串1
                            var analyzer    = AnalyzerFactory.GetSportAnalyzer(ticket.GameCode, ticket.GameType, int.Parse(ticket.PlayType.Replace("P", "").Split('_')[0]));
                            var bonusResult = analyzer.CaculateBonus(codeList.ToArray(), ticketListInfo.MatchList.ToArray());
                            if (bonusResult.IsWin)
                            {
                                bonusCount += bonusResult.BonusCount;
                                for (var i = 0; i < bonusResult.BonusCount; i++)
                                {
                                    var matchIdList         = bonusResult.BonusHitMatchIdListCollection[i];
                                    var sps                 = GetSPs(ticket.GameCode, ticket.GameType, ticket.IssuseNumber, matchIdList);
                                    var oneBeforeBonusMoney = 2M;
                                    var isTrue              = false;
                                    var num_q               = 0;
                                    foreach (var item in sps)
                                    {
                                        if (item.Value == 1M)
                                        {
                                            num_q++;
                                            var entity        = codeList.Where(p => p.MatchIndex == int.Parse(item.Key)).FirstOrDefault();
                                            var anteCodeCount = entity.AnteCode.Split(',').Count();
                                            oneBeforeBonusMoney *= anteCodeCount;
                                            if (sps.Count == 1)
                                            {
                                                isTrue = true;
                                            }
                                        }
                                        else
                                        {
                                            oneBeforeBonusMoney *= item.Value;
                                        }
                                    }
                                    if (!isTrue && num_q != sps.Count)
                                    {
                                        oneBeforeBonusMoney *= 0.65M;    // 官方扣点 - 65%
                                    }
                                    oneBeforeBonusMoney = Math.Truncate(oneBeforeBonusMoney * 100) / 100;
                                    var oneAfterBonusMoney = oneBeforeBonusMoney;

                                    //北单奖金小于2元的 按2元计算
                                    if (oneBeforeBonusMoney < 2M)
                                    {
                                        oneBeforeBonusMoney = 2M;
                                        oneAfterBonusMoney  = 2M;
                                    }

                                    if (oneBeforeBonusMoney >= 10000)
                                    {
                                        oneAfterBonusMoney = oneBeforeBonusMoney * (1M - 0.2M);
                                    }
                                    oneBeforeBonusMoney *= ticket.Amount;
                                    oneAfterBonusMoney  *= ticket.Amount;

                                    //单票金额上限
                                    if (oneAfterBonusMoney >= 5000000M)
                                    {
                                        oneAfterBonusMoney = 5000000M;
                                    }

                                    preTaxBonusMoney   += oneBeforeBonusMoney;
                                    afterTaxBonusMoney += oneAfterBonusMoney;
                                }
                            }

                            #endregion
                        }

                        //更新票数据sql
                        prizeList.Add(new TicketBatchPrizeInfo
                        {
                            //Id = item.Id,
                            TicketId    = ticket.TicketId,
                            BonusStatus = afterTaxBonusMoney > 0M ? BonusStatus.Win : BonusStatus.Lose,
                            PreMoney    = preTaxBonusMoney,
                            AfterMoney  = afterTaxBonusMoney,
                        });

                        //var ticketStrSql = string.Format("update C_Sports_Ticket set PreTaxBonusMoney={0},AfterTaxBonusMoney={1},BonusStatus={2} where TicketId='{3}' {4}"
                        //          , preTaxBonusMoney, afterTaxBonusMoney, afterTaxBonusMoney > 0M ? Convert.ToInt32(BonusStatus.Win) : Convert.ToInt32(BonusStatus.Lose), ticket.TicketId, Environment.NewLine);
                        //manager.ExecSql(ticketStrSql);
                        successCount++;
                    }
                    catch (Exception ex)
                    {
                        failCount++;
                        log.Add(ticket.TicketId + "派奖出错 - " + ex.Message);
                    }
                }

                //批量更新数据库
                BusinessHelper.UpdateTicketBonus(prizeList);

                log.Insert(0, string.Format("总查询到{0}张票,成功派奖票:{1}条,失败派奖票:{2}条", ticketListInfo.TicketList.Count, successCount, failCount));
            }
            catch (Exception ex)
            {
                return("派奖票数据出错 - " + ex.Message);
            }

            return(string.Join(Environment.NewLine, log.ToArray()));
        }