/// <summary>
        /// 宝单分享
        /// </summary>
        public void ComplateTicket(string userId, string schemeId, decimal totalMoney, decimal totalErrorMoney)
        {
            try
            {
                if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(schemeId))
                {
                    return;
                }
                var orderManager = new Sports_Manager();
                var sd_Manager   = new TotalSingleTreasureManager();
                var manager      = new BDFXManager();
                var orderRunning = orderManager.QuerySports_Order_Running(schemeId);
                if (orderRunning == null)
                {
                    return;
                }
                if (orderRunning.SchemeType == (int)SchemeType.SingleTreasure)
                {
                    var saveOrderEntity = orderManager.QuerySaveOrder(schemeId);
                    if (saveOrderEntity == null)
                    {
                        return;
                    }
                    var      BDFXOrderEntity    = sd_Manager.QueryTotalSingleTreasureBySchemeId(schemeId);
                    var      anteCodeList       = orderManager.QuerySportsAnteCodeBySchemeId(schemeId);
                    DateTime firstMatchStopTime = new DateTime();
                    DateTime lastMatchStopTime  = new DateTime();
                    if (orderRunning.GameCode.ToUpper() == "JCZQ")
                    {
                        var matchIdArray = (from l in anteCodeList select l.MatchId).Distinct().ToArray();
                        var matchList    = orderManager.QueryJCZQSaleMatchCount(matchIdArray);
                        firstMatchStopTime = matchList.Min(s => s.FSStopBettingTime);
                        lastMatchStopTime  = matchList.Max(s => s.FSStopBettingTime);
                    }
                    if (BDFXOrderEntity == null || string.IsNullOrEmpty(BDFXOrderEntity.UserId))//晒单
                    {
                        var epectedBonusMoney = 0M;
                        var ticketList        = orderManager.QueryTicketList(schemeId);
                        if (ticketList != null && ticketList.Count > 0)
                        {
                            foreach (var item in ticketList)
                            {
                                var minMoney  = 0M;
                                var maxMoney  = 0M;
                                var playCount = 0;
                                if (!string.IsNullOrEmpty(item.PlayType))
                                {
                                    var tempArray = item.PlayType.Replace("P", "").Split('_');
                                    if (tempArray.Length >= 2)
                                    {
                                        playCount = Convert.ToInt32(tempArray[1]);
                                    }
                                }

                                if (string.IsNullOrEmpty(item.PlayType) || playCount <= 1)
                                {
                                    var winMoneyList = string.IsNullOrEmpty(item.BetContent) || string.IsNullOrEmpty(item.LocOdds) ? null : Common.Utilities.UsefullHelper.GetTicketMinMoneyOrMaxMoney(item.BetContent, item.LocOdds, out minMoney, out maxMoney);
                                }
                                else
                                {
                                    Common.Utilities.UsefullHelper.GetTicketMinMoneyOrMaxMoney_MN(item.PlayType.Replace("P", ""), item.BetContent, item.LocOdds, out minMoney, out maxMoney);
                                }
                                epectedBonusMoney += maxMoney;
                            }
                        }
                        epectedBonusMoney = Convert.ToDecimal(epectedBonusMoney.ToString("N2"));
                        var expectedReturnRate = 0M;
                        if (orderRunning.TotalMoney > 0)
                        {
                            expectedReturnRate = epectedBonusMoney / orderRunning.TotalMoney;
                            expectedReturnRate = Math.Truncate(expectedReturnRate * 100) / 100M;
                        }
                        BDFXOrderEntity                           = new C_TotalSingleTreasure();
                        BDFXOrderEntity.Commission                = saveOrderEntity.BDFXCommission;
                        BDFXOrderEntity.CreateTime                = DateTime.Now;
                        BDFXOrderEntity.CurrentBetMoney           = orderRunning.TotalMoney;
                        BDFXOrderEntity.ExpectedBonusMoney        = epectedBonusMoney;
                        BDFXOrderEntity.ExpectedReturnRate        = expectedReturnRate;
                        BDFXOrderEntity.FirstMatchStopTime        = firstMatchStopTime;
                        BDFXOrderEntity.IsBonus                   = false;
                        BDFXOrderEntity.IsComplate                = false;
                        BDFXOrderEntity.LastMatchStopTime         = lastMatchStopTime.AddMinutes(120);
                        BDFXOrderEntity.TotalBuyCount             = 0;
                        BDFXOrderEntity.TotalBuyMoney             = 0;
                        BDFXOrderEntity.TotalBonusMoney           = 0;
                        BDFXOrderEntity.ProfitRate                = 0;
                        BDFXOrderEntity.SchemeId                  = orderRunning.SchemeId;
                        BDFXOrderEntity.TotalCommissionMoney      = 0;
                        BDFXOrderEntity.UserId                    = orderRunning.UserId;
                        BDFXOrderEntity.SingleTreasureDeclaration = saveOrderEntity.SingleTreasureDeclaration;
                        BDFXOrderEntity.Security                  = orderRunning.Security;
                        sd_Manager.AddTotalSingleTreasure(BDFXOrderEntity);
                    }
                    var singleTreasureAttentionSummary = manager.QuerySingleTreasureAttentionSummaryByUserId(orderRunning.UserId);
                    if (singleTreasureAttentionSummary == null || string.IsNullOrEmpty(singleTreasureAttentionSummary.UserId))//初始化关注统计表
                    {
                        C_SingleTreasure_AttentionSummary entity = new C_SingleTreasure_AttentionSummary();
                        entity.UserId = orderRunning.UserId;
                        entity.BeConcernedUserCount = 0;
                        entity.ConcernedUserCount   = 0;
                        entity.SingleTreasureCount += 1;
                        entity.UpdateTime           = DateTime.Now;
                        manager.AddSingleTreasureAttentionSummary(entity);
                    }
                    else
                    {
                        singleTreasureAttentionSummary.SingleTreasureCount += 1;
                        manager.UpdateSingleTreasureAttentionSummary(singleTreasureAttentionSummary);
                    }
                }
                else if (orderRunning.SchemeType == (int)SchemeType.SingleCopy)//抄单
                {
                    var recordSingleCopyEntity = sd_Manager.QueryBDFXRecordSingleCopyBySchemeId(schemeId);
                    if (recordSingleCopyEntity != null)
                    {
                        var bdEntity = sd_Manager.QueryTotalSingleTreasureBySchemeId(recordSingleCopyEntity.BDXFSchemeId);
                        if (bdEntity != null)
                        {
                            bdEntity.TotalBuyCount += 1;
                            bdEntity.TotalBuyMoney += totalMoney;
                            sd_Manager.UpdateTotalSingleTreasure(bdEntity);
                        }
                    }
                }
            }
            catch
            {
            }
        }
Exemple #2
0
        public DateTime CheckGeneralBettingMatch(Sports_Manager sportsManager, string gameCode, string gameType, string playType, List <Sports_AnteCodeInfo> codeList, string issuseNumber, SchemeBettingCategory?bettingCategory = null)
        {
            if (gameCode == "BJDC")
            {
                var matchIdArray = (from l in codeList select string.Format("{0}|{1}", issuseNumber, l.MatchId)).Distinct().ToArray();
                var matchList    = sportsManager.QueryBJDCSaleMatchCount(matchIdArray);
                if (gameType.ToUpper() == "SF")
                {
                    var SFGGMatchList = sportsManager.QuerySFGGSaleMatchCount(matchIdArray);

                    if (SFGGMatchList.Count != matchIdArray.Length)
                    {
                        throw new LogicException("所选比赛中有停止销售的比赛。");
                    }
                    BettingHelper.CheckPrivilegesType_BJDC(gameCode, gameType, playType, issuseNumber, codeList, matchList);
                    return(SFGGMatchList.Min(m => m.BetStopTime));
                }
                else
                {
                    if (matchList.Count != matchIdArray.Length)
                    {
                        throw new LogicException("所选比赛中有停止销售的比赛。");
                    }
                    BettingHelper.CheckPrivilegesType_BJDC(gameCode, gameType, playType, issuseNumber, codeList, matchList);
                    return(matchList.Min(m => m.LocalStopTime));
                }
                //if (matchList.Count != matchIdArray.Length && gameType != "HH")
                //    throw new ArgumentException("所选比赛中有停止销售的比赛。");
            }
            if (gameCode == "JCZQ")
            {
                var matchIdArray = (from l in codeList select l.MatchId).Distinct().ToArray();
                var matchList    = sportsManager.QueryJCZQSaleMatchCount(matchIdArray);
                //if (matchList.Count != matchIdArray.Length && gameType != "HH")
                //    throw new ArgumentException("所选比赛中有停止销售的比赛。");
                if (matchList.Count != matchIdArray.Length)
                {
                    throw new LogicException("所选比赛中有停止销售的比赛。");
                }
                //var matchResultList = sportsManager.QueryJCZQMatchResult(matchIdArray);
                //if (matchResultList.Count > 0)
                //    throw new ArgumentException(string.Format("所选比赛中包含结束的比赛:{0}", string.Join(",", matchResultList.Select(p => p.MatchId).ToArray())));

                BettingHelper.CheckPrivilegesType_JCZQ(gameCode, gameType, playType, codeList, matchList);

                //if (playType == "1_1")
                if (bettingCategory != null && bettingCategory.Value == SchemeBettingCategory.SingleBetting)
                {
                    return(matchList.Min(m => m.DSStopBettingTime));
                }
                return(matchList.Min(m => m.FSStopBettingTime));
            }
            if (gameCode == "JCLQ")
            {
                var matchIdArray = (from l in codeList select l.MatchId).Distinct().ToArray();
                var matchList    = sportsManager.QueryJCLQSaleMatchCount(matchIdArray);
                //if (matchList.Count != matchIdArray.Length && gameType != "HH")
                //    throw new ArgumentException("所选比赛中有停止销售的比赛。");
                if (matchList.Count != matchIdArray.Length)
                {
                    throw new LogicException("所选比赛中有停止销售的比赛。");
                }
                var matchResultList = sportsManager.QueryJCLQMatchResult(matchIdArray);
                if (matchResultList.Count > 0)
                {
                    throw new LogicException(string.Format("所选比赛中包含结束的比赛:{0}", string.Join(",", matchResultList.Select(p => p.MatchId).ToArray())));
                }

                BettingHelper.CheckPrivilegesType_JCLQ(gameCode, gameType, playType, codeList, matchList);

                //if (playType == "1_1")
                if (bettingCategory != null && bettingCategory.Value == SchemeBettingCategory.SingleBetting)
                {
                    return(matchList.Min(m => m.DSStopBettingTime));
                }
                return(matchList.Min(m => m.FSStopBettingTime));
            }
            if (gameCode == "CTZQ")
            {
                var issuse = new LotteryGameManager().QueryGameIssuseByKey(gameCode, gameType, issuseNumber);
                if (issuse == null)
                {
                    throw new LogicException(string.Format("{0},{1}奖期{2}不存在", gameCode, gameType, issuseNumber));
                }
                if (issuse.LocalStopTime < DateTime.Now)
                {
                    throw new LogicException(string.Format("{0},{1}奖期{2}结束时间为{3}", gameCode, gameType, issuseNumber, issuse.LocalStopTime.ToString("yyyy-MM-dd HH:mm")));
                }
                return(issuse.LocalStopTime);
            }
            //其它数字彩
            var currentIssuse = new LotteryGameManager().QueryGameIssuseByKey(gameCode, gameCode == "CTZQ" ? gameType : string.Empty, issuseNumber);

            if (currentIssuse == null)
            {
                throw new LogicException(string.Format("{0},{1}奖期{2}不存在", gameCode, gameType, issuseNumber));
            }
            if (currentIssuse.LocalStopTime < DateTime.Now)
            {
                throw new LogicException(string.Format("{0},{1}奖期{2}结束时间为{3}", gameCode, gameType, issuseNumber, currentIssuse.LocalStopTime.ToString("yyyy-MM-dd HH:mm")));
            }
            return(currentIssuse.LocalStopTime);
        }