BroadcastBatchToZhengCangJob.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App\Jobs;
  3. use App\Batch;
  4. use App\Services\ForeignZhenCangService;
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Contracts\Queue\ShouldQueue;
  7. use Illuminate\Foundation\Bus\Dispatchable;
  8. use Illuminate\Queue\InteractsWithQueue;
  9. use Illuminate\Queue\SerializesModels;
  10. class BroadcastBatchToZhengCangJob implements ShouldQueue
  11. {
  12. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  13. private $batches;
  14. /**
  15. * Create a new job instance.
  16. *
  17. * @return void
  18. */
  19. public function __construct($batches)
  20. {
  21. $this->batches=$batches;
  22. }
  23. /**
  24. * Execute the job.
  25. *
  26. * @return void
  27. */
  28. public function handle()
  29. {
  30. /** @var ForeignZhenCangService $foreignZhenCangService */
  31. $foreignZhenCangService=app('ForeignZhenCangService');
  32. foreach ($this->batches as &$batch){
  33. $batch->loadMissing([
  34. 'orders.orderCommodities.commodity.barcodes'
  35. ]);
  36. $foreignZhenCangService->broadcastBatch($batch);
  37. }
  38. }
  39. }