diff --git a/saiadmin-artd/src/locales/langs/en/dice/reward.json b/saiadmin-artd/src/locales/langs/en/dice/reward.json index 25c2229..085a473 100644 --- a/saiadmin-artd/src/locales/langs/en/dice/reward.json +++ b/saiadmin-artd/src/locales/langs/en/dice/reward.json @@ -73,7 +73,7 @@ "labelLotteryTypeFree": "Free tier pool", "labelAnte": "Ante", "placeholderAnte": "Select ante config", - "anteRandomOption": "Random (pick from channel ante configs)", + "anteRandomOption": "Random (each paid spin picks independently from channel ante configs)", "placeholderPaidPool": "Leave empty to set T1–T5 weights manually", "placeholderFreePool": "Leave empty to set T1–T5 weights manually", "selectedPoolHint": "Selected pool: {name}", diff --git a/saiadmin-artd/src/locales/langs/zh/dice/reward.json b/saiadmin-artd/src/locales/langs/zh/dice/reward.json index e981806..1f9ee80 100644 --- a/saiadmin-artd/src/locales/langs/zh/dice/reward.json +++ b/saiadmin-artd/src/locales/langs/zh/dice/reward.json @@ -73,7 +73,7 @@ "labelLotteryTypeFree": "免费档位奖池", "labelAnte": "底注", "placeholderAnte": "请选择底注配置", - "anteRandomOption": "随机(从当前渠道底注配置中抽取)", + "anteRandomOption": "随机(每局付费抽奖从当前渠道底注配置中独立抽取)", "placeholderPaidPool": "不选则下方手动设定 T1–T5 档位权重", "placeholderFreePool": "不选则下方手动设定 T1–T5 档位权重", "selectedPoolHint": "已选奖池:{name}", diff --git a/server/app/dice/logic/reward_config_record/DiceRewardConfigRecordLogic.php b/server/app/dice/logic/reward_config_record/DiceRewardConfigRecordLogic.php index 20b6312..b868543 100644 --- a/server/app/dice/logic/reward_config_record/DiceRewardConfigRecordLogic.php +++ b/server/app/dice/logic/reward_config_record/DiceRewardConfigRecordLogic.php @@ -268,7 +268,8 @@ class DiceRewardConfigRecordLogic extends DiceBaseLogic is_array($params) ? $params : [] ); $allowed = [100, 500, 1000, 5000]; - $ante = $this->resolveWeightTestAnte($params, $deptId); + $anteRandom = !empty($params['ante_random']); + $ante = $anteRandom ? 0 : $this->resolveWeightTestAnte($params, $deptId); $lotteryConfigId = isset($params['lottery_config_id']) ? (int) $params['lottery_config_id'] : 0; $paidConfigId = isset($params['paid_lottery_config_id']) ? (int) $params['paid_lottery_config_id'] : 0; diff --git a/server/app/dice/logic/reward_config_record/WeightTestRunner.php b/server/app/dice/logic/reward_config_record/WeightTestRunner.php index 568a860..5719455 100644 --- a/server/app/dice/logic/reward_config_record/WeightTestRunner.php +++ b/server/app/dice/logic/reward_config_record/WeightTestRunner.php @@ -5,6 +5,8 @@ namespace app\dice\logic\reward_config_record; use app\api\logic\PlayStartLogic; use app\dice\helper\AdminScopeHelper; +use app\dice\helper\ConfigScopeEditHelper; +use app\dice\model\ante_config\DiceAnteConfig; use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig; use app\dice\model\play_record_test\DicePlayRecordTest; use app\dice\model\reward_config_record\DiceRewardConfigRecord; @@ -60,7 +62,11 @@ class WeightTestRunner return; } + $anteRandom = $this->isAnteRandomMode($record); $ante = is_numeric($record->ante ?? null) ? intval($record->ante) : 1; + if (!$anteRandom && $ante <= 0) { + $ante = 1; + } $paidS = (int) ($record->paid_s_count ?? 0); $paidN = (int) ($record->paid_n_count ?? 0); $total = $paidS + $paidN; @@ -140,6 +146,7 @@ class WeightTestRunner $paidS, $paidN, $ante, + $anteRandom, $configType0, $paidPoolConfig, $freePoolConfig, @@ -180,6 +187,7 @@ class WeightTestRunner int $paidS, int $paidN, int $ante, + bool $anteRandom, $defaultPoolConfig, $paidPoolConfig, $freePoolConfig, @@ -196,17 +204,22 @@ class WeightTestRunner ): void { $queue = []; for ($i = 0; $i < $paidS; $i++) { - $queue[] = ['paid', 0, $ante]; + $queue[] = ['paid', 0, $anteRandom ? 0 : $ante]; } for ($i = 0; $i < $paidN; $i++) { - $queue[] = ['paid', 1, $ante]; + $queue[] = ['paid', 1, $anteRandom ? 0 : $ante]; } $qi = 0; while ($qi < count($queue)) { $item = $queue[$qi]; $isPaid = $item[0] === 'paid'; $dir = $item[1]; - $playAnte = $item[2]; + $playAnte = (int) $item[2]; + if ($isPaid && $anteRandom) { + $playAnte = $this->pickRandomAnteMult($deptId); + } elseif ($playAnte <= 0) { + $playAnte = $ante > 0 ? $ante : 1; + } $lotteryType = $isPaid ? 0 : 1; if ($isPaid) { @@ -249,6 +262,36 @@ class WeightTestRunner } } + /** + * 是否启用「底注随机」:每局付费抽奖从当前渠道底注配置中独立抽取 mult + */ + private function isAnteRandomMode(DiceRewardConfigRecord $record): bool + { + $snap = $record->tier_weights_snapshot ?? null; + if (!is_array($snap)) { + return false; + } + + return !empty($snap['ante_random']); + } + + /** + * 从当前渠道 dice_ante_config 中随机取一条 mult + */ + private function pickRandomAnteMult(int $deptId): int + { + $anteQuery = DiceAnteConfig::field('id,mult')->order('mult', 'asc'); + ConfigScopeEditHelper::applyDeptIdWhere($anteQuery, $deptId); + $rows = $anteQuery->select()->toArray(); + if ($rows === []) { + return 1; + } + $picked = $rows[random_int(0, count($rows) - 1)]; + $mult = (int) ($picked['mult'] ?? 0); + + return $mult > 0 ? $mult : 1; + } + /** * 从 tier_weights_snapshot 读取付费/免费档位权重快照 */