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

圆通快递接口开发-快递轨迹

hu hao 4 лет назад
Родитель
Сommit
73bf1b4cf1
1 измененных файлов с 52 добавлено и 0 удалено
  1. 52 0
      app/Jobs/LogisticYTOSync.php

+ 52 - 0
app/Jobs/LogisticYTOSync.php

@@ -0,0 +1,52 @@
+<?php
+
+namespace App\Jobs;
+
+use App\Services\LogisticYDService;
+use App\Services\LogisticYTOService;
+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;
+
+class LogisticYTOSync implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+    /**
+     * @var $logisticYTOService LogisticYTOService
+     * @var $orderPackageReceivedSyncService OrderPackageReceivedSyncService
+     * @var $logistic_number string
+     */
+
+    protected $logistic_number;
+
+    protected $logisticYTOService;
+    protected $orderPackageReceivedSyncService;
+
+    /**
+     * LogisticYDSync constructor.
+     * @param $logistic_number
+     */
+    public function __construct($logistic_number)
+    {
+        $this->logistic_number = $logistic_number;
+    }
+
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        ini_set('max_execution_time', 10);
+        $this->logisticYTOService = app('LogisticYTOService');
+        $nativeResponse = $this->logisticYTOService->query($this->logistic_number);
+        $formattedData = $this->logisticYTOService->format($nativeResponse);
+        $this->orderPackageReceivedSyncService = app('OrderPackageReceivedSyncService');
+        $this->orderPackageReceivedSyncService->update([$formattedData]);
+    }
+}