Ejemplo n.º 1
0
        private static DateTime?OpenTime      = null; //开奖时间

        public static void QqSsc()
        {
            try
            {
                //http://api.b1cp.com/t?p=json&t=qqffc&token=FF446B723EB25993
                //http://www.b1cp.com/api?p=json&t=txffc&limit=1&token=00fb782bad8e5241
                Log.Debug("开始腾迅分分彩...");

                SysLotteryModel sysLottery = _lotteryDal.GetSysLotteryByCode("qqffc");

                if (sysLottery == null || string.IsNullOrEmpty(sysLottery.ApiUrl))
                {
                    throw new Exception("无效的API配置");
                }

                //Stopwatch sw = new Stopwatch();
                //sw.Start(); //  开始监视代码运行时间

                //如果上期开奖时间大于1分钟
                if (OpenTime.HasValue && OpenTime.Value.AddSeconds(60) > DateTime.Now)
                {
                    return;
                }

                //string url = "http://api.b1cp.com/t?p=json&t=txffc&token=776E371D7EF404E4";
                //IList<ByLottery> data = ByHelper.GetLotteryData(url);
                IList <ByLottery> data = ByHelper.GetLotteryData(sysLottery.ApiUrl);

                //sw.Stop(); //  停止监视
                //Log.DebugFormat("获取腾迅分分彩花费时间: {0}毫秒", sw.Elapsed.Milliseconds);

                foreach (ByLottery lot in data)
                {
                    string openTime = lot.opentime;
                    string openCode = lot.opencode;
                    string expect   = lot.expect; //期号

                    expect = expect.Substring(0, 8) + "-" + expect.Substring(8);

                    //存储开奖号码
                    if (_dal.Update(1005, expect, openCode, openTime, openCode))
                    {
                        OpenTime = Convert.ToDateTime(openTime);  //开奖时间
                        Public.SaveLotteryData2File(1005);        //存储开奖号码到JSON/XML文件
                        LotteryCheck.RunOfIssueNum(1005, expect); //处理开奖信息
                    }
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("腾讯分分彩异常: {0}", ex);
                //new LogExceptionDAL().Save("采集异常", "腾讯分分彩获取开奖数据出错,错误代码:" + ex.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取彩票系统配置
        /// </summary>
        /// <returns>彩票详细</returns>
        public SysLotteryModel GetSysLotteryById(int id)
        {
            IList <SysLotteryModel> lotteries = GetSysLotteries();
            SysLotteryModel         lottery   = null;

            if (lotteries != null && lotteries.Count > 0)
            {
                lottery = (from lt in lotteries where lt.Id == id select lt).FirstOrDefault();
            }

            return(lottery);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取彩票系统配置
        /// </summary>
        /// <param name="code">彩票code</param>
        /// <returns>彩票详细</returns>
        public SysLotteryModel GetSysLotteryByCode(string code)
        {
            IList <SysLotteryModel> lotteries = GetSysLotteries();
            SysLotteryModel         lottery   = null;

            if (lotteries != null && lotteries.Count > 0)
            {
                lottery = (from lt in lotteries where lt.Code.Equals(code, StringComparison.OrdinalIgnoreCase) select lt).FirstOrDefault();
            }

            return(lottery);
        }
        /// <summary>
        /// 更新彩票数据
        /// </summary>
        /// <param name="code">彩票编码</param>
        public static void UpdateData(object code = null)
        {
            try
            {
                //http://api.b1cp.com/t?p=json&t=qqffc&token=FF446B723EB25993
                //http://www.b1cp.com/api?p=json&t=txffc&limit=1&token=00fb782bad8e5241
                //Log.Debug("开始QqSsc...");

                //if (code == "ssl")
                //{
                //    string test = "";
                //}

                SysLotteryModel sysLottery = _lotteryDal.GetSysLotteryByCode(code.ToString());

                Log.DebugFormat("获取开奖信息: {0} {1}", sysLottery.Title, sysLottery.Code);
                if (sysLottery == null || string.IsNullOrEmpty(sysLottery.ApiUrl))
                {
                    throw new Exception("无效的API配置");
                }

                int lotId = sysLottery.Id; //彩票Id
                IList <ByLottery> data = ByHelper.GetLotteryData(sysLottery.ApiUrl);

                foreach (ByLottery lot in data)
                {
                    string openTime = lot.opentime;
                    string openCode = lot.opencode;
                    string expect   = lot.expect; //期号

                    expect = GetExpect(code.ToString(), expect);

                    if (_dal.Update(lotId, expect, openCode, openTime, openCode))
                    {
                        Public.SaveLotteryData2File(lotId);
                        LotteryCheck.RunOfIssueNum(lotId, expect);
                        Log.DebugFormat("发布开奖信息: {0} {1}", sysLottery.Title, openCode);
                    }

                    Log.DebugFormat("开奖信息详细: {0} {1} {2}", sysLottery.Title, expect, openCode);
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("官方彩票异常: {0} {1}", code != null ? code.ToString() : "奖种无效", ex);
                //new LogExceptionDAL().Save("采集异常", "腾讯分分彩获取开奖数据出错,错误代码:" + ex.Message);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 检查投注时间
        /// </summary>
        private void ajaxCheckBetTime()
        {
            LotteryDAL lotDal = new LotteryDAL();

            FlexDAL.UserBetDAL betDal = new FlexDAL.UserBetDAL();
            string             id     = this.q("id"); //彩中编码
            int lotteryid             = 0;

            Int32.TryParse(id, out lotteryid);
            SysLotteryModel lottery = lotDal.GetSysLotteryById(lotteryid);

            if (betDal.CheckBetTime(lotteryid) == false)
            {
                this._response = this.JsonResult(0, string.Format("凌晨1点55分到上午10点, [{0}]暂停开奖", lottery.Title));
            }
            else
            {
                this._response = this.JsonResult(1, "有效开奖时间");
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取彩票系统配置
        /// </summary>
        /// <returns>彩票详细</returns>
        public IList <SysLotteryModel> GetSysLotteries()
        {
            IList <SysLotteryModel> lotteries = (IList <SysLotteryModel>)RTCache.Get(Const.CACHE_KEY_SYS_LOTTERY);

            if (lotteries == null || lotteries.Count <= 0)
            {
                lotteries = new List <SysLotteryModel>();
                using (DbOperHandler db = new ComData().Doh())
                {
                    db.Reset();
                    db.SqlCmd = "select * from Sys_Lottery order by id";
                    DataTable dataTable = db.GetDataTable();

                    if (dataTable != null && dataTable.Rows.Count > 0)
                    {
                        for (int i = 0; i < dataTable.Rows.Count; i++)
                        {
                            SysLotteryModel lot = new SysLotteryModel()
                            {
                                Id        = Convert.ToInt32(dataTable.Rows[i]["id"]),
                                Title     = Convert.ToString(dataTable.Rows[i]["Title"]),
                                Code      = Convert.ToString(dataTable.Rows[i]["Code"]),
                                CloseTime = Convert.ToInt32(dataTable.Rows[i]["CloseTime"]),
                                IsOpen    = Convert.ToBoolean(dataTable.Rows[i]["CloseTime"]),
                                ApiUrl    = Convert.ToString(dataTable.Rows[i]["ApiUrl"])
                            };

                            lotteries.Add(lot);
                        }
                    }
                }

                RTCache.Insert(Const.CACHE_KEY_SYS_LOTTERY, lotteries);
            }

            return(lotteries);
        }
Ejemplo n.º 7
0
        private void ajaxBetting2()
        {
            if (this.AdminId == "")
            {
                this._response = this.JsonResult(0, "投注失败,请重新登录后再进行投注!");
            }
            else if (this.site.BetIsOpen == 1)
            {
                this._response = this.JsonResult(0, "系统正在维护,不能投注!");
            }
            else
            {
                HttpContext.Current.Response.ContentType = "application/json";
                List <ajaxBetting.RequestDataJSON> requestDataJsonList = ajaxBetting.JSONToObject <List <ajaxBetting.RequestDataJSON> >(HttpUtility.UrlDecode(new StreamReader(HttpContext.Current.Request.InputStream).ReadToEnd()));
                ajaxBetting.RequestDataJSON        requestDataJson1    = new ajaxBetting.RequestDataJSON();
                int lotteryId = requestDataJsonList[0].lotteryId;

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

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

                int     int32 = Convert.ToInt32(this.AdminId);
                Decimal num1  = new Decimal();
                try
                {
                    string[] issueTimeAndSn = betDal.GetIssueTimeAndSN(lotteryId);
                    string   str1           = issueTimeAndSn[0];
                    DateTime dateTime       = Convert.ToDateTime(issueTimeAndSn[1]);
                    DateTime serverTime     = FlexDAL.PublicDAL.GetServerTime();
                    for (int index = 0; index < requestDataJsonList.Count; ++index)
                    {
                        ajaxBetting.RequestDataJSON requestDataJson2 = requestDataJsonList[index];
                        num1 += requestDataJson2.price * (Decimal)requestDataJson2.Num * requestDataJson2.times;
                    }
                    string str2 = betDal.CheckBet(int32, lotteryId, Convert.ToDecimal(num1), dateTime);
                    if (!string.IsNullOrEmpty(str2))
                    {
                        this._response = this.JsonResult(0, str2);
                    }
                    else
                    {
                        int num2 = 0;
                        for (int index = 0; index < requestDataJsonList.Count; ++index)
                        {
                            ajaxBetting.RequestDataJSON requestDataJson2 = requestDataJsonList[index];
                            this.doh.Reset();
                            this.doh.ConditionExpress = "Id=@Id";
                            this.doh.AddConditionParameter("@Id", (object)requestDataJson2.playId.ToString());
                            string  str3        = string.Concat(this.doh.GetField("Sys_PlaySmallType", "Title2"));
                            Decimal singelBouns = new Decimal();
                            if (lotteryId != 5001)
                            {
                                if (Convert.ToDecimal(requestDataJson2.price) < Decimal.Zero || Convert.ToDecimal(requestDataJson2.Num) < Decimal.One || Convert.ToDecimal(requestDataJson2.times) < Decimal.One)
                                {
                                    this._response = this.JsonResult(0, "投注错误!请重新投注!");
                                    return;
                                }
                                string str4 = Calculate.BetNumerice(int32, lotteryId, requestDataJson2.balls, requestDataJson2.playId.ToString(), requestDataJson2.strPos, Convert.ToInt32(requestDataJson2.Num), Convert.ToDecimal(requestDataJson2.Point), ref singelBouns);
                                if (!string.IsNullOrEmpty(str4))
                                {
                                    this._response = str4.Replace("[", "").Replace("]", "");
                                    return;
                                }
                                if (singelBouns <= Decimal.Zero)
                                {
                                    this._response = this.JsonResult(0, "投注失败,返点错误,请重新投注!");
                                    return;
                                }
                                if (Convert.ToDecimal(requestDataJson2.price) * (Decimal)Convert.ToInt32(requestDataJson2.Num) * (Decimal)Convert.ToInt32(requestDataJson2.times) >= new Decimal(1000000))
                                {
                                    this._response = this.JsonResult(0, "投注失败,单个玩法投注额不能超过100万!");
                                    return;
                                }
                            }
                            UserBetModel model = new UserBetModel();
                            model.UserId      = int32;
                            model.UserMoney   = Decimal.Zero;
                            model.LotteryId   = lotteryId;
                            model.PlayId      = Convert.ToInt32(requestDataJson2.playId.ToString());
                            model.PlayCode    = str3;
                            model.IssueNum    = str1;
                            model.SingleMoney = Convert.ToDecimal(requestDataJson2.price);
                            model.Num         = Convert.ToInt32(requestDataJson2.Num);
                            model.Detail      = requestDataJson2.balls;
                            model.Point       = Convert.ToDecimal(requestDataJson2.Point);
                            model.Bonus       = singelBouns;
                            model.Pos         = requestDataJson2.strPos;
                            model.STime       = dateTime;
                            model.STime2      = serverTime;
                            model.IsDelay     = 0;
                            model.Times       = Convert.ToDecimal(requestDataJson2.times);
                            model.ZHID        = 0;
                            num2 = !model.Pos.Equals("") ?
                                   betDal.InsertBetPos(model, "Web端") :
                                   (model.PlayCode.Equals("P_5ZH") || model.PlayCode.Equals("P_4ZH_L") || (model.PlayCode.Equals("P_4ZH_R") || model.PlayCode.Equals("P_3ZH_L")) || (model.PlayCode.Equals("P_3ZH_C") || model.PlayCode.Equals("P_3ZH_R")) ?
                                    betDal.InsertBetZH(model, "Web端") :
                                    betDal.InsertBet(model, "Web端"));
                        }
                        if (num2 > 0)
                        {
                            this._response = this.JsonResult(1, "第" + str1 + "期投注成功,请期待开奖!");
                        }
                        else
                        {
                            this._response = this.JsonResult(0, "对不起,投注失败!");
                        }
                        //this._response = this.JsonResult(1, "第" + str1 + "期投注成功,请期待开奖!");
                    }
                }
                catch (Exception ex)
                {
                    this._response = this.JsonResult(0, "对不起,投注失败!" + (object)ex);
                }
            }
        }
Ejemplo n.º 8
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, "对不起,投注失败!");
                }
            }
        }
        private void ajaxBetting2()
        {
            if (this.AdminId == "")
            {
                this._response = this.JsonResult(0, "投注失败,请重新登录后再进行投注!");
            }
            else if (this.site.BetIsOpen == 1)
            {
                this._response = this.JsonResult(0, "系统正在维护,不能投注!");
            }
            else
            {
                HttpContext.Current.Response.ContentType = "application/json";
                List <ajaxBetting.RequestDataJSON> requestDataJsonList = ajaxBetting.JSONToObject <List <ajaxBetting.RequestDataJSON> >(HttpUtility.UrlDecode(new StreamReader(HttpContext.Current.Request.InputStream).ReadToEnd()));
                ajaxBetting.RequestDataJSON        requestDataJson1    = new ajaxBetting.RequestDataJSON();
                int lotteryId1 = requestDataJsonList[0].lotteryId;   //投注信息
                int int32_1    = Convert.ToInt32(this.AdminId);      //会员Id

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

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


                Decimal num1 = new Decimal(0);
                try
                {
                    //获取当前一期时间和期号
                    string[] issueTimeAndSn = betDal.GetIssueTimeAndSN(lotteryId1);
                    string   str1           = issueTimeAndSn[0];                     //期号
                    DateTime dateTime       = Convert.ToDateTime(issueTimeAndSn[1]); //开奖时间
                    DateTime serverTime     = FlexDAL.PublicDAL.GetServerTime();     //系统时间
                    for (int index = 0; index < requestDataJsonList.Count; ++index)
                    {
                        ajaxBetting.RequestDataJSON requestDataJson2 = requestDataJsonList[index];
                        num1 += requestDataJson2.price * (Decimal)requestDataJson2.Num * requestDataJson2.times;
                    }
                    string str2 = betDal.CheckBet(int32_1, lotteryId1, Convert.ToDecimal(num1), dateTime);
                    if (!string.IsNullOrEmpty(str2))
                    {
                        this._response = this.JsonResult(0, str2);
                    }
                    else
                    {
                        int num2 = 0;
                        for (int index = 0; index < requestDataJsonList.Count; ++index)
                        {
                            ajaxBetting.RequestDataJSON requestDataJson2 = requestDataJsonList[index];
                            this.doh.Reset();
                            this.doh.ConditionExpress = "Id=@Id";
                            DbOperHandler doh            = this.doh;
                            string        _conditionName = "@Id";
                            int           playId1        = requestDataJson2.playId;
                            string        str3           = playId1.ToString();
                            doh.AddConditionParameter(_conditionName, (object)str3);
                            string  str4        = string.Concat(this.doh.GetField("Sys_PlaySmallType", "Title2"));
                            Decimal singelBouns = new Decimal(0);
                            if (lotteryId1 != 5001)
                            {
                                if (Convert.ToDecimal(requestDataJson2.price) < new Decimal(0) || Convert.ToDecimal(requestDataJson2.Num) < new Decimal(1) || Convert.ToDecimal(requestDataJson2.times) < new Decimal(1))
                                {
                                    this._response = this.JsonResult(0, "投注错误!请重新投注!");
                                    return;
                                }
                                int    userId     = int32_1;
                                int    lotteryId2 = lotteryId1;
                                string balls      = requestDataJson2.balls;
                                playId1 = requestDataJson2.playId;
                                string  playId2 = playId1.ToString();
                                string  strPos  = requestDataJson2.strPos;
                                int     int32_2 = Convert.ToInt32(requestDataJson2.Num);
                                Decimal Point   = Convert.ToDecimal(requestDataJson2.Point);
                                string  str5    = Calculate.BetNumerice(userId, lotteryId2, balls, playId2, strPos, int32_2, Point, ref singelBouns);
                                if (!string.IsNullOrEmpty(str5))
                                {
                                    this._response = str5.Replace("[", "").Replace("]", "");
                                    return;
                                }
                                if (singelBouns <= new Decimal(0))
                                {
                                    this._response = this.JsonResult(0, "投注失败,返点错误,请重新投注!");
                                    return;
                                }
                            }
                            UserBetModel model = new UserBetModel();
                            model.UserId      = int32_1;
                            model.UserMoney   = new Decimal(0);
                            model.LotteryId   = lotteryId1;
                            model.PlayId      = Convert.ToInt32(requestDataJson2.playId);
                            model.PlayCode    = str4;
                            model.IssueNum    = str1;
                            model.SingleMoney = Convert.ToDecimal(requestDataJson2.price);
                            model.Num         = Convert.ToInt32(requestDataJson2.Num);
                            model.Detail      = requestDataJson2.balls;
                            model.Point       = Convert.ToDecimal(requestDataJson2.Point);
                            model.Bonus       = singelBouns;
                            model.Pos         = requestDataJson2.strPos;
                            model.STime       = dateTime;
                            model.STime2      = serverTime;
                            model.IsDelay     = 0;
                            model.Times       = Convert.ToDecimal(requestDataJson2.times);
                            model.ZHID        = 0;
                            num2 = !model.Pos.Equals("") ?
                                   betDal.InsertBetPos(model, "手机端") :
                                   (!model.PlayCode.Equals("P_5ZH") && !model.PlayCode.Equals("P_4ZH_L") && (!model.PlayCode.Equals("P_4ZH_R") && !model.PlayCode.Equals("P_3ZH_L")) && !model.PlayCode.Equals("P_3ZH_C") && !model.PlayCode.Equals("P_3ZH_R") ?
                                    betDal.InsertBet(model, "手机端") :
                                    betDal.InsertBetZH(model, "手机端"));
                        }
                        if (num2 > 0)
                        {
                            this._response = this.JsonResult(1, "第" + str1 + "期投注成功,请期待开奖!");
                        }
                        else
                        {
                            this._response = this.JsonResult(0, "对不起,投注失败!");
                        }

                        //this._response = this.JsonResult(1, "第" + str1 + "期投注成功,请期待开奖!");
                    }
                }
                catch (Exception ex)
                {
                    this._response = this.JsonResult(0, "对不起,投注失败!");
                }
            }
        }
Ejemplo n.º 10
0
        private void ajaxLotteryTime()
        {
            LotteryDAL dal = new LotteryDAL();

            string ltId = this.q("lid");//彩种Id
            int    id;

            if (Int32.TryParse(ltId, out id) == false)
            {
                this._response = "{}";
                return;
            }

            SysLotteryModel lottery = dal.GetSysLotteryById(id);

            if (lottery == null)
            {
                this._response = "{}";
                return;
            }

            string str2 = "0";
            //名称
            //彩种类别
            //倒计时
            //封单时间
            //下期期号
            //已开期数
            //当前期号
            string ltInfo = "{\"name\": \"名称\",\"lotteryid\": \"彩种类别\",\"ordertime\": \"倒计时\",\"closetime\": \"封单时间\",\"nestsn\": \"下期期号\",\"opennum\": \"已开期数\",\"cursn\": \"当前期号\"}";

            ltInfo = ltInfo.Replace("名称", lottery.Title);
            ltInfo = ltInfo.Replace("彩种类别", ltId);
            ltInfo = ltInfo.Replace("封单时间", lottery.CloseTime.ToString());

            DateTime dateTime1 = DateTime.Now;
            //DateTime curDateTime = this.GetDateTime(); //当前日期时间
            DateTime curDateTime = this.GetDateTime();               //当前日期时间
            string   curDate     = curDateTime.ToString("yyyyMMdd"); //当前日期
            string   curTime     = curDateTime.ToString("HH:mm:ss"); //当前时间

            int      num;
            string   newValue1;
            string   newValue2;
            TimeSpan timeSpan;

            if (ltId == "3002" || ltId == "3003")
            {
                num = curDateTime.Year;
                DateTime dateTime3 = Convert.ToDateTime(num.ToString() + "-01-01 20:30:00");
                this.doh.Reset();
                this.doh.SqlCmd = "select datediff(d,'" + dateTime3.ToString("yyyy-MM-dd HH:mm:ss") + "','" + curDateTime.ToString("yyyy-MM-dd HH:mm:ss") + "') as d";
                int    Num  = Convert.ToInt32(this.doh.GetDataTable().Rows[0]["d"]) - 7 + 1;
                string str7 = curDateTime.AddDays(-1.0).ToString("yyyy-MM-dd") + " 20:30:00";
                string str8 = curDateTime.ToString("yyyy-MM-dd") + " 20:30:00";
                if (curDateTime > Convert.ToDateTime(curDateTime.ToString(" 20:30:00")))
                {
                    str8 = curDateTime.AddDays(1.0).ToString("yyyy-MM-dd") + " 20:30:00";
                }
                else
                {
                    --Num;
                }
                num       = curDateTime.Year;
                newValue1 = num.ToString() + Func.AddZero(Num, 3);
                num       = curDateTime.Year;
                newValue2 = num.ToString() + Func.AddZero(Num + 1, 3);
                timeSpan  = Convert.ToDateTime(str8) - Convert.ToDateTime(curTime);
            }
            else
            {
                if (UserCenterSession.LotteryTime == null)
                {
                    UserCenterSession.LotteryTime = new LotteryTimeDAL().GetTable();
                }
                DataRow[] dataRowArray1 = UserCenterSession.LotteryTime.Select("Time >'" + curTime + "' and LotteryId=" + ltId, "Time asc");
                if (dataRowArray1.Length == 0)
                {
                    dataRowArray1 = UserCenterSession.LotteryTime.Select("Time <='" + curTime + "' and LotteryId=" + ltId, "Time asc");
                    newValue2     = curDateTime.AddDays(1.0).ToString("yyyyMMdd") + "-" + dataRowArray1[0]["Sn"].ToString();
                }
                else
                {
                    newValue2 = curDate + "-" + dataRowArray1[0]["Sn"].ToString();
                    dateTime1 = Convert.ToDateTime(dataRowArray1[0]["Time"].ToString());
                    if (curDateTime > Convert.ToDateTime(curDateTime.ToString("yyyy-MM-dd") + " 00:00:00") && curDateTime < Convert.ToDateTime(curDateTime.ToString("yyyy-MM-dd") + " 10:00:01") && ltId == "1003")
                    {
                        newValue2 = curDateTime.AddDays(-1.0).ToString("yyyyMMdd") + "-" + dataRowArray1[0]["Sn"].ToString();
                    }
                    if (curDateTime > Convert.ToDateTime(curDateTime.ToString("yyyy-MM-dd") + " 23:00:00") && curDateTime < Convert.ToDateTime(curDateTime.ToString("yyyy-MM-dd") + " 23:59:59") && (ltId == "1014" || ltId == "1016"))
                    {
                        newValue2 = curDateTime.AddDays(1.0).ToString("yyyyMMdd") + "-" + dataRowArray1[0]["Sn"].ToString();
                    }
                }
                if (Convert.ToDateTime(dataRowArray1[0]["Time"].ToString()) < Convert.ToDateTime(curTime))
                {
                    dateTime1 = Convert.ToDateTime(curDateTime.AddDays(1.0).ToString("yyyy-MM-dd") + " " + dataRowArray1[0]["Time"].ToString());
                }
                timeSpan = dateTime1 - Convert.ToDateTime(curTime);
                DataRow[] dataRowArray2 = UserCenterSession.LotteryTime.Select("Time <'" + curTime + "' and LotteryId=" + ltId, "Time desc");
                if (dataRowArray2.Length == 0)
                {
                    dataRowArray2 = UserCenterSession.LotteryTime.Select("LotteryId=" + ltId, "Time desc");
                    newValue1     = curDateTime.AddDays(-1.0).ToString("yyyyMMdd") + "-" + dataRowArray2[0]["Sn"].ToString();
                    str2          = dataRowArray2[0]["Sn"].ToString();
                }
                else
                {
                    newValue1 = curDate + "-" + dataRowArray2[0]["Sn"].ToString();
                    str2      = dataRowArray2[0]["Sn"].ToString();
                    if (curDateTime > Convert.ToDateTime(curDateTime.ToString("yyyy-MM-dd") + " 00:00:00") && curDateTime < Convert.ToDateTime(curDateTime.ToString("yyyy-MM-dd") + " 10:00:01") && ltId == "1003")
                    {
                        newValue1 = curDateTime.AddDays(-1.0).ToString("yyyyMMdd") + "-" + dataRowArray2[0]["Sn"].ToString();
                        str2      = dataRowArray2[0]["Sn"].ToString();
                    }
                    if (curDateTime > Convert.ToDateTime(curDateTime.ToString("yyyy-MM-dd") + " 23:00:00") && curDateTime < Convert.ToDateTime(curDateTime.ToString("yyyy-MM-dd") + " 23:59:59") && (ltId == "1014" || ltId == "1016"))
                    {
                        newValue1 = curDateTime.AddDays(1.0).ToString("yyyyMMdd") + "-" + dataRowArray2[0]["Sn"].ToString();
                    }
                }
                if (ltId == "1010" || ltId == "1017" || ltId == "3004")
                {
                    newValue1 = string.Concat((object)(new LotteryTimeDAL().GetTsIssueNum(ltId) + Convert.ToInt32(dataRowArray2[0]["Sn"].ToString())));
                    str2      = dataRowArray2[0]["Sn"].ToString();
                    newValue2 = string.Concat((object)(Convert.ToInt32(newValue1) + 1));
                }
                if (ltId == "1012")
                {
                    newValue1 = string.Concat((object)(new LotteryTimeDAL().GetTsIssueNum("1012") + Convert.ToInt32(dataRowArray2[0]["Sn"].ToString())));
                    str2      = dataRowArray2[0]["Sn"].ToString();
                    newValue2 = string.Concat((object)(Convert.ToInt32(newValue1) + 1));
                }
                if (ltId == "1013")
                {
                    newValue1 = string.Concat((object)(new LotteryTimeDAL().GetTsIssueNum("1013") + Convert.ToInt32(dataRowArray2[0]["Sn"].ToString())));
                    str2      = dataRowArray2[0]["Sn"].ToString();
                    newValue2 = string.Concat((object)(Convert.ToInt32(newValue1) + 1));
                }
                if (ltId == "1014" || ltId == "1015" || ltId == "1016")
                {
                    newValue1 = newValue1.Replace("-", "");
                    newValue2 = newValue2.Replace("-", "");
                }
                if (ltId == "4001")
                {
                    newValue1 = string.Concat((object)(new LotteryTimeDAL().GetTsIssueNum("4001") + Convert.ToInt32(dataRowArray2[0]["Sn"].ToString())));
                    str2      = dataRowArray2[0]["Sn"].ToString();
                    newValue2 = string.Concat((object)(Convert.ToInt32(newValue1) + 1));
                }
            }
            string newValue3 = string.Concat((object)(timeSpan.Days * 24 * 60 * 60 + timeSpan.Hours * 60 * 60 + timeSpan.Minutes * 60 + timeSpan.Seconds));
            string str9      = ltInfo.Replace("下期期号", newValue2).Replace("当前期号", newValue1).Replace("倒计时", newValue3);
            string oldValue  = "已开期数";

            num = Convert.ToInt32(str2);
            string newValue4 = num.ToString();

            this._response = str9.Replace(oldValue, newValue4);
        }