HandleExceptionWaybill.php 948 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Jobs;
  3. use App\Order;
  4. use App\Waybill;
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Contracts\Queue\ShouldQueue;
  7. use Illuminate\Foundation\Bus\Dispatchable;
  8. use Illuminate\Queue\InteractsWithQueue;
  9. class HandleExceptionWaybill implements ShouldQueue
  10. {
  11. use Dispatchable, InteractsWithQueue, Queueable;
  12. /** @var Waybill|\stdClass */
  13. protected $waybill;
  14. /**
  15. * Create a new job instance.
  16. *
  17. * @param Waybill $waybill
  18. *
  19. * @return void
  20. */
  21. public function __construct(Waybill $waybill)
  22. {
  23. $this->waybill = $waybill;
  24. }
  25. /**
  26. * Execute the job.
  27. *
  28. * @return void
  29. *
  30. * @throws
  31. */
  32. public function handle()
  33. {
  34. $order = Order::query()->where("code",$this->waybill->wms_bill_number)->first();
  35. if ($order)$this->waybill->update(["order_id"=>$order->id]);
  36. else throw new \Exception("order does not exist");
  37. }
  38. }