bug fix
This commit is contained in:
@@ -698,15 +698,23 @@ public class JDUtil {
|
|||||||
private void handleInitState(String wxid, String message, UserInteractionState state) {
|
private void handleInitState(String wxid, String message, UserInteractionState state) {
|
||||||
if ("转".equals(message)) {
|
if ("转".equals(message)) {
|
||||||
state.setCurrentState(UserInteractionState.ProcessState.PRODUCT_PROMOTION);
|
state.setCurrentState(UserInteractionState.ProcessState.PRODUCT_PROMOTION);
|
||||||
state.setCurrentField("content");
|
state.setCurrentField("content—withOutPic");
|
||||||
wxUtil.sendTextMessage(wxid, "请输入推广方案(包含商品链接):", 1, wxid, false);
|
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);
|
logger.info("进入转链流程 - 用户: {}", wxid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePromotionState(String wxid, String message, UserInteractionState state) {
|
private void handlePromotionState(String wxid, String message, UserInteractionState state) {
|
||||||
if ("content".equals(state.getCurrentField())) {
|
if ("content—withOutPic".equals(state.getCurrentField())) {
|
||||||
processContentInput(wxid, message, state);
|
processContentInput(wxid, message, state,false);
|
||||||
|
} else if ("content—withPic".equals(state.getCurrentField())) {
|
||||||
|
processContentInput(wxid, message, state,true);
|
||||||
|
|
||||||
} else if ("confirm".equals(state.getCurrentField())) {
|
} else if ("confirm".equals(state.getCurrentField())) {
|
||||||
handleGiftMoneyConfirmation(wxid, message, state);
|
handleGiftMoneyConfirmation(wxid, message, state);
|
||||||
}
|
}
|
||||||
@@ -821,8 +829,9 @@ public class JDUtil {
|
|||||||
* @param wxid 用户微信ID
|
* @param wxid 用户微信ID
|
||||||
* @param message 用户输入的方案内容
|
* @param message 用户输入的方案内容
|
||||||
* @param state 当前交互状态
|
* @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 {
|
try {
|
||||||
// 1. 清除旧缓存
|
// 1. 清除旧缓存
|
||||||
cacheMap.remove("productData" + wxid);
|
cacheMap.remove("productData" + wxid);
|
||||||
@@ -831,11 +840,11 @@ public class JDUtil {
|
|||||||
// 2. 生成推广内容
|
// 2. 生成推广内容
|
||||||
HashMap<String, List<String>> contentResult = generatePromotionContent(message, false);
|
HashMap<String, List<String>> contentResult = generatePromotionContent(message, false);
|
||||||
|
|
||||||
|
if (withPic){
|
||||||
// 3. 发送文本内容
|
// 3. 发送文本内容
|
||||||
for (String text : contentResult.get("text")) {
|
for (String text : contentResult.get("text")) {
|
||||||
wxUtil.sendTextMessage(wxid, text, 1, wxid, true);
|
wxUtil.sendTextMessage(wxid, text, 1, wxid, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 发送图片(如果有)
|
// 4. 发送图片(如果有)
|
||||||
List<String> images = contentResult.get("images");
|
List<String> images = contentResult.get("images");
|
||||||
if (images != null) {
|
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. 缓存商品数据
|
// 5. 缓存商品数据
|
||||||
if (!contentResult.get("data").isEmpty()) {
|
if (!contentResult.get("data").isEmpty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user