Ejemplo n.º 1
0
        public NormPlanDefaultConfigOutput NormPlanConfig(string planId = null)
        {
            var         lotterInfo  = _lotteryQueryService.GetLotteryInfoById(_lotterySession.SystemTypeId);
            var         predictCode = string.Empty;
            PlanInfoDto planInfo    = null;

            if (!planId.IsNullOrEmpty())
            {
                planInfo    = _planInfoQueryService.GetPlanInfoById(planId);
                predictCode = planInfo.PredictCode;
            }
            _cacheManager.RemoveByPattern("Lottery.PlanTrack");
            var normPlanDefaultConfig = _normPlanConfigQueryService.GetNormPlanDefaultConfig(lotterInfo.LotteryCode, predictCode);
            var output = new NormPlanDefaultConfigOutput();

            if (planInfo != null && planInfo.PredictCode == PredictCodeDefinition.RxNumCode)
            {
                var rxCount = Convert.ToInt32(planInfo.PlanCode.Substring(planInfo.PlanCode.Length - 1));

                output.ForecastCounts = GetOutputCounts(rxCount, rxCount);
            }
            else
            {
                output.ForecastCounts = GetOutputCounts(normPlanDefaultConfig.MinForecastCount, normPlanDefaultConfig.MaxForecastCount);
            }

            output.PlanCycles = GetOutputCounts(normPlanDefaultConfig.MinPlanCycle, normPlanDefaultConfig.MaxPlanCycle);
            return(output);
        }
Ejemplo n.º 2
0
        public FinalLotteryDataOutput GetFinalLotteryData(string lotteryId)
        {
            var lotteryInfo = _lotteryQueryService.GetLotteryInfoById(lotteryId);
            var finalData   = _lotteryFinalDataQueryService.GetFinalData(lotteryId);
            // var todayActLotteryCount = finalData.FinalPeriod - finalData.TodayFirstPeriod + 1;
            var lotteryTimerManager = new TimeRuleManager(lotteryInfo);

            var finalLotteryDataOutput = new FinalLotteryDataOutput()
            {
                Period      = finalData.FinalPeriod,
                Data        = finalData.Data,
                LotteryTime = finalData.LotteryTime,
                //  NextLotteryTime = lotteryTimerManager.NextLotteryTime().Value,
                NextPeriod = finalData.FinalPeriod + 1,
            };

            if (lotteryTimerManager.FinalPeriodIsLottery(finalData))
            {
                finalLotteryDataOutput.IsLotteryData = true;
                DateTime nextLotteryTime;
                if (lotteryTimerManager.ParseNextLotteryTime(out nextLotteryTime))
                {
                    finalLotteryDataOutput.NextLotteryTime = nextLotteryTime;
                    var intervalTime = nextLotteryTime - DateTime.Now;
                    finalLotteryDataOutput.RemainSeconds = (int)intervalTime.TotalSeconds;
                }
            }
            else
            {
                finalLotteryDataOutput.IsLotteryData = false;
                finalLotteryDataOutput.RemainSeconds = 0;
            }
            return(finalLotteryDataOutput);
        }
Ejemplo n.º 3
0
        public UserAuthOutput GetMyselfAuthInfo(string userId, string lotteryId)
        {
            var authInfo = _sellQueryService.GetMyselfAuthInfo(userId, lotteryId)
                           ?? new UserAuthOutput()
            {
                Notes       = "普通版授权",
                LotteryName = _lotteryQueryService.GetLotteryInfoById(_lotterySession.SystemTypeId).Name
            };

            return(authInfo);
        }
Ejemplo n.º 4
0
        public async Task <EntryInfo> GetUserInfo()
        {
            var userInfo = await _userInfoService.GetUserInfoById(_lotterySession.UserId);

            var userInfoOutput = AutoMapper.Mapper.Map <UserInfoOutput>(userInfo);

            userInfoOutput.MemberRank   = _userMemberRank;
            userInfoOutput.SystemType   = _lotterySession.SystemType;
            userInfoOutput.SystemTypeId = _lotterySession.SystemTypeId;
            var entryInfo = new EntryInfo()
            {
                UserInfo = userInfoOutput
            };

            if (_lotterySession.SystemType == SystemType.App)
            {
                var lotteryInfo = _lotteryQueryService.GetLotteryInfoById(_lotterySession.SystemTypeId);
                entryInfo.LotteryInfo = AutoMapper.Mapper.Map <LotteryInfoOutput>(lotteryInfo);
            }
            return(entryInfo);
        }
Ejemplo n.º 5
0
        private void JobNEachTaskExcuteAfterHandler(object sender, Events.LotteryJobEventArgs e)
        {
            var lotteryInfo      = _lotteryQueryService.GetLotteryInfoById(e.LotteryId);
            var finalLotteryData = e.LotteryFinalData;
            var predictPeroid    = finalLotteryData.FinalPeriod + 1;

            var predictDatas = new List <PredictDataDto>();
            var userNorms    = _normConfigQueryService.GetUserOrDefaultNormConfigs(lotteryInfo.Id);

            foreach (var userNorm in userNorms.Safe())
            {
                predictDatas.AddRange(_lotteryPredictDataService.PredictNormData(lotteryInfo.Id, userNorm, predictPeroid, e.LotteryCode));
            }
            predictDatas.GroupBy(p => p.NormConfigId).ForEach(item =>
            {
                var planInfo             = _normConfigQueryService.GetNormPlanInfoByNormId(item.Key, e.LotteryId);
                var newestPredictDataDto = item.OrderByDescending(p => p.StartPeriod).First();
                var normConfig           = _normConfigQueryService.GetUserNormConfig(item.Key);
                var planTrackNumber      = new PlanTrackNumber()
                {
                    NormId                = normConfig.Id,
                    PlanId                = planInfo.Id,
                    PlanName              = planInfo.PlanName,
                    EndPeriod             = newestPredictDataDto.EndPeriod,
                    StartPeriod           = newestPredictDataDto.StartPeriod,
                    MinorCycle            = newestPredictDataDto.MinorCycle,
                    PredictData           = newestPredictDataDto.PredictedData,
                    CurrentPredictPeriod  = newestPredictDataDto.CurrentPredictPeriod,
                    PredictType           = planInfo.DsType,
                    HistoryPredictResults = GetHistoryPredictResults(item.OrderByDescending(p => p.StartPeriod), item.Key, normConfig.LookupPeriodCount, planInfo.PlanNormTable, lotteryInfo.LotteryCode),
                };
                var rightCount               = planTrackNumber.HistoryPredictResults.Count(p => p == 0);
                var totleCount               = planTrackNumber.HistoryPredictResults.Count(p => p != 2);
                var currentScore             = Math.Round((double)rightCount / totleCount, 2);
                planTrackNumber.CurrentScore = currentScore;
                WritePlanTrackNumbers(item, planInfo, currentScore, lotteryInfo.LotteryCode);
            });

            Console.WriteLine(e.LotteryCode + ":" + e.LotteryFinalData.FinalPeriod + "-" + e.LotteryFinalData.Data);
        }
Ejemplo n.º 6
0
 private void InitLotteryInfo()
 {
     _lotteryInfo = _lotteryQueryService.GetLotteryInfoById(_lotterySession.SystemTypeId);
 }
Ejemplo n.º 7
0
        //private string GetPredictedDataByRate(IDictionary<int, double> predictedDataRate, PredictType dsType, NormConfigDto userNorm)
        //{
        //    if (dsType == PredictType.Fix)
        //    {
        //        var predictedDataList = predictedDataRate.OrderByDescending(p => p.Value).Select(p => p.Key).ToList();
        //        var result = predictedDataList.Take(userNorm.ForecastCount).ToString(",");
        //        return result;
        //    }
        //    else
        //    {
        //        var predictedDataList = predictedDataRate.OrderBy(p => p.Value).Select(p => p.Key).ToList();
        //        var result = predictedDataList.Take(userNorm.ForecastCount).ToString(",");
        //        return result;
        //    }
        //}

        private PredictedResult JudgePredictDataResult(string lotteryId, PredictDataDto startPeriodData, NormConfigDto userNormConfig)
        {
            var planInfo    = _planInfoQueryService.GetPlanInfoById(userNormConfig.PlanId);
            var lotteryInfo = _lotteryQueryService.GetLotteryInfoById(lotteryId);
            var judgeResult = JudgePredictDataResultFatory.CreateJudgePredictDataResult(planInfo.PredictCode);

            return(judgeResult.JudgePredictDataResult(lotteryInfo, startPeriodData, userNormConfig));

            //var planInfo = _planInfoQueryService.GetPlanInfoById(userNormConfig.PlanId);
            //var lotteryData = _lotteryDataQueryService.GetPredictPeriodData(lotteryId, startPeriodData.CurrentPredictPeriod);
            //if (lotteryData == null)
            //{
            //    return PredictedResult.Running;
            //}
            //var lotteryNumber = new LotteryNumber(lotteryData);
            //var normPlanInfo = _planInfoQueryService.GetPlanInfoById(userNormConfig.PlanId);
            //if (planInfo.PlanPosition == PlanPosition.Single)
            //{
            //    var postion = planInfo.PositionInfos.First().Position;

            //    var lotteryNumberData = GetLotteryNumberData(lotteryNumber, postion, normPlanInfo); //lotteryNumber[postion];
            //    bool isRight;
            //    if (normPlanInfo.PredictCode == PredictCodeDefinition.NumCode)
            //    {
            //        var numPredictData = startPeriodData.PredictedData.Split(',').Select(p => Convert.ToInt32(p));
            //        var numLotteryNum = Convert.ToInt32(lotteryNumberData);
            //        if (normPlanInfo.DsType == PredictType.Fix)
            //        {
            //            isRight = numPredictData.Contains(numLotteryNum);
            //        }
            //        else
            //        {
            //            isRight = !numPredictData.Contains(numLotteryNum);
            //        }
            //    }
            //    else
            //    {
            //        if (normPlanInfo.DsType == PredictType.Fix)
            //        {
            //            isRight = startPeriodData.PredictedData
            //                .Contains(lotteryNumberData.ToString());
            //        }
            //        else
            //        {
            //            isRight = !startPeriodData.PredictedData
            //                .Contains(lotteryNumberData.ToString());
            //        }
            //    }
            //    if (isRight) //:todo bug
            //    {
            //        return PredictedResult.Right;
            //    }
            //    else
            //    {
            //        if (startPeriodData.CurrentPredictPeriod >= startPeriodData.EndPeriod)
            //        {
            //            return PredictedResult.Error;
            //        }
            //        return PredictedResult.Running;
            //    }
            //}
            //else if (planInfo.PlanPosition == PlanPosition.Multiple)
            //{
            //    #region 不定位预测结果判定正错

            //    var positions = planInfo.PositionInfos.Select(p => p.Position).ToArray();
            //    var lotteryNumbers = new List<object>(); // lotteryNumber.GetLotteryNumbers(positions);
            //    foreach (var position in positions)
            //    {
            //        lotteryNumbers.Add(GetLotteryNumberData(lotteryNumber, position, normPlanInfo));
            //    }
            //    if (normPlanInfo.PredictCode == PredictCodeDefinition.NumCode)
            //    {
            //        var predictNumber = startPeriodData.PredictedData.Split(',').Select(p => Convert.ToInt32(p))
            //            .ToArray();
            //        if (planInfo.DsType == PredictType.Fix)
            //        {
            //            if (lotteryNumbers.Any(p => predictNumber.Contains(Convert.ToInt32(p))))
            //            {
            //                return PredictedResult.Right;
            //            }
            //            else if (startPeriodData.CurrentPredictPeriod >= startPeriodData.EndPeriod)
            //            {
            //                return PredictedResult.Error;
            //            }
            //            return PredictedResult.Running;
            //        }
            //        else
            //        {
            //            if (!lotteryNumbers.Any(p => predictNumber.Contains(Convert.ToInt32(p))))
            //            {
            //                return PredictedResult.Right;
            //            }
            //            else if (startPeriodData.CurrentPredictPeriod >= startPeriodData.EndPeriod)
            //            {
            //                return PredictedResult.Error;
            //            }
            //            return PredictedResult.Running;
            //        }
            //    }
            //    else
            //    {
            //        var predictNumber = startPeriodData.PredictedData.Split(',').Select(p => p)
            //            .ToArray();
            //        if (planInfo.DsType == PredictType.Fix)
            //        {
            //            if (lotteryNumbers.Any(p => predictNumber.Contains(p)))
            //            {
            //                return PredictedResult.Right;
            //            }
            //            else if (startPeriodData.CurrentPredictPeriod >= startPeriodData.EndPeriod)
            //            {
            //                return PredictedResult.Error;
            //            }
            //            return PredictedResult.Running;
            //        }
            //        else
            //        {
            //            if (!lotteryNumbers.Any(p => predictNumber.Contains(p)))
            //            {
            //                return PredictedResult.Right;
            //            }
            //            else if (startPeriodData.CurrentPredictPeriod >= startPeriodData.EndPeriod)
            //            {
            //                return PredictedResult.Error;
            //            }
            //            return PredictedResult.Running;
            //        }
            //    }

            //    #endregion 不定位预测结果判定正错
            //}
            //else
            //{
            //    var rank = planInfo.PositionInfos.First().Position;
            //    var lotteryNumberData = lotteryNumber.GetRankNumber(rank);
            //    if (startPeriodData.PredictedData.Contains(lotteryNumberData.ToString()))
            //    {
            //        if (planInfo.DsType == PredictType.Fix)
            //        {
            //            return PredictedResult.Right;
            //        }
            //        else if (startPeriodData.CurrentPredictPeriod >= startPeriodData.EndPeriod)
            //        {
            //            return PredictedResult.Error;
            //        }
            //        return PredictedResult.Running;
            //    }
            //    else
            //    {
            //        if (planInfo.DsType == PredictType.Kill)
            //        {
            //            return PredictedResult.Right;
            //        }
            //        else if (startPeriodData.CurrentPredictPeriod >= startPeriodData.EndPeriod)
            //        {
            //            return PredictedResult.Error;
            //        }
            //        return PredictedResult.Running;
            //    }
            //}
        }