|
|
@@ -245,10 +245,24 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
|
|
|
if (ids.isEmpty()) {
|
|
|
return Result.error("id 或 idList 不能为空");
|
|
|
}
|
|
|
+
|
|
|
+ // 同步更新 emails 表的 has_protect
|
|
|
+ LambdaQueryWrapper<MarketEmailsEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(MarketEmailsEntity::getId, ids);
|
|
|
+ queryWrapper.eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0);
|
|
|
+ List<MarketEmailsEntity> list = this.list(queryWrapper);
|
|
|
+ List<Long> customerIdList = list.stream().filter(e -> e.getCustomerId() != null)
|
|
|
+ .map(MarketEmailsEntity::getCustomerId).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(customerIdList)) {
|
|
|
+ return Result.error("客户列表为空");
|
|
|
+ }
|
|
|
+
|
|
|
LambdaUpdateWrapper<MarketEmailsEntity> wrapper = new LambdaUpdateWrapper<>();
|
|
|
- wrapper.in(MarketEmailsEntity::getId, ids);
|
|
|
+ wrapper.in(MarketEmailsEntity::getCustomerId, customerIdList);
|
|
|
wrapper.eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0);
|
|
|
wrapper.set(MarketEmailsEntity::getHasProtect, dto.getHasProtect());
|
|
|
+ wrapper.set(MarketEmailsEntity::getProtectTime, new Date());
|
|
|
+
|
|
|
// 如果是开启保护 且 前端传了保护原因 -> 一并写入
|
|
|
if (Integer.valueOf(1).equals(dto.getHasProtect()) && !ObjectUtils.isEmpty(dto.getProtectReason())) {
|
|
|
wrapper.set(MarketEmailsEntity::getProtectReason, dto.getProtectReason());
|
|
|
@@ -261,16 +275,7 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
|
|
|
if (!ok) {
|
|
|
return Result.error("保护失败");
|
|
|
}
|
|
|
- // 同步更新 emails 表的 has_protect
|
|
|
- LambdaQueryWrapper<MarketEmailsEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.in(MarketEmailsEntity::getId, ids);
|
|
|
- queryWrapper.eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0);
|
|
|
- List<MarketEmailsEntity> list = this.list(queryWrapper);
|
|
|
- List<Long> emailIdList = list.stream().filter(e -> e.getEmailId() != null)
|
|
|
- .map(MarketEmailsEntity::getEmailId).collect(Collectors.toList());
|
|
|
- if (!CollectionUtils.isEmpty(emailIdList)) {
|
|
|
-// emailService.updateEmailHasProtect(emailIdList, dto.getHasProtect());
|
|
|
- }
|
|
|
+
|
|
|
return Result.ok();
|
|
|
}
|
|
|
|
|
|
@@ -290,10 +295,21 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
|
|
|
if (ids.isEmpty()) {
|
|
|
return Result.error("id 或 idList 不能为空");
|
|
|
}
|
|
|
+ LambdaQueryWrapper<MarketEmailsEntity> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(MarketEmailsEntity::getId, ids);
|
|
|
+ queryWrapper.eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0);
|
|
|
+ List<MarketEmailsEntity> list = this.list(queryWrapper);
|
|
|
+ List<Long> customerIdList = list.stream().filter(e -> e.getCustomerId() != null)
|
|
|
+ .map(MarketEmailsEntity::getCustomerId).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(customerIdList)) {
|
|
|
+ return Result.error("客户列表为空");
|
|
|
+ }
|
|
|
+
|
|
|
LambdaUpdateWrapper<MarketEmailsEntity> wrapper = new LambdaUpdateWrapper<>();
|
|
|
- wrapper.in(MarketEmailsEntity::getId, ids);
|
|
|
+ wrapper.in(MarketEmailsEntity::getCustomerId, customerIdList);
|
|
|
wrapper.eq(MarketEmailsEntity::getIsDelete, CommonConstant.DEL_FLAG_0);
|
|
|
wrapper.set(MarketEmailsEntity::getHasSuspend, dto.getHasSuspend());
|
|
|
+ wrapper.set(MarketEmailsEntity::getSuspendTime, new Date());
|
|
|
boolean ok = this.update(wrapper);
|
|
|
if (!ok) {
|
|
|
return Result.error("暂停失败");
|
|
|
@@ -484,13 +500,13 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
|
|
|
} else {
|
|
|
wrapper.eq(MarketEmailsEntity::getHasSuspend, 1);
|
|
|
}
|
|
|
- wrapper.select(MarketEmailsEntity::getId,
|
|
|
- MarketEmailsEntity::getRecipient,
|
|
|
- MarketEmailsEntity::getCustomerId,
|
|
|
- MarketEmailsEntity::getHasProtect,
|
|
|
- MarketEmailsEntity::getHasSuspend,
|
|
|
- MarketEmailsEntity::getProtectReason,
|
|
|
- MarketEmailsEntity::getUpdateTime);
|
|
|
+// wrapper.select(MarketEmailsEntity::getId,
|
|
|
+// MarketEmailsEntity::getRecipient,
|
|
|
+// MarketEmailsEntity::getCustomerId,
|
|
|
+// MarketEmailsEntity::getHasProtect,
|
|
|
+// MarketEmailsEntity::getHasSuspend,
|
|
|
+// MarketEmailsEntity::getProtectReason,
|
|
|
+// MarketEmailsEntity::getUpdateTime);
|
|
|
List<MarketEmailsEntity> all = this.list(wrapper);
|
|
|
|
|
|
// 按 recipient 聚合(同一客户多个保护/暂停记录合并为一张卡片)
|
|
|
@@ -520,11 +536,17 @@ public class MarketEmailsServiceImpl extends MyBaseServiceImpl<MarketEmailsMappe
|
|
|
vo.setHasSuspend(1);
|
|
|
}
|
|
|
// 取最早的 updateTime 作为保护/暂停时间
|
|
|
- if (e.getUpdateTime() != null) {
|
|
|
- if (vo.getProtectTime() == null || e.getUpdateTime().before(vo.getProtectTime())) {
|
|
|
- vo.setProtectTime(e.getUpdateTime());
|
|
|
- }
|
|
|
+ if (e.getProtectTime() != null) {
|
|
|
+ vo.setProtectTime(e.getProtectTime());
|
|
|
+ }
|
|
|
+ if (e.getSuspendTime() != null) {
|
|
|
+ vo.setSuspendTime(e.getSuspendTime());
|
|
|
}
|
|
|
+// if (e.getUpdateTime() != null) {
|
|
|
+// if (vo.getProtectTime() == null || e.getUpdateTime().before(vo.getProtectTime())) {
|
|
|
+// vo.setProtectTime(e.getUpdateTime());
|
|
|
+// }
|
|
|
+// }
|
|
|
// 保护原因:取该 recipient 下任意一条非空的(多条一致时取最先写入的)
|
|
|
if (vo.getProtectReason() == null && e.getProtectReason() != null && !e.getProtectReason().isEmpty()) {
|
|
|
vo.setProtectReason(e.getProtectReason());
|