args[0] ?? 'land'; $land = $this->validation->$landKey ?? null; if (!$land) { $this->addError('土地信息不存在,请先验证土地归属'); return false; } // 不再 try { // 检查土地状态是否为可收获状态 if ($land->status !== LAND_STATUS::HARVESTABLE->value) { $statusName = $this->getStatusName($land->status); $this->addError("土地当前状态为{$statusName},不允许收获"); return false; } return true; } catch (\Exception $e) { $this->addError('验证收获状态时发生错误: ' . $e->getMessage()); return false; } } /** * 获取状态名称 * * @param int $status 状态值 * @return string 状态名称 */ private function getStatusName(int $status): string { // 使用LAND_STATUS枚举的getName方法,确保状态名称一致性 return LAND_STATUS::getName($status); } }