feat(lottery): 扩展传统马来赔率、玩法结算与开注商短码支持
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user