|
@@ -41,14 +41,46 @@ private const LOG_MODULE = 'BindjigouJob';
|
|
// 这里的逻辑会在 ConsumerProcess 进程中执行
|
|
// 这里的逻辑会在 ConsumerProcess 进程中执行
|
|
// var_dump($this->params);
|
|
// var_dump($this->params);
|
|
|
|
|
|
- $res = $this->bindjigou($this->params['user_id'],$this->params['bind_jigou_id']);
|
|
|
|
|
|
+ $res = $this->bindjigou($this->params['user_id'],$this->params['old_jigou_id'],$this->params['new_jigou_id']);
|
|
|
|
|
|
LogUtil::info('处理结果', self::LOG_MODULE, __FUNCTION__,$res);
|
|
LogUtil::info('处理结果', self::LOG_MODULE, __FUNCTION__,$res);
|
|
LogUtil::close();
|
|
LogUtil::close();
|
|
}
|
|
}
|
|
|
|
|
|
//曾经 答题贡献的分数,用户曾经都要给到新机构
|
|
//曾经 答题贡献的分数,用户曾经都要给到新机构
|
|
- public function bindjigou($user_id,$bind_jigou_id){
|
|
|
|
|
|
+ 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();
|
|
|
|
+ return true;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ public function bindjigou_old($user_id,$bind_jigou_id){
|
|
|
|
|
|
//机构得分记录
|
|
//机构得分记录
|
|
$map = [
|
|
$map = [
|