优化一键测试权重
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user