|
@@ -1,63 +0,0 @@
|
|
|
-<?php declare (strict_types=1);
|
|
|
-
|
|
|
-namespace app\command;
|
|
|
-
|
|
|
-use think\console\Command;
|
|
|
-use think\console\Input;
|
|
|
-use think\console\Output;
|
|
|
-use think\Exception;
|
|
|
-use think\facade\Cache;
|
|
|
-use think\facade\Config;
|
|
|
-use think\facade\Db;
|
|
|
-
|
|
|
-//处理有赞物流数据
|
|
|
-class handleYzExpressData extends Command
|
|
|
-{
|
|
|
- protected function configure()
|
|
|
- {
|
|
|
- // 指令配置
|
|
|
- $this->setName('handle_yz_express_data')->setDescription('处理有赞物流数据');
|
|
|
- }
|
|
|
-
|
|
|
- //处理有赞订单数据
|
|
|
- protected function execute(Input $input, Output $output)
|
|
|
- {
|
|
|
-
|
|
|
- try {
|
|
|
-
|
|
|
-
|
|
|
- $orderCode = Cache::store('redis')->handler()->rpop(Config::get('app.yz_express_queue_key'));
|
|
|
-
|
|
|
- if ($orderCode) {
|
|
|
- //去查询对应的发货单信息
|
|
|
- $out_rs = Db::name('order_out')
|
|
|
- ->alias('o')
|
|
|
- ->field('o.id,o.outCode,e.post_code,e.post_name')
|
|
|
- ->leftJoin('express_data e', 'e.order_out_id=o.id')
|
|
|
- ->where([
|
|
|
- 'o.is_del' => 0,
|
|
|
- 'o.orderCode' => $orderCode
|
|
|
- ])
|
|
|
- ->where('e.status', '>', 0)
|
|
|
- ->find();
|
|
|
-
|
|
|
- if ($out_rs) {
|
|
|
-
|
|
|
- //回调有赞项目接口,尝试发货
|
|
|
- $res = curl_request(config('app.yz_domain') . 'api/yz_out_send', ['orderCode' => $orderCode, 'out_stype' => $out_rs['post_name'], 'post_code' => $out_rs['post_code'], 'uid' => 0, 'uname' => '脚本', 'order_out' => $out_rs['outCode']]);
|
|
|
- $res = json_decode($res, true);
|
|
|
-
|
|
|
- if ($res['code'] != 0) $output->writeln('有赞发货失败,' . $res['message']);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception $exception) {
|
|
|
- $output->writeln('处理失败,' . $exception->getMessage());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-}
|