setName('UpdateYzHistoryData') ->setDescription('更新有赞的历史数据'); } protected function execute(Input $input, Output $output) { $data = Db::name('order_out') ->alias('a') ->field('a.orderCode,a.outCode,a.post_name,a.post_code') ->leftJoin('sale b', 'b.orderCode=a.orderCode') ->where('a.addtime', '>=', date('Y-m-d H:i:s', time() - 72 * 3600)) ->where([ 'a.is_del' => 0, 'a.status' => 2, 'b.order_source' => 5 ]) ->limit(1)->select()->toArray(); // ->cursor(); $url = config('app.yz_domain') . 'api/yz_out_send'; foreach ($data as $value) { $res = curl_request($url, [ 'orderCode' => $value['orderCode'], 'out_stype' => $value['post_name'], 'post_code' => $value['post_code'], 'uid' => 96, 'uname' => '武锋(历史数据处理)', 'order_out' => $value['outCode'], ]); $res = json_decode($res, true); if ($res['code'] != 0) $output->writeln('handle fail,' . json_encode($value, JSON_UNESCAPED_UNICODE) . ':' . $res['message']); } } }