Пример #1
0
        public static string GetOpenRemainingTime(int lType)
        {
            DateTime d = DateTime.Now;

            if (lType < 9)
            {
                #region 3D 双色球 七星彩 大乐透 六合彩 排3 排5 七乐彩

                string   sql    = "select OpenLine from DateLine where lType = " + lType;
                DateTime target = (DateTime)SqlHelper.ExecuteScalar(sql);

                if (d > target)
                {
                    return("正在开奖");
                }

                return(Util.GetTwoDateCha(d, target));

                #endregion
            }
            else if (lType >= 9 && lType < 15)
            {
                #region 时时彩
                //8点-10点
                var list = LotteryTime.GetLotteryTimeList().Where(x => x.LType == lType.ToString());

                #endregion
            }

            return(string.Empty);
        }
Пример #2
0
        public ApiResult <List <LotteryTimeModel> > GetLotteryTimeSettings(int ltype)
        {
            var list = LotteryTime.GetLotteryTimeModelList();

            return(new ApiResult <List <LotteryTimeModel> >()
            {
                Data = list
            });
        }
Пример #3
0
        /// <summary>
        /// 发布计划
        /// </summary>
        public ApiResult Bet(int lType, string currentIssue, string betInfo, long userId)
        {
            #region 校验
            //获取当前状态
            string time = LotteryTime.GetTime(lType.ToString());
            if (time == "正在开奖")
            {
                return(new ApiResult(400, "发帖失败,当期已封盘"));
            }

            if (LuoUtil.GetRemainingTime(lType) == "已封盘")
            {
                return(new ApiResult(400, "发帖失败,当期已封盘"));
            }

            //校验当前这期是否已开奖
            string isOpenSql = "select count(1) from dbo.LotteryRecord where lType=" + lType + " and Issue=@Issue";
            object obj       = SqlHelper.ExecuteScalar(isOpenSql, new SqlParameter("@Issue", currentIssue));
            if (obj != null && Convert.ToInt32(obj) > 0)
            {
                return(new ApiResult(400, "发帖失败,当期已封盘"));
            }

            //获取当前最新期
            string currentLastIssue = LuoUtil.GetCurrentIssue(lType);
            if (string.IsNullOrEmpty(currentLastIssue) && currentIssue != currentLastIssue)
            {
                return(new ApiResult(400, "发帖失败,当期已封盘"));
            }

            #endregion

            //数据清理
            string sql = "delete from BettingRecord where UserId=" + userId + " and lType =" + lType + " and Issue=@Issue";
            SqlHelper.ExecuteNonQuery(sql, new SqlParameter("@Issue", currentIssue));



            string[] betInfoArr = betInfo.Split('$');

            string playName  = "";
            string playName2 = "";            //单双  大小 五码
            string betNum    = "";
            string s1        = "";


            foreach (string s in betInfoArr)
            {
                string[] arr = s.Split('*');

                playName = arr[0];
                betNum   = arr[1];

                string[] betNumArr = betNum.Split('|');

                for (int i = 0; i < betNumArr.Length; i++)
                {
                    s1 = betNumArr[i];

                    if (!string.IsNullOrEmpty(s1))
                    {
                        playName2 = Util.GetPlayName(lType, playName, s1, i);

                        sql = "insert into BettingRecord(UserId,lType,Issue,BigPlayName,PlayName,BetNum,SubTime) values(" + userId + "," + lType + ",@Issue,@BigPlayName,@PlayName,@BetNum,GETDATE())";

                        SqlParameter[] pms =
                        {
                            new SqlParameter("@Issue",       currentIssue),
                            new SqlParameter("@BigPlayName", playName),
                            new SqlParameter("@PlayName",    playName + playName2),
                            new SqlParameter("@BetNum",      s1),
                        };

                        SqlHelper.ExecuteNonQuery(sql, pms);
                    }
                }
            }
            return(new ApiResult());
        }
Пример #4
0
        /// <summary>
        /// 查询指定时间的期号,(期号一直递增的则查询最新一期期号)
        /// </summary>
        /// <param name="lType">彩种Id</param>
        /// <param name="queryTime">查询时间</param>
        /// <returns></returns>
        public static string GetCurrentIssue(int lType, DateTime queryTime)
        {
            string issue = "";


            if (lType <= 8)

            {
                //期号一直递增,获取最后一次开奖号码+1
                return(Util.GetPK10Issue(lType));
            }


            //期号按天递增
            DateTime nowTime = queryTime;
            string   dateStr = nowTime.ToString("yyyyMMdd");
            //step1.查询当前彩种开奖配置
            string lotteryType = lType.ToString();

            var lotteryTimeModel = LotteryTime.GetLotteryModel(lotteryType);


            int intervalCount = 0;

            #region 处理高频彩,期号一直递增
            //step1.1查询当日第一期

            var calcDay = new DateTime(2018, 05, 01);
            int days    = (nowTime - calcDay).Days;
            if (lType == 10)
            {
                //2018年5月1日前,累计期号为0264968期,
                //则,当前初始期号 = 264968 + 相差天数 * 每天多少期
                int totalIssues = days * 84;
                intervalCount = 264968 + totalIssues;
            }
            else if (lType == 39)
            {
                int totalIssues = days * 89;
                intervalCount = 108121 + totalIssues;
            }
            else if (lType == 54)
            {
                int totalIssues = days * 84;
                intervalCount = 204856 + totalIssues;
            }
            else if (lType == 63)
            {
                int totalIssues = days * 179;
                intervalCount = 679450 + totalIssues;
            }
            else if (lType == 65)
            {
                int totalIssues = days * 179;
                intervalCount = 885428 + totalIssues;
            }
            #endregion

            //step2.判断是否获取到开奖配置,未获取到则查询最近的将要开奖的配置
            if (lotteryTimeModel == null)
            {
                //查询初始期号
                lotteryTimeModel = LotteryTime.GetModelUseIssue(lotteryType);
                intervalCount   += lotteryTimeModel.BeginIssue.ToInt32();

                var endTime = DateTime.Parse(lotteryTimeModel.EndTime);

                if (lType != 13 && lType != 35 && lType != 51 && lType != 64)
                {
                    if (endTime < nowTime)
                    {
                        dateStr = endTime.AddDays(1).ToString("yyyyMMdd");
                    }
                }
            }
            else
            {
                //if (lType != 9 && lType != 51)
                //{
                //    dateStr = lotteryTimeModel.BeginTimeDate.ToString("yyyyMMdd");
                //}

                if (lType == 9 || lType == 51)
                {
                    //获取当前阶段初始期号
                    intervalCount += lotteryTimeModel.BeginIssue.ToInt32();
                }
                else
                {
                    dateStr = lotteryTimeModel.BeginTimeDate.ToString("yyyyMMdd");
                }
                //step3.获取该彩种的开奖间隔时长。并是否小于等于0, true则返回空

                //获取当前彩种开奖间隔时长(毫秒)
                int lotteryInterval = int.Parse(lotteryTimeModel.TimeInterval) * 60000;
                if (lotteryInterval == 0)
                {
                    return(dateStr);
                }

                //step4.获取当前彩种当前阶段开始时间,并计算当前时间与开始时间的间隔(秒)

                //获取当前彩种当前阶段开始时间(重庆时时彩 9 会分多个阶段)
                //DateTime lotteryBeginTime = DateTime.Parse(lotteryTimeModel.BeginTime);
                DateTime lotteryBeginTime = lotteryTimeModel.BeginTimeDate;


                #region 处理重庆时时彩 重庆快乐十分跨天的期号 凌晨为第一期
                if ((lType == 9 || lType == 51) && lotteryTimeModel.BeginTimeDate.Day != lotteryTimeModel.EndTimeDate.Day)
                {
                    //处理 0点到2点
                    if (nowTime > lotteryTimeModel.EndTimeDate.Date)
                    {
                        intervalCount    = 0;
                        lotteryBeginTime = lotteryTimeModel.EndTimeDate.Date;
                    }
                }
                #endregion

                var intervalTimeSpan = (nowTime - lotteryBeginTime);
                //获取当前时间与开始时间间隔(秒)
                int intervalMilliseconds = (int)intervalTimeSpan.TotalMilliseconds;

                //step5.计算当前第几期
                intervalCount += (int)(intervalMilliseconds / lotteryInterval);
                if (intervalMilliseconds % lotteryInterval != 0)
                {
                    intervalCount += 1;
                }
            }


            if (lType == 10 || lType == 39 || lType == 54 || lType == 63 || lType == 65)
            {
                if (lType == 10)
                {
                    return(intervalCount.ToString("D7"));
                }

                return(intervalCount.ToString());
            }

            //step6.判断彩种类型,返回不同长度的期号
            if ((lType >= 9 && lType <= 14) || lType == 64)
            {
                issue = intervalCount.ToString("000");
            }
            else
            {
                issue = intervalCount.ToString("00");
            }

            //step7.拼接当日期号
            string result = dateStr + issue;

            //step8.处理晚上 结束后的特殊情况
            string date = nowTime.ToString("yyyy-MM-dd");
            Util.HandIssueSpecial(lType, nowTime, date, issue, result);

            return(result);
        }
Пример #5
0
        /// <summary>
        /// 查询当前彩种封盘倒计时
        /// </summary>
        /// <param name="lType"></param>
        /// <returns></returns>
        public static string GetRemainingTime(int lType)
        {
            DateTime d = DateTime.Now;

            #region 49彩 七星彩 3D 排3 排5 七乐彩
            if (lType < 9)
            {
                //查询设置的开奖时间,进行比较

                string   sql    = "select OpenLine from DateLine where lType = " + lType;
                DateTime target = (DateTime)SqlHelper.ExecuteScalar(sql);

                var diffTimespan = target - d;
                int diffSeconds  = (int)diffTimespan.TotalSeconds;
                if (0 <= diffSeconds && diffSeconds <= 30)
                {
                    return("已封盘");
                }

                return(CompareTime(d, target));
            }
            #endregion

            //查询下一期开奖时间
            string lotteryType    = lType.ToString();
            var    lotterySetting = LotteryTime.GetLotteryModel(lotteryType, d);
            if (lotterySetting == null)
            {
                lotterySetting = LotteryTime.GetModelUseIssue(lotteryType);

                if (lotterySetting == null)
                {
                    return(string.Empty);
                }

                return(GetDiffTime(lotterySetting.BeginTimeDate - d));
            }
            else
            {
                //开奖前30秒封盘


                //step1.当期开奖时间和当前时间差,获取相差总时长(毫秒)
                TimeSpan diff = d - lotterySetting.BeginTimeDate;

                int totalMilliseconds = (int)diff.TotalMilliseconds;

                //step2.计算除数
                int divisorMilliseconds = lotterySetting.TimeInterval.ToInt32() * 60 * 1000;

                //step3.计算余数
                int diffCount             = totalMilliseconds / divisorMilliseconds;
                int remainderMilliseconds = totalMilliseconds % divisorMilliseconds;

                //step4.判断是否封盘的30秒
                int disableMilliseconds = divisorMilliseconds - remainderMilliseconds;

                if (0 <= disableMilliseconds && disableMilliseconds <= 30000)
                {
                    return("已封盘");
                }

                //封盘开始时间
                DateTime disableTime =
                    lotterySetting.BeginTimeDate.AddMilliseconds((diffCount + 1) * divisorMilliseconds - 30000);
                var disableDiff = disableTime - lotterySetting.BeginTimeDate;
                return(GetDiffTime(disableDiff));
            }
        }
Пример #6
0
        /// <summary>
        /// 获取首页彩种信息列表
        /// </summary>
        /// <param name="lotteryTypePId">彩种分类Id</param>
        /// <returns></returns>
        public ApiResult <List <IndexLotteryInfoResDto> > GetIndexLotteryList(int lotteryTypePId)
        {
            //string memcacheKey = string.Format("GetIndexLotteryList_{0}", lotteryTypePId);
            string memcacheKey = string.Format(RedisKeyConst.Home_IndexLotteryList, lotteryTypePId);
            var    resDto      = CacheHelper.GetCache <List <IndexLotteryInfoResDto> >(memcacheKey);

            if (resDto == null || resDto.Count < 1)
            {
                var lotteryList = GetLotteryTypeList(lotteryTypePId).Select(x => x.lType);

                string lTypes = string.Join(",", lotteryList);


                var dateTime = DateTime.Now.AddDays(-5);
                resDto = GetLotteryRecordList(lTypes, dateTime);

                if (resDto != null && resDto.Any())
                {
                    int cacheTimeout = 4;
                    if (lotteryTypePId == 1)
                    {
                        cacheTimeout = 1440;
                    }

                    CacheHelper.AddCache(memcacheKey, resDto, cacheTimeout);
                }
            }
            else
            {
                //从缓存获取的数据,重新计算下期开奖时间
                resDto.ForEach(x =>
                {
                    x.OpenTime = LotteryTime.GetTime(x.LType.ToString());
                });
            }


            //lotteryList.ForEach(x =>
            //{
            //    var info = new IndexLotteryInfoResDto()
            //    {
            //        LType = x.lType,
            //        LTypeName = Util.GetLotteryTypeName(x.lType),
            //    };

            //    var lastLotteryRecord = GetLotteryRecord(x.lType);
            //    if (lastLotteryRecord != null)
            //    {
            //        info.OpenNum = lastLotteryRecord.Num;
            //        info.Issue = lastLotteryRecord.Issue;
            //        info.OpenTime = lastLotteryRecord.ShowOpenTime;
            //        info.OpenNumAlias = Util.GetShowInfo(lastLotteryRecord.lType, lastLotteryRecord.Num, lastLotteryRecord.SubTime);
            //       // info.CurrentIssue = LuoUtil.GetCurrentIssue(x.lType);
            //        info.CurrentIssue = "";
            //    }
            //    info.Logo = Util.GetLotteryIconUrl(x.lType);
            //    resDto.Add(info);
            //});

            return(new ApiResult <List <IndexLotteryInfoResDto> >()
            {
                Data = resDto
            });
        }