|
@@ -1,47 +1,51 @@
|
|
|
package com.fs.course.service.impl;
|
|
|
|
|
|
-import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
+import com.fs.common.utils.PubFun;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
-import com.fs.company.domain.CompanyUser;
|
|
|
+import com.fs.common.utils.date.DateUtil;
|
|
|
import com.fs.company.mapper.CompanyUserMapper;
|
|
|
import com.fs.config.cloud.CloudHostProper;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
|
-import com.fs.course.domain.FsCourseDomainName;
|
|
|
-import com.fs.course.domain.FsCourseLink;
|
|
|
-import com.fs.course.domain.FsCourseRealLink;
|
|
|
-import com.fs.course.domain.FsUserCourseVideo;
|
|
|
+import com.fs.course.domain.*;
|
|
|
import com.fs.course.mapper.FsCourseDomainNameMapper;
|
|
|
import com.fs.course.mapper.FsCourseLinkMapper;
|
|
|
+import com.fs.course.mapper.FsCourseWatchLogMapper;
|
|
|
import com.fs.course.mapper.FsUserCourseVideoMapper;
|
|
|
import com.fs.course.param.FsCourseLinkCreateParam;
|
|
|
-import com.fs.course.service.IFsCourseDomainNameService;
|
|
|
+import com.fs.course.param.FsCourseLinkRoomParam;
|
|
|
import com.fs.course.service.IFsCourseLinkService;
|
|
|
+import com.fs.course.service.IFsUserCourseService;
|
|
|
+import com.fs.qw.domain.QwGroupChat;
|
|
|
+import com.fs.qw.domain.QwGroupChatUser;
|
|
|
import com.fs.qw.domain.QwUser;
|
|
|
+import com.fs.qw.mapper.QwExternalContactMapper;
|
|
|
import com.fs.qw.mapper.QwUserMapper;
|
|
|
+import com.fs.qw.service.IQwGroupChatService;
|
|
|
+import com.fs.qw.service.IQwGroupChatUserService;
|
|
|
+import com.fs.qw.vo.GroupUserExternalVo;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.voice.utils.StringUtil;
|
|
|
import lombok.Synchronized;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.checkerframework.checker.units.qual.A;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
-import java.net.URI;
|
|
|
import java.net.URLDecoder;
|
|
|
-import java.security.SecureRandom;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
import java.util.*;
|
|
|
|
|
|
import static com.fs.course.utils.LinkUtil.generateRandomStringWithLock;
|
|
|
+import static com.fs.sop.service.impl.SopUserLogsInfoServiceImpl.convertStringToDate;
|
|
|
|
|
|
/**
|
|
|
* 短链Service业务层处理
|
|
@@ -60,6 +64,21 @@ public class FsCourseLinkServiceImpl implements IFsCourseLinkService
|
|
|
|
|
|
@Autowired
|
|
|
private FsCourseDomainNameMapper fsCourseDomainNameMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsCourseWatchLogMapper fsCourseWatchLogMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QwExternalContactMapper qwExternalContactMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsUserCourseService fsUserCourseService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IQwGroupChatService qwGroupChatService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IQwGroupChatUserService qwGroupChatUserService;
|
|
|
@Autowired
|
|
|
private QwUserMapper qwUserMapper;
|
|
|
@Autowired
|
|
@@ -559,4 +578,84 @@ public class FsCourseLinkServiceImpl implements IFsCourseLinkService
|
|
|
return R.error("发生未知错误,请稍后再试").put("realLink", link);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R createRoomLink(FsCourseLinkRoomParam param, QwUser qwUser) {
|
|
|
+ FsCourseLinkCreateParam createParam = new FsCourseLinkCreateParam();
|
|
|
+ createParam.setCourseId(param.getCourseId());
|
|
|
+ createParam.setVideoId(param.getVideoId());
|
|
|
+ createParam.setCorpId(param.getCorpId());
|
|
|
+ createParam.setCompanyUserId(qwUser.getCompanyUserId());
|
|
|
+ createParam.setCompanyId(qwUser.getCompanyId());
|
|
|
+ createParam.setQwUserId(qwUser.getId());
|
|
|
+ createParam.setChatId(param.getChatId());
|
|
|
+ String linkUrl;
|
|
|
+ R createLink = createRoomLinkUrl(createParam);
|
|
|
+ if (createLink.get("code").equals(500)){
|
|
|
+ return R.error("链接生成失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ QwGroupChat groupChat = qwGroupChatService.selectQwGroupChatByChatId(param.getChatId());
|
|
|
+ List<QwGroupChatUser> qwGroupChatUserList = qwGroupChatUserService.selectQwGroupChatUserByChatIds(new String[]{param.getChatId()});
|
|
|
+ List<String> groupChatUserIds = PubFun.listToNewList(qwGroupChatUserList, QwGroupChatUser::getUserId);
|
|
|
+ if(!groupChatUserIds.isEmpty()){
|
|
|
+ List<GroupUserExternalVo> userList = qwExternalContactMapper.selectByGroupUser(groupChatUserIds);
|
|
|
+ Map<String, List<GroupUserExternalVo>> userMap = PubFun.listToMapByGroupList(userList, GroupUserExternalVo::getExternalUserId);
|
|
|
+ qwGroupChatUserList.forEach(e -> {
|
|
|
+ e.setUserList(userMap.getOrDefault(e.getUserId(), Collections.emptyList()));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ qwGroupChatUserList.stream().filter(e -> e.getUserList() != null && !e.getUserList().isEmpty()).forEach(e -> {
|
|
|
+ Map<String, GroupUserExternalVo> userMap = PubFun.listToMapByGroupObject(e.getUserList(), GroupUserExternalVo::getUserId);
|
|
|
+ GroupUserExternalVo vo = userMap.get(groupChat.getOwner());
|
|
|
+ if (vo != null && vo.getId() != null) {
|
|
|
+ addWatchLogIfNeeded(param.getVideoId(), param.getCourseId(), vo.getFsUserId(), qwUser.getId(), qwUser.getCompanyUserId(), qwUser.getCompanyId(), vo.getId(), new Date(), new Date());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("群聊创建看课记录失败!", e);
|
|
|
+ }
|
|
|
+
|
|
|
+ linkUrl = (String) createLink.get("url");
|
|
|
+
|
|
|
+ FsUserCourse course = fsUserCourseService.selectFsUserCourseByCourseId(param.getCourseId());
|
|
|
+
|
|
|
+ JSONObject news = new JSONObject(true); // true 表示保持字段顺序
|
|
|
+ news.put("link", linkUrl);
|
|
|
+ news.put("title", course.getCourseName());
|
|
|
+ news.put("desc", param.getTitle());
|
|
|
+ news.put("imgUrl", course.getImgUrl());
|
|
|
+ return R.ok().put("news",news);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void addWatchLogIfNeeded(Long videoId, Long courseId,
|
|
|
+ Long fsUserId, Long qwUserId, Long companyUserId,
|
|
|
+ Long companyId, Long externalId, Date startTime,Date createTime) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ FsCourseWatchLog watchLog = new FsCourseWatchLog();
|
|
|
+ watchLog.setVideoId(videoId);
|
|
|
+ watchLog.setQwExternalContactId(externalId);
|
|
|
+ watchLog.setSendType(2);
|
|
|
+ watchLog.setQwUserId(qwUserId);
|
|
|
+ watchLog.setDuration(0L);
|
|
|
+ watchLog.setCourseId(courseId);
|
|
|
+ watchLog.setCompanyUserId(companyUserId);
|
|
|
+ watchLog.setCompanyId(companyId);
|
|
|
+ watchLog.setCreateTime(createTime);
|
|
|
+ watchLog.setUpdateTime(createTime);
|
|
|
+ watchLog.setLogType(3);
|
|
|
+ watchLog.setUserId(fsUserId);
|
|
|
+ watchLog.setCampPeriodTime(startTime);
|
|
|
+ //存看课记录
|
|
|
+ fsCourseWatchLogMapper.insertOrUpdateFsCourseWatchLog(watchLog);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("一键群发失败-插入观看记录失败:"+e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|