isSuccess() || $context->isDatabaseOperationNeeded() || !empty($context->getVoice()->message)) { return CanHandleResult::no(); } return CanHandleResult::yes(); } /** * 具体处理逻辑:最后节点处理 */ protected function doHandle(ProcessContext $context): ProcessContext { if (!$context->isSuccess() || $context->isDatabaseOperationNeeded() || !empty($context->getVoice()->message)) { return $context; } // 无节点命中 Logger::debug('当前刷卡无节点命中 currentStep={} readerType={} expectedNextStep={}', [ $context->getCurrentStep() ?: '(空)', $context->getReader()->type, $context->getVoice()->expectedNextStep ]); // 如果有预期的下一步,则返回错误 if ($context->getVoice()->hasExpectedNextStep()) { Logger::debug("节点期望: {$context->getVoice()->expectedNextStep->value}"); return $context->builder()->error($context->getVoice()->expectedNextStep)->build(); } // 异常流程 Logger::error("异常流程,所有节点处理完成,无匹配节点并且无预期的下一步"); return $context->builder()->error(VoiceMessage::UNKNOWN_ERROR)->build(); } }