From 6f9057ce56bd66037fad856145b7a4d8bc23cb8d Mon Sep 17 00:00:00 2001 From: Van0313 <60689272+Van0313@users.noreply.github.com> Date: Fri, 2 May 2025 20:49:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/van/business/util/JDUtil.java | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main/java/cn/van/business/util/JDUtil.java b/src/main/java/cn/van/business/util/JDUtil.java index b17ff3e..e69379e 100644 --- a/src/main/java/cn/van/business/util/JDUtil.java +++ b/src/main/java/cn/van/business/util/JDUtil.java @@ -1650,7 +1650,18 @@ public class JDUtil { state.setCurrentState(UserInteractionState.ProcessState.COMMENT_GENERATION); state.setCurrentField("commentTypeSelection"); // 提示用户选择评论类型 - wxUtil.sendTextMessage(fromWxid, "请选择要生成的评论类型:\n回复 1 - 消毒柜评论\n回复 2 - 油烟机评论", 1, fromWxid, false); + getProductTypeMap(); + if (productTypeMap == null){ + wxUtil.sendTextMessage(fromWxid, "productTypeMap 为空 ", 1, fromWxid, false); + return; + } + StringBuilder productTypeStr = new StringBuilder(); + for (Map.Entry entry : productTypeMap.entrySet()) { + String k = entry.getKey(); + String value = entry.getValue(); + productTypeStr.append(k).append(":").append(value).append("\n"); + } + wxUtil.sendTextMessage(fromWxid, "请选择要生成的评论类型:" + productTypeStr, 1, fromWxid, false); logger.info("进入生成评论流程 - 用户: {}", fromWxid); } catch (Exception e) { @@ -1676,16 +1687,6 @@ public class JDUtil { * 处理生成评论流程中的用户交互 */ private void handleCommentInteraction(String fromWxid, String message, UserInteractionState state) { - try { - String[] split = message.replaceAll("\r", "").split("\n"); - if (split.length != 0) { - message = split[0].trim().replace("\n", ""); - for (int i = 1; i < split.length; i++) { - } - } - } catch (Exception e) { - logger.error("handleCommentInteraction 处理生成评论流程中的用户交互异常 - 用户: {}, 状态: {}", fromWxid, state, e); - } String key = INTERACTION_STATE_PREFIX + fromWxid; logger.info("handleCommentInteraction 处理生成评论流程中的用户交互 - 用户: {}, 状态: {},message: {}", fromWxid, state, message); try { @@ -1694,6 +1695,10 @@ public class JDUtil { return; } getProductTypeMap(); + if (productTypeMap == null){ + wxUtil.sendTextMessage(fromWxid, "productTypeMap 为空 ", 1, fromWxid, false); + return; + } if (productTypeMap.containsKey(message)) { generateComment(fromWxid, message); } else { @@ -1718,6 +1723,10 @@ public class JDUtil { // 获取产品ID getProductTypeMap(); + if (productTypeMap == null){ + wxUtil.sendTextMessage(fromWxid, "productTypeMap 为空 ", 1, fromWxid, false); + return; + } String product_id = productTypeMap.get(productType); if (product_id == null || product_id.isEmpty()) { wxUtil.sendTextMessage(fromWxid, "缺失对应的SKUID", 1, fromWxid, false);