From 99e7650dd89cdb4f7c7900fed041c4d56f3a4674 Mon Sep 17 00:00:00 2001 From: zzh <1368735060@qq.com> Date: Mon, 9 Nov 2026 15:57:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=A2=E6=88=B7=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=97=A0=20monitorScope=20=E6=97=B6=E8=A2=AB=20SqlSugar=20?= =?UTF-8?q?=E7=A9=BA=E7=BB=93=E6=9E=9C=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- .../Services/Customers/CustomerService.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Oms.Application/Services/Customers/CustomerService.cs b/src/Oms.Application/Services/Customers/CustomerService.cs index 605c8bf..8a29a78 100644 --- a/src/Oms.Application/Services/Customers/CustomerService.cs +++ b/src/Oms.Application/Services/Customers/CustomerService.cs @@ -520,6 +520,11 @@ public class CustomerService : ApplicationService var agentId = input.AgentId.GetValueOrDefault(); var monitorScope = NormalizeMonitorScope(input.MonitorScope); var hasMonitorScope = !string.IsNullOrEmpty(monitorScope); + // 必须用 bool 常量进表达式;勿写 monitorScope != "x"(null 会被 SqlSugar 参数化, + // SQL 里 NULL <> 'x' 为 UNKNOWN,列表会被滤成空)。 + var isMonitorNewToday = monitorScope == "newToday"; + var isMonitorOnline = monitorScope == "online"; + var isMonitorInactive7d = monitorScope == "inactive7d"; // 与 /monitor/overview 客户 KPI 同一时间口径 var today = DateTime.Today; var tomorrow = today.AddDays(1); @@ -538,10 +543,10 @@ public class CustomerService : ApplicationService (string.IsNullOrWhiteSpace(salesman) || customer.Salesman == salesman) && (string.IsNullOrWhiteSpace(customerService) || customer.CustomerService == customerService) && (!hasAgentFilter || customer.AgentId == agentId) && - (monitorScope != "newToday" || (customer.CreateTime >= today && customer.CreateTime < tomorrow)) && - (monitorScope != "online" || + (!isMonitorNewToday || (customer.CreateTime >= today && customer.CreateTime < tomorrow)) && + (!isMonitorOnline || (customer.LastLoginTime != null && customer.LastLoginTime >= onlineSince)) && - (monitorScope != "inactive7d" || + (!isMonitorInactive7d || (customer.LastLoginTime == null || customer.LastLoginTime < inactive7dThreshold)); }