args[0] ?? 'user_id'; $userId = $data[$userIdKey] ?? null; if (!$userId) { $this->addError('用户ID不能为空'); return false; } try { // 检查用户是否拥有该工具 $userItems = ItemService::getUserItems($userId, ['item_id' => $toolItemId]); if ($userItems->isEmpty()) { $this->addError('您没有该铲除工具'); return false; } $totalQuantity = $userItems->sum('quantity'); if ($totalQuantity <= 0) { $this->addError('铲除工具数量不足'); return false; } return true; } catch (\Exception $e) { $this->addError('验证铲除工具时发生错误: ' . $e->getMessage()); return false; } } }