feat: 增强奖池与钱包服务的多币种支持能力
更新 JackpotManualBurstService:在解析头奖中奖者时支持币种代码处理。 重构 SettlementBatchWorkflowService:按币种聚合玩家派奖金额,确保各币种结算准确入账。 修改 SettlementOrchestrator:按币种分别处理奖池爆奖流程,提升派奖准确性。 优化 TicketWalletService:在派奖幂等键中加入币种信息,避免多币种场景下的重复处理问题。 新增测试用例,验证多币种派奖场景及待处理交易的正确处理逻辑。
This commit is contained in:
@@ -68,7 +68,7 @@ final class JackpotManualBurstService
|
||||
}
|
||||
|
||||
$batch = $this->resolveSettlementBatch($draw);
|
||||
$winnerItems = $this->firstPrizeWinnerItems($batch);
|
||||
$winnerItems = $this->firstPrizeWinnerItems($batch, (string) $locked->currency_code);
|
||||
if ($winnerItems->isEmpty()) {
|
||||
throw new \RuntimeException('jackpot_manual_no_first_prize_winners');
|
||||
}
|
||||
@@ -170,17 +170,19 @@ final class JackpotManualBurstService
|
||||
/**
|
||||
* @return Collection<int, TicketItem>
|
||||
*/
|
||||
private function firstPrizeWinnerItems(SettlementBatch $batch): Collection
|
||||
private function firstPrizeWinnerItems(SettlementBatch $batch, string $currencyCode): Collection
|
||||
{
|
||||
$targetCurrency = strtoupper($currencyCode);
|
||||
$details = TicketSettlementDetail::query()
|
||||
->where('settlement_batch_id', $batch->id)
|
||||
->where('matched_prize_tier', 'first')
|
||||
->where('win_amount', '>', 0)
|
||||
->whereHas('ticketItem.order', fn ($q) => $q->where('currency_code', $targetCurrency))
|
||||
->with('ticketItem')
|
||||
->get();
|
||||
|
||||
return $details
|
||||
->map(fn (TicketSettlementDetail $d) => $d->ticketItem)
|
||||
->map(fn (TicketSettlementDetail $d): ?TicketItem => $d->ticketItem)
|
||||
->filter(fn (?TicketItem $item): bool => $item instanceof TicketItem)
|
||||
->values();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user