京粉备注
This commit is contained in:
@@ -1271,8 +1271,7 @@ 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 {
|
||||||
@@ -1633,11 +1632,10 @@ public class JDUtil {
|
|||||||
|
|
||||||
public void sendOrderToWxByOrderP(String order, String fromWxid) {
|
public void sendOrderToWxByOrderP(String order, String fromWxid) {
|
||||||
logger.info("sendOrderToWxByOrderP.order {}", order);
|
logger.info("sendOrderToWxByOrderP.order {}", order);
|
||||||
|
getProductTypeMap();
|
||||||
// 检查是否命中“评”指令
|
// 检查是否命中“评”指令
|
||||||
if (!productTypeMap.containsKey(order.trim())) {
|
if (!productTypeMap.containsKey(order.trim())) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
getProductTypeMap();
|
|
||||||
StringBuilder productTypeStr = new StringBuilder();
|
StringBuilder productTypeStr = new StringBuilder();
|
||||||
for (Map.Entry<String, String> entry : productTypeMap.entrySet()) {
|
for (Map.Entry<String, String> entry : productTypeMap.entrySet()) {
|
||||||
String k = entry.getKey();
|
String k = entry.getKey();
|
||||||
@@ -1661,7 +1659,7 @@ public class JDUtil {
|
|||||||
public void getProductTypeMap() {
|
public void getProductTypeMap() {
|
||||||
Map<Object, Object> rawMap = redisTemplate.opsForHash().entries(PRODUCT_TYPE_MAP_PREFIX);
|
Map<Object, Object> rawMap = redisTemplate.opsForHash().entries(PRODUCT_TYPE_MAP_PREFIX);
|
||||||
|
|
||||||
if (rawMap != null && !rawMap.isEmpty()) {
|
if (!rawMap.isEmpty()) {
|
||||||
productTypeMap.clear();
|
productTypeMap.clear();
|
||||||
for (Map.Entry<Object, Object> entry : rawMap.entrySet()) {
|
for (Map.Entry<Object, Object> entry : rawMap.entrySet()) {
|
||||||
productTypeMap.put(entry.getKey().toString(), entry.getValue().toString());
|
productTypeMap.put(entry.getKey().toString(), entry.getValue().toString());
|
||||||
@@ -1700,7 +1698,7 @@ public class JDUtil {
|
|||||||
* 生成评论内容
|
* 生成评论内容
|
||||||
*/
|
*/
|
||||||
private synchronized 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, true);
|
||||||
|
|
||||||
// 获取产品ID
|
// 获取产品ID
|
||||||
getProductTypeMap();
|
getProductTypeMap();
|
||||||
@@ -1724,7 +1722,7 @@ public class JDUtil {
|
|||||||
Collections.shuffle(availableComments);
|
Collections.shuffle(availableComments);
|
||||||
commentToUse = availableComments.get(0);
|
commentToUse = availableComments.get(0);
|
||||||
} else {
|
} else {
|
||||||
wxUtil.sendTextMessage(fromWxid, "没有本地评论,调用外部接口抓取", 1, fromWxid, false);
|
wxUtil.sendTextMessage(fromWxid, "没有本地评论,调用外部接口抓取", 1, fromWxid, true);
|
||||||
// 没有本地评论,调用外部接口抓取
|
// 没有本地评论,调用外部接口抓取
|
||||||
try {
|
try {
|
||||||
String fetchUrl = "http://192.168.8.6:5000/fetch_comments?product_id=" + product_id;
|
String fetchUrl = "http://192.168.8.6:5000/fetch_comments?product_id=" + product_id;
|
||||||
@@ -1734,7 +1732,7 @@ public class JDUtil {
|
|||||||
logger.info("fetchUrl: {}", fetchUrl);
|
logger.info("fetchUrl: {}", fetchUrl);
|
||||||
// code = 200 表示成功,-200 表示失败
|
// code = 200 表示成功,-200 表示失败
|
||||||
if (response.getStatus() == 200) {
|
if (response.getStatus() == 200) {
|
||||||
wxUtil.sendTextMessage(fromWxid, "已获取新的评论,请稍等", 1, fromWxid, false);
|
wxUtil.sendTextMessage(fromWxid, "已获取新的评论,请稍等", 1, fromWxid, true);
|
||||||
// ✅ 关键修改:重新从数据库中查询,而不是使用内存中的 fetchedComments
|
// ✅ 关键修改:重新从数据库中查询,而不是使用内存中的 fetchedComments
|
||||||
availableComments = commentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(product_id, 1);
|
availableComments = commentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(product_id, 1);
|
||||||
if (!availableComments.isEmpty()) {
|
if (!availableComments.isEmpty()) {
|
||||||
@@ -1756,7 +1754,7 @@ public class JDUtil {
|
|||||||
wxUtil.sendTextMessage(fromWxid, "没有找到可用的评论数据", 1, fromWxid, false);
|
wxUtil.sendTextMessage(fromWxid, "没有找到可用的评论数据", 1, fromWxid, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wxUtil.sendTextMessage(fromWxid, "原评论:\n" + commentToUse.getCommentText(), 1, fromWxid, false);
|
wxUtil.sendTextMessage(fromWxid, "原评论:\n" + commentToUse.getCommentText(), 1, fromWxid, true);
|
||||||
// 发送图片(如果有)
|
// 发送图片(如果有)
|
||||||
String pictureUrls = commentToUse.getPictureUrls();
|
String pictureUrls = commentToUse.getPictureUrls();
|
||||||
if (pictureUrls != null && !pictureUrls.isEmpty()) {
|
if (pictureUrls != null && !pictureUrls.isEmpty()) {
|
||||||
@@ -1777,7 +1775,7 @@ public class JDUtil {
|
|||||||
wxUtil.sendTextMessage(fromWxid, "DS评论生成失败", 1, fromWxid, false);
|
wxUtil.sendTextMessage(fromWxid, "DS评论生成失败", 1, fromWxid, false);
|
||||||
}
|
}
|
||||||
// 发送生成的评论文本
|
// 发送生成的评论文本
|
||||||
wxUtil.sendTextMessage(fromWxid, "DS回复:\n" + deepSeekResponse, 1, fromWxid, false);
|
wxUtil.sendTextMessage(fromWxid, "DS回复:\n" + deepSeekResponse, 1, fromWxid, true);
|
||||||
|
|
||||||
// 更新评论状态为已使用
|
// 更新评论状态为已使用
|
||||||
commentToUse.setIsUse(1);
|
commentToUse.setIsUse(1);
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user