Files
lotteryLaravel/app/Services/Settlement/OddsSnapshotReader.php

27 lines
625 B
PHP

<?php
namespace App\Services\Settlement;
/**
* 从注单赔率快照 JSON 读取各档赔率(阶段 5 落库结构,与 {@see PlayRuleEngine} 一致)。
*/
final class OddsSnapshotReader
{
/**
* @param list<array<string, mixed>>|null $snapshot
*/
public function oddsValueForScope(?array $snapshot, string $scope): int
{
if ($snapshot === null) {
return 0;
}
foreach ($snapshot as $row) {
if (($row['prize_scope'] ?? null) === $scope) {
return (int) ($row['odds_value'] ?? 0);
}
}
return 0;
}
}