SendTexts.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace App\Jobs;
  3. use App\Jobs\Job;
  4. use Illuminate\Queue\SerializesModels;
  5. use Illuminate\Queue\InteractsWithQueue;
  6. use Illuminate\Contracts\Queue\ShouldQueue;
  7. use App\Http\Controllers\Wechat\Staff\TextsWorksController;
  8. class SendTexts extends Job implements ShouldQueue
  9. {
  10. use InteractsWithQueue, SerializesModels;
  11. private $data;
  12. /**
  13. * Create a new job instance.
  14. *
  15. * @return void
  16. */
  17. public function __construct($data)
  18. {
  19. //
  20. $data['send_time']=date("Y-m-d H:i:s");
  21. $this->data = $data;
  22. }
  23. /**
  24. * Execute the job.
  25. *
  26. * @return void
  27. */
  28. public function handle()
  29. {
  30. //
  31. $this->data['receive_time'] = date("Y-m-d H:i:s");
  32. echo json_encode($this->data);
  33. try{
  34. $TemplateWork = new TextsWorksController($this->data['data']);
  35. $TemplateWork->do_work();
  36. }
  37. // 加上\ 全局抓取
  38. catch(\Exception $e){
  39. v('handle_ept: info:'.$e->getMessage());
  40. }
  41. }
  42. /**
  43. * The job failed to process.
  44. *
  45. * @param Exception $exception
  46. * @return void
  47. */
  48. public function failed(Exception $exception)
  49. {
  50. // Send user notification of failure, etc...
  51. v('sendTexts_ept:'.$exception->getMessage().' data:'.json_encode($this->data));
  52. }
  53. }