HandleExceptionWaybill.php 1005 B

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