args[0] ?? 'user_id'; $upgradeConfigKey = $this->args[1] ?? 'upgrade_config'; $userId = $data[$userIdKey] ?? null; $upgradeConfig = $this->validation->$upgradeConfigKey ?? null; if (!$userId) { $this->addError('用户ID不能为空'); return false; } if (!$upgradeConfig) { $this->addError('升级配置不存在,请先验证升级路径'); return false; } try { // 获取目标土地类型 $targetLandType = FarmLandType::find($upgradeConfig->to_type_id); if (!$targetLandType) { $this->addError('目标土地类型不存在'); return false; } // 获取用户房屋信息 $farmUser = FarmUser::where('user_id', $userId)->first(); if (!$farmUser) { $this->addError('用户农场信息不存在'); return false; } // 检查房屋等级是否满足要求 if ($farmUser->house_level < $targetLandType->unlock_house_level) { $this->addError("房屋等级不足,需要{$targetLandType->unlock_house_level}级,当前{$farmUser->house_level}级"); return false; } return true; } catch (\Exception $e) { Log::error('验证房屋等级时发生错误', [ 'user_id' => $userId, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString() ]); $this->addError('验证房屋等级时发生错误: ' . $e->getMessage()); return false; } } }