|
|
@@ -772,7 +772,14 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
QwGroupChat groupChat = groupChatMap.get(logVo.getChatId());
|
|
|
if (groupChat.getChatUserList() != null && !groupChat.getChatUserList().isEmpty()) {
|
|
|
QwSopLogs sopLogs = createBaseLog(formattedSendTime, logVo, ruleTimeVO, groupChat.getChatId(), groupChat.getName(), null, isOfficial, null, null);
|
|
|
- ruleTimeVO.setSendType(6);
|
|
|
+ boolean hasGroupNotice = content.getSetting() != null && content.getSetting().stream()
|
|
|
+ .anyMatch(st -> "11".equals(st.getContentType()));
|
|
|
+ if(hasGroupNotice){
|
|
|
+ ruleTimeVO.setSendType(21);
|
|
|
+ log.info("检测到群公告类型,设置sendType=21, sopId:{}, chatId:{}", logVo.getSopId(), groupChat.getChatId());
|
|
|
+ } else {
|
|
|
+ ruleTimeVO.setSendType(6);
|
|
|
+ }
|
|
|
ruleTimeVO.setType(2);
|
|
|
handleLogBasedOnType(sopLogs, content, logVo, sendTime, courseId, videoId,
|
|
|
type, qwUserId, companyUserId, companyId, groupChat.getChatId(), welcomeText, qwUserName,
|
|
|
@@ -945,12 +952,35 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
//直播间发送类型
|
|
|
case 20:
|
|
|
handleLiveMessage(sopLogs, content, companyUserId, companyId, isGroupChat, qwUserId, groupChat, externalId, logVo, liveId);
|
|
|
+ break;
|
|
|
+ case 21:
|
|
|
+ handleGroupNoticeMessage(sopLogs, content, isGroupChat);
|
|
|
+ break;
|
|
|
default:
|
|
|
log.error("未知的消息类型 {},跳过处理。", type);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 处理群公告消息
|
|
|
+ * @param sopLogs 日志对象
|
|
|
+ * @param content 内容对象
|
|
|
+ * @param isGroupChat 是否为群聊
|
|
|
+ */
|
|
|
+ private void handleGroupNoticeMessage(QwSopLogs sopLogs, QwSopTempSetting.Content content, boolean isGroupChat) {
|
|
|
+ // 群公告只能发给群聊
|
|
|
+ if (!isGroupChat) {
|
|
|
+ log.warn("群公告只能发给群聊,跳过处理");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置发送类型为21(群公告)
|
|
|
+ sopLogs.setSendType(21);
|
|
|
+ sopLogs.setContentJson(JSON.toJSONString(content));
|
|
|
+ enqueueQwSopLogs(sopLogs);
|
|
|
+ }
|
|
|
+
|
|
|
private void handleVoiceMessage(QwSopLogs sopLogs, QwSopTempSetting.Content content, String companyUserId) {
|
|
|
sopLogs.setContentJson(JSON.toJSONString(content));
|
|
|
enqueueQwSopLogs(sopLogs);
|
|
|
@@ -962,14 +992,14 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
// 深拷贝 Content 对象,避免使用 JSON
|
|
|
QwSopTempSetting.Content clonedContent = deepCopyContent(content);
|
|
|
if (clonedContent == null) {
|
|
|
- log.error("Failed to clone content, skipping handleCourseMessage.");
|
|
|
+// log.error("Failed to clone content, skipping handleCourseMessage.");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
List<QwSopTempSetting.Content.Setting> settings = clonedContent.getSetting();
|
|
|
List<QwSopTempSetting.Content.Setting> settingAll = new ArrayList<>();
|
|
|
if (settings == null || settings.isEmpty()) {
|
|
|
- log.error("Cloned content settings are empty, skipping.");
|
|
|
+// log.error("Cloned content settings are empty, skipping.");
|
|
|
return;
|
|
|
}
|
|
|
// 顺序处理每个 Setting,避免过多的并行导致线程开销
|
|
|
@@ -1088,7 +1118,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
// 2. 获取系统配置
|
|
|
SysConfig luckyBagConfig = sysConfigMapper.selectConfigByConfigKey("luckyBag.config");
|
|
|
if (ObjectUtil.isEmpty(luckyBagConfig) || StringUtil.strIsNullOrEmpty(luckyBagConfig.getConfigValue())) {
|
|
|
- log.warn("福袋配置为空,设置发送状态为失败");
|
|
|
+// log.warn("福袋配置为空,设置发送状态为失败");
|
|
|
setSopLogsStatus(sopLogs, 5L, 0L, "福袋配置不存在");
|
|
|
}
|
|
|
|
|
|
@@ -1097,7 +1127,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
try {
|
|
|
jsonObject = JSON.parseObject(luckyBagConfig.getConfigValue());
|
|
|
} catch (Exception e) {
|
|
|
- log.error("解析福袋配置JSON失败: {}", luckyBagConfig.getConfigValue(), e);
|
|
|
+// log.error("解析福袋配置JSON失败: {}", luckyBagConfig.getConfigValue(), e);
|
|
|
setSopLogsStatus(sopLogs, 5L, 0L, "福袋配置格式错误");
|
|
|
}
|
|
|
|
|
|
@@ -1113,7 +1143,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
}
|
|
|
|
|
|
if (count == null) {
|
|
|
- log.warn("周限制次数配置为空");
|
|
|
+// log.warn("周限制次数配置为空");
|
|
|
setSopLogsStatus(sopLogs, 5L, 0L, "周限制次数配置错误");
|
|
|
}
|
|
|
|
|
|
@@ -1143,12 +1173,12 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
Object cachedCount = redisCache.getCacheObject(countCacheKey);
|
|
|
if (cachedCount != null && cachedCount instanceof Integer) {
|
|
|
recordCount = (Integer) cachedCount;
|
|
|
- log.debug("福袋计数缓存命中,userId: {},次数: {}", fsUserId, recordCount);
|
|
|
+// log.debug("福袋计数缓存命中,userId: {},次数: {}", fsUserId, recordCount);
|
|
|
|
|
|
// 如果只需要判断是否超限,且已超限,直接返回
|
|
|
if (recordCount >= count) {
|
|
|
- log.info("用户福袋次数已达上限(计数缓存), userId: {}, 当前次数: {}, 限制次数: {}",
|
|
|
- fsUserId, recordCount, count);
|
|
|
+// log.info("用户福袋次数已达上限(计数缓存), userId: {}, 当前次数: {}, 限制次数: {}",
|
|
|
+// fsUserId, recordCount, count);
|
|
|
setSopLogsStatus(sopLogs, 5L, 0L, "超过福袋发放次数");
|
|
|
luckyBagCollectRecords = Collections.emptyList();
|
|
|
// 可以直接返回,不需要查询完整记录
|
|
|
@@ -1196,7 +1226,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
|
|
|
// 6. 检查次数限制
|
|
|
if (recordCount >= count) {
|
|
|
- log.info("用户福袋次数已达上限, userId: {}, 当前次数: {}, 限制次数: {}", fsUserId, recordCount, count);
|
|
|
+// log.info("用户福袋次数已达上限, userId: {}, 当前次数: {}, 限制次数: {}", fsUserId, recordCount, count);
|
|
|
setSopLogsStatus(sopLogs, 5L, 0L, "超过福袋发放次数");
|
|
|
}
|
|
|
}
|
|
|
@@ -1212,7 +1242,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
0L, 0L, qwUserId, companyUserId, companyId, cachedCourseConfig, null);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.error("生成活动链接失败", e);
|
|
|
+// log.error("生成活动链接失败", e);
|
|
|
setSopLogsStatus(sopLogs, 5L, 0L, "生成活动链接失败");
|
|
|
return;
|
|
|
}
|
|
|
@@ -1241,7 +1271,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
setting.setMiniprogramTitle("福袋发放");
|
|
|
setting.setMiniprogramPage(link);
|
|
|
|
|
|
- log.info("福袋配置成功,userId: {}, appId: {}", fsUserId, finalAppId);
|
|
|
+// log.info("福袋配置成功,userId: {}, appId: {}", fsUserId, finalAppId);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
log.error("任务模板福袋发放失败", e);
|
|
|
@@ -1332,7 +1362,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
}
|
|
|
|
|
|
if (config == null) {
|
|
|
- log.error("CourseConfig is not loaded.");
|
|
|
+// log.error("CourseConfig is not loaded.");
|
|
|
return "";
|
|
|
}
|
|
|
FsCourseLink link = new FsCourseLink();
|
|
|
@@ -1388,13 +1418,13 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
// 深拷贝 Content 对象,避免使用 JSON
|
|
|
QwSopTempSetting.Content clonedContent = deepCopyContent(content);
|
|
|
if (clonedContent == null) {
|
|
|
- log.error("Failed to clone content, skipping handleCourseMessage.");
|
|
|
+// log.error("Failed to clone content, skipping handleCourseMessage.");
|
|
|
return;
|
|
|
}
|
|
|
clonedContent.setLiveId(liveId);
|
|
|
List<QwSopTempSetting.Content.Setting> settings = clonedContent.getSetting();
|
|
|
if (settings == null || settings.isEmpty()) {
|
|
|
- log.error("Cloned content settings are empty, skipping.");
|
|
|
+// log.error("Cloned content settings are empty, skipping.");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -1476,7 +1506,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
// 深拷贝 Content 对象,避免使用 JSON
|
|
|
QwSopTempSetting.Content clonedContent = deepCopyContent(content);
|
|
|
if (clonedContent == null) {
|
|
|
- log.error("Failed to clone content, skipping handleCourseMessage.");
|
|
|
+// log.error("Failed to clone content, skipping handleCourseMessage.");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -1487,7 +1517,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
|
|
|
List<QwSopTempSetting.Content.Setting> settings = clonedContent.getSetting();
|
|
|
if (settings == null || settings.isEmpty()) {
|
|
|
- log.error("Cloned content settings are empty, skipping.");
|
|
|
+// log.error("Cloned content settings are empty, skipping.");
|
|
|
return;
|
|
|
}
|
|
|
//如果是@所有人,就添加
|
|
|
@@ -1603,9 +1633,10 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
setting.setMiniType(miniType);
|
|
|
if (!StringUtil.strIsNullOrEmpty(finalAppId)) {
|
|
|
setting.setMiniprogramAppid(finalAppId);
|
|
|
- } else {
|
|
|
- log.error("公司的小程序id为空:采用了前端传的固定值" + sopLogs.getSopId());
|
|
|
}
|
|
|
+// else {
|
|
|
+// log.error("公司的小程序id为空:采用了前端传的固定值" + sopLogs.getSopId());
|
|
|
+// }
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -1755,8 +1786,8 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
st.setBusinessId(String.valueOf(businessId));
|
|
|
String realLinkFull = appActivitlLink + JSON.toJSONString(courseMap);
|
|
|
link.setRealLink(realLinkFull);
|
|
|
- log.error("存入fs_course_link:" + registeredRealLink);
|
|
|
- log.error("QwSopCourseFinishTempSetting.Setting:{}", st);
|
|
|
+// log.error("存入fs_course_link:" + registeredRealLink);
|
|
|
+// log.error("QwSopCourseFinishTempSetting.Setting:{}", st);
|
|
|
//存短链-
|
|
|
fsCourseLinkMapper.insertFsCourseLink(link);
|
|
|
return link.getRealLink();
|
|
|
@@ -1835,7 +1866,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- log.info("福袋记录添加成功 [recordId:{}, luckyBagId:{}]", recordId, content.getLuckyBagId());
|
|
|
+// log.info("福袋记录添加成功 [recordId:{}, luckyBagId:{}]", recordId, content.getLuckyBagId());
|
|
|
return recordId;
|
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
@@ -1948,7 +1979,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
}
|
|
|
|
|
|
if (config == null) {
|
|
|
- log.error("CourseConfig is not loaded.");
|
|
|
+// log.error("CourseConfig is not loaded.");
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
@@ -2045,7 +2076,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
}
|
|
|
|
|
|
if (config == null) {
|
|
|
- log.error("CourseConfig is not loaded.");
|
|
|
+// log.error("CourseConfig is not loaded.");
|
|
|
return null;
|
|
|
}
|
|
|
FsCourseLink link = createFsCourseLink(corpId, sendTime, courseId, videoId, qwUserId,
|
|
|
@@ -2162,7 +2193,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
}
|
|
|
|
|
|
if (config == null) {
|
|
|
- log.error("CourseConfig is not loaded.");
|
|
|
+// log.error("CourseConfig is not loaded.");
|
|
|
return "";
|
|
|
}
|
|
|
|