OrderCreateWaybill.php 840 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Jobs;
  3. use App\Order;
  4. use Illuminate\Bus\Queueable;
  5. use Illuminate\Contracts\Queue\ShouldQueue;
  6. use Illuminate\Foundation\Bus\Dispatchable;
  7. use Illuminate\Queue\InteractsWithQueue;
  8. class OrderCreateWaybill implements ShouldQueue
  9. {
  10. use Dispatchable, InteractsWithQueue, Queueable;
  11. private $arr;
  12. /**
  13. * Create a new job instance.
  14. *
  15. * @return void
  16. */
  17. public function __construct(array $arr)
  18. {
  19. $this->arr = $arr;
  20. }
  21. /**
  22. * Execute the job.
  23. *
  24. * @return void
  25. */
  26. public function handle()
  27. {
  28. if (!$this->arr)return;
  29. $codes = array_column($this->arr,"code");
  30. $orders = Order::query()->with("logistic")->where("code",$codes)->get();
  31. foreach ($orders as $order) app("WaybillService")->createDbBill($order);
  32. }
  33. }