SyncOrderIssueOrWorkOrderBySWMS.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Jobs;
  3. use App\OrderIssue;
  4. use App\Services\SyncSWMSOrderIssueAndWorkOrderService;
  5. use App\WorkOrder;
  6. use Illuminate\Bus\Queueable;
  7. use Illuminate\Contracts\Queue\ShouldQueue;
  8. use Illuminate\Foundation\Bus\Dispatchable;
  9. use Illuminate\Queue\InteractsWithQueue;
  10. use Illuminate\Queue\SerializesModels;
  11. /**
  12. * @Deprecated 订单问题件通知SWMS
  13. */
  14. class SyncOrderIssueOrWorkOrderBySWMS implements ShouldQueue
  15. {
  16. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  17. public static $ORDER_ISSUE_TYPE = 1;
  18. public static $WORK_ORDER_TYPE = 2;
  19. /** @var OrderIssue */
  20. private $orderIssue;
  21. /** @var WorkOrder */
  22. private $workOrder;
  23. private $type;
  24. /**
  25. * Create a new job instance.
  26. *
  27. * @return void
  28. */
  29. public function __construct($params,$type)
  30. {
  31. $this->type = $type;
  32. if($type == $this::$ORDER_ISSUE_TYPE){
  33. $this->orderIssue = $params;
  34. } else if($type == $this::$WORK_ORDER_TYPE){
  35. $this->workOrder = $params;
  36. }
  37. }
  38. /**
  39. * Execute the job.
  40. *
  41. * @return void
  42. */
  43. public function handle()
  44. {
  45. /** @var SyncSWMSOrderIssueAndWorkOrderService $service */
  46. $service = app(SyncSWMSOrderIssueAndWorkOrderService::class);
  47. if($this->type == $this::$ORDER_ISSUE_TYPE){
  48. $class = $this->orderIssue->getMorphClass();
  49. if(str_contains($class,'OrderIssue')){
  50. $service->sendOrderIssue($this->orderIssue);
  51. } else {
  52. $service->sendWorkOrder($this->orderIssue);
  53. }
  54. } else if($this->type == $this::$WORK_ORDER_TYPE){
  55. $service->sendWorkOrder($this->workOrder);
  56. }
  57. }
  58. }