Fix horse race seed pool payouts
This commit is contained in:
@@ -70,6 +70,7 @@ class CloseHorseRaceJob implements ShouldQueue
|
||||
|
||||
$config = GameConfig::forGame('horse_racing')?->params ?? [];
|
||||
$houseTake = (int) ($config['house_take_percent'] ?? 5);
|
||||
$seedPool = (int) ($config['seed_pool'] ?? 0);
|
||||
$winnerId = (int) $race->winner_horse_id;
|
||||
|
||||
// 按马匹统计各匹下注金额
|
||||
@@ -82,7 +83,7 @@ class CloseHorseRaceJob implements ShouldQueue
|
||||
|
||||
$totalPool = array_sum($horsePools);
|
||||
$winnerPool = (int) ($horsePools[$winnerId] ?? 0);
|
||||
$netPool = (int) ($totalPool * (1 - $houseTake / 100));
|
||||
$distributablePool = HorseRace::calcDistributablePool($horsePools, $houseTake, $seedPool, $winnerPool);
|
||||
|
||||
// 结算:遍历所有下注记录
|
||||
$bets = HorseBet::query()
|
||||
@@ -93,7 +94,7 @@ class CloseHorseRaceJob implements ShouldQueue
|
||||
|
||||
$totalPayout = 0;
|
||||
|
||||
DB::transaction(function () use ($bets, $winnerId, $netPool, $winnerPool, $currency, &$totalPayout) {
|
||||
DB::transaction(function () use ($bets, $winnerId, $distributablePool, $winnerPool, $currency, &$totalPayout) {
|
||||
foreach ($bets as $bet) {
|
||||
if ((int) $bet->horse_id !== $winnerId) {
|
||||
// 未中奖(本金已在下注时扣除)
|
||||
@@ -104,7 +105,7 @@ class CloseHorseRaceJob implements ShouldQueue
|
||||
|
||||
// 中奖:按注额比例分配净注池
|
||||
if ($winnerPool > 0) {
|
||||
$payout = (int) round($netPool * ($bet->amount / $winnerPool));
|
||||
$payout = (int) round($distributablePool * ($bet->amount / $winnerPool));
|
||||
} else {
|
||||
$payout = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user