소스 검색

优化,防重复处理

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 = [
                 '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(){
         
         //
-        $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();
 
@@ -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();
         return true;
     }