Ejemplo n.º 1
0
        public static void GetlhcInfo(LotteryResult retObj)
        {
            try
            {
                string       openuri  = "http://tkkj.cc/";
                WebRequest   request  = WebRequest.Create(openuri);
                WebResponse  response = request.GetResponse();
                StreamReader reader   = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));

                string uriInfo = reader.ReadToEnd();
                //string ExpectmarkStr = "第<font size=\"\" color=\"#ff6600\"><strong>";
                //retObj.Expect = uriInfo.Substring(uriInfo.IndexOf(ExpectmarkStr) + ExpectmarkStr.Length, 3);
                string OpencodemarkStr = "特:";
                string opencodestr     = uriInfo.Substring(uriInfo.IndexOf(OpencodemarkStr) - 17, 21);
                retObj.Opencode = opencodestr.Replace("-", ",").Replace("特:", ",");
                string NextmarkStr = "开<br/>";
                string NextStr     = uriInfo.Substring(uriInfo.IndexOf(NextmarkStr) - 19, 19);

                int nextYear = retObj.Opentime.Value.Year;
                if (retObj.NextExpect == "001")
                {
                    nextYear++;
                }
                retObj.NextExpect = nextYear.ToString() + NextStr.Substring(0, 3);
                string NextOpenTimeStr = nextYear.ToString() + "-" + NextStr.Substring(5, 5).Replace("月", "-") + " " + NextStr.Substring(NextStr.Length - 5, 5);
                retObj.NextOpenTime = DateTime.Parse(NextOpenTimeStr);
            }
            catch (Exception ex)
            {
                throw new Exception("六合彩开奖数据获取失败,原因:" + ex.Message);
            }
        }
        public static List <LotteryResult> GetPagList(string cpCode, int status, bool orderby, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string btime = "", string etime = "")
        {
            string sqlwhere = " b.cpCode='" + cpCode + "'";

            if (status > -1)
            {
                sqlwhere += " and b.Status=" + status;
            }
            if (!string.IsNullOrEmpty(btime))
            {
                sqlwhere += " and b.CreateTime>='" + btime + "'";
            }
            if (!string.IsNullOrEmpty(etime))
            {
                sqlwhere += " and b.CreateTime<='" + etime + " 23:59:59:999'";
            }
            DataTable dt = CommonBusiness.GetPagerData(" LotteryResult (nolock) b ",
                                                       "b.*", sqlwhere, "b.AutoID ", pageSize, pageIndex,
                                                       out totalCount, out pageCount, orderby);
            List <LotteryResult> list = new List <LotteryResult>();

            foreach (DataRow dr in dt.Rows)
            {
                LotteryResult model = new LotteryResult();
                model.FillData(dr);
                list.Add(model);
            }
            return(list);
        }
        public static LotteryResult GetLotteryResult(string cpCode, int status, string btime, string etime, string orderasc = "asc")
        {
            string sqlwhere = " where  b.cpCode='" + cpCode + "'";

            if (status > -1)
            {
                sqlwhere += " and b.Status=" + status;
            }

            if (!string.IsNullOrEmpty(btime))
            {
                sqlwhere += " and b.opentime>='" + btime + "'";
            }
            if (!string.IsNullOrEmpty(etime))
            {
                sqlwhere += " and b.opentime<='" + etime + " 23:59:59:999'";
            }

            DataTable     dt    = LotteryResultDAL.GetDataTable("select top 1 *  from  LotteryResult (nolock) b " + sqlwhere + " Order by AutoID " + orderasc);
            LotteryResult model = new LotteryResult();

            foreach (DataRow dr in dt.Rows)
            {
                model.FillData(dr);
            }
            return(model);
        }
Ejemplo n.º 4
0
        public OperationResult UpdateLotteryResult(Guid id, int state)
        {
            LotteryResult entity = LotteryResultRepository.Entities.Where(lr => lr.Id == id).FirstOrDefault();

            if (entity == null)
            {
                return(new OperationResult(OperationResultType.Warning, string.Format("没有Id为{0}的中奖信息。", id.ToString()), id.ToString()));
            }

            if (state == entity.LotteryResultStateNum)
            {
                return(new OperationResult(OperationResultType.Warning, "要更新的状态与数据库的一致,无需更改。", entity));
            }
            entity.LotteryResultStateNum = state;
            int rcount = LotteryResultRepository.Update(entity);

            if (rcount > 0)
            {
                return(new OperationResult(OperationResultType.Success, "更新状态成功。", entity));
            }
            else
            {
                return(new OperationResult(OperationResultType.Warning, "更新状态失败。"));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 根据官方开奖结果处理用户所有下注信息
        /// </summary>
        /// <param name="?"></param>
        public void ProcessBet(LotteryResult lotteryRes)
        {
            List <BetRecord> Recs = betService.LoadEntities(s => s.LotteryType.Equals(lotteryRes.LotteryType) && s.Expect.Equals(lotteryRes.Expect) && s.LotteryState.Equals("未开奖")).ToList();

            foreach (BetRecord item in Recs)
            {
                //先获取所有该类型该期号下的单注下注信息
                List <BetChildRecord> ChildRecs = betCService.LoadEntities(s => s.BetRecordId.Value == item.Id).ToList();
                decimal?WinMoney = 0;
                foreach (BetChildRecord Childitem in ChildRecs)
                {
                    bool isWin    = false;
                    int  opencode = int.Parse(lotteryRes.Opencode.Split(',')[Childitem.BetBallNo.Value - 1]);
                    //计算开奖结果
                    switch (Childitem.BetType)
                    {
                    case "单双":
                        isWin = isWinForSingleDouble(Childitem.BetInfo, opencode);
                        break;

                    case "大小":
                        isWin = isWinForBigSmall(Childitem.LotteryType, Childitem.BetInfo, opencode);
                        break;

                    case "数字":
                        isWin = isWinForNo(Childitem.BetInfo, opencode);
                        break;

                    default:
                        break;
                    }
                    if (isWin)
                    { //如果中奖则修改单注状态并累加父注输赢金额
                        Childitem.WinState = "中奖";

                        WinMoney += Childitem.BetMoney * decimal.Parse(Childitem.Odds.ToString());
                        //用户余额增加
                        UserInfo user = userService.LoadEntities(s => s.Name.Equals(item.BetUser)).FirstOrDefault();
                        if (user != null)
                        {
                            Account acc = accService.LoadEntities(s => s.UserId == user.id).FirstOrDefault();
                            if (acc != null)
                            {
                                acc.Balance += Childitem.BetMoney.Value * decimal.Parse(Childitem.Odds.ToString());
                                accService.UpdateEntityNoCommit(acc);
                            }
                        }
                    }
                    else
                    {
                        Childitem.WinState = "未中奖";
                    }
                    betCService.UpdateEntityNoCommit(Childitem);
                }
                item.TotalWinOrLose = WinMoney;
                item.LotteryState   = "已开奖";
                betService.UpdateEntityNoCommit(item);
                dbService.Savechange();
            }
        }
        private void Display(LotteryResult result)
        {
            Console.Write("Your 'Lottery Numbers' are: ");

            var foregroundColor = Colour.Black.ConsoleColor;

            foreach (var number in result.Numbers)
            {
                var backgroundColor = number.ToConsoleColor();

                Console.BackgroundColor = backgroundColor;
                Console.ForegroundColor = foregroundColor;
                Console.Write($" {number} ");
            }

            if (result.HasBonusBall)
            {
                var backgroundColor = result.BonusBall.ToConsoleColor();

                Console.ResetColor();
                Console.Write($" and your 'Bonus Ball' is: ");
                Console.BackgroundColor = backgroundColor;
                Console.ForegroundColor = foregroundColor;
                Console.Write($" {result.BonusBall} ");
            }

            Console.ResetColor();
            Console.WriteLine();
        }
Ejemplo n.º 7
0
        public bool ConsumeTask(LotteryTask t)
        {
            task = t;
            Browser.InitBrowser();

            Console.Write("开始采集:" + task.website);
            //彩种种类
            string subPage = GetLotteryType(task.website);
            //开奖结果
            LotteryResult lr = GetResult(subPage);

            Console.Write("采集结果:" + lr.ToString());

            bool cmp = true;
            //对比结果
            List <LotteryResult> lrs = DapperHelper.getResultByNo(lr.No.Substring(lr.No.Length - 6, 6), lr.lotteryType);

            for (int i = 0; i < lrs.Count; i++)
            {
                if (lrs[i].Number != lr.Number || lrs[i].guanYaHe != lr.guanYaHe)
                {
                    cmp = false;
                }
            }

            lr.isRight = cmp;

            DapperHelper.setLotteryResult(lr);

            return(cmp);
        }
Ejemplo n.º 8
0
        //public static void Start()
        //{
        //    ThreadStart start = new ThreadStart(GetLetteryInfo);
        //    Thread th = new Thread(start);
        //    th.IsBackground = true;
        //    th.Start();
        //}

        public static void GetLetteryInfo()
        {
            try
            {
                string            path       = System.AppDomain.CurrentDomain.BaseDirectory;
                string            fullPath   = path + "LotteryWebsite.xml";
                XDocument         doc        = XDocument.Load(fullPath);
                var               website    = doc.Descendants("webSite").Select(p => new { lotteryType = p.Element("lotteryType").Value, url = p.Element("url").Value }).ToList();
                BetLotteryProcess betprocess = new BetLotteryProcess();
                ResultProcess     resProcess = new ResultProcess();
                foreach (var item in website)
                {
                    string html = HttpGet(item.url, Encoding.UTF8);
                    LotteryResultService         lrService = new LotteryResultService();
                    Dictionary <string, JObject> dicreds   = DeserializeStringToDictionary <string, JObject>(html);
                    foreach (var dictionary in dicreds)
                    {
                        LotteryResult existLotteryResult = lrService.LoadEntities(s => s.LotteryType == item.lotteryType && s.Expect == dictionary.Key).FirstOrDefault();
                        if (existLotteryResult != null)
                        {
                            continue;
                        }
                        JObject       lottery       = dictionary.Value;
                        LotteryResult lotteryResult = new LotteryResult();
                        lotteryResult.LotteryType = item.lotteryType;
                        lotteryResult.Expect      = dictionary.Key;
                        lotteryResult.Opencode    = lottery["number"].ToString();
                        //开奖日期不能用接口反回的时间,不准确

                        //if (lotteryResult.LotteryType.Equals("六合彩"))
                        lotteryResult.Opentime = GetRealOpenTime(lotteryResult.LotteryType, DateTime.Parse(lottery["dateline"].ToString()));
                        lotteryResult.Opentime = lotteryResult.Opentime.Value.AddSeconds(0 - lotteryResult.Opentime.Value.Second);
                        //else
                        //{
                        //    LotteryResult beforeResult = lrService.LoadEntities(s => s.LotteryType == item.lotteryType).OrderByDescending(s => s.Expect).FirstOrDefault();
                        //    if (beforeResult == null)
                        //        lotteryResult.Opentime = GetRealOpenTime(lotteryResult.LotteryType, DateTime.Parse(lottery["dateline"].ToString()));
                        //    else
                        //        lotteryResult.Opentime = beforeResult.NextOpenTime;
                        //}
                        if (lotteryResult.LotteryType.Equals("六合彩"))
                        {
                            GetHttpInfoForlhc.GetlhcInfo(lotteryResult);
                        }
                        else
                        {
                            lotteryResult.NextExpect   = resProcess.GetNextExpect(item.lotteryType, lotteryResult.Expect);
                            lotteryResult.NextOpenTime = resProcess.GetNextOpenTime(item.lotteryType, lotteryResult.Opentime.Value);
                        }
                        lrService.AddEntity(lotteryResult);
                        betprocess.ProcessBet(lotteryResult);
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 新增彩票开奖结果
 /// </summary>
 /// <param name="lotteryResult"></param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public async Task AddLotteryResult(LotteryResult lotteryResult, CancellationToken cancellationToken = default(CancellationToken))
 {
     if (lotteryResult == null)
     {
         throw new ArgumentNullException(nameof(lotteryResult));
     }
     Context.Add(lotteryResult);
     await Context.SaveChangesAsync(cancellationToken);
 }
Ejemplo n.º 10
0
 public static int setLotteryResult(LotteryResult rst)
 {
     using (IDbConnection connection = new MySqlConnection(constr))
     {
         string sql    = @" INSERT INTO lotteryresult (lotteryID,lotteryType,time,No,Number,guanYaHe,longHu,isRight)
      VALUES(@lotteryID,@lotteryType,@time,@No,@Number,@guanYaHe,@longHu,@isRight); ";
         int    result = connection.Execute(sql, rst); //直接传送list对象
         return(result);
     }
 }
        public static LotteryResult GetNowLottery(string cpcode)
        {
            DataTable     dt    = LotteryResultDAL.BaseProvider.GetNowLottery(cpcode);
            LotteryResult model = new LotteryResult();

            foreach (DataRow dr in dt.Rows)
            {
                model.FillData(dr);
            }
            return(model);
        }
        public static LotteryResult GetOpenLottery(string cpcode, string sqlwhere, int top = 1)
        {
            DataTable     dt    = LotteryResultDAL.BaseProvider.GetOpenLottery(cpcode, sqlwhere, top);
            LotteryResult model = new LotteryResult();

            foreach (DataRow dr in dt.Rows)
            {
                model.FillData(dr);
            }
            return(model);
        }
Ejemplo n.º 13
0
        public JsonResult UpdateLotteryResult(Guid id, int state)
        {
            OperationResult result = LotteryResultSiteContract.UpdateLotteryResult(id, state);

            if (result.ResultType == OperationResultType.Success)
            {
                LotteryResult rtnmodel = (LotteryResult)result.AppendData;
                return(Json(new { OK = true, Message = "更新状态成功!" }, JsonRequestBehavior.AllowGet));
            }

            string msg = result.Message ?? result.ResultType.ToDescription();

            return(Json(new { OK = false, Message = msg }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 14
0
 //获取距离当前开奖时间的秒数
 public int GetCountDownTimes()
 {
     try
     {
         string        ResultType    = Request["lotteryType"];
         LotteryResult lotteryResult = GetLastLotteryResultByType(ResultType);
         int           countDown     = (int)(lotteryResult.NextOpenTime.Value - DateTime.Now).TotalSeconds;
         return(countDown);
     }
     catch (Exception ex)
     {
         throw new ApplicationException("获取开奖倒计时的时间出错,原因:" + ex.Message);
     }
 }
Ejemplo n.º 15
0
        //百家乐三公
        public ActionResult bjlsg()
        {
            LotteryResult lotteryResult = GetLastLotteryResultByType("百家乐三公");

            if (lotteryResult == null)
            {
                return(View());
            }
            ViewBag.lotteryType  = lotteryResult.LotteryType;
            ViewBag.expect       = lotteryResult.Expect;
            ViewBag.openttime    = lotteryResult.Opentime;
            ViewBag.opencode     = lotteryResult.Opencode.Replace(",", " ");
            ViewBag.nextExpect   = lotteryResult.NextExpect;
            ViewBag.nextOpenTime = lotteryResult.NextOpenTime;
            return(View());
        }
        public static LotteryResult GetLotteryResult(string cpCode, string status, string orderasc = "asc")
        {
            string sqlwhere = " where  b.cpCode='" + cpCode + "'";

            if (!string.IsNullOrEmpty(status))
            {
                sqlwhere += " and b.Status in (" + status + ") ";
            }

            DataTable     dt    = LotteryResultDAL.GetDataTable("select top 1 *  from  LotteryResult (nolock) b " + sqlwhere + " Order by AutoID " + orderasc);
            LotteryResult model = new LotteryResult();

            foreach (DataRow dr in dt.Rows)
            {
                model.FillData(dr);
            }
            return(model);
        }
Ejemplo n.º 17
0
        public ActionResult klsfNumber()
        {
            string number = Request["number"];

            ViewBag.number = number;
            LotteryResult lotteryResult = GetLastLotteryResultByType("广东快乐十分");

            if (lotteryResult == null)
            {
                return(View());
            }
            ViewBag.lotteryType  = lotteryResult.LotteryType;
            ViewBag.expect       = lotteryResult.Expect;
            ViewBag.openttime    = lotteryResult.Opentime;
            ViewBag.opencode     = lotteryResult.Opencode.Replace(",", " ");
            ViewBag.nextExpect   = lotteryResult.NextExpect;
            ViewBag.nextOpenTime = lotteryResult.NextOpenTime;
            return(View());
        }
Ejemplo n.º 18
0
        public void SaveNewLotteryResult()
        {
            _logger.LogInformation("获取最新开奖结果");
            OpenResult openResult = openService.GetOpenResult();

            if (openResult != null)
            {
                LotteryResult lotteryResult = new LotteryResult(openResult.periodicalnum,
                                                                openResult.result, openResult.resulttime);
                var oldResult = resultRepo.GetById(lotteryResult.Id);
                if (oldResult == null)
                {
                    resultRepo.Insert(lotteryResult);


                    resultRepo.InsertLotteryPredictionCode_4_Temp(lotteryResult.Id);
                    resultRepo.InsertLotteryPredictionTotal_T(lotteryResult.Id);
                }
            }
        }
Ejemplo n.º 19
0
        public string GetLotteryCode()
        {
            _logger.LogInformation("Get LotteryCode");
            LotteryResult lr = resultRepo.GetLastRow();

            if (lr != null)
            {
                var nextDate = GetNextLotteryDate(lr.LotteryDate);
                if (nextDate.Year == lr.LotteryDate.Year)
                {
                    return((int.Parse(lr.Id) + 1).ToString());
                }
                else
                {
                    return(nextDate.ToString("yy") + "001");
                }
            }
            else
            {
                return("errorNo");
            }
        }
        public ActionResult BetRecordDetail()
        {
            ViewBag.parentId = Request["parentId"];
            var       id        = int.Parse(Request["parentId"]);
            BetRecord betRecord = brService.LoadEntities(s => s.Id == id).FirstOrDefault();

            ViewBag.BetMoney     = betRecord.BetMoney;
            ViewBag.BetCount     = betRecord.BetCount;
            ViewBag.LotteryState = betRecord.LotteryState;
            LotteryResult lr = lrService.LoadEntities(s => s.LotteryType == betRecord.LotteryType && s.Expect == betRecord.Expect).FirstOrDefault();

            ViewBag.lotteryType = betRecord.LotteryType;
            ViewBag.expect      = betRecord.Expect;
            if (lr == null)
            {
                ViewBag.Opencode = "未开奖";
            }
            else
            {
                ViewBag.Opencode = lr.Opencode;
            }
            return(View());
        }
Ejemplo n.º 21
0
        public static List <LotteryResult> GetLotteryOpen(int pageIndex, ref int totalCount, ref int pageCount, string cpcode = "", int pageSize = 15, string btime = "", string etime = "", string status = "0,1", string keywords = "")
        {
            string whereSql = " 1=1 ";

            if (!string.IsNullOrEmpty(status) && status != "-1")
            {
                whereSql += " and a.Status in (" + status + ")";
            }
            if (!string.IsNullOrEmpty(btime))
            {
                whereSql += " and a.OpenTime>='" + btime + "'";
            }
            if (!string.IsNullOrEmpty(etime))
            {
                whereSql += " and a.OpenTime<='" + etime + " 23:59:59:999'";
            }
            if (!string.IsNullOrEmpty(cpcode))
            {
                whereSql += " and a.CPCode='" + cpcode + "'";
            }
            if (!string.IsNullOrEmpty(keywords))
            {
                whereSql += " and a.IssueNum like'%" + keywords + "%' ";
            }
            string    cstr = @" a.AutoID,a.CPCode,a.IssueNum,c.ResultNum AutoNum,a.ResultNum ResultNum,a.Status,a.UpdateTime,a.CreateTime,a.PizeNum,a.UserNum,a.SumNum,a.OpenTime,a.Num,b.CPName ";
            DataTable dt   = CommonBusiness.GetPagerData(" LotteryResult a join lottery b on a.CPCode=b.CPCode left join LotteryWaitPay c on a.CPCode=c.CPCode and a.IssueNum=c.IssueNum ", cstr, whereSql, "a.AutoID", pageSize, pageIndex, out totalCount, out pageCount);

            List <LotteryResult> list = new List <LotteryResult>();

            foreach (DataRow dr in dt.Rows)
            {
                LotteryResult model = new LotteryResult();
                model.FillData(dr);
                list.Add(model);
            }
            return(list);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 彩票开始开奖
        /// </summary>
        /// <returns></returns>
        public async Task <ResponseMessage> LotteryRunAsync(CancellationToken requestAborted)
        {
            var response   = new ResponseMessage();
            var periodInfo = await _allocateStore.GetScorePeriods().Where(w => w.State == 1 && !w.IsDelete).FirstOrDefaultAsync();

            if (periodInfo == null)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = "没有进行中的赛季,开奖失败";
                return(response);
            }

            var nowTime       = DateTime.Now;
            var numberList    = new List <int>();         //开奖号码
            var numberPeriods = await GetNumberPeriods(); //本次开奖期数

            #region 生成中奖号码
            //生成6个不相同的号码
            while (numberList.Count < 6)
            {
                var rd     = new Random();
                var rdNext = rd.Next(0, 26);
                if (numberList.Any(a => a == rdNext))
                {
                    continue;
                }
                numberList.Add(rdNext);
            }
            numberList = numberList.OrderBy(o => o).ToList();
            #endregion

            #region 计算中奖的人
            var lotteryUser = await _giftStore.GetLotteryUsers().Where(w => w.NumberPeriods == numberPeriods && w.PeriodId == periodInfo.Id).ToListAsync(); //当期投注的人

            var number6Count = 0; var number6Score = 0;                                                                                                     //中6个的注数和总分数
            var number5Count = 0; var number5Score = 0;                                                                                                     //中5个的注数和总分数
            var number4Count = 0; var number4Score = 0;                                                                                                     //中4个的注数和总分数
            var number3Count = 0; var number3Score = 0;                                                                                                     //中3个的注数和总分数
            var number2Count = 0; var number2Score = 0;                                                                                                     //中2个的注数和总分数
            var inputScore = lotteryUser.Sum(s => s.Score);                                                                                                 //总投注K币
            foreach (var lu in lotteryUser)
            {
                var winNumber = new List <int>();     //中奖的号码
                var buyNumber = lu.Number.Split(','); //购买的号码
                foreach (var bn in buyNumber)
                {
                    if (numberList.Any(a => a == int.Parse(bn)))
                    {
                        winNumber.Add(int.Parse(bn));
                    }
                }
                winNumber = winNumber.OrderBy(o => o).ToList();

                //中2个号,保本
                if (winNumber.Count == 2)
                {
                    lu.WinningNumber = string.Join(',', winNumber);
                    lu.WinningScore  = lu.Score;
                    number2Count++;
                    number2Score += lu.WinningScore ?? 0;
                }
                //中3个号,翻2倍
                if (winNumber.Count == 3)
                {
                    lu.WinningNumber = string.Join(',', winNumber);
                    lu.WinningScore  = lu.Score * 2;
                    number3Count++;
                    number3Score += lu.WinningScore ?? 0;
                }
                //中4个号,翻10倍
                if (winNumber.Count == 4)
                {
                    lu.WinningNumber = string.Join(',', winNumber);
                    lu.WinningScore  = lu.Score * 10;
                    number4Count++;
                    number4Score += lu.WinningScore ?? 0;
                }
                //中5个号,翻300倍
                if (winNumber.Count == 5)
                {
                    lu.WinningNumber = string.Join(',', winNumber);
                    lu.WinningScore  = lu.Score * 300;
                    number5Count++;
                    number5Score += lu.WinningScore ?? 0;
                }
                //中6个号,翻5000倍
                if (winNumber.Count == 6)
                {
                    lu.WinningNumber = string.Join(',', winNumber);
                    lu.WinningScore  = lu.Score * 5000;
                    number6Count++;
                    number6Score += lu.WinningScore ?? 0;
                }
            }
            lotteryUser = lotteryUser.Where(w => !string.IsNullOrEmpty(w.WinningNumber)).ToList();//筛选出中奖的人
            #endregion

            var lotteryResult = new LotteryResult
            {
                Id            = Guid.NewGuid().ToString(),
                CreateTime    = nowTime,
                NumberPeriods = numberPeriods,
                Number        = string.Join(',', numberList),
                WinResult     = JsonHelper.ToJson(new
                {
                    All     = new { Count = lotteryUser.Count, OutScore = lotteryUser.Sum(s => s.WinningScore), InputScore = inputScore },
                    Number6 = new { Count = number6Count, Score = number6Score },
                    Number5 = new { Count = number5Count, Score = number5Score },
                    Number4 = new { Count = number4Count, Score = number4Score },
                    Number3 = new { Count = number3Count, Score = number3Score },
                    Number2 = new { Count = number2Count, Score = number2Score },
                })
            };


            var userIds      = lotteryUser.Select(s => s.UserId).ToList();
            var userInfoList = await _allocateStore.GetUserInfos().Where(w => !w.IsDelete && userIds.Contains(w.Id)).ToListAsync();

            //事务保存
            using (var trans = await _transaction.BeginTransaction())
            {
                try
                {
                    //事务里面重新查一次
                    var scoreInfoList = await _allocateStore.GetScoreInfos().Where(w => !w.IsDelete && w.PeriodId == periodInfo.Id && userIds.Contains(w.UserId)).ToListAsync();

                    foreach (var lu in lotteryUser)
                    {
                        var storeInfo = scoreInfoList.FirstOrDefault(fi => fi.UserId == lu.UserId);
                        if (storeInfo != null)
                        {
                            storeInfo.ConsumableScore = storeInfo.ConsumableScore + lu.WinningScore.Value;
                            await _allocateStore.UpdateScoreInfo(storeInfo, requestAborted);

                            await _giftStore.UpdateLotteryUser(lu, requestAborted);

                            //添加中彩票动态
                            await _dynamicHelper.AddDynamicContent(
                                DynamicType.WinLottery,
                                periodInfo.Id,
                                lu.Id,
                                null,
                                null,
                                userInfoList.FirstOrDefault(fi => fi.Id == lu.UserId)?.UserName,
                                userInfoList.FirstOrDefault(fi => fi.Id == lu.UserId)?.GroupName,
                                lu.UserId,
                                $"在K彩第《{lu.NumberPeriods}》期投中号码:{lu.WinningNumber}",
                                lu.WinningScore.Value,
                                null,
                                null
                                );
                        }
                    }
                    await _giftStore.AddLotteryResult(lotteryResult, requestAborted);

                    //添加开奖动态
                    await _dynamicHelper.AddDynamicContent(
                        DynamicType.LotteryResult,
                        periodInfo.Id,
                        lotteryResult.Id,
                        null,
                        null,
                        "K先生",
                        "K先生",
                        "K先生",
                        $"⭐K彩⭐第《{lotteryResult.NumberPeriods}》期开奖结果:{lotteryResult.Number}。共中出{lotteryUser.Count}注,共中出{lotteryUser.Sum(s => s.WinningScore)}K。" +
                        $"{(number6Count > 0 ? "一等奖" + number6Count + "注,恭喜走上人生巅峰。" : "")}" +
                        $"{(number5Count > 0?"二等奖"+ number5Count + "注,恭喜一夜暴富。" : "")}" +
                        $"{(number4Count > 0 ? "三等奖共" + number4Count + $"注。" : "")}" +
                        $"{(number3Count > 0 ? "四等奖共" + number3Count + "注。" : "")}" +
                        $"{(number2Count > 0 ? "五等奖共" + number2Count + "注。" : "")}" +
                        $"单注最高奖{lotteryUser.Max(m=>m.WinningScore)}K。",
                        0,
                        null,
                        null
                        );

                    trans.Commit();
                }
                catch (Exception e)
                {
                    trans.Rollback();
                    throw new Exception("保存事务失败", e);
                }
            }
            // 触发信息变化
            await _sendClientMessageManager.SendInfos(new List <Dto.Common.SendClientType>()
            {
                Dto.Common.SendClientType.Dynamic
            });

            return(response);
        }
Ejemplo n.º 23
0
 private async Task LoadLocalSelectListAsync(LotteryResult model)
 {
     ViewData["Loteries"] = new SelectList(await _repository.GetLotteriesForCombo(), "Id", "Name", model.LotteryId);
 }
Ejemplo n.º 24
0
        public ActionResult <LotteryResult> Get(string lottery, string no)
        {
            LotteryResult lr = DapperHelper.getRstByNo(lottery, no.Substring(no.Length - 6, 6));

            return(lr);
        }
Ejemplo n.º 25
0
        public JsonResult GetNextData(string lotteryType)
        {
            try
            {
                LotteryResult lotteryResult = GetLastLotteryResultByType(lotteryType);
                if (lotteryResult == null)
                {
                    return(Json(null));
                }
                int           countDown = (int)(lotteryResult.NextOpenTime.Value - DateTime.Now).TotalSeconds;
                LotteryResult retRes    = new LotteryResult();
                if (countDown <= 0 && (lotteryType == "重庆时时彩" || lotteryType == "广东快乐十分" || lotteryType == "广东11选5"))
                {//为保证用户可以继续下注,到开奖时间后先虚拟下一期出来
                    string   VirNextExpect   = "";
                    DateTime VirNextOpenTime = DateTime.Now;
                    switch (lotteryType)
                    {
                    case "重庆时时彩":
                        VirNextExpect   = resP.cqsscNextExpect(lotteryResult.NextExpect);
                        VirNextOpenTime = resP.cqsscNextOpenTime(lotteryResult.NextOpenTime.Value);
                        break;

                    case "广东快乐十分":
                        VirNextExpect   = resP.gdklsfNextExpect(lotteryResult.NextExpect);
                        VirNextOpenTime = resP.gdklsfNextOpenTime(lotteryResult.NextOpenTime.Value);
                        break;

                    case "广东11选5":
                        VirNextExpect   = resP.gd11x5NextExpect(lotteryResult.NextExpect);
                        VirNextOpenTime = resP.gd11x5NextOpenTime(lotteryResult.NextOpenTime.Value);
                        break;

                    default:
                        break;
                    }
                    LotteryResult VirExcept = VirExcepts.Where(s => s.Expect.Equals(lotteryResult.NextExpect) && s.LotteryType.Equals(lotteryType)).FirstOrDefault();
                    if (VirExcept == null)
                    {
                        VirExcept              = new LotteryResult();
                        VirExcept.LotteryType  = lotteryType;
                        VirExcept.Expect       = lotteryResult.NextExpect;
                        VirExcept.NextExpect   = VirNextExpect;
                        VirExcept.NextOpenTime = VirNextOpenTime;
                        VirExcepts.Add(VirExcept);
                    }
                    retRes = VirExcept;
                    VirExcepts.RemoveAll(s => s.Expect != lotteryResult.NextExpect && s.LotteryType.Equals(lotteryType));
                }
                else
                {
                    retRes = lotteryResult;
                }
                if (retRes.LotteryType.Equals("六合彩"))
                {
                    retRes.Opencode = resP.ConvertlhcNoBose(retRes.Opencode);
                }
                var retVal = new
                {
                    Expect      = retRes.Expect,
                    LotteryType = retRes.LotteryType,
                    OpenCode    = !string.IsNullOrEmpty(retRes.Opencode) ? retRes.Opencode.Replace(',', ' '):"",
                    NextExpect  = retRes.NextExpect,
                    Rema        = (int)(retRes.NextOpenTime.Value - DateTime.Now).TotalSeconds
                };
                return(Json(retVal, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw new ApplicationException("获取开奖倒计时的时间出错,原因:" + ex.Message);
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 获取开奖结果
        /// </summary>
        /// <param name="PageURL"></param>
        /// <param name="name"></param>
        private LotteryResult GetResult(string subUrl)
        {
            LotteryResult lr = new LotteryResult();

            lr.isRight = false;
            if (task.website.StartsWith("https://www.1393c.com"))
            {
                string subHtml = Browser.getHtml(subUrl);
                HtmlAgilityPack.HtmlDocument subdoc = new HtmlAgilityPack.HtmlDocument();
                subdoc.LoadHtml(subHtml);
                HtmlNodeCollection nodes = subdoc.DocumentNode.SelectNodes("//table[@class='lot-table']//tr[2]");
                if (nodes != null)
                {
                    List <LotteryResult> rst = new List <LotteryResult>();

                    foreach (HtmlNode node in nodes)
                    {
                        HtmlNodeCollection tds = node.SelectNodes("td");
                        int tdNum = tds.Count;
                        //lr = new LotteryResult();
                        int no = 0;
                        lr.lotteryID   = task.lotteryID;
                        lr.lotteryType = task.lotteryType;
                        HtmlNodeCollection ps = tds[no++].SelectNodes("p");
                        lr.No   = StringHelper.trimEnd(ps[0].InnerText).Replace("-", "");
                        lr.time = StringHelper.trimEnd(ps[1].InnerText);

                        //开奖号码
                        Match m = Regex.Match(tds[no++].InnerHtml, @"\d+");
                        while (m.Success)
                        {
                            lr.Number += (StringHelper.trimEnd(m.Value) + ",");
                            m          = m.NextMatch();
                        }
                        //冠亚和
                        lr.guanYaHe += StringHelper.trimEnd(tds[no++].InnerText) + "," + StringHelper.trimEnd(tds[no++].InnerText) + "," + StringHelper.trimEnd(tds[no++].InnerText);
                        //龙虎
                        lr.longHu = StringHelper.trimEnd(tds[no++].InnerText) + "," + StringHelper.trimEnd(tds[no++].InnerText) + "," + StringHelper.trimEnd(tds[no++].InnerText) + "," + StringHelper.trimEnd(tds[no++].InnerText) + "," + StringHelper.trimEnd(tds[no++].InnerText);

                        rst.Add(lr);
                    }
                    //DapperHelper.setLotteryResult(rst);
                }
            }
            else if (task.website.StartsWith("https://1680380.com"))
            {
                string subHtml = Browser.getHtml(subUrl);
                HtmlAgilityPack.HtmlDocument subdoc = new HtmlAgilityPack.HtmlDocument();
                subdoc.LoadHtml(subHtml);
                HtmlNodeCollection nodes = subdoc.DocumentNode.SelectNodes("//div[@id='jrsmhmtj']//tr[2]");//position()>1
                if (nodes != null)
                {
                    List <LotteryResult> rst = new List <LotteryResult>();

                    foreach (HtmlNode node in nodes)
                    {
                        HtmlNodeCollection tds = node.SelectNodes("td");
                        //lr = new LotteryResult();
                        int no = 0;
                        lr.lotteryID   = task.lotteryID;
                        lr.lotteryType = task.lotteryType;
                        //时间
                        lr.time = StringHelper.trimEnd(tds[no++].InnerText);
                        //期数
                        lr.No = StringHelper.trimEnd(tds[no++].InnerText).Replace("-", "");

                        //开奖号码
                        HtmlNodeCollection lis = tds[no++].SelectNodes("ul/li/i");
                        foreach (HtmlNode li in lis)
                        {
                            lr.Number += StringHelper.trimEnd(li.InnerText) + ",";
                        }

                        //冠亚和
                        lr.guanYaHe += StringHelper.trimEnd(tds[no++].InnerText) + "," + StringHelper.trimEnd(tds[no++].InnerText) + "," + StringHelper.trimEnd(tds[no++].InnerText);
                        //龙虎
                        lr.longHu = StringHelper.trimEnd(tds[no++].InnerText) + "," + StringHelper.trimEnd(tds[no++].InnerText) + "," + StringHelper.trimEnd(tds[no++].InnerText) + "," + StringHelper.trimEnd(tds[no++].InnerText) + "," + StringHelper.trimEnd(tds[no++].InnerText);

                        rst.Add(lr);
                    }
                    //DapperHelper.setLotteryResult(rst);
                }
            }
            else
            {
                string apiUrl  = string.Format("http://cx971.com/pc/index/getLottoDetail?lottoName={0}&page=1&showpage=10", subUrl);
                string subHtml = Browser.getResponse(apiUrl);

                HistoryData hd = JsonConvert.DeserializeObject <HistoryData>(subHtml);

                if (hd != null)
                {
                    List <LotteryResult> rst = new List <LotteryResult>();

                    foreach (History his in hd.data.history)
                    {
                        //lr = new LotteryResult();
                        lr.lotteryID   = task.lotteryID;
                        lr.lotteryType = task.lotteryType;
                        //时间
                        lr.time = his.timeDraw;
                        //期数
                        lr.No = (his.qishu + "").Replace("-", "");

                        //开奖号码
                        foreach (int n in his.nums)
                        {
                            lr.Number += StringHelper.trimEnd(n.ToString()) + ",";
                        }

                        //冠亚和
                        lr.guanYaHe = ((his.nums[0] + his.nums[1]) + "," + (his.SumBigSmall == "1"?"大,":"小,") + (his.SumOddEven == "1" ? "单" : "双"));
                        //龙虎
                        lr.longHu = (his.DragonTiger1 == "1"?"龙,":"虎,") + (his.DragonTiger2 == "1" ? "龙," : "虎,") + (his.DragonTiger3 == "1" ? "龙," : "虎,") + (his.DragonTiger4 == "1" ? "龙," : "虎,") + (his.DragonTiger5 == "1" ? "龙" : "虎");

                        rst.Add(lr);
                        break;
                    }
                    //DapperHelper.setLotteryResult(rst);
                }
            }
            return(lr);
        }
Ejemplo n.º 27
0
        }         // Name

        public PlayLottery(Guid playerID)
        {
            this.playerID = playerID;
            Result        = new LotteryResult();
        }         // constructor