From e896cbc0f5d5483d4661918556f45b7b9a6c31c2 Mon Sep 17 00:00:00 2001
From: zhengyuxuan <zhengyuxuan1995>
Date: 星期一, 24 三月 2025 20:31:36 +0800
Subject: [PATCH] fix:手续费、利润等计算
---
LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 40 +++++++++++++++++++++++++++++++++++-----
1 files changed, 35 insertions(+), 5 deletions(-)
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index 67ce229..060bbdb 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -398,6 +398,9 @@
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,
@@ -429,12 +432,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;
@@ -2069,5 +2072,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