feat(lottery): 扩展传统马来赔率、玩法结算与开注商短码支持
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
lotterLaravel E2E / e2e-api (push) Has been cancelled

This commit is contained in:
2026-07-10 17:04:28 +08:00
parent 2ea3e810a0
commit cbb18b976f
24 changed files with 320 additions and 45 deletions

View File

@@ -15,13 +15,43 @@ final class OddsStandardScopes
{
/** @var array<string, int> */
public const PRESET_ODDS_BY_SCOPE = [
'first' => 250_000,
'second' => 110_000,
'third' => 55_000,
'starter' => 22_000,
'consolation' => 6_500,
'first' => 25_000_000,
'second' => 10_000_000,
'third' => 5_000_000,
'starter' => 1_800_000,
'consolation' => 600_000,
];
/** Traditional Malaysia 4D defaults, in multiplier x 10,000. */
public static function presetOddsForPlay(string $playCode): array
{
if ($playCode === 'small') {
return [
'first' => 35_000_000,
'second' => 20_000_000,
'third' => 10_000_000,
'starter' => 0,
'consolation' => 0,
];
}
if (str_starts_with($playCode, 'pos_3')) {
return self::scale(self::PRESET_ODDS_BY_SCOPE, 10);
}
if (str_starts_with($playCode, 'pos_2')) {
return self::scale(self::PRESET_ODDS_BY_SCOPE, 100);
}
return self::PRESET_ODDS_BY_SCOPE;
}
/** @param array<string, int> $odds @return array<string, int> */
private static function scale(array $odds, int $divisor): array
{
return array_map(static fn (int $value): int => (int) floor($value / $divisor), $odds);
}
/** @var list<string> */
public const SCOPE_KEYS = ['first', 'second', 'third', 'starter', 'consolation'];
@@ -100,7 +130,7 @@ final class OddsStandardScopes
$rebate = $dimensionCommissions[$key]['rebate'] ?? 0;
$commission = $dimensionCommissions[$key]['commission'] ?? 0;
foreach (self::PRESET_ODDS_BY_SCOPE as $scope => $oddsValue) {
foreach (self::presetOddsForPlay($playCode) as $scope => $oddsValue) {
$exists = OddsItem::query()
->where('version_id', $vid)
->where('provider_code', $providerCode)