This commit is contained in:
Your Name
2026-08-18 14:08:38 +08:00
parent 8b9df1154c
commit bc1228a310
77 changed files with 10763 additions and 1181 deletions
@@ -23,8 +23,17 @@ $tagSql = (string)$tagQuery->fetchSql()->select();
if (!str_contains($tagSql, 'qywx_external_contact_tag')) {
throw new RuntimeException('tag 渠道未使用结构化客户标签关系表');
}
if (!str_contains($tagSql, ' IN (SELECT channel_tag.external_userid')) {
throw new RuntimeException('tag 渠道未通过去重子查询过滤 external_userid');
if (!str_contains($tagSql, 'EXISTS (SELECT 1 FROM')) {
throw new RuntimeException('tag 渠道未使用 EXISTS 半连接,避免物化整渠客户 ID');
}
if (!str_contains($tagSql, 'channel_tag.external_userid = e.external_userid')) {
throw new RuntimeException('tag 渠道未按事实表 external_userid 相关查询');
}
if (!str_contains($tagSql, 'tag_id = ')) {
throw new RuntimeException('单标签渠道应使用 tag_id = 走组合索引');
}
if (str_contains($tagSql, 'tag_id IN (')) {
throw new RuntimeException('单标签渠道不应退化为 tag_id IN');
}
if (str_contains($tagSql, 'follow_users') || str_contains($tagSql, 'LIKE')) {
throw new RuntimeException('tag 渠道仍在扫描 follow_users JSON');
@@ -47,4 +56,26 @@ if (!str_contains($legacySql, 'channel_contact.delete_time IS NULL')) {
throw new RuntimeException('老渠道回退包含了已删除客户记录');
}
$groupQuery = Db::name('qywx_external_contact_event')->alias('e');
MediaChannelService::applyExternalUserChannelFilter(
$groupQuery,
'e.external_userid',
[
'source_tag_id' => '',
'source_tag_ids' => ['tag-group-a', 'tag-group-b'],
'channel_name' => '自媒体4',
'is_group' => true,
]
);
$groupSql = (string)$groupQuery->fetchSql()->select();
if (!str_contains($groupSql, 'EXISTS (SELECT 1 FROM')) {
throw new RuntimeException('分组渠道未使用 EXISTS 半连接');
}
if (!str_contains($groupSql, 'tag_id IN (')) {
throw new RuntimeException('分组渠道未按多个 tag_id 过滤');
}
if (str_contains($groupSql, 'follow_users') || str_contains($groupSql, 'LIKE')) {
throw new RuntimeException('分组渠道仍在扫描 follow_users JSON');
}
echo "MEDIA_CHANNEL_EXTERNAL_USER_FILTER_OK\n";