|
|
@@ -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生成邮件内容
|