fix: 应收应付「仅当前生效阶段」列表金额为 0
All checks were successful
Build and Deploy / deploy (push) Successful in 1m2s

SqlSugar 在同一查询上 Select 后再分页会沿用投影列,导致 Amount/Currency 丢失;候选筛选与最终全字段查询拆开。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zzh 2026-10-15 20:11:46 +08:00
parent 8258ae746e
commit 66d383160f

View File

@ -1215,12 +1215,14 @@ public class OrderRepository : OmsSqlSugarRepository<Order>, IOrderRepository, I
return feeQuery;
}
// SqlSugar:在同一 ISugarQueryable 上 Select 后再 Where/ToPageList,会沿用投影列,
// 导致 Amount/Currency 等未选字段落成默认值(金额全 0、币种空)。候选查询与最终查询拆开。
var candidates = await feeQuery
.Select(f => new { f.Id, f.OrderId, f.Type, f.CostItem, f.ChargingStage })
.ToListAsync(cancellationToken);
if (candidates.Count == 0)
{
return feeQuery.Where(_ => false);
return db.Queryable<OrderFee>().Where(_ => false);
}
var winningIds = candidates
@ -1232,7 +1234,9 @@ public class OrderRepository : OmsSqlSugarRepository<Order>, IOrderRepository, I
.Id)
.ToArray();
return feeQuery.Where(f => winningIds.Contains(f.Id));
return db.Queryable<OrderFee>()
.Where(fee => !fee.IsDeleted)
.Where(f => winningIds.Contains(f.Id));
}
private static int GetChargingStageRank(string? stage) =>