OrderTag.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace App\Jobs;
  3. use App\Service\Order\OrderTagService;
  4. use Illuminate\Bus\Queueable;
  5. use Illuminate\Contracts\Queue\ShouldQueue;
  6. use Illuminate\Foundation\Bus\Dispatchable;
  7. use Illuminate\Queue\InteractsWithQueue;
  8. use Illuminate\Queue\SerializesModels;
  9. use Illuminate\Support\Facades\DB;
  10. class OrderTag implements ShouldQueue
  11. {
  12. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  13. protected $order_no;
  14. /**
  15. * Create a new job instance.
  16. *
  17. * @return void
  18. */
  19. public function __construct($order_no)
  20. {
  21. //
  22. $this->order_no = $order_no;
  23. }
  24. /**
  25. * Execute the job.
  26. *
  27. * @return void
  28. */
  29. public function handle()
  30. {
  31. //生成芯片数据更新订单产品部件信息
  32. $service = new OrderTagService();
  33. DB::beginTransaction();
  34. try{
  35. $service = $service->setTag($this->order_no);
  36. DB::commit();
  37. }catch (\Exception $e){
  38. DB::rollBack();
  39. $this->dispatch($this->order_no);
  40. }
  41. }
  42. }