Fix horse race seed pool payouts
This commit is contained in:
@@ -51,6 +51,7 @@ class HorseRaceController extends Controller
|
||||
// 计算各马匹当前注额
|
||||
$config = GameConfig::forGame('horse_racing')?->params ?? [];
|
||||
$houseTake = (int) ($config['house_take_percent'] ?? 5);
|
||||
$seedPool = (int) ($config['seed_pool'] ?? 0);
|
||||
|
||||
$horsePools = HorseBet::query()
|
||||
->where('race_id', $race->id)
|
||||
@@ -59,13 +60,13 @@ class HorseRaceController extends Controller
|
||||
->pluck('pool', 'horse_id')
|
||||
->toArray();
|
||||
|
||||
$oddsMap = HorseRace::calcOdds($horsePools, $houseTake, $seedPool);
|
||||
|
||||
// 计算实时赔率
|
||||
$horses = $race->horses ?? [];
|
||||
$horsesWithBets = array_map(function ($horse) use ($horsePools, $houseTake) {
|
||||
$horsesWithBets = array_map(function ($horse) use ($horsePools, $oddsMap) {
|
||||
$horsePool = (int) ($horsePools[$horse['id']] ?? 0);
|
||||
$totalPool = array_sum(array_values($horsePools));
|
||||
$netPool = $totalPool * (1 - $houseTake / 100);
|
||||
$odds = $horsePool > 0 ? round($netPool / $horsePool, 2) : null;
|
||||
$odds = $horsePool > 0 ? ($oddsMap[$horse['id']] ?? null) : null;
|
||||
|
||||
return [
|
||||
'id' => $horse['id'],
|
||||
|
||||
Reference in New Issue
Block a user