32 lines
1.6 KiB
PHP
32 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
$logicPath = dirname(__DIR__) . '/app/adminapi/logic/firstvisit/WecomPromotionLogic.php';
|
|
$viewPath = dirname(__DIR__, 2) . '/admin/src/views/first_visit/wecom_promotion/index.vue';
|
|
$logic = file_get_contents($logicPath);
|
|
$view = file_get_contents($viewPath);
|
|
if (!is_string($logic) || !is_string($view)) {
|
|
throw new RuntimeException('无法读取获客助手删除链路源码');
|
|
}
|
|
|
|
$start = strpos($logic, 'public static function deletePool(');
|
|
$end = strpos($logic, 'public static function saveMember(', $start === false ? 0 : $start);
|
|
if ($start === false || $end === false || $end <= $start) {
|
|
throw new RuntimeException('无法定位 deletePool 方法');
|
|
}
|
|
$method = substr($logic, $start, $end - $start);
|
|
$remoteDeleteAt = strpos($method, '$api->deleteLink($remoteLinkId)');
|
|
$localDeleteAt = strpos($method, "Db::transaction(function () use (\$id, \$now)");
|
|
if ($remoteDeleteAt === false || $localDeleteAt === false || $remoteDeleteAt >= $localDeleteAt) {
|
|
throw new RuntimeException('删除方案必须先永久删除企业微信官方链接,再删除本地记录');
|
|
}
|
|
if (!str_contains($method, '本地方案已保留') || !str_contains($method, "'remote_status' => 2")) {
|
|
throw new RuntimeException('企业微信删除失败保护或成功状态记录缺失');
|
|
}
|
|
if (!str_contains($view, '已投放的链接会失效且无法恢复') || !str_contains($view, "confirmButtonText: '永久删除'")) {
|
|
throw new RuntimeException('前端没有明确提示官方链接将被永久删除');
|
|
}
|
|
|
|
echo "WECOM_PROMOTION_DELETE_POOL_CONTRACT_OK\n";
|