zhengyuxuan
2025-04-07 6ae97d768948e197a89492239441feca04c1dbb9
LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs
@@ -1,4 +1,5 @@
using Alipay.AopSdk.F2FPay.Model;
using Castle.Core.Internal;
using LifePayment.Application.Contracts;
using LifePayment.Domain.Shared;
using Microsoft.AspNetCore.Authorization;
@@ -11,6 +12,7 @@
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Uow;
using ZeroD.Util;
namespace LifePayment.HttpApi
{
@@ -22,6 +24,7 @@
    {
        private readonly ILifePayService _lifePayService;
        private readonly ILifePayOrderService _lifePayOrderService;
        private readonly ILogger<AliPayNotifyController> _logger;
@@ -29,10 +32,12 @@
               ILogger<AliPayNotifyController> logger,
               ILifePayService lifePayService)
               ILifePayService lifePayService,
               ILifePayOrderService lifePayOrderService)
        {
            _logger = logger;
            _lifePayService = lifePayService;
            _lifePayOrderService = lifePayOrderService;
        }
        /// <summary>
@@ -54,14 +59,31 @@
            if (input.OutTradeNo.Contains("JF"))
            {
                if (input.TradeStatus == LifePaymentConstant.AliPayStatus.支付成功)
                if (input.TradeStatus == LifePaymentConstant.AliPayStatus.支付成功 && input.OutBizNo.IsNullOrEmpty())
                {
                    await _lifePayService.LifePaySuccessHandler(input.OutTradeNo, input.TradeNo);
                    // 插入收支流水
                    await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput() { OrderNo = input.OutTradeNo,
                        OutOrderNo = input.TradeNo ,LifePayType = LifePayTypeEnum.AliPay,ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Expenses });
                }
                else if((input.TradeStatus == LifePaymentConstant.AliPayStatus.支付成功 && input.OutBizNo.IsNotNullOrEmpty() && input.RefundFee.HasValue) ||
                    input.TradeStatus == LifePaymentConstant.AliPayStatus.超时关闭)
                {
                    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
                    });
                }
            }
            else
            {
                   _logger.LogError($"生活管家支付宝充值回调通知:订单号异常 "+ input.OutTradeNo);
                   _logger.LogError($"生活管家支付宝充值回调通知:订单号异常 " + input.OutTradeNo);
            }
            return new ContentResult