LogisticYTOSync.php 1.5 KB

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