1.修复关闭自动创建下一局后还自动创建下一期
This commit is contained in:
@@ -30,7 +30,7 @@ class Game extends MobileBase
|
||||
return $response;
|
||||
}
|
||||
|
||||
$periodRow = GameHotDataRedis::gameRecordLatest();
|
||||
$periodRow = $this->resolveMobilePeriodRow();
|
||||
$now = time();
|
||||
$startAt = $periodRow ? $this->intValue($periodRow['period_start_at'] ?? 0) : $now;
|
||||
$lockAt = $startAt + 20;
|
||||
@@ -57,6 +57,7 @@ class Game extends MobileBase
|
||||
'server_time' => $now,
|
||||
'runtime_enabled' => GameRecordService::getConfigBool(GameRecordService::KEY_AUTO_CREATE),
|
||||
'period' => [
|
||||
'period_id' => $periodRow ? $this->intValue($periodRow['id'] ?? 0) : 0,
|
||||
'period_no' => (string) ($periodRow['period_no'] ?? ''),
|
||||
'status' => $this->mapPeriodStatus($periodRow['status'] ?? null),
|
||||
'countdown' => $countdown,
|
||||
@@ -110,7 +111,7 @@ class Game extends MobileBase
|
||||
if ($response !== null) {
|
||||
return $response;
|
||||
}
|
||||
$periodRow = GameHotDataRedis::gameRecordLatest();
|
||||
$periodRow = $this->resolveMobilePeriodRow();
|
||||
if (!$periodRow) {
|
||||
return $this->mobileError(2002, 'Game period does not exist');
|
||||
}
|
||||
@@ -118,7 +119,7 @@ class Game extends MobileBase
|
||||
$startAt = $this->intValue($periodRow['period_start_at'] ?? 0);
|
||||
return $this->mobileSuccess([
|
||||
'runtime_enabled' => GameRecordService::getConfigBool(GameRecordService::KEY_AUTO_CREATE),
|
||||
'period_id' => $periodRow['id'],
|
||||
'period_id' => $this->intValue($periodRow['id'] ?? 0),
|
||||
'period_no' => $periodRow['period_no'],
|
||||
'status' => $this->mapPeriodStatus($periodRow['status'] ?? null),
|
||||
'countdown' => max(0, ($startAt + 30) - $now),
|
||||
@@ -193,6 +194,14 @@ class Game extends MobileBase
|
||||
if ($this->intValue($period->status) !== 0) {
|
||||
return $this->mobileError(3002, 'Betting is closed');
|
||||
}
|
||||
$activeRow = GameHotDataRedis::gameRecordActive();
|
||||
if ($activeRow !== null) {
|
||||
$activeNo = trim((string) ($activeRow['period_no'] ?? ''));
|
||||
$activeId = $this->intValue($activeRow['id'] ?? 0);
|
||||
if ($activeNo !== '' && ($periodNo !== $activeNo || $this->intValue($period->id) !== $activeId)) {
|
||||
return $this->mobileError(3004, 'Not the current period; please refresh period_no');
|
||||
}
|
||||
}
|
||||
|
||||
$userIdRaw = $this->auth->id ?? null;
|
||||
$userId = filter_var($userIdRaw, FILTER_VALIDATE_INT);
|
||||
@@ -529,6 +538,16 @@ class Game extends MobileBase
|
||||
return (string) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动端展示的当前期:优先进行中局(id 最大且 status∈0..3),避免 gameRecordLatest 指向已结束新局而客户端仍用旧 period_no 下注。
|
||||
*
|
||||
* @return array<string, mixed>|null
|
||||
*/
|
||||
private function resolveMobilePeriodRow(): ?array
|
||||
{
|
||||
return GameHotDataRedis::gameRecordActive() ?? GameHotDataRedis::gameRecordLatest();
|
||||
}
|
||||
|
||||
private function intValue($value): int
|
||||
{
|
||||
$result = filter_var($value, FILTER_VALIDATE_INT);
|
||||
|
||||
Reference in New Issue
Block a user