From f44b19122e88c377fe20f504e31da3910659c441 Mon Sep 17 00:00:00 2001
From: zhengyuxuan <zhengyuxuan1995>
Date: 星期四, 03 四月 2025 15:56:18 +0800
Subject: [PATCH] fix:bug修复

---
 LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs |  114 ++++++++++++++++++++++++++-------------------------------
 1 files changed, 52 insertions(+), 62 deletions(-)

diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs
index cef804e..458bbba 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayOrderService.cs
@@ -14,9 +14,6 @@
 using LifePayment.Domain;
 using static LifePayment.Domain.Shared.LifePaymentConstant;
 using Newtonsoft.Json;
-using LifePayment.Domain.Common;
-using Spire.Pdf.Exporting.XPS.Schema;
-using Nest;
 
 namespace LifePayment.Application.LifePay
 {
@@ -61,7 +58,7 @@
         public async Task<PageOutput<LifePayConsumptionListOutput>> GetLifePayConsumptionPage(LifePayConsumptionPageInput input)
         {
             var channles = await _lifePayChannlesRep.Where(x => x.ChannlesName.Contains(input.KeyWord)).Select(x => x.ChannlesNum).ToListAsync();
-            var list = await _lifePayConsumption.Where(x => x.IsDeleted == false)
+            var list = await _lifePayConsumption
                 .WhereIf(input.KeyWord.IsNotNullOrEmpty(), x => x.OrderNo.Contains(input.KeyWord) || x.AcoolyOrderNo.Contains(input.KeyWord) || channles.Contains(x.ChannelId))
                 .WhereIf(input.Flow.HasValue, x => x.Flow == input.Flow)
                 .WhereIf(input.TimeBegin.HasValue, x => x.FinishTime >= input.TimeBegin)
@@ -81,8 +78,8 @@
                 })
                 .GetPageResult(input.PageModel);
 
-            var totalDeductionAmount = await _lifePayConsumption.Where(x => x.IsDeleted == false).SumAsync(x => x.DeductionAmount);
-            var totalFrozenAmount = await _lifePayConsumption.Where(x => x.IsDeleted == false).SumAsync(x => x.FrozenAmount);
+            var totalDeductionAmount = await _lifePayConsumption.SumAsync(x => x.DeductionAmount);
+            var totalFrozenAmount = await _lifePayConsumption.SumAsync(x => x.FrozenAmount);
             LifePayConsumptionStatistics objectData = new LifePayConsumptionStatistics();
             objectData.TotalDeductionAmount = totalDeductionAmount;
             objectData.TotalFrozenAmount = totalFrozenAmount.Value;
@@ -97,7 +94,7 @@
         /// <returns></returns>
         public async Task<PageOutput<LifePayRechargeReceiptsListOutput>> GetLifePayRechargeReceiptsPage(LifePayRechargeReceiptsPageInput input)
         {
-            var list = await _lifePayRechargeReceiptsRepository.Where(x => x.IsDeleted == false)
+            var list = await _lifePayRechargeReceiptsRepository
                 .WhereIf(input.KeyWord.IsNotNullOrEmpty(), x => x.OrderNo.Contains(input.KeyWord))
                 .WhereIf(input.CreationTimeBegin.HasValue, x => x.CreationTime >= input.CreationTimeBegin)
                 .WhereIf(input.CreationTimeEnd.HasValue, x => x.CreationTime <= input.CreationTimeEnd)
@@ -112,7 +109,7 @@
                 })
                 .GetPageResult(input.PageModel);
 
-            var total = await _lifePayRechargeReceiptsRepository.Where(x => x.IsDeleted == false).SumAsync(x => x.RechargeAmount);
+            var total = await _lifePayRechargeReceiptsRepository.SumAsync(x => x.RechargeAmount);
             LifePayRechargeReceiptsStatistics objectData = new LifePayRechargeReceiptsStatistics();
             objectData.TotalRechargeAmount = total;
             list.ObjectData = objectData;
@@ -126,7 +123,7 @@
         /// <returns></returns>
         public async Task<PageOutput<LifePayExpensesReceiptsListOutput>> GetLifePayExpensesReceiptsPage(LifePayExpensesReceiptsPageInput input)
         {
-            var list = await _lifePayExpensesReceiptsRepository.Where(x => x.IsDeleted == false)
+            var list = await _lifePayExpensesReceiptsRepository
                 .WhereIf(input.KeyWord.IsNotNullOrEmpty(), x => x.OrderNo.Contains(input.KeyWord) || x.OutOrderNo.Contains(input.KeyWord))
                 .WhereIf(input.LifePayType.HasValue, x => x.LifePayType == input.LifePayType)
                 .WhereIf(input.ExpensesReceiptsType.HasValue, x => x.ExpensesReceiptsType == input.ExpensesReceiptsType)
@@ -145,8 +142,8 @@
                 })
                 .GetPageResult(input.PageModel);
 
-            var totalIncome = await _lifePayExpensesReceiptsRepository.Where(x => x.IsDeleted == false && x.ExpensesReceiptsType == ExpensesReceiptsTypeEnum.Expenses).SumAsync(x => x.Amount);
-            var totalRefund = await _lifePayExpensesReceiptsRepository.Where(x => x.IsDeleted == false && x.ExpensesReceiptsType == ExpensesReceiptsTypeEnum.Receipts).SumAsync(x => x.Amount);
+            var totalIncome = await _lifePayExpensesReceiptsRepository.Where(x => x.ExpensesReceiptsType == ExpensesReceiptsTypeEnum.Expenses).SumAsync(x => x.Amount);
+            var totalRefund = await _lifePayExpensesReceiptsRepository.Where(x => x.ExpensesReceiptsType == ExpensesReceiptsTypeEnum.Receipts).SumAsync(x => x.Amount);
 
             LifePayExpensesReceiptsStatistics objectData = new LifePayExpensesReceiptsStatistics();
             objectData.TotalIncome = totalIncome;
@@ -163,7 +160,7 @@
         /// <returns></returns>
         public async Task<PageOutput<LifePayChannlesRakeListOutput>> GetLifePayChannlesRakePage(LifePayChannlesRakePageInput input)
         {
-            var list = await _lifePayChannlesRakeRepository.Where(x => x.IsDeleted == false)
+            var list = await _lifePayChannlesRakeRepository
                 .WhereIf(input.ChannelId.IsNotNullOrEmpty(), x => x.ChannelId == input.ChannelId)
                 .WhereIf(input.CreationTimeBegin.HasValue, x => x.CreationTime >= input.CreationTimeBegin)
                 .WhereIf(input.CreationTimeEnd.HasValue, x => x.CreationTime <= input.CreationTimeEnd)
@@ -183,7 +180,7 @@
                 })
                 .GetPageResult(input.PageModel);
 
-            var totalRakePrice = await _lifePayChannlesRakeRepository.Where(x => x.IsDeleted == false)
+            var totalRakePrice = await _lifePayChannlesRakeRepository
                 .WhereIf(input.ChannelId.IsNotNullOrEmpty(), x => x.ChannelId == input.ChannelId)
                 .WhereIf(input.CreationTimeBegin.HasValue, x => x.CreationTime >= input.CreationTimeBegin)
                 .WhereIf(input.CreationTimeEnd.HasValue, x => x.CreationTime <= input.CreationTimeEnd)
@@ -235,11 +232,11 @@
             CheckExtensions.IfTrueThrowUserFriendlyException(input.OrderNo == null, "璇疯緭鍏ヤ笟鍔¤鍗曞彿");
             CheckExtensions.IfTrueThrowUserFriendlyException(input.RechargeAmount <= 0, "鍏呭�奸噾棰濆簲澶т簬0");
             CheckExtensions.IfTrueThrowUserFriendlyException(input.Voucher == null, "璇锋彁浜ゅ厖鍊煎嚟璇�");
-            var repeat = await _lifePayRechargeReceiptsRepository.Where(x => x.IsDeleted == false && x.OrderNo == input.OrderNo).FirstOrDefaultAsync();
+            var repeat = await _lifePayRechargeReceiptsRepository.Where(x => x.OrderNo == input.OrderNo).FirstOrDefaultAsync();
             CheckExtensions.IfTrueThrowUserFriendlyException(repeat != null && repeat.Id != input.Id, "涓氬姟璁㈠崟鍙烽噸澶�");
             if (input.Id.HasValue)
             {
-                var payRechargeReceipts = await _lifePayRechargeReceiptsRepository.Where(x => x.IsDeleted == false && x.Id == input.Id.Value).FirstOrDefaultAsync();
+                var payRechargeReceipts = await _lifePayRechargeReceiptsRepository.Where(x => x.Id == input.Id.Value).FirstOrDefaultAsync();
                 payRechargeReceipts.OrderNo = input.OrderNo;
                 payRechargeReceipts.RechargeAmount = input.RechargeAmount;
                 payRechargeReceipts.Remark = input.Remark;
@@ -338,6 +335,9 @@
             }
         }
 
+
+        
+
         /// <summary>
         /// 缁熻鎵�鏈夋秷璐规祦姘�
         /// </summary>
@@ -415,23 +415,31 @@
                     await AddLifePayExpensesReceipts(input);
 
                     /// 鍑鸿处
+                    AddLifePayExpensesReceiptsInput receipts = new AddLifePayExpensesReceiptsInput()
+                    {
+                        OrderNo = item.OrderNo,
+                        OutOrderNo = item.OutOrderNo,
+                        LifePayType = item.LifePayType,
+                        Amount = item.Amount,
+                        ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Expenses
+                    };
                     if (item.RefundOrderNo.IsNotNullOrEmpty())
                     {
-                        input.OutRefundNo = item.OrderNo;
-                        input.ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Receipts;
-                        await AddLifePayExpensesReceipts(input);
-
-                        input.OutRefundNo = item.RefundOrderNo;
-                        input.ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Receipts;
-                        await AddLifePayExpensesReceipts(input);
+                        receipts.OutRefundNo = item.RefundOrderNo;
+                        receipts.ExpensesReceiptsType = ExpensesReceiptsTypeEnum.Receipts;
+                        await AddLifePayExpensesReceipts(receipts);
                     }
                 }
             }
         }
 
+        /// <summary>
+        /// 鑾峰彇鍏ㄩ儴娓犻亾鍒嗕剑
+        /// </summary>
+        /// <returns></returns>
         public async Task GetAllChannlesRake()
         {
-            var orderlist = await _lifePayOrderRepository.Where(x => x.IsDeleted == false && x.PayStatus == LifePayStatusEnum.宸叉敮浠� && x.LifePayOrderStatus == LifePayOrderStatusEnum.宸插畬鎴�).ToListAsync();
+            var orderlist = await _lifePayOrderRepository.Where(x => x.PayStatus == LifePayStatusEnum.宸叉敮浠� && x.LifePayOrderStatus == LifePayOrderStatusEnum.宸插畬鎴�).ToListAsync();
             foreach (var item in orderlist)
             {
                 /// 姣涘埄
@@ -444,9 +452,9 @@
                     LifePayChannlesRake lifePayChannlesRake = new LifePayChannlesRake()
                     {
                         OrderNo = item.OrderNo,
-                        PayAmount = item.PayAmount.Value,
-                        ChannlesRakeRate = item.ChannlesRakeRate.Value,
-                        ChannlesRakePrice = channlesRakePrice.Value,
+                        PayAmount = item.RechargeAmount ?? 0,
+                        ChannlesRakeRate = item.ChannlesRakeRate ?? 0,
+                        ChannlesRakePrice = channlesRakePrice ?? 0,
                         FinishTime = item.FinishTime.Value,
                         ChannelId = item.ChannelId,
                     };
@@ -481,30 +489,18 @@
                     lifePayConsumption.Flow = ConsumptionFlowEnum.Unchanged;
                     lifePayConsumption.DeductionAmount = 0;
                     lifePayConsumption.FrozenAmount = lifePayConsumption.Amount;
-
-                    repeat = await _lifePayConsumption.Where(x => x.OrderNo == lifePayConsumption.OrderNo
-                    && x.ACOOLYStatus == lifePayConsumption.ACOOLYStatus && x.Flow == lifePayConsumption.Flow).FirstOrDefaultAsync();
-                    if (repeat == null)
-                    {
-                        await _lifePayConsumption.InsertAsync(lifePayConsumption);
-                    }
-
                     break;
                 case ACOOLYStatusEnum.宸插畬鎴�:
-                    lifePayConsumption.FinishTime = orderFinishTime.Value;
+                    if (orderFinishTime.HasValue)
+                    {
+                        lifePayConsumption.FinishTime = orderFinishTime.Value;
+                    }
+
                     lifePayConsumption.ACOOLYStatus = ACOOLYStatusEnum.宸插畬鎴�;
                     lifePayConsumption.FrozenStatus = ConsumptionFrozenStatusEnum.Thaw;
                     lifePayConsumption.Flow = ConsumptionFlowEnum.Out;
                     lifePayConsumption.DeductionAmount = lifePayConsumption.Amount;
                     lifePayConsumption.FrozenAmount = 0;
-
-                    repeat = await _lifePayConsumption.Where(x => x.OrderNo == lifePayConsumption.OrderNo
-                    && x.ACOOLYStatus == lifePayConsumption.ACOOLYStatus && x.Flow == lifePayConsumption.Flow).FirstOrDefaultAsync();
-                    if (repeat == null)
-                    {
-                        await _lifePayConsumption.InsertAsync(lifePayConsumption);
-                    }
-
                     break;
                 case ACOOLYStatusEnum.鍏呭�煎け璐�:
                     lifePayConsumption.FinishTime = orderCreationTime;
@@ -513,32 +509,19 @@
                     lifePayConsumption.Flow = ConsumptionFlowEnum.Unchanged;
                     lifePayConsumption.DeductionAmount = 0;
                     lifePayConsumption.FrozenAmount = lifePayConsumption.Amount;
-
-                    repeat = await _lifePayConsumption.Where(x => x.OrderNo == lifePayConsumption.OrderNo
-                    && x.ACOOLYStatus == lifePayConsumption.ACOOLYStatus && x.Flow == lifePayConsumption.Flow).FirstOrDefaultAsync();
-                    if (repeat == null)
-                    {
-                        await _lifePayConsumption.InsertAsync(lifePayConsumption);
-                    }
-
                     break;
                 case ACOOLYStatusEnum.宸查��娆�:
-                    lifePayConsumption.FinishTime = orderFinishTime.Value;
+                    if (orderFinishTime.HasValue)
+                    {
+                        lifePayConsumption.FinishTime = orderFinishTime.Value;
+                    }
+
                     lifePayConsumption.ACOOLYStatus = ACOOLYStatusEnum.宸查��娆�;
                     lifePayConsumption.FrozenStatus = ConsumptionFrozenStatusEnum.Thaw;
                     lifePayConsumption.Flow = ConsumptionFlowEnum.Unchanged;
                     lifePayConsumption.DeductionAmount = 0;
                     lifePayConsumption.FrozenAmount = 0;
-
-                    repeat = await _lifePayConsumption.Where(x => x.OrderNo == lifePayConsumption.OrderNo
-                    && x.ACOOLYStatus == lifePayConsumption.ACOOLYStatus && x.Flow == lifePayConsumption.Flow).FirstOrDefaultAsync();
-                    if (repeat == null)
-                    {
-                        await _lifePayConsumption.InsertAsync(lifePayConsumption);
-                    }
-
                     break;
-
                 //case ACOOLYStatusEnum.閮ㄥ垎鍏呭�兼垚鍔�:
                 //    lifePayConsumption.FinishTime = orderCreationTime;
                 //    lifePayConsumption.ACOOLYStatus = ACOOLYStatusEnum.閮ㄥ垎鍏呭�兼垚鍔�;
@@ -557,11 +540,18 @@
                 //    break;
                 default: break;
             }
+
+            repeat = await _lifePayConsumption.Where(x => x.OrderNo == lifePayConsumption.OrderNo
+                   && x.ACOOLYStatus == lifePayConsumption.ACOOLYStatus && x.Flow == lifePayConsumption.Flow).FirstOrDefaultAsync();
+            if (repeat == null)
+            {
+                await _lifePayConsumption.InsertAsync(lifePayConsumption);
+            }
         }
 
         private async Task<IQueryable<LifePayChannlesRakeListOutput>> GetLifePayChannlesRakeListFilter(LifePayChannlesRakePageInput input)
         {
-            var list = _lifePayChannlesRakeRepository.Where(x => x.IsDeleted == false)
+            var list = _lifePayChannlesRakeRepository
                 .WhereIf(input.ChannelId.IsNotNullOrEmpty(), x => x.ChannelId == input.ChannelId)
                 .WhereIf(input.CreationTimeBegin.HasValue, x => x.CreationTime >= input.CreationTimeBegin)
                 .WhereIf(input.CreationTimeEnd.HasValue, x => x.CreationTime <= input.CreationTimeEnd)

--
Gitblit v1.9.1