Ejemplo n.º 1
0
        private void ajaxZHBetting()
        {
            if (this.AdminId == "")
            {
                this._response = this.JsonResult(0, "投注失败,请重新登录后再进行投注!");
            }
            else
            {
                HttpContext.Current.Response.ContentType = "application/json";
                List <ajaxBetting.RequestDataJSONZH> requestDataJsonzhList = ajaxBetting.JSONToObject <List <ajaxBetting.RequestDataJSONZH> >("[" + new StreamReader(HttpContext.Current.Request.InputStream).ReadToEnd() + "]");
                ajaxBetting.RequestDataJSONZH        requestDataJsonzh1    = new ajaxBetting.RequestDataJSONZH();
                int     int32_1 = Convert.ToInt32(this.AdminId);
                int     int32_2 = Convert.ToInt32(requestDataJsonzhList[0].lotteryId);
                int     int32_3 = Convert.ToInt32(requestDataJsonzhList[0].IsStop);
                int     int32_4 = Convert.ToInt32(requestDataJsonzhList[0].ZHNums);
                Decimal num     = Convert.ToDecimal(requestDataJsonzhList[0].ZHSums);

                LotteryDAL         lotDal  = new LotteryDAL();
                FlexDAL.UserBetDAL betDal  = new FlexDAL.UserBetDAL();
                SysLotteryModel    lottery = lotDal.GetSysLotteryById(int32_2);

                if (betDal.CheckBetTime(int32_2) == false)
                {
                    this._response = this.JsonResult(0, string.Format("凌晨1点55分到上午10点, [{0}]暂停开奖", lottery.Title));
                    return;
                }

                try
                {
                    string[] issueTimeAndSn = betDal.GetIssueTimeAndSN(int32_2);
                    string   str1           = issueTimeAndSn[0];
                    DateTime dateTime       = Convert.ToDateTime(issueTimeAndSn[1]);
                    DateTime serverTime     = FlexDAL.PublicDAL.GetServerTime();
                    string   str2           = betDal.CheckBet(int32_1, int32_2, Convert.ToDecimal(num), dateTime);
                    if (!string.IsNullOrEmpty(str2))
                    {
                        this._response = this.JsonResult(0, str2);
                    }
                    else
                    {
                        Decimal        money   = new Decimal();
                        UserZhBetModel zhmodel = new UserZhBetModel();
                        zhmodel.UserId        = int32_1;
                        zhmodel.LotteryId     = int32_2;
                        zhmodel.PlayId        = 0;
                        zhmodel.StartIssueNum = str1;
                        zhmodel.TotalNums     = int32_4;
                        zhmodel.IsStop        = int32_3;
                        zhmodel.STime         = DateTime.Now;
                        List <UserBetModel>      userBetModelList = new List <UserBetModel>();
                        List <UserZhDetailModel> listZh           = new List <UserZhDetailModel>();
                        for (int index1 = 0; index1 < requestDataJsonzhList.Count; ++index1)
                        {
                            ajaxBetting.RequestDataJSONZH requestDataJsonzh2 = requestDataJsonzhList[index1];
                            this.doh.Reset();
                            this.doh.ConditionExpress = "Id=@Id";
                            this.doh.AddConditionParameter("@Id", (object)requestDataJsonzh2.playId.ToString());
                            string str3 = string.Concat(this.doh.GetField("Sys_PlaySmallType", "Title2"));
                            if (Convert.ToDecimal(requestDataJsonzh2.price) < Decimal.Zero || Convert.ToDecimal(requestDataJsonzh2.Num) < Decimal.One || Convert.ToDecimal(requestDataJsonzh2.times) < Decimal.One)
                            {
                                this._response = this.JsonResult(0, "投注错误!请重新投注!");
                                return;
                            }
                            Decimal singelBouns = new Decimal();
                            string  str4        = Calculate.BetNumerice(int32_1, int32_2, requestDataJsonzh2.balls, requestDataJsonzh2.playId.ToString(), requestDataJsonzh2.strPos, Convert.ToInt32(requestDataJsonzh2.Num), Convert.ToDecimal(requestDataJsonzh2.Point), ref singelBouns);
                            if (!string.IsNullOrEmpty(str4))
                            {
                                this._response = str4.Replace("[", "").Replace("]", "");
                                return;
                            }
                            if (singelBouns <= Decimal.Zero)
                            {
                                this._response = this.JsonResult(0, "投注失败,返点错误,请重新投注!");
                                return;
                            }
                            UserBetModel userBetModel = new UserBetModel();
                            userBetModel.UserId      = int32_1;
                            userBetModel.UserMoney   = Decimal.Zero;
                            userBetModel.LotteryId   = int32_2;
                            userBetModel.PlayId      = Convert.ToInt32(requestDataJsonzh2.playId);
                            userBetModel.PlayCode    = str3;
                            userBetModel.SingleMoney = Convert.ToDecimal(requestDataJsonzh2.price);
                            userBetModel.Num         = Convert.ToInt32(requestDataJsonzh2.Num);
                            userBetModel.Detail      = requestDataJsonzh2.balls;
                            userBetModel.Point       = Convert.ToDecimal(requestDataJsonzh2.Point);
                            userBetModel.Bonus       = singelBouns;
                            userBetModel.Pos         = requestDataJsonzh2.strPos;
                            userBetModel.STime2      = serverTime;
                            userBetModel.IsDelay     = 0;
                            userBetModel.ZHID        = 0;
                            for (int index2 = 0; index2 < requestDataJsonzh2.table2.Count; ++index2)
                            {
                                ajaxBetting.RequestDataJSONZH2 requestDataJsonzH2 = requestDataJsonzh2.table2[index2];
                                if (Convert.ToInt32(requestDataJsonzH2.ZHTimes) > 0 && Convert.ToDecimal(requestDataJsonzH2.ZHIssueNum.Replace("-", "")) >= Convert.ToDecimal(str1.Replace("-", "")))
                                {
                                    UserZhDetailModel userZhDetailModel = new UserZhDetailModel();
                                    userZhDetailModel.IssueNum = requestDataJsonzH2.ZHIssueNum;
                                    userZhDetailModel.Times    = Convert.ToInt32(requestDataJsonzH2.ZHTimes);
                                    userZhDetailModel.STime    = Convert.ToDateTime(requestDataJsonzH2.ZHSTime);
                                    userZhDetailModel.Lists.Add(userBetModel);
                                    money += userBetModel.SingleMoney * (Decimal)userBetModel.Num * (Decimal)userZhDetailModel.Times;
                                    listZh.Add(userZhDetailModel);
                                }
                            }
                        }
                        zhmodel.TotalSums = money;
                        if (listZh.Count > 0)
                        {
                            if (betDal.InsertZhBet(zhmodel, listZh, money, "Web端追号") > 0)
                            {
                                this._response = this.JsonResult(1, "追号成功!请等待开奖!");
                            }
                            else
                            {
                                this._response = this.JsonResult(0, "对不起,投注失败!");
                            }
                        }
                        else
                        {
                            this._response = this.JsonResult(0, "对不起,投注失败!0");
                        }
                    }
                }
                catch (Exception ex)
                {
                    this._response = this.JsonResult(0, "对不起,投注失败!");
                }
            }
        }
Ejemplo n.º 2
0
        private void ajaxZHBetting()
        {
            if (this.AdminId == "")
            {
                this._response = base.JsonResult(0, "投注失败,请重新登录后再进行投注!");
                return;
            }
            HttpContext.Current.Response.ContentType = "application/json";
            string str = new StreamReader(HttpContext.Current.Request.InputStream).ReadToEnd();
            List <ajaxBetting.RequestDataJSONZH> list = ajaxBetting.JSONToObject <List <ajaxBetting.RequestDataJSONZH> >("[" + str + "]");

            ajaxBetting.RequestDataJSONZH requestDataJSONZH = new ajaxBetting.RequestDataJSONZH();
            int     userId    = Convert.ToInt32(this.AdminId);
            int     lotteryId = Convert.ToInt32(list[0].lotteryId);
            int     isStop    = Convert.ToInt32(list[0].IsStop);
            int     totalNums = Convert.ToInt32(list[0].ZHNums);
            decimal num       = Convert.ToDecimal(list[0].ZHSums);

            try
            {
                string[] expr_D3    = new Lottery.DAL.Flex.UserBetDAL().GetIssueTimeAndSN(lotteryId);
                string   text       = expr_D3[0];
                DateTime sTime      = Convert.ToDateTime(expr_D3[1]);
                DateTime serverTime = PublicDAL.GetServerTime();
                string   text2      = new Lottery.DAL.Flex.UserBetDAL().CheckBet(userId, lotteryId, Convert.ToDecimal(num), sTime);
                if (!string.IsNullOrEmpty(text2))
                {
                    this._response = base.JsonResult(0, text2);
                }
                else
                {
                    num = 0m;
                    UserZhBetModel userZhBetModel = new UserZhBetModel();
                    userZhBetModel.UserId        = userId;
                    userZhBetModel.LotteryId     = lotteryId;
                    userZhBetModel.PlayId        = 0;
                    userZhBetModel.StartIssueNum = text;
                    userZhBetModel.TotalNums     = totalNums;
                    userZhBetModel.IsStop        = isStop;
                    userZhBetModel.STime         = DateTime.Now;
                    new List <UserBetModel>();
                    List <UserZhDetailModel> list2 = new List <UserZhDetailModel>();
                    for (int i = 0; i < list.Count; i++)
                    {
                        requestDataJSONZH = list[i];
                        this.doh.Reset();
                        this.doh.ConditionExpress = "Id=@Id";
                        this.doh.AddConditionParameter("@Id", requestDataJSONZH.playId.ToString());
                        string playCode = string.Concat(this.doh.GetField("Sys_PlaySmallType", "Title2"));
                        if (Convert.ToDecimal(requestDataJSONZH.price) < decimal.Zero || Convert.ToDecimal(requestDataJSONZH.Num) < decimal.One || Convert.ToDecimal(requestDataJSONZH.times) < decimal.One)
                        {
                            this._response = base.JsonResult(0, "投注错误!请重新投注!");
                            return;
                        }
                        decimal num2  = 0m;
                        string  text3 = Calculate.BetNumerice(userId, lotteryId, requestDataJSONZH.balls, requestDataJSONZH.playId.ToString(), requestDataJSONZH.strPos, Convert.ToInt32(requestDataJSONZH.Num), Convert.ToDecimal(requestDataJSONZH.Point), ref num2);
                        if (!string.IsNullOrEmpty(text3))
                        {
                            this._response = text3.Replace("[", "").Replace("]", "");
                            return;
                        }
                        if (num2 <= decimal.Zero)
                        {
                            this._response = base.JsonResult(0, "投注失败,返点错误,请重新投注!");
                            return;
                        }
                        UserBetModel userBetModel = new UserBetModel();
                        userBetModel.UserId      = userId;
                        userBetModel.UserMoney   = decimal.Zero;
                        userBetModel.LotteryId   = lotteryId;
                        userBetModel.PlayId      = Convert.ToInt32(requestDataJSONZH.playId);
                        userBetModel.PlayCode    = playCode;
                        userBetModel.SingleMoney = Convert.ToDecimal(requestDataJSONZH.price);
                        userBetModel.Num         = Convert.ToInt32(requestDataJSONZH.Num);
                        userBetModel.Detail      = requestDataJSONZH.balls;
                        userBetModel.Point       = Convert.ToDecimal(requestDataJSONZH.Point);
                        userBetModel.Bonus       = num2;
                        userBetModel.Pos         = requestDataJSONZH.strPos;
                        userBetModel.STime2      = serverTime;
                        userBetModel.IsDelay     = 0;
                        userBetModel.ZHID        = 0;
                        for (int j = 0; j < requestDataJSONZH.table2.Count; j++)
                        {
                            ajaxBetting.RequestDataJSONZH2 requestDataJSONZH2 = requestDataJSONZH.table2[j];
                            if (Convert.ToInt32(requestDataJSONZH2.ZHTimes) > 0 && Convert.ToDecimal(requestDataJSONZH2.ZHIssueNum.Replace("-", "")) >= Convert.ToDecimal(text.Replace("-", "")))
                            {
                                UserZhDetailModel userZhDetailModel = new UserZhDetailModel();
                                userZhDetailModel.IssueNum = requestDataJSONZH2.ZHIssueNum;
                                userZhDetailModel.Times    = Convert.ToInt32(requestDataJSONZH2.ZHTimes);
                                userZhDetailModel.STime    = Convert.ToDateTime(requestDataJSONZH2.ZHSTime);
                                userZhDetailModel.Lists.Add(userBetModel);
                                num += userBetModel.SingleMoney * userBetModel.Num * userZhDetailModel.Times;
                                list2.Add(userZhDetailModel);
                            }
                        }
                    }
                    userZhBetModel.TotalSums = num;
                    if (list2.Count > 0)
                    {
                        if (new Lottery.DAL.Flex.UserBetDAL().InsertZhBet(userZhBetModel, list2, num, "Web端追号") > 0)
                        {
                            this._response = base.JsonResult(1, "追号成功!请等待开奖!");
                        }
                        else
                        {
                            this._response = base.JsonResult(0, "对不起,投注失败!");
                        }
                    }
                    else
                    {
                        this._response = base.JsonResult(0, "对不起,投注失败!0");
                    }
                }
            }
            catch (Exception)
            {
                this._response = base.JsonResult(0, "对不起,投注失败!");
            }
        }