From d64a364e912bb0d34c3efabd1bdee9a2f6ec0878 Mon Sep 17 00:00:00 2001
From: zhengyuxuan <zhengyuxuan1995>
Date: 星期一, 24 三月 2025 14:06:24 +0800
Subject: [PATCH] fix:微信退款bug修复、新增获取渠道折扣接口

---
 LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs     |    5 ++
 LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml |    6 +++
 LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs               |   12 ++++++
 LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs   |    7 +++
 LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml                |    6 +++
 LifePayment/LifePayment.Application/LifePay/LifePayService.cs              |   24 ++++++++++-
 LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs         |   17 ++++++--
 7 files changed, 69 insertions(+), 8 deletions(-)

diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
index e72264b..41279f3 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/ILifePayService.cs
@@ -143,6 +143,13 @@
     /// <returns></returns>
     Task<List<LifePayRateListOutput>> GetRate();
 
+
+    /// <summary>
+    /// 鑾峰彇娓犻亾鎶樻墸
+    /// </summary>
+    /// <returns></returns>
+    Task<ChannelRateOutput> GetChannelRate(ChannelsBaseInput input);
+
     /// <summary>
     /// 鑾峰彇鎵嬬画璐硅垂鐜�
     /// </summary>
diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
index 3fde72d..ef263de 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
@@ -935,4 +935,9 @@
     /// </summary>
     public int YesterdayActiveUsers { get; set; }
 
+}
+
+public class ChannelRateOutput
+{
+    public decimal ChannlesRate { get; set; }
 }
\ No newline at end of file
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index 974ebc5..00d63e0 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -152,6 +152,16 @@
     }
 
     /// <summary>
+    /// 鑾峰彇娓犻亾鎶樻墸
+    /// </summary>
+    /// <returns></returns>
+    public async Task<ChannelRateOutput> GetChannelRate(ChannelsBaseInput input)
+    {
+        return  _lifePayChannlesRep.Where(x => x.IsDeleted == false && x.ChannlesNum == input.CheckChannelId).Select(x => new ChannelRateOutput() { ChannlesRate = x.ChannlesRate })
+                                           .FirstOrDefault();
+    }
+
+    /// <summary>
     /// 鑾峰彇鎵嬬画璐硅垂鐜�
     /// </summary>
     /// <returns></returns>
@@ -1327,12 +1337,16 @@
                     order.LifePayOrderStatus = LifePayOrderStatusEnum.閫�娆句腑;
                     order.LifePayRefundStatus = LifePayRefundStatusEnum.閫�娆句腑;
                 }
+                else if (wxRefundResult.Message == "璁㈠崟宸插叏棰濋��娆�")
+                {
+                    order.LifePayOrderStatus = LifePayOrderStatusEnum.宸查��娆�;
+                    order.LifePayRefundStatus = LifePayRefundStatusEnum.宸查��娆�;
+                }
                 else
                 {
                     order.LifePayOrderStatus = LifePayOrderStatusEnum.寰呴��娆�;
                     order.LifePayRefundStatus = LifePayRefundStatusEnum.寰呴��娆�;
                 }
-
                 break;
             case LifePayTypeEnum.AliPay:
                 var aliRefundResult = await AliTradeRefund(new AlipayTradeRefundRequest() { OutTradeNo = order.OrderNo, RefundAmount = Convert.ToInt32(input.RefundPrice * 100).ToString() });
@@ -1351,7 +1365,7 @@
         order.RefundCheckUserId = CurrentUser.Id;
         order.RefundPrice = input.RefundPrice;
 
-        await _lifePayOrderRepository.UpdateAsync(order);
+        //await _lifePayOrderRepository.UpdateAsync(order);
 
         #region 璁板綍鏃ュ織
 
@@ -1390,6 +1404,10 @@
 
             await _lifePayOrderRepository.UpdateAsync(order);
         }
+        else if (order.LifePayOrderStatus == LifePayOrderStatusEnum.宸查��娆� || order.LifePayRefundStatus == LifePayRefundStatusEnum.宸查��娆�)
+        {
+            throw new UserFriendlyException("褰撳墠璁㈠崟鏃犳硶閲嶅鐢宠閫�娆�");
+        }
         else
         {
             throw new UserFriendlyException("褰撳墠璁㈠崟鐘舵�佹棤娉曠敵璇烽��娆�");
@@ -1411,7 +1429,7 @@
         {
             OutTradeNo = outTradeNo,
             OutRefundNo = outRefundNo,
-            Reason = reason,
+            //Reason = reason,
             Amount = new Model_WxPayDomesticRefunds_Amount
             {
                 Refund = refund,
diff --git a/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs b/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs
index 4c235b5..c94907b 100644
--- a/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs
+++ b/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs
@@ -613,11 +613,11 @@
         [JsonProperty("out_refund_no")]
         public string OutRefundNo { get; set; }
 
-        /// <summary>
-        ///  閫�娆惧師鍥�
-        /// </summary>
-        [JsonProperty("reason")]
-        public string Reason { get; set; }
+        ///// <summary>
+        /////  閫�娆惧師鍥�
+        ///// </summary>
+        //[JsonProperty("reason")]
+        //public string Reason { get; set; }
 
         /// <summary>
         /// 閫�娆剧粨鏋滃洖璋僽rl
@@ -721,6 +721,13 @@
         [JsonProperty("amount")]
         public Model_WxPayRetuenDomesticRefunds_Amount Amount { get; set; }
 
+
+        /// <summary>
+        /// 杩斿洖淇℃伅
+        /// </summary>
+        [JsonProperty("message")]
+        public string Message { get; set; }
+
     }
 
     public class Model_WxPayRetuenDomesticRefunds_Amount: Model_WxPayDomesticRefunds_Amount
diff --git a/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml b/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
index 3a86491..44eb421 100644
--- a/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
+++ b/LifePayment/LifePayment.Host/LifePaymentService.HttpApi.xml
@@ -104,6 +104,12 @@
             </summary>
             <returns></returns>
         </member>
+        <member name="M:LifePayment.HttpApi.LifePayController.GetChannelRate(LifePayment.Domain.Shared.ChannelsBaseInput)">
+            <summary>
+            鑾峰彇娓犻亾鎶樻墸
+            </summary>
+            <returns></returns>
+        </member>
         <member name="M:LifePayment.HttpApi.LifePayController.GetPremium">
             <summary>
             鑾峰彇鎵嬬画璐硅垂鐜�
diff --git a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
index 1fa69a8..af8a7c3 100644
--- a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
+++ b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
@@ -130,6 +130,12 @@
             </summary>
             <returns></returns>
         </member>
+        <member name="M:LifePayment.Application.Contracts.ILifePayService.GetChannelRate(LifePayment.Domain.Shared.ChannelsBaseInput)">
+            <summary>
+            鑾峰彇娓犻亾鎶樻墸
+            </summary>
+            <returns></returns>
+        </member>
         <member name="M:LifePayment.Application.Contracts.ILifePayService.GetPremium">
             <summary>
             鑾峰彇鎵嬬画璐硅垂鐜�
diff --git a/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs b/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
index ed87e63..63d1182 100644
--- a/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
+++ b/LifePayment/LifePayment.HttpApi/LifePay/LifePayController.cs
@@ -150,6 +150,18 @@
         }
 
         /// <summary>
+        /// 鑾峰彇娓犻亾鎶樻墸
+        /// </summary>
+        /// <returns></returns>
+        [HttpGet]
+        [AllowAnonymous]
+        [ChannelFilter]
+        public async Task<ChannelRateOutput> GetChannelRate(ChannelsBaseInput input)
+        {
+            return await _lifePayService.GetChannelRate(input);
+        }
+
+        /// <summary>
         /// 鑾峰彇鎵嬬画璐硅垂鐜�
         /// </summary>
         /// <returns></returns>

--
Gitblit v1.9.1