|
@@ -4,39 +4,35 @@ import com.alibaba.fastjson.JSON;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
-import com.yonge.cooleshow.api.feign.dto.ImUserInfo;
|
|
|
|
import com.google.common.collect.ImmutableList;
|
|
import com.google.common.collect.ImmutableList;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import com.microsvc.toolkit.common.webportal.exception.BizException;
|
|
import com.microsvc.toolkit.common.webportal.exception.BizException;
|
|
import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
import com.yonge.cooleshow.auth.config.CustomerServiceConfig;
|
|
import com.yonge.cooleshow.auth.config.CustomerServiceConfig;
|
|
-import com.yonge.cooleshow.biz.dal.dao.EmployeeDao;
|
|
|
|
-import com.yonge.cooleshow.biz.dal.dao.StudentDao;
|
|
|
|
-import com.yonge.cooleshow.biz.dal.dao.SubjectDao;
|
|
|
|
-import com.yonge.cooleshow.biz.dal.dao.TeacherDao;
|
|
|
|
-import com.yonge.cooleshow.biz.dal.dao.UserBindingTeacherDao;
|
|
|
|
|
|
+import com.yonge.cooleshow.biz.dal.dao.*;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.QueryMyFollowSearch;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.QueryMyFollowSearch;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.StudentSearch;
|
|
import com.yonge.cooleshow.biz.dal.dto.search.StudentSearch;
|
|
import com.yonge.cooleshow.biz.dal.entity.*;
|
|
import com.yonge.cooleshow.biz.dal.entity.*;
|
|
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
import com.yonge.cooleshow.biz.dal.enums.ImGroupMemberRoleType;
|
|
import com.yonge.cooleshow.biz.dal.enums.ImGroupMemberRoleType;
|
|
import com.yonge.cooleshow.biz.dal.enums.ImGroupType;
|
|
import com.yonge.cooleshow.biz.dal.enums.ImGroupType;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.enums.MessageTypeEnum;
|
|
import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
|
|
import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.mapper.TenantGroupMapper;
|
|
import com.yonge.cooleshow.biz.dal.service.ImGroupService;
|
|
import com.yonge.cooleshow.biz.dal.service.ImGroupService;
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMapper;
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMapper;
|
|
-import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumPurchaseMapper;
|
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumRefMapper;
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumRefMapper;
|
|
|
|
+import com.yonge.cooleshow.biz.dal.service.*;
|
|
import com.yonge.cooleshow.biz.dal.service.ImGroupMemberService;
|
|
import com.yonge.cooleshow.biz.dal.service.ImGroupMemberService;
|
|
-import com.yonge.cooleshow.biz.dal.service.ImGroupService;
|
|
|
|
import com.yonge.cooleshow.biz.dal.service.ImUserFriendService;
|
|
import com.yonge.cooleshow.biz.dal.service.ImUserFriendService;
|
|
import com.yonge.cooleshow.biz.dal.service.StudentService;
|
|
import com.yonge.cooleshow.biz.dal.service.StudentService;
|
|
import com.yonge.cooleshow.biz.dal.service.StudentTotalService;
|
|
import com.yonge.cooleshow.biz.dal.service.StudentTotalService;
|
|
import com.yonge.cooleshow.biz.dal.service.im.ImGroupCoreService;
|
|
import com.yonge.cooleshow.biz.dal.service.im.ImGroupCoreService;
|
|
import com.yonge.cooleshow.biz.dal.service.SysConfigService;
|
|
import com.yonge.cooleshow.biz.dal.service.SysConfigService;
|
|
-import com.yonge.cooleshow.biz.dal.service.TeacherService;
|
|
|
|
import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
|
|
import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
|
|
import com.yonge.cooleshow.biz.dal.service.UserTenantAlbumRecordService;
|
|
import com.yonge.cooleshow.biz.dal.service.UserTenantAlbumRecordService;
|
|
import com.yonge.cooleshow.biz.dal.vo.MyFollow;
|
|
import com.yonge.cooleshow.biz.dal.vo.MyFollow;
|
|
@@ -52,6 +48,7 @@ import com.yonge.cooleshow.common.enums.UserLockFlag;
|
|
import com.yonge.cooleshow.common.enums.YesOrNoEnum;
|
|
import com.yonge.cooleshow.common.enums.YesOrNoEnum;
|
|
import com.yonge.toolset.base.util.StringUtil;
|
|
import com.yonge.toolset.base.util.StringUtil;
|
|
import com.yonge.toolset.mybatis.support.PageUtil;
|
|
import com.yonge.toolset.mybatis.support.PageUtil;
|
|
|
|
+import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
|
|
import com.yonge.toolset.utils.date.DateUtil;
|
|
import com.yonge.toolset.utils.date.DateUtil;
|
|
import com.yonge.toolset.utils.easyexcel.ExcelDataReaderProperty;
|
|
import com.yonge.toolset.utils.easyexcel.ExcelDataReaderProperty;
|
|
import com.yonge.toolset.utils.string.ValueUtil;
|
|
import com.yonge.toolset.utils.string.ValueUtil;
|
|
@@ -67,7 +64,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.text.MessageFormat;
|
|
import java.text.MessageFormat;
|
|
-import java.text.ParseException;
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
@@ -121,6 +117,10 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
@Autowired
|
|
@Autowired
|
|
private CustomerServiceConfig customerServiceConfig;
|
|
private CustomerServiceConfig customerServiceConfig;
|
|
|
|
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysMessageService sysMessageService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public StudentDao getDao() {
|
|
public StudentDao getDao() {
|
|
return baseMapper;
|
|
return baseMapper;
|
|
@@ -129,6 +129,9 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
@Autowired
|
|
@Autowired
|
|
private ImGroupCoreService imGroupCoreService;
|
|
private ImGroupCoreService imGroupCoreService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private TenantGroupMapper tenantGroupMapper;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public StudentVo detail(Long userId) {
|
|
public StudentVo detail(Long userId) {
|
|
return baseMapper.detail(userId);
|
|
return baseMapper.detail(userId);
|
|
@@ -207,11 +210,18 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
studentHomeVo.setTenantAlbumStatus(1);
|
|
studentHomeVo.setTenantAlbumStatus(1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- UserTenantAlbumRecord record =
|
|
|
|
- userTenantAlbumRecordService.getNewestByTenantIdAndUserId(tenantInfo.getId(), detail.getUserId(),
|
|
|
|
- ClientEnum.STUDENT);
|
|
|
|
|
|
+ UserTenantAlbumRecord record = userTenantAlbumRecordService.lambdaQuery()
|
|
|
|
+ .eq(UserTenantAlbumRecord::getTenantId, tenantInfo.getId())
|
|
|
|
+ .eq(UserTenantAlbumRecord::getUserId, detail.getUserId())
|
|
|
|
+ .eq(UserTenantAlbumRecord::getClientType, ClientEnum.STUDENT)
|
|
|
|
+ .orderByDesc(UserTenantAlbumRecord::getEndTime)
|
|
|
|
+ .last("limit 1").one();
|
|
if (record == null || record.getEndTime().getTime() < System.currentTimeMillis()) {
|
|
if (record == null || record.getEndTime().getTime() < System.currentTimeMillis()) {
|
|
studentHomeVo.setTenantAlbumFlag(YesOrNoEnum.NO);
|
|
studentHomeVo.setTenantAlbumFlag(YesOrNoEnum.NO);
|
|
|
|
+ if (record != null) {
|
|
|
|
+ studentHomeVo.setTenantAlbumStartTime(record.getStartTime());
|
|
|
|
+ studentHomeVo.setTenantAlbumEndTime(record.getEndTime());
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
studentHomeVo.setTenantAlbumStatus(2);
|
|
studentHomeVo.setTenantAlbumStatus(2);
|
|
studentHomeVo.setTenantAlbumFlag(YesOrNoEnum.YES);
|
|
studentHomeVo.setTenantAlbumFlag(YesOrNoEnum.YES);
|
|
@@ -220,6 +230,12 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ if (detail.getTenantGroupId() != null) {
|
|
|
|
+ TenantGroup tenantGroup = tenantGroupMapper.selectById(detail.getTenantGroupId());
|
|
|
|
+ if (tenantGroup != null) {
|
|
|
|
+ studentHomeVo.setTenantGroupName(tenantGroup.getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
return studentHomeVo;
|
|
return studentHomeVo;
|
|
}
|
|
}
|
|
@@ -434,6 +450,10 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
public Boolean save(StudentWrapper.Student studentInfo) {
|
|
public Boolean save(StudentWrapper.Student studentInfo) {
|
|
|
|
+ if (studentInfo.getTenantGroupId() == null) {
|
|
|
|
+ studentInfo.setTenantGroupId(-1L);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (studentInfo.getId() == null) {
|
|
if (studentInfo.getId() == null) {
|
|
return createStudent(studentInfo);
|
|
return createStudent(studentInfo);
|
|
} else {
|
|
} else {
|
|
@@ -450,6 +470,11 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
}
|
|
}
|
|
dataList.sort(Comparator.comparingInt(ExcelDataReaderProperty::getRowIndex));
|
|
dataList.sort(Comparator.comparingInt(ExcelDataReaderProperty::getRowIndex));
|
|
|
|
|
|
|
|
+ QueryWrapper<TenantGroup> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.lambda().eq(TenantGroup::getTenantId, tenantId);
|
|
|
|
+ List<TenantGroup> groups = tenantGroupMapper.selectList(queryWrapper);
|
|
|
|
+ Map<String, Long> groupNameIdMap = groups.stream().collect(Collectors.toMap(TenantGroup::getName, TenantGroup::getId));
|
|
|
|
+
|
|
Map<String, Long> subjectIdNamemap = subjectDao.findAll(new HashMap<>())
|
|
Map<String, Long> subjectIdNamemap = subjectDao.findAll(new HashMap<>())
|
|
.stream().collect(Collectors.toMap(next -> next.getName(), next -> next.getId()));
|
|
.stream().collect(Collectors.toMap(next -> next.getName(), next -> next.getId()));
|
|
Set<String> subjectNames = subjectIdNamemap.keySet();
|
|
Set<String> subjectNames = subjectIdNamemap.keySet();
|
|
@@ -464,16 +489,23 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
int msgRowNo = rowIndex + 1;
|
|
int msgRowNo = rowIndex + 1;
|
|
student.checkValid().forEach(err -> errMsg.add(String.format("第%s行%s", msgRowNo, err)));
|
|
student.checkValid().forEach(err -> errMsg.add(String.format("第%s行%s", msgRowNo, err)));
|
|
|
|
|
|
- if (phoneMap.containsKey(student.getPhone().trim())) {
|
|
|
|
- errMsg.add(String.format("第%s行手机号重复", msgRowNo));
|
|
|
|
- } else {
|
|
|
|
- phoneMap.put(student.getPhone().trim(), msgRowNo);
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(student.getPhone())) {
|
|
|
|
+ if (phoneMap.containsKey(student.getPhone())) {
|
|
|
|
+ errMsg.add(String.format("第%s行手机号重复", msgRowNo));
|
|
|
|
+ } else {
|
|
|
|
+ phoneMap.put(student.getPhone(), msgRowNo);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- if (!subjectNames.contains(student.getSubjectName())) {
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(student.getSubjectName()) && !subjectNames.contains(student.getSubjectName())) {
|
|
errMsg.add(String.format("第%s行声部不支持", msgRowNo));
|
|
errMsg.add(String.format("第%s行声部不支持", msgRowNo));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(student.getTenantGroupName()) &&
|
|
|
|
+ !groupNameIdMap.containsKey(student.getTenantGroupName())) {
|
|
|
|
+ errMsg.add(String.format("第%s行小组不存在", msgRowNo));
|
|
|
|
+ }
|
|
|
|
+
|
|
if (errMsg.size() > 100) {
|
|
if (errMsg.size() > 100) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -517,6 +549,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
student.setGender("男".equals(studentImport.getGender()) ? 1 : 0);
|
|
student.setGender("男".equals(studentImport.getGender()) ? 1 : 0);
|
|
student.setSubjectId(subjectIdNamemap.get(studentImport.getSubjectName()).toString());
|
|
student.setSubjectId(subjectIdNamemap.get(studentImport.getSubjectName()).toString());
|
|
student.setPhone(studentImport.getPhone());
|
|
student.setPhone(studentImport.getPhone());
|
|
|
|
+ student.setTenantGroupId(groupNameIdMap.getOrDefault(studentImport.getTenantGroupName(), -1L));
|
|
|
|
|
|
LocalDate birthday = LocalDate.parse(studentImport.getBirthday(), DateTimeFormatter.ISO_LOCAL_DATE);
|
|
LocalDate birthday = LocalDate.parse(studentImport.getBirthday(), DateTimeFormatter.ISO_LOCAL_DATE);
|
|
student.setBirthdate(birthday);
|
|
student.setBirthdate(birthday);
|
|
@@ -569,8 +602,38 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.lambdaUpdate().set(Student::getTenantId, toTenantId)
|
|
this.lambdaUpdate().set(Student::getTenantId, toTenantId)
|
|
|
|
+ .set(Student::getTenantGroupId, -1L)
|
|
.eq(Student::getUserId, student.getUserId())
|
|
.eq(Student::getUserId, student.getUserId())
|
|
.update();
|
|
.update();
|
|
|
|
+
|
|
|
|
+ sendStudentTenantChange(student,toTenantId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void sendStudentTenantChange(Student student, Long toTenantId) {
|
|
|
|
+ if (student.getTenantId() == null || student.getTenantId() == -1) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserById(student.getUserId());
|
|
|
|
+ if (sysUser == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ TenantInfo tenantInfo = tenantInfoService.getById(student.getTenantId());
|
|
|
|
+ if (tenantInfo == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ TenantInfo newTenantInfo = tenantInfoService.getById(toTenantId);
|
|
|
|
+ if (newTenantInfo == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Map<Long, String> receivers = new HashMap<>();
|
|
|
|
+ receivers.put(student.getUserId(), sysUser.getPhone());
|
|
|
|
+ try {
|
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.TENANT_STUDENT_CHANGE,
|
|
|
|
+ receivers, null, 0, null, ClientEnum.TENANT_STUDENT.getCode(),tenantInfo.getName(),newTenantInfo.getName());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("学生机构变更极光消息推送异常,", e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private Boolean updateStudent(StudentWrapper.Student studentInfo) {
|
|
private Boolean updateStudent(StudentWrapper.Student studentInfo) {
|
|
@@ -615,16 +678,22 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
studentIds.add(student.getUserId());
|
|
studentIds.add(student.getUserId());
|
|
imUserFriendService.saveUserFriend(teacher.getUserId(), studentIds);
|
|
imUserFriendService.saveUserFriend(teacher.getUserId(), studentIds);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ sendStudentTenantChange(student,newTenantId);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
// 手机号码修改
|
|
// 手机号码修改
|
|
|
|
+ boolean updatePhone = false;
|
|
if (!student.getPhone().equals(studentInfo.getPhone())) {
|
|
if (!student.getPhone().equals(studentInfo.getPhone())) {
|
|
- com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = getOrCreateAccount(studentInfo);
|
|
|
|
|
|
+ updatePhone = true;
|
|
|
|
+ SysUser oldSysUser = sysUserMapper.getByUserId(studentInfo.getId());
|
|
|
|
+ com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = getOrCreateAccount(studentInfo, oldSysUser.getPassword());
|
|
this.lambdaUpdate().set(Student::getSubjectId, studentInfo.getSubjectId())
|
|
this.lambdaUpdate().set(Student::getSubjectId, studentInfo.getSubjectId())
|
|
.set(Student::getTenantId, studentInfo.getTenantId())
|
|
.set(Student::getTenantId, studentInfo.getTenantId())
|
|
.set(Student::getUserId, sysUser.getId())
|
|
.set(Student::getUserId, sysUser.getId())
|
|
.set(Student::getUpdateTime, new Date())
|
|
.set(Student::getUpdateTime, new Date())
|
|
|
|
+ .set(Student::getTenantGroupId, studentInfo.getTenantGroupId())
|
|
.set(StringUtils.isNotEmpty(studentInfo.getAvatar()), Student::getAvatar, studentInfo.getAvatar())
|
|
.set(StringUtils.isNotEmpty(studentInfo.getAvatar()), Student::getAvatar, studentInfo.getAvatar())
|
|
.eq(Student::getUserId, studentInfo.getId())
|
|
.eq(Student::getUserId, studentInfo.getId())
|
|
.update();
|
|
.update();
|
|
@@ -635,6 +704,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
newStudent.setUpdateTime(new Date());
|
|
newStudent.setUpdateTime(new Date());
|
|
newStudent.setTenantId(studentInfo.getTenantId());
|
|
newStudent.setTenantId(studentInfo.getTenantId());
|
|
newStudent.setAvatar(studentInfo.getAvatar());
|
|
newStudent.setAvatar(studentInfo.getAvatar());
|
|
|
|
+ newStudent.setTenantGroupId(studentInfo.getTenantGroupId());
|
|
this.getBaseMapper().updateById(newStudent);
|
|
this.getBaseMapper().updateById(newStudent);
|
|
}
|
|
}
|
|
com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = sysUserMapper.selectById(studentInfo.getId());
|
|
com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = sysUserMapper.selectById(studentInfo.getId());
|
|
@@ -653,17 +723,92 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.warn("学生注册IM失败:" + e.getMessage());
|
|
log.warn("学生注册IM失败:" + e.getMessage());
|
|
}
|
|
}
|
|
|
|
+ // 手机号修改,退出登录
|
|
|
|
+ if (updatePhone) {
|
|
|
|
+ sysUserFeignService.exitByPhone(ClientEnum.STUDENT.getCode().toLowerCase(), student.getPhone());
|
|
|
|
+ }
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void quitFromTenantGroupIM(Long tenantGroupId, Long studentId) {
|
|
|
|
+ TenantGroup tenantGroup = tenantGroupMapper.selectById(tenantGroupId);
|
|
|
|
+ if (tenantGroup == null || StringUtils.isEmpty(tenantGroup.getImGroupId())) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ String imGroupId = tenantGroup.getImGroupId();
|
|
|
|
+ ImGroup imGroup = imGroupService.getById(imGroupId);
|
|
|
|
+ if (imGroup == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Integer count = imGroupMemberService.lambdaQuery()
|
|
|
|
+ .eq(ImGroupMember::getId, imGroupId)
|
|
|
|
+ .eq(ImGroupMember::getUserId, studentId)
|
|
|
|
+ .eq(ImGroupMember::getRoleType, ImGroupMemberRoleType.STUDENT)
|
|
|
|
+ .count();
|
|
|
|
+ if (count == 0) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ imGroupService.quit(imGroupId, studentId, ClientEnum.STUDENT, true);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("退出机构小组群失败", e);
|
|
|
|
+ throw new BizException("退出机构小组群失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加到机构小组IM群
|
|
|
|
+ * @param tenantGroupId 机构小组ID
|
|
|
|
+ * @param studentId 学生ID
|
|
|
|
+ */
|
|
|
|
+ private void add2TenantGroupIM(Long tenantGroupId, Long studentId) {
|
|
|
|
+ TenantGroup tenantGroup = tenantGroupMapper.selectById(tenantGroupId);
|
|
|
|
+ String imGroupId = tenantGroup.getImGroupId();
|
|
|
|
+ if (imGroupId == null) {
|
|
|
|
+ // 建群
|
|
|
|
+ try {
|
|
|
|
+ ImGroupWrapper.ImGroup imGroup = new ImGroupWrapper.ImGroup();
|
|
|
|
+ imGroup.setId(IdWorker.getId());
|
|
|
|
+ imGroup.setCreateBy(tenantGroup.getAdminId());
|
|
|
|
+ imGroup.setType(ImGroupType.ORG.getCode());
|
|
|
|
+ imGroup.setName(tenantGroup.getName());
|
|
|
|
+ imGroupId = imGroupService.create(imGroup);
|
|
|
|
+ tenantGroup.setImGroupId(imGroupId);
|
|
|
|
+ tenantGroupMapper.updateById(tenantGroup);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("创建机构小组群失败", e);
|
|
|
|
+ throw new BizException("创建机构小组群失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if ("-1".equals(imGroupId)) {
|
|
|
|
+ // 群已经解散,改为-1标志
|
|
|
|
+ log.info("群已经解散,不再添加机构小组群:" + imGroupId);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ ImGroup imGroup = imGroupService.getById(imGroupId);
|
|
|
|
+ if (imGroup != null) {
|
|
|
|
+ Set<Long> userIds = new HashSet<>();
|
|
|
|
+ userIds.add(studentId);
|
|
|
|
+ imGroupService.addGroupMember(imGroupId, userIds);
|
|
|
|
+ } else {
|
|
|
|
+ tenantGroup.setImGroupId("-1");
|
|
|
|
+ tenantGroupMapper.updateById(tenantGroup);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("加入机构小组群失败", e);
|
|
|
|
+ throw new BizException("加入机构小组群失败");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private Boolean createStudent(StudentWrapper.Student studentInfo) {
|
|
private Boolean createStudent(StudentWrapper.Student studentInfo) {
|
|
String avatar = studentInfo.getAvatar();
|
|
String avatar = studentInfo.getAvatar();
|
|
if (StringUtils.isEmpty(avatar)) {
|
|
if (StringUtils.isEmpty(avatar)) {
|
|
avatar = sysConfigService.findConfigValue(SysConfigConstant.STUDENT_AVATAR);
|
|
avatar = sysConfigService.findConfigValue(SysConfigConstant.STUDENT_AVATAR);
|
|
studentInfo.setAvatar(avatar);
|
|
studentInfo.setAvatar(avatar);
|
|
}
|
|
}
|
|
- com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = getOrCreateAccount(studentInfo);
|
|
|
|
|
|
+ com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = getOrCreateAccount(studentInfo, null);
|
|
Student student = new Student();
|
|
Student student = new Student();
|
|
student.setUserId(sysUser.getId());
|
|
student.setUserId(sysUser.getId());
|
|
student.setTenantId(studentInfo.getTenantId());
|
|
student.setTenantId(studentInfo.getTenantId());
|
|
@@ -671,6 +816,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
student.setAvatar(studentInfo.getAvatar());
|
|
student.setAvatar(studentInfo.getAvatar());
|
|
student.setCreateTime(new Date());
|
|
student.setCreateTime(new Date());
|
|
student.setLockFlag(UserLockFlag.NORMAL);
|
|
student.setLockFlag(UserLockFlag.NORMAL);
|
|
|
|
+ student.setTenantGroupId(studentInfo.getTenantGroupId());
|
|
|
|
|
|
save(student);
|
|
save(student);
|
|
try {
|
|
try {
|
|
@@ -692,7 +838,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
|
|
|
|
// 与随机一个客服建立好友
|
|
// 与随机一个客服建立好友
|
|
String customerService = customerServiceConfig.getCustomerService();
|
|
String customerService = customerServiceConfig.getCustomerService();
|
|
- if(StringUtils.isNotBlank(customerService)){
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(customerService)) {
|
|
List<String> phones = Arrays.stream(customerService.split(",")).collect(Collectors.toList());
|
|
List<String> phones = Arrays.stream(customerService.split(",")).collect(Collectors.toList());
|
|
Random rand = new Random();
|
|
Random rand = new Random();
|
|
String mobile = phones.get(rand.nextInt(phones.size()));
|
|
String mobile = phones.get(rand.nextInt(phones.size()));
|
|
@@ -703,10 +849,16 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 加入机构小组群
|
|
|
|
+// if (studentInfo.getTenantGroupId() != -1L) {
|
|
|
|
+// add2TenantGroupIM(student.getTenantGroupId(), student.getUserId());
|
|
|
|
+// }
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- private com.yonge.cooleshow.biz.dal.entity.SysUser getOrCreateAccount(StudentWrapper.Student studentInfo) {
|
|
|
|
|
|
+ private com.yonge.cooleshow.biz.dal.entity.SysUser getOrCreateAccount(StudentWrapper.Student studentInfo,
|
|
|
|
+ String password) {
|
|
QueryWrapper<com.yonge.cooleshow.biz.dal.entity.SysUser> sysUserQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<com.yonge.cooleshow.biz.dal.entity.SysUser> sysUserQueryWrapper = new QueryWrapper<>();
|
|
sysUserQueryWrapper.lambda().eq(com.yonge.cooleshow.biz.dal.entity.SysUser::getPhone, studentInfo.getPhone());
|
|
sysUserQueryWrapper.lambda().eq(com.yonge.cooleshow.biz.dal.entity.SysUser::getPhone, studentInfo.getPhone());
|
|
List<com.yonge.cooleshow.biz.dal.entity.SysUser> sysUsers = sysUserMapper.selectList(sysUserQueryWrapper);
|
|
List<com.yonge.cooleshow.biz.dal.entity.SysUser> sysUsers = sysUserMapper.selectList(sysUserQueryWrapper);
|
|
@@ -742,10 +894,13 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
|
|
sysUser.setUserType("STUDENT");
|
|
sysUser.setUserType("STUDENT");
|
|
sysUser.setBirthdate(studentInfo.getBirthdate());
|
|
sysUser.setBirthdate(studentInfo.getBirthdate());
|
|
sysUser.setUsername(studentInfo.getName());
|
|
sysUser.setUsername(studentInfo.getName());
|
|
-
|
|
|
|
- String newPassword = MessageFormat.format("klx{0}", studentInfo.getPhone().substring(7));
|
|
|
|
- String password = new BCryptPasswordEncoder().encode(newPassword);
|
|
|
|
sysUser.setPassword(password);
|
|
sysUser.setPassword(password);
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isEmpty(password)) {
|
|
|
|
+ String newPassword = MessageFormat.format("klx{0}", studentInfo.getPhone().substring(7));
|
|
|
|
+ sysUser.setPassword(new BCryptPasswordEncoder().encode(newPassword));
|
|
|
|
+ }
|
|
|
|
+
|
|
sysUserMapper.insert(sysUser);
|
|
sysUserMapper.insert(sysUser);
|
|
}
|
|
}
|
|
return sysUser;
|
|
return sysUser;
|