重构评论
This commit is contained in:
@@ -1699,7 +1699,7 @@ public class JDUtil {
|
|||||||
/**
|
/**
|
||||||
* 生成评论内容
|
* 生成评论内容
|
||||||
*/
|
*/
|
||||||
private void generateComment(String fromWxid, String productType) {
|
private synchronized void generateComment(String fromWxid, String productType) {
|
||||||
wxUtil.sendTextMessage(fromWxid, "已接收到评论生成指令,等候过程请勿重复输入", 1, fromWxid, false);
|
wxUtil.sendTextMessage(fromWxid, "已接收到评论生成指令,等候过程请勿重复输入", 1, fromWxid, false);
|
||||||
|
|
||||||
// 获取产品ID
|
// 获取产品ID
|
||||||
@@ -1757,7 +1757,16 @@ public class JDUtil {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wxUtil.sendTextMessage(fromWxid, "原评论:\n" + commentToUse.getCommentText(), 1, fromWxid, false);
|
wxUtil.sendTextMessage(fromWxid, "原评论:\n" + commentToUse.getCommentText(), 1, fromWxid, false);
|
||||||
|
// 发送图片(如果有)
|
||||||
|
String pictureUrls = commentToUse.getPictureUrls();
|
||||||
|
if (pictureUrls != null && !pictureUrls.isEmpty()) {
|
||||||
|
// 使用 fastjson 将 JSON 字符串解析为 List<String>
|
||||||
|
List<String> urlList = JSON.parseArray(pictureUrls, String.class);
|
||||||
|
|
||||||
|
for (String url : urlList) {
|
||||||
|
wxUtil.sendImageMessage(fromWxid, url.trim()); // 假设 sendImageMessage 支持 URL
|
||||||
|
}
|
||||||
|
}
|
||||||
// 调用 DeepSeek 生成新的评论内容
|
// 调用 DeepSeek 生成新的评论内容
|
||||||
String deepSeekPrompt = COMMENT_TEMPLATES_DS + commentToUse.getCommentText();
|
String deepSeekPrompt = COMMENT_TEMPLATES_DS + commentToUse.getCommentText();
|
||||||
String deepSeekResponse = "";
|
String deepSeekResponse = "";
|
||||||
@@ -1770,24 +1779,10 @@ public class JDUtil {
|
|||||||
// 发送生成的评论文本
|
// 发送生成的评论文本
|
||||||
wxUtil.sendTextMessage(fromWxid, "DS回复:\n" + deepSeekResponse, 1, fromWxid, false);
|
wxUtil.sendTextMessage(fromWxid, "DS回复:\n" + deepSeekResponse, 1, fromWxid, false);
|
||||||
|
|
||||||
// 发送图片(如果有)
|
|
||||||
String pictureUrls = commentToUse.getPictureUrls();
|
|
||||||
if (pictureUrls != null && !pictureUrls.isEmpty()) {
|
|
||||||
// 使用 fastjson 将 JSON 字符串解析为 List<String>
|
|
||||||
List<String> urlList = JSON.parseArray(pictureUrls, String.class);
|
|
||||||
|
|
||||||
for (String url : urlList) {
|
|
||||||
wxUtil.sendImageMessage(fromWxid, url.trim()); // 假设 sendImageMessage 支持 URL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 更新评论状态为已使用
|
// 更新评论状态为已使用
|
||||||
commentToUse.setIsUse(1);
|
commentToUse.setIsUse(1);
|
||||||
commentRepository.save(commentToUse);
|
commentRepository.save(commentToUse);
|
||||||
|
|
||||||
// 重置状态
|
|
||||||
resetState(fromWxid, loadOrCreateState(INTERACTION_STATE_PREFIX + fromWxid));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user