重构评论
This commit is contained in:
@@ -1640,10 +1640,6 @@ public class JDUtil {
|
||||
// 检查是否命中“评”指令
|
||||
UserInteractionState state = null;
|
||||
if (!productTypeMap.containsKey(order.trim())) {
|
||||
// 初始化用户交互状态
|
||||
String key = INTERACTION_STATE_PREFIX + fromWxid;
|
||||
state = loadOrCreateState(key);
|
||||
logger.info("loadOrCreateState - 用户: {}, 状态: {}", fromWxid, state);
|
||||
|
||||
try {
|
||||
StringBuilder productTypeStr = new StringBuilder();
|
||||
@@ -1658,20 +1654,8 @@ public class JDUtil {
|
||||
} catch (Exception e) {
|
||||
logger.error("生成评论流程初始化异常 - 用户: {}, 状态: {}", fromWxid, state, e);
|
||||
wxUtil.sendTextMessage(fromWxid, "处理异常,请重新开始", 1, fromWxid, false);
|
||||
resetState(fromWxid, state);
|
||||
} finally {
|
||||
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);
|
||||
}
|
||||
@@ -1695,14 +1679,10 @@ public class JDUtil {
|
||||
/**
|
||||
* 处理生成评论流程中的用户交互
|
||||
*/
|
||||
private void handleCommentInteraction(String fromWxid, String message, UserInteractionState state) {
|
||||
String key = INTERACTION_STATE_PREFIX + fromWxid;
|
||||
private void handleCommentInteraction(String fromWxid, String message) {
|
||||
logger.info("handleCommentInteraction 处理生成评论流程中的用户交互 - 用户: {}, 状态: {},message: {}", fromWxid, state, message);
|
||||
try {
|
||||
// 检查当前状态是否为生成评论流程
|
||||
//if (!"commentTypeSelection".equals(state.getCurrentField())) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
getProductTypeMap();
|
||||
if (productTypeMap == null) {
|
||||
wxUtil.sendTextMessage(fromWxid, "productTypeMap 为空 ", 1, fromWxid, false);
|
||||
@@ -1715,11 +1695,8 @@ public class JDUtil {
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("生成评论流程处理异常 - 用户: {}, 状态: {}", fromWxid, state, e);
|
||||
logger.error("生成评论流程处理异常 - 用户: {}", fromWxid, e);
|
||||
wxUtil.sendTextMessage(fromWxid, "处理异常,请重新开始", 1, fromWxid, false);
|
||||
resetState(fromWxid, state);
|
||||
} finally {
|
||||
saveState(key, state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user