重构评论

This commit is contained in:
Van0313
2025-05-06 11:56:27 +08:00
parent 0d10b3583e
commit f84910a678

View File

@@ -1646,20 +1646,11 @@ public class JDUtil {
logger.info("loadOrCreateState - 用户: {}, 状态: {}", fromWxid, state);
try {
// 设置当前状态为生成评论流程
state.setCurrentState(UserInteractionState.ProcessState.COMMENT_GENERATION);
state.setCurrentField("commentTypeSelection");
// 提示用户选择评论类型
getProductTypeMap();
if (productTypeMap == null) {
wxUtil.sendTextMessage(fromWxid, "productTypeMap 为空 ", 1, fromWxid, false);
return;
}
StringBuilder productTypeStr = new StringBuilder();
for (Map.Entry<String, String> entry : productTypeMap.entrySet()) {
String k = entry.getKey();
//String value = entry.getValue();
productTypeStr.append(" ").append(k) .append("\n");
productTypeStr.append(" ").append(k).append("\n");
}
wxUtil.sendTextMessage(fromWxid, "请选择要生成的评论类型:\n " + productTypeStr, 1, fromWxid, false);
logger.info("进入生成评论流程 - 用户: {}", fromWxid);
@@ -1672,6 +1663,15 @@ public class JDUtil {
saveState(key, state);
}
} else {
// 初始化用户交互状态
String key = INTERACTION_STATE_PREFIX + fromWxid;
state = loadOrCreateState(key);
logger.info("loadOrCreateState - 用户: {}, 状态: {}", fromWxid, state);
// 设置当前状态为生成评论流程
state.setCurrentState(UserInteractionState.ProcessState.COMMENT_GENERATION);
state.setCurrentField("commentTypeSelection");
saveState(key, state);
// 如果未命中“评”指令,检查是否在生成评论流程中
handleCommentInteraction(fromWxid, order, state);
}
@@ -1700,9 +1700,9 @@ public class JDUtil {
logger.info("handleCommentInteraction 处理生成评论流程中的用户交互 - 用户: {}, 状态: {},message: {}", fromWxid, state, message);
try {
// 检查当前状态是否为生成评论流程
if (!"commentTypeSelection".equals(state.getCurrentField())) {
return;
}
//if (!"commentTypeSelection".equals(state.getCurrentField())) {
// return;
//}
getProductTypeMap();
if (productTypeMap == null) {
wxUtil.sendTextMessage(fromWxid, "productTypeMap 为空 ", 1, fromWxid, false);