|
|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.fs.app.taskService.SopLogsTaskService;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
+import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.exception.base.BaseException;
|
|
|
import com.fs.common.utils.PubFun;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
@@ -20,6 +21,7 @@ import com.fs.course.domain.*;
|
|
|
import com.fs.course.mapper.*;
|
|
|
import com.fs.course.param.FsCourseLinkCreateParam;
|
|
|
import com.fs.course.service.IFsCourseLinkService;
|
|
|
+import com.fs.course.service.IFsUserCourseService;
|
|
|
import com.fs.qw.domain.*;
|
|
|
import com.fs.qw.mapper.QwExternalContactMapper;
|
|
|
import com.fs.qw.mapper.QwUserMapper;
|
|
|
@@ -104,6 +106,11 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
@Autowired
|
|
|
private QwSopMapper sopMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FsUserCourseMapper fsUserCourseMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
|
|
|
@Autowired
|
|
|
private QwExternalContactServiceImpl qwExternalContactService;
|
|
|
@@ -177,6 +184,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
private AsyncCourseWatchFinishService asyncCourseWatchFinishService;
|
|
|
|
|
|
|
|
|
+
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
loadCourseConfig();
|
|
|
@@ -615,7 +623,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
|
|
|
insertSopUserLogs(sopUserLogsInfos, logVo, sendTime, ruleTimeVO, content, qwUserId,
|
|
|
companyUserId, companyId, qwUserByRedis.getWelcomeText(),qwUserByRedis.getQwUserName(),
|
|
|
- groupChatMap, miniAppId,config,miniMap, sendMsgType,companies);
|
|
|
+ groupChatMap, miniAppId,config,miniMap, sendMsgType,companies,day);
|
|
|
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -660,7 +668,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
String qwUserId,String companyUserId,String companyId,String welcomeText,String qwUserName,
|
|
|
Map<String, QwGroupChat> groupChatMap,String miniAppId,CourseConfig config,
|
|
|
Map<Long, Map<Integer, List<CompanyMiniapp>>> miniMap, Integer sendMsgType,
|
|
|
- List<Company> companies) {
|
|
|
+ List<Company> companies,Long day) {
|
|
|
String formattedSendTime = sendTime.toInstant()
|
|
|
.atZone(ZoneId.systemDefault())
|
|
|
.format(DATE_TIME_FORMATTER);
|
|
|
@@ -716,7 +724,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
QwSopLogs sopLogs = createBaseLog(formattedSendTime, logVo, ruleTimeVO, groupChat.getChatId(), groupChat.getName(), null, isOfficial, null,null);
|
|
|
handleLogBasedOnType(sopLogs, content, logVo, sendTime, courseId, videoId,
|
|
|
type, qwUserId, companyUserId, companyId, groupChat.getChatId(), welcomeText, qwUserName,
|
|
|
- null, true, miniAppId, groupChat,config, miniMap, null, sendMsgType,companies);
|
|
|
+ null, true, miniAppId, groupChat,config, miniMap, null, sendMsgType,companies,day);
|
|
|
} else {
|
|
|
if(groupChat.getChatUserList() != null && !groupChat.getChatUserList().isEmpty()){
|
|
|
groupChat.getChatUserList().forEach(user -> {
|
|
|
@@ -725,7 +733,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
QwSopLogs sopLogs = createBaseLog(formattedSendTime, logVo, ruleTimeVO, user.getUserId(), user.getName(), null, isOfficial, null,null);
|
|
|
handleLogBasedOnType(sopLogs, content, logVo, sendTime, courseId, videoId,
|
|
|
type, qwUserId, companyUserId, companyId, user.getId().toString(), welcomeText, qwUserName,
|
|
|
- null, false, miniAppId, groupChat,config, miniMap, null, sendMsgType,companies);
|
|
|
+ null, false, miniAppId, groupChat,config, miniMap, null, sendMsgType,companies,day);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
@@ -740,7 +748,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
QwSopLogs sopLogs = createBaseLog(formattedSendTime, logVo, ruleTimeVO, contactId.getExternalContactId(), externalUserName, fsUserId, isOfficial, contactId.getExternalId(),contactId.getIsDaysNotStudy());
|
|
|
handleLogBasedOnType(sopLogs, content, logVo, sendTime, courseId, videoId,
|
|
|
type, qwUserId, companyUserId, companyId, externalId, welcomeText, qwUserName, fsUserId, false, miniAppId,
|
|
|
- null,config, miniMap, grade, sendMsgType,companies);
|
|
|
+ null,config, miniMap, grade, sendMsgType,companies,day);
|
|
|
} catch (Exception e) {
|
|
|
log.error("处理 externalContactId {} 时发生异常: {}", contactId, e.getMessage(), e);
|
|
|
}
|
|
|
@@ -855,7 +863,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
String qwUserName, Long fsUserId, boolean isGroupChat, String miniAppId,
|
|
|
QwGroupChat groupChat,CourseConfig config,
|
|
|
Map<Long, Map<Integer, List<CompanyMiniapp>>> miniMap,
|
|
|
- Integer grade, Integer sendMsgType ,List<Company> companies ) {
|
|
|
+ Integer grade, Integer sendMsgType ,List<Company> companies,Long day ) {
|
|
|
switch (type) {
|
|
|
case 1:
|
|
|
handleNormalMessage(sopLogs, content,companyUserId);
|
|
|
@@ -863,7 +871,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
case 2:
|
|
|
handleCourseMessage(sopLogs, content, logVo, sendTime, courseId, videoId,
|
|
|
qwUserId, companyUserId, companyId, externalId, welcomeText,qwUserName, fsUserId,
|
|
|
- isGroupChat, miniAppId, groupChat,config,miniMap, grade, sendMsgType,companies);
|
|
|
+ isGroupChat, miniAppId, groupChat,config,miniMap, grade, sendMsgType,companies,day);
|
|
|
break;
|
|
|
case 3:
|
|
|
handleOrderMessage(sopLogs, content);
|
|
|
@@ -904,7 +912,7 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
String companyId, String externalId, String welcomeText, String qwUserName,
|
|
|
Long fsUserId, boolean isGroupChat, String miniAppId, QwGroupChat groupChat,CourseConfig config,Map<Long,
|
|
|
Map<Integer, List<CompanyMiniapp>>> miniMap,Integer grade, Integer sendMsgType,
|
|
|
- List<Company> companies) {
|
|
|
+ List<Company> companies,Long day) {
|
|
|
// 深拷贝 Content 对象,避免使用 JSON
|
|
|
QwSopTempSetting.Content clonedContent = deepCopyContent(content);
|
|
|
if (clonedContent == null) {
|
|
|
@@ -1016,6 +1024,13 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ Long courseProjectType = getCourseProjectType(courseId);
|
|
|
+
|
|
|
+ // 医言九鼎 天数小于 7 发 广珍堂大药房
|
|
|
+ if (!Objects.isNull(courseProjectType) && day <=7 && (courseProjectType== 17 || courseProjectType== 22 )){
|
|
|
+ setting.setMiniprogramAppid("wx0d1a3dd485268521");
|
|
|
+ }
|
|
|
+
|
|
|
setting.setMiniprogramPage(sortLink.replaceAll("^[\\s\\u2005]+", ""));
|
|
|
|
|
|
try {
|
|
|
@@ -1067,6 +1082,25 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
|
|
|
enqueueQwSopLogs(sopLogs);
|
|
|
}
|
|
|
|
|
|
+ private Long getCourseProjectType(Long courseId){
|
|
|
+
|
|
|
+ String courseKey="h5user:course:project:" + courseId;
|
|
|
+
|
|
|
+ Long courseProject=null;
|
|
|
+ try {
|
|
|
+ courseProject = redisCache.getCacheObject(courseKey);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("获取课程-项目有误:{}{}", courseId,e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (courseProject==null){
|
|
|
+ FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(courseId);
|
|
|
+ courseProject=fsUserCourse.getProject();
|
|
|
+ redisCache.setCacheObject(courseKey,fsUserCourse.getProject());
|
|
|
+ }
|
|
|
+ return courseProject;
|
|
|
+ }
|
|
|
+
|
|
|
private String getAppIdFromMiniMap(Map<Long, Map<Integer, List<CompanyMiniapp>>> miniMap,
|
|
|
String companyId,
|
|
|
int sendMsgType,
|