From f7bb0825bc06b8cea32caa44d2326dde51990e77 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期四, 11 九月 2025 11:10:55 +0800
Subject: [PATCH] feat: 公告

---
 LifePayment/LifePayment.Application/LifePay/LifePayService.cs |   63 +++++++++++++++++++------------
 1 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index b658491..dcbc06f 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -1,5 +1,6 @@
 锘縰sing Alipay.EasySDK.Payment.Common.Models;
 using LifePayment.Application.Contracts;
+using LifePayment.Application.LifePay;
 using LifePayment.Domain;
 using LifePayment.Domain.LifePay;
 using LifePayment.Domain.Models;
@@ -50,6 +51,7 @@
     private readonly IAliPayApi _aliPayApi;
     private readonly IAlipayInterfaceManager _alipayInterfaceManager;
     private readonly IWxPayApi _wxPayApi;
+    private readonly ILifePayRateService _lifePayRateService;
     private readonly WxPayOption _wxPayOptions;
     private readonly InitSetting _initSettingOptions;
 
@@ -77,6 +79,7 @@
                           IRepository<LifePayAccount, Guid> lifePayAccount,
                           IDataFilter dataFilter,
                           IChannelFilter channelFilter,
+                          ILifePayRateService lifePayRateService,
                           IAbpDistributedLock distributedLock)
     {
         _logger = logger;
@@ -101,6 +104,7 @@
         _channelFilter = channelFilter;
         this.distributedLock = distributedLock;
         _operateHistory = operateHistory;
+        _lifePayRateService = lifePayRateService;
     }
 
     #region 鏌ヨ
@@ -1086,11 +1090,14 @@
         && x.OrderParamDetailJsonStr.Contains(input.ProductData.Phone)).AnyAsync();
         CheckExtensions.IfTrueThrowUserFriendlyException(repeatOrder, "鎮ㄦ湁鍚屾埛鍙疯鍗曟鍦ㄥ厖鍊间腑锛岃鍕块噸澶嶅厖鍊�");
 
-        var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.榛樿璇濊垂鎶樻墸);
+        var rateChannel = await GetLifePayRate(channle,input.ProductData.IspCode);
+        //骞冲彴鎶樻墸
+        var rate = rateChannel.Rate;
 
         var amount = CalculateAmount(input.ProductData.ParValue, rate);
 
-        var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环);
+        //渚涘簲鍟嗘姌鎵d环
+        var platformRate = rateChannel.SupplierRate;
 
         var orderInput = new CreateLifePayOrderInput
         {
@@ -1106,8 +1113,8 @@
             DiscountAmount = amount.DiscountAmount,
             RechargeAmount = amount.RechargeAmount,
             ChannelId = channle.ChannlesNum,
-            PlatformRate = platformRate.Rate,
-            PlatformDeductionAmount = amount.RechargeAmount * platformRate.Rate / 100,
+            PlatformRate = platformRate,
+            PlatformDeductionAmount = amount.RechargeAmount * platformRate / 100,
             ChannleRate = rate,
             ChannlesRakeRate = channle.ChannlesRakeRate,
         };
@@ -1140,16 +1147,13 @@
          && x.OrderParamDetailJsonStr.Contains(input.ProductData.ElectricAccount)).AnyAsync();
         CheckExtensions.IfTrueThrowUserFriendlyException(repeatOrder, "鎮ㄦ湁鍚屾埛鍙疯鍗曟鍦ㄥ厖鍊间腑锛岃鍕块噸澶嶅厖鍊�");
 
+        var rateChannel = await GetLifePayRate(channle, input.ProductData.ElectricType);
+        //骞冲彴鎶樻墸
+        var rate = rateChannel.Rate;
 
-        var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.榛樿鐢佃垂鎶樻墸);
         var amount = CalculateAmount(input.ProductData.ParValue, rate);
-        var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环);
-
-        //TODO 鐩稿叧鍗曢」鎶樻墸璋冭妭鍔熻兘鏈笂绾� 鐩墠閽堝鎯呭喌涓存椂鍐欐
-        if (input.ProductData.ElectricType == "guowang")
-        {
-            platformRate.Rate = 95;
-        }
+        //渚涘簲鍟嗘姌鎵d环
+        var platformRate = rateChannel.SupplierRate;
 
         var orderInput = new CreateLifePayOrderInput
         {
@@ -1164,8 +1168,8 @@
             DiscountAmount = amount.DiscountAmount,
             RechargeAmount = amount.RechargeAmount,
             ChannelId = channle.ChannlesNum,
-            PlatformRate = platformRate.Rate,
-            PlatformDeductionAmount = amount.RechargeAmount * platformRate.Rate / 100,
+            PlatformRate = platformRate,
+            PlatformDeductionAmount = amount.RechargeAmount * platformRate / 100,
             ChannleRate = rate,
             ChannlesRakeRate = channle.ChannlesRakeRate,
         };
@@ -1198,12 +1202,14 @@
         && x.OrderParamDetailJsonStr.Contains(input.ProductData.GasAccount)).AnyAsync();
         CheckExtensions.IfTrueThrowUserFriendlyException(repeatOrder, "鎮ㄦ湁鍚屾埛鍙疯鍗曟鍦ㄥ厖鍊间腑锛岃鍕块噸澶嶅厖鍊�");
 
-
-        var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.榛樿鐕冩皵鎶樻墸);
+        var rateChannel = await GetLifePayRate(channle, input.ProductData.GasOrgType);
+        //骞冲彴鎶樻墸
+        var rate = rateChannel.Rate;
 
         var amount = CalculateAmount(input.ProductData.ParValue, rate);
 
-        var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环);
+        //渚涘簲鍟嗘姌鎵d环
+        var platformRate = rateChannel.SupplierRate;
 
         var orderInput = new CreateLifePayOrderInput
         {
@@ -1219,8 +1225,8 @@
             DiscountAmount = amount.DiscountAmount,
             RechargeAmount = amount.RechargeAmount,
             ChannelId = channle.ChannlesNum,
-            PlatformRate = platformRate.Rate,
-            PlatformDeductionAmount = amount.RechargeAmount * platformRate.Rate / 100,
+            PlatformRate = platformRate,
+            PlatformDeductionAmount = amount.RechargeAmount * platformRate / 100,
             ChannleRate = rate,
             ChannlesRakeRate = channle.ChannlesRakeRate,
         };
@@ -1923,6 +1929,7 @@
                 dto.PromoterId = promoter.Id;
             }
 
+            //TODO 鍚庣画闇�瑕佷慨鏀� 鐜板湪鐨勪緵搴斿晢鎶樻墸浠锋牴鎹繍钀ュ晢涓嶅悓 閰嶇疆涓嶅悓 涓嶆槸缁熶竴閰嶇疆浜�
             var rate = await _lifePayRateRepository.FirstOrDefaultAsync(it => it.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环);
             CheckExtensions.IfTrueThrowUserFriendlyException(rate != null && input.ChannlesRate < rate.Rate, "娓犻亾鎶樻墸鏃犳硶浣庝簬渚涘簲鍟嗘姌鎵�");
 
@@ -2455,18 +2462,24 @@
         };
     }
 
-    public async Task<decimal> GetLifePayRate(CreateEditPayChannelsInput channel, LifePayRateTypeEnum lifePayRateType)
+    public async Task<GetLifePayRateOutput> GetLifePayRate(CreateEditPayChannelsInput channel, string code)
     {
+        var rateChannel = await _lifePayRateService.GetRateChannelByCode(code);
+            CheckExtensions.IfTrueThrowUserFriendlyException(rateChannel.Id.IsEmpty(), "鏈厤缃姌鎵�");
         if (channel == null)
         {
-            var rate = await GetRate();
-            CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "鏈厤缃姌鎵�");
-            var result = rate.FirstOrDefault(x => x.RateType == lifePayRateType).Rate;
-            return result;
+            return new GetLifePayRateOutput
+            {
+                Rate = rateChannel.PlatformRate,
+                SupplierRate = rateChannel.SupplierRate
+            };
         }
         else
         {
-            return channel.ChannlesRate;
+            return new GetLifePayRateOutput {
+                Rate= channel.ChannlesRate,
+                SupplierRate = rateChannel.SupplierRate
+            };
         }
     }
 

--
Gitblit v1.9.1