Plantaskrecharge.php 1.4 KB

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