diff --git a/app/common/service/GameBetSettleService.php b/app/common/service/GameBetSettleService.php index bbe6a05..5635b98 100644 --- a/app/common/service/GameBetSettleService.php +++ b/app/common/service/GameBetSettleService.php @@ -763,11 +763,20 @@ final class GameBetSettleService if ($userIds === []) { return []; } - $rows = Db::name('user') - ->whereIn('id', $userIds) - ->field(['id', 'nickname', 'username']) - ->select() - ->toArray(); + // 兼容不同库结构:有的库没有 nickname 字段(仅 username) + try { + $rows = Db::name('user') + ->whereIn('id', $userIds) + ->field(['id', 'nickname', 'username']) + ->select() + ->toArray(); + } catch (Throwable) { + $rows = Db::name('user') + ->whereIn('id', $userIds) + ->field(['id', 'username']) + ->select() + ->toArray(); + } $out = []; foreach ($rows as $row) { $uid = isset($row['id']) && is_numeric($row['id']) ? (int) $row['id'] : 0; diff --git a/scripts/debug_period_win_flags.php b/scripts/debug_period_win_flags.php index a87fc72..afa2f47 100644 --- a/scripts/debug_period_win_flags.php +++ b/scripts/debug_period_win_flags.php @@ -26,6 +26,11 @@ if ($periodId <= 0 && isset($opts['period-no'])) { if ($periodNo !== '') { $pid = Db::name('game_record')->where('period_no', $periodNo)->value('id'); $periodId = is_numeric((string) $pid) ? (int) $pid : 0; + if ($periodId <= 0) { + // 兜底:部分环境 game_record.period_no 与 bet_order.period_no 不一致(或 game_record 未落库),从注单反查 period_id + $pid2 = Db::name('bet_order')->where('period_no', $periodNo)->value('period_id'); + $periodId = is_numeric((string) $pid2) ? (int) $pid2 : 0; + } echo "period_no={$periodNo} => period_id={$periodId}" . PHP_EOL; } }