SendMessageCourseCommand.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Jobs\SendMessageFive;
  4. use App\Jobs\SendMessageFour;
  5. use App\Jobs\SendMessageOne;
  6. use App\Jobs\SendMessageSeven;
  7. use App\Jobs\SendMessageSix;
  8. use App\Jobs\SendMessageThree;
  9. use App\Jobs\SendMessageTwo;
  10. use App\Models\Basic;
  11. use App\Models\Enroll;
  12. use Carbon\Carbon;
  13. use Illuminate\Console\Command;
  14. use Illuminate\Support\Facades\Log;
  15. class SendMessageCourseCommand extends Command
  16. {
  17. /**
  18. * The name and signature of the console command.
  19. *
  20. * @var string
  21. */
  22. protected $signature = 'SendMess';
  23. /**
  24. * The console command description.
  25. *
  26. * @var string
  27. */
  28. protected $description = 'Command description';
  29. /**
  30. * Create a new command instance.
  31. *
  32. * @return void
  33. */
  34. public function __construct()
  35. {
  36. parent::__construct();
  37. }
  38. /**
  39. * Execute the console command.
  40. *
  41. * @return mixed
  42. */
  43. public function handle()
  44. {
  45. $tem='xZRPVJAb0lahLAJhWuOAknw7N3yk-CXKn88QjMaHQ_8';
  46. $basic=Basic::whereIn('keys',['season','round_start_time','round_end_time'])->select('value','keys')->get();
  47. foreach ($basic as $k=>$v){
  48. $re[$v['keys']]=$v['value'];
  49. }
  50. $now=Carbon::now()->timestamp;
  51. if ($now>=$re['round_start_time']&&$now<=$re['round_end_time']){
  52. $data=Enroll::where('season',$re['season'])->where('status',0)->with(['user:id,phone'])->select('uid')->get()->toArray();
  53. for ($i=0;$i<1000;$i++){
  54. if (isset($data[$i])){
  55. dispatch(new SendMessageOne($data[$i]));
  56. }
  57. if (isset($data[$i+1000])){
  58. dispatch(new SendMessageTwo($data[$i+1000]));
  59. }
  60. if (isset($data[$i+2000])){
  61. dispatch(new SendMessageThree($data[$i+2000]));
  62. }
  63. if (isset($data[$i+3000])){
  64. dispatch(new SendMessageFour($data[$i+3000]));
  65. }
  66. if (isset($data[$i+4000])){
  67. dispatch(new SendMessageFive($data[$i+4000]));
  68. }
  69. if (isset($data[$i+5000])){
  70. dispatch(new SendMessageSix($data[$i+5000]));
  71. }
  72. if (isset($data[$i+6000])){
  73. dispatch(new SendMessageSeven($data[$i+6000]));
  74. }
  75. }
  76. // Log::error($data[0]);
  77. }
  78. }
  79. }