LogisticYDSync.php 1.3 KB

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