Exemple #1
0
    /// <summary>
    /// 根据原过关方式,获取拆分串关列表,每个元素为串关数,表示N串1
    /// </summary>
    /// <param name="playType">原过关方式</param>
    /// <returns></returns>
    public static int[] GetPlayTypeList(string playType)
    {
        var comb = new Combination();

        try
        {
            List <int> tmp = new List <int>();
            if (playType.Split(',').Length == 1 && !playType.EndsWith("_1"))
            {
                var nps = playType.Replace("P", "").Split('_');
                var gs  = int.Parse(nps[0]);
                var zs  = int.Parse(nps[1]);
                tmp = SportAnalyzer.AnalyzeChuan(gs, zs).ToList();

                //var allZS = 0;
                //for (int i = gs; i >= 1; i--)
                //{
                //    tmp.Add(i.ToString());
                //    allZS += comb.Calculate(gs, i);
                //    if (allZS == zs)
                //    { break; }
                //}
            }
            else
            {
                tmp = playType.Replace("P", "").Replace("_1", "").Split(',').Select(a => int.Parse(a)).ToList();
            }

            return(tmp.OrderByDescending(a => a).ToArray());;
        }
        catch
        {
            return(new int[] { });
        }
    }
Exemple #2
0
        public int CheckBettingOrderMoney(List <Sports_AnteCodeInfo> codeList, string gameCode, string gameType, string playType, int amount, decimal schemeTotalMoney, DateTime stopTime, bool isAllow = false, string userId = "")
        {
            //验证投注号码
            if (stopTime < DateTime.Now)
            {
                throw new Exception("投注结束时间不能小于当前时间");
            }

            //验证投注内容是否合法,或是否重复
            foreach (var item in codeList)
            {
                var oneCodeArray = item.AnteCode.Split(',');
                if (oneCodeArray.Distinct().Count() != oneCodeArray.Length)
                {
                    throw new Exception(string.Format("投注号码{0}中包括重复的内容", item.AnteCode));
                }
                BettingHelper.CheckSportAnteCode(gameCode, string.IsNullOrEmpty(item.GameType) ? gameType : item.GameType.ToUpper(), oneCodeArray);
            }

            var tmp        = playType.Split('|');
            var totalMoney = 0M;
            var totalCount = 0;

            var c = new Combination();

            foreach (var chuan in tmp)
            {
                var chuanArray = chuan.Split('_');
                if (chuanArray.Length != 2)
                {
                    continue;
                }

                var m = int.Parse(chuanArray[0]);
                var n = int.Parse(chuanArray[1]);

                //串关包括的真实串数
                var countList = SportAnalyzer.AnalyzeChuan(m, n);
                if (n > 1)
                {
                    //3_3类型
                    c.Calculate(codeList.ToArray(), m, (arr) =>
                    {
                        //m场比赛
                        if (arr.Select(p => p.MatchId).Distinct().Count() == m)
                        {
                            foreach (var count in countList)
                            {
                                //M串1
                                c.Calculate(arr, count, (a1) =>
                                {
                                    var cCount = 1;
                                    foreach (var t in a1)
                                    {
                                        cCount *= t.AnteCode.Split(',').Length;
                                    }
                                    totalCount += cCount;
                                });
                            }
                        }
                    });
                }
                else
                {
                    var ac      = new ArrayCombination();
                    var danList = codeList.Where(a => a.IsDan).ToList();
                    //var tuoList = codeList.Where(a => !a.IsDan).ToList();
                    var totalCodeList = new List <Sports_AnteCodeInfo[]>();
                    foreach (var g in codeList.GroupBy(p => p.MatchId))
                    {
                        totalCodeList.Add(codeList.Where(p => p.MatchId == g.Key).ToArray());
                    }
                    //3_1类型
                    foreach (var count in countList)
                    {
                        //c.Calculate(totalCodeList.ToArray(), count - danList.Count, (arr2) =>
                        c.Calculate(totalCodeList.ToArray(), count, (arr2) =>
                        {
                            ac.Calculate(arr2, (tuoArr) =>
                            {
                                #region 拆分组合票

                                var isContainsDan = true;
                                foreach (var dan in danList)
                                {
                                    var con = tuoArr.FirstOrDefault(p => p.MatchId == dan.MatchId);
                                    if (con == null)
                                    {
                                        isContainsDan = false;
                                        break;
                                    }
                                }

                                if (isContainsDan)
                                {
                                    var cCount = 1;
                                    foreach (var t in tuoArr)
                                    {
                                        cCount *= t.AnteCode.Split(',').Length;
                                    }
                                    totalCount += cCount;
                                    //if (!isAllow && BusinessHelper.IsSiteLimit(gameCode))
                                    //{
                                    //    if (!string.IsNullOrEmpty(userId) && !BusinessHelper.IsSpecificUser(userId))//如果是特定用户,则不限制投注
                                    //    {
                                    //        if ((cCount * amount * 2M) < 50)
                                    //            throw new Exception("您好,根据您投注的内容将产生多张彩票,每张彩票金额不足50元,请您增加倍数以达到出票条件。");
                                    //    }
                                    //}
                                }

                                #endregion
                            });
                        });
                    }
                }
            }
            totalMoney = totalCount * amount * 2M;

            if (totalMoney != schemeTotalMoney)
            {
                throw new ArgumentException(string.Format("订单金额不正确,应该为:{0};实际为:{1}。", totalMoney, schemeTotalMoney));
            }
            return(totalCount);
        }