YPZ 3 settimane fa
parent
commit
4fdfa85156

+ 16 - 0
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/entity/MarketEmailsEntity.java

@@ -62,6 +62,8 @@ public class MarketEmailsEntity extends SysBaseField {
     @TableField("expect_send_time")
     private Date expectSendTime;
 
+
+
     @ApiModelProperty(value = "邮件内容")
     @TableField("content")
     private String content;
@@ -74,6 +76,20 @@ public class MarketEmailsEntity extends SysBaseField {
     @TableField("has_suspend")
     private Integer hasSuspend;
 
+    @ApiModelProperty(value = "客户保护时间")
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JSONField(format ="yyyy-MM-dd HH:mm:ss")
+    @TableField("protect_time")
+    private Date protectTime;
+
+    @ApiModelProperty(value = "客户暂停时间")
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JSONField(format ="yyyy-MM-dd HH:mm:ss")
+    @TableField("suspend_time")
+    private Date suspendTime;
+
     @ApiModelProperty(value = "收件人邮箱")
     @TableField("recipient")
     private String recipient;

+ 45 - 23
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/MarketEmailsServiceImpl.java

@@ -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());

+ 20 - 5
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/vo/MarketEmailsProtectVO.java

@@ -1,6 +1,7 @@
 package com.storlead.trade.vo;
 
 import com.alibaba.fastjson.annotation.JSONField;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -39,15 +40,29 @@ public class MarketEmailsProtectVO implements Serializable {
     @ApiModelProperty(value = "保护原因")
     private String protectReason;
 
-    @ApiModelProperty(value = "保护时间(取该 recipient 下最早一次保护的时间)")
-    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
-    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
-    private Date protectTime;
+//    @ApiModelProperty(value = "保护时间(取该 recipient 下最早一次保护的时间)")
+//    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+//    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+//    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+//    private Date protectTime;
 
     @ApiModelProperty(value = "是否保护(0未保护、1保护)")
     private Integer hasProtect;
 
     @ApiModelProperty(value = "是否暂停(0未暂停、1暂停)")
     private Integer hasSuspend;
+
+    @ApiModelProperty(value = "客户保护时间")
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JSONField(format ="yyyy-MM-dd HH:mm:ss")
+    @TableField("protect_time")
+    private Date protectTime;
+
+    @ApiModelProperty(value = "客户暂停时间")
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @JSONField(format ="yyyy-MM-dd HH:mm:ss")
+    @TableField("suspend_time")
+    private Date suspendTime;
 }