LOG_MODULE, 'do'); // 根据参数处理具体逻辑 // 通过具体参数获取模型等 // 这里的逻辑会在 ConsumerProcess 进程中执行 $res = $this->do(); LogUtil::info('处理结果', $this->LOG_MODULE, 'do', [ 'code' => $res, 'message' => $this->getMessage(), 'data' => $this->getData(), ]); return $res; } /** * 开始工作 * @return true */ protected function do(): bool { // 业务代码 return $this->success('执行成功'); } /** * 返回成功结果 * @param string $message * @param mixed $data * @return bool */ protected function success(string $message = 'success', mixed $data = []): bool { $this->message = $message; $this->data = $data; return true; } /** * 返回失败结果 * @param string $message * @param mixed $data * @return bool */ protected function error(string $message = 'error', mixed $data = []): bool { $this->message = $message; $this->data = $data; return false; } /** * 获取成功数据 * @return mixed */ public function getData(): mixed { return $this->data; } /** * 获取消息 * @return string */ public function getMessage(): string { return $this->message; } }