From 3274bc9ca97ce02bd7eb86107898a40531057477 Mon Sep 17 00:00:00 2001
From: sunpengfei <i@angelzzz.com>
Date: 星期一, 09 六月 2025 16:37:48 +0800
Subject: [PATCH] pref:多次接收到支付回调的bug

---
 LifePayment/LifePayment.Application/LifePay/LifePayService.cs |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index dbbcb41..7d0e1f1 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -130,6 +130,16 @@
     }
 
     /// <summary>
+    /// 璇濊垂璁㈠崟鏌ヨ
+    /// </summary>
+    /// <param name="input"></param>
+    /// <returns></returns>
+    public async Task<QueryPhoneOrderResponse> QueryPhoneOrder(QueryPhoneOrderRequestInput input)
+    {
+        return await _aCOOLYManager.QueryPhoneOrder(input);
+    }
+
+    /// <summary>
     /// 鑾峰彇璇濊垂闈㈠��
     /// </summary>
     /// <param name="input"></param>
@@ -353,6 +363,7 @@
                                 RefundPrice = a.RefundPrice,
                                 ChannelName = b.ChannlesName,
                                 ActualRechargeAmount = a.RechargeAmount,
+                                ActualReceivedAmount = a.ActualReceivedAmount,
                                 PlatformDeductionAmount = a.PlatformDeductionAmount,
                                 ACOOLYStatus = a.ACOOLYStatus,
                                 LifePayRefundStatus = a.LifePayRefundStatus,
@@ -453,6 +464,7 @@
             PremiumPrice = orderpirce.PremiumPrice,
             Profit = orderpirce.Profit,
             RefundOrderNo = order.RefundOrderNo,
+            ActualReceivedAmount = order.ActualReceivedAmount
         };
 
         return result;
@@ -1294,7 +1306,7 @@
         var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync();
         CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
 
-        if (order.PayStatus == LifePayStatusEnum.宸叉敮浠�)
+        if (order.PayStatus != LifePayStatusEnum.鏈敮浠�)
         {
             return;
         }
@@ -1376,12 +1388,13 @@
         var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync();
         CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
 
-        if (order.LifePayOrderStatus == LifePayOrderStatusEnum.宸插畬鎴�)
+        if (order.LifePayOrderStatus == status && order.ACOOLYStatus == acoolyStatus)
         {
+            _logger.LogInformation($"璁㈠崟锛坽orderNo}锛夊凡澶勭悊璇ョ姸鎬�");
             return;
         }
 
-         //order.PlatformDeductionAmount = payAmount;
+        order.ActualReceivedAmount = actualParValue;
 
         if (acoolyOrderNo.IsNotNullOrEmpty())
         {
@@ -1404,6 +1417,8 @@
             || order.LifePayOrderStatus == LifePayOrderStatusEnum.宸查��娆�)
         {
             order.FinishTime = DateTime.Now;
+            order.PlatformDeductionAmount = Math.Round((order.ActualReceivedAmount ?? 0) * (order.PlatformRate ?? 0) / 100, 2);
+            order.RefundPrice = Math.Round((1 - ((order.ActualReceivedAmount ?? 0) / (order.RechargeAmount ?? 0))) * (order.PayAmount ?? 0), 2);
         }
 
         await _lifePayOrderRepository.UpdateAsync(order);
@@ -1513,6 +1528,8 @@
         order.RefundTime = DateTime.Now;
         order.RefundCheckUserId = CurrentUser.Id;
         order.RefundPrice = input.RefundPrice;
+        order.ActualReceivedAmount = Math.Round((1 - ((order.RefundPrice ?? 0) / (order.PayAmount ?? 0))) * (order.RechargeAmount ?? 0), 2);
+        order.PlatformDeductionAmount = Math.Round((order.ActualReceivedAmount ?? 0) * (order.PlatformRate ?? 0) / 100, 2);
 
         //await _lifePayOrderRepository.UpdateAsync(order);
 

--
Gitblit v1.9.1