This commit is contained in:
Van0313
2025-04-23 22:13:03 +08:00
parent 17e592e8ed
commit 39ea8e5859

View File

@@ -698,15 +698,23 @@ public class JDUtil {
private void handleInitState(String wxid, String message, UserInteractionState state) {
if ("".equals(message)) {
state.setCurrentState(UserInteractionState.ProcessState.PRODUCT_PROMOTION);
state.setCurrentField("content");
wxUtil.sendTextMessage(wxid, "请输入推广方案(包含商品链接", 1, wxid, false);
state.setCurrentField("content—withOutPic");
wxUtil.sendTextMessage(wxid, "请输入推广方案 \n " + "(指令: 转 不返回图文 \n 文案 带图文 ", 1, wxid, false);
logger.info("进入转链流程 - 用户: {}", wxid);
} else if ("文案".equals(message)) {
state.setCurrentState(UserInteractionState.ProcessState.PRODUCT_PROMOTION);
state.setCurrentField("content—withPic");
wxUtil.sendTextMessage(wxid, "请输入推广方案 \n " + "(指令: 转 不返回图文 \n 文案 带图文 ", 1, wxid, false);
logger.info("进入转链流程 - 用户: {}", wxid);
}
}
private void handlePromotionState(String wxid, String message, UserInteractionState state) {
if ("content".equals(state.getCurrentField())) {
processContentInput(wxid, message, state);
if ("content—withOutPic".equals(state.getCurrentField())) {
processContentInput(wxid, message, state,false);
} else if ("content—withPic".equals(state.getCurrentField())) {
processContentInput(wxid, message, state,true);
} else if ("confirm".equals(state.getCurrentField())) {
handleGiftMoneyConfirmation(wxid, message, state);
}
@@ -821,8 +829,9 @@ public class JDUtil {
* @param wxid 用户微信ID
* @param message 用户输入的方案内容
* @param state 当前交互状态
* @param b
*/
private void processContentInput(String wxid, String message, UserInteractionState state) {
private void processContentInput(String wxid, String message, UserInteractionState state, boolean withPic) {
try {
// 1. 清除旧缓存
cacheMap.remove("productData" + wxid);
@@ -831,11 +840,11 @@ public class JDUtil {
// 2. 生成推广内容
HashMap<String, List<String>> contentResult = generatePromotionContent(message, false);
if (withPic){
// 3. 发送文本内容
for (String text : contentResult.get("text")) {
wxUtil.sendTextMessage(wxid, text, 1, wxid, true);
}
// 4. 发送图片(如果有)
List<String> images = contentResult.get("images");
if (images != null) {
@@ -845,6 +854,15 @@ public class JDUtil {
}
}
}
}else {
// 3. 发送文本内容
for (String text : contentResult.get("text")) {
if (text.contains("链接类型")){
wxUtil.sendTextMessage(wxid, text, 1, wxid, true);
}
}
}
// 5. 缓存商品数据
if (!contentResult.get("data").isEmpty()) {