优化一键测试权重

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();
}