Plantasktyping.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use Illuminate\Support\Facades\DB;
  5. use App\Jobs\TypingJob;
  6. class Plantasktyping extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'command:Plantasktyping';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = 'Command description';
  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 int
  33. */
  34. public function handle()
  35. {
  36. $map = [
  37. ['plantask_status', '=' ,0]
  38. ];
  39. $list = DB::table('mt_gift_user_typing')->where($map)->orderBy('id','asc')->get()->toArray();
  40. //dd($list);
  41. if(!empty($list)){
  42. foreach($list as $key => $val){
  43. $msg_id = $val->id;
  44. dispatch((new TypingJob($msg_id))->delay(0));//加入队列
  45. }
  46. //更新
  47. $ids = array_column($list,'id');
  48. $update = [
  49. 'plantask_status' => 1,
  50. ];
  51. DB::table('mt_gift_user_typing')->whereIn('id',$ids)->update($update);
  52. }
  53. return 0;
  54. }
  55. }