1.优化一键测试权重时每次压注的底注为随机

This commit is contained in:
2026-06-04 15:00:55 +08:00
parent f8969097d7
commit 6ef3663957
4 changed files with 50 additions and 6 deletions

View File

@@ -73,7 +73,7 @@
"labelLotteryTypeFree": "Free tier pool", "labelLotteryTypeFree": "Free tier pool",
"labelAnte": "Ante", "labelAnte": "Ante",
"placeholderAnte": "Select ante config", "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 T1T5 weights manually", "placeholderPaidPool": "Leave empty to set T1T5 weights manually",
"placeholderFreePool": "Leave empty to set T1T5 weights manually", "placeholderFreePool": "Leave empty to set T1T5 weights manually",
"selectedPoolHint": "Selected pool: {name}", "selectedPoolHint": "Selected pool: {name}",

View File

@@ -73,7 +73,7 @@
"labelLotteryTypeFree": "免费档位奖池", "labelLotteryTypeFree": "免费档位奖池",
"labelAnte": "底注", "labelAnte": "底注",
"placeholderAnte": "请选择底注配置", "placeholderAnte": "请选择底注配置",
"anteRandomOption": "随机(从当前渠道底注配置中抽取)", "anteRandomOption": "随机(每局付费抽奖从当前渠道底注配置中独立抽取)",
"placeholderPaidPool": "不选则下方手动设定 T1T5 档位权重", "placeholderPaidPool": "不选则下方手动设定 T1T5 档位权重",
"placeholderFreePool": "不选则下方手动设定 T1T5 档位权重", "placeholderFreePool": "不选则下方手动设定 T1T5 档位权重",
"selectedPoolHint": "已选奖池:{name}", "selectedPoolHint": "已选奖池:{name}",

View File

@@ -268,7 +268,8 @@ class DiceRewardConfigRecordLogic extends DiceBaseLogic
is_array($params) ? $params : [] is_array($params) ? $params : []
); );
$allowed = [100, 500, 1000, 5000]; $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; $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; $paidConfigId = isset($params['paid_lottery_config_id']) ? (int) $params['paid_lottery_config_id'] : 0;

View File

@@ -5,6 +5,8 @@ namespace app\dice\logic\reward_config_record;
use app\api\logic\PlayStartLogic; use app\api\logic\PlayStartLogic;
use app\dice\helper\AdminScopeHelper; 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\lottery_pool_config\DiceLotteryPoolConfig;
use app\dice\model\play_record_test\DicePlayRecordTest; use app\dice\model\play_record_test\DicePlayRecordTest;
use app\dice\model\reward_config_record\DiceRewardConfigRecord; use app\dice\model\reward_config_record\DiceRewardConfigRecord;
@@ -60,7 +62,11 @@ class WeightTestRunner
return; return;
} }
$anteRandom = $this->isAnteRandomMode($record);
$ante = is_numeric($record->ante ?? null) ? intval($record->ante) : 1; $ante = is_numeric($record->ante ?? null) ? intval($record->ante) : 1;
if (!$anteRandom && $ante <= 0) {
$ante = 1;
}
$paidS = (int) ($record->paid_s_count ?? 0); $paidS = (int) ($record->paid_s_count ?? 0);
$paidN = (int) ($record->paid_n_count ?? 0); $paidN = (int) ($record->paid_n_count ?? 0);
$total = $paidS + $paidN; $total = $paidS + $paidN;
@@ -140,6 +146,7 @@ class WeightTestRunner
$paidS, $paidS,
$paidN, $paidN,
$ante, $ante,
$anteRandom,
$configType0, $configType0,
$paidPoolConfig, $paidPoolConfig,
$freePoolConfig, $freePoolConfig,
@@ -180,6 +187,7 @@ class WeightTestRunner
int $paidS, int $paidS,
int $paidN, int $paidN,
int $ante, int $ante,
bool $anteRandom,
$defaultPoolConfig, $defaultPoolConfig,
$paidPoolConfig, $paidPoolConfig,
$freePoolConfig, $freePoolConfig,
@@ -196,17 +204,22 @@ class WeightTestRunner
): void { ): void {
$queue = []; $queue = [];
for ($i = 0; $i < $paidS; $i++) { for ($i = 0; $i < $paidS; $i++) {
$queue[] = ['paid', 0, $ante]; $queue[] = ['paid', 0, $anteRandom ? 0 : $ante];
} }
for ($i = 0; $i < $paidN; $i++) { for ($i = 0; $i < $paidN; $i++) {
$queue[] = ['paid', 1, $ante]; $queue[] = ['paid', 1, $anteRandom ? 0 : $ante];
} }
$qi = 0; $qi = 0;
while ($qi < count($queue)) { while ($qi < count($queue)) {
$item = $queue[$qi]; $item = $queue[$qi];
$isPaid = $item[0] === 'paid'; $isPaid = $item[0] === 'paid';
$dir = $item[1]; $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; $lotteryType = $isPaid ? 0 : 1;
if ($isPaid) { 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 读取付费/免费档位权重快照 * 从 tier_weights_snapshot 读取付费/免费档位权重快照
*/ */