| | |
| | | using LifePayment.Application.Contracts; |
| | | using Alipay.AopSdk.Core.Domain; |
| | | using LifePayment.Application.Contracts; |
| | | using LifePayment.Domain; |
| | | using LifePayment.Domain.Shared; |
| | | using Medallion.Threading; |
| | |
| | | /// <param name="input"></param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [UnitOfWork(false)] |
| | | public async Task<WxRechargeNotifyResult> WxRechargeNotify(WxRechargeNotifyInput input) |
| | | { |
| | | try |
| | |
| | | }); |
| | | |
| | | await CurrentUnitOfWork.SaveChangesAsync(); |
| | | _logger.LogInformation("事务完成"); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | await CurrentUnitOfWork.RollbackAsync(); |
| | | _logger.LogError($"微信支付回调异常:{ex.Message}", ex); |
| | | return new WxRechargeNotifyResult |
| | | { |
| | | Code = "FAIL", |
| | |
| | | { |
| | | try |
| | | { |
| | | _logger.LogError($"微信退款回调通知:进入微信回调"); |
| | | var req = input.ToJson(); |
| | | _logger.LogError($"微信退款回调通知:进入微信回调:" + req); |
| | | var data = _wxPayApi.AesGcmDecrypt(input.Resource.AssociatedData, input.Resource.Nonce, input.Resource.Ciphertext); |
| | | _logger.LogError($"微信退款回调通知data:" + data); |
| | | var wxPayNotice = JsonConvert.DeserializeObject<WxPayDomesticRefundsNotice>(data); |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | _logger.LogError($"微信退款回调通知错误:" + ex.Message); |
| | | return new WxRechargeNotifyResult |
| | | { |
| | | Code = "FAIL", |
| | |
| | | Code = "SUCCESS", |
| | | }; |
| | | } |
| | | |
| | | [HttpPost] |
| | | [UnitOfWork] |
| | | public async Task WxPayDomesticRefundsNotifyImp(WxPayDomesticRefundsNotice input) |
| | | { |
| | | var wxPayNotice = input; |
| | | if (wxPayNotice.OutTradeNo.Contains("JF")) |
| | | { |
| | | |
| | | switch (wxPayNotice.RefundStatus) |
| | | { |
| | | case LifePaymentConstant.WxPayRefundStatus.退款成功: |
| | | await _lifePayService.LifePayRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.已退款); |
| | | // 插入收支流水 |
| | | await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput() |
| | | { |
| | | OrderNo = wxPayNotice.OutTradeNo, |
| | | OutRefundNo = wxPayNotice.OutRefundNo, |
| | | OutOrderNo = wxPayNotice.TransactionId, |
| | | LifePayType = LifePayTypeEnum.WxPay, |
| | | ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Receipts, |
| | | Amount = wxPayNotice.Amount.Total |
| | | }); |
| | | break; |
| | | case LifePaymentConstant.WxPayRefundStatus.退款关闭: |
| | | case LifePaymentConstant.WxPayRefundStatus.退款处理中: |
| | | case LifePaymentConstant.WxPayRefundStatus.退款异常: |
| | | await _lifePayService.LifePayRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.退款中); |
| | | break; |
| | | default: await _lifePayService.LifePayRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.退款中); break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |