|
@@ -0,0 +1,65 @@
|
|
|
|
+<?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
|
|
|
|
+{
|
|
|
|
+ /**
|
|
|
|
+ * The name and signature of the console command.
|
|
|
|
+ *
|
|
|
|
+ * @var string
|
|
|
|
+ */
|
|
|
|
+ protected $signature = 'command:Plantask';
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * The console command description.
|
|
|
|
+ *
|
|
|
|
+ * @var string
|
|
|
|
+ */
|
|
|
|
+ protected $description = 'Command description';
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Create a new command instance.
|
|
|
|
+ *
|
|
|
|
+ * @return void
|
|
|
|
+ */
|
|
|
|
+ public function __construct()
|
|
|
|
+ {
|
|
|
|
+ parent::__construct();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Execute the console command.
|
|
|
|
+ *
|
|
|
|
+ * @return int
|
|
|
|
+ */
|
|
|
|
+ public function handle()
|
|
|
|
+ {
|
|
|
|
+ $list = DB::table('mt_message')->where('dispatch_status',0)->orderBy('id','asc')->get()->toArray();
|
|
|
|
+ //dd($list);
|
|
|
|
+ //
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+}
|