修复店铺列表 ExpirationFilter 嵌套三元导致 SqlSugar IIF 翻译失败。
按 expired/within7days/normal 分支构造独立 predicate,与充值等模块写法对齐。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
fb61fbb072
commit
c2d7b5c854
@ -170,20 +170,37 @@ public class PlatformStoreService : ApplicationService
|
|||||||
var platformCode = input.PlatformCode?.Trim();
|
var platformCode = input.PlatformCode?.Trim();
|
||||||
var nickname = input.StoreNickname?.Trim();
|
var nickname = input.StoreNickname?.Trim();
|
||||||
var filter = input.ExpirationFilter?.Trim().ToLowerInvariant();
|
var filter = input.ExpirationFilter?.Trim().ToLowerInvariant();
|
||||||
|
var hasPlatformCode = !string.IsNullOrWhiteSpace(platformCode);
|
||||||
|
var hasNickname = !string.IsNullOrWhiteSpace(nickname);
|
||||||
var now = DateTime.Now;
|
var now = DateTime.Now;
|
||||||
var within7Days = now.AddDays(7);
|
var within7Days = now.AddDays(7);
|
||||||
|
|
||||||
return x =>
|
// 显式按过期筛选分支构造表达式,避免嵌套三元被 ORM 翻译成非法 IIF。
|
||||||
(!hasCustomerFilter || x.CustomerId == customerIdValue)
|
return filter switch
|
||||||
&& (string.IsNullOrWhiteSpace(platformCode) || x.PlatformCode == platformCode)
|
{
|
||||||
&& (string.IsNullOrWhiteSpace(nickname) || x.StoreNickname.Contains(nickname))
|
"expired" => x =>
|
||||||
&& (string.IsNullOrWhiteSpace(filter) || filter == "normal"
|
(!hasCustomerFilter || x.CustomerId == customerIdValue)
|
||||||
? string.IsNullOrWhiteSpace(filter) || !x.TokenExpireTime.HasValue || x.TokenExpireTime > within7Days
|
&& (!hasPlatformCode || x.PlatformCode == platformCode)
|
||||||
: filter == "expired"
|
&& (!hasNickname || x.StoreNickname.Contains(nickname!))
|
||||||
? x.TokenExpireTime.HasValue && x.TokenExpireTime < now
|
&& x.TokenExpireTime.HasValue
|
||||||
: filter == "within7days"
|
&& x.TokenExpireTime < now,
|
||||||
? x.TokenExpireTime.HasValue && x.TokenExpireTime >= now && x.TokenExpireTime <= within7Days
|
"within7days" => x =>
|
||||||
: true);
|
(!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) =>
|
private static PlatformStoreOutput MapOutput(SalesStore entity) =>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user