lizhen_gitee 2 dias atrás
pai
commit
8d21f9d3de
2 arquivos alterados com 6 adições e 29 exclusões
  1. 3 17
      app/Controller/Api/v1/TestController.php
  2. 3 12
      app/Job/BindjigouJob.php

+ 3 - 17
app/Controller/Api/v1/TestController.php

@@ -20,37 +20,23 @@ class TestController extends AbstractController
     }
 
     public function test2(){
-        $user_id = 93;$old_jigou_id = 16;$new_jigou_id = 18;
-        $a = $this->bindjigou($user_id,$old_jigou_id,$new_jigou_id);
-        dump($a);
-    }
+        $user_id = 93;$old_jigou_id = 17;$new_jigou_id = 18;
 
-    public function bindjigou($user_id,$old_jigou_id,$new_jigou_id){
 
         Db::beginTransaction();
 
         //用户答题记录,都改成现在的机构id
         $rs3 = Db::table('user_question_log')->where('user_id',$user_id)->update(['jigou_id'=>$new_jigou_id]);
-        if(!$rs3){
-            Db::rollBack();
-            return false;
-        }
+
 
         //重新计算老机构的分
         $sum_score = Db::table('user_question_log')->where('jigou_id',$old_jigou_id)->where('is_right',1)->sum('score');
         $rs2 = Db::table('vote_jigou')->where('id',$old_jigou_id)->update(['score'=>$sum_score]);
-        if(!$rs2){
-            Db::rollBack();
-            return false;
-        }
+
 
         //重新计算新机构的分
         $sum_score = Db::table('user_question_log')->where('jigou_id',$new_jigou_id)->where('is_right',1)->sum('score');
         $rs1 = Db::table('vote_jigou')->where('id',$new_jigou_id)->update(['score'=>$sum_score]);
-        if(!$rs1){
-            Db::rollBack();
-            return false;
-        }
 
 
         Db::commit();

+ 3 - 12
app/Job/BindjigouJob.php

@@ -54,26 +54,17 @@ private const LOG_MODULE = 'BindjigouJob';
 
         //用户答题记录,都改成现在的机构id
         $rs3 = Db::table('user_question_log')->where('user_id',$user_id)->update(['jigou_id'=>$new_jigou_id]);
-        if(!$rs3){
-            Db::rollBack();
-            return false;
-        }
+
 
         //重新计算老机构的分
         $sum_score = Db::table('user_question_log')->where('jigou_id',$old_jigou_id)->where('is_right',1)->sum('score');
         $rs2 = Db::table('vote_jigou')->where('id',$old_jigou_id)->update(['score'=>$sum_score]);
-        if(!$rs2){
-            Db::rollBack();
-            return false;
-        }
+
 
         //重新计算新机构的分
         $sum_score = Db::table('user_question_log')->where('jigou_id',$new_jigou_id)->where('is_right',1)->sum('score');
         $rs1 = Db::table('vote_jigou')->where('id',$new_jigou_id)->update(['score'=>$sum_score]);
-        if(!$rs1){
-            Db::rollBack();
-            return false;
-        }
+
 
 
         Db::commit();