'U8PO_PomainSave', 2 => 'U8SaleOrderSave', ]; public function __construct($data) { $this->data = $data; } public function handle() { try { $function = $this->function[$this->data['type']] ?? ''; if(empty($function)) return; //调用同步方法 $this->$function(); } catch (\Throwable $e) { $this->delete(); } } //采购 private function U8PO_PomainSave(){ $service = new U8ServerService(); if(! empty($service->error)) { $service->finalSettle($this->data['id'], U8Job::one, $service->error); return; } $service->U8PO_PomainSave($this->data['id'], $this->data['user_name']); } //销售(合同) private function U8SaleOrderSave(){ $service = new U8ServerService(); if(! empty($service->error)) { $service->finalSettle($this->data['id'], U8Job::two, $service->error); return; } $service->U8SaleOrderSave($this->data['id'], $this->data['user_name']); } // public function failed($exception) // { // // 记录失败错误信息到日志或其他媒介 // $errorMessage = $exception->getFile() . $exception->getMessage() . $exception->getLine(); // $this->recordErrorTable($errorMessage); // } private function recordErrorTable($msg){ $data = $this->data; ErrorTable::insert([ 'msg' => $msg, 'data' => json_encode($this->data), 'user_id' => $data['user']['id'], 'user_operation_time' => $data['user']['operate_time'], 'type' => $data['type'] ]); } protected function echoMessage(OutputInterface $output) { //输出消息 $output->writeln(json_encode($this->data)); } }