LogisticYTOSync.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  15. /**
  16. * @var $logisticYTOService LogisticYTOService
  17. * @var $orderPackageReceivedSyncService OrderPackageReceivedSyncService
  18. * @var $logistic_number string
  19. */
  20. protected $logistic_number;
  21. protected $logisticYTOService;
  22. protected $orderPackageReceivedSyncService;
  23. /**
  24. * LogisticYDSync constructor.
  25. * @param $logistic_number
  26. */
  27. public function __construct($logistic_number)
  28. {
  29. $this->logistic_number = $logistic_number;
  30. }
  31. /**
  32. * Execute the job.
  33. *
  34. * @return void
  35. */
  36. public function handle()
  37. {
  38. ini_set('max_execution_time', 10);
  39. LogService::log(LogisticYTOSync::class, "{$this->logistic_number}-JOB-YTO", '');
  40. $this->logisticYTOService = app('LogisticYTOService');
  41. $nativeResponse = $this->logisticYTOService->query($this->logistic_number);
  42. $formattedData = $this->logisticYTOService->format($nativeResponse);
  43. $this->orderPackageReceivedSyncService = app('OrderPackageReceivedSyncService');
  44. $this->orderPackageReceivedSyncService->update([$formattedData]);
  45. }
  46. }