PushQQMiniprogramNotice.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\Console\Commands\Notices;
  3. use App\Jobs\PushQQminiprogramNoticeJob;
  4. use App\Models\User\AuthKey;
  5. use Illuminate\Console\Command;
  6. class PushQQMiniprogramNotice extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'yy:qqpair';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = '72hQQ小程序活动模版消息';
  20. /**
  21. * Create a new command instance.
  22. *
  23. * @return void
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. }
  29. /**
  30. * Execute the console command.
  31. *
  32. * @return mixed
  33. */
  34. public function handle()
  35. {
  36. $keyword1 = $this->ask("请输入keyword1的内容:");
  37. $keyword2 = $this->ask("请输入keyword2的内容:");
  38. $keyword3 = $this->ask("请输入keyword3的内容:");
  39. $data = array(
  40. 'title' => '72小时活动报名运营通知',
  41. 'template_id' => 'd149209e80157fd6e340a8049f7c02b7',
  42. 'page' => "fpdx/pages/starter/starter",
  43. 'parameters' => [
  44. 'keyword1' => [
  45. 'value' => $keyword1,
  46. ],
  47. 'keyword2' => [
  48. 'value' => $keyword2,
  49. ],
  50. 'keyword3' => [
  51. 'value' => $keyword3,
  52. ]
  53. ]
  54. );
  55. $users = AuthKey::where('auth_type', config("qqprogram.public_id"))->get(['uid']);
  56. $bar = $this->output->createProgressBar($users->count());
  57. $bar->start();
  58. $k = 0;
  59. $uids = array();
  60. foreach ($users as $user) {
  61. array_push($uids, $user->uid);
  62. if (1000 == $k) {
  63. PushQQminiprogramNoticeJob::dispatch($uids, $data);
  64. $uids = array();
  65. $k = 0;
  66. }
  67. $k++;
  68. $bar->advance();
  69. }
  70. !empty($uids) && PushQQminiprogramNoticeJob::dispatch($uids, $data);
  71. $bar->finish();
  72. }
  73. }