浏览代码

优化,防重复处理

lizhen_gitee 1 年之前
父节点
当前提交
030eab70f3
共有 2 个文件被更改,包括 14 次插入3 次删除
  1. 2 2
      app/Console/Commands/Plantask.php
  2. 12 1
      app/Jobs/GiftJob.php

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

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

+ 12 - 1
app/Jobs/GiftJob.php

@@ -81,7 +81,10 @@ class GiftJob implements ShouldQueue
     public function goaaa(){
     public function goaaa(){
         
         
         //
         //
-        $data = DB::table('hx_gift_user_party')->where('id',$this->msgid)->first();
+        $data = DB::table('hx_gift_user_party')->where('id',$this->msgid)->where('new_task_status',0)->first();
+        if(empty($data)){
+            return true;
+        }
 
 
         DB::beginTransaction();
         DB::beginTransaction();
 
 
@@ -117,6 +120,14 @@ class GiftJob implements ShouldQueue
             }
             }
         }
         }
 
 
+        $update_data = ['new_task_status'=>1];
+        $rs_update = DB::table('hx_gift_user_party')->where('id',$this->msgid)->update($update_data);
+
+        if(!$rs_update){
+            Db::rollBack();
+            return false;
+        }
+
         Db::commit();
         Db::commit();
         return true;
         return true;
     }
     }