PushQQminiprogramNoticeJob.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Jobs;
  3. use App\Services\NoticeService\Channels\QQMiniTemplateChannel;
  4. use Illuminate\Bus\Queueable;
  5. use Illuminate\Queue\SerializesModels;
  6. use Illuminate\Queue\InteractsWithQueue;
  7. use Illuminate\Contracts\Queue\ShouldQueue;
  8. use Illuminate\Foundation\Bus\Dispatchable;
  9. class PushQQminiprogramNoticeJob implements ShouldQueue
  10. {
  11. use Dispatchable;
  12. use InteractsWithQueue;
  13. use Queueable;
  14. use SerializesModels;
  15. private $data;
  16. private $uids;
  17. /**
  18. * Create a new job instance.
  19. *
  20. * @param array $uids
  21. * @param array $data
  22. */
  23. public function __construct(array $uids, array $data)
  24. {
  25. $this->uids = $uids;
  26. $this->data = $data;
  27. }
  28. /**
  29. * Execute the job.
  30. *
  31. * @return void
  32. */
  33. public function handle()
  34. {
  35. foreach ($this->uids as $uid) {
  36. $app = new QQMiniTemplateChannel();
  37. $app->setAppId(config('qqprogram.app_id'))
  38. ->toUser($uid)
  39. ->setPage($this->data['page'])
  40. ->setTitle($this->data['title'])
  41. ->setTemplateId($this->data['template_id'])
  42. ->setParameters($this->data['parameters'])
  43. ->send();
  44. }
  45. }
  46. }