优化彩金池杀分逻辑-根据彩金池玩家盈利判断而非玩家个人盈利判断

This commit is contained in:
2026-03-20 15:25:45 +08:00
parent ca620eb536
commit 8702cb0571
2 changed files with 21 additions and 30 deletions

View File

@@ -77,23 +77,14 @@ class PlayStartLogic
throw new ApiException('Lottery pool config not found (name=default required)');
}
// 玩家累计盈利:仅统计 lottery_config_id=default 的成功对局。
// 付费券:盈利按 win_coin - 100/局计算;免费券:不扣除 100/局,只计入 win_coin。
$playerQuery = DicePlayRecord::where('player_id', $playerId)
->where('lottery_config_id', $configType0->id)
->where('status', self::RECORD_STATUS_SUCCESS);
$playerWinSum = (float) $playerQuery->sum('win_coin');
$paidPlayCount = (int) DicePlayRecord::where('player_id', $playerId)
->where('lottery_config_id', $configType0->id)
->where('lottery_type', self::LOTTERY_TYPE_PAID)
->where('status', self::RECORD_STATUS_SUCCESS)
->count();
$playerProfitTotal = $playerWinSum - 100.0 * $paidPlayCount;
// 彩金池累计盈利:用于判断是否触发杀分(不再依赖单个玩家累计盈利)
// 该值来自 dice_lottery_pool_config.profit_amount
$poolProfitTotal = $configType0->profit_amount ?? 0;
$safetyLine = (int) ($configType0->safety_line ?? 0);
$killEnabled = ((int) ($configType0->kill_enabled ?? 1)) === 1;
// 盈利>=安全线且开启杀分:付费/免费都用 killScore盈利<安全线:付费用玩家权重,免费用 killScore无则用 default
// 记录 lottery_config_id用池权重时记对应池付费用玩家权重时记 default
$usePoolWeights = ($ticketType === self::LOTTERY_TYPE_PAID && $killEnabled && $playerProfitTotal >= $safetyLine && $configType1 !== null)
$usePoolWeights = ($ticketType === self::LOTTERY_TYPE_PAID && $killEnabled && $poolProfitTotal >= $safetyLine && $configType1 !== null)
|| ($ticketType === self::LOTTERY_TYPE_FREE);
$config = $usePoolWeights
? (($ticketType === self::LOTTERY_TYPE_FREE && $configType1 === null) ? $configType0 : $configType1)
@@ -274,8 +265,10 @@ class PlayStartLogic
$p->save();
// 玩家累计盈利累加在 type=0 彩金池上:每局按“当前中奖金额(含 BIGWIN - 抽奖券费用 100”
$perPlayProfit = $winCoin - 100.0;
// 彩金池累计盈利累加在 name=default 彩金池上:
// 付费券:每局按“当前中奖金额(含 BIGWIN - 抽奖券费用 100”
// 免费券:取消票价成本 100只计入中奖金额
$perPlayProfit = ($ticketType === self::LOTTERY_TYPE_PAID) ? ($winCoin - 100.0) : $winCoin;
$addProfit = $perPlayProfit;
try {
DiceLotteryPoolConfig::where('id', $type0ConfigId)->update([