feat: 扩展奖池、风控与报表能力,新增对账补偿、广播和人工操作接口
This commit is contained in:
@@ -30,11 +30,12 @@ final class JackpotBurstAllocator
|
||||
|
||||
$thresholdOk = (int) $pool->current_amount >= (int) $pool->trigger_threshold;
|
||||
$gapOk = $this->gapTriggerMet($pool);
|
||||
if (! $thresholdOk && ! $gapOk) {
|
||||
$comboOk = $this->comboTriggerMet($pool, $winners);
|
||||
if (! $thresholdOk && ! $gapOk && ! $comboOk) {
|
||||
return ['allocations' => [], 'pool_payout' => 0, 'trigger' => null];
|
||||
}
|
||||
|
||||
$trigger = $thresholdOk ? 'threshold' : 'forced_gap';
|
||||
$trigger = $thresholdOk ? 'threshold' : ($gapOk ? 'forced_gap' : 'play_combo');
|
||||
|
||||
$poolBefore = (int) $pool->current_amount;
|
||||
$poolPayout = (int) floor($poolBefore * (float) $pool->payout_rate);
|
||||
@@ -81,6 +82,8 @@ final class JackpotBurstAllocator
|
||||
'trigger_snapshot_json' => [
|
||||
'threshold_ok' => $thresholdOk,
|
||||
'gap_ok' => $gapOk,
|
||||
'combo_ok' => $comboOk,
|
||||
'combo_trigger_play_codes' => $this->comboTriggerPlayCodes($pool),
|
||||
'pool_amount_before' => $poolBefore,
|
||||
'payout_rate' => (string) $pool->payout_rate,
|
||||
],
|
||||
@@ -104,4 +107,35 @@ final class JackpotBurstAllocator
|
||||
|
||||
return $count >= $gap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection<int, array{item: TicketItem, matched_tier: ?string, gross_win: int}> $winners
|
||||
*/
|
||||
private function comboTriggerMet(JackpotPool $pool, Collection $winners): bool
|
||||
{
|
||||
$codes = $this->comboTriggerPlayCodes($pool);
|
||||
if ($codes === []) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $winners->contains(
|
||||
fn (array $r): bool => in_array((string) $r['item']->play_code, $codes, true),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
private function comboTriggerPlayCodes(JackpotPool $pool): array
|
||||
{
|
||||
$raw = $pool->combo_trigger_play_codes;
|
||||
if (! is_array($raw)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return array_values(array_filter(
|
||||
array_map(fn ($v): string => strtolower(trim((string) $v)), $raw),
|
||||
fn (string $v): bool => $v !== '',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user