|
@@ -5,6 +5,9 @@ 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;
|
|
|
|
|
|
//处理有赞物流数据
|
|
@@ -20,38 +23,38 @@ class handleYzExpressData extends Command
|
|
|
protected function execute(Input $input, Output $output)
|
|
|
{
|
|
|
|
|
|
- $rs = Db::connect('mysql_yz')
|
|
|
- ->table('yz_order_info')
|
|
|
- ->field('i.id,i.orderCode')
|
|
|
- ->alias('i')
|
|
|
- ->leftJoin('yz_order_express e', 'e.tid=i.tid')
|
|
|
- ->where('i.status', 6)
|
|
|
- ->whereNull('e.id')
|
|
|
- ->find();
|
|
|
-
|
|
|
- if ($rs) {
|
|
|
- //去查询对应的发货单信息
|
|
|
- $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' => $rs['orderCode']
|
|
|
- ])
|
|
|
- ->where('e.status', '>', 0)
|
|
|
- ->find();
|
|
|
-
|
|
|
- if ($out_rs) {
|
|
|
-
|
|
|
- //回调有赞项目接口,尝试发货
|
|
|
- $res = curl_request(config('app.yz_domain') . 'api/yz_out_send', ['orderCode' => $rs['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);
|
|
|
- halt($res);
|
|
|
- if ($res['code'] != 0) $output->writeln('有赞发货失败,' . $res['message']);
|
|
|
- }
|
|
|
+ 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());
|
|
|
}
|
|
|
|
|
|
}
|