You've already forked FrameTour-BE
refactor(task): 重构下载通知任务逻辑
- 引入 ScenicConfigManager 用于获取景区配置信息 - 根据景区配置动态生成通知标题和内容 - 优化了第二次和第三次通知的处理逻辑 - 移除了优惠券相关查询,简化了代码结构
This commit is contained in:
@@ -648,7 +648,16 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
||||||
String title = "您在【" + scenic.getName() + "】的专属影像";
|
ScenicConfigManager configManager = scenicRepository.getScenicConfigManager(item.getScenicId());
|
||||||
|
String configTitle = configManager.getString("first_notification_title");
|
||||||
|
String configContent = configManager.getString("first_notification_content");
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(configTitle) || StringUtils.isBlank(configContent)) {
|
||||||
|
log.info("景区[{}]未配置第一次通知内容,跳过发送通知", scenic.getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String title = configTitle.replace("【景区】", scenic.getName());
|
||||||
String page = "pages/videoSynthesis/index?type=1&scenicId=" + item.getScenicId() + "&faceId=" + item.getFaceId();
|
String page = "pages/videoSynthesis/index?type=1&scenicId=" + item.getScenicId() + "&faceId=" + item.getFaceId();
|
||||||
/**
|
/**
|
||||||
* 视频名称 {{thing1.DATA}}
|
* 视频名称 {{thing1.DATA}}
|
||||||
@@ -664,7 +673,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
|||||||
timeMap2.put("value", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
|
timeMap2.put("value", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm"));
|
||||||
dataParam.put("time4", timeMap2);
|
dataParam.put("time4", timeMap2);
|
||||||
Map<String, String> remarkMap = new HashMap<>();
|
Map<String, String> remarkMap = new HashMap<>();
|
||||||
remarkMap.put("value", "请及时查看视频,48小时后系统删除");
|
remarkMap.put("value", configContent);
|
||||||
dataParam.put("thing3", remarkMap);
|
dataParam.put("thing3", remarkMap);
|
||||||
params.put("data", dataParam);
|
params.put("data", dataParam);
|
||||||
params.put("page", page);
|
params.put("page", page);
|
||||||
|
@@ -18,6 +18,7 @@ import com.ycwl.basic.notify.entity.NotifyContent;
|
|||||||
import com.ycwl.basic.notify.enums.NotifyType;
|
import com.ycwl.basic.notify.enums.NotifyType;
|
||||||
import com.ycwl.basic.repository.ScenicRepository;
|
import com.ycwl.basic.repository.ScenicRepository;
|
||||||
import com.ycwl.basic.repository.TemplateRepository;
|
import com.ycwl.basic.repository.TemplateRepository;
|
||||||
|
import com.ycwl.basic.integration.common.manager.ScenicConfigManager;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -65,7 +66,16 @@ public class DownloadNotificationTasker {
|
|||||||
}
|
}
|
||||||
log.info("发送模板消息");
|
log.info("发送模板消息");
|
||||||
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
||||||
String title = "您在【" + scenic.getName() + "】的专属影像";
|
ScenicConfigManager configManager = scenicRepository.getScenicConfigManager(item.getScenicId());
|
||||||
|
String configTitle = configManager.getString("second_notification_title");
|
||||||
|
String configContent = configManager.getString("second_notification_content");
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(configTitle) || StringUtils.isBlank(configContent)) {
|
||||||
|
log.info("景区[{}]未配置第二次通知内容,跳过发送通知", scenic.getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String title = configTitle.replace("【景区】", scenic.getName());
|
||||||
String page = "pages/videoSynthesis/index?type=2&scenicId=" + item.getScenicId() + "&faceId=" + item.getFaceId();
|
String page = "pages/videoSynthesis/index?type=2&scenicId=" + item.getScenicId() + "&faceId=" + item.getFaceId();
|
||||||
/**
|
/**
|
||||||
* 景区 {{thing1.DATA}}
|
* 景区 {{thing1.DATA}}
|
||||||
@@ -77,17 +87,7 @@ public class DownloadNotificationTasker {
|
|||||||
videoMap.put("value", title);
|
videoMap.put("value", title);
|
||||||
dataParam.put("thing1", videoMap);
|
dataParam.put("thing1", videoMap);
|
||||||
Map<String, String> remarkMap = new HashMap<>();
|
Map<String, String> remarkMap = new HashMap<>();
|
||||||
// 查询是否有优惠券可用,如果有,则显示优惠券配置的内容
|
remarkMap.put("value", configContent);
|
||||||
CouponQueryReq query = new CouponQueryReq();
|
|
||||||
query.setScenicId(item.getScenicId());
|
|
||||||
query.setType(2);
|
|
||||||
query.setStatus(1);
|
|
||||||
List<CouponRespVO> coupons = couponMapper.selectByQuery(query);
|
|
||||||
if (coupons.isEmpty() || StringUtils.isBlank(coupons.getFirst().getBroadcast())) {
|
|
||||||
remarkMap.put("value", "系统删除前,请下载好您的旅行视频");
|
|
||||||
} else {
|
|
||||||
remarkMap.put("value", coupons.getFirst().getBroadcast());
|
|
||||||
}
|
|
||||||
dataParam.put("thing3", remarkMap);
|
dataParam.put("thing3", remarkMap);
|
||||||
params.put("data", dataParam);
|
params.put("data", dataParam);
|
||||||
params.put("page", page);
|
params.put("page", page);
|
||||||
@@ -121,7 +121,16 @@ public class DownloadNotificationTasker {
|
|||||||
}
|
}
|
||||||
log.info("发送模板消息");
|
log.info("发送模板消息");
|
||||||
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
ScenicEntity scenic = scenicRepository.getScenic(item.getScenicId());
|
||||||
String title = "您在【" + scenic.getName() + "】的专属影像";
|
ScenicConfigManager configManager = scenicRepository.getScenicConfigManager(item.getScenicId());
|
||||||
|
String configTitle = configManager.getString("third_notification_title");
|
||||||
|
String configContent = configManager.getString("third_notification_content");
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(configTitle) || StringUtils.isBlank(configContent)) {
|
||||||
|
log.info("景区[{}]未配置第三次通知内容,跳过发送通知", scenic.getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String title = configTitle.replace("【景区】", scenic.getName());
|
||||||
String page = "pages/videoSynthesis/index?type=3&scenicId=" + item.getScenicId() + "&faceId=" + item.getFaceId();
|
String page = "pages/videoSynthesis/index?type=3&scenicId=" + item.getScenicId() + "&faceId=" + item.getFaceId();
|
||||||
/**
|
/**
|
||||||
* 影像名称 {{thing1.DATA}}
|
* 影像名称 {{thing1.DATA}}
|
||||||
@@ -138,17 +147,7 @@ public class DownloadNotificationTasker {
|
|||||||
dateMap.put("value", DateUtil.format(expireDate, "yyyy-MM-dd HH:mm"));
|
dateMap.put("value", DateUtil.format(expireDate, "yyyy-MM-dd HH:mm"));
|
||||||
dataParam.put("time2", dateMap);
|
dataParam.put("time2", dateMap);
|
||||||
Map<String, String> remarkMap = new HashMap<>();
|
Map<String, String> remarkMap = new HashMap<>();
|
||||||
// 查询是否有优惠券可用,如果有,则显示优惠券配置的内容
|
remarkMap.put("value", configContent);
|
||||||
CouponQueryReq query = new CouponQueryReq();
|
|
||||||
query.setScenicId(item.getScenicId());
|
|
||||||
query.setType(3);
|
|
||||||
query.setStatus(1);
|
|
||||||
List<CouponRespVO> coupons = couponMapper.selectByQuery(query);
|
|
||||||
if (coupons.isEmpty() || StringUtils.isBlank(coupons.getFirst().getBroadcast())) {
|
|
||||||
remarkMap.put("value", "视频即将删除,花点小钱买下回忆");
|
|
||||||
} else {
|
|
||||||
remarkMap.put("value", coupons.getFirst().getBroadcast());
|
|
||||||
}
|
|
||||||
dataParam.put("thing3", remarkMap);
|
dataParam.put("thing3", remarkMap);
|
||||||
params.put("data", dataParam);
|
params.put("data", dataParam);
|
||||||
params.put("page", page);
|
params.put("page", page);
|
||||||
@@ -201,8 +200,17 @@ public class DownloadNotificationTasker {
|
|||||||
log.info("模板消息为空");
|
log.info("模板消息为空");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ScenicConfigManager configManager = scenicRepository.getScenicConfigManager(scenicId);
|
||||||
|
String configTitle = configManager.getString("second_notification_title");
|
||||||
|
String configContent = configManager.getString("second_notification_content");
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(configTitle) || StringUtils.isBlank(configContent)) {
|
||||||
|
log.info("景区[{}]未配置第一次通知内容,跳过发送通知", scenic.getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
log.info("发送模板消息");
|
log.info("发送模板消息");
|
||||||
String title = "您在【" + scenic.getName() + "】的专属影像";
|
String title = configTitle.replace("【景区】", scenic.getName());
|
||||||
String page = "pages/videoSynthesis/index?type=2&scenicId=" + item.getScenicId() + "&faceId=" + item.getFaceId();
|
String page = "pages/videoSynthesis/index?type=2&scenicId=" + item.getScenicId() + "&faceId=" + item.getFaceId();
|
||||||
/**
|
/**
|
||||||
* 景区 {{thing1.DATA}}
|
* 景区 {{thing1.DATA}}
|
||||||
@@ -214,7 +222,7 @@ public class DownloadNotificationTasker {
|
|||||||
videoMap.put("value", title);
|
videoMap.put("value", title);
|
||||||
dataParam.put("thing1", videoMap);
|
dataParam.put("thing1", videoMap);
|
||||||
Map<String, String> remarkMap = new HashMap<>();
|
Map<String, String> remarkMap = new HashMap<>();
|
||||||
remarkMap.put("value", "请及时购买并下载好您的旅行视频");
|
remarkMap.put("value", configContent);
|
||||||
dataParam.put("thing3", remarkMap);
|
dataParam.put("thing3", remarkMap);
|
||||||
params.put("data", dataParam);
|
params.put("data", dataParam);
|
||||||
params.put("page", page);
|
params.put("page", page);
|
||||||
|
Reference in New Issue
Block a user