Plantaskvideo.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use Illuminate\Support\Facades\DB;
  5. use App\Jobs\VideoJob;
  6. class Plantaskvideo extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'command:Plantaskvideo';
  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. ['updatetime' , '<' ,time()-300],
  39. ];
  40. $list = DB::table('mt_user_match_video_log')->where($map)->orderBy('id','asc')->get()->toArray();
  41. //dd($list);
  42. if(!empty($list)){
  43. foreach($list as $key => $val){
  44. $msg_id = $val->id;
  45. dispatch((new VideoJob($msg_id))->delay(0));//加入队列
  46. }
  47. //更新
  48. $ids = array_column($list,'id');
  49. $update = [
  50. 'plantask_status' => 1,
  51. ];
  52. DB::table('mt_user_match_video_log')->whereIn('id',$ids)->update($update);
  53. }
  54. return 0;
  55. }
  56. }