优化一键测试权重

This commit is contained in:
2026-03-16 11:23:28 +08:00
parent 72b43759f1
commit 76aa9bde8b
9 changed files with 47 additions and 14 deletions

View File

@@ -195,12 +195,19 @@ class DiceRewardLogic
continue;
}
$id = isset($item['id']) ? (int) $item['id'] : 0;
$weight = isset($item['weight']) ? (int) $item['weight'] : self::WEIGHT_MIN;
if ($id <= 0) {
$id = isset($item['reward_id']) ? (int) $item['reward_id'] : 0;
}
if ($id <= 0) {
throw new ApiException('存在无效的 DiceReward id');
}
$weight = isset($item['weight']) ? (int) $item['weight'] : self::WEIGHT_MIN;
$weight = max(self::WEIGHT_MIN, min(self::WEIGHT_MAX, $weight));
DiceReward::where('id', $id)->update(['weight' => $weight]);
$model = DiceReward::find($id);
if ($model !== null) {
$model->weight = $weight;
$model->save();
}
}
DiceReward::refreshCache();
}

View File

@@ -152,6 +152,7 @@ class DiceRewardConfigRecordLogic extends BaseLogic
->where('grid_number', $gridNumber)
->update(['weight' => $weight]);
}
DiceRewardConfig::refreshCache();
}
$tiers = ['T1', 'T2', 'T3', 'T4', 'T5'];

View File

@@ -7,6 +7,8 @@ use app\api\logic\PlayStartLogic;
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
use app\dice\model\play_record_test\DicePlayRecordTest;
use app\dice\model\reward_config_record\DiceRewardConfigRecord;
use app\dice\model\reward\DiceReward;
use app\dice\model\reward_config\DiceRewardConfig;
use support\Log;
/**
@@ -82,6 +84,10 @@ class WeightTestRunner
}
}
// 每次测试开始前清空进程内静态缓存,强制从共享缓存读取最新 BIGWIN/奖励配置,与数据库一致
DiceRewardConfig::clearRequestInstance();
DiceReward::clearRequestInstance();
$playLogic = new PlayStartLogic();
$resultCounts = [];
$tierCounts = [];