From 78bf5ae3845bd2d7008eae76a1d4facb2d29280b Mon Sep 17 00:00:00 2001
From: zhengyuxuan <zhengyuxuan1995>
Date: 星期五, 21 三月 2025 15:11:42 +0800
Subject: [PATCH] fix:部分退款接口更新

---
 LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs     |   13 ++++--
 LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml |   33 ++++++++++++++--
 LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs      |   16 ++++++++
 LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayEnum.cs          |    9 ++++
 LifePayment/LifePayment.Application/LifePay/LifePayService.cs              |   43 ++++++++++++++++++---
 5 files changed, 99 insertions(+), 15 deletions(-)

diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs
index 39b7289..e38e3a3 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs
@@ -352,9 +352,25 @@
 {
     public Guid Id { get; set; }
 
+    /// <summary>
+    /// 涓婁紶鍑瘉
+    /// </summary>
     public string RefundCredentialsImgUrl { get; set; }
 
+    /// <summary>
+    /// 閫�娆鹃┏鍥炲師鍥�
+    /// </summary>
     public string RefundCheckRemark { get; set; }
+
+    /// <summary>
+    /// 閫�娆剧被鍨�
+    /// </summary>
+    public LifePayRefundTypeEnum LifePayRefundType { get; set; }
+
+    /// <summary>
+    /// 閫�娆鹃噾棰�
+    /// </summary>
+    public decimal RefundPrice { get; set; }
 }
 
 public class RefundUserLifePayOrderInput : ChannelsBaseInput
diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
index 54f3991..cb59958 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
@@ -869,6 +869,11 @@
 public class TopStatisticsOutput
 {
     /// <summary>
+    /// 鍒涘缓鏃堕棿
+    /// </summary>
+    public DateTime CreationTime { get; set; }
+
+    /// <summary>
     /// 璐︽埛浣欓
     /// </summary>
     public decimal Amount { get; set; }
@@ -881,7 +886,7 @@
     /// <summary>
     /// 鏄ㄦ棩鏀舵
     /// </summary>
-    public decimal ReceiptsYesterda { get; set; }
+    public decimal ReceiptsYesterday { get; set; }
 
 
     /// <summary>
@@ -897,17 +902,17 @@
     /// <summary>
     /// 鏄ㄦ棩涓嬪崟
     /// </summary>
-    public int OrdersNumYesterda { get; set; }
+    public int OrdersNumYesterday { get; set; }
 
     /// <summary>
     /// 鏄ㄦ棩鎴愬姛
     /// </summary>
-    public int YesterdaSuccess { get; set; }
+    public int YesterdaySuccess { get; set; }
 
     /// <summary>
     /// 鏄ㄦ棩澶辫触
     /// </summary>
-    public int YesterdaFail { get; set; }
+    public int YesterdayFail { get; set; }
 
     /// <summary>
     /// 绱鐢ㄦ埛
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index e24db15..e4e9294 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -122,13 +122,34 @@
                 AccumulatedUsers = accumulatedUsers,
             };
             await _dallyStatisticsRepository.InsertAsync(entity);
-            //var result = ObjectMapper.Map<DallyStatistics, TopStatisticsOutput>(entity);
-            return new TopStatisticsOutput();
+
+            TopStatisticsOutput topStatisticsOutput = new TopStatisticsOutput()
+            {
+                Amount = entity.Amount,
+                AccumulatedReceipts = entity.AccumulatedReceipts,
+                ReceiptsYesterday = entity.ReceiptsYesterday,
+                AccumulatedOrders = entity.AccumulatedOrders,
+                OrdersNumYesterday = entity.OrdersNumYesterday,
+                YesterdaySuccess = entity.YesterdaySuccess,
+                YesterdayFail = entity.YesterdayFail,
+                AccumulatedUsers = entity.AccumulatedUsers,
+            };
+            return topStatisticsOutput;
         }
         else
         {
-            var result = ObjectMapper.Map<DallyStatistics, TopStatisticsOutput>(statistics);
-            return result;
+            TopStatisticsOutput topStatisticsOutput = new TopStatisticsOutput()
+            {
+                Amount = statistics.Amount,
+                AccumulatedReceipts = statistics.AccumulatedReceipts,
+                ReceiptsYesterday = statistics.ReceiptsYesterday,
+                AccumulatedOrders = statistics.AccumulatedOrders,
+                OrdersNumYesterday = statistics.OrdersNumYesterday,
+                YesterdaySuccess = statistics.YesterdaySuccess,
+                YesterdayFail = statistics.YesterdayFail,
+                AccumulatedUsers = statistics.AccumulatedUsers,
+            };
+            return topStatisticsOutput;
         }
     }
 
@@ -1283,6 +1304,14 @@
         {
             return;
         }
+        if (input.RefundPrice > order.PayAmount)
+        {
+            throw new UserFriendlyException("閫�娆剧殑閲戦涓嶈兘澶т簬瀹炰粯閲戦");
+        }
+        if (input.LifePayRefundType == LifePayRefundTypeEnum.鍏ㄩ閫�娆� && input.RefundPrice != order.PayAmount)
+        {
+            throw new UserFriendlyException("鍏ㄩ閫�娆剧殑閲戦涓庡疄浠橀噾棰濅笉涓�鑷�");
+        }
 
         if (order.LifePayOrderStatus != LifePayOrderStatusEnum.宸插け璐� && order.PayStatus != LifePayStatusEnum.寰呴��娆� && order.LifePayOrderStatus != LifePayOrderStatusEnum.閫�娆惧緟瀹℃牳)
         {
@@ -1294,7 +1323,7 @@
         switch (order.LifePayType)
         {
             case LifePayTypeEnum.WxPay:
-                var wxRefundResult = await WxPayDomesticRefunds(order.OrderNo, outRefundNo,order.RefundApplyRemark, Convert.ToInt32(order.PayAmount * 100), Convert.ToInt32(order.PayAmount * 100));
+                var wxRefundResult = await WxPayDomesticRefunds(order.OrderNo, outRefundNo,order.RefundApplyRemark, Convert.ToInt32(input.RefundPrice * 100), Convert.ToInt32(order.PayAmount * 100));
                 if (wxRefundResult.Status == "SUCCESS")
                 {
                     order.PayStatus = LifePayStatusEnum.宸查��娆�;
@@ -1316,7 +1345,7 @@
 
                 break;
             case LifePayTypeEnum.AliPay:
-                var aliRefundResult = await AliTradeRefund(new AlipayTradeRefundRequest() { OutTradeNo = order.OrderNo, RefundAmount = order.PayAmount.ToString() });
+                var aliRefundResult = await AliTradeRefund(new AlipayTradeRefundRequest() { OutTradeNo = order.OrderNo, RefundAmount = Convert.ToInt32(input.RefundPrice * 100).ToString() });
                 if (aliRefundResult.Code != AlipayResultCode.Success)
                 {
                     throw new UserFriendlyException("閫�娆惧け璐�");
@@ -1332,7 +1361,7 @@
         order.RefundCheckRemark = input.RefundCheckRemark;
         order.RefundTime = DateTime.Now;
         order.RefundCheckUserId = CurrentUser.Id;
-        order.RefundPrice = order.PayAmount;
+        order.RefundPrice = input.RefundPrice;
 
         await _lifePayOrderRepository.UpdateAsync(order);
 
diff --git a/LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayEnum.cs b/LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayEnum.cs
index 0979050..3ab14a3 100644
--- a/LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayEnum.cs
+++ b/LifePayment/LifePayment.Domain.Shared/Enum/LifePay/LifePayEnum.cs
@@ -150,4 +150,13 @@
 
     [Description("寰俊鐨勫唴瀹�")]
     寰俊鐨勫唴瀹� = 4,
+}
+
+public enum LifePayRefundTypeEnum
+{
+    [Description("鍏ㄩ閫�娆�")]
+    鍏ㄩ閫�娆� = 10,
+
+    [Description("閮ㄥ垎閫�娆�")]
+    閮ㄥ垎閫�娆� = 20
 }
\ No newline at end of file
diff --git a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
index c1e0de8..5193fb0 100644
--- a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
+++ b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
@@ -510,6 +510,26 @@
             鎼滅储鍏抽敭璇�
             </summary>
         </member>
+        <member name="P:LifePayment.Application.Contracts.RefundLifePayOrderInput.RefundCredentialsImgUrl">
+            <summary>
+            涓婁紶鍑瘉
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.RefundLifePayOrderInput.RefundCheckRemark">
+            <summary>
+            閫�娆鹃┏鍥炲師鍥�
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.RefundLifePayOrderInput.LifePayRefundType">
+            <summary>
+            閫�娆剧被鍨�
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.RefundLifePayOrderInput.RefundPrice">
+            <summary>
+            閫�娆鹃噾棰�
+            </summary>
+        </member>
         <member name="P:LifePayment.Application.Contracts.RefundUserLifePayOrderInput.UserId">
             <summary>
             鐢ㄦ埛Id
@@ -1265,6 +1285,11 @@
             鍒涘缓鏃堕棿
             </summary>
         </member>
+        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.CreationTime">
+            <summary>
+            鍒涘缓鏃堕棿
+            </summary>
+        </member>
         <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.Amount">
             <summary>
             璐︽埛浣欓
@@ -1275,7 +1300,7 @@
             绱鏀舵
             </summary>
         </member>
-        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.ReceiptsYesterda">
+        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.ReceiptsYesterday">
             <summary>
             鏄ㄦ棩鏀舵
             </summary>
@@ -1290,17 +1315,17 @@
             绱涓嬪崟
             </summary>
         </member>
-        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.OrdersNumYesterda">
+        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.OrdersNumYesterday">
             <summary>
             鏄ㄦ棩涓嬪崟
             </summary>
         </member>
-        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.YesterdaSuccess">
+        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.YesterdaySuccess">
             <summary>
             鏄ㄦ棩鎴愬姛
             </summary>
         </member>
-        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.YesterdaFail">
+        <member name="P:LifePayment.Application.Contracts.TopStatisticsOutput.YesterdayFail">
             <summary>
             鏄ㄦ棩澶辫触
             </summary>

--
Gitblit v1.9.1