From c2d7b5c854e3ef8272bc9dd990237cb7a222c035 Mon Sep 17 00:00:00 2001 From: zzh <1368735060@qq.com> Date: Sat, 11 Jul 2026 17:10:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BA=97=E9=93=BA=E5=88=97?= =?UTF-8?q?=E8=A1=A8=20ExpirationFilter=20=E5=B5=8C=E5=A5=97=E4=B8=89?= =?UTF-8?q?=E5=85=83=E5=AF=BC=E8=87=B4=20SqlSugar=20IIF=20=E7=BF=BB?= =?UTF-8?q?=E8=AF=91=E5=A4=B1=E8=B4=A5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 按 expired/within7days/normal 分支构造独立 predicate,与充值等模块写法对齐。 Co-authored-by: Cursor --- .../Services/Orders/PlatformStoreService.cs | 39 +++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/Oms.Application/Services/Orders/PlatformStoreService.cs b/src/Oms.Application/Services/Orders/PlatformStoreService.cs index 357bffa..71678c3 100644 --- a/src/Oms.Application/Services/Orders/PlatformStoreService.cs +++ b/src/Oms.Application/Services/Orders/PlatformStoreService.cs @@ -170,20 +170,37 @@ public class PlatformStoreService : ApplicationService var platformCode = input.PlatformCode?.Trim(); var nickname = input.StoreNickname?.Trim(); var filter = input.ExpirationFilter?.Trim().ToLowerInvariant(); + var hasPlatformCode = !string.IsNullOrWhiteSpace(platformCode); + var hasNickname = !string.IsNullOrWhiteSpace(nickname); var now = DateTime.Now; var within7Days = now.AddDays(7); - return x => - (!hasCustomerFilter || x.CustomerId == customerIdValue) - && (string.IsNullOrWhiteSpace(platformCode) || x.PlatformCode == platformCode) - && (string.IsNullOrWhiteSpace(nickname) || x.StoreNickname.Contains(nickname)) - && (string.IsNullOrWhiteSpace(filter) || filter == "normal" - ? string.IsNullOrWhiteSpace(filter) || !x.TokenExpireTime.HasValue || x.TokenExpireTime > within7Days - : filter == "expired" - ? x.TokenExpireTime.HasValue && x.TokenExpireTime < now - : filter == "within7days" - ? x.TokenExpireTime.HasValue && x.TokenExpireTime >= now && x.TokenExpireTime <= within7Days - : true); + // 显式按过期筛选分支构造表达式,避免嵌套三元被 ORM 翻译成非法 IIF。 + return filter switch + { + "expired" => x => + (!hasCustomerFilter || x.CustomerId == customerIdValue) + && (!hasPlatformCode || x.PlatformCode == platformCode) + && (!hasNickname || x.StoreNickname.Contains(nickname!)) + && x.TokenExpireTime.HasValue + && x.TokenExpireTime < now, + "within7days" => x => + (!hasCustomerFilter || x.CustomerId == customerIdValue) + && (!hasPlatformCode || x.PlatformCode == platformCode) + && (!hasNickname || x.StoreNickname.Contains(nickname!)) + && x.TokenExpireTime.HasValue + && x.TokenExpireTime >= now + && x.TokenExpireTime <= within7Days, + "normal" => x => + (!hasCustomerFilter || x.CustomerId == customerIdValue) + && (!hasPlatformCode || x.PlatformCode == platformCode) + && (!hasNickname || x.StoreNickname.Contains(nickname!)) + && (!x.TokenExpireTime.HasValue || x.TokenExpireTime > within7Days), + _ => x => + (!hasCustomerFilter || x.CustomerId == customerIdValue) + && (!hasPlatformCode || x.PlatformCode == platformCode) + && (!hasNickname || x.StoreNickname.Contains(nickname!)) + }; } private static PlatformStoreOutput MapOutput(SalesStore entity) =>