优化当前彩金池累加逻辑

This commit is contained in:
2026-03-20 15:03:18 +08:00
parent d72868eb76
commit 8684fdc9f0
2 changed files with 17 additions and 7 deletions

View File

@@ -77,13 +77,18 @@ class PlayStartLogic
throw new ApiException('Lottery pool config not found (name=default required)'); throw new ApiException('Lottery pool config not found (name=default required)');
} }
// 玩家累计盈利:仅统计 lottery_config_id=type=0 的成功对局(中奖金额-100*局数) // 玩家累计盈利:仅统计 lottery_config_id=default 的成功对局。
// 付费券:盈利按 win_coin - 100/局计算;免费券:不扣除 100/局,只计入 win_coin。
$playerQuery = DicePlayRecord::where('player_id', $playerId) $playerQuery = DicePlayRecord::where('player_id', $playerId)
->where('lottery_config_id', $configType0->id) ->where('lottery_config_id', $configType0->id)
->where('status', self::RECORD_STATUS_SUCCESS); ->where('status', self::RECORD_STATUS_SUCCESS);
$playerWinSum = (float) $playerQuery->sum('win_coin'); $playerWinSum = (float) $playerQuery->sum('win_coin');
$playerPlayCount = (int) $playerQuery->count(); $paidPlayCount = (int) DicePlayRecord::where('player_id', $playerId)
$playerProfitTotal = $playerWinSum - 100.0 * $playerPlayCount; ->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;
$safetyLine = (int) ($configType0->safety_line ?? 0); $safetyLine = (int) ($configType0->safety_line ?? 0);
$killEnabled = ((int) ($configType0->kill_enabled ?? 1)) === 1; $killEnabled = ((int) ($configType0->kill_enabled ?? 1)) === 1;
// 盈利>=安全线且开启杀分:付费/免费都用 killScore盈利<安全线:付费用玩家权重,免费用 killScore无则用 default // 盈利>=安全线且开启杀分:付费/免费都用 killScore盈利<安全线:付费用玩家权重,免费用 killScore无则用 default

View File

@@ -80,7 +80,8 @@ class WeightTestRunner
DiceRewardConfig::clearRequestInstance(); DiceRewardConfig::clearRequestInstance();
DiceReward::clearRequestInstance(); DiceReward::clearRequestInstance();
//“玩家”盈利: 玩家累计盈利:仅统计 lottery_config_id=default 的成功对局win_coin - 100与 PlayStartLogic 一致 //“玩家”盈利:仅统计 lottery_config_id=default 的成功对局
// 付费券:盈利 = win_coin - 100/局;免费券:盈利 = win_coin不扣除 100/局)
$playerProfitTotal = 0.0; $playerProfitTotal = 0.0;
$playLogic = new PlayStartLogic(); $playLogic = new PlayStartLogic();
@@ -114,6 +115,7 @@ class WeightTestRunner
} }
for ($i = 0; $i < $freeS; $i++) { for ($i = 0; $i < $freeS; $i++) {
$row = $playLogic->simulateOnePlay($freeConfig, 0, 1, null); $row = $playLogic->simulateOnePlay($freeConfig, 0, 1, null);
$this->accumulateProfitForDefault($row, 1, $freeConfig, $configType0, $playerProfitTotal);
$this->aggregate($row, $resultCounts, $tierCounts); $this->aggregate($row, $resultCounts, $tierCounts);
$buffer[] = $this->rowForInsert($row, $recordId); $buffer[] = $this->rowForInsert($row, $recordId);
$done++; $done++;
@@ -121,6 +123,7 @@ class WeightTestRunner
} }
for ($i = 0; $i < $freeN; $i++) { for ($i = 0; $i < $freeN; $i++) {
$row = $playLogic->simulateOnePlay($freeConfig, 1, 1, null); $row = $playLogic->simulateOnePlay($freeConfig, 1, 1, null);
$this->accumulateProfitForDefault($row, 1, $freeConfig, $configType0, $playerProfitTotal);
$this->aggregate($row, $resultCounts, $tierCounts); $this->aggregate($row, $resultCounts, $tierCounts);
$buffer[] = $this->rowForInsert($row, $recordId); $buffer[] = $this->rowForInsert($row, $recordId);
$done++; $done++;
@@ -139,17 +142,19 @@ class WeightTestRunner
} }
/** /**
* 仅当付费抽奖且使用 default 池时累加玩家盈利win_coin - 100,与 PlayStartLogic 一致 * 仅当使用 default 池lottery_config_id=default时累加玩家盈利,与 PlayStartLogic 一致
* @param int $lotteryType 0=付费券1=免费券
* @param object $usedConfig 本次使用的奖池配置 * @param object $usedConfig 本次使用的奖池配置
* @param object $configType0 name=default 的彩金池 * @param object $configType0 name=default 的彩金池
*/ */
private function accumulateProfitForDefault(array $row, int $lotteryType, $usedConfig, $configType0, float &$playerProfitTotal): void private function accumulateProfitForDefault(array $row, int $lotteryType, $usedConfig, $configType0, float &$playerProfitTotal): void
{ {
if ($lotteryType !== 0 || $usedConfig === null || $configType0 === null || !isset($row['win_coin'])) { if (($lotteryType !== 0 && $lotteryType !== 1) || $usedConfig === null || $configType0 === null || !isset($row['win_coin'])) {
return; return;
} }
if ((int) $usedConfig->id === (int) $configType0->id) { if ((int) $usedConfig->id === (int) $configType0->id) {
$playerProfitTotal += (float) $row['win_coin'] - 100.0; $winCoin = (float) $row['win_coin'];
$playerProfitTotal += $lotteryType === 0 ? ($winCoin - 100.0) : $winCoin;
} }
} }