Example #1
0
        public async Task <UpdateUserPlanNormOutput> UpdateUserPlanNorm(UserNormPlanConfigInput input)
        {
            var validatorResult = await _userNormConfigInputValidator.ValidateAsync(input);

            if (!validatorResult.IsValid)
            {
                throw new LotteryDataException(validatorResult.Errors.Select(p => p.ErrorMessage + "</br>").ToString(";"));
            }

            // todo: 更严格的指标公式验证
            _cacheManager.RemoveByPattern("Lottery.PlanTrack");
            var finalLotteryData = _lotteryDataAppService.GetFinalLotteryData(LotteryInfo.Id);
            var userPlanNorm     = _normConfigAppService.GetUserNormConfigByPlanId(_lotterySession.UserId, LotteryInfo.Id, input.PlanId);

            if (userPlanNorm.Id.IsNullOrEmpty())
            {
                var planInfo = _planInfoAppService.GetPlanInfoById(input.PlanId);
                var command  = new AddNormConfigCommand(Guid.NewGuid().ToString(), _lotterySession.UserId, LotteryInfo.Id, input.PlanId,
                                                        input.PlanCycle, input.ForecastCount, finalLotteryData.Period,
                                                        input.UnitHistoryCount, input.HistoryCount, input.MinRightSeries, input.MaxRightSeries,
                                                        input.MinErrorSeries, input.MaxErrorSeries, input.LookupPeriodCount,
                                                        input.ExpectMinScore, input.ExpectMaxScore, planInfo.Sort, input.CustomNumbers);
                await SendCommandAsync(command);
            }
            else
            {
                var command = new UpdateNormConfigCommand(userPlanNorm.Id, _lotterySession.UserId, LotteryInfo.Id, input.PlanId,
                                                          input.PlanCycle, input.ForecastCount, finalLotteryData.Period,
                                                          input.UnitHistoryCount, input.HistoryCount, input.MinRightSeries, input.MaxRightSeries,
                                                          input.MinErrorSeries, input.MaxErrorSeries, input.LookupPeriodCount,
                                                          input.ExpectMinScore, input.ExpectMaxScore, input.CustomNumbers);
                await SendCommandAsync(command);
            }

            var canSwitchFormula = _userMemberRank > MemberRank.Senior;
            var tips             = "设置公式指标成功";

            if (canSwitchFormula)
            {
                tips += ",是否立即根据该指标计算追号数据?";
            }

            var result = new UpdateUserPlanNormOutput()
            {
                Tips             = tips,
                CanSwitchFormula = canSwitchFormula
            };

            return(result);
        }
Example #2
0
 public void Handle(ICommandContext context, UpdateNormConfigCommand command)
 {
     context.Get <NormConfig>(command.AggregateRootId).UpdateNormConfig(command.LastStartPeriod,
                                                                        command.PlanCycle, command.ForecastCount, command.UnitHistoryCount, command.HistoryCount, command.MinRightSeries, command.MaxRightSeries, command.MinErrorSeries,
                                                                        command.MaxErrorSeries, command.LookupPeriodCount, command.ExpectMinScore, command.ExpectMaxScore, command.CustomNumbers);
 }