From 6bdd9d63172414d05dc47c554589430643936cb9 Mon Sep 17 00:00:00 2001 From: zhengyuxuan <zhengyuxuan1995> Date: 星期二, 25 三月 2025 14:55:36 +0800 Subject: [PATCH] fix:计算渠道折扣 --- LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 51 ++++++++++++++++++++++++++++----------------------- 1 files changed, 28 insertions(+), 23 deletions(-) diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs index 6872d9d..e3e14b3 100644 --- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs +++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs @@ -283,7 +283,7 @@ RefundApplyRemark = a.RefundApplyRemark, RefundTime = a.RefundTime, ChannelName = b.ChannlesName, - ActualRechargeAmount = a.ActualRechargeAmount, + ActualRechargeAmount = a.RechargeAmount, PlatformDeductionAmount = a.PlatformDeductionAmount, ACOOLYStatus = a.ACOOLYStatus, LifePayRefundStatus = a.LifePayRefundStatus, @@ -302,7 +302,7 @@ var result = await (from a in _channelFilter.GetChannelLifePayOrderFilter(_lifePayOrderRepository) .Where(x => x.LifePayOrderStatus == LifePayOrderStatusEnum.寰呴��娆� || x.LifePayOrderStatus == LifePayOrderStatusEnum.宸查��娆� || x.LifePayOrderStatus == LifePayOrderStatusEnum.閫�娆句腑 - || x.LifePayRefundStatus > LifePayRefundStatusEnum.鏃犻渶閫�娆�) + || (x.LifePayRefundStatus > LifePayRefundStatusEnum.鏃犻渶閫�娆� && x.LifePayRefundStatus != LifePayRefundStatusEnum.閫�娆鹃┏鍥�)) .WhereIf(input.BeginRefundTime.HasValue, x => x.RefundTime >= input.BeginRefundTime) .WhereIf(input.EndRefundTime.HasValue, x => x.RefundTime <= input.EndRefundTime) .WhereIf(input.BeginRefundApplyTime.HasValue, x => x.RefundApplyTime >= input.BeginRefundApplyTime) @@ -337,10 +337,11 @@ RefundCheckRemark = a.RefundCheckRemark, RefundApplyRemark = a.RefundApplyRemark, RefundApplyTime = a.RefundApplyTime, + RefundOrderNo = a.RefundOrderNo, RefundTime = a.RefundTime, RefundPrice = a.RefundPrice, ChannelName = b.ChannlesName, - ActualRechargeAmount = a.ActualRechargeAmount, + ActualRechargeAmount = a.RechargeAmount, PlatformDeductionAmount = a.PlatformDeductionAmount, ACOOLYStatus = a.ACOOLYStatus, LifePayRefundStatus = a.LifePayRefundStatus, @@ -365,6 +366,7 @@ PayAmount = x.PayAmount, PhoneNumber = x.PhoneNumber, RefundOrderNo = x.RefundOrderNo, + RefundApplyTime = x.RefundApplyTime, ChannelName = x.ChannelName, CreationTime = x.CreationTime, ACOOLYStatus = x.ACOOLYStatus, @@ -380,13 +382,13 @@ s.SerialNumber = ++i; s.ACOOLYStatusStr = s.ACOOLYStatus.GetDescription(); s.LifePayOrderTypeStr = s.LifePayOrderType.GetDescription(); - s.CreationTimeStr = s.CreationTime.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm); s.RechargeAmountStr = s.RechargeAmount.ToString("F2"); s.ActualReceivedAmount = s.ActualReceivedAmount; s.LifePayRefundStatusStr = s.LifePayRefundStatus.GetDescription(); s.PayAmountStr = s.PayAmount.ToString("F2"); s.LifePayTypeStr = s.LifePayType.GetDescription(); s.FinishTimeStr = !s.FinishTime.HasValue ? string.Empty : s.FinishTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm); + s.RefundApplyTimeStr = !s.RefundApplyTime.HasValue? string.Empty:s.RefundApplyTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm); }); return result; } @@ -427,7 +429,7 @@ RefundTime = order.RefundTime, ACOOLYOrderNo = order.ACOOLYOrderNo, LifePayRefundStatus = order.LifePayRefundStatus, - ActualRechargeAmount = order.ActualRechargeAmount, + ActualRechargeAmount = order.RechargeAmount, RefundPrice = order.RefundPrice, PlatformRate = order.PlatformRate, PlatformPrice = order.PlatformDeductionAmount, @@ -756,7 +758,7 @@ s.LifePayTypeStr = s.LifePayType.GetDescription(); s.PayStatusStr = s.PayStatus.GetDescription(); s.ActualRechargeAmountStr = s.ActualRechargeAmount.ToString("F2"); - s.LifePayRefundStatusStr = s.LifePayRefundStatusStr.GetDescription(); + s.LifePayRefundStatusStr = s.LifePayRefundStatus.GetDescription(); s.ACOOLYStatusStr = s.ACOOLYStatus.GetDescription(); //s.LifePayOrderStatusStr = s.LifePayOrderStatus.GetDescription(); s.FinishTimeStr = !s.FinishTime.HasValue ? string.Empty : s.FinishTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmmss); @@ -831,12 +833,12 @@ var channle = await GetLifePayChannlesDtoByNum(input.ChannelId); CheckExtensions.IfTrueThrowUserFriendlyException(channle == null, "娓犻亾涓嶅瓨鍦�"); - var rate = await GetRate(); - CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "鏈厤缃姌鎵�"); + //var rate = await GetRate(); + //CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "鏈厤缃姌鎵�"); - //var rate = await GetLifePayRate(); + var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.榛樿璇濊垂鎶樻墸); - var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.榛樿璇濊垂鎶樻墸).Rate); + var amount = CalculateAmount(input.ProductData.ParValue, rate); var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环); @@ -885,10 +887,13 @@ CheckExtensions.IfTrueThrowUserFriendlyException(channle == null, "娓犻亾涓嶅瓨鍦�"); CheckExtensions.IfTrueThrowUserFriendlyException(channle.Status == LifePayChannelsStatsEnum.绂佺敤, "娓犻亾宸茶绂佺敤"); - var rate = await GetRate(); - CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "鏈厤缃姌鎵�"); + //var rate = await GetRate(); + //CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "鏈厤缃姌鎵�"); - var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.榛樿鐢佃垂鎶樻墸).Rate); + + var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.榛樿鐢佃垂鎶樻墸); + + var amount = CalculateAmount(input.ProductData.ParValue, rate); var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环); @@ -934,10 +939,13 @@ CheckExtensions.IfTrueThrowUserFriendlyException(channle == null, "娓犻亾涓嶅瓨鍦�"); CheckExtensions.IfTrueThrowUserFriendlyException(channle.Status == LifePayChannelsStatsEnum.绂佺敤, "娓犻亾宸茶绂佺敤"); - var rate = await GetRate(); - CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "鏈厤缃姌鎵�"); + //var rate = await GetRate(); + //CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "鏈厤缃姌鎵�"); - var amount = CalculateAmount(input.ProductData.ParValue, rate.FirstOrDefault(x => x.RateType == LifePayRateTypeEnum.榛樿鐕冩皵鎶樻墸).Rate); + + var rate = await GetLifePayRate(channle, LifePayRateTypeEnum.榛樿鐕冩皵鎶樻墸); + + var amount = CalculateAmount(input.ProductData.ParValue, rate); var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环); @@ -1388,10 +1396,10 @@ break; case LifePayTypeEnum.AliPay: - var aliRefundResult = await AliTradeRefund(new AlipayTradeRefundRequest() { OutTradeNo = order.OrderNo, RefundAmount = Convert.ToInt32(input.RefundPrice * 100).ToString() }); + var aliRefundResult = await AliTradeRefund(new AlipayTradeRefundRequest() { OutTradeNo = order.OrderNo, RefundAmount = input.RefundPrice.ToString() }); if (aliRefundResult.Code != AlipayResultCode.Success) { - throw new UserFriendlyException("閫�娆惧け璐�"); + throw new UserFriendlyException("閫�娆惧け璐�:" + aliRefundResult.SubMsg); } order.LifePayOrderStatus = LifePayOrderStatusEnum.宸查��娆�; @@ -2115,9 +2123,9 @@ }; } - public async Task<decimal> GetLifePayRate(string channelId, LifePayRateTypeEnum lifePayRateType) + public async Task<decimal> GetLifePayRate(CreateEditPayChannelsInput channel, LifePayRateTypeEnum lifePayRateType) { - if (string.IsNullOrEmpty(channelId)) + if (channel == null) { var rate = await GetRate(); CheckExtensions.IfTrueThrowUserFriendlyException(rate.IsNullOrEmpty(), "鏈厤缃姌鎵�"); @@ -2126,9 +2134,6 @@ } else { - var channel = await _lifePayChannlesRep.Where(x => x.ChannlesNum == channelId).FirstOrDefaultAsync(); - - CheckExtensions.IfTrueThrowUserFriendlyException(channel == null, "鏈壘鍒板搴旀笭閬�"); return channel.ChannlesRate; } } -- Gitblit v1.9.1