From d11d61b4f1dc8aa62ff3e42a98065343c6259a96 Mon Sep 17 00:00:00 2001 From: zpc Date: Wed, 4 Feb 2026 02:35:38 +0800 Subject: [PATCH] 321 --- .../Services/StatisticsService.cs | 52 ++++++++++++------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/server/HoneyBox/src/HoneyBox.Admin.Business/Services/StatisticsService.cs b/server/HoneyBox/src/HoneyBox.Admin.Business/Services/StatisticsService.cs index d29d3124..9947617a 100644 --- a/server/HoneyBox/src/HoneyBox.Admin.Business/Services/StatisticsService.cs +++ b/server/HoneyBox/src/HoneyBox.Admin.Business/Services/StatisticsService.cs @@ -559,33 +559,45 @@ public class StatisticsService : IStatisticsService var total = await query.CountAsync(); // 分页获取盒子列表 - var goods = await query + var goodsData = await query .OrderByDescending(g => g.Id) .Skip(request.Skip) .Take(request.PageSize) - .Select(g => new BoxProfitItem + .Select(g => new { - Id = g.Id, - Title = g.Title, - ImgUrl = g.ImgUrl, - Price = g.Price, - Stock = g.Stock, - Status = g.Status, - Type = g.Type, - TypeName = BoxTypeNames.ContainsKey(g.Type) ? BoxTypeNames[g.Type] : "未知类型", - // 统计数据初始化为0,后续异步加载 - UseMoney = 0, - ScMoney = 0, - ReMoney = 0, - FhMoney = 0, - CjCount = 0, - Profit = 0, - ProfitRate = 0, - IsNegative = false, - Loaded = false + g.Id, + g.Title, + g.ImgUrl, + g.Price, + g.Stock, + g.Status, + g.Type }) .ToListAsync(); + // 在内存中映射类型名称(避免 EF Core 无法翻译字典方法的问题) + var goods = goodsData.Select(g => new BoxProfitItem + { + Id = g.Id, + Title = g.Title, + ImgUrl = g.ImgUrl, + Price = g.Price, + Stock = g.Stock, + Status = g.Status, + Type = g.Type, + TypeName = BoxTypeNames.GetValueOrDefault(g.Type, "未知类型"), + // 统计数据初始化为0,后续异步加载 + UseMoney = 0, + ScMoney = 0, + ReMoney = 0, + FhMoney = 0, + CjCount = 0, + Profit = 0, + ProfitRate = 0, + IsNegative = false, + Loaded = false + }).ToList(); + return PagedResult.Create(goods, total, request.Page, request.PageSize); }