From 7a540f529d2c9a541993bc9818cad9c9093fec91 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期三, 03 十二月 2025 11:04:35 +0800
Subject: [PATCH] fix: bug
---
LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 71 ++++++++++++++++++++++-------------
1 files changed, 45 insertions(+), 26 deletions(-)
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index 6a6bbf7..14da46e 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 鏌ヨ
@@ -512,7 +516,7 @@
public async Task<LifePayRefundOrderOutput> GetLifePayRefundOrderDetail(string orderNo)
{
var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync();
- var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环);
+ //var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环);
var channle = await _lifePayChannlesRep.FirstOrDefaultAsync(r => r.ChannlesNum == order.ChannelId);
var premium = await _lifePayPremiumRepository.Where(x => x.PremiumType == order.LifePayType).FirstOrDefaultAsync();
CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
@@ -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,
};
@@ -1554,6 +1560,12 @@
if (order.LifePayOrderStatus == status && order.ACOOLYStatus == acoolyStatus)
{
_logger.LogInformation($"璁㈠崟锛坽orderNo}锛夊凡澶勭悊璇ョ姸鎬�");
+ return;
+ }
+
+ if (order.LifePayOrderStatus == LifePayOrderStatusEnum.宸查��娆�)
+ {
+ _logger.LogInformation($"璁㈠崟宸查��娆�,涓嶅湪澶勭悊");
return;
}
@@ -1923,6 +1935,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 +2468,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