Browse Source

逻辑调整

yuanliang 9 months ago
parent
commit
7c95e685c4

+ 2 - 2
cooleshow-auth/auth-server/src/main/resources/config/mybatis/SysUserMapper.xml

@@ -386,10 +386,10 @@
     <select id="getCustomerServiceByFriendLeast" resultMap="SysUser">
         select m.*
         from (SELECT te.user_id_,
-                     count(distinct iuf.friend_id_) friends
+                     count(iuf.friend_id_) friends
               from teacher te
                        left join sys_user su on te.user_id_ = su.id_
-                       left join im_user_friend iuf on te.user_id_ = iuf.user_id_
+                       left join im_user_friend iuf on te.user_id_ = iuf.user_id_ and iuf.source_form_='CUSTOMER'
               where te.lock_flag_ = 0
                 and te.customer_service_ = 1
                 and su.del_flag_ = 0

+ 7 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherServiceImpl.java

@@ -2,6 +2,7 @@ package com.yonge.cooleshow.biz.dal.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -640,6 +641,9 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
             List<TeacherWrapper.CustomerServiceSendMsg2User> customerServiceSendMsg2User = new ArrayList<>();
             if (Boolean.TRUE.equals(customerService) && Boolean.FALSE.equals(teacherSubmitReq.getCustomerService())) {
                 customerServiceSendMsg2User.addAll(transferFriendV2(teacher.getUserId(), true));
+                this.update(null, new UpdateWrapper<Teacher>().lambda()
+                        .eq(Teacher::getCustomerId, teacherSubmitReq.getUserId())
+                        .set(Teacher::getCustomerId, null));
             }
             // 如果机构解绑,更新机构ID为-1
             if (Boolean.TRUE.equals(teacherSubmitReq.getBindTenant())) {
@@ -1629,6 +1633,9 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
         Boolean customerService = teacher.getCustomerService();
         if (UserLockFlag.NORMAL.equals(teacher.getLockFlag()) && Boolean.TRUE.equals(customerService)) {
             List<TeacherWrapper.CustomerServiceSendMsg2User> customerServiceSendMsg2User = transferFriendV2(teacherId, false);
+            this.update(null, new UpdateWrapper<Teacher>().lambda()
+                    .eq(Teacher::getCustomerId, teacherId)
+                    .set(Teacher::getCustomerId, null));
             for (TeacherWrapper.CustomerServiceSendMsg2User serviceSendMsg2User : customerServiceSendMsg2User) {
                 String customerMessage = sysConfigService.findConfigValue(SysConfigConstant.CUSTOMER_SERVICE_ADD_MSG);
                 String customerTitle = sysConfigService.findConfigValue(SysConfigConstant.CUSTOMER_SERVICE_ADD_MSG_TITLE);

+ 5 - 5
cooleshow-user/user-biz/src/main/resources/config/mybatis/TeacherMapper.xml

@@ -441,10 +441,10 @@
         from
         ( SELECT
         te.user_id_,
-        count(distinct iuf.friend_id_) friends
+        count(iuf.friend_id_) friends
         from teacher te
         left join sys_user su on te.user_id_ = su.id_
-        left join im_user_friend iuf on te.user_id_ = iuf.user_id_
+        left join im_user_friend iuf on te.user_id_ = iuf.user_id_ and iuf.source_form_='CUSTOMER'
         where te.lock_flag_ = 0 and te.customer_service_ = 1 and su.del_flag_ = 0 and su.lock_flag_ = 0
         group by te.user_id_
         order by friends
@@ -453,11 +453,11 @@
     </select>
 
     <select id="getCustomerServiceFriendNums" resultType="com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherWrapper$TeacherFriend">
-        SELECT te.user_id_                    teacherId,
-               count(distinct iuf.friend_id_) friendNums
+        SELECT te.user_id_           teacherId,
+               count(iuf.friend_id_) friendNums
         from teacher te
                  left join sys_user su on te.user_id_ = su.id_
-                 left join im_user_friend iuf on te.user_id_ = iuf.user_id_ and iuf.client_type_ = 'TEACHER'
+                 left join im_user_friend iuf on te.user_id_ = iuf.user_id_ and iuf.client_type_ = 'TEACHER' and iuf.source_form_='CUSTOMER'
         where te.lock_flag_ = 0
           and te.customer_service_ = 1
           and su.del_flag_ = 0