| | |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | [UnitOfWork(false)] |
| | | public async Task<ContentResult> AliRechargeNotify() |
| | | { |
| | | _logger.LogError($"生活管家支付宝充值回调通知:进入支付宝回调"); |
| | |
| | | |
| | | if (input.OutTradeNo.Contains("JF")) |
| | | { |
| | | if (input.TradeStatus == LifePaymentConstant.AliPayStatus.支付成功 && input.OutBizNo.IsNullOrEmpty()) |
| | | try |
| | | { |
| | | await _lifePayService.LifePaySuccessHandler(input.OutTradeNo, input.TradeNo); |
| | | // 插入收支流水 |
| | | await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput() |
| | | if (input.TradeStatus == LifePaymentConstant.AliPayStatus.支付成功 && input.OutBizNo.IsNullOrEmpty()) |
| | | { |
| | | OrderNo = input.OutTradeNo, |
| | | OutOrderNo = input.TradeNo, |
| | | LifePayType = LifePayTypeEnum.AliPay, |
| | | ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Expenses |
| | | }); |
| | | await CurrentUnitOfWork.SaveChangesAsync(); |
| | | await _lifePayService.LifePaySuccessHandler(input.OutTradeNo, input.TradeNo); |
| | | // 插入收支流水 |
| | | await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput() |
| | | { |
| | | OrderNo = input.OutTradeNo, |
| | | OutOrderNo = input.TradeNo, |
| | | LifePayType = LifePayTypeEnum.AliPay, |
| | | ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Expenses |
| | | }); |
| | | await CurrentUnitOfWork.SaveChangesAsync(); |
| | | _logger.LogInformation("事务完成"); |
| | | } |
| | | else if (((input.TradeStatus == LifePaymentConstant.AliPayStatus.支付成功 || input.TradeStatus == LifePaymentConstant.AliPayStatus.超时关闭) |
| | | && input.OutBizNo.IsNotNullOrEmpty() |
| | | && (input.RefundFee.HasValue && input.RefundFee > 0))) |
| | | { |
| | | await _lifePayService.LifePayRefundsHandler(input.OutTradeNo, LifePayRefundStatusEnum.已退款); |
| | | // 插入收支流水 |
| | | await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput() |
| | | { |
| | | OrderNo = input.OutTradeNo, |
| | | OutRefundNo = input.OutBizNo, |
| | | OutOrderNo = input.TradeNo, |
| | | LifePayType = LifePayTypeEnum.AliPay, |
| | | ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Receipts |
| | | }); |
| | | await CurrentUnitOfWork.SaveChangesAsync(); |
| | | _logger.LogInformation("事务完成"); |
| | | } |
| | | } |
| | | else if (((input.TradeStatus == LifePaymentConstant.AliPayStatus.支付成功 || input.TradeStatus == LifePaymentConstant.AliPayStatus.超时关闭) |
| | | && input.OutBizNo.IsNotNullOrEmpty() |
| | | && (input.RefundFee.HasValue && input.RefundFee > 0))) |
| | | catch (Exception ex) |
| | | { |
| | | await _lifePayService.LifePayRefundsHandler(input.OutTradeNo, LifePayRefundStatusEnum.已退款); |
| | | // 插入收支流水 |
| | | await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput() |
| | | { |
| | | OrderNo = input.OutTradeNo, |
| | | OutRefundNo = input.OutBizNo, |
| | | OutOrderNo = input.TradeNo, |
| | | LifePayType = LifePayTypeEnum.AliPay, |
| | | ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Receipts |
| | | }); |
| | | await CurrentUnitOfWork.SaveChangesAsync(); |
| | | await CurrentUnitOfWork.RollbackAsync(); |
| | | _logger.LogError($"支付宝支付回调异常:{ex.Message}", ex); |
| | | } |
| | | } |
| | | else |