ActionTrigger.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Jobs;
  3. use Artisan;
  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. /**
  10. * 动作触发器,兼容所有扔队列需要异步处理的请求
  11. * @author zhoulingjie
  12. *
  13. */
  14. class ActionTrigger implements ShouldQueue
  15. {
  16. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  17. protected $data;
  18. /**
  19. * Create a new job instance.
  20. *
  21. * @return void
  22. */
  23. public function __construct($data)
  24. {
  25. //
  26. \Log::info('action_trigger_init');
  27. $this->data = $data;
  28. }
  29. /**
  30. * Execute the job.
  31. *
  32. * @return void
  33. */
  34. public function handle()
  35. {
  36. $data = $this->data;
  37. $data = isset($data['data'])?$data['data']:null;
  38. \Log::info('ActionTrigger_start');\Log::info($data);
  39. try {
  40. \Log::info('ActionTrigger:'.$data['action_type'].' start');
  41. Artisan::call('ActionTrigger:'.$data['action_type'],['data'=>$data]);
  42. } catch (\Exception $e) {
  43. \Log::info('action_trigger_ept:'.$e->getMessage());
  44. }
  45. }
  46. }