From 8684fdc9f08ae9898e223cb2d1667a7fad4bdcb1 Mon Sep 17 00:00:00 2001 From: zhenhui <1276357500@qq.com> Date: Fri, 20 Mar 2026 15:03:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BD=93=E5=89=8D=E5=BD=A9?= =?UTF-8?q?=E9=87=91=E6=B1=A0=E7=B4=AF=E5=8A=A0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/app/api/logic/PlayStartLogic.php | 11 ++++++++--- .../logic/reward_config_record/WeightTestRunner.php | 13 +++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/server/app/api/logic/PlayStartLogic.php b/server/app/api/logic/PlayStartLogic.php index 945b329..e8c34f9 100644 --- a/server/app/api/logic/PlayStartLogic.php +++ b/server/app/api/logic/PlayStartLogic.php @@ -77,13 +77,18 @@ class PlayStartLogic 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) ->where('lottery_config_id', $configType0->id) ->where('status', self::RECORD_STATUS_SUCCESS); $playerWinSum = (float) $playerQuery->sum('win_coin'); - $playerPlayCount = (int) $playerQuery->count(); - $playerProfitTotal = $playerWinSum - 100.0 * $playerPlayCount; + $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; $safetyLine = (int) ($configType0->safety_line ?? 0); $killEnabled = ((int) ($configType0->kill_enabled ?? 1)) === 1; // 盈利>=安全线且开启杀分:付费/免费都用 killScore;盈利<安全线:付费用玩家权重,免费用 killScore(无则用 default) diff --git a/server/app/dice/logic/reward_config_record/WeightTestRunner.php b/server/app/dice/logic/reward_config_record/WeightTestRunner.php index 010256e..3e7af65 100644 --- a/server/app/dice/logic/reward_config_record/WeightTestRunner.php +++ b/server/app/dice/logic/reward_config_record/WeightTestRunner.php @@ -80,7 +80,8 @@ class WeightTestRunner DiceRewardConfig::clearRequestInstance(); DiceReward::clearRequestInstance(); - //“玩家”盈利: 玩家累计盈利:仅统计 lottery_config_id=default 的成功对局(win_coin - 100),与 PlayStartLogic 一致 + //“玩家”盈利:仅统计 lottery_config_id=default 的成功对局。 + // 付费券:盈利 = win_coin - 100/局;免费券:盈利 = win_coin(不扣除 100/局) $playerProfitTotal = 0.0; $playLogic = new PlayStartLogic(); @@ -114,6 +115,7 @@ class WeightTestRunner } for ($i = 0; $i < $freeS; $i++) { $row = $playLogic->simulateOnePlay($freeConfig, 0, 1, null); + $this->accumulateProfitForDefault($row, 1, $freeConfig, $configType0, $playerProfitTotal); $this->aggregate($row, $resultCounts, $tierCounts); $buffer[] = $this->rowForInsert($row, $recordId); $done++; @@ -121,6 +123,7 @@ class WeightTestRunner } for ($i = 0; $i < $freeN; $i++) { $row = $playLogic->simulateOnePlay($freeConfig, 1, 1, null); + $this->accumulateProfitForDefault($row, 1, $freeConfig, $configType0, $playerProfitTotal); $this->aggregate($row, $resultCounts, $tierCounts); $buffer[] = $this->rowForInsert($row, $recordId); $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 $configType0 name=default 的彩金池 */ 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; } 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; } }