| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace App\Jobs;
- use App\Batch;
- use App\Exceptions\ErrorException;
- use App\Log;
- use App\Services\ForeignZhenCangService;
- use App\Services\LogService;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Queue\SerializesModels;
- /**
- * @Deprecated 侦仓任务推送
- */
- 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');
- if(!$this->batches){throw new ErrorException('波次任务中波次不存在!');}
- $batchCollect=collect($this->batches);
- //暂时直接指定 375 妍柯货主
- $batches=Batch::query()->where('owner_id',375)->whereIn('id',data_get($batchCollect,'*.id'))->get();
- try {
- foreach ($batches as &$batch) {
- $batch->loadMissing([
- 'orders.orderCommodities.commodity.barcodes'
- ]);
- $foreignZhenCangService->broadcastBatch($batch);
- }
- } catch (\Exception $e) {
- LogService::log(__METHOD__,'BroadcastBatchToZhengCangJob','波次任务推送祯仓失败'.json_encode($e->getMessage()));
- }
- }
- }
|