|
@@ -275,6 +275,7 @@ public class MarketingCampaignServiceImpl
|
|
|
marketingCampaignSopDetailEntity.setName(sopDetailEntity.getName());
|
|
marketingCampaignSopDetailEntity.setName(sopDetailEntity.getName());
|
|
|
marketingCampaignSopDetailEntity.setStep(sopDetailEntity.getStep());
|
|
marketingCampaignSopDetailEntity.setStep(sopDetailEntity.getStep());
|
|
|
marketingCampaignSopDetailEntity.setType(sopDetailEntity.getType());
|
|
marketingCampaignSopDetailEntity.setType(sopDetailEntity.getType());
|
|
|
|
|
+ marketingCampaignSopDetailEntity.setDays(sopDetailEntity.getDays());
|
|
|
marketingCampaignSopDetailEntity.setEmailContent(sopDetailEntity.getEmailContent());
|
|
marketingCampaignSopDetailEntity.setEmailContent(sopDetailEntity.getEmailContent());
|
|
|
//预留补充ai生成的邮件内容模板
|
|
//预留补充ai生成的邮件内容模板
|
|
|
// marketingCampaignSopDetailEntity.setEmailContent();
|
|
// marketingCampaignSopDetailEntity.setEmailContent();
|
|
@@ -296,6 +297,10 @@ public class MarketingCampaignServiceImpl
|
|
|
return Result.error("id不能为空");
|
|
return Result.error("id不能为空");
|
|
|
}
|
|
}
|
|
|
MarketingCampaignEntity marketingCampaignOld = this.getById(marketingCampaignDTO.getId());
|
|
MarketingCampaignEntity marketingCampaignOld = this.getById(marketingCampaignDTO.getId());
|
|
|
|
|
+ //只有未开始的营销活动才能修改
|
|
|
|
|
+ if (marketingCampaignOld.getStatus() != null && marketingCampaignOld.getStatus() != 0) {
|
|
|
|
|
+ return Result.error("该营销活动不能修改");
|
|
|
|
|
+ }
|
|
|
MarketingCampaignEntity marketingCampaignEntity = new MarketingCampaignEntity();
|
|
MarketingCampaignEntity marketingCampaignEntity = new MarketingCampaignEntity();
|
|
|
BeanUtils.copyProperties(marketingCampaignDTO, marketingCampaignEntity);
|
|
BeanUtils.copyProperties(marketingCampaignDTO, marketingCampaignEntity);
|
|
|
// supervisorList 转为逗号分隔字符串
|
|
// supervisorList 转为逗号分隔字符串
|
|
@@ -347,6 +352,7 @@ public class MarketingCampaignServiceImpl
|
|
|
marketingCampaignSopDetailEntity.setName(sopDetailEntity.getName());
|
|
marketingCampaignSopDetailEntity.setName(sopDetailEntity.getName());
|
|
|
marketingCampaignSopDetailEntity.setStep(sopDetailEntity.getStep());
|
|
marketingCampaignSopDetailEntity.setStep(sopDetailEntity.getStep());
|
|
|
marketingCampaignSopDetailEntity.setType(sopDetailEntity.getType());
|
|
marketingCampaignSopDetailEntity.setType(sopDetailEntity.getType());
|
|
|
|
|
+ marketingCampaignSopDetailEntity.setDays(sopDetailEntity.getDays());
|
|
|
marketingCampaignSopDetailEntity.setEmailContent(sopDetailEntity.getEmailContent());
|
|
marketingCampaignSopDetailEntity.setEmailContent(sopDetailEntity.getEmailContent());
|
|
|
//预留补充ai生成的邮件内容模板
|
|
//预留补充ai生成的邮件内容模板
|
|
|
// marketingCampaignSopDetailEntity.setEmailContent();
|
|
// marketingCampaignSopDetailEntity.setEmailContent();
|
|
@@ -401,68 +407,33 @@ public class MarketingCampaignServiceImpl
|
|
|
public void syncStartEndStatus() {
|
|
public void syncStartEndStatus() {
|
|
|
LocalDate today = LocalDate.now(ZoneId.of("Asia/Shanghai"));
|
|
LocalDate today = LocalDate.now(ZoneId.of("Asia/Shanghai"));
|
|
|
// 查询所有未开始的活动
|
|
// 查询所有未开始的活动
|
|
|
- List<MarketingCampaignEntity> all = this.lambdaQuery()
|
|
|
|
|
|
|
+ List<MarketingCampaignEntity> nonAll = this.lambdaQuery()
|
|
|
.eq(MarketingCampaignEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
|
|
.eq(MarketingCampaignEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
|
|
|
.eq(MarketingCampaignEntity::getStatus, 0)
|
|
.eq(MarketingCampaignEntity::getStatus, 0)
|
|
|
|
|
+ .ge(MarketingCampaignEntity::getBeginData, today)
|
|
|
.list();
|
|
.list();
|
|
|
- if (CollectionUtils.isEmpty(all)) {
|
|
|
|
|
- log.info("营销活动开始/结束状态同步:无未删除活动,跳过");
|
|
|
|
|
- return;
|
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(nonAll)) {
|
|
|
|
|
+ List<Long> startIdList = nonAll.stream().map(MarketingCampaignEntity::getId).collect(Collectors.toList());
|
|
|
|
|
+ LambdaUpdateWrapper<MarketEmailsEntity> marketEmailsUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ marketEmailsUpdateWrapper.in(MarketEmailsEntity::getMarketingCampaignId, startIdList);
|
|
|
|
|
+ marketEmailsUpdateWrapper.ne(MarketEmailsEntity::getStatus, -3);
|
|
|
|
|
+ marketEmailsUpdateWrapper.set(MarketEmailsEntity::getStatus, -1);
|
|
|
|
|
+ marketEmailsService.update(marketEmailsUpdateWrapper);
|
|
|
}
|
|
}
|
|
|
- // 按目标状态分组,只收集需要变更的 id(跳过暂停 / 日期缺失 / 状态已一致)
|
|
|
|
|
- // 后续每种状态仅执行一次批量 UPDATE,而非逐条 UPDATE
|
|
|
|
|
- Map<Integer, List<Long>> idsByStatus = new HashMap<>(4);
|
|
|
|
|
- // 变更的实体列表(status 已回填为目标状态,用于区分改为开始/结束)
|
|
|
|
|
- List<MarketingCampaignEntity> changed = new ArrayList<>();
|
|
|
|
|
- for (MarketingCampaignEntity c : all) {
|
|
|
|
|
- Integer expected = computeStartEndStatus(c, today);
|
|
|
|
|
- if (expected == null) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- Integer current = c.getStatus();
|
|
|
|
|
- // 尊重手动暂停,不自动覆盖
|
|
|
|
|
- if (current != null && current == STATUS_PAUSED) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- if (expected.equals(current)) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- idsByStatus.computeIfAbsent(expected, k -> new ArrayList<>()).add(c.getId());
|
|
|
|
|
- c.setStatus(expected);
|
|
|
|
|
- changed.add(c);
|
|
|
|
|
|
|
+ // 查询所有已结束的活动
|
|
|
|
|
+ List<MarketingCampaignEntity> stopAll = this.lambdaQuery()
|
|
|
|
|
+ .eq(MarketingCampaignEntity::getIsDelete, CommonConstant.DEL_FLAG_0)
|
|
|
|
|
+ .eq(MarketingCampaignEntity::getStatus, 1)
|
|
|
|
|
+ .le(MarketingCampaignEntity::getEndDate, today)
|
|
|
|
|
+ .list();
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(stopAll)) {
|
|
|
|
|
+ List<Long> stopIdList = stopAll.stream().map(MarketingCampaignEntity::getId).collect(Collectors.toList());
|
|
|
|
|
+ LambdaUpdateWrapper<MarketEmailsEntity> marketEmailsUpdateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
|
+ marketEmailsUpdateWrapper.in(MarketEmailsEntity::getMarketingCampaignId, stopIdList);
|
|
|
|
|
+ marketEmailsUpdateWrapper.eq(MarketEmailsEntity::getStatus, -1);
|
|
|
|
|
+ marketEmailsUpdateWrapper.set(MarketEmailsEntity::getStatus, -3);
|
|
|
|
|
+ marketEmailsService.update(marketEmailsUpdateWrapper);
|
|
|
}
|
|
}
|
|
|
-// // 每种目标状态执行一次批量 UPDATE
|
|
|
|
|
-// for (Map.Entry<Integer, List<Long>> entry : idsByStatus.entrySet()) {
|
|
|
|
|
-// List<Long> ids = entry.getValue();
|
|
|
|
|
-// if (CollectionUtils.isEmpty(ids)) {
|
|
|
|
|
-// continue;
|
|
|
|
|
-// }
|
|
|
|
|
-// this.lambdaUpdate()
|
|
|
|
|
-// .in(MarketingCampaignEntity::getId, ids)
|
|
|
|
|
-// .set(MarketingCampaignEntity::getStatus, entry.getKey())
|
|
|
|
|
-// .update();
|
|
|
|
|
-// }
|
|
|
|
|
-// // 按目标状态拆分列表并打印:哪些改为开始、哪些改为结束
|
|
|
|
|
-// List<Long> started = changed.stream()
|
|
|
|
|
-// .filter(e -> STATUS_RUNNING == e.getStatus())
|
|
|
|
|
-// .map(MarketingCampaignEntity::getId)
|
|
|
|
|
-// .collect(Collectors.toList());
|
|
|
|
|
-// List<Long> ended = changed.stream()
|
|
|
|
|
-// .filter(e -> STATUS_COMPLETED == e.getStatus())
|
|
|
|
|
-// .map(MarketingCampaignEntity::getId)
|
|
|
|
|
-// .collect(Collectors.toList());
|
|
|
|
|
-// log.info("营销活动开始/结束状态同步完成:改为开始(运行中)={}, 改为结束(完成)={}", started, ended);
|
|
|
|
|
-// MarketEmailsCustomerVO startVO = new MarketEmailsCustomerVO();
|
|
|
|
|
-// startVO.setMarketingCampaignIdList(started);
|
|
|
|
|
-// //修改状态为待发送
|
|
|
|
|
-// startVO.setStatus(-1);
|
|
|
|
|
-// marketEmailsService.updateCustomerEmailStatus(startVO);
|
|
|
|
|
-//
|
|
|
|
|
-// MarketEmailsCustomerVO endVO = new MarketEmailsCustomerVO();
|
|
|
|
|
-// endVO.setMarketingCampaignIdList(ended);
|
|
|
|
|
-// //修改状态为待发送
|
|
|
|
|
-// endVO.setStatus(-3);
|
|
|
|
|
-// marketEmailsService.updateCustomerEmailStatus(endVO);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|