重构评论
This commit is contained in:
@@ -97,19 +97,7 @@ public class JDUtil {
|
|||||||
5:价格有浮动,不支持补差价,谢谢理解。
|
5:价格有浮动,不支持补差价,谢谢理解。
|
||||||
6:全国联保,全国统一安装标准。支持官方 400,服务号查询,假一赔十。
|
6:全国联保,全国统一安装标准。支持官方 400,服务号查询,假一赔十。
|
||||||
""";
|
""";
|
||||||
private static final String WENAN_FANAN_BX ="本人提供免费指导下单服务,一台也是团购价,细心指导\n" +
|
private static final String WENAN_FANAN_BX = "本人提供免费指导下单服务,一台也是团购价,细心指导\n" + "\n" + "【质量】官旗下单,包正的\n" + "【物流】您自己账户可跟踪,24小时发货\n" + "【售后】您自己账户直接联系,无忧售后\n" + "【安装】专业人员安装,全程无需您操心\n" + "【价格】标价就是到手价,骑共享单车去酒吧,该省省该花花\n" + "【服务】手把手教您下单,有问题随时咨询\n" + "【体验】所有服务都是官旗提供,价格有内部渠道优惠,同品质更优惠!\n" + "\n" + "信息更新日期:\n" + "\n" + "捡漏价格不定时有变动,优惠不等人,发「省份+型号」免费咨询当日最低价!";
|
||||||
"\n" +
|
|
||||||
"【质量】官旗下单,包正的\n" +
|
|
||||||
"【物流】您自己账户可跟踪,24小时发货\n" +
|
|
||||||
"【售后】您自己账户直接联系,无忧售后\n" +
|
|
||||||
"【安装】专业人员安装,全程无需您操心\n" +
|
|
||||||
"【价格】标价就是到手价,骑共享单车去酒吧,该省省该花花\n" +
|
|
||||||
"【服务】手把手教您下单,有问题随时咨询\n" +
|
|
||||||
"【体验】所有服务都是官旗提供,价格有内部渠道优惠,同品质更优惠!\n" +
|
|
||||||
"\n" +
|
|
||||||
"信息更新日期:\n" +
|
|
||||||
"\n" +
|
|
||||||
"捡漏价格不定时有变动,优惠不等人,发「省份+型号」免费咨询当日最低价!";
|
|
||||||
private static final String FANAN_COMMON = "\n1 文案复制到微,点击领券,到J东APP结算\n" + "2 换新可直接代消单,不用提供回收\n " + "3 独家虹包 https://u.jd.com/raa0eI4 至高可领618 \n";
|
private static final String FANAN_COMMON = "\n1 文案复制到微,点击领券,到J东APP结算\n" + "2 换新可直接代消单,不用提供回收\n " + "3 独家虹包 https://u.jd.com/raa0eI4 至高可领618 \n";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1238,7 +1226,8 @@ public class JDUtil {
|
|||||||
try {
|
try {
|
||||||
priceList = extractPrices(message);
|
priceList = extractPrices(message);
|
||||||
finallyMessage.put("priceList", priceList);
|
finallyMessage.put("priceList", priceList);
|
||||||
} catch (Exception ignored) { }
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (String url : urls) {
|
for (String url : urls) {
|
||||||
try {
|
try {
|
||||||
@@ -1649,6 +1638,7 @@ public class JDUtil {
|
|||||||
logger.warn("Redis 中未找到键为 {} 的 Hash 数据", PRODUCT_TYPE_MAP_PREFIX);
|
logger.warn("Redis 中未找到键为 {} 的 Hash 数据", PRODUCT_TYPE_MAP_PREFIX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addProductTypeMap(String key, String value) {
|
public void addProductTypeMap(String key, String value) {
|
||||||
redisTemplate.opsForHash().put(PRODUCT_TYPE_MAP_PREFIX, key, value);
|
redisTemplate.opsForHash().put(PRODUCT_TYPE_MAP_PREFIX, key, value);
|
||||||
}
|
}
|
||||||
@@ -1683,7 +1673,10 @@ public class JDUtil {
|
|||||||
*/
|
*/
|
||||||
private synchronized void generateComment(String fromWxid, String productType) {
|
private synchronized void generateComment(String fromWxid, String productType) {
|
||||||
wxUtil.sendTextMessage(fromWxid, "已接收到评论生成指令,等候过程请勿重复输入", 1, fromWxid, true);
|
wxUtil.sendTextMessage(fromWxid, "已接收到评论生成指令,等候过程请勿重复输入", 1, fromWxid, true);
|
||||||
|
int allCommentCount = 0;
|
||||||
|
int usedCommentCount = 0;
|
||||||
|
int canUseComentCount = 0;
|
||||||
|
int addCommentCount = 0;
|
||||||
// 获取产品ID
|
// 获取产品ID
|
||||||
getProductTypeMap();
|
getProductTypeMap();
|
||||||
String product_id = productTypeMap.get(productType);
|
String product_id = productTypeMap.get(productType);
|
||||||
@@ -1694,6 +1687,10 @@ public class JDUtil {
|
|||||||
|
|
||||||
// 从数据库获取可用评论
|
// 从数据库获取可用评论
|
||||||
List<Comment> availableComments = commentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(product_id, 1);
|
List<Comment> availableComments = commentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(product_id, 1);
|
||||||
|
List<Comment> usedComments = commentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(product_id, 0);
|
||||||
|
canUseComentCount = availableComments.size();
|
||||||
|
usedCommentCount = usedComments.size();
|
||||||
|
|
||||||
|
|
||||||
Comment commentToUse = null;
|
Comment commentToUse = null;
|
||||||
|
|
||||||
@@ -1716,6 +1713,7 @@ public class JDUtil {
|
|||||||
// ✅ 关键修改:重新从数据库中查询,而不是使用内存中的 fetchedComments
|
// ✅ 关键修改:重新从数据库中查询,而不是使用内存中的 fetchedComments
|
||||||
availableComments = commentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(product_id, 1);
|
availableComments = commentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(product_id, 1);
|
||||||
if (!availableComments.isEmpty()) {
|
if (!availableComments.isEmpty()) {
|
||||||
|
addCommentCount = canUseComentCount - availableComments.size();
|
||||||
Collections.shuffle(availableComments);
|
Collections.shuffle(availableComments);
|
||||||
commentToUse = availableComments.get(0);
|
commentToUse = availableComments.get(0);
|
||||||
}
|
}
|
||||||
@@ -1749,9 +1747,11 @@ public class JDUtil {
|
|||||||
StringBuilder deepSeekPrompt = new StringBuilder(COMMENT_TEMPLATES_DS + commentToUse.getCommentText());
|
StringBuilder deepSeekPrompt = new StringBuilder(COMMENT_TEMPLATES_DS + commentToUse.getCommentText());
|
||||||
//String deepSeekResponse = "";
|
//String deepSeekResponse = "";
|
||||||
String gptResponse = "";
|
String gptResponse = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//deepSeekResponse = deepSeekClientUtil.getDeepSeekResponse(deepSeekPrompt);
|
//deepSeekResponse = deepSeekClientUtil.getDeepSeekResponse(deepSeekPrompt);
|
||||||
List<Comment> comments = commentRepository.findByProductIdAndPictureUrlsIsNotNull(product_id);
|
List<Comment> comments = commentRepository.findByProductIdAndPictureUrlsIsNotNull(product_id);
|
||||||
|
allCommentCount = comments.size();
|
||||||
// 随机截取至多10个
|
// 随机截取至多10个
|
||||||
comments = comments.subList(0, Math.min(10, comments.size()));
|
comments = comments.subList(0, Math.min(10, comments.size()));
|
||||||
for (Comment comment : comments) {
|
for (Comment comment : comments) {
|
||||||
@@ -1766,9 +1766,8 @@ public class JDUtil {
|
|||||||
wxUtil.sendTextMessage(fromWxid, "AI 评论生成失败", 1, fromWxid, false);
|
wxUtil.sendTextMessage(fromWxid, "AI 评论生成失败", 1, fromWxid, false);
|
||||||
}
|
}
|
||||||
// 发送生成的评论文本
|
// 发送生成的评论文本
|
||||||
//wxUtil.sendTextMessage(fromWxid, "DS回复:\n" + deepSeekResponse, 1, fromWxid, true);
|
|
||||||
wxUtil.sendTextMessage(fromWxid, "GPT回复:\n" + gptResponse, 1, fromWxid, true);
|
wxUtil.sendTextMessage(fromWxid, "GPT回复:\n" + gptResponse, 1, fromWxid, true);
|
||||||
|
wxUtil.sendTextMessage(fromWxid, "评论统计:\n" + "型号 " + productType + "\n" + "新增:" + addCommentCount + "\n" + "已使用:" + usedCommentCount + "\n" + "可用:" + canUseComentCount + "\n" + "总数:" + allCommentCount, 1, fromWxid, true);
|
||||||
// 更新评论状态为已使用
|
// 更新评论状态为已使用
|
||||||
commentToUse.setIsUse(1);
|
commentToUse.setIsUse(1);
|
||||||
commentRepository.save(commentToUse);
|
commentRepository.save(commentToUse);
|
||||||
|
|||||||
Reference in New Issue
Block a user