This commit is contained in:
zpc 2026-02-04 02:35:38 +08:00
parent 8c71ebe7eb
commit d11d61b4f1

View File

@ -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<BoxProfitItem>.Create(goods, total, request.Page, request.PageSize);
}