public void Incentive() { var benevolenceIndex = RandomArray.BenevolenceIndex(); if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday) { //周日两倍激励 benevolenceIndex = benevolenceIndex * 2; } //善心指数判断 if (benevolenceIndex <= 0 || benevolenceIndex >= 1) { throw new Exception("善心指数异常"); } //遍历所有的钱包发送激励指令 var wallets = _walletQueryService.ListPage(); foreach (var wallet in wallets) { var command = new IncentiveBenevolenceCommand(wallet.Id, benevolenceIndex); _commandService.SendAsync(command); } }
public async Task <BaseApiResponse> IncentiveBenevolence(IncentiveBenevolenceRequest request) { request.CheckNotNull(nameof(request)); if (request.BenevolenceIndex <= 0 || request.BenevolenceIndex >= 1) { return(new BaseApiResponse { Code = 400, Message = "善心指数异常" }); } //遍历所有的钱包发送激励指令 var wallets = _walletQueryService.ListPage(); foreach (var wallet in wallets) { var command = new IncentiveBenevolenceCommand(wallet.Id, request.BenevolenceIndex); await ExecuteCommandAsync(command); } return(new BaseApiResponse()); }