This commit is contained in:
Leo
2025-03-13 17:40:41 +08:00
parent 11b453e0d6
commit 8d003e5181

View File

@@ -36,8 +36,6 @@ import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -1215,26 +1213,26 @@ public class JDUtil {
try {
switch (state.getCurrentStep()) {
case STEP_PRODUCT_LINK:
// 解析商品链接获取SKU
String skuId = parseSkuFromUrl(message);
Map<String, String> productInfo = queryProductInfo(skuId);
state.getCollectedFields().put("skuId", skuId);
state.getCollectedFields().put("productInfo", productInfo.get("name") + "\n价格" + productInfo.get("price"));
state.setCurrentStep(STEP_AMOUNT);
wxUtil.sendTextMessage(fromWxid, "商品信息:\n" + productInfo.get("name") + "\n当前价格" + productInfo.get("price") + "\n请输入开通金额", 1, fromWxid);
break;
case STEP_AMOUNT:
if (!isValidAmount(message)) {
wxUtil.sendTextMessage(fromWxid, "金额格式错误,请重新输入", 1, fromWxid);
return;
}
state.getCollectedFields().put("amount", message);
state.setCurrentStep(STEP_QUANTITY);
wxUtil.sendTextMessage(fromWxid, "请输入开通数量:", 1, fromWxid);
break;
//case STEP_PRODUCT_LINK:
// // 解析商品链接获取SKU
// String skuId = parseSkuFromUrl(message);
// Map<String, String> productInfo = queryProductInfo(skuId);
// state.getCollectedFields().put("skuId", skuId);
// state.getCollectedFields().put("productInfo", productInfo.get("name") + "\n价格" + productInfo.get("price"));
//
// state.setCurrentStep(STEP_AMOUNT);
// wxUtil.sendTextMessage(fromWxid, "商品信息:\n" + productInfo.get("name") + "\n当前价格" + productInfo.get("price") + "\n请输入开通金额", 1, fromWxid);
// break;
//
//case STEP_AMOUNT:
// if (!isValidAmount(message)) {
// wxUtil.sendTextMessage(fromWxid, "金额格式错误,请重新输入", 1, fromWxid);
// return;
// }
// state.getCollectedFields().put("amount", message);
// state.setCurrentStep(STEP_QUANTITY);
// wxUtil.sendTextMessage(fromWxid, "请输入开通数量:", 1, fromWxid);
// break;
case STEP_QUANTITY:
if (!isValidQuantity(message)) {
@@ -1430,14 +1428,6 @@ public class JDUtil {
updateLastInteractionTime();
}
// 推荐使用枚举管理状态
public enum ProcessState {
INIT, GIFT_MONEY_FLOW, DISINFECTANT_CABINET
}
public enum GiftMoneyStep {
STEP_PRODUCT_LINK, STEP_AMOUNT, STEP_QUANTITY
}
}