更新
This commit is contained in:
@@ -24,6 +24,10 @@ $params = [
|
||||
];
|
||||
$overviewStartedAt = microtime(true);
|
||||
$overview = FirstVisitConversionLogic::overview($params, (int) $admin['id'], $admin);
|
||||
$canViewDeletedFans = ($admin['account'] ?? null) === 'admin';
|
||||
if (($overview['meta']['can_view_deleted_fans'] ?? null) !== $canViewDeletedFans) {
|
||||
throw new RuntimeException('Deleted-fan visibility must follow exact authenticated account, not root');
|
||||
}
|
||||
$overviewElapsedMs = (microtime(true) - $overviewStartedAt) * 1000;
|
||||
$candidates = [];
|
||||
$collect = static function (array $rows, array $path = []) use (&$collect, &$candidates): void {
|
||||
@@ -73,16 +77,29 @@ $detailElapsedMs = (microtime(true) - $detailStartedAt) * 1000;
|
||||
if ((int) ($detail['count'] ?? -1) !== (int) ($row['add_fans_count'] ?? 0)) {
|
||||
throw new RuntimeException('Fan detail count does not match the clicked add_fans_count row');
|
||||
}
|
||||
if ((int) ($detail['entity']['deleted_fans_count'] ?? -1) !== (int) ($row['deleted_fans_count'] ?? 0)) {
|
||||
if (($detail['can_view_deleted_fans'] ?? null) !== $canViewDeletedFans) {
|
||||
throw new RuntimeException('Fan detail visibility differs from overview');
|
||||
}
|
||||
if ($canViewDeletedFans && (int) ($detail['entity']['deleted_fans_count'] ?? -1) !== (int) ($row['deleted_fans_count'] ?? 0)) {
|
||||
throw new RuntimeException('Fan detail entity metadata lost deleted_fans_count');
|
||||
}
|
||||
if (!$canViewDeletedFans && (array_key_exists('deleted_fans_count', $detail['entity']) || array_key_exists('deleted_fans_count', $row))) {
|
||||
throw new RuntimeException('Other root accounts must not receive deleted_fans_count');
|
||||
}
|
||||
|
||||
foreach ($detail['lists'] ?? [] as $fan) {
|
||||
foreach (['external_userid', 'customer_name', 'wecom_userid', 'wecom_staff_name', 'add_time', 'is_deleted', 'delete_time'] as $field) {
|
||||
$requiredFields = ['external_userid', 'customer_name', 'wecom_userid', 'wecom_staff_name', 'add_time'];
|
||||
if ($canViewDeletedFans) {
|
||||
$requiredFields = array_merge($requiredFields, ['is_deleted', 'delete_time']);
|
||||
}
|
||||
foreach ($requiredFields as $field) {
|
||||
if (!array_key_exists($field, $fan)) {
|
||||
throw new RuntimeException("Fan detail row is missing {$field}");
|
||||
}
|
||||
}
|
||||
if (!$canViewDeletedFans && (array_key_exists('is_deleted', $fan) || array_key_exists('delete_time', $fan))) {
|
||||
throw new RuntimeException('Other accounts must not receive deletion state through fan detail');
|
||||
}
|
||||
}
|
||||
|
||||
$forgedDetail = FirstVisitConversionLogic::fansDetail($params + [
|
||||
@@ -114,8 +131,9 @@ if ($centerRows !== []) {
|
||||
$centerDetailElapsedMs = (microtime(true) - $centerStartedAt) * 1000;
|
||||
$centerDetailCount = (int) ($centerDetail['count'] ?? -1);
|
||||
if ($centerDetailCount !== (int) ($centerRow['add_fans_count'] ?? 0)
|
||||
|| (int) ($centerDetail['entity']['deleted_fans_count'] ?? -1)
|
||||
!== (int) ($centerRow['deleted_fans_count'] ?? 0)
|
||||
|| ($canViewDeletedFans && (int) ($centerDetail['entity']['deleted_fans_count'] ?? -1)
|
||||
!== (int) ($centerRow['deleted_fans_count'] ?? 0))
|
||||
|| (!$canViewDeletedFans && array_key_exists('deleted_fans_count', $centerDetail['entity'] ?? []))
|
||||
) {
|
||||
throw new RuntimeException('郑州二中心 detail count does not match overview');
|
||||
}
|
||||
@@ -169,12 +187,12 @@ if ($parentCandidates !== []) {
|
||||
}
|
||||
|
||||
echo sprintf(
|
||||
"FAN_DETAIL_DB_SMOKE_OK range=2026-08-01..2026-08-25 type=%s entity=%s path=%s count=%d deleted=%d parent=%d overview_ms=%.1f detail_ms=%.1f center_count=%d center_detail_ms=%.1f forged=0\n",
|
||||
"FAN_DETAIL_DB_SMOKE_OK range=2026-08-01..2026-08-25 type=%s entity=%s path=%s count=%d deleted=%s parent=%d overview_ms=%.1f detail_ms=%.1f center_count=%d center_detail_ms=%.1f forged=0\n",
|
||||
$entityType,
|
||||
(string) ($row['name'] ?? $row['id'] ?? ''),
|
||||
(string) ($row['_smoke_path'] ?? ''),
|
||||
(int) $detail['count'],
|
||||
(int) ($detail['entity']['deleted_fans_count'] ?? 0),
|
||||
$canViewDeletedFans ? (string) ($detail['entity']['deleted_fans_count'] ?? 0) : 'hidden',
|
||||
$parentChecked ? 1 : 0,
|
||||
$overviewElapsedMs,
|
||||
$detailElapsedMs,
|
||||
|
||||
Reference in New Issue
Block a user