Просмотр исходного кода

主动同步快递信息添加队列任务

ANG YU 5 лет назад
Родитель
Сommit
046e09c132

+ 44 - 0
app/Jobs/OrderPackageReceivedSync.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Services\OrderPackageReceivedSyncService;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+
+/**
+ * 同步快递路由信息任务 调用时需要延迟1h触发
+ * Class OrderPackageReceivedSync
+ * @package App\Jobs
+ */
+class OrderPackageReceivedSync implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    protected $logisticNumbers;
+    protected $service;
+
+    /**
+     * OrderPackageReceivedSync constructor.
+     * @param $logisticNumbers
+     */
+    public function __construct($logisticNumbers)
+    {
+        $this->logisticNumbers = $logisticNumbers;
+        $this->service =  new OrderPackageReceivedSyncService();
+    }
+
+
+    /**
+     * Execute the job.
+     * @return void
+     * @throws \Exception
+     */
+    public function handle()
+    {
+        $this->service->syncLogisticRouteApi($this->logisticNumbers);
+    }
+}

+ 1 - 1
app/Services/OrderPackageReceivedSyncService.php

@@ -26,7 +26,7 @@ class OrderPackageReceivedSyncService
     }
 
     /**
-     * 根据传递的承运商与快递单号更新快递信息,延迟一小时执行
+     * 根据传递的承运商与快递单号更新快递信息
      * @param array $logisticNumbers 快递单号
      * example: ['SF' => ['SF1038651915891', 'SF1038651413847', 'SF1038611050071'],'ZT'=>['75424148714142','548464120822', '75424147834290']....]
      * @throws Exception 快递接口调用或者返回的信息有误,无法更新指定的快递路由信息