fix: 客户列表无 monitorScope 时被 SqlSugar 空结果过滤 #21
@ -520,6 +520,11 @@ public class CustomerService : ApplicationService
|
|||||||
var agentId = input.AgentId.GetValueOrDefault();
|
var agentId = input.AgentId.GetValueOrDefault();
|
||||||
var monitorScope = NormalizeMonitorScope(input.MonitorScope);
|
var monitorScope = NormalizeMonitorScope(input.MonitorScope);
|
||||||
var hasMonitorScope = !string.IsNullOrEmpty(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 同一时间口径
|
// 与 /monitor/overview 客户 KPI 同一时间口径
|
||||||
var today = DateTime.Today;
|
var today = DateTime.Today;
|
||||||
var tomorrow = today.AddDays(1);
|
var tomorrow = today.AddDays(1);
|
||||||
@ -538,10 +543,10 @@ public class CustomerService : ApplicationService
|
|||||||
(string.IsNullOrWhiteSpace(salesman) || customer.Salesman == salesman) &&
|
(string.IsNullOrWhiteSpace(salesman) || customer.Salesman == salesman) &&
|
||||||
(string.IsNullOrWhiteSpace(customerService) || customer.CustomerService == customerService) &&
|
(string.IsNullOrWhiteSpace(customerService) || customer.CustomerService == customerService) &&
|
||||||
(!hasAgentFilter || customer.AgentId == agentId) &&
|
(!hasAgentFilter || customer.AgentId == agentId) &&
|
||||||
(monitorScope != "newToday" || (customer.CreateTime >= today && customer.CreateTime < tomorrow)) &&
|
(!isMonitorNewToday || (customer.CreateTime >= today && customer.CreateTime < tomorrow)) &&
|
||||||
(monitorScope != "online" ||
|
(!isMonitorOnline ||
|
||||||
(customer.LastLoginTime != null && customer.LastLoginTime >= onlineSince)) &&
|
(customer.LastLoginTime != null && customer.LastLoginTime >= onlineSince)) &&
|
||||||
(monitorScope != "inactive7d" ||
|
(!isMonitorInactive7d ||
|
||||||
(customer.LastLoginTime == null || customer.LastLoginTime < inactive7dThreshold));
|
(customer.LastLoginTime == null || customer.LastLoginTime < inactive7dThreshold));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user