1
This commit is contained in:
@@ -90,6 +90,24 @@ public class BatchPublishServiceImpl implements IBatchPublishService
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理敏感营销词(保留换行不动)
|
||||
*/
|
||||
private String cleanForbiddenPhrases(String text) {
|
||||
if (text == null || text.isEmpty()) {
|
||||
return text;
|
||||
}
|
||||
String cleaned = text;
|
||||
// 先清理更长的组合词,再清理单词
|
||||
cleaned = cleaned.replaceAll("咨询客服领\\s*国补", "");
|
||||
cleaned = cleaned.replaceAll("政府补贴", "");
|
||||
cleaned = cleaned.replaceAll("国补", "");
|
||||
cleaned = cleaned.replaceAll("补贴", "");
|
||||
// 清理每行首尾空格
|
||||
cleaned = cleaned.replaceAll("(?m)^[ \\t]+|[ \\t]+$", "");
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用京东接口生成推广内容
|
||||
*/
|
||||
@@ -117,10 +135,11 @@ public class BatchPublishServiceImpl implements IBatchPublishService
|
||||
item.put("price", item.getJSONObject("priceInfo").get("price"));
|
||||
}
|
||||
|
||||
// 清理 content 字段中的URL
|
||||
// 清理 content 字段中的URL与敏感词
|
||||
if (item.containsKey("content")) {
|
||||
String content = item.getString("content");
|
||||
content = cleanUrlsFromText(content);
|
||||
content = cleanForbiddenPhrases(content);
|
||||
item.put("content", content);
|
||||
}
|
||||
|
||||
@@ -134,6 +153,7 @@ public class BatchPublishServiceImpl implements IBatchPublishService
|
||||
if (wenanItem != null && wenanItem.containsKey("content")) {
|
||||
String wenanContent = wenanItem.getString("content");
|
||||
wenanContent = cleanUrlsFromText(wenanContent);
|
||||
wenanContent = cleanForbiddenPhrases(wenanContent);
|
||||
wenanItem.put("content", wenanContent);
|
||||
}
|
||||
}
|
||||
@@ -624,8 +644,9 @@ public class BatchPublishServiceImpl implements IBatchPublishService
|
||||
shop.setProvince(commonParams.getProvince());
|
||||
shop.setCity(commonParams.getCity());
|
||||
shop.setDistrict(commonParams.getDistrict());
|
||||
// 标题长度限制:最多60个字符,做安全截断(按code point防止截断表情)
|
||||
// 标题清理敏感词并限制长度(最多60个字符)
|
||||
String title = item.getProductName();
|
||||
title = cleanForbiddenPhrases(title);
|
||||
shop.setTitle(truncateByCodePoints(title, 60));
|
||||
|
||||
// 【修改】使用用户选择的文案
|
||||
@@ -636,6 +657,8 @@ public class BatchPublishServiceImpl implements IBatchPublishService
|
||||
"SKUID: " + item.getSkuid() + "\n" +
|
||||
"店铺信息: " + ((productConfig != null && productConfig.getShopName() != null) ? productConfig.getShopName() : "京东商城");
|
||||
}
|
||||
// 内容清理敏感词
|
||||
content = cleanForbiddenPhrases(content);
|
||||
shop.setContent(content);
|
||||
|
||||
// 【修改】使用商品配置中的图片数组
|
||||
|
||||
Reference in New Issue
Block a user