|
|
@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.fs.common.config.FSSysConfig;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
@@ -18,10 +19,7 @@ import com.fs.company.mapper.CompanyUserMapper;
|
|
|
import com.fs.company.service.ICompanyMiniappService;
|
|
|
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.FsCourseWatchLog;
|
|
|
+import com.fs.course.domain.*;
|
|
|
import com.fs.course.mapper.FsCourseDomainNameMapper;
|
|
|
import com.fs.course.mapper.FsCourseLinkMapper;
|
|
|
import com.fs.course.mapper.FsCourseWatchLogMapper;
|
|
|
@@ -30,6 +28,10 @@ import com.fs.course.service.IFsCourseLinkService;
|
|
|
import com.fs.course.service.IFsUserCourseVideoService;
|
|
|
import com.fs.fastGpt.domain.FastGptChatReplaceWords;
|
|
|
import com.fs.fastGpt.mapper.FastGptChatReplaceWordsMapper;
|
|
|
+import com.fs.his.domain.FsUser;
|
|
|
+import com.fs.his.mapper.FsUserMapper;
|
|
|
+import com.fs.live.domain.LiveWatchLog;
|
|
|
+import com.fs.live.mapper.LiveWatchLogMapper;
|
|
|
import com.fs.qw.domain.*;
|
|
|
import com.fs.qw.mapper.*;
|
|
|
import com.fs.qw.param.QwExtCourseSopWatchLog;
|
|
|
@@ -59,6 +61,8 @@ import com.fs.sop.vo.ExtCourseSopWatchLogVO;
|
|
|
import com.fs.sop.vo.QwCreateLinkByAppVO;
|
|
|
import com.fs.sop.vo.SopUserLogsInfoVOE;
|
|
|
import com.fs.sop.vo.SopUserLogsVo;
|
|
|
+import com.fs.system.domain.SysConfig;
|
|
|
+import com.fs.system.mapper.SysConfigMapper;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.voice.utils.StringUtil;
|
|
|
import org.slf4j.Logger;
|
|
|
@@ -89,7 +93,9 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
private static final String SHORT_LINK_PREFIX = "/courseH5/pages/course/learning?s=";
|
|
|
private static final String miniappRealLink = "/pages_course/video.html?course=";
|
|
|
private static final String appRealLink = "/pages/courseAnswer/index?link=";
|
|
|
+ private static final String appActivitlLink = "/pages_course/activity.html?link=";
|
|
|
private static final String appLink = "https://jump.ylrztop.com/jumpapp/pages/index/index?link=";
|
|
|
+ private static final String registeredRealLink = "/pages_course/register.html?link=";
|
|
|
// private static final String miniappRealLink = "/pages/index/index?course=";
|
|
|
|
|
|
@Autowired
|
|
|
@@ -170,6 +176,18 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
@Autowired
|
|
|
private IQwSopTempVoiceService sopTempVoiceService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ LiveWatchLogMapper liveWatchLogMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LuckyBagMapper luckyBagMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LuckyBagCollectRecordMapper luckyBagCollectRecordMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsUserMapper fsUserMapper;
|
|
|
+
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@@ -511,20 +529,25 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
e.setUserList(userMap.getOrDefault(e.getUserId(), Collections.emptyList()));
|
|
|
});
|
|
|
}
|
|
|
- try {
|
|
|
- groupList.forEach(groupChat -> {
|
|
|
- QwUser qwUser = qwUserMapper.selectQwUserByIdByWeComeText2(groupChat.getOwner(), groupChat.getCorpId());
|
|
|
- groupChat.getChatUserList().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.getSopId(), param.getVideoId(), param.getCourseId(), vo.getFsUserId(), qwUser.getId().toString(), qwUser.getCompanyUserId().toString(), qwUser.getCompanyId().toString(), vo.getId(), param.getStartTime(), createTime,2);
|
|
|
- }
|
|
|
+
|
|
|
+ //没有传值课程和课节 是直播的数据
|
|
|
+ if(null != param.getCourseId() && null !=param.getVideoId()){
|
|
|
+ try {
|
|
|
+ groupList.forEach(groupChat -> {
|
|
|
+ QwUser qwUser = qwUserMapper.selectQwUserByIdByWeComeText2(groupChat.getOwner(), groupChat.getCorpId());
|
|
|
+ groupChat.getChatUserList().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.getSopId(), param.getVideoId(), param.getCourseId(), vo.getFsUserId(), qwUser.getId().toString(), qwUser.getCompanyUserId().toString(), qwUser.getCompanyId().toString(), vo.getId(), param.getStartTime(), createTime,2);
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("群聊创建看课记录失败!", e);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("群聊创建看课记录失败!", e);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
if (param.getSendType() != null && param.getSendType() == 2) {
|
|
|
sopLogsList = groupUserList.stream().map(groupUser -> {
|
|
|
QwGroupChat qwGroupChat = groupMap.get(groupUser.getChatId());
|
|
|
@@ -666,10 +689,19 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
break;
|
|
|
//直播小程序单独
|
|
|
case "12":
|
|
|
- String sortLiveLink = "/pages_course/living?companyId=" + qwUser.getCompanyUserId() + "&companyUserId=" + companyUserId + "&liveId=" + st.getLiveId();
|
|
|
+ String sortLiveLink = "/pages_course/living.html?companyId=" + qwUser.getCompanyUserId() + "&companyUserId=" + companyUserId + "&liveId=" + st.getLiveId() + "&corpId=" + param.getCorpId()+"&qwUserId=" + qwUser.getId() +"&externalId=" + vo.getId().toString();
|
|
|
st.setContentType("4");
|
|
|
String js = configService.selectConfigByKey("his.config");
|
|
|
FSSysConfig sysConfig= JSON.parseObject(js,FSSysConfig.class);
|
|
|
+ //todo 发个人看课记录处理
|
|
|
+ try {
|
|
|
+ if (vo != null && vo.getId() != null) {
|
|
|
+ createLiveWatchLogAndInsert(qwUser.getCompanyId().toString(), qwUser.getCompanyUserId().toString(),vo.getId().toString(),Long.valueOf(st.getLiveId()),sysConfig.getAppId(),2, qwUser.getId().toString(),param.getCorpId());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("群聊创建直播看课记录失败!", e);
|
|
|
+ }
|
|
|
+// createLiveWatchLogAndInsert();
|
|
|
st.setMiniprogramAppid(sysConfig.getAppId());
|
|
|
st.setMiniprogramPage(sortLiveLink);
|
|
|
break;
|
|
|
@@ -809,10 +841,25 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
break;
|
|
|
//直播小程序单独
|
|
|
case "12":
|
|
|
- String sortLiveLink = "/pages_course/living?companyId=" + qwUser.getCompanyUserId() + "&companyUserId=" + qwUser.getCompanyUserId() + "&liveId=" + st.getLiveId();
|
|
|
+ String sortLiveLink = "/pages_course/living.html?companyId=" + qwUser.getCompanyUserId() + "&companyUserId=" + qwUser.getCompanyUserId() + "&liveId=" + st.getLiveId() + "&corpId=" +param.getCorpId()+"&qwUserId=" + qwUser.getId() + "&chatId=" + groupChat.getChatId();
|
|
|
st.setContentType("4");
|
|
|
String js = configService.selectConfigByKey("his.config");
|
|
|
FSSysConfig sysConfig= JSON.parseObject(js,FSSysConfig.class);
|
|
|
+ //发群处理看课记录
|
|
|
+// createLiveWatchLogAndInsert();
|
|
|
+ try {
|
|
|
+ groupList.forEach(gc -> {
|
|
|
+ gc.getChatUserList().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) {
|
|
|
+ createLiveWatchLogAndInsert(qwUser.getCompanyId().toString(), qwUser.getCompanyUserId().toString(),vo.getId().toString(),Long.valueOf(st.getLiveId()),sysConfig.getAppId(),2, qwUser.getId().toString(),param.getCorpId());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("群聊创建直播看课记录失败!", e);
|
|
|
+ }
|
|
|
st.setMiniprogramAppid(sysConfig.getAppId());
|
|
|
st.setMiniprogramPage(sortLiveLink);
|
|
|
break;
|
|
|
@@ -1013,10 +1060,17 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
break;
|
|
|
//直播小程序单独
|
|
|
case "12":
|
|
|
- String sortLiveLink = "/pages_course/living?companyId=" + qwUser.getCompanyUserId() + "&companyUserId=" + qwUser.getCompanyUserId() + "&liveId=" + st.getLiveId();
|
|
|
+ String sortLiveLink = "/pages_course/living.html?companyId=" + qwUser.getCompanyUserId() + "&companyUserId=" + qwUser.getCompanyUserId() + "&liveId=" + st.getLiveId() + "&corpId=" + param.getCorpId()+"&qwUserId=" + qwUserId +"&externalId=" + item.getExternalId().toString();
|
|
|
st.setContentType("4");
|
|
|
String js = configService.selectConfigByKey("his.config");
|
|
|
FSSysConfig sysConfig= JSON.parseObject(js,FSSysConfig.class);
|
|
|
+ //todo 发个人看课记录处理
|
|
|
+ try {
|
|
|
+ createLiveWatchLogAndInsert(qwUser.getCompanyId().toString(), qwUser.getCompanyUserId().toString(),item.getExternalId().toString(),Long.valueOf(st.getLiveId()),sysConfig.getAppId(),2, qwUserId,param.getCorpId());
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("群聊创建直播看课记录失败!", e);
|
|
|
+ }
|
|
|
st.setMiniprogramAppid(sysConfig.getAppId());
|
|
|
st.setMiniprogramPage(sortLiveLink);
|
|
|
break;
|
|
|
@@ -1280,7 +1334,7 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
switch (finalSendType){
|
|
|
case 5:
|
|
|
List<QwSopCourseFinishTempSetting.Setting> list = processSetting(item,qwUser, param, words, config, qwCompany,companyUserId,companyId,
|
|
|
- contact,dataTime, finalDomainName,miniMap,companies);
|
|
|
+ contact,dataTime, finalDomainName,miniMap,companies,sopLogs);
|
|
|
setting.setSetting(list);
|
|
|
break;
|
|
|
case 9:
|
|
|
@@ -1344,7 +1398,7 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
CourseConfig config,QwCompany qwCompany,String companyUserId, String companyId,
|
|
|
QwExternalContact contact,Date dataTime,String domainName,
|
|
|
Map<Long, Map<Integer, List<CompanyMiniapp>>> miniMap,
|
|
|
- List<Company> companies ){
|
|
|
+ List<Company> companies,QwSopLogs sopLogs ){
|
|
|
List<QwSopCourseFinishTempSetting.Setting> list = JSONArray.parseArray(param.getSetting(),QwSopCourseFinishTempSetting.Setting.class);
|
|
|
|
|
|
for (QwSopCourseFinishTempSetting.Setting st : list) {
|
|
|
@@ -1471,17 +1525,25 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
+
|
|
|
//直播小程序单独
|
|
|
case "12":
|
|
|
String sortLiveLink;
|
|
|
- sortLiveLink = "/pages_course/living?companyId=" + companyId + "&companyUserId=" + companyUserId + "&liveId=" + st.getLiveId();
|
|
|
+ sortLiveLink = "/pages_course/living.html?companyId=" + companyId + "&companyUserId=" + companyUserId + "&liveId=" + st.getLiveId() + "&corpId=" + param.getCorpId()+"&qwUserId=" + qwUser.getId() +"&externalId=" + item.getExternalId().toString();
|
|
|
|
|
|
|
|
|
String miniprogramLiveTitle = st.getMiniprogramTitle();
|
|
|
int maxLiveLength = 17;
|
|
|
st.setMiniprogramTitle(miniprogramLiveTitle.length() > maxLiveLength ? miniprogramLiveTitle.substring(0, maxLiveLength) + "..." : miniprogramLiveTitle);
|
|
|
+
|
|
|
String json = configService.selectConfigByKey("his.config");
|
|
|
FSSysConfig sysConfig= JSON.parseObject(json,FSSysConfig.class);
|
|
|
+ //todo 发个人看课记录处理
|
|
|
+ try {
|
|
|
+ createLiveWatchLogAndInsert(qwUser.getCompanyId().toString(), qwUser.getCompanyUserId().toString(),item.getExternalId().toString(),Long.valueOf(st.getLiveId()),sysConfig.getAppId(),2, String.valueOf(qwUser.getId()),param.getCorpId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("群聊创建直播看课记录失败!", e);
|
|
|
+ }
|
|
|
st.setMiniprogramAppid(sysConfig.getAppId());
|
|
|
st.setMiniprogramPage(sortLiveLink);
|
|
|
st.setContentType("4");
|
|
|
@@ -1492,7 +1554,7 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
- case "14":
|
|
|
+ case "15":
|
|
|
//app语音
|
|
|
try {
|
|
|
qwSop = qwSopMapper.selectQwSopById(param.getSopId());
|
|
|
@@ -1504,7 +1566,7 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
break;
|
|
|
- case "15":
|
|
|
+ case "16":
|
|
|
//app文本
|
|
|
String txt = StringUtil.strIsNullOrEmpty(qwUser.getWelcomeText()) ? "" : qwUser.getWelcomeText();
|
|
|
st.setValue(st.getValue()
|
|
|
@@ -1517,6 +1579,99 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
break;
|
|
|
+ case "14":
|
|
|
+ LuckyBag luckyBag = luckyBagMapper.selectLuckyBagById(st.getLuckyBagId());
|
|
|
+ if(ObjectUtil.isNotEmpty(luckyBag)&&luckyBag.getDataStatus().equals("0")){
|
|
|
+ sopLogs.setSendStatus(5L);
|
|
|
+ sopLogs.setReceivingStatus(0L);
|
|
|
+ sopLogs.setRemark("福袋配置被禁用");
|
|
|
+ }else
|
|
|
+ if (ObjectUtil.isNotEmpty(sopLogs.getFsUserId())){
|
|
|
+ //获取配置并校验
|
|
|
+ SysConfig luckBagConfig = configService.selectConfigByConfigKey("luckyBag.config");
|
|
|
+ if (ObjectUtil.isEmpty(luckBagConfig)) {
|
|
|
+ sopLogs.setSendStatus(5L);
|
|
|
+ sopLogs.setReceivingStatus(0L);
|
|
|
+ sopLogs.setRemark("福袋配置不存在");
|
|
|
+ }
|
|
|
+ // 2. 解析配置值
|
|
|
+ JSONObject jsonObject;
|
|
|
+ try {
|
|
|
+ jsonObject = JSON.parseObject(luckBagConfig.getConfigValue());
|
|
|
+ Integer count = jsonObject.getInteger("weekLimit");
|
|
|
+
|
|
|
+ // 查询用户记录并校验次数
|
|
|
+ LuckyBagCollectRecord queryRecord = new LuckyBagCollectRecord();
|
|
|
+ queryRecord.setUserId(sopLogs.getFsUserId());
|
|
|
+ queryRecord.setCollectType("1");
|
|
|
+ // 动态计算时间范围
|
|
|
+ LocalDate endDate = LocalDate.now();
|
|
|
+ LocalDate startDate = endDate.minusDays(6); // 包含今天
|
|
|
+
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("beginSendTime", startDate.toString());
|
|
|
+ params.put("endSendTime", endDate.toString());
|
|
|
+ queryRecord.setParams(params);
|
|
|
+ List<LuckyBagCollectRecord> luckyBagCollectRecords =
|
|
|
+ luckyBagCollectRecordMapper.selectLuckyBagCollectRecordList(queryRecord);
|
|
|
+
|
|
|
+ // 判断是否超过限制
|
|
|
+ if (luckyBagCollectRecords.size() >= count) {
|
|
|
+ sopLogs.setSendStatus(5L);
|
|
|
+ sopLogs.setReceivingStatus(0L);
|
|
|
+ sopLogs.setRemark("超过福袋发放次数");
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 处理配置解析异常
|
|
|
+ sopLogs.setSendStatus(5L);
|
|
|
+ sopLogs.setReceivingStatus(0L);
|
|
|
+ sopLogs.setRemark("福袋配置解析失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ linkByMiniApp = createActivityLinkByMiniApp(st,sopLogs, param.getCorpId(), dataTime, param.getCourseId(), param.getVideoId(),
|
|
|
+ String.valueOf(qwUser.getId()), companyUserId, companyId, item.getExternalId(), config,null);
|
|
|
+
|
|
|
+ miniAppId = null;
|
|
|
+
|
|
|
+ if (!miniMap.isEmpty() && qwUser.getSendMsgType() == 1) {
|
|
|
+ Map<Integer, List<CompanyMiniapp>> integerListMap = miniMap.get(Long.valueOf(companyId));
|
|
|
+ if (integerListMap != null) {
|
|
|
+ effectiveGrade = (item.getGrade() == null) ? 5 : item.getGrade();
|
|
|
+ listIndex = (effectiveGrade == 1 || effectiveGrade == 2) ? 0 : 1;
|
|
|
+
|
|
|
+ //评级是6 S级,则走A类小程序
|
|
|
+ if (effectiveGrade==6){
|
|
|
+ listIndex=2;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CompanyMiniapp> miniapps = integerListMap.get(listIndex);
|
|
|
+
|
|
|
+ if (miniapps != null && !miniapps.isEmpty()) {
|
|
|
+ CompanyMiniapp companyMiniapp = miniapps.get(0);
|
|
|
+ if (companyMiniapp != null && !StringUtil.strIsNullOrEmpty(companyMiniapp.getAppId())) {
|
|
|
+ miniAppId = companyMiniapp.getAppId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.strIsNullOrEmpty(miniAppId) && !StringUtil.strIsNullOrEmpty(qwCompany.getMiniAppId())) {
|
|
|
+ miniAppId = qwCompany.getMiniAppId();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!StringUtil.strIsNullOrEmpty(miniAppId)) {
|
|
|
+ st.setMiniprogramAppid(miniAppId);
|
|
|
+ } else {
|
|
|
+ log.error("公司的小程序id为空:采用了前端传的固定值" + sopLogs.getSopId());
|
|
|
+ }
|
|
|
+
|
|
|
+ st.setMiniprogramTitle("福袋发放");
|
|
|
+
|
|
|
+ st.setMiniprogramPage(linkByMiniApp);
|
|
|
+ break;
|
|
|
+
|
|
|
default:
|
|
|
break;
|
|
|
|
|
|
@@ -1526,6 +1681,134 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ public String createActivityLinkByMiniApp(QwSopCourseFinishTempSetting.Setting st, QwSopLogs sopLogs, String corpId, Date sendTime, Integer courseId, Integer videoId, String qwUserId, String companyUserId, String companyId, Long externalId, CourseConfig config, String chatId) {
|
|
|
+ FsCourseLink link = createFsCourseLink(corpId, sendTime, courseId, videoId, Long.valueOf(qwUserId),
|
|
|
+ companyUserId, companyId, null, 3, chatId);
|
|
|
+ Date updateTime = createUpdateTime(st, sendTime, config);
|
|
|
+ link.setUpdateTime(updateTime);
|
|
|
+ FsCourseRealLink courseMap = new FsCourseRealLink();
|
|
|
+ BeanUtils.copyProperties(link, courseMap);
|
|
|
+ Long businessId = addLuckyBagCollectRecord(st,sopLogs,updateTime,companyUserId,companyId,chatId);
|
|
|
+ courseMap.setBusinessId(String.valueOf(businessId));
|
|
|
+ st.setBusinessId(String.valueOf(businessId));
|
|
|
+ st.setExternalUserId(sopLogs.getExternalUserId());
|
|
|
+ String json = configService.selectConfigByKey("luckyBag.config");
|
|
|
+ Map<String, Object> luckyBagConfig = JSON.parseObject(json, Map.class);
|
|
|
+ Object miniprogramPicUrl = luckyBagConfig.get("miniprogramPicUrl");
|
|
|
+ if(miniprogramPicUrl != null){
|
|
|
+ st.setMiniprogramPicUrl(miniprogramPicUrl.toString());
|
|
|
+ }
|
|
|
+ courseMap.setQwExternalId(sopLogs.getExternalId());
|
|
|
+ String realLinkFull = appActivitlLink + JSON.toJSONString(courseMap);
|
|
|
+ link.setRealLink(realLinkFull);
|
|
|
+ log.error("存入fs_course_link:" + registeredRealLink );
|
|
|
+ log.error("QwSopCourseFinishTempSetting.Setting:{}" ,st );
|
|
|
+ //存短链-
|
|
|
+ fsCourseLinkMapper.insertFsCourseLink(link);
|
|
|
+ return link.getRealLink();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 增加福袋发放记录、领取记录
|
|
|
+ *
|
|
|
+ * @param content
|
|
|
+ * @param qwSopLogs
|
|
|
+ * @param sendTime
|
|
|
+ * @param companyUserId
|
|
|
+ * @param companyId
|
|
|
+ * @param chatId
|
|
|
+ */
|
|
|
+ private Long addLuckyBagCollectRecord(QwSopCourseFinishTempSetting.Setting content,
|
|
|
+ QwSopLogs qwSopLogs,
|
|
|
+ Date sendTime,
|
|
|
+ String companyUserId,
|
|
|
+ String companyId,
|
|
|
+ String chatId) {
|
|
|
+ try {
|
|
|
+ // 参数校验
|
|
|
+ if (content == null || qwSopLogs == null || sendTime == null) {
|
|
|
+ log.warn("添加福袋记录失败:必要参数为空 [content:{}, qwSopLogs:{}, sendTime:{}]",
|
|
|
+ content, qwSopLogs, sendTime);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(companyId) || StringUtils.isEmpty(companyUserId)) {
|
|
|
+ log.warn("公司ID或用户ID为空 [companyId:{}, companyUserId:{}]", companyId, companyUserId);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证福袋ID
|
|
|
+ if (content.getLuckyBagId() == null) {
|
|
|
+ log.warn("福袋ID为空");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询福袋信息
|
|
|
+ LuckyBag luckyBag = luckyBagMapper.selectLuckyBagById(content.getLuckyBagId());
|
|
|
+ if (luckyBag == null) {
|
|
|
+ log.warn("未找到对应的福袋信息 [luckyBagId:{}]", content.getLuckyBagId());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查福袋状态
|
|
|
+ if (luckyBag.getDataStatus() != null && luckyBag.getDataStatus().equals(0)) {
|
|
|
+ log.warn("福袋被禁用 [luckyBagId:{}]", content.getLuckyBagId());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询公司信息
|
|
|
+ Company company = companyMapper.selectCompanyById(Long.valueOf(companyId));
|
|
|
+ if (company == null) {
|
|
|
+ log.warn("未找到对应的公司信息 [companyId:{}]", companyId);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建福袋记录
|
|
|
+ LuckyBagCollectRecord luckyBagCollectRecord = buildLuckyBagRecord(content, qwSopLogs, sendTime,
|
|
|
+ companyUserId, companyId, chatId, company, luckyBag);
|
|
|
+
|
|
|
+ // 插入记录并返回ID
|
|
|
+ int result = luckyBagCollectRecordMapper.insertLuckyBagCollectRecord(luckyBagCollectRecord);
|
|
|
+ if (result <= 0) {
|
|
|
+ log.warn("福袋记录插入失败 [luckyBagId:{}]", content.getLuckyBagId());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 返回新增记录的ID
|
|
|
+ Long recordId = luckyBagCollectRecord.getId();
|
|
|
+ if (recordId == null) {
|
|
|
+ log.warn("福袋记录插入成功但未返回ID [luckyBagId:{}]", content.getLuckyBagId());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("福袋记录添加成功 [recordId:{}, luckyBagId:{}]", recordId, content.getLuckyBagId());
|
|
|
+ return recordId;
|
|
|
+
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ log.error("ID转换失败 [companyId:{}, companyUserId:{}]", companyId, companyUserId, e);
|
|
|
+ return null;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("ID:" + (content != null ? content.getLuckyBagId() : "unknown") + "-添加福袋记录失败", e);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void createVoiceUrlToIm(QwSopCourseFinishTempSetting.Setting st, String companyUserId, QwSop qwSop) {
|
|
|
+ QwSopTempVoice qwSopTempVoice = sopTempVoiceService.selectQwSopTempVoiceByCompanyUserIdAndVoiceTxt(Long.valueOf(companyUserId), st.getValue());
|
|
|
+ if (qwSopTempVoice != null && qwSopTempVoice.getVoiceUrl() != null && qwSopTempVoice.getRecordType() == 1) {
|
|
|
+ st.setVoiceUrl(qwSopTempVoice.getUserVoiceUrl());
|
|
|
+ st.setVoiceDuration(String.valueOf(qwSopTempVoice.getDuration()));
|
|
|
+ } else if (qwSopTempVoice == null) {
|
|
|
+ if(st.getValue() != null){
|
|
|
+ qwSopTempVoice = new QwSopTempVoice();
|
|
|
+ qwSopTempVoice.setCompanyUserId(Long.valueOf(companyUserId));
|
|
|
+ qwSopTempVoice.setVoiceTxt(st.getValue());
|
|
|
+ qwSopTempVoice.setRecordType(0);
|
|
|
+ sopTempVoiceService.insertQwSopTempVoice(qwSopTempVoice);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void createVoiceUrlToIm(QwSopCourseFinishTempSetting.Setting st, String companyUserId, QwSop qwSop) {
|
|
|
QwSopTempVoice qwSopTempVoice = sopTempVoiceService.selectQwSopTempVoiceByCompanyUserIdAndVoiceTxt(Long.valueOf(companyUserId), st.getValue());
|
|
|
if (qwSopTempVoice != null && qwSopTempVoice.getVoiceUrl() != null && qwSopTempVoice.getRecordType() == 1) {
|
|
|
@@ -1783,5 +2066,88 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 直播看课记录处理
|
|
|
+ * @param companyId
|
|
|
+ * @param companyUserId
|
|
|
+ * @param externalId
|
|
|
+ * @param liveId
|
|
|
+ * @param appId
|
|
|
+ * @param logSource
|
|
|
+ * @param qwUserId
|
|
|
+ * @param corpId
|
|
|
+ */
|
|
|
+ public void createLiveWatchLogAndInsert(String companyId,String companyUserId,String externalId,Long liveId,String appId,Integer logSource,String qwUserId,String corpId){
|
|
|
+ try{
|
|
|
+ // 写入对应数据源的记录表
|
|
|
+ LiveWatchLog itemLiveWatchLog = new LiveWatchLog();
|
|
|
+ itemLiveWatchLog.setLiveId(liveId);
|
|
|
+ itemLiveWatchLog.setLogType(3);
|
|
|
+ itemLiveWatchLog.setSopCreateTime(new Date());
|
|
|
+ itemLiveWatchLog.setCompanyId(Long.valueOf(companyId));
|
|
|
+ itemLiveWatchLog.setCompanyUserId(Long.valueOf(companyUserId));
|
|
|
+ itemLiveWatchLog.setSendAppId(appId);
|
|
|
+ itemLiveWatchLog.setLogSource(logSource);
|
|
|
+ itemLiveWatchLog.setQwUserId(qwUserId);
|
|
|
+ itemLiveWatchLog.setExternalContactId(Long.valueOf(externalId));
|
|
|
+ itemLiveWatchLog.setCorpId(corpId);
|
|
|
+ if(liveWatchLogMapper.updateLiveWatchLogCondition(itemLiveWatchLog) > 0){
|
|
|
+
|
|
|
+ }else{
|
|
|
+ List<LiveWatchLog> handleList= new ArrayList<>();
|
|
|
+ handleList.add(itemLiveWatchLog);
|
|
|
+ liveWatchLogMapper.insertLiveWatchLogBatch(handleList);
|
|
|
+ }
|
|
|
+ }catch(Exception e){
|
|
|
+ log.error("创建直播看课记录失败:{}",e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建福袋记录对象
|
|
|
+ */
|
|
|
+ private LuckyBagCollectRecord buildLuckyBagRecord(QwSopCourseFinishTempSetting.Setting content,
|
|
|
+ QwSopLogs qwSopLogs,
|
|
|
+ Date sendTime,
|
|
|
+ String companyUserId,
|
|
|
+ String companyId,
|
|
|
+ String chatId,
|
|
|
+ Company company,
|
|
|
+ LuckyBag luckyBag) {
|
|
|
+ LuckyBagCollectRecord record = new LuckyBagCollectRecord();
|
|
|
+ QwUser qwUser = qwUserMapper.selectQwUserEntityByQwUserIdAndCorId(qwSopLogs.getQwUserid(),qwSopLogs.getCorpId());
|
|
|
+ record.setQwUserId(qwUser.getQwUserId());
|
|
|
+ record.setQwUserName(qwUser.getQwUserName());
|
|
|
+ record.setLuckyBagId(content.getLuckyBagId());
|
|
|
+ record.setExpiryTime(sendTime);
|
|
|
+ record.setCollectType("3");
|
|
|
+ record.setCompanyId(Long.valueOf(companyId));
|
|
|
+ record.setUserId(qwSopLogs.getFsUserId());
|
|
|
+ if (ObjectUtil.isNotEmpty(qwSopLogs.getFsUserId())){
|
|
|
+ FsUser fsUser = fsUserMapper.selectFsUserByUserId(qwSopLogs.getFsUserId());
|
|
|
+ record.setUserName(ObjectUtil.isNotEmpty(fsUser)?fsUser.getNickName():null);
|
|
|
+ }
|
|
|
+ record.setCompanyName(company.getCompanyName());
|
|
|
+ record.setCompanyUserId(Long.valueOf(companyUserId));
|
|
|
+ record.setSendLink(content.getMiniprogramPage());
|
|
|
+
|
|
|
+ // 设置奖励类型和聊天信息
|
|
|
+ if (StringUtils.isNotEmpty(chatId)) {
|
|
|
+ record.setRewardType(1L);
|
|
|
+ record.setChatId(chatId);
|
|
|
+ record.setExternalUserName(qwSopLogs.getExternalUserName());
|
|
|
+ } else {
|
|
|
+ record.setRewardType(2L);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置币种金额
|
|
|
+ if (luckyBag.getRewardType() != null && luckyBag.getRewardType().equals("1")) {
|
|
|
+ record.setCoinAmount(luckyBag.getAmount());
|
|
|
+ }
|
|
|
+
|
|
|
+ return record;
|
|
|
+ }
|
|
|
|
|
|
}
|