feat: 为赔率项增加 dimension 字段并支持按维度配置佣金,调整后台配置导航权限
This commit is contained in:
@@ -48,9 +48,11 @@ final class PlayRuleEngine
|
||||
|
||||
$unitBetAmount = $this->resolveUnitBetAmount($playCode, $amount, $combinationCount);
|
||||
$totalBetAmount = $this->resolveTotalBetAmount($playCode, $amount, $unitBetAmount, $combinationCount);
|
||||
$dimensionInt = $this->toDimensionInt(is_string($dimension) ? $dimension : null, $playConfig);
|
||||
$primaryOdds = $this->pickPrimaryOdds($oddsItems);
|
||||
$rebateRate = (float) $primaryOdds->rebate_rate;
|
||||
$commissionRate = (float) $primaryOdds->commission_rate;
|
||||
// 佣金按维度(2D/3D/4D)配置:从 odds_items 中查找匹配维度的佣金率
|
||||
$commissionRate = $this->pickCommissionByDimension($oddsItems, $dimensionInt);
|
||||
$actualDeductAmount = max(0, (int) floor($totalBetAmount * (1 - $rebateRate)));
|
||||
$maxOdds = $oddsItems->max(fn (OddsItem $row) => (int) $row->odds_value) ?? 0;
|
||||
$estimatedPayoutPerCombo = (int) floor($unitBetAmount * ($maxOdds / 10000));
|
||||
@@ -302,6 +304,28 @@ final class PlayRuleEngine
|
||||
return $oddsItems->firstOrFail();
|
||||
}
|
||||
|
||||
/**
|
||||
* 按维度(2D/3D/4D)获取佣金率
|
||||
*
|
||||
* @param Collection<int, OddsItem> $oddsItems
|
||||
*/
|
||||
private function pickCommissionByDimension(Collection $oddsItems, ?int $dimension): float
|
||||
{
|
||||
if ($dimension === null) {
|
||||
// 如果维度为空,返回第一个 odds item 的佣金率(向后兼容)
|
||||
return (float) ($oddsItems->first()?->commission_rate ?? 0);
|
||||
}
|
||||
|
||||
// 查找匹配维度的 odds item
|
||||
$dimensionItem = $oddsItems->firstWhere('dimension', $dimension);
|
||||
if ($dimensionItem !== null) {
|
||||
return (float) $dimensionItem->commission_rate;
|
||||
}
|
||||
|
||||
// 如果没有找到匹配维度的,返回第一个的佣金率(向后兼容)
|
||||
return (float) ($oddsItems->first()?->commission_rate ?? 0);
|
||||
}
|
||||
|
||||
private function toDimensionInt(?string $dimension, PlayConfigItem $playConfig): ?int
|
||||
{
|
||||
return match ($dimension) {
|
||||
|
||||
Reference in New Issue
Block a user