|
@@ -2,6 +2,7 @@ package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -51,11 +52,13 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.tritonus.share.ArraySet;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
@@ -289,6 +292,9 @@ public class ImUserFriendServiceImpl extends ServiceImpl<ImUserFriendDao, ImUser
|
|
|
*/
|
|
|
@Override
|
|
|
public Integer registerUserBindCustomerService(Long userId, List<Long> friendIds, ClientEnum clientType) {
|
|
|
+ if(userId == null || CollectionUtils.isEmpty(friendIds)){
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
|
|
|
SysUser sysUser = sysUserMapper.getByUserId(userId);
|
|
|
try {
|
|
@@ -297,13 +303,31 @@ public class ImUserFriendServiceImpl extends ServiceImpl<ImUserFriendDao, ImUser
|
|
|
} catch (Exception e) {
|
|
|
log.error("注册用户失败:" + userId + ",type:" + clientType);
|
|
|
}
|
|
|
+ // 判断是否是同一机构
|
|
|
+ EImUserFriendSourceForm sourceForm = EImUserFriendSourceForm.CUSTOMER;
|
|
|
+ Teacher customer = teacherDao.selectById(friendIds.get(0));
|
|
|
+ if (customer.getTenantId() != null && customer.getTenantId() > 0) {
|
|
|
+ if (ClientEnum.STUDENT.equals(clientType)) {
|
|
|
+ Student student = studentDao.selectById(userId);
|
|
|
+ if (customer.getTenantId().equals(student.getTenantId())) {
|
|
|
+ sourceForm = EImUserFriendSourceForm.TEACHER;
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if (ClientEnum.TEACHER.equals(clientType)) {
|
|
|
+ Teacher teacher = teacherDao.selectById(userId);
|
|
|
+ if (customer.getTenantId().equals(teacher.getTenantId())) {
|
|
|
+ sourceForm = EImUserFriendSourceForm.TEACHER;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 添加新用户好友,客服默认为老师身份
|
|
|
for (Long teacherId : friendIds) {
|
|
|
if (ClientEnum.STUDENT == clientType) {
|
|
|
- saveUserFriend(teacherId, Sets.newHashSet(userId), EImUserFriendSourceForm.CUSTOMER);
|
|
|
+ saveUserFriend(teacherId, Sets.newHashSet(userId), sourceForm);
|
|
|
studentDao.update(null, new UpdateWrapper<Student>().lambda().eq(Student::getUserId, userId).set(Student::getCustomerId, teacherId));
|
|
|
} else if (ClientEnum.TEACHER == clientType) {
|
|
|
- saveUserTeacherFriend(teacherId, Sets.newHashSet(userId), EImUserFriendSourceForm.CUSTOMER);
|
|
|
+ saveUserTeacherFriend(teacherId, Sets.newHashSet(userId), sourceForm);
|
|
|
teacherDao.update(null, new UpdateWrapper<Teacher>().lambda().eq(Teacher::getUserId, userId).set(Teacher::getCustomerId, teacherId));
|
|
|
}
|
|
|
|