addError("物品不存在"); return false; } // 检查是否为宝箱类型 if ($item->type !== ITEM_TYPE::CHEST) { $this->addError("该物品不是宝箱类型"); return false; } // 检查宝箱是否有配置 $chestConfig = ItemChestConfig::where('item_id', $itemId) ->where('is_active', true) ->first(); if (!$chestConfig) { $this->addError("宝箱没有配置或配置未激活"); return false; } // 检查是否配置了奖励组 if (!$chestConfig->reward_group_id) { $this->addError("宝箱没有配置奖励组"); return false; } // 将宝箱信息保存到验证对象中,供后续使用 $chestItemKey = $this->args[0] ?? null; if ($chestItemKey) { $this->validation->$chestItemKey = $item; } return true; } catch (\Exception $e) { $this->addError('验证宝箱物品时发生错误: ' . $e->getMessage()); return false; } } }