data = $data; $this->user = $user; $this->type = $type; } public function handle() { $service = new TPlusServerService(); try { $data = $this->data; $user = $this->user; $type = $this->type; if($type == 1){ //收付款单 list($status, $msg) = $service->synRevenueCostFromTPlus($data, $user); }elseif($type == 2){ list($status, $msg) = $service->synSalaryEmployeeFromMine($data, $user); }else{ list($status, $msg) = $service->synFreightFeeFromMine($data, $user); } $this->finalDo($msg, $service); } catch (\Throwable $e) { $this->finalDo("异常:" . $e->getMessage(), $service); $this->delete(); } } private function finalDo($msg, $service){ $type = $this->type; $service->delTableKey($type); $service->clearTmpTable($type); $user = $this->user; $data = $this->data; RevenueCostMain::insert([ 'result' => $msg, 'crt_id' => $user['id'], 'crt_time' => $data['operation_time'], 'order_type' => $data['type'], ]); } protected function echoMessage(OutputInterface $output) { //输出消息 $output->writeln(json_encode($this->data)); } }