|
@@ -208,6 +208,56 @@ public class FeiShuService {
|
|
|
throw new CustomException("当前销售没有可用的飞书账号,请先配置或更换账号");
|
|
throw new CustomException("当前销售没有可用的飞书账号,请先配置或更换账号");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 手动飞书发课:每次新建飞书文档(风控后直接重新生成即可)。
|
|
|
|
|
+ */
|
|
|
|
|
+ public String createManualFeishuDirectCourseLink(Long videoId, Long companyId, Long courseId,
|
|
|
|
|
+ Long companyUserId, String shortLink) {
|
|
|
|
|
+ CourseConfig config = getCourseConfig();
|
|
|
|
|
+ if (!Boolean.TRUE.equals(config.getEnableFeishuNewLink())) {
|
|
|
|
|
+ throw new CustomException("未开启飞书看课");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (companyUserId == null) {
|
|
|
|
|
+ throw new CustomException("销售ID不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ Long feishuAccountId = feishuAccountService.resolveSendAccountId(companyUserId, null);
|
|
|
|
|
+
|
|
|
|
|
+ FsUserCourseVideo userCourseVideo = videoMapper.selectFsUserCourseVideoByVideoId(videoId);
|
|
|
|
|
+ if (userCourseVideo == null) {
|
|
|
|
|
+ throw new CustomException("视频不存在: " + videoId);
|
|
|
|
|
+ }
|
|
|
|
|
+ int questionFlag = resolveQuestionFlag(userCourseVideo);
|
|
|
|
|
+
|
|
|
|
|
+ List<FeishuAccount> accounts = clientPool.listEnabledAccounts(companyUserId, feishuAccountId);
|
|
|
|
|
+ CustomException lastError = null;
|
|
|
|
|
+ for (FeishuAccount account : accounts) {
|
|
|
|
|
+ FeishuClientHolder holder = clientPool.getClient(companyUserId, account.getId());
|
|
|
|
|
+ try {
|
|
|
|
|
+ String iframeUrl = buildCoursePageLink(companyId, companyUserId, courseId, videoId, 0L, shortLink, questionFlag);
|
|
|
|
|
+ String documentId = createDirectCourseDocumentWithRetry(holder, userCourseVideo.getTitle(), iframeUrl);
|
|
|
|
|
+ feishuAccountMapper.incrementNumberUse(account.getId());
|
|
|
|
|
+ updateCourseLinkFeishuAccount(shortLink, account.getId());
|
|
|
|
|
+ String resultUrl = FEISHU_DOC_URL_PREFIX + documentId;
|
|
|
|
|
+ log.info("手动飞书发课新建文档: companyUserId={}, videoId={}, docUrl={}",
|
|
|
|
|
+ companyUserId, videoId, resultUrl);
|
|
|
|
|
+ return resultUrl;
|
|
|
|
|
+ } catch (CustomException e) {
|
|
|
|
|
+ lastError = e;
|
|
|
|
|
+ if (isAccountUnavailable(e)) {
|
|
|
|
|
+ log.warn("销售[{}]飞书账号[{}]不可用,尝试下一个", companyUserId, account.getId());
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ throw e;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new CustomException("创建飞书免授权看课链接失败: " + e.getMessage(), e);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (lastError != null) {
|
|
|
|
|
+ throw lastError;
|
|
|
|
|
+ }
|
|
|
|
|
+ throw new CustomException("当前销售没有可用的飞书账号,请先配置或更换账号");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 生成飞书初始链接(注册授权链接)。
|
|
* 生成飞书初始链接(注册授权链接)。
|
|
|
*/
|
|
*/
|