1.修复游戏实时对局/admin/game/live页面的报错
This commit is contained in:
@@ -151,6 +151,48 @@ final class GameHotDataRedis
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 派彩宽限期已结束但缓存仍为 status=3(导致页面倒计时 0、无法开新期)。
|
||||
*/
|
||||
public static function isExpiredPayoutRecord(array $row): bool
|
||||
{
|
||||
if ((int) ($row['status'] ?? -1) !== 3) {
|
||||
return false;
|
||||
}
|
||||
$until = (int) ($row['payout_until'] ?? 0);
|
||||
|
||||
return $until <= 0 || $until <= time();
|
||||
}
|
||||
|
||||
/**
|
||||
* 下注/封盘期缓存与库不一致或已超时未开奖(period_start 过久仍为 0/1)。
|
||||
*/
|
||||
public static function isStaleOpenPeriodRecord(array $row, int $periodSeconds): bool
|
||||
{
|
||||
$st = (int) ($row['status'] ?? -1);
|
||||
if (!in_array($st, [0, 1], true)) {
|
||||
return false;
|
||||
}
|
||||
$start = (int) ($row['period_start_at'] ?? 0);
|
||||
if ($start <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return time() - $start > $periodSeconds + 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存行疑似过期时,按库回写 Redis 后再由调用方重新读取。
|
||||
*/
|
||||
public static function gameRecordRevalidateFromDbIfStale(array $row, int $periodSeconds = 30): void
|
||||
{
|
||||
if (!self::isExpiredPayoutRecord($row) && !self::isStaleOpenPeriodRecord($row, $periodSeconds)) {
|
||||
return;
|
||||
}
|
||||
$id = (int) ($row['id'] ?? 0);
|
||||
self::gameRecordSyncCachesAfterDbWrite($id > 0 ? $id : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>|null
|
||||
*/
|
||||
@@ -165,7 +207,11 @@ final class GameHotDataRedis
|
||||
if ($cached !== null && $cached !== '') {
|
||||
$decoded = json_decode($cached, true);
|
||||
if (is_array($decoded)) {
|
||||
return $decoded;
|
||||
if (self::isExpiredPayoutRecord($decoded)) {
|
||||
self::gameRecordSyncCachesAfterDbWrite($id);
|
||||
} else {
|
||||
return $decoded;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,7 +238,11 @@ final class GameHotDataRedis
|
||||
if ($cached !== null && $cached !== '') {
|
||||
$decoded = json_decode($cached, true);
|
||||
if (is_array($decoded)) {
|
||||
return $decoded;
|
||||
if (self::isExpiredPayoutRecord($decoded)) {
|
||||
self::gameRecordRefreshAggregateCaches();
|
||||
} else {
|
||||
return $decoded;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user