|
|
@@ -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,8 @@ 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.*;
|
|
|
@@ -61,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;
|
|
|
@@ -91,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
|
|
|
@@ -175,6 +179,15 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
@Autowired
|
|
|
LiveWatchLogMapper liveWatchLogMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private LuckyBagMapper luckyBagMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LuckyBagCollectRecordMapper luckyBagCollectRecordMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsUserMapper fsUserMapper;
|
|
|
+
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@@ -1321,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:
|
|
|
@@ -1385,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) {
|
|
|
@@ -1512,6 +1525,7 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
+
|
|
|
//直播小程序单独
|
|
|
case "12":
|
|
|
String sortLiveLink;
|
|
|
@@ -1540,6 +1554,124 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
+ case "15":
|
|
|
+ //app语音
|
|
|
+ try {
|
|
|
+ qwSop = qwSopMapper.selectQwSopById(param.getSopId());
|
|
|
+ createVoiceUrl(st, companyUserId, qwSop);
|
|
|
+ if (qwUser.getCompanyUserId() != null) {
|
|
|
+ createVoiceUrlToIm(st, String.valueOf(qwUser.getCompanyUserId()), qwSop);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "16":
|
|
|
+ //app文本
|
|
|
+ String txt = StringUtil.strIsNullOrEmpty(qwUser.getWelcomeText()) ? "" : qwUser.getWelcomeText();
|
|
|
+ st.setValue(st.getValue()
|
|
|
+ .replaceAll("#客服称呼#", txt)
|
|
|
+ .replaceAll("#销售称呼#", txt)
|
|
|
+ .replaceAll("#客户称呼#", StringUtil.strIsNullOrEmpty(contact.getStageStatus()) || "0".equals(contact.getStageStatus()) ? "同学" : contact.getStageStatus()));
|
|
|
+ try {
|
|
|
+ replaceContent(st.getContentType(), st.getValue(), st::setValue, words); // 替换 value
|
|
|
+ } catch (Exception e) {
|
|
|
+ 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;
|
|
|
|
|
|
@@ -1549,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 List<QwSopCourseFinishTempSetting.Setting> parseSettings(String jsonData) {
|
|
|
try {
|
|
|
if (jsonData.startsWith("[") && jsonData.endsWith("]")) {
|
|
|
@@ -1829,4 +2089,49 @@ public class SopUserLogsInfoServiceImpl implements ISopUserLogsInfoService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 构建福袋记录对象
|
|
|
+ */
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
}
|