1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- namespace App\Console\Commands;
- use Illuminate\Console\Command;
- use App\Common\Library\Easemob;
- use Illuminate\Support\Facades\DB;
- use App\Jobs\EasemobJob;
- class Plantask extends Command
- {
-
- protected $signature = 'command:Plantask';
-
- protected $description = 'Command description';
-
- public function __construct()
- {
- parent::__construct();
- }
-
- public function handle()
- {
- $list = DB::table('mt_message')->where('dispatch_status',0)->orderBy('id','asc')->get()->toArray();
-
-
- if(!empty($list)){
- foreach($list as $key => $val){
- $msg_id = $val->id;
- dispatch((new EasemobJob($msg_id))->delay(0));
- }
- }
-
- $ids = array_column($list,'id');
- $update = [
- 'dispatch_status' => 1,
- ];
- DB::table('mt_message')->whereIn('id',$ids)->update($update);
- return 0;
- }
- }
|