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) =>