Ejemplo n.º 1
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();
            }
        }