From fa7b6158e23dafad4824b8832599143c7ba8dc49 Mon Sep 17 00:00:00 2001 From: zhengyuxuan <zhengyuxuan1995> Date: 星期四, 27 三月 2025 00:45:01 +0800 Subject: [PATCH] Merge branch 'master' into dev-lifepay-v1.3 --- LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 219 ++++++++++++++++++++++++++++++------------------------ 1 files changed, 120 insertions(+), 99 deletions(-) diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs index d9596c9..405d11c 100644 --- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs +++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs @@ -27,6 +27,7 @@ using Volo.Abp.ObjectMapping; using NPOI.SS.Formula.Functions; using StackExchange.Redis; +using static Volo.Abp.Identity.Settings.IdentitySettingNames; namespace LifePayment.Application; @@ -157,7 +158,7 @@ /// <returns></returns> public async Task<ChannelRateOutput> GetChannelRate(ChannelsBaseInput input) { - return _lifePayChannlesRep.Where(x => x.IsDeleted == false && x.ChannlesNum == input.CheckChannelId).Select(x => new ChannelRateOutput() { ChannlesRate = x.ChannlesRate }) + return _lifePayChannlesRep.Where(x => x.IsDeleted == false && x.ChannlesNum == input.CheckChannelId).Select(x => new ChannelRateOutput() { ChannlesRate = x.ChannlesRate }) .FirstOrDefault(); } @@ -389,7 +390,7 @@ 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); + s.RefundApplyTimeStr = !s.RefundApplyTime.HasValue ? string.Empty : s.RefundApplyTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmm); }); return result; } @@ -399,14 +400,14 @@ { var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync(); var channle = await _lifePayChannlesRep.FirstOrDefaultAsync(r => r.ChannlesNum == order.ChannelId); - 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; - var orderpirce = await GetOrderPrice(order.RechargeAmount, order.PayAmount,order.PlatformRate, order.ChannleRate, order.ChannlesRakeRate,order.PremiumRate); + CheckExtensions.IfTrueThrowUserFriendlyException(user == null, "鐢ㄦ埛涓嶅瓨鍦�"); + var orderpirce = await GetOrderPrice(order.RechargeAmount, order.PayAmount, order.PlatformRate ?? 0, order.ChannleRate ?? 0, order.ChannlesRakeRate ?? 0, order.PremiumRate ?? 0); var result = new LifePayOrderOutput() - { + { UserName = user.Name, UserPhoneNumber = user.PhoneNumber, DiscountAmount = order.DiscountAmount, @@ -441,7 +442,8 @@ ChannlesRakePrice = orderpirce.ChannlesRakePrice, PremiumRate = order.PremiumRate, PremiumPrice = orderpirce.PremiumPrice, - Profit = orderpirce.Profit + Profit = orderpirce.Profit, + RefundOrderNo = order.RefundOrderNo, }; return result; @@ -728,7 +730,7 @@ { DiscountAmount = x.DiscountAmount, FinishTime = x.FinishTime, - //LifePayOrderStatus = x.LifePayOrderStatus, + LifePayOrderStatus = x.LifePayOrderStatus, LifePayOrderType = x.LifePayOrderType, LifePayType = x.LifePayType, OrderNo = x.OrderNo, @@ -761,7 +763,7 @@ s.ActualRechargeAmountStr = s.ActualRechargeAmount.ToString("F2"); s.LifePayRefundStatusStr = s.LifePayRefundStatus == LifePayRefundStatusEnum.鏃犻渶閫�娆� ? "" : s.LifePayRefundStatus.GetDescription(); s.ACOOLYStatusStr = s.ACOOLYStatus.GetDescription(); - //s.LifePayOrderStatusStr = s.LifePayOrderStatus.GetDescription(); + s.LifePayOrderStatusStr = s.LifePayOrderStatus.GetDescription(); s.FinishTimeStr = !s.FinishTime.HasValue ? string.Empty : s.FinishTime.Value.ToString(LifePaymentConstant.DateTimeFormatStr.yyyyMMddHHmmss); }); return result; @@ -842,7 +844,7 @@ var amount = CalculateAmount(input.ProductData.ParValue, rate); var platformRate = await _lifePayRateRepository.FirstOrDefaultAsync(r => r.RateType == LifePayRateTypeEnum.渚涘簲鍟嗘姌鎵d环); - + var orderInput = new CreateLifePayOrderInput { @@ -859,7 +861,7 @@ RechargeAmount = amount.RechargeAmount, ChannelId = channle.ChannlesNum, PlatformRate = platformRate.Rate, - PlatformDeductionAmount = amount.RechargeAmount * platformRate.Rate /100, + PlatformDeductionAmount = amount.RechargeAmount * platformRate.Rate / 100, ChannleRate = rate, ChannlesRakeRate = channle.ChannlesRakeRate, //ChannlesRakePrice = amount.RechargeAmount * (channle.ChannlesRate - platformRate.Rate) / 100 * channle.ChannlesRakeRate / 100 @@ -1069,6 +1071,25 @@ } /// <summary> + /// 淇敼瀹為檯鍒拌处閲戦 + /// </summary> + /// <param name="input"></param> + /// <returns></returns> + public async Task<int> UpdateLifePayOrderActualReceivedAmount(UpdateLifePayOrderInput input) + { + var order = await _lifePayOrderRepository.Where(x => x.Id == input.Id).FirstOrDefaultAsync(); + + CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�"); + CheckExtensions.IfTrueThrowUserFriendlyException(order.ACOOLYStatus != ACOOLYStatusEnum.閮ㄥ垎鍏呭�兼垚鍔�, "璇ヨ鍗曟棤娉曚慨鏀瑰埌璐﹂噾棰�"); + + order.ActualReceivedAmount = input.ActualReceivedAmount; + + await _lifePayOrderRepository.UpdateAsync(order); + + return Constant.SUCCESS; + } + + /// <summary> /// 鍒涘缓鐢熸椿缂磋垂璁㈠崟 /// </summary> /// <param name="input"></param> @@ -1104,7 +1125,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); } @@ -1135,7 +1156,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); } @@ -1163,7 +1184,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); } @@ -1281,6 +1302,7 @@ _logger.LogError(ex, "澶勭悊鐢熸椿缂磋垂鏀粯鎴愬姛鍥炶皟鏃跺紓甯�"); order.LifePayOrderStatus = LifePayOrderStatusEnum.寰呴��娆�; order.LifePayRefundStatus = LifePayRefundStatusEnum.寰呴��娆�; + order.RefundApplyRemark = ex.Message; } _logger.LogError("鐢熸椿缂磋垂璁㈠崟鐘舵�侊細" + order.LifePayOrderStatus.ToString()); await _lifePayOrderRepository.UpdateAsync(order); @@ -1300,7 +1322,7 @@ case LifePayRefundStatusEnum.閫�娆句腑: order.LifePayOrderStatus = LifePayOrderStatusEnum.閫�娆句腑; break; - default:break; + default: break; } } @@ -1310,7 +1332,7 @@ /// <param name="orderNo"></param> /// <param name="outOrderNo"></param> /// <returns></returns> - public async Task ACOOLYOrderNotifyHandler(string orderNo, string acoolyOrderNo, LifePayOrderStatusEnum status, ACOOLYStatusEnum acoolyStatus, decimal payAmount,string refundApplyRemark) + public async Task ACOOLYOrderNotifyHandler(string orderNo, string acoolyOrderNo, LifePayOrderStatusEnum status, ACOOLYStatusEnum acoolyStatus, decimal payAmount, string refundApplyRemark) { var order = await _lifePayOrderRepository.Where(x => x.OrderNo == orderNo).FirstOrDefaultAsync(); CheckExtensions.IfTrueThrowUserFriendlyException(order == null, "璁㈠崟涓嶅瓨鍦�"); @@ -1378,7 +1400,7 @@ switch (order.LifePayType) { case LifePayTypeEnum.WxPay: - var wxRefundResult = await WxPayDomesticRefunds(order.OrderNo, outRefundNo,order.RefundApplyRemark, Convert.ToInt32(input.RefundPrice * 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.LifePayOrderStatus = LifePayOrderStatusEnum.宸查��娆�; @@ -1480,7 +1502,7 @@ /// <param name="total"></param> /// <param name="currency"></param> /// <returns></returns> - public async Task<WxPayDomesticRefundsReponse> WxPayDomesticRefunds(string outTradeNo,string outRefundNo, string reason, int refund, int total, string currency = "CNY") + public async Task<WxPayDomesticRefundsReponse> WxPayDomesticRefunds(string outTradeNo, string outRefundNo, string reason, int refund, int total, string currency = "CNY") { WxPayDomesticRefundsRequest req = new WxPayDomesticRefundsRequest { @@ -1634,7 +1656,7 @@ dto.Status = input.Status; #region 璁板綍鏃ュ織 - await PublishLifePayOrderHistoryEvent("娓犻亾绠$悊", "缂栬緫", input.Id.Value, TableType.LifePayChannles); + await LifePayOrderHistory("娓犻亾绠$悊", "缂栬緫", input.Id.Value, TableType.LifePayChannles); #endregion } @@ -1647,7 +1669,7 @@ #region 璁板綍鏃ュ織 - await PublishLifePayOrderHistoryEvent("娓犻亾绠$悊", "鏂板", input.Id.Value, TableType.LifePayChannles); + await LifePayOrderHistory("娓犻亾绠$悊", "鏂板", input.Id.Value, TableType.LifePayChannles); #endregion } @@ -1664,8 +1686,7 @@ #region 璁板綍鏃ュ織 - await PublishLifePayOrderHistoryEvent("娓犻亾绠$悊", status.GetDescription(), id, TableType.LifePayChannles); - + await LifePayOrderHistory("娓犻亾绠$悊", status.GetDescription(), id, TableType.LifePayChannles); #endregion } @@ -1779,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, "鏀粯閲戦閿欒"); @@ -2001,39 +2022,39 @@ .WhereIf(input.LifePayOrderType.HasValue, x => x.LifePayOrderType == input.LifePayOrderType.Value) .WhereIf(input.UserId.HasValue, x => x.UserId == input.UserId.Value) .WhereIf(input.KeyWords.IsNotNullOrEmpty(), x => x.OrderNo.Contains(input.KeyWords) || x.OutOrderNo.Contains(input.KeyWords) || x.ACOOLYOrderNo.Contains(input.KeyWords) || channles.Contains(x.ChannelId)) - join b in _lifePayChannlesRep on a.ChannelId equals b.ChannlesNum into temp - from b in temp.DefaultIfEmpty() - select new LifePayOrderListOutput - { - DiscountAmount = a.DiscountAmount, - FinishTime = a.FinishTime, - Id = a.Id, - LifePayOrderStatus = a.LifePayOrderStatus, - LifePayOrderType = a.LifePayOrderType, - LifePayType = a.LifePayType, - OrderNo = a.OrderNo, - PayAmount = a.PayAmount, - PhoneNumber = a.PhoneNumber, - RechargeAmount = a.RechargeAmount, - UserId = a.UserId, - OutOrderNo = a.OutOrderNo, - PayStatus = a.PayStatus, - PayTime = a.PayTime, - ACOOLYOrderNo = a.ACOOLYOrderNo, - RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(), - RefundPrice = a.RefundPrice, - CreationTime = a.CreationTime, - RefundCheckRemark = a.RefundCheckRemark, - RefundApplyRemark = a.RefundApplyRemark, - RefundTime = a.RefundTime, - ChannelName = b.ChannlesName, - ActualRechargeAmount = a.ActualRechargeAmount, - PlatformDeductionAmount = a.PlatformDeductionAmount, - ACOOLYStatus = a.ACOOLYStatus, - LifePayRefundStatus = a.LifePayRefundStatus, - }); + join b in _lifePayChannlesRep on a.ChannelId equals b.ChannlesNum into temp + from b in temp.DefaultIfEmpty() + select new LifePayOrderListOutput + { + DiscountAmount = a.DiscountAmount, + FinishTime = a.FinishTime, + Id = a.Id, + LifePayOrderStatus = a.LifePayOrderStatus, + LifePayOrderType = a.LifePayOrderType, + LifePayType = a.LifePayType, + OrderNo = a.OrderNo, + PayAmount = a.PayAmount, + PhoneNumber = a.PhoneNumber, + RechargeAmount = a.RechargeAmount, + UserId = a.UserId, + OutOrderNo = a.OutOrderNo, + PayStatus = a.PayStatus, + PayTime = a.PayTime, + ACOOLYOrderNo = a.ACOOLYOrderNo, + RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(), + RefundPrice = a.RefundPrice, + CreationTime = a.CreationTime, + RefundCheckRemark = a.RefundCheckRemark, + RefundApplyRemark = a.RefundApplyRemark, + RefundTime = a.RefundTime, + ChannelName = b.ChannlesName, + ActualRechargeAmount = a.ActualRechargeAmount, + PlatformDeductionAmount = a.PlatformDeductionAmount, + ACOOLYStatus = a.ACOOLYStatus, + LifePayRefundStatus = a.LifePayRefundStatus, + }); - + return result; } @@ -2052,40 +2073,40 @@ .WhereIf(input.LifePayOrderType.HasValue, x => x.LifePayOrderType == input.LifePayOrderType.Value) .WhereIf(input.UserId.HasValue, x => x.UserId == input.UserId.Value) .WhereIf(input.KeyWords.IsNotNullOrEmpty(), x => x.PhoneNumber.Contains(input.KeyWords) || x.OrderNo.Contains(input.KeyWords) || x.OutOrderNo.Contains(input.KeyWords) || x.ACOOLYOrderNo.Contains(input.KeyWords)) - join b in _lifePayChannlesRep on a.ChannelId equals b.ChannlesNum into temp - from b in temp.DefaultIfEmpty() - select new LifePayOrderListOutput - { - DiscountAmount = a.DiscountAmount, - FinishTime = a.FinishTime, - Id = a.Id, - LifePayOrderStatus = a.LifePayOrderStatus, - LifePayOrderType = a.LifePayOrderType, - LifePayType = a.LifePayType, - OrderNo = a.OrderNo, - PayAmount = a.PayAmount, - PhoneNumber = a.PhoneNumber, - RechargeAmount = a.RechargeAmount, - UserId = a.UserId, - OutOrderNo = a.OutOrderNo, - PayStatus = a.PayStatus, - PayTime = a.PayTime, - ACOOLYOrderNo = a.ACOOLYOrderNo, - RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(), - CreationTime = a.CreationTime, - RefundCheckRemark = a.RefundCheckRemark, - RefundApplyRemark = a.RefundApplyRemark, - RefundApplyTime = a.RefundApplyTime, - RefundTime = a.RefundTime, - RefundOrderNo = a.RefundOrderNo, - RefundPrice = a.RefundPrice, - ChannelName = b.ChannlesName, - ActualRechargeAmount = a.ActualRechargeAmount, - PlatformDeductionAmount = a.PlatformDeductionAmount, - ACOOLYStatus = a.ACOOLYStatus, - LifePayRefundStatus = a.LifePayRefundStatus, - ActualReceivedAmount = a.ActualReceivedAmount.HasValue? a.ActualReceivedAmount.Value : 0 - }); + join b in _lifePayChannlesRep on a.ChannelId equals b.ChannlesNum into temp + from b in temp.DefaultIfEmpty() + select new LifePayOrderListOutput + { + DiscountAmount = a.DiscountAmount, + FinishTime = a.FinishTime, + Id = a.Id, + LifePayOrderStatus = a.LifePayOrderStatus, + LifePayOrderType = a.LifePayOrderType, + LifePayType = a.LifePayType, + OrderNo = a.OrderNo, + PayAmount = a.PayAmount, + PhoneNumber = a.PhoneNumber, + RechargeAmount = a.RechargeAmount, + UserId = a.UserId, + OutOrderNo = a.OutOrderNo, + PayStatus = a.PayStatus, + PayTime = a.PayTime, + ACOOLYOrderNo = a.ACOOLYOrderNo, + RefundCredentialsImgUrl = a.RefundCredentialsImgUrl.GetOssPath(), + CreationTime = a.CreationTime, + RefundCheckRemark = a.RefundCheckRemark, + RefundApplyRemark = a.RefundApplyRemark, + RefundApplyTime = a.RefundApplyTime, + RefundTime = a.RefundTime, + RefundOrderNo = a.RefundOrderNo, + RefundPrice = a.RefundPrice, + ChannelName = b.ChannlesName, + ActualRechargeAmount = a.ActualRechargeAmount, + PlatformDeductionAmount = a.PlatformDeductionAmount, + ACOOLYStatus = a.ACOOLYStatus, + LifePayRefundStatus = a.LifePayRefundStatus, + ActualReceivedAmount = a.ActualReceivedAmount.HasValue ? a.ActualReceivedAmount.Value : 0 + }); return result; } private IQueryable<CreateEditPayChannelsInput> GetLifePayChannlesListFilter() @@ -2104,8 +2125,8 @@ }); } - public async Task<OrderPriceReturn> GetOrderPrice(decimal price, decimal priceAmount, decimal? platformRate,decimal? channleRate, - decimal? channlesRakeRate,decimal? premiumRate) + public async Task<OrderPriceReturn> GetOrderPrice(decimal price, decimal priceAmount, decimal platformRate, decimal channleRate, + decimal channlesRakeRate, decimal premiumRate) { /// 姣涘埄 var grossProfit = price * (channleRate - platformRate) / 100; @@ -2114,20 +2135,20 @@ var platformPrice = price * platformRate / 100; /// 鎵嬬画璐� - var premiumPrice = priceAmount * premiumRate / 100; + var premiumPrice = priceAmount * (premiumRate) / 100; /// 娓犻亾浣i噾 锛�(鍏呭�奸潰棰� * 娓犻亾鎶樻墸姣斾緥)-(鍏呭�奸潰棰� * 骞冲彴鎶樻墸姣斾緥)锛�* 浣i噾姣斾緥 - var channlesRakePrice = grossProfit * channlesRakeRate / 100; + var channlesRakePrice = grossProfit * (channlesRakeRate) / 100; /// 鍒╂鼎 - var profit = grossProfit - channlesRakePrice - premiumPrice; + var profit = grossProfit - channlesRakePrice - (premiumRate); 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 + PlatformPrice = platformPrice, + PremiumPrice = premiumPrice, + ChannlesRakePrice = channlesRakePrice, + Profit = profit }; } -- Gitblit v1.9.1