| | |
| | | private readonly ChannelWalletTransactionRepository channelWalletTransactionRepository = channelWalletTransactionRepository; |
| | | private readonly ChannelWalletService channelWalletService = channelWalletService; |
| | | |
| | | /// <summary> |
| | | /// 保存渠道平安银行钱包 |
| | | /// </summary> |
| | | /// <param name="request"></param> |
| | | /// <param name="cancellationToken"></param> |
| | | /// <returns></returns> |
| | | public async Task<SaveChannelPingAnPayWalletCommandResult> Handle(SaveChannelPingAnPayWalletCommand request, CancellationToken cancellationToken) |
| | | { |
| | | var logier = JwtUtils.GetCurrentLogier(); |
| | |
| | | wallet = new ChannelWallet(); |
| | | wallet.ChannelId = logier.ChannelId; |
| | | wallet.Access = EnumWalletAccess.PingAnPay; |
| | | wallet.SignStatus = EnumWalletSignStatus.Normal; |
| | | wallet.Bank = "平安银行"; |
| | | wallet.SignStatus = EnumWalletSignStatus.Apply; |
| | | request.Adapt(wallet); |
| | | await channelWalletRepository.SetCode(wallet); |
| | | await channelWalletRepository.InsertNowAsync(wallet); |
| | | } |
| | | else |
| | | { |
| | | wallet.SignStatus = EnumWalletSignStatus.Apply; |
| | | request.Adapt(wallet); |
| | | await channelWalletRepository.UpdateNowAsync(wallet); |
| | | } |
| | | await channelWalletService.GetEnterpriseWalletBalance(wallet); |
| | | return new SaveChannelPingAnPayWalletCommandResult |
| | | { |
| | | WalletId = wallet.Id, |
| | | Id = wallet.Id, |
| | | Balance = wallet.Balance, |
| | | ErrorCode = wallet.ErrorCode, |
| | | FailReason = wallet.FailReason |
| | | }; |
| | | } |
| | | |
| | |
| | | .FirstOrDefaultAsync(); |
| | | |
| | | if (wallet == null) throw Oops.Oh(EnumErrorCodeType.s404, "未开通钱包"); |
| | | |
| | | if (wallet.SignStatus != EnumWalletSignStatus.Normal) throw Oops.Oh(EnumErrorCodeType.s404, "钱包未签约"); |
| | | await channelWalletService.GetEnterpriseWalletBalance(wallet); |
| | | if (request.Amount > wallet.Balance) throw Oops.Oh(EnumErrorCodeType.s404, "余额不足"); |
| | | |