From d3df5273d83fefa80e988300f1d33387985c811c Mon Sep 17 00:00:00 2001
From: zhengyuxuan <zhengyuxuan1995>
Date: 星期一, 31 三月 2025 17:33:28 +0800
Subject: [PATCH] fix:支付宝支付回调

---
 LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs           |    8 ++++----
 LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml |    8 ++++++++
 LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs   |   10 +++++++++-
 LifePayment/LifePayment.Application/LifePay/LifePayService.cs              |    5 +++--
 LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs          |   18 +++++++++++++++++-
 5 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
index f5cb567..299ec16 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
@@ -50,7 +50,15 @@
     /// <returns></returns>
     Task LifePaySuccessHandler(string orderNo, string outOrderNo);
 
-    Task WxPayDomesticRefundsHandler(string orderNo, LifePayRefundStatusEnum refundStatus);
+    /// <summary>
+    /// 閫�娆炬垚鍔熷洖璋冨鐞�
+    /// </summary>
+    /// <param name="orderNo"></param>
+    /// <param name="refundStatus"></param>
+    /// <returns></returns>
+    Task LifePayRefundsHandler(string orderNo, LifePayRefundStatusEnum refundStatus);
+
+    
 
     /// <summary>
     /// 渚涘簲鍟嗗洖璋冨鐞�
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index 41fde74..5bae261 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -1321,7 +1321,7 @@
         await _lifePayOrderRepository.UpdateAsync(order);
     }
 
-    public async Task WxPayDomesticRefundsHandler(string orderNo, LifePayRefundStatusEnum refundStatus)
+    public async Task LifePayRefundsHandler(string orderNo, LifePayRefundStatusEnum refundStatus)
     {
         var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync();
         CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
@@ -1338,6 +1338,7 @@
             default: break;
         }
     }
+
 
     /// <summary>
     /// ACOOLYO璁㈠崟閫氱煡澶勭悊
@@ -1598,7 +1599,7 @@
             await _lifePayAccount.InsertAsync(userAccount);
         }
 
-        if (input.LifePayType == LifePayOrderTypeEnum.PhoneOrder)
+        if (input.LifePayType == LifePayOrderTypeEnum.PhoneOrder || input.LifePayType == LifePayOrderTypeEnum.ElectricOrder)
         {
             var extraProperties = JsonConvert.DeserializeObject<Model_UserAccountExtraProperties>(input.ExtraProperties);
             if (!string.IsNullOrEmpty(extraProperties.Name) && extraProperties.Phone == user.PhoneNumber)
diff --git a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
index 666f3db..e48f92f 100644
--- a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
+++ b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
@@ -42,6 +42,14 @@
             <param name="outOrderNo"></param>
             <returns></returns>
         </member>
+        <member name="M:LifePayment.Application.Contracts.ILifePayService.LifePayRefundsHandler(System.String,LifePayment.Domain.Shared.LifePayRefundStatusEnum)">
+            <summary>
+            閫�娆炬垚鍔熷洖璋冨鐞�
+            </summary>
+            <param name="orderNo"></param>
+            <param name="refundStatus"></param>
+            <returns></returns>
+        </member>
         <member name="M:LifePayment.Application.Contracts.ILifePayService.ACOOLYOrderNotifyHandler(System.String,System.String,LifePayment.Domain.Shared.LifePayOrderStatusEnum,LifePayment.Domain.Shared.ACOOLYStatusEnum,System.Decimal,System.String)">
             <summary>
             渚涘簲鍟嗗洖璋冨鐞�
diff --git a/LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs b/LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs
index e2cbb0a..e5b41c0 100644
--- a/LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs
+++ b/LifePayment/LifePayment.HttpApi/LifePay/AliPayNotifyController.cs
@@ -1,4 +1,5 @@
 锘縰sing 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
 {
@@ -57,7 +59,7 @@
 
             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);
                     // 鎻掑叆鏀舵敮娴佹按
@@ -65,6 +67,20 @@
                         OutOrderNo = input.TradeNo ,LifePayType = LifePayTypeEnum.AliPay,ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Expenses,
                         Amount = input.ReceiptAmount.Value });
                 }
+                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,
+                        OutOrderNo = input.TradeNo,
+                        LifePayType = LifePayTypeEnum.AliPay,
+                        ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Receipts,
+                        Amount = input.ReceiptAmount.Value
+                    });
+                }
             }
             else
             {
diff --git a/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs b/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs
index 970139a..bfec02f 100644
--- a/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs
+++ b/LifePayment/LifePayment.HttpApi/LifePay/WxPayNotifyController.cs
@@ -110,7 +110,7 @@
                     {
                         case LifePaymentConstant.WxPayRefundStatus.閫�娆炬垚鍔�:
                         case LifePaymentConstant.WxPayRefundStatus.閫�娆惧叧闂�:
-                            await _lifePayService.WxPayDomesticRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.宸查��娆�);
+                            await _lifePayService.LifePayRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.宸查��娆�);
                             // 鎻掑叆鏀舵敮娴佹按
                             await _lifePayOrderService.AddLifePayExpensesReceipts(new AddLifePayExpensesReceiptsInput()
                             {
@@ -122,12 +122,12 @@
                             });
                             break;
                         case LifePaymentConstant.WxPayRefundStatus.閫�娆惧鐞嗕腑:
-                            await _lifePayService.WxPayDomesticRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.閫�娆句腑);
+                            await _lifePayService.LifePayRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.閫�娆句腑);
                             break;
                         case LifePaymentConstant.WxPayRefundStatus.閫�娆惧紓甯�:
-                            await _lifePayService.WxPayDomesticRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.閫�娆句腑);
+                            await _lifePayService.LifePayRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.閫�娆句腑);
                             break;
-                        default : await _lifePayService.WxPayDomesticRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.閫�娆句腑);break;
+                        default : await _lifePayService.LifePayRefundsHandler(wxPayNotice.OutTradeNo, LifePayRefundStatusEnum.閫�娆句腑);break;
                     }
                 }
             }

--
Gitblit v1.9.1