Kaynağa Gözat

修改营销系统

YPZ 3 hafta önce
ebeveyn
işleme
9733098b5b

+ 6 - 0
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/entity/CustomerBaseEntity.java

@@ -1,6 +1,8 @@
 package com.storlead.trade.entity;
 
+import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.storlead.framework.mybatis.entity.SysBaseField;
 import io.swagger.annotations.ApiModelProperty;
@@ -10,6 +12,10 @@ import lombok.Data;
 @TableName("customer_base")
 public class CustomerBaseEntity extends SysBaseField {
 
+    @ApiModelProperty(value = "主键id")
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
     @ApiModelProperty(value = "客户id")
     @TableField("customer_analysis_id")
     private Long customerAnalysisId;

+ 7 - 7
java/storlead-sasa/storlead-trade/src/main/java/com/storlead/trade/service/impl/MarketingCampaignEntityServiceImpl.java

@@ -109,16 +109,16 @@ public class MarketingCampaignEntityServiceImpl
         //添加关联客户
         List<Long> customerIdList = marketingCampaignDTO.getCustomerAnalysisIdList();
         if (!CollectionUtils.isEmpty(customerIdList)) {
-            List<CustomerBaseEntity> customerBaseEntityList = new ArrayList<>();
-            for (Long customerId : customerIdList) {
+            // 去重,避免主键冲突
+            List<Long> distinctCustomerIds = customerIdList.stream().distinct().collect(Collectors.toList());
+            for (Long customerId : distinctCustomerIds) {
                 CustomerBaseEntity customerBaseEntity = new CustomerBaseEntity();
                 customerBaseEntity.setCustomerAnalysisId(customerId);
                 customerBaseEntity.setMarketingCampaignId(marketingCampaignEntity.getId());
-                customerBaseEntityList.add(customerBaseEntity);
-            }
-            boolean saveOk =customerBaseEntityService.saveBatch(customerBaseEntityList);
-            if (!saveOk){
-                return Result.error("添加失败");
+                boolean saveOk = customerBaseEntityService.save(customerBaseEntity);
+                if (!saveOk) {
+                    return Result.error("添加关联客户失败");
+                }
             }
         }
         //添加关联sopDetailIdList,并调取ai生成邮件内容