fix: 优化 soldOutBucketKey 方法逻辑,确保数字和字母处理一致性;更新数据库填充器以对齐仪表盘场景

This commit is contained in:
2026-05-11 17:20:58 +08:00
parent 0cbd64a5af
commit 7e96c01da1
4 changed files with 505 additions and 7 deletions

View File

@@ -243,24 +243,33 @@ final class AdminDashboardSnapshotBuilder
];
}
/** @return 'd4'|'d3'|'d2'|'special'|'other' */
/**
* 与仪表盘前端维度一致:先按「提取数字位数」分 4D/3D/2D含字母且不足 3 位有效数字的视为特别号。
*
* @return 'd4'|'d3'|'d2'|'special'|'other'
*/
private function soldOutBucketKey(string $normalizedNumber): string
{
$raw = trim($normalizedNumber);
if (preg_match('/[A-Za-z]/', $raw) === 1) {
$digits = preg_replace('/\D/', '', $raw) ?? '';
$digitLen = strlen($digits);
$hasLetter = preg_match('/[A-Za-z]/', $raw) === 1;
if ($hasLetter && $digitLen < 3) {
return 'special';
}
$digits = preg_replace('/\D/', '', $raw) ?? '';
$len = strlen($digits) > 0 ? strlen($digits) : strlen($raw);
if ($len >= 4) {
if ($digitLen >= 4) {
return 'd4';
}
if ($len === 3) {
if ($digitLen === 3) {
return 'd3';
}
if ($len === 2) {
if ($digitLen === 2) {
return 'd2';
}
if ($hasLetter) {
return 'special';
}
return 'other';
}