args[0] ?? 'land'; $land = $this->validation->$landKey ?? null; if (!$land) { $this->addError('土地信息不存在,请先验证土地归属'); return false; } try { // 检查土地状态是否为空闲状态(允许升级) // 只有空闲状态的土地才能进行升级 if ($land->status !== LAND_STATUS::IDLE->value) { $statusName = $this->getStatusName($land->status); $errorMsg = "土地当前状态为{$statusName},不允许升级"; $this->addError($errorMsg); return false; } return true; } catch (\Exception $e) { $this->addError('验证土地升级状态时发生错误: ' . $e->getMessage()); return false; } } /** * 获取状态名称 * * @param int $status 状态值 * @return string 状态名称 */ private function getStatusName(int $status): string { return match ($status) { LAND_STATUS::IDLE->value => '空闲', LAND_STATUS::PLANTING->value => '种植中', LAND_STATUS::HARVESTABLE->value => '可收获', LAND_STATUS::WITHERED->value => '枯萎', LAND_STATUS::DISASTER->value => '灾害', default => '未知状态' }; } }