/// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="Source"></param>
        /// <returns></returns>
        public int InsertBetZH(FFModel.Account.UserBetModel model, string Source, DateTime STime, string userId, string playCode)
        {
            int      logSysId = 0;
            int      num1     = 0;
            DateTime STime2   = STime;

            FlexDAL.UserBetDAL betDal         = new FlexDAL.UserBetDAL();
            string[]           issueTimeAndSn = betDal.GetIssueTimeAndSN(model.LotteryId);
            string             issueNum       = issueTimeAndSn[0];

            using (SqlConnection sqlConnection = new SqlConnection(ComData.connectionString))
            {
                sqlConnection.Open();
                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.Connection = sqlConnection;
                try
                {
                    string str1 = "";
                    string str2 = "";
                    string str3 = "";
                    if (playCode == "P_5ZH")
                    {
                        str1 = "P_5ZH_WQBSG,P_5ZH_QBSG,P_5ZH_BSG,P_5ZH_SG,P_5ZH_G";
                        str2 = "1,10,100,1000,10000";
                        string[] strArray = model.Balls.Replace("_", "").Split(',');
                        int      num2     = 1;
                        int      num3     = 1;
                        int      num4     = 1;
                        int      num5     = 1;
                        int      num6     = 1;
                        for (int index = 0; index < strArray.Length; ++index)
                        {
                            num2 *= strArray[index].Length;
                        }
                        for (int index = 1; index < strArray.Length; ++index)
                        {
                            num3 *= strArray[index].Length;
                        }
                        for (int index = 2; index < strArray.Length; ++index)
                        {
                            num4 *= strArray[index].Length;
                        }
                        for (int index = 3; index < strArray.Length; ++index)
                        {
                            num5 *= strArray[index].Length;
                        }
                        for (int index = 4; index < strArray.Length; ++index)
                        {
                            num6 *= strArray[index].Length;
                        }
                        str3 = num2.ToString() + "," + (object)num3 + "," + (object)num4 + "," + (object)num5 + "," + (object)num6;
                    }
                    if (playCode == "P_4ZH_L")
                    {
                        str1 = "P_4ZH_L_WQBS,P_4ZH_L_QBS,P_4ZH_L_BS,P_4ZH_L_S";
                        str2 = "1,10,100,1000";
                        string[] strArray = model.Balls.Replace("_", "").Split(',');
                        int      num2     = 1;
                        int      num3     = 1;
                        int      num4     = 1;
                        int      num5     = 1;
                        for (int index = 0; index < strArray.Length; ++index)
                        {
                            num2 *= strArray[index].Length;
                        }
                        for (int index = 1; index < strArray.Length; ++index)
                        {
                            num3 *= strArray[index].Length;
                        }
                        for (int index = 2; index < strArray.Length; ++index)
                        {
                            num4 *= strArray[index].Length;
                        }
                        for (int index = 3; index < strArray.Length; ++index)
                        {
                            num5 *= strArray[index].Length;
                        }
                        str3 = num2.ToString() + "," + (object)num3 + "," + (object)num4 + "," + (object)num5;
                    }
                    if (playCode == "P_4ZH_R")
                    {
                        str1 = "P_4ZH_R_QBSG,P_4ZH_R_BSG,P_4ZH_R_SG,P_4ZH_R_G";
                        str2 = "1,10,100,1000";
                        string[] strArray = model.Balls.Replace("_", "").Split(',');
                        int      num2     = 1;
                        int      num3     = 1;
                        int      num4     = 1;
                        int      num5     = 1;
                        for (int index = 0; index < strArray.Length; ++index)
                        {
                            num2 *= strArray[index].Length;
                        }
                        for (int index = 1; index < strArray.Length; ++index)
                        {
                            num3 *= strArray[index].Length;
                        }
                        for (int index = 2; index < strArray.Length; ++index)
                        {
                            num4 *= strArray[index].Length;
                        }
                        for (int index = 3; index < strArray.Length; ++index)
                        {
                            num5 *= strArray[index].Length;
                        }
                        str3 = num2.ToString() + "," + (object)num3 + "," + (object)num4 + "," + (object)num5;
                    }
                    if (playCode == "P_3ZH_L")
                    {
                        str1 = "P_3ZH_L_WQB,P_3ZH_L_QB,P_3ZH_L_B";
                        str2 = "1,10,100";
                        string[] strArray = model.Balls.Replace("_", "").Split(',');
                        int      num2     = 1;
                        int      num3     = 1;
                        int      num4     = 1;
                        for (int index = 0; index < strArray.Length; ++index)
                        {
                            num2 *= strArray[index].Length;
                        }
                        for (int index = 1; index < strArray.Length; ++index)
                        {
                            num3 *= strArray[index].Length;
                        }
                        for (int index = 2; index < strArray.Length; ++index)
                        {
                            num4 *= strArray[index].Length;
                        }
                        str3 = num2.ToString() + "," + (object)num3 + "," + (object)num4;
                    }
                    if (playCode == "P_3ZH_C")
                    {
                        str1 = "P_3ZH_C_QBS,P_3ZH_C_BS,P_3ZH_C_S";
                        str2 = "1,10,100";
                        string[] strArray = model.Balls.Replace("_", "").Split(',');
                        int      num2     = 1;
                        int      num3     = 1;
                        int      num4     = 1;
                        for (int index = 0; index < strArray.Length; ++index)
                        {
                            num2 *= strArray[index].Length;
                        }
                        for (int index = 1; index < strArray.Length; ++index)
                        {
                            num3 *= strArray[index].Length;
                        }
                        for (int index = 2; index < strArray.Length; ++index)
                        {
                            num4 *= strArray[index].Length;
                        }
                        str3 = num2.ToString() + "," + (object)num3 + "," + (object)num4;
                    }
                    if (playCode == "P_3ZH_R")
                    {
                        str1 = "P_3ZH_R_BSG,P_3ZH_R_SG,P_3ZH_R_G";
                        str2 = "1,10,100";
                        string[] strArray = model.Balls.Replace("_", "").Split(',');
                        int      num2     = 1;
                        int      num3     = 1;
                        int      num4     = 1;
                        for (int index = 0; index < strArray.Length; ++index)
                        {
                            num2 *= strArray[index].Length;
                        }
                        for (int index = 1; index < strArray.Length; ++index)
                        {
                            num3 *= strArray[index].Length;
                        }
                        for (int index = 2; index < strArray.Length; ++index)
                        {
                            num4 *= strArray[index].Length;
                        }
                        str3 = num2.ToString() + "," + (object)num3 + "," + (object)num4;
                    }
                    string[] strArray1 = str1.Split(',');
                    string[] strArray2 = str2.Split(',');
                    string[] strArray3 = str3.Split(',');
                    for (int index = 0; index < strArray1.Length; ++index)
                    {
                        if (Convert.ToInt32(strArray3[index]) > 0)
                        {
                            string  bet   = model.SsId;
                            Decimal Money = Convert.ToDecimal(model.Price * (Decimal)Convert.ToInt32(strArray3[index]) * model.Times);
                            if (new UserTotalTran().MoneyOpers(bet, userId, Money, model.LotteryId, model.PlayId, logSysId, 3, 99, string.Empty, string.Empty, "会员投注", "") > 0)
                            {
                                SqlParameter[] values = new SqlParameter[21]
                                {
                                    new SqlParameter("@SsId", (object)bet),
                                    new SqlParameter("@UserId", (object)userId),
                                    //new SqlParameter("@UserMoney", (object) model.UserMoney),
                                    new SqlParameter("@UserMoney", (object)0),
                                    new SqlParameter("@LotteryId", (object)model.LotteryId),
                                    new SqlParameter("@PlayId", (object)model.PlayId),
                                    new SqlParameter("@IssueNum", (object)issueNum),
                                    new SqlParameter("@SingleMoney", (object)model.Price),
                                    new SqlParameter("@Num", (object)Convert.ToInt32(strArray3[index])),
                                    new SqlParameter("@Detail", (object)""),
                                    new SqlParameter("@Total", (object)(model.Price * (Decimal)Convert.ToInt32(strArray3[index]))),
                                    new SqlParameter("@Point", (object)model.Point),
                                    new SqlParameter("@PointMoney", (object)(model.Price * (Decimal)Convert.ToInt32(strArray3[index]) * model.Point / new Decimal(100))),
                                    new SqlParameter("@Bonus", (object)(model.SingelBouns / (Decimal)Convert.ToInt32(strArray2[index]))),
                                    new SqlParameter("@Pos", (object)""),
                                    new SqlParameter("@PlayCode", (object)strArray1[index]),
                                    new SqlParameter("@STime", (object)STime),
                                    new SqlParameter("@STime2", (object)STime2),
                                    //new SqlParameter("@IsDelay", (object) model.IsDelay),
                                    new SqlParameter("@IsDelay", (object)0),
                                    new SqlParameter("@Times", (object)model.Times),
                                    new SqlParameter("@ZhId", (object)"0"),
                                    new SqlParameter("@Source", (object)Source)
                                };
                                sqlCommand.CommandText  = "insert into N_UserBet(SsId,UserId,UserMoney,LotteryId,PlayId,IssueNum,SingleMoney,Num,Detail,Total\r\n                                        ,Point,PointMoney,Bonus,Pos,PlayCode,STime,STime2,IsDelay,Times,ZhId,Source)\r\n                                        values(@SsId,@UserId,@UserMoney,@LotteryId,@PlayId,@IssueNum,@SingleMoney,@Num,@Detail,@Total\r\n                                        ,@Point,@PointMoney,@Bonus,@Pos,@PlayCode,@STime,@STime2,@IsDelay,@Times,@ZhId,@Source)";
                                sqlCommand.CommandText += " SELECT SCOPE_IDENTITY()";
                                sqlCommand.Parameters.AddRange(values);
                                logSysId = Convert.ToInt32(sqlCommand.ExecuteScalar());
                                sqlCommand.Parameters.Clear();
                                ++num1;
                                BetDetailDAL.SetBetDetail(STime2.ToString("yyyyMMdd"), userId.ToString(), logSysId.ToString(), model.Balls.Replace("|", "#"));
                            }
                        }
                    }
                    logSysId = num1 <= 0 ? 0 : 1;
                }
                catch (Exception ex)
                {
                    new LogExceptionDAL().Save("系统异常", ex.Message);
                    logSysId = 0;
                }
            }
            return(logSysId);
        }
        /// <summary>
        /// 将投注信息存放到到数据库
        /// </summary>
        /// <param name="model"></param>
        /// <param name="Source">来源:web端投注还是手机端</param>
        /// <returns></returns>
        public int InsertBet(FFModel.Account.UserBetModel model, string Source, DateTime STime, string userId, string playCode)
        {
            int logSysId = 0;

            using (SqlConnection sqlConnection = new SqlConnection(ComData.connectionString))
            {
                sqlConnection.Open();
                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.Connection = sqlConnection;
                try
                {
                    string   bet    = model.SsId;
                    DateTime STime2 = STime;

                    FlexDAL.UserBetDAL betDal         = new FlexDAL.UserBetDAL();
                    string[]           issueTimeAndSn = betDal.GetIssueTimeAndSN(model.LotteryId);
                    string             str1           = issueTimeAndSn[0];

                    Decimal Money = Convert.ToDecimal(model.SingelBouns * (Decimal)model.Num * model.Times);
                    if (new UserTotalTran().MoneyOpers(bet, userId, Money, model.LotteryId, model.PlayId, logSysId, 3, 99, string.Empty, string.Empty, "会员投注", "") <= 0)
                    {
                        return(0);
                    }
                    SqlParameter[] values = new SqlParameter[21]
                    {
                        new SqlParameter("@SsId", (object)bet),
                        new SqlParameter("@UserId", (object)userId),
                        //new SqlParameter("@UserMoney", (object) model.UserMoney),
                        new SqlParameter("@UserMoney", (object)0),
                        new SqlParameter("@LotteryId", (object)model.LotteryId),
                        new SqlParameter("@PlayId", (object)model.PlayId),
                        new SqlParameter("@IssueNum", (object)str1),
                        new SqlParameter("@SingleMoney", (object)model.Price),
                        new SqlParameter("@Num", (object)model.Num),
                        new SqlParameter("@Detail", (object)""),
                        new SqlParameter("@Total", (object)(model.Price * (Decimal)model.Num)),
                        new SqlParameter("@Point", (object)model.Point),
                        new SqlParameter("@PointMoney", (object)(model.Price * (Decimal)model.Num * model.Point / new Decimal(100))),
                        new SqlParameter("@Bonus", (object)model.SingelBouns),
                        new SqlParameter("@Pos", (object)model.StrPos),
                        new SqlParameter("@PlayCode", (object)playCode),
                        //new SqlParameter("@STime", (object) model.STime),
                        //new SqlParameter("@STime2", (object) model.STime2),
                        new SqlParameter("@STime", (object)STime),
                        new SqlParameter("@STime2", (object)STime2),
                        //new SqlParameter("@IsDelay", (object) model.IsDelay),
                        new SqlParameter("@IsDelay", (object)0),
                        new SqlParameter("@Times", (object)model.Times),
                        new SqlParameter("@ZhId", (object)"0"),
                        new SqlParameter("@Source", (object)Source)
                    };
                    sqlCommand.CommandText  = "insert into N_UserBet(SsId,UserId,UserMoney,LotteryId,PlayId,IssueNum,SingleMoney,Num,Detail,Total\r\n                                        ,Point,PointMoney,Bonus,Pos,PlayCode,STime,STime2,IsDelay,Times,ZhId,Source)\r\n                                        values(@SsId,@UserId,@UserMoney,@LotteryId,@PlayId,@IssueNum,@SingleMoney,@Num,@Detail,@Total\r\n                                        ,@Point,@PointMoney,@Bonus,@Pos,@PlayCode,@STime,@STime2,@IsDelay,@Times,@ZhId,@Source)";
                    sqlCommand.CommandText += " SELECT SCOPE_IDENTITY()";
                    sqlCommand.Parameters.AddRange(values);
                    logSysId = Convert.ToInt32(sqlCommand.ExecuteScalar());
                    sqlCommand.Parameters.Clear();
                    BetDetailDAL.SetBetDetail(STime2.ToString("yyyyMMdd"), userId, logSysId.ToString(), model.Balls.Replace("|", "#"));
                }
                catch (Exception ex)
                {
                    new LogExceptionDAL().Save("系统异常", ex.Message);
                    logSysId = 0;
                }
            }
            return(logSysId);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="Source"></param>
        /// <returns></returns>
        public int InsertBetPos(FFModel.Account.UserBetModel model, string Source, DateTime STime, string userId, string playCode)
        {
            int      logSysId = 0;
            int      num      = 0;
            DateTime STime2   = STime;

            FlexDAL.UserBetDAL betDal         = new FlexDAL.UserBetDAL();
            string[]           issueTimeAndSn = betDal.GetIssueTimeAndSN(model.LotteryId);
            string             issueNum       = issueTimeAndSn[0];

            using (SqlConnection sqlConnection = new SqlConnection(ComData.connectionString))
            {
                sqlConnection.Open();
                SqlCommand sqlCommand = new SqlCommand();
                sqlCommand.Connection = sqlConnection;
                try
                {
                    string   str1      = "";
                    string[] strArray1 = model.StrPos.Split(',');
                    string   str2      = playCode + "_";
                    switch (playCode)
                    {
                    case "R_4FS":
                    case "R_4DS":
                    case "R_4ZX24":
                    case "R_4ZX12":
                    case "R_4ZX6":
                    case "R_4ZX4":
                        if (model.StrPos != "")
                        {
                            int count = Regex.Matches(model.StrPos, "1").Count;
                            if (count == 4)
                            {
                                str1 = str1 + str2 + (strArray1[0].Equals("1") ? "W" : "") + (strArray1[1].Equals("1") ? "Q" : "") + (strArray1[2].Equals("1") ? "B" : "") + (strArray1[3].Equals("1") ? "S" : "") + (strArray1[4].Equals("1") ? "G" : "") + ",";
                            }
                            if (count == 5)
                            {
                                string[] strArray2 = "W,Q,B,S,G".Split(',');
                                for (int index1 = 0; index1 < strArray2.Length; ++index1)
                                {
                                    for (int index2 = index1 + 1; index2 < strArray2.Length; ++index2)
                                    {
                                        for (int index3 = index2 + 1; index3 < strArray2.Length; ++index3)
                                        {
                                            for (int index4 = index3 + 1; index4 < strArray2.Length; ++index4)
                                            {
                                                str1 = str1 + str2 + strArray2[index1] + strArray2[index2] + strArray2[index3] + strArray2[index4] + ",";
                                            }
                                        }
                                    }
                                }
                                break;
                            }
                            break;
                        }
                        break;

                    case "R_3FS":
                    case "R_3DS":
                    case "R_3Z3":
                    case "R_3Z6":
                    case "R_3HX":
                    case "R_3HE":
                    case "R_3ZHE":
                    case "R_3KD":
                    case "R_3ZBD":
                    case "R_3QTWS":
                    case "R_3QTTS":
                    case "R_3Z3DS":
                    case "R_3Z6DS":
                        if (model.StrPos != "")
                        {
                            int count = Regex.Matches(model.StrPos, "1").Count;
                            if (count == 3)
                            {
                                str1 = str1 + str2 + (strArray1[0].Equals("1") ? "W" : "") + (strArray1[1].Equals("1") ? "Q" : "") + (strArray1[2].Equals("1") ? "B" : "") + (strArray1[3].Equals("1") ? "S" : "") + (strArray1[4].Equals("1") ? "G" : "") + ",";
                            }
                            if (count >= 4)
                            {
                                string   str3      = "" + (strArray1[0].Equals("1") ? "W," : "") + (strArray1[1].Equals("1") ? "Q," : "") + (strArray1[2].Equals("1") ? "B," : "") + (strArray1[3].Equals("1") ? "S," : "") + (strArray1[4].Equals("1") ? "G," : "");
                                string[] strArray2 = str3.Substring(0, str3.Length - 1).Split(',');
                                for (int index1 = 0; index1 < strArray2.Length; ++index1)
                                {
                                    for (int index2 = index1 + 1; index2 < strArray2.Length; ++index2)
                                    {
                                        for (int index3 = index2 + 1; index3 < strArray2.Length; ++index3)
                                        {
                                            str1 = str1 + str2 + strArray2[index1] + strArray2[index2] + strArray2[index3] + ",";
                                        }
                                    }
                                }
                                break;
                            }
                            break;
                        }
                        break;

                    case "R_2FS":
                    case "R_2DS":
                    case "R_2Z2":
                    case "R_2HE":
                    case "R_2ZHE":
                    case "R_2ZDS":
                    case "R_2KD":
                    case "R_2ZBD":
                        if (model.StrPos != "")
                        {
                            int count = Regex.Matches(model.StrPos, "1").Count;
                            if (count == 2)
                            {
                                str1 = str1 + str2 + (strArray1[0].Equals("1") ? "W" : "") + (strArray1[1].Equals("1") ? "Q" : "") + (strArray1[2].Equals("1") ? "B" : "") + (strArray1[3].Equals("1") ? "S" : "") + (strArray1[4].Equals("1") ? "G" : "") + ",";
                            }
                            if (count >= 3)
                            {
                                string   str3      = "" + (strArray1[0].Equals("1") ? "W," : "") + (strArray1[1].Equals("1") ? "Q," : "") + (strArray1[2].Equals("1") ? "B," : "") + (strArray1[3].Equals("1") ? "S," : "") + (strArray1[4].Equals("1") ? "G," : "");
                                string[] strArray2 = str3.Substring(0, str3.Length - 1).Split(',');
                                for (int index1 = 0; index1 < strArray2.Length; ++index1)
                                {
                                    for (int index2 = index1 + 1; index2 < strArray2.Length; ++index2)
                                    {
                                        str1 = str1 + str2 + strArray2[index1] + strArray2[index2] + ",";
                                    }
                                }
                                break;
                            }
                            break;
                        }
                        break;
                    }
                    string[] strArray3 = str1.Substring(0, str1.Length - 1).Split(',');
                    for (int index = 0; index < strArray3.Length; ++index)
                    {
                        string  bet   = model.SsId;
                        Decimal Money = Convert.ToDecimal(model.Price * (Decimal)model.Num * model.Times / (Decimal)strArray3.Length);
                        if (new UserTotalTran().MoneyOpers(bet, userId, Money, model.LotteryId, model.PlayId, logSysId, 3, 99, string.Empty, string.Empty, "会员投注", "") > 0)
                        {
                            SqlParameter[] values = new SqlParameter[21]
                            {
                                new SqlParameter("@SsId", (object)bet),
                                new SqlParameter("@UserId", (object)userId),
                                //new SqlParameter("@UserMoney", (object) model.UserMoney),
                                new SqlParameter("@UserMoney", (object)0),
                                new SqlParameter("@LotteryId", (object)model.LotteryId),
                                new SqlParameter("@PlayId", (object)model.PlayId),
                                new SqlParameter("@IssueNum", (object)issueNum),
                                new SqlParameter("@SingleMoney", (object)model.Price),
                                new SqlParameter("@Num", (object)(model.Num / strArray3.Length)),
                                new SqlParameter("@Detail", (object)""),
                                new SqlParameter("@Total", (object)(model.Price * (Decimal)model.Num / (Decimal)strArray3.Length)),
                                new SqlParameter("@Point", (object)model.Point),
                                new SqlParameter("@PointMoney", (object)(model.Price * (Decimal)model.Num * model.Point / (Decimal)strArray3.Length / new Decimal(100))),
                                new SqlParameter("@Bonus", (object)model.SingelBouns),
                                new SqlParameter("@Pos", (object)""),
                                new SqlParameter("@PlayCode", (object)strArray3[index]),
                                new SqlParameter("@STime", (object)STime),
                                new SqlParameter("@STime2", (object)STime2),
                                //new SqlParameter("@IsDelay", (object) model.IsDelay),
                                new SqlParameter("@IsDelay", (object)0),
                                new SqlParameter("@Times", (object)model.Times),
                                new SqlParameter("@ZhId", (object)"0"),
                                new SqlParameter("@Source", (object)Source)
                            };
                            sqlCommand.CommandText  = "insert into N_UserBet(SsId,UserId,UserMoney,LotteryId,PlayId,IssueNum,SingleMoney,Num,Detail,Total\r\n                                        ,Point,PointMoney,Bonus,Pos,PlayCode,STime,STime2,IsDelay,Times,ZhId,Source)\r\n                                        values(@SsId,@UserId,@UserMoney,@LotteryId,@PlayId,@IssueNum,@SingleMoney,@Num,@Detail,@Total\r\n                                        ,@Point,@PointMoney,@Bonus,@Pos,@PlayCode,@STime,@STime2,@IsDelay,@Times,@ZhId,@Source)";
                            sqlCommand.CommandText += " SELECT SCOPE_IDENTITY()";
                            sqlCommand.Parameters.AddRange(values);
                            logSysId = Convert.ToInt32(sqlCommand.ExecuteScalar());
                            sqlCommand.Parameters.Clear();
                            ++num;
                            BetDetailDAL.SetBetDetail(STime2.ToString("yyyyMMdd"), userId, logSysId.ToString(), model.Balls.Replace("|", "#"));
                        }
                    }
                    logSysId = num < strArray3.Length ? 0 : 1;
                }
                catch (Exception ex)
                {
                    new LogExceptionDAL().Save("系统异常", ex.Message);
                    logSysId = 0;
                }
            }
            return(logSysId);
        }