This commit is contained in:
2025-10-10 02:07:29 +08:00
parent 4070dfdf91
commit e435298978
2 changed files with 81 additions and 1 deletions

View File

@@ -54,7 +54,7 @@ public class BatchPublishServiceImpl implements IBatchPublishService
// 京东接口配置 // 京东接口配置
private final static String requestUrl = "http://192.168.8.88:6666/jd/"; private final static String requestUrl = "http://192.168.8.88:6666/jd/";
private final static String skey = "your_skey_here"; private final static String skey = "2192057370ef8140c201079969c956a3";
@Autowired @Autowired
private IOuterIdGeneratorService outerIdGeneratorService; private IOuterIdGeneratorService outerIdGeneratorService;
@@ -68,7 +68,10 @@ public class BatchPublishServiceImpl implements IBatchPublishService
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("skey", skey); param.put("skey", skey);
param.put("promotionContent", requestBody.get("promotionContent")); param.put("promotionContent", requestBody.get("promotionContent"));
log.info("调用京东接口URL: {}, 参数: {}", url, param.toJSONString());
String result = HttpUtils.sendJsonPost(url, param.toJSONString()); String result = HttpUtils.sendJsonPost(url, param.toJSONString());
log.info("京东接口响应: {}", result);
// 尝试将 priceInfo.price 提取为顶层 price 字段,并清理文案中的 URL // 尝试将 priceInfo.price 提取为顶层 price 字段,并清理文案中的 URL
try { try {
@@ -113,6 +116,8 @@ public class BatchPublishServiceImpl implements IBatchPublishService
List<String> skuids = LineReportParser.extractSkuids(message); List<String> skuids = LineReportParser.extractSkuids(message);
log.info("提取到 {} 个URL, {} 个SKUID", urls.size(), skuids.size()); log.info("提取到 {} 个URL, {} 个SKUID", urls.size(), skuids.size());
log.info("提取的URLs: {}", urls);
log.info("提取的SKUIDs: {}", skuids);
// 查询商品详情 // 查询商品详情
List<Map<String, Object>> products = new ArrayList<>(); List<Map<String, Object>> products = new ArrayList<>();

75
test_parse.html Normal file
View File

@@ -0,0 +1,75 @@
<!DOCTYPE html>
<html>
<head>
<title>线报解析测试</title>
</head>
<body>
<h2>线报解析测试</h2>
<textarea id="message" rows="10" cols="80" placeholder="请输入线报消息">
【京东】iPhone 15 Pro Max
https://item.jd.com/100012345678.html
到手价7999元
【京东】MacBook Pro
https://item.jd.com/100087654321.html
到手价12999元
SKUID: 1000987654321
</textarea>
<br><br>
<button onclick="testParse()">测试解析</button>
<div id="result"></div>
<script>
function testParse() {
const message = document.getElementById('message').value;
const resultDiv = document.getElementById('result');
// 京东链接正则表达式
const jdUrlPattern = /https?:\/\/[^\s]*?jd\.com[^\s]*/g;
// SKUID正则表达式10-13位数字
const skuidPattern = /\b(\d{10,13})\b/g;
// 提取URLs
const urls = [];
let match;
while ((match = jdUrlPattern.exec(message)) !== null) {
let url = match[0];
url = url.replace(/[\s,,。!?]+$/, '');
if (!urls.includes(url)) {
urls.push(url);
}
}
// 提取SKUIDs
const skuids = [];
while ((match = skuidPattern.exec(message)) !== null) {
const skuid = match[1];
if (skuid.length >= 11) {
skuids.push(skuid);
}
}
// 从URL中提取SKUID
for (const url of urls) {
const skuidMatch = url.match(/item\.jd\.com\/(\d+)\.html/);
if (skuidMatch) {
const skuid = skuidMatch[1];
if (!skuids.includes(skuid)) {
skuids.push(skuid);
}
}
}
resultDiv.innerHTML = `
<h3>解析结果:</h3>
<p><strong>提取到 ${urls.length} 个URL</strong></p>
<ul>${urls.map(url => `<li>${url}</li>`).join('')}</ul>
<p><strong>提取到 ${skuids.length} 个SKUID</strong></p>
<ul>${skuids.map(skuid => `<li>${skuid}</li>`).join('')}</ul>
`;
}
</script>
</body>
</html>