public async Task <string> GetUserNormDefaultConfig(UserNormDefaultConfigInput input) { var validatorResult = await _userNormDefaultConfigInputValidator.ValidateAsync(input); if (!validatorResult.IsValid) { throw new LotteryDataException(validatorResult.Errors.Select(p => p.ErrorMessage + "</br>").ToString(";")); } var userNormConfig = _userNormDefaultConfigService.GetUserNormConfig(_lotterySession.UserId, LotteryInfo.Id); if (userNormConfig == null) { var command = new AddUserNormDefaultConfigCommand(Guid.NewGuid().ToString(), _lotterySession.UserId, LotteryInfo.Id, input.PlanCycle, input.ForecastCount, input.UnitHistoryCount, input.HistoryCount, input.MinRightSeries, input.MaxRightSeries, input.MinErrorSeries, input.MaxErrorSeries, input.LookupPeriodCount, input.ExpectMinScore, input.ExpectMaxScore); await SendCommandAsync(command); } else { var command = new UpdateUserNormDefaultConfigCommand(userNormConfig.Id, input.PlanCycle, input.ForecastCount, input.UnitHistoryCount, input.HistoryCount, input.MinRightSeries, input.MaxRightSeries, input.MinErrorSeries, input.MaxErrorSeries, input.LookupPeriodCount, input.ExpectMinScore, input.ExpectMaxScore); await SendCommandAsync(command); } return("设置默认的公式指标成功"); }
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); }