Browse Source

逻辑调整

yuanliang 11 months ago
parent
commit
13119c0ee0

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

@@ -641,9 +641,7 @@ 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));
+                clearUserCustomerRelation(teacherSubmitReq.getUserId());
             }
             // 如果机构解绑,更新机构ID为-1
             if (Boolean.TRUE.equals(teacherSubmitReq.getBindTenant())) {
@@ -696,6 +694,16 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
         return teacher;
     }
 
+    // 清除专属客服信息
+    private void clearUserCustomerRelation(Long userId) {
+        this.update(null, new UpdateWrapper<Teacher>().lambda()
+                .eq(Teacher::getCustomerId, userId)
+                .set(Teacher::getCustomerId, null));
+        studentService.update(null, new UpdateWrapper<Student>().lambda()
+                .eq(Student::getCustomerId, userId)
+                .set(Student::getCustomerId, null));
+    }
+
     // 客服好友移交给其他客服
     private List<TeacherWrapper.CustomerServiceSendMsg2User> transferFriend(Long userId, boolean saveGroupFriend) {
         List<TeacherWrapper.CustomerServiceSendMsg2User> result = new ArrayList<>();
@@ -1633,9 +1641,7 @@ 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));
+            clearUserCustomerRelation(teacherId);
             for (TeacherWrapper.CustomerServiceSendMsg2User serviceSendMsg2User : customerServiceSendMsg2User) {
                 String customerMessage = sysConfigService.findConfigValue(SysConfigConstant.CUSTOMER_SERVICE_ADD_MSG);
                 String customerTitle = sysConfigService.findConfigValue(SysConfigConstant.CUSTOMER_SERVICE_ADD_MSG_TITLE);