更新
This commit is contained in:
@@ -77,20 +77,37 @@ class CustomerLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
}
|
||||
}
|
||||
|
||||
// 添加时间:与 lists 排序口径一致(external_first_add_time 优先,0 则 create_time)
|
||||
// 添加时间筛选,两种口径:
|
||||
// first(默认)= 首次添加时间在窗口内(external_first_add_time 优先,0 则 create_time)
|
||||
// any = 企微「全部客户+时间筛选」口径:存在"添加时间在窗口内的现存跟进关系"即命中
|
||||
// (含老客户被重加/被其他员工添加;关系已解除的不算),数据源为现存关系表
|
||||
$addStart = trim((string) ($this->params['add_time_start'] ?? ''));
|
||||
$addEnd = trim((string) ($this->params['add_time_end'] ?? ''));
|
||||
$effExpr = 'COALESCE(NULLIF(external_first_add_time, 0), create_time)';
|
||||
if ($addStart !== '') {
|
||||
$t = strtotime($addStart . ' 00:00:00');
|
||||
if ($t !== false) {
|
||||
$query->whereRaw($effExpr . ' > 0 AND ' . $effExpr . ' >= ?', [$t]);
|
||||
$addMode = trim((string) ($this->params['add_time_mode'] ?? 'first'));
|
||||
$startTs = $addStart !== '' ? strtotime($addStart . ' 00:00:00') : false;
|
||||
$endTs = $addEnd !== '' ? strtotime($addEnd . ' 23:59:59') : false;
|
||||
|
||||
if ($addMode === 'any' && ($startTs !== false || $endTs !== false)) {
|
||||
$followQuery = Db::name('qywx_external_contact_follow')->where('createtime', '>', 0);
|
||||
if ($startTs !== false) {
|
||||
$followQuery->where('createtime', '>=', $startTs);
|
||||
}
|
||||
}
|
||||
if ($addEnd !== '') {
|
||||
$t = strtotime($addEnd . ' 23:59:59');
|
||||
if ($t !== false) {
|
||||
$query->whereRaw($effExpr . ' > 0 AND ' . $effExpr . ' <= ?', [$t]);
|
||||
if ($endTs !== false) {
|
||||
$followQuery->where('createtime', '<=', $endTs);
|
||||
}
|
||||
$matchedExtIds = $followQuery->group('external_userid')->column('external_userid');
|
||||
if ($matchedExtIds === []) {
|
||||
$query->whereRaw('1=0');
|
||||
} else {
|
||||
$query->whereIn('external_userid', $matchedExtIds);
|
||||
}
|
||||
} else {
|
||||
$effExpr = 'COALESCE(NULLIF(external_first_add_time, 0), create_time)';
|
||||
if ($startTs !== false) {
|
||||
$query->whereRaw($effExpr . ' > 0 AND ' . $effExpr . ' >= ?', [$startTs]);
|
||||
}
|
||||
if ($endTs !== false) {
|
||||
$query->whereRaw($effExpr . ' > 0 AND ' . $effExpr . ' <= ?', [$endTs]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,6 +175,9 @@ class CustomerLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$fromDb = (int) ($item['external_first_add_time'] ?? 0);
|
||||
$fromJson = CustomerLogic::minFollowCreatetime($followUsers);
|
||||
$item['external_first_add_time'] = $fromDb > 0 ? $fromDb : $fromJson;
|
||||
|
||||
// 「任意添加」口径会带出软删行,前端据此显示"已删除"标记
|
||||
$item['is_deleted'] = !empty($item['delete_time']) ? 1 : 0;
|
||||
}
|
||||
unset($item);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user