|
@@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.google.common.collect.Lists;
|
|
|
-import com.microsvc.toolkit.middleware.rtc.enums.EDeviceMessageType;
|
|
|
import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
|
|
|
import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
|
|
|
import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
@@ -48,10 +47,8 @@ import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMapper;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumRefMapper;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantUnbindHistoryMapper;
|
|
|
import com.yonge.cooleshow.biz.dal.mapper.TenantUnbindRecordMapper;
|
|
|
-import com.yonge.cooleshow.biz.dal.queryInfo.TeacherQueryInfo;
|
|
|
import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.HotTeacherVo;
|
|
|
-import com.yonge.cooleshow.biz.dal.vo.MusicSheetUploadCountVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.MyFens;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.TeacherAuthEntryRecordVo;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.TeacherHomeVo;
|
|
@@ -61,8 +58,6 @@ import com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.UserPaymentOrderWrapper;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.im.ImGroupWrapper;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherWrapper;
|
|
|
-import com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper;
|
|
|
-import com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherWrapper;
|
|
|
import com.yonge.cooleshow.common.constant.SysConfigConstant;
|
|
|
import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
import com.yonge.cooleshow.common.enums.CacheNameEnum;
|
|
@@ -94,17 +89,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.yonge.cooleshow.biz.dal.constant.LiveRoomConstant.TEACHER_TEMP_LIVE_ROOM;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.redisson.api.RMap;
|
|
|
-import org.redisson.api.RedissonClient;
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
-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;
|
|
@@ -112,11 +97,6 @@ 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;
|
|
|
-
|
|
|
-import static com.yonge.cooleshow.biz.dal.constant.LiveRoomConstant.TEACHER_TEMP_LIVE_ROOM;
|
|
|
|
|
|
@Service
|
|
|
public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> implements TeacherService {
|
|
@@ -599,15 +579,11 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
|
|
|
sendBindUnBindSMS(teacher.getUserId(), teacherSubmitReq.getPhone(), MessageTypeEnum.TEACHER_BIND_TENANT, teacher.getTenantId());
|
|
|
|
|
|
// 与客服建立好友
|
|
|
- String customerService = customerServiceConfig.getCustomerService();
|
|
|
- if (StringUtils.isNotBlank(customerService)) {
|
|
|
- List<String> phones = Arrays.stream(customerService.split(",")).collect(Collectors.toList());
|
|
|
- Random rand = new Random();
|
|
|
- String mobile = phones.get(rand.nextInt(phones.size()));
|
|
|
- SysUser friend = sysUserMapper.findUserByPhone(mobile);
|
|
|
- if (friend != null) {
|
|
|
+ if (!Boolean.TRUE.equals(teacher.getCustomerService())) {
|
|
|
+ Teacher customerServiceTeacher = getCustomerServiceByFriendLeast();
|
|
|
+ if (customerServiceTeacher != null) {
|
|
|
imUserFriendService.registerUserBindCustomerService(teacher.getUserId(),
|
|
|
- Collections.singletonList(friend.getId()), ClientEnum.TEACHER);
|
|
|
+ Collections.singletonList(customerServiceTeacher.getUserId()), ClientEnum.TEACHER);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -631,6 +607,11 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
|
|
|
updateTenant(updateTenant, teacherSubmitReq.getUpdateBy());
|
|
|
}
|
|
|
|
|
|
+ // 客服状态变更,移交好友信息
|
|
|
+ if (Boolean.TRUE.equals(teacher.getCustomerService()) && Boolean.FALSE.equals(teacherSubmitReq.getCustomerService())) {
|
|
|
+ transferFriend(teacher.getUserId());
|
|
|
+ }
|
|
|
+
|
|
|
teacher.setUpdateTime(new Date());
|
|
|
teacher = getTeacherDetil(teacher, teacherSubmitReq);
|
|
|
if (null == teacher.getEntryAuthDate() || null == teacher.getMusicianDate()) {
|
|
@@ -648,6 +629,33 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
|
|
|
return teacher;
|
|
|
}
|
|
|
|
|
|
+ // 客服好友移交给其他客服
|
|
|
+ private void transferFriend(Long userId) {
|
|
|
+ List<ImUserFriend> friendList = imUserFriendService.lambdaQuery()
|
|
|
+ .eq(ImUserFriend::getUserId, userId)
|
|
|
+ .eq(ImUserFriend::getClientType, ClientEnum.TEACHER)
|
|
|
+ .list();
|
|
|
+ if (friendList.isEmpty()) { // 没有好友
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Teacher> customerService = getCustomerService();
|
|
|
+ List<Long> teacherIdList = customerService.stream().map(Teacher::getUserId).collect(Collectors.toList());
|
|
|
+ teacherIdList.removeIf(n->n.equals(userId));
|
|
|
+ if (teacherIdList.isEmpty()) { // 没有客服
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ List<Long> friendIdList = friendList.stream().map(ImUserFriend::getFriendId).collect(Collectors.toList());
|
|
|
+ friendIdList.removeIf(teacherIdList::contains);
|
|
|
+ if (friendIdList.isEmpty()) { // 有一个客服好友
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //todo
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/***
|
|
|
* 封装用户信息
|
|
|
* @author liweifan
|
|
@@ -700,6 +708,7 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
|
|
|
teacher.setSettlementFrom(teacherSubmitReq.getSettlementFrom());
|
|
|
teacher.setTenantId(teacherSubmitReq.getTenantId() == null ? -1L : teacherSubmitReq.getTenantId());
|
|
|
teacher.setAvatar(Optional.ofNullable(teacherSubmitReq.getAvatar()).orElse(teacher.getAvatar()));
|
|
|
+ teacher.setCustomerService(teacherSubmitReq.getCustomerService());
|
|
|
if (StringUtil.isEmpty(teacherSubmitReq.getTeacherType())) {
|
|
|
return teacher;
|
|
|
}
|
|
@@ -1117,7 +1126,10 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
|
|
|
});
|
|
|
}
|
|
|
// 删除好友关系
|
|
|
- imUserFriendService.delStudentFriendByTenantId(teacher.getTenantId(), teacher.getUserId(), ClientEnum.TEACHER.getCode());
|
|
|
+ Boolean customerService = teacher.getCustomerService();
|
|
|
+ if (Boolean.FALSE.equals(customerService)) {
|
|
|
+ imUserFriendService.delStudentFriendByTenantId(teacher.getTenantId(), teacher.getUserId(), ClientEnum.TEACHER.getCode());
|
|
|
+ }
|
|
|
addBindUnBindRecord(teacher.getUserId(), teacher.getTenantId(), false);
|
|
|
SysUser sysUser = sysUserMapper.getByUserId(teacher.getUserId());
|
|
|
sendBindUnBindSMS(teacher.getUserId(), sysUser.getPhone(), MessageTypeEnum.TEACHER_UNBIND_TENANT, teacher.getTenantId());
|
|
@@ -1250,4 +1262,20 @@ public class TeacherServiceImpl extends ServiceImpl<TeacherDao, Teacher> impleme
|
|
|
sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, messageType,
|
|
|
receivers, null, 0, null, ClientEnum.SYSTEM.getCode(), tenantInfo.getName());
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取学生好友最少的一个客服
|
|
|
+ * @return 客服
|
|
|
+ */
|
|
|
+ private Teacher getCustomerServiceByFriendLeast() {
|
|
|
+ return this.getBaseMapper().getCustomerServiceByFriendLeast();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Teacher> getCustomerService() {
|
|
|
+ return this.lambdaQuery()
|
|
|
+ .eq(Teacher::getCustomerService, true)
|
|
|
+ .eq(Teacher::getLockFlag, false)
|
|
|
+ .list();
|
|
|
+ }
|
|
|
}
|