"表单提交", "17" => "智能电话_确认接通", "40" => "无效事件", "192" => "私信留资", "194" => "确认意向", "195" => "加为好友", "196" => "预付定金", "285" => "正价支付", "386" => "微信_添加企业微信", "527" => "到店", "536" => "团购留资", "537" => "私信意向", ]; /** * @return void */ protected function configure() { $this->addArgument('agentId', InputArgument::OPTIONAL, 'Name description'); } protected function execute(InputInterface $input, OutputInterface $output): int { try { $output->writeln("获取线索订单====>".getDateFull()); $agentId = $input->getArgument("agentId"); if (empty($agentId)) { $output->writeln("配置错误1====>".getDateFull()); return self::SUCCESS; } $config = (new HxAgent)->where("account",$agentId)->findOrEmpty(); $config['version'] = "res"; if ($config->isEmpty()) { $output->writeln("配置错误2====>".getDateFull()); return self::SUCCESS; } $result = (new Store)->config($config->toArray())->token()->asyncClue($config['account']); $mode = new HxOrderLife; if (!empty($result['clue_data'])) { foreach ($result['clue_data'] as $k => $v) { if ($v['order_id'] > 0) { $v['telephone'] = (new SignUtil)->init($config['secret'])->decryptAES($v['telephone']); $v['agent_id'] = $config['agent_id']; $v['create_at'] = $v['create_time_detail']??getDateFull(); // print_r($v); $order = $mode->where("order_id",$v['order_id'])->findOrEmpty(); if ($order->isEmpty()) { echo getDateFull()."==新增订单=={$v['order_id']}==\n"; $v['pay_at'] = $v['modify_time']; $order->strict(false)->insertGetId($v); } else { echo getDateFull()."==更新订单=={$v['order_id']}==\n"; $order->product_id = $v['product_id']; if ($v['order_status'] == '履约中') { $order->telephone = $v['telephone']; $order->tel_addr = $v['tel_addr']; } $order->save(); } } else { echo getDateFull()."==跳过订单=={$v['order_id']}==\n"; } } } else { echo getDateFull()."==该账号下无订单=={$agentId}==\n"; } } catch (\Throwable $throwable) { echo getDateFull()."==获取线索订单失败\n"; echo $throwable->getMessage()."\n"; echo $throwable->getFile()."【".$throwable->getLine()."】\n"; } return self::SUCCESS; } }