From 5c484470be685a55c13f48c271f56330dbf0d93d Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期二, 25 三月 2025 19:24:09 +0800 Subject: [PATCH] fix: s --- LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 72 +++++++++++++++++++++--------------- 1 files changed, 42 insertions(+), 30 deletions(-) diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs index a6519a5..597e1a6 100644 --- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs +++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs @@ -247,6 +247,7 @@ { var channles = await _lifePayChannlesRep.Where(x => x.ChannlesName.Contains(input.KeyWords)).Select(x => x.ChannlesNum).ToListAsync(); var result = await (from a in _channelFilter.GetChannelLifePayOrderFilter(_lifePayOrderRepository) + .Where(x => x.PayStatus != LifePayStatusEnum.鏈敮浠�) .WhereIf(input.BeginFinishTime.HasValue, x => x.FinishTime >= input.BeginFinishTime) .WhereIf(input.EndFinishTime.HasValue, x => x.FinishTime <= input.EndFinishTime) .WhereIf(input.BeginPayTime.HasValue, x => x.PayTime >= input.BeginPayTime) @@ -385,7 +386,7 @@ s.LifePayOrderTypeStr = s.LifePayOrderType.GetDescription(); s.RechargeAmountStr = s.RechargeAmount.ToString("F2"); s.ActualReceivedAmount = s.ActualReceivedAmount; - s.LifePayRefundStatusStr = s.LifePayRefundStatus.GetDescription(); + s.LifePayRefundStatusStr = s.LifePayRefundStatus == LifePayRefundStatusEnum.鏃犻渶閫�娆� ? "" : 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); @@ -733,7 +734,7 @@ LifePayType = x.LifePayType, OrderNo = x.OrderNo, PayAmount = x.PayAmount, - ActualRechargeAmount = x.ActualRechargeAmount.HasValue ? x.ActualRechargeAmount.Value : 0, + ActualRechargeAmount = x.RechargeAmount, PhoneNumber = x.PhoneNumber, RechargeAmount = x.RechargeAmount, OutOrderNo = x.OutOrderNo, @@ -759,7 +760,7 @@ s.LifePayTypeStr = s.LifePayType.GetDescription(); s.PayStatusStr = s.PayStatus.GetDescription(); s.ActualRechargeAmountStr = s.ActualRechargeAmount.ToString("F2"); - s.LifePayRefundStatusStr = s.LifePayRefundStatus.GetDescription(); + s.LifePayRefundStatusStr = s.LifePayRefundStatus == LifePayRefundStatusEnum.鏃犻渶閫�娆� ? "" : 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); @@ -834,12 +835,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环); @@ -859,8 +860,8 @@ RechargeAmount = amount.RechargeAmount, ChannelId = channle.ChannlesNum, PlatformRate = platformRate.Rate, - PlatformDeductionAmount = amount.RechargeAmount * platformRate.Rate / 100, - ChannleRate = channle.ChannlesRate, + PlatformDeductionAmount = amount.RechargeAmount * platformRate.Rate /100, + ChannleRate = rate, ChannlesRakeRate = channle.ChannlesRakeRate, //ChannlesRakePrice = amount.RechargeAmount * (channle.ChannlesRate - platformRate.Rate) / 100 * channle.ChannlesRakeRate / 100 }; @@ -888,10 +889,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环); @@ -910,7 +914,7 @@ RechargeAmount = amount.RechargeAmount, ChannelId = channle.ChannlesNum, PlatformRate = platformRate.Rate, - ChannleRate = channle.ChannlesRate, + ChannleRate = rate, ChannlesRakeRate = channle.ChannlesRakeRate, }; @@ -937,10 +941,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环); @@ -957,7 +964,10 @@ PayAmount = amount.PayAmont, DiscountAmount = amount.DiscountAmount, RechargeAmount = amount.RechargeAmount, - ChannelId = channle.ChannlesNum + ChannelId = channle.ChannlesNum, + PlatformRate = platformRate.Rate, + ChannleRate = rate, + ChannlesRakeRate = channle.ChannlesRakeRate, }; await CreateLifePayOrder(orderInput); @@ -1014,7 +1024,7 @@ } /// <summary> - /// 璁剧疆鐢熸椿缂磋垂鏀粯绫诲瀷 + /// 鑾峰彇寰俊鏀粯鐨凧SAPI /// </summary> /// <param name="input"></param> /// <returns></returns> @@ -1026,6 +1036,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 = "鐢熸椿缂磋垂-"; @@ -1112,7 +1124,7 @@ #endif CheckExtensions.IfTrueThrowUserFriendlyException(!result.Success || (result.Code != ACOOLYConstant.Code.SUCCESS && result.Code != ACOOLYConstant.Code.PROCESSING), - "璋冪敤ACOOLY鎺ュ彛ConfirmElectricOrder杩斿洖閿欒:" + JsonConvert.SerializeObject(result)); + result.Message); return (result.Code, requestInput.RequestNo, result.PhoneChargeOrder.BusiOrderNo); } @@ -1143,7 +1155,7 @@ #endif CheckExtensions.IfTrueThrowUserFriendlyException(!result.Success || (result.Code != ACOOLYConstant.Code.SUCCESS && result.Code != ACOOLYConstant.Code.PROCESSING), - "璋冪敤ACOOLY鎺ュ彛ConfirmElectricOrder杩斿洖閿欒:" + JsonConvert.SerializeObject(result)); + result.Message); return (result.Code, requestInput.RequestNo, result.ElectricChargeOrder.BusiOrderNo); } @@ -1171,7 +1183,7 @@ #endif CheckExtensions.IfTrueThrowUserFriendlyException(!result.Success || (result.Code != ACOOLYConstant.Code.SUCCESS && result.Code != ACOOLYConstant.Code.PROCESSING), - "璋冪敤ACOOLY鎺ュ彛ConfirmElectricOrder杩斿洖閿欒:" + JsonConvert.SerializeObject(result)); + result.Message); return (result.Code, requestInput.RequestNo, result.GasChargeOrder.BusiOrderNo); } @@ -1289,6 +1301,7 @@ _logger.LogError(ex, "澶勭悊鐢熸椿缂磋垂鏀粯鎴愬姛鍥炶皟鏃跺紓甯�"); order.LifePayOrderStatus = LifePayOrderStatusEnum.寰呴��娆�; order.LifePayRefundStatus = LifePayRefundStatusEnum.寰呴��娆�; + order.RefundApplyRemark = ex.Message; } _logger.LogError("鐢熸椿缂磋垂璁㈠崟鐘舵�侊細" + order.LifePayOrderStatus.ToString()); await _lifePayOrderRepository.UpdateAsync(order); @@ -1558,9 +1571,9 @@ if (input.LifePayType == LifePayOrderTypeEnum.璇濊垂璁㈠崟) { var extraProperties = JsonConvert.DeserializeObject<Model_UserAccountExtraProperties>(input.ExtraProperties); - if (!string.IsNullOrEmpty(extraProperties.Name) && extraProperties.Phone == user.PhoneNumber) + if (!string.IsNullOrEmpty(extraProperties.Name)) { - user.Name = extraProperties.Name; + user.Name = extraProperties.Phone == user.PhoneNumber ? extraProperties.Name : string.Empty; } } @@ -1787,10 +1800,10 @@ private (decimal PayAmont, decimal DiscountAmount, decimal RechargeAmount) CalculateAmount(decimal amount, decimal rate) { /// 姝e父鏀粯 - //var payAmount = decimal.Round(amount * rate / 100, 2, MidpointRounding.AwayFromZero); + var payAmount = decimal.Round(amount * rate / 100, 2, MidpointRounding.AwayFromZero); /// 1鍒嗛挶鏀粯 - decimal payAmount = 0.01m; + //decimal payAmount = 0.01m; CheckExtensions.IfTrueThrowUserFriendlyException(payAmount < 0.01m, "鏀粯閲戦閿欒"); @@ -1997,6 +2010,7 @@ { var channles = await _lifePayChannlesRep.Where(x => x.ChannlesName.Contains(input.KeyWords)).Select(x => x.ChannlesNum).ToListAsync(); var result = (from a in _channelFilter.GetChannelLifePayOrderFilter(_lifePayOrderRepository) + .Where(x => x.PayStatus != LifePayStatusEnum.鏈敮浠�) .WhereIf(input.BeginFinishTime.HasValue, x => x.FinishTime >= input.BeginFinishTime) .WhereIf(input.EndFinishTime.HasValue, x => x.FinishTime <= input.EndFinishTime) .WhereIf(input.BeginPayTime.HasValue, x => x.PayTime >= input.BeginPayTime) @@ -2084,6 +2098,7 @@ RefundApplyRemark = a.RefundApplyRemark, RefundApplyTime = a.RefundApplyTime, RefundTime = a.RefundTime, + RefundOrderNo = a.RefundOrderNo, RefundPrice = a.RefundPrice, ChannelName = b.ChannlesName, ActualRechargeAmount = a.ActualRechargeAmount, @@ -2137,9 +2152,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(), "鏈厤缃姌鎵�"); @@ -2148,9 +2163,6 @@ } else { - var channel = await _lifePayChannlesRep.Where(x => x.ChannlesNum == channelId).FirstOrDefaultAsync(); - - CheckExtensions.IfTrueThrowUserFriendlyException(channel == null, "鏈壘鍒板搴旀笭閬�"); return channel.ChannlesRate; } } -- Gitblit v1.9.1