'fsdy2.fengsutb.com', 'Connection' => 'keep-alive', 'sec-ch-ua-platform' => 'Windows', 'Authorization' => 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZmEiLCJuaWtlIjoi6Zi_5Y-R5rWL6YCfIiwiY3JlYXRlZCI6MTc1ODk2NjM3NjU5MywiZHBJZCI6MTkxOTQwLCJleHAiOjE3NTkyMjU1NzYsImVuYWJsZWQiOnRydWUsImF1dGhvcml0aWVzIjpbInpodXlvbmdodSJdLCJkcEFjY291bnRJZCI6MTc4MzU3fQ.S37D56hG2SwttUYy7OBFet-GOeG5wW6U7j1d2NF7UoFzHWlSpSA4IjwZU1d9Z33xD44Zyiib4zGa_QRxCO2imw', 'sec-ch-ua' => '"Chromium";v="140", "Not=A?Brand";v="24", "Microsoft Edge";v="140"', 'sec-ch-ua-mobile' => '?0', 'doudian-event-id' => '1757940551000163', 'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36 Edg/140.0.0.0', 'Accept' => 'application/json, text/plain, */*', 'platform' => 'dy', 'Origin' => 'https://fx.fengsutb.com', 'Sec-Fetch-Site' => 'same-site', 'Sec-Fetch-Mode' => 'cors', 'Sec-Fetch-Dest' => 'empty', 'Referer' => 'https://fx.fengsutb.com/', 'Accept-Language' => 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6', 'Content-Type' => 'application/json', ]; // 指令配置 protected function configure() { $this->setName('task:dy')->setDescription('the task command'); } //根据shop_id protected function execute(Input $input, Output $output) { $client = new Client([ 'verify' => false]); $last_time = CrontabLog::getLastRunTime(2); $body = '{ "goodType": 2, "goodsFlag": 1, "current": 1, "size": 25, "startTime": "'.$last_time.'", "endTime": "'.date('Y-m-d H:i:s').'", "skuOuterIdExact": false, "skuPropExact": false, "sort": "CONSIGN_TIME", "sortAsc": false, "timeType": 2, "tradeStatus": 2 }'; //获取Token $this->headers['Authorization'] = site_config('addonsd.authorization_token'); $request = new Request('POST', $this->url, $this->headers, $body); $res = $client->sendAsync($request)->wait(); if($res->getStatusCode() == 200) { $data = json_decode($res->getBody()->getContents(), true); $list = $data['data']['list']; if(empty($list)) { $output->writeln('无数据'); return; } $queue = []; $shopList = new ShopList(); $fengsuSku = new FengsuSku(); $productConfig = new ProductConfig(); $shopDelivery = new ShopDelivery(); $customerSpec = new CustomerSpec(); foreach($list as $item) { $status = FengsuService::getAdditionalPrice( $shopList, $fengsuSku, $productConfig, $shopDelivery, $customerSpec, $item); $queue[] = [ 'shop_id' => $item['shopId'], 'trade_from' => $item['tradeFrom'], 'province' => $item['receiverProvince'], 'city' => $item['receiverCity'], 'company_name' => $item['tradeOrderPrintVos'][0]['companyName'], 'waybill_no' => $item['waybillNo'], 'consign_time' => $item['consignTime'], 'goods_id' => $item['tradeOrderPrintVos'][0]['goodsId'], 'sku_id' => $item['tradeOrderPrintVos'][0]['skuId'], 'num' => $item['tradeOrderPrintVos'][0]['total'], 'goods_title' => $item['tradeOrderPrintVos'][0]['goodsTitle'], 'weigh' => $item['tradeOrderPrintVos'][0]['weight'], 'price' => bcdiv((string)$item['payment'], '100', 2), 'status' => $status, ]; } // 保存到数据库 (new FengsuShip())->saveAll($queue); // 更新最后执行时间 CrontabLog::create(['type_id' => 2,'last_time' => date('Y-m-d H:i:s')]); } // 指令输出 $output->writeln('ok'); } }