From ff7920ed1f3b0ff3f4fccd97c4b31b80fb63b142 Mon Sep 17 00:00:00 2001
From: lingling <kety1122@163.com>
Date: 星期五, 21 三月 2025 16:18:33 +0800
Subject: [PATCH] Merge branch 'master' of http://120.26.58.240:8888/r/LifePaymentApi
---
LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 78 ++++++++++++++++++++++++++++++--------
1 files changed, 61 insertions(+), 17 deletions(-)
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index e24db15..577dd86 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -26,6 +26,7 @@
using Volo.Abp.Domain.Entities;
using Volo.Abp.ObjectMapping;
using NPOI.SS.Formula.Functions;
+using StackExchange.Redis;
namespace LifePayment.Application;
@@ -122,13 +123,34 @@
AccumulatedUsers = accumulatedUsers,
};
await _dallyStatisticsRepository.InsertAsync(entity);
- //var result = ObjectMapper.Map<DallyStatistics, TopStatisticsOutput>(entity);
- return new TopStatisticsOutput();
+
+ TopStatisticsOutput topStatisticsOutput = new TopStatisticsOutput()
+ {
+ Amount = entity.Amount,
+ AccumulatedReceipts = entity.AccumulatedReceipts,
+ ReceiptsYesterday = entity.ReceiptsYesterday,
+ AccumulatedOrders = entity.AccumulatedOrders,
+ OrdersNumYesterday = entity.OrdersNumYesterday,
+ YesterdaySuccess = entity.YesterdaySuccess,
+ YesterdayFail = entity.YesterdayFail,
+ AccumulatedUsers = entity.AccumulatedUsers,
+ };
+ return topStatisticsOutput;
}
else
{
- var result = ObjectMapper.Map<DallyStatistics, TopStatisticsOutput>(statistics);
- return result;
+ TopStatisticsOutput topStatisticsOutput = new TopStatisticsOutput()
+ {
+ Amount = statistics.Amount,
+ AccumulatedReceipts = statistics.AccumulatedReceipts,
+ ReceiptsYesterday = statistics.ReceiptsYesterday,
+ AccumulatedOrders = statistics.AccumulatedOrders,
+ OrdersNumYesterday = statistics.OrdersNumYesterday,
+ YesterdaySuccess = statistics.YesterdaySuccess,
+ YesterdayFail = statistics.YesterdayFail,
+ AccumulatedUsers = statistics.AccumulatedUsers,
+ };
+ return topStatisticsOutput;
}
}
@@ -381,10 +403,8 @@
public async Task<LifePayOrderOutput> GetLifePayOrderDetail(string orderNo)
{
var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync();
- 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.IsDeleted == false && x.PremiumType == order.LifePayType).FirstOrDefaultAsync();
- CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�");
+ 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;
@@ -415,16 +435,16 @@
LifePayRefundStatus = order.LifePayRefundStatus,
ActualRechargeAmount = order.ActualRechargeAmount,
RefundPrice = order.RefundPrice,
- PlatformRate = platformRate.Rate,
+ PlatformRate = order.PlatformRate,
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),
- PremiumRate = premium == null ? 0 : premium.Rate,
- PremiumPrice = premium == null ? 0 : Math.Round(order.PayAmount * premium.Rate, 2),
- Profit = (order.PayAmount - order.PlatformDeductionAmount) * (1.00m - channle.ChannlesRakeRate / 100) - (premium == null ? 0 : Math.Round(order.PayAmount * premium.Rate, 2))
+ PremiumRate = order.PremiumRate,
+ PremiumPrice = Math.Round(order.PayAmount * order.PremiumRate, 2),
+ Profit = (order.PayAmount - order.PlatformDeductionAmount) * (1.00m - channle.ChannlesRakeRate / 100) - Math.Round(order.PayAmount * order.PremiumRate, 2)
};
return result;
@@ -812,6 +832,9 @@
var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.榛樿璇濊垂鎶樻墸).Rate);
+ var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环);
+
+
var orderInput = new CreateLifePayOrderInput
{
OrderNo = channle.ChannlesNum + CreateOrderNo(),
@@ -825,7 +848,10 @@
PayAmount = amount.PayAmont,
DiscountAmount = amount.DiscountAmount,
RechargeAmount = amount.RechargeAmount,
- ChannelId = channle.ChannlesNum
+ ChannelId = channle.ChannlesNum,
+ PlatformRate = platformRate.Rate,
+ ChannleRate = channle.ChannlesRate,
+ ChannlesRakeRate = channle.ChannlesRakeRate,
};
await CreateLifePayOrder(orderInput);
@@ -856,6 +882,8 @@
var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.榛樿鐢佃垂鎶樻墸).Rate);
+ var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环);
+
var orderInput = new CreateLifePayOrderInput
{
OrderNo = channle.ChannlesNum + CreateOrderNo(),
@@ -869,7 +897,10 @@
PayAmount = amount.PayAmont,
DiscountAmount = amount.DiscountAmount,
RechargeAmount = amount.RechargeAmount,
- ChannelId = channle.ChannlesNum
+ ChannelId = channle.ChannlesNum,
+ PlatformRate = platformRate.Rate,
+ ChannleRate = channle.ChannlesRate,
+ ChannlesRakeRate = channle.ChannlesRakeRate,
};
await CreateLifePayOrder(orderInput);
@@ -899,6 +930,8 @@
CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "鏈厤缃姌鎵�");
var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.榛樿鐕冩皵鎶樻墸).Rate);
+
+ var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环);
var orderInput = new CreateLifePayOrderInput
{
@@ -938,7 +971,8 @@
CheckExtensions.IfTrueThrowUserFriendlyException(order.LifePayType.HasValue, "褰撳墠璁㈠崟宸查�夋嫨鏀粯绫诲瀷");
order.LifePayType = input.LifePayType;
-
+ var premium = await _lifePayPremiumRepository.Where(x => x.IsDeleted == false && x.PremiumType == order.LifePayType).FirstOrDefaultAsync();
+ order.PremiumRate = premium == null ? 0 : premium.Rate;
await _lifePayOrderRepository.UpdateAsync(order);
var desc = "鐢熸椿缂磋垂-";
@@ -1284,6 +1318,16 @@
return;
}
+ if (input.RefundPrice > order.PayAmount)
+ {
+ throw new UserFriendlyException("閫�娆剧殑閲戦涓嶈兘澶т簬瀹炰粯閲戦");
+ }
+
+ if (input.LifePayRefundType == LifePayRefundTypeEnum.鍏ㄩ閫�娆�)
+ {
+ input.RefundPrice = order.PayAmount;
+ }
+
if (order.LifePayOrderStatus != LifePayOrderStatusEnum.宸插け璐� && order.PayStatus != LifePayStatusEnum.寰呴��娆� && order.LifePayOrderStatus != LifePayOrderStatusEnum.閫�娆惧緟瀹℃牳)
{
throw new UserFriendlyException("褰撳墠璁㈠崟鐘舵�佹棤娉曢��娆�");
@@ -1294,7 +1338,7 @@
switch (order.LifePayType)
{
case LifePayTypeEnum.WxPay:
- var wxRefundResult = await WxPayDomesticRefunds(order.OrderNo, outRefundNo,order.RefundApplyRemark, Convert.ToInt32(order.PayAmount * 100), Convert.ToInt32(order.PayAmount * 100));
+ var wxRefundResult = await WxPayDomesticRefunds(order.OrderNo, outRefundNo,order.RefundApplyRemark, Convert.ToInt32(input.RefundPrice * 100), Convert.ToInt32(order.PayAmount * 100));
if (wxRefundResult.Status == "SUCCESS")
{
order.PayStatus = LifePayStatusEnum.宸查��娆�;
@@ -1316,7 +1360,7 @@
break;
case LifePayTypeEnum.AliPay:
- var aliRefundResult = await AliTradeRefund(new AlipayTradeRefundRequest() { OutTradeNo = order.OrderNo, RefundAmount = order.PayAmount.ToString() });
+ var aliRefundResult = await AliTradeRefund(new AlipayTradeRefundRequest() { OutTradeNo = order.OrderNo, RefundAmount = Convert.ToInt32(input.RefundPrice * 100).ToString() });
if (aliRefundResult.Code != AlipayResultCode.Success)
{
throw new UserFriendlyException("閫�娆惧け璐�");
@@ -1332,7 +1376,7 @@
order.RefundCheckRemark = input.RefundCheckRemark;
order.RefundTime = DateTime.Now;
order.RefundCheckUserId = CurrentUser.Id;
- order.RefundPrice = order.PayAmount;
+ order.RefundPrice = input.RefundPrice;
await _lifePayOrderRepository.UpdateAsync(order);
--
Gitblit v1.9.1