示例#1
0
 public void Handle(ICommandContext context, CreateWithdrawApplyCommand command)
 {
     context.Get <Wallet>(command.AggregateRootId).ApplyWithdraw(command.WithdrawApplyId, new WithdrawApplyInfo(
                                                                     command.Amount,
                                                                     command.BankName,
                                                                     command.BankNumber,
                                                                     command.BankOwner,
                                                                     "等待审核"));
 }
示例#2
0
        public async Task <BaseApiResponse> ApplyWithdraw(ApplyWithdrawRequest request)
        {
            request.CheckNotNull(nameof(request));

            var currentAccount = _contextService.GetCurrentAccount(HttpContext.Current);
            //判断提现限额
            var wallet = _walletQueryService.Info(currentAccount.WalletId.ToGuid());

            if (wallet.IsFreeze == Freeze.Freeze)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "钱包冻结,无法提现"
                });
            }
            if (wallet.TodayWithdrawAmount + request.Amount > ConfigSettings.OneDayWithdrawLimit)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "单日提现不得超过{0}元".FormatWith(ConfigSettings.OneDayWithdrawLimit)
                });
            }
            if (wallet.WeekWithdrawAmount + request.Amount > ConfigSettings.OneWeekWithdrawLimit)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "每周提现不得超过{0}元".FormatWith(ConfigSettings.OneWeekWithdrawLimit)
                });
            }

            var command = new CreateWithdrawApplyCommand(
                GuidUtil.NewSequentialId(),
                currentAccount.WalletId.ToGuid(),
                request.Amount,
                request.BankCard.BankName,
                request.BankCard.Number,
                request.BankCard.OwnerName);

            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            return(new BaseApiResponse());
        }