|
|
@@ -0,0 +1,54 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Jobs;
|
|
|
+
|
|
|
+use App\Services\LogisticAliJiSuApiService;
|
|
|
+use App\Services\LogService;
|
|
|
+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 LogisticAliJiSuSync implements ShouldQueue
|
|
|
+{
|
|
|
+ use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @var $logisticAliJiSuApiService LogisticAliJiSuApiService
|
|
|
+ * @var $orderPackageReceivedSyncService OrderPackageReceivedSyncService
|
|
|
+ * @var $logistic_number string
|
|
|
+ */
|
|
|
+
|
|
|
+ protected $logistic_number;
|
|
|
+ protected $logisticAliJiSuApiService;
|
|
|
+ protected $orderPackageReceivedSyncService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Create a new job instance.
|
|
|
+ *
|
|
|
+ * @param $logistic_number
|
|
|
+ */
|
|
|
+ public function __construct($logistic_number)
|
|
|
+ {
|
|
|
+ $this->logistic_number=$logistic_number;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Execute the job.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function handle()
|
|
|
+ {
|
|
|
+ LogService::log(LogisticAliJiSuSync::class, "{$this->logistic_number}-JOB-AliJiSu", '');
|
|
|
+ $this->logisticAliJiSuApiService = app('LogisticAliJiSuApiService');
|
|
|
+ $response = $this->logisticAliJiSuApiService->query($this->logistic_number);
|
|
|
+ if ($response && $response->status==0){
|
|
|
+ $format = $this->logisticAliJiSuApiService->format($response);
|
|
|
+ $this->orderPackageReceivedSyncService = app('OrderPackageReceivedSyncService');
|
|
|
+ if (count($format)>0 && $format['logistic_number']) $this->orderPackageReceivedSyncService->update([$format]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|