|
|
@@ -0,0 +1,45 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Jobs;
|
|
|
+
|
|
|
+use App\Batch;
|
|
|
+use App\Services\ForeignZhenCangService;
|
|
|
+use Illuminate\Bus\Queueable;
|
|
|
+use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
+use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
+use Illuminate\Queue\InteractsWithQueue;
|
|
|
+use Illuminate\Queue\SerializesModels;
|
|
|
+
|
|
|
+class BroadcastBatchToZhengCangJob implements ShouldQueue
|
|
|
+{
|
|
|
+ use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
+
|
|
|
+ private $batches;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Create a new job instance.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function __construct($batches)
|
|
|
+ {
|
|
|
+ $this->batches=$batches;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Execute the job.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function handle()
|
|
|
+ {
|
|
|
+ /** @var ForeignZhenCangService $foreignZhenCangService */
|
|
|
+ $foreignZhenCangService=app('ForeignZhenCangService');
|
|
|
+ foreach ($this->batches as &$batch){
|
|
|
+ $batch->loadMissing([
|
|
|
+ 'orders.orderCommodities.commodity.barcodes'
|
|
|
+ ]);
|
|
|
+ $foreignZhenCangService->broadcastBatch($batch);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|