예제 #1
0
        public async Task <BaseApiResponse> AcceptTransfer(AcceptTransferRequest request)
        {
            request.CheckNotNull(nameof(request));

            var wallet = _walletQueryService.InfoByUserId(request.UserId);

            if (wallet == null)
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "没有该收款人"
                });
            }

            string number  = DateTime.Now.ToSerialNumber();
            var    command = new CreateCashTransferCommand(
                GuidUtil.NewSequentialId(),
                wallet.Id,
                number,                    //流水号
                CashTransferType.Transfer,
                CashTransferStatus.Placed, //这里只是提交,只有钱包接受改记录后,才更新为成功
                request.Amount,
                0,
                WalletDirection.In,
                request.Remark);

            var result = await ExecuteCommandAsync(command);

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