示例#1
0
        public async Task <BaseApiResponse> AdjustMaxImportAmount([FromBody] AdjustMaxImportAmountRequest request)
        {
            request.CheckNotNull(nameof(request));
            //判断
            var thirdCurrency = _thirdCurrencyQueryService.Find(request.Id);

            if (thirdCurrency == null)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "没找到该外币"
                });
            }
            var amount = request.Amount;

            if (request.Direction == WalletDirection.Out)
            {
                amount = -amount;
            }
            var command = new ChargeThirdCurrencyCommand(
                amount
                )
            {
                AggregateRootId = request.Id
            };
            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            return(new BaseApiResponse());
        }
示例#2
0
        public async Task <BaseApiResponse> AdjustMaxImportAmount(AdjustMaxImportAmountRequest request)
        {
            request.CheckNotNull(nameof(request));
            //判断
            var thirdCurrency = _thirdCurrencyQueryService.Find(request.Id);

            if (thirdCurrency == null)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "没找到该外币"
                });
            }
            var amount = request.Amount;

            if (request.Direction == WalletDirection.Out)
            {
                amount = -amount;
            }
            var command = new ChargeThirdCurrencyCommand(
                amount
                )
            {
                AggregateRootId = request.Id
            };
            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            //添加操作记录
            var currentAdmin = _contextService.GetCurrentAdmin(HttpContext.Current);

            RecordOperat(currentAdmin.AdminId.ToGuid(), "调整外币最大导入量", request.Id, "{0},{1}{2}".FormatWith(thirdCurrency.Name, request.Direction.ToDescription(), request.Amount));
            return(new BaseApiResponse());
        }
 public void Handle(ICommandContext context, ChargeThirdCurrencyCommand command)
 {
     context.Get <ThirdCurrency>(command.AggregateRootId).Charge(command.Amount);
 }