Plantask.php 1.3 KB

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