where('period_no', $periodNo)->value('id'); $periodId = is_numeric((string) $pid) ? (int) $pid : 0; echo "period_no={$periodNo} => period_id={$periodId}" . PHP_EOL; } } if ($periodId <= 0) { fwrite(STDERR, "请指定 --period-id 或 --period-no\n"); exit(1); } $record = Db::name('game_record')->where('id', $periodId)->find(); if (!is_array($record)) { fwrite(STDERR, "对局不存在: period_id={$periodId}\n"); exit(1); } $resultNumber = filter_var($record['result_number'] ?? 0, FILTER_VALIDATE_INT); if ($resultNumber === false || $resultNumber < 1) { fwrite(STDERR, "对局尚未开奖(result_number 无效),无法诊断\n"); exit(1); } $periodNo = is_string($record['period_no'] ?? null) ? (string) $record['period_no'] : ''; echo "period_id={$periodId} period_no={$periodNo} result_number={$resultNumber}" . PHP_EOL; // 注意:这里只输出标记相关信息,不会触发任何写库/推送 $rows = Db::name('bet_order') ->where('period_id', $periodId) ->whereIn('status', [GameBetSettleService::PLAY_STATUS_SETTLED, GameBetSettleService::PLAY_STATUS_PENDING_REVIEW]) ->field(['id', 'user_id', 'streak_at_bet', 'total_amount', 'win_amount', 'status']) ->order('id', 'asc') ->select() ->toArray(); if ($rows === []) { echo "no settled orders\n"; exit(0); } echo "streak_win_reward rows (level=1..10):" . PHP_EOL; foreach (StreakWinReward::loadRows() as $r) { $st = (int) ($r['streak'] ?? 0); $od = (int) ($r['odds_factor'] ?? 1); $jk = !empty($r['is_jackpot']) ? 1 : 0; echo "- level={$st} odds_factor={$od} is_jackpot={$jk}" . PHP_EOL; } echo PHP_EOL . "orders:" . PHP_EOL; $anyJackpot = false; foreach ($rows as $row) { $betId = (int) ($row['id'] ?? 0); $uid = (int) ($row['user_id'] ?? 0); $streakAtBet = (int) ($row['streak_at_bet'] ?? 0); $win = is_string($row['win_amount'] ?? null) ? (string) $row['win_amount'] : (is_numeric($row['win_amount'] ?? null) ? (string) $row['win_amount'] : '0.00'); $winNorm = bcadd($win, '0', 2); $level = StreakWinReward::levelFromStreakAtBet($streakAtBet); $odds = StreakWinReward::totalOddsMultiplierForStreakAtBet($streakAtBet); $isJackpotByStreak = StreakWinReward::isJackpotForStreakAtBet($streakAtBet); $needReview = ((int) ($row['status'] ?? 0)) === GameBetSettleService::PLAY_STATUS_PENDING_REVIEW; $flags = (new ReflectionClass(GameBetSettleService::class))->getMethod('betWinJackpotFlagsForOrder'); $flags->setAccessible(true); /** @var array{is_jackpot: bool, payout_pending_review: bool} $computed */ $computed = $flags->invoke(null, $row, $winNorm, $needReview); $anyJackpot = $anyJackpot || !empty($computed['is_jackpot']); echo "- bet_id={$betId} user_id={$uid} streak_at_bet={$streakAtBet} level={$level} odds_factor={$odds} win_amount={$winNorm}" . " is_jackpot_by_streak=" . ($isJackpotByStreak ? '1' : '0') . " payout_pending_review=" . (!empty($computed['payout_pending_review']) ? '1' : '0') . " is_jackpot=" . (!empty($computed['is_jackpot']) ? '1' : '0') . PHP_EOL; } echo PHP_EOL . "summary: any_jackpot=" . ($anyJackpot ? '1' : '0') . PHP_EOL;