Procházet zdrojové kódy

Merge branch 'feature/1019-tenant' into develop-new

yuanliang před 1 rokem
rodič
revize
95b0b3c49c

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

@@ -94,6 +94,10 @@ public class ImUserFriendServiceImpl extends ServiceImpl<ImUserFriendDao, ImUser
         List<ImUserFriend> imUserFriends = new ArrayList<>();
         BasicUserInfo teacherInfo = teacherDao.getBasicUserInfo(teacherId);
         List<BasicUserInfo> studentInfos = teacherDao.findBasicUserInfo(studentIds);
+        if (teacherInfo == null || studentInfos.isEmpty()) {
+            // 过滤注销状态的账号
+            return;
+        }
         studentInfos.add(teacherInfo);
         Map<Long, List<BasicUserInfo>> basicUserInfoMap =
                 studentInfos.stream().collect(Collectors.groupingBy(BasicUserInfo::getUserId));

+ 8 - 11
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/StudentServiceImpl.java

@@ -810,19 +810,16 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
                     new HashSet<>(ImmutableList.of(sysUser.getId()))));
         }
 
-        //  与客服建立好友
+        //  与随机一个客服建立好友
         String customerService = customerServiceConfig.getCustomerService();
-        if(StringUtils.isNotBlank(customerService)){
+        if (StringUtils.isNotBlank(customerService)) {
             List<String> phones = Arrays.stream(customerService.split(",")).collect(Collectors.toList());
-            // 通过手机号获取用户ID
-            QueryWrapper<com.yonge.cooleshow.biz.dal.entity.SysUser> queryWrapper = new QueryWrapper<>();
-            queryWrapper.lambda().in(com.yonge.cooleshow.biz.dal.entity.SysUser::getPhone,phones);
-            List<com.yonge.cooleshow.biz.dal.entity.SysUser> sysUsers = sysUserMapper.selectList(queryWrapper);
-            Set<Long> userIds = sysUsers.stream().map(com.yonge.cooleshow.biz.dal.entity.SysUser::getId).collect(Collectors.toSet());
-            for (Long teacherId : userIds) {
-                HashSet<Long> studentIds = new HashSet<>();
-                studentIds.add(student.getUserId());
-                imUserFriendService.saveUserFriend(teacherId, studentIds);
+            Random rand = new Random();
+            String mobile = phones.get(rand.nextInt(phones.size()));
+            SysUser friend = sysUserMapper.findUserByPhone(mobile);
+            if (friend != null) {
+                imUserFriendService.registerUserBindCustomerService(student.getUserId(),
+                        Collections.singletonList(friend.getId()), ClientEnum.STUDENT);
             }
         }
 

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

@@ -86,13 +86,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
@@ -116,8 +110,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
@@ -488,15 +480,14 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
         }
         //  与客服建立好友
         String customerService = customerServiceConfig.getCustomerService();
-        if(StringUtils.isNotBlank(customerService)){
+        if (StringUtils.isNotBlank(customerService)) {
             List<String> phones = Arrays.stream(customerService.split(",")).collect(Collectors.toList());
-            // 通过手机号获取用户ID
-            QueryWrapper<com.yonge.cooleshow.biz.dal.entity.SysUser> queryWrapper = new QueryWrapper<>();
-            queryWrapper.lambda().in(com.yonge.cooleshow.biz.dal.entity.SysUser::getPhone,phones);
-            List<com.yonge.cooleshow.biz.dal.entity.SysUser> sysUsers = sysUserMapper.selectList(queryWrapper);
-            Set<Long> userIds = sysUsers.stream().map(com.yonge.cooleshow.biz.dal.entity.SysUser::getId).collect(Collectors.toSet());
-            if (!userIds.isEmpty()) {
-                imUserFriendService.saveUserTeacherFriend(teacher.getUserId(), userIds);
+            Random rand = new Random();
+            String mobile = phones.get(rand.nextInt(phones.size()));
+            SysUser friend = sysUserMapper.findUserByPhone(mobile);
+            if (friend != null) {
+                imUserFriendService.registerUserBindCustomerService(teacher.getUserId(),
+                        Collections.singletonList(friend.getId()), ClientEnum.TEACHER);
             }
         }