Переглянути джерело

计划任务防重复处理

lizhen_gitee 1 рік тому
батько
коміт
3b94e38c4a
2 змінених файлів з 13 додано та 5 видалено
  1. 2 2
      app/Console/Commands/Plantask.php
  2. 11 3
      app/Jobs/EasemobJob.php

+ 2 - 2
app/Console/Commands/Plantask.php

@@ -52,13 +52,13 @@ class Plantask extends Command
         }
 
         //更新
-        $ids = array_column($list,'id');
+        /*$ids = array_column($list,'id');
 
         $update = [
             'dispatch_status' => 1,
         ];
 
-        DB::table('mt_message')->whereIn('id',$ids)->update($update);
+        DB::table('mt_message')->whereIn('id',$ids)->update($update);*/
 
         return 0;
     }

+ 11 - 3
app/Jobs/EasemobJob.php

@@ -39,10 +39,18 @@ class EasemobJob implements ShouldQueue
     public function handle()
     {
         //
-        $info = DB::table('mt_message')->where('id',$this->msgid)->first();
+        $info = DB::table('mt_message')->where('id',$this->msgid)->where('dispatch_status',0)->first();
+        if(!empty($info)){
+            $easemob = new Easemob();
+            $rs = $easemob->push_text($info->user_id,$info->title,$info->content);
+
+            $update = [
+                'dispatch_status' => 1,
+            ];
+
+            DB::table('mt_message')->where('id',$this->msgid)->update($update);
+        }
 
-        $easemob = new Easemob();
-        $rs = $easemob->push_text($info->user_id,$info->title,$info->content);
         /*echo '<pre>';
         var_dump($rs);*/