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 | 67 +++++++++++++++++++++++----------
1 files changed, 46 insertions(+), 21 deletions(-)
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index ddfd419..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,10 +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环);
+ //渚涘簲鍟嗘姌鎵d环
+ var platformRate = rateChannel.SupplierRate;
var orderInput = new CreateLifePayOrderInput
{
@@ -1158,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,
};
@@ -1192,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
{
@@ -1213,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,
};
@@ -1551,6 +1563,12 @@
return;
}
+ if (order.LifePayOrderStatus == LifePayOrderStatusEnum.宸查��娆�)
+ {
+ _logger.LogInformation($"璁㈠崟宸查��娆�,涓嶅湪澶勭悊");
+ return;
+ }
+
order.ActualReceivedAmount = actualParValue;
order.PlatformDeductionAmount = Math.Round((order.ActualReceivedAmount ?? 0) * (order.PlatformRate ?? 0) / 100, 2);
@@ -1609,7 +1627,7 @@
await _lifePayOrderService.CreatLifePayConsumption(acoolyStatus, order.OrderNo, order.ACOOLYOrderNo,
order.PlatformDeductionAmount ?? 0, order.ChannelId, order.CreationTime, order.FinishTime, order.ChannleRate, parValue, actualParValue);
- await CurrentUnitOfWork.CompleteAsync();
+ await CurrentUnitOfWork.SaveChangesAsync();
_logger.LogInformation("浜嬪姟瀹屾垚");
}
@@ -1917,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, "娓犻亾鎶樻墸鏃犳硶浣庝簬渚涘簲鍟嗘姌鎵�");
@@ -2449,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