LogisticYTOSync.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace App\Jobs;
  3. use App\Services\LogisticYDService;
  4. use App\Services\LogisticYTOService;
  5. use App\Services\LogService;
  6. use App\Services\OrderPackageReceivedSyncService;
  7. use Illuminate\Bus\Queueable;
  8. use Illuminate\Contracts\Queue\ShouldQueue;
  9. use Illuminate\Foundation\Bus\Dispatchable;
  10. use Illuminate\Queue\InteractsWithQueue;
  11. use Illuminate\Queue\SerializesModels;
  12. class LogisticYTOSync implements ShouldQueue
  13. {
  14. public $tries = 2;
  15. public $timeout = 10;
  16. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  17. /**
  18. * @var $logisticYTOService LogisticYTOService
  19. * @var $orderPackageReceivedSyncService OrderPackageReceivedSyncService
  20. * @var $logistic_number string
  21. */
  22. protected $logistic_number;
  23. protected $logisticYTOService;
  24. protected $orderPackageReceivedSyncService;
  25. /**
  26. * LogisticYDSync constructor.
  27. * @param $logistic_number
  28. */
  29. public function __construct($logistic_number)
  30. {
  31. $this->logistic_number = $logistic_number;
  32. }
  33. /**
  34. * Execute the job.
  35. *
  36. * @return void
  37. */
  38. public function handle()
  39. {
  40. LogService::log(LogisticYTOSync::class, "{$this->logistic_number}-JOB-YTO", '');
  41. $this->logisticYTOService = app('LogisticYTOService');
  42. $nativeResponse = $this->logisticYTOService->query($this->logistic_number);
  43. $formattedData = $this->logisticYTOService->format($nativeResponse);
  44. $this->orderPackageReceivedSyncService = app('OrderPackageReceivedSyncService');
  45. $this->orderPackageReceivedSyncService->update([$formattedData]);
  46. }
  47. }