From 78bf5ae3845bd2d7008eae76a1d4facb2d29280b Mon Sep 17 00:00:00 2001 From: zhengyuxuan <zhengyuxuan1995> Date: 星期五, 21 三月 2025 15:11:42 +0800 Subject: [PATCH] fix:部分退款接口更新 --- LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 61 +++++++++++++++++++++++------- 1 files changed, 46 insertions(+), 15 deletions(-) diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs index ff3ef8a..e4e9294 100644 --- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs +++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs @@ -102,6 +102,7 @@ var accumulatedReceipts = await _lifePayOrderRepository.Where(x => x.CreationTime < today).SumAsync(x => x.PayAmount); var receiptsYesterday = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today).SumAsync(x => x.PayAmount); var accumulatedOrders = await _lifePayOrderRepository.Where(x => x.CreationTime < today).CountAsync(); + var accumulatedIncome = await _lifePayOrderRepository.Where(x => x.CreationTime < today).SumAsync(x => x.ActualRechargeAmount); var ordersNumYesterday = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today).CountAsync(); var yesterdaySuccess = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today && x.LifePayOrderStatus == LifePayOrderStatusEnum.宸插畬鎴�).CountAsync(); var yesterdayFail = await _lifePayOrderRepository.Where(x => x.CreationTime >= today.AddDays(-1) && x.CreationTime < today && x.LifePayOrderStatus == LifePayOrderStatusEnum.宸插け璐�).CountAsync(); @@ -111,23 +112,44 @@ { Id = GuidGenerator.Create(), CreationTime = DateTime.Now, - Amount = "0", - AccumulatedReceipts = accumulatedReceipts.ToString(), - ReceiptsYesterday = receiptsYesterday.ToString(), - AccumulatedOrders = accumulatedOrders.ToString(), - OrdersNumYesterday = ordersNumYesterday.ToString(), - YesterdaySuccess = yesterdaySuccess.ToString(), - YesterdayFail = yesterdayFail.ToString(), - AccumulatedUsers = accumulatedUsers.ToString(), + Amount = 0, + AccumulatedReceipts = accumulatedReceipts, + ReceiptsYesterday = receiptsYesterday, + AccumulatedOrders = accumulatedOrders, + OrdersNumYesterday = ordersNumYesterday, + YesterdaySuccess = yesterdaySuccess, + YesterdayFail = yesterdayFail, + AccumulatedUsers = accumulatedUsers, }; await _dallyStatisticsRepository.InsertAsync(entity); - var result = ObjectMapper.Map<DallyStatistics, TopStatisticsOutput>(entity); - return result; + + 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; } } @@ -466,6 +488,7 @@ ACOOLYOrderNo = order.ACOOLYOrderNo, LifePayRefundStatus = order.LifePayRefundStatus, ActualRechargeAmount = order.ActualRechargeAmount, + ActualReceivedAmount = order.ActualReceivedAmount, RefundPrice = order.RefundPrice, ElecBillUrl = order.ElecBillUrl.GetOssPath(), RefundElecBillUrl = order.RefundElecBillUrl.GetOssPath(), @@ -1281,6 +1304,14 @@ { return; } + if (input.RefundPrice > order.PayAmount) + { + throw new UserFriendlyException("閫�娆剧殑閲戦涓嶈兘澶т簬瀹炰粯閲戦"); + } + if (input.LifePayRefundType == LifePayRefundTypeEnum.鍏ㄩ閫�娆� && input.RefundPrice != order.PayAmount) + { + throw new UserFriendlyException("鍏ㄩ閫�娆剧殑閲戦涓庡疄浠橀噾棰濅笉涓�鑷�"); + } if (order.LifePayOrderStatus != LifePayOrderStatusEnum.宸插け璐� && order.PayStatus != LifePayStatusEnum.寰呴��娆� && order.LifePayOrderStatus != LifePayOrderStatusEnum.閫�娆惧緟瀹℃牳) { @@ -1292,7 +1323,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.宸查��娆�; @@ -1314,7 +1345,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("閫�娆惧け璐�"); @@ -1330,7 +1361,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