From a4c45f3ba8e26f4b7532fb2b4f4d35205489050c Mon Sep 17 00:00:00 2001 From: liguoyang Date: Tue, 14 Oct 2025 14:29:37 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BC=98=E5=8C=96=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ShiftAndBusinessPlaceAnalysisResponse.cs | 6 +++--- .../Services/Implements/BalanceSummaryService.cs | 15 +++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Src/Dlhis.Canteen/Order/Response/ShiftAndBusinessPlaceAnalysisResponse.cs b/Src/Dlhis.Canteen/Order/Response/ShiftAndBusinessPlaceAnalysisResponse.cs index 369de506..f0208130 100644 --- a/Src/Dlhis.Canteen/Order/Response/ShiftAndBusinessPlaceAnalysisResponse.cs +++ b/Src/Dlhis.Canteen/Order/Response/ShiftAndBusinessPlaceAnalysisResponse.cs @@ -1,8 +1,8 @@ -using System.Text.Json.Serialization; using Dlhis.Entity.Canteen.Enums; using Dlhis.ExcelHelper; using Kurisu.AspNetCore.DataAccess.Dto; using Kurisu.AspNetCore.Utils.Extensions; +using Newtonsoft.Json; namespace Dlhis.Canteen.Order.Response; @@ -16,12 +16,12 @@ public class ShiftAndBusinessPlaceAnalysisResponse /// /// 消费人数 /// - public int Total { get; set; } + public int UserCount { get; set; } /// /// 消费次数 /// - public int CostCount => Pagination.Total; + public int CostCount { get; set; } /// /// 分页数据 diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceSummaryService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceSummaryService.cs index 2a62c518..be4e8140 100644 --- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceSummaryService.cs +++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceSummaryService.cs @@ -185,13 +185,20 @@ public class BalanceSummaryService : IBalanceSummaryService }) .ToPageListAsync(request); - var amount = await QueryableShiftAndBusinessPlaceAnalysis(request).SumAsync(record => SqlFunc.Abs(record.Amount)); - var userCount = await QueryableShiftAndBusinessPlaceAnalysis(request).Select(record => record.UserCode).Distinct().CountAsync(); + var data = await QueryableShiftAndBusinessPlaceAnalysis(request) + .Select(record => new + { + Amount = SqlFunc.AggregateSum(record.Amount), + UserCount = SqlFunc.AggregateDistinctCount(record.UserCode), + CostCount = SqlFunc.AggregateCount(record.Id), + }) + .FirstAsync(); return new ShiftAndBusinessPlaceAnalysisResponse { - Amount = amount, - Total = userCount, + Amount = data?.Amount ?? 0, + UserCount = data?.UserCount ?? 0, + CostCount = data?.CostCount ?? 0, Pagination = page, };