|
|
@@ -20,7 +20,6 @@ import com.fs.course.domain.FsCourseLink;
|
|
|
import com.fs.course.domain.FsCoursePlaySourceConfig;
|
|
|
import com.fs.course.domain.FsCourseWatchLog;
|
|
|
import com.fs.course.mapper.FsCourseLinkMapper;
|
|
|
-import com.fs.course.mapper.FsUserCourseVideoMapper;
|
|
|
import com.fs.course.service.IFsCourseWatchLogService;
|
|
|
import com.fs.feishu.domain.FeishuAccount;
|
|
|
import com.fs.feishu.domain.FeishuLinkError;
|
|
|
@@ -48,6 +47,7 @@ import com.fs.qw.service.IRedPacketService;
|
|
|
import com.fs.qw.vo.QwSopCourseFinishTempSetting;
|
|
|
import com.fs.qwApi.param.QwExternalContactHParam;
|
|
|
import com.fs.sop.domain.QwSopLogs;
|
|
|
+import com.fs.sop.mapper.QwSopLogsMapper;
|
|
|
import com.fs.sop.service.IQwSopLogsService;
|
|
|
import com.fs.sop.service.impl.QwSopLogsServiceImpl;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
@@ -57,6 +57,7 @@ import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
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;
|
|
|
@@ -117,6 +118,8 @@ public class IpadSendServer {
|
|
|
private FeishuLinkErrorMapper feishuLinkErrorMapper;
|
|
|
@Autowired
|
|
|
private FeiShuService feiShuService;
|
|
|
+ @Autowired
|
|
|
+ private QwSopLogsMapper qwSopLogsMapper;
|
|
|
|
|
|
//销售的个人飞书应用账户缓存的key
|
|
|
private static final String FEISHU_COMPANY_USER_KEY = "feishu:account_company_user:";
|
|
|
@@ -329,10 +332,10 @@ public class IpadSendServer {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void sendLink(BaseVo vo, QwSopCourseFinishTempSetting.Setting content, Long externalId) {
|
|
|
+ public void sendLink(BaseVo vo, QwSopCourseFinishTempSetting.Setting content,QwSopLogs qwSopLogs, Long externalId) {
|
|
|
if ("18".equals(content.getContentType())){
|
|
|
// 完善content里面的飞书注册链接
|
|
|
- completeFeishuRegisterLink(vo, content, externalId);
|
|
|
+ completeFeishuRegisterLink(vo, content,qwSopLogs, externalId);
|
|
|
}
|
|
|
// 文本
|
|
|
LinkVo linkVo = LinkVo.builder()
|
|
|
@@ -353,11 +356,12 @@ public class IpadSendServer {
|
|
|
/**
|
|
|
* 完善飞书注册链接
|
|
|
* */
|
|
|
- public QwSopCourseFinishTempSetting.Setting completeFeishuRegisterLink(BaseVo vo, QwSopCourseFinishTempSetting.Setting content, Long externalId) {
|
|
|
- try {
|
|
|
+ public QwSopCourseFinishTempSetting.Setting completeFeishuRegisterLink(BaseVo vo, QwSopCourseFinishTempSetting.Setting content,QwSopLogs qwSopLogs,Long externalId) {
|
|
|
+
|
|
|
//初始链接
|
|
|
String initUrl = content.getLinkUrl();
|
|
|
// 1. 从初始链接提取携带的短链
|
|
|
+ try {
|
|
|
String shortLink = extractLastPathSegment(initUrl);
|
|
|
FsCourseLink fsCourseLink = courseLinkMapper.selectFsCourseLinkByLink(shortLink);
|
|
|
Long companyId = fsCourseLink.getCompanyId();
|
|
|
@@ -367,23 +371,26 @@ public class IpadSendServer {
|
|
|
//从缓存取出docId;account
|
|
|
String docIdKey=FEISHU_DOC_ID + externalId+ "_" + videoId;
|
|
|
String feiShuDocId = redisCache.getCacheObject(docIdKey);
|
|
|
+ //根据初始链接组装真实链接
|
|
|
+ String completeFeiShuLinkUrl = replaceShortLinkInUrl(initUrl, feiShuDocId);
|
|
|
if (StringUtils.isBlank(feiShuDocId)) {
|
|
|
- //调用飞书API创建docId
|
|
|
+ //调用飞书API直接获取完整飞书链接
|
|
|
String feishuRegisterLink = feiShuService.getFeishuRegisterLink(videoId, companyId, courseId, companyUserId, shortLink);
|
|
|
content.setLinkUrl(feishuRegisterLink);
|
|
|
- String docId = extractLastPathSegment(initUrl);
|
|
|
- //缓存docId
|
|
|
- redisCache.setCacheObject(docIdKey, docId);
|
|
|
+ //更新qwSopLogs
|
|
|
+ qwSopLogsService.updateLinkUrlInContentJson(qwSopLogs, completeFeiShuLinkUrl);
|
|
|
return content;
|
|
|
}
|
|
|
+
|
|
|
String clientKey = FEISHU_CLIENT+feiShuDocId;
|
|
|
String accountStr = redisCache.getCacheObject(clientKey);
|
|
|
FeishuAccount account = JSONUtil.toBean(accountStr, FeishuAccount.class);
|
|
|
|
|
|
//如果缓存中的docId为空,则从feishu接口创建新的docId
|
|
|
Client client = buildClient(account);
|
|
|
- //根据初始链接组装真实链接
|
|
|
- String completeFeiShuLinkUrl = replaceShortLinkInUrl(initUrl, feiShuDocId);
|
|
|
+
|
|
|
+ //更新qwSopLogs
|
|
|
+ qwSopLogsService.updateLinkUrlInContentJson(qwSopLogs, completeFeiShuLinkUrl);
|
|
|
content.setLinkUrl(completeFeiShuLinkUrl);
|
|
|
String authUrl = buildAuthLink(companyId, companyUserId, courseId, videoId, shortLink);
|
|
|
// ============ 异步调用飞书API完善文档内容与文档权限 ============
|
|
|
@@ -396,9 +403,8 @@ public class IpadSendServer {
|
|
|
return content;
|
|
|
}catch (Exception e){
|
|
|
log.error("ID:{}-完善飞书注册链接异常:{}", vo.getId(), e.getMessage());
|
|
|
- throw new BaseException("完善飞书注册链接异常");
|
|
|
}
|
|
|
-
|
|
|
+ return content;
|
|
|
}
|
|
|
|
|
|
//构造发送的飞书授权链接
|
|
|
@@ -429,11 +435,6 @@ public class IpadSendServer {
|
|
|
return JSONUtil.toBean(json, CourseConfig.class);
|
|
|
}
|
|
|
|
|
|
- private void disablePersonalAccount(FeishuAccount account, String errorMsg) {
|
|
|
- feishuAccountMapper.updateStatusAndErrorMsg(account.getId(), 0, errorMsg);
|
|
|
- clearCompanyUserCache(account.getCompanyId(), account.getCompanyUserId());
|
|
|
- }
|
|
|
-
|
|
|
private void recordLinkError(Long videoId, Long companyId, Long courseId,
|
|
|
Long companyUserId, String link, String errorInfo, Integer type) {
|
|
|
FeishuLinkError error = new FeishuLinkError();
|
|
|
@@ -728,7 +729,7 @@ public class IpadSendServer {
|
|
|
break;
|
|
|
case "3":
|
|
|
// 链接
|
|
|
- sendLink(vo, content, externalUserId);
|
|
|
+ sendLink(vo, content, qwSopLogs,externalUserId);
|
|
|
break;
|
|
|
case "4":
|
|
|
case "10":
|
|
|
@@ -820,7 +821,7 @@ public class IpadSendServer {
|
|
|
break;
|
|
|
case "18":
|
|
|
// 链接
|
|
|
- sendLink(vo, content,externalUserId);
|
|
|
+ sendLink(vo, content,qwSopLogs,externalUserId);
|
|
|
break;
|
|
|
case "21":
|
|
|
content.setSendStatus(0);
|