51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use app\common\service\qywx\MediaChannelService;
|
|
use think\facade\Db;
|
|
|
|
require dirname(__DIR__) . '/vendor/autoload.php';
|
|
|
|
$app = new think\App();
|
|
$app->initialize();
|
|
|
|
$tagQuery = Db::name('qywx_external_contact_event')->alias('e');
|
|
MediaChannelService::applyExternalUserChannelFilter(
|
|
$tagQuery,
|
|
'e.external_userid',
|
|
[
|
|
'source_tag_id' => 'tag-regression-id',
|
|
'source_tag_name' => '回归渠道',
|
|
]
|
|
);
|
|
$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, 'follow_users') || str_contains($tagSql, 'LIKE')) {
|
|
throw new RuntimeException('tag 渠道仍在扫描 follow_users JSON');
|
|
}
|
|
|
|
$legacyQuery = Db::name('order')->alias('o');
|
|
MediaChannelService::applyExternalUserChannelFilter(
|
|
$legacyQuery,
|
|
'o.payer_external_userid',
|
|
[
|
|
'source_tag_id' => '',
|
|
'source_tag_name' => '仅名称老渠道',
|
|
]
|
|
);
|
|
$legacySql = (string)$legacyQuery->fetchSql()->select();
|
|
if (!str_contains($legacySql, ' IN (SELECT channel_contact.external_userid')) {
|
|
throw new RuntimeException('老渠道回退未使用去重 external_userid 子查询');
|
|
}
|
|
if (!str_contains($legacySql, 'channel_contact.delete_time IS NULL')) {
|
|
throw new RuntimeException('老渠道回退包含了已删除客户记录');
|
|
}
|
|
|
|
echo "MEDIA_CHANNEL_EXTERNAL_USER_FILTER_OK\n";
|