From 6836fa235faae79bfd82c4d63915ec60aaa24d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A9=AC=E6=A2=93=E5=BD=AD?= Date: Tue, 28 Apr 2026 01:38:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E5=90=8D=E4=BA=BA=E6=95=B0=E5=8E=BB?= =?UTF-8?q?=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Event/UnifiedRegistrationService.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/YD_Event.Application/Event/UnifiedRegistrationService.cs b/YD_Event.Application/Event/UnifiedRegistrationService.cs index cc2b73e..f0d32c6 100644 --- a/YD_Event.Application/Event/UnifiedRegistrationService.cs +++ b/YD_Event.Application/Event/UnifiedRegistrationService.cs @@ -749,7 +749,7 @@ public class UnifiedRegistrationService : ITransient var regItems = new List(); var persons = new List(); - int totalPersonCount = 0; + var uniqueUserIds = new HashSet(); // 用于去重的用户ID集合 foreach (var item in input.Items) { @@ -782,8 +782,6 @@ public class UnifiedRegistrationService : ITransient }; regItems.Add(regItem); - totalPersonCount += team.Persons.Count; - foreach (var pInput in team.Persons) { persons.Add(new EventRegistrationPerson @@ -806,6 +804,12 @@ public class UnifiedRegistrationService : ITransient CreatedUserId = input.CreatedUserId, CreatedTime = DateTime.Now }); + + // 将用户ID添加到去重集合中 + if (pInput.UserId.HasValue) + { + uniqueUserIds.Add(pInput.UserId.Value); + } } } } @@ -813,9 +817,10 @@ public class UnifiedRegistrationService : ITransient await _registrationItemRepository.InsertRangeAsync(regItems); await _registrationPersonRepository.InsertRangeAsync(persons); - var totalAmount = CalculateTotalAmount(feeConfig, eventProjects, input.Items, totalPersonCount); + // 使用去重后的用户数量计算金额 + var totalAmount = CalculateTotalAmount(feeConfig, eventProjects, input.Items, uniqueUserIds.Count); - return (totalAmount, totalPersonCount); + return (totalAmount, uniqueUserIds.Count); } ///