From 72845b9ade14bae50bc99a739d8ca5459b491c45 Mon Sep 17 00:00:00 2001
From: zhengyuxuan <zhengyuxuan1995>
Date: 星期二, 25 三月 2025 09:34:48 +0800
Subject: [PATCH] fix:开启1分钱支付

---
 LifePayment/LifePayment.Application/LifePay/LifePayService.cs |   53 ++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 42 insertions(+), 11 deletions(-)

diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index a4e76a1..a33468f 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -358,7 +358,7 @@
     {
         var result = await (await GetLifePayRefundOrderListFilter(input)).Select(x => new LifePayRefundOrderListTemplate
         {
-            FinishTime = x.FinishTime,
+            FinishTime = x.RefundTime,
             RefundPrice = x.RefundPrice,
             LifePayOrderType = x.LifePayOrderType,
             LifePayType = x.LifePayType,
@@ -368,6 +368,7 @@
             ChannelName = x.ChannelName,
             CreationTime = x.CreationTime,
             ACOOLYStatus = x.ACOOLYStatus,
+            RefundApplyRemark = x.RefundApplyRemark,
             RechargeAmount = x.RechargeAmount,
             ActualReceivedAmount = x.ActualReceivedAmount.ToString("F2"),
             LifePayRefundStatus = x.LifePayRefundStatus,
@@ -397,8 +398,10 @@
         var channle = await _lifePayChannlesRep.FirstOrDefaultAsync(r => r.ChannlesNum == order.ChannelId);
          CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
         var user = await _lifePayUserRepository.FirstOrDefaultAsync(x => x.Id == order.UserId);
-        
         var channlesRakePrice = (order.PayAmount - (order.PlatformDeductionAmount == null ? 0 : order.PlatformDeductionAmount)) * channle.ChannlesRakeRate / 100;
+        var orderpirce = await GetOrderPrice(order.RechargeAmount, order.PayAmount,order.PlatformRate, order.ChannleRate, order.ChannlesRakeRate,order.PremiumRate);
+
+
         var result = new LifePayOrderOutput()
                 {
             UserName = user.Name,
@@ -430,12 +433,12 @@
             PlatformPrice = order.PlatformDeductionAmount,
             ElecBillUrl = order.ElecBillUrl.GetOssPath(),
             RefundElecBillUrl = order.RefundElecBillUrl.GetOssPath(),
-            ChannleRate = channle.ChannlesRate,
-            ChannlesRakeRate = channle.ChannlesRakeRate,
-            ChannlesRakePrice = channlesRakePrice.HasValue ? 0 : Math.Round(channlesRakePrice.Value, 2),
+            ChannleRate = order.ChannleRate,
+            ChannlesRakeRate = order.ChannlesRakeRate,
+            ChannlesRakePrice = orderpirce.ChannlesRakePrice,
             PremiumRate = order.PremiumRate,
-            PremiumPrice = Math.Round(order.PayAmount * (order.PremiumRate.HasValue ? order.PremiumRate.Value:0), 2),
-            Profit = (order.PayAmount - order.PlatformDeductionAmount) * (1.00m - channle.ChannlesRakeRate / 100) - Math.Round(order.PayAmount * (order.PremiumRate.HasValue ? order.PremiumRate.Value : 0), 2)
+            PremiumPrice = orderpirce.PremiumPrice,
+            Profit = orderpirce.Profit
         };
 
         return result;
@@ -745,17 +748,17 @@
         {
             s.SerialNumber = ++i;
             s.LifePayOrderTypeStr = s.LifePayOrderType.GetDescription();
-            s.CreationTimeStr = s.CreationTime.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm);
+            s.CreationTimeStr = s.CreationTime.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmmss);
             s.RechargeAmountStr = s.RechargeAmount.ToString("F2");
             s.PayAmountStr = s.PayAmount.ToString("F2");
-            s.PayTimeStr = !s.PayTime.HasValue ? string.Empty : s.PayTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm);
+            s.PayTimeStr = !s.PayTime.HasValue ? string.Empty : s.PayTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmmss);
             s.LifePayTypeStr = s.LifePayType.GetDescription();
             s.PayStatusStr = s.PayStatus.GetDescription();
             s.ActualRechargeAmountStr = s.ActualRechargeAmount.ToString("F2");
             s.LifePayRefundStatusStr = s.LifePayRefundStatusStr.GetDescription();
             s.ACOOLYStatusStr = s.ACOOLYStatus.GetDescription();
             //s.LifePayOrderStatusStr = s.LifePayOrderStatus.GetDescription();
-            s.FinishTimeStr = !s.FinishTime.HasValue ? string.Empty : s.FinishTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm);
+            s.FinishTimeStr = !s.FinishTime.HasValue ? string.Empty : s.FinishTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmmss);
         });
         return result;
     }
@@ -1305,6 +1308,7 @@
         {
             order.ACOOLYOrderNo = acoolyOrderNo;
         }
+
         if (refundApplyRemark.IsNotNullOrEmpty())
         {
             order.RefundApplyRemark = refundApplyRemark;
@@ -1312,7 +1316,7 @@
 
         order.LifePayOrderStatus = status;
         order.ACOOLYStatus = acoolyStatus;
-
+        order.FinishTime = DateTime.Now;
         await _lifePayOrderRepository.UpdateAsync(order);
     }
 
@@ -2069,5 +2073,32 @@
                     });
     }
 
+    public async Task<OrderPriceReturn> GetOrderPrice(decimal price, decimal priceAmount, decimal? platformRate,decimal? channleRate,
+        decimal? channlesRakeRate,decimal? premiumRate)
+    {
+        /// 姣涘埄
+        var grossProfit = price * (channleRate - platformRate) / 100;
+
+        /// 骞冲彴鎵f閲戦  鍏呭�奸潰棰� * 骞冲彴鎶樻墸姣斾緥
+        var platformPrice = price * platformRate / 100;
+
+        /// 鎵嬬画璐�
+        var premiumPrice = priceAmount * premiumRate / 100;
+
+        /// 娓犻亾浣i噾  锛�(鍏呭�奸潰棰� * 娓犻亾鎶樻墸姣斾緥)-(鍏呭�奸潰棰� * 骞冲彴鎶樻墸姣斾緥)锛�* 浣i噾姣斾緥
+        var channlesRakePrice = grossProfit * channlesRakeRate / 100;
+
+        /// 鍒╂鼎
+        var profit = grossProfit - channlesRakePrice - premiumPrice;
+
+        return new OrderPriceReturn()
+        {
+            PlatformPrice = platformPrice.HasValue? platformPrice.Value :0,
+            PremiumPrice = premiumPrice.HasValue ? premiumPrice.Value : 0,
+            ChannlesRakePrice = channlesRakePrice.HasValue? channlesRakePrice.Value:0,
+            Profit = profit.HasValue ? profit.Value : 0
+        };
+    }
+
     #endregion
 }

--
Gitblit v1.9.1