基本完成转链。富贵指日可待!
This commit is contained in:
@@ -13,7 +13,7 @@ import static cn.van.business.util.JDUtil.UserInteractionState.GiftMoneyStep.STE
|
|||||||
class AmountStepHandler implements FlowStepHandler {
|
class AmountStepHandler implements FlowStepHandler {
|
||||||
public void handle(JDUtil util, String wxid, String input, JDUtil.UserInteractionState state) {
|
public void handle(JDUtil util, String wxid, String input, JDUtil.UserInteractionState state) {
|
||||||
if (!util.isValidAmount(input)) {
|
if (!util.isValidAmount(input)) {
|
||||||
util.wxUtil.sendTextMessage(wxid, "金额格式错误", 1, wxid);
|
util.wxUtil.sendTextMessage(wxid, "金额格式错误", 1, wxid,false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state.getCollectedFields().put("amount", input);
|
state.getCollectedFields().put("amount", input);
|
||||||
|
|||||||
@@ -364,7 +364,7 @@ public class JDUtil {
|
|||||||
}
|
}
|
||||||
if (!contents.isEmpty()) {
|
if (!contents.isEmpty()) {
|
||||||
for (StringBuilder stringBuilder : contents) {
|
for (StringBuilder stringBuilder : contents) {
|
||||||
wxUtil.sendTextMessage(fromWxid, stringBuilder.toString(), 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, stringBuilder.toString(), 1, fromWxid, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,13 +480,13 @@ public class JDUtil {
|
|||||||
for (String s : split) {
|
for (String s : split) {
|
||||||
content.append("https://item.jd.com/").append(s.trim()).append(".html").append("\r\n");
|
content.append("https://item.jd.com/").append(s.trim()).append(".html").append("\r\n");
|
||||||
}
|
}
|
||||||
wxUtil.sendTextMessage(fromWxid, content.toString(), 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, content.toString(), 1, fromWxid, false);
|
||||||
content = new StringBuilder();
|
content = new StringBuilder();
|
||||||
content.append("手机端").append("\r\n");
|
content.append("手机端").append("\r\n");
|
||||||
for (String s : split) {
|
for (String s : split) {
|
||||||
content.append("https://item.m.jd.com/product/").append(s.trim()).append(".html").append("\r\n");
|
content.append("https://item.m.jd.com/product/").append(s.trim()).append(".html").append("\r\n");
|
||||||
}
|
}
|
||||||
wxUtil.sendTextMessage(fromWxid, content.toString(), 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, content.toString(), 1, fromWxid, false);
|
||||||
content = new StringBuilder();
|
content = new StringBuilder();
|
||||||
contents.add(content);
|
contents.add(content);
|
||||||
|
|
||||||
@@ -517,7 +517,7 @@ public class JDUtil {
|
|||||||
}
|
}
|
||||||
if (!contents.isEmpty()) {
|
if (!contents.isEmpty()) {
|
||||||
for (StringBuilder stringBuilder : contents) {
|
for (StringBuilder stringBuilder : contents) {
|
||||||
wxUtil.sendTextMessage(fromWxid, stringBuilder.toString(), 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, stringBuilder.toString(), 1, fromWxid, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -672,12 +672,12 @@ public class JDUtil {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
resetState(fromWxid, state);
|
resetState(fromWxid, state);
|
||||||
wxUtil.sendTextMessage(fromWxid, "流程异常,请重新开始", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "流程异常,请重新开始", 1, fromWxid, false);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("流程处理异常 - 用户: {}, 状态: {}", fromWxid, state, e);
|
logger.error("流程处理异常 - 用户: {}, 状态: {}", fromWxid, state, e);
|
||||||
resetState(fromWxid, state);
|
resetState(fromWxid, state);
|
||||||
wxUtil.sendTextMessage(fromWxid, "处理异常,请重新开始", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "处理异常,请重新开始", 1, fromWxid, false);
|
||||||
} finally {
|
} finally {
|
||||||
saveState(key, state);
|
saveState(key, state);
|
||||||
}
|
}
|
||||||
@@ -709,7 +709,7 @@ public class JDUtil {
|
|||||||
if ("转".equals(message)) {
|
if ("转".equals(message)) {
|
||||||
state.setCurrentState(UserInteractionState.ProcessState.PRODUCT_PROMOTION);
|
state.setCurrentState(UserInteractionState.ProcessState.PRODUCT_PROMOTION);
|
||||||
state.setCurrentField("content");
|
state.setCurrentField("content");
|
||||||
wxUtil.sendTextMessage(wxid, "请输入推广方案(包含商品链接):", 1, wxid);
|
wxUtil.sendTextMessage(wxid, "请输入推广方案(包含商品链接):", 1, wxid, false);
|
||||||
logger.info("进入转链流程 - 用户: {}", wxid);
|
logger.info("进入转链流程 - 用户: {}", wxid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -724,7 +724,7 @@ public class JDUtil {
|
|||||||
|
|
||||||
private void handleGiftMoneyFlow(String wxid, String message, UserInteractionState state) {
|
private void handleGiftMoneyFlow(String wxid, String message, UserInteractionState state) {
|
||||||
if (!state.validateStep(state.getCurrentStep())) {
|
if (!state.validateStep(state.getCurrentStep())) {
|
||||||
wxUtil.sendTextMessage(wxid, "流程顺序异常,请重新开始", 1, wxid);
|
wxUtil.sendTextMessage(wxid, "流程顺序异常,请重新开始", 1, wxid, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -739,30 +739,30 @@ public class JDUtil {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
state.setCurrentStep(STEP_AMOUNT);
|
state.setCurrentStep(STEP_AMOUNT);
|
||||||
wxUtil.sendTextMessage(wxid, "请输入金额(1-50元):", 1, wxid);
|
wxUtil.sendTextMessage(wxid, "请输入金额(1-50元):", 1, wxid, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processAmountInput(String wxid, String message, UserInteractionState state) {
|
private void processAmountInput(String wxid, String message, UserInteractionState state) {
|
||||||
if (!isValidAmount(message)) {
|
if (!isValidAmount(message)) {
|
||||||
wxUtil.sendTextMessage(wxid, "金额格式错误,请输入1-50元", 1, wxid);
|
wxUtil.sendTextMessage(wxid, "金额格式错误,请输入1-50元", 1, wxid, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
state.getCollectedFields().put("amount", message);
|
state.getCollectedFields().put("amount", message);
|
||||||
state.setCurrentStep(STEP_QUANTITY);
|
state.setCurrentStep(STEP_QUANTITY);
|
||||||
wxUtil.sendTextMessage(wxid, "请输入数量(1-100):", 1, wxid);
|
wxUtil.sendTextMessage(wxid, "请输入数量(1-100):", 1, wxid, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processQuantityInput(String wxid, String message, UserInteractionState state) {
|
private void processQuantityInput(String wxid, String message, UserInteractionState state) {
|
||||||
if (!isValidQuantity(message)) {
|
if (!isValidQuantity(message)) {
|
||||||
wxUtil.sendTextMessage(wxid, "数量格式错误,请输入1-100的整数", 1, wxid);
|
wxUtil.sendTextMessage(wxid, "数量格式错误,请输入1-100的整数", 1, wxid, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String cachedData = cacheMap.get("productData" + wxid);
|
String cachedData = cacheMap.get("productData" + wxid);
|
||||||
String finalWenAn = cacheMap.get("finalWenAn" + wxid);
|
String finalWenAn = cacheMap.get("finalWenAn" + wxid);
|
||||||
if (cachedData == null) {
|
if (cachedData == null) {
|
||||||
wxUtil.sendTextMessage(wxid, "数据丢失,请重新开始流程", 1, wxid);
|
wxUtil.sendTextMessage(wxid, "数据丢失,请重新开始流程", 1, wxid, false);
|
||||||
resetState(wxid, state);
|
resetState(wxid, state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -777,7 +777,7 @@ public class JDUtil {
|
|||||||
|
|
||||||
String giftKey = createGiftCoupon(skuId, amount, quantity, owner, skuName);
|
String giftKey = createGiftCoupon(skuId, amount, quantity, owner, skuName);
|
||||||
if (giftKey == null) {
|
if (giftKey == null) {
|
||||||
wxUtil.sendTextMessage(wxid, "礼金创建失败,请重试", 1, wxid);
|
wxUtil.sendTextMessage(wxid, "礼金创建失败,请重试", 1, wxid, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 记录成功日志
|
// 记录成功日志
|
||||||
@@ -785,15 +785,15 @@ public class JDUtil {
|
|||||||
wxid, skuId, amount, quantity);
|
wxid, skuId, amount, quantity);
|
||||||
// 生成转链
|
// 生成转链
|
||||||
String transferUrl = transfer(skuId, giftKey);
|
String transferUrl = transfer(skuId, giftKey);
|
||||||
wxUtil.sendTextMessage(wxid, "附带礼金的链接:\n" + transferUrl, 1, wxid);
|
wxUtil.sendTextMessage(wxid, "附带礼金的链接:\n" + transferUrl, 1, wxid, false);
|
||||||
wxUtil.sendTextMessage(wxid, "附带礼金的方案:\n", 1, wxid);
|
wxUtil.sendTextMessage(wxid, "附带礼金的方案:\n", 1, wxid, false);
|
||||||
|
|
||||||
wxUtil.sendTextMessage(wxid, finalWenAn.replaceAll(jsonObject.getString("url"), transferUrl), 1, wxid);
|
wxUtil.sendTextMessage(wxid, finalWenAn.replaceAll(jsonObject.getString("url"), transferUrl), 1, wxid, false);
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("礼金处理异常 - 用户: {}", wxid, e);
|
logger.error("礼金处理异常 - 用户: {}", wxid, e);
|
||||||
wxUtil.sendTextMessage(wxid, "处理异常,请重试", 1, wxid);
|
wxUtil.sendTextMessage(wxid, "处理异常,请重试", 1, wxid, false);
|
||||||
} finally {
|
} finally {
|
||||||
resetState(wxid, state);
|
resetState(wxid, state);
|
||||||
cacheMap.remove("text" + wxid);
|
cacheMap.remove("text" + wxid);
|
||||||
@@ -820,7 +820,7 @@ public class JDUtil {
|
|||||||
|
|
||||||
// 3. 发送文本内容
|
// 3. 发送文本内容
|
||||||
for (String text : contentResult.get("text")) {
|
for (String text : contentResult.get("text")) {
|
||||||
wxUtil.sendTextMessage(wxid, text, 1, wxid);
|
wxUtil.sendTextMessage(wxid, text, 1, wxid, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 发送图片(如果有)
|
// 4. 发送图片(如果有)
|
||||||
@@ -853,14 +853,14 @@ public class JDUtil {
|
|||||||
}
|
}
|
||||||
wxUtil.sendTextMessage(wxid,
|
wxUtil.sendTextMessage(wxid,
|
||||||
"是否需要开通礼金?\n回复 1 - 是\n回复 2 - 否",
|
"是否需要开通礼金?\n回复 1 - 是\n回复 2 - 否",
|
||||||
1, wxid);
|
1, wxid, false);
|
||||||
} else {
|
} else {
|
||||||
wxUtil.sendTextMessage(wxid, "未获取到商品数据,请检查链接格式", 1, wxid);
|
wxUtil.sendTextMessage(wxid, "未获取到商品数据,请检查链接格式", 1, wxid, false);
|
||||||
state.reset();
|
state.reset();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("处理推广内容异常 - 用户: {}", wxid, e);
|
logger.error("处理推广内容异常 - 用户: {}", wxid, e);
|
||||||
wxUtil.sendTextMessage(wxid, "处理内容时发生异常,请重试", 1, wxid);
|
wxUtil.sendTextMessage(wxid, "处理内容时发生异常,请重试", 1, wxid, false);
|
||||||
state.reset();
|
state.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -883,7 +883,7 @@ public class JDUtil {
|
|||||||
wxUtil.sendTextMessage(wxid,
|
wxUtil.sendTextMessage(wxid,
|
||||||
"请输入开通金额(1-50元,支持小数点后两位):\n" +
|
"请输入开通金额(1-50元,支持小数点后两位):\n" +
|
||||||
"示例:20.50",
|
"示例:20.50",
|
||||||
1, wxid);
|
1, wxid, false);
|
||||||
|
|
||||||
} else if ("2".equals(message)) {
|
} else if ("2".equals(message)) {
|
||||||
// 用户选择不开通礼金
|
// 用户选择不开通礼金
|
||||||
@@ -897,12 +897,12 @@ public class JDUtil {
|
|||||||
finalWenAn = (finalWenAn.replace(productInfo.getString("url"), transferUrl));
|
finalWenAn = (finalWenAn.replace(productInfo.getString("url"), transferUrl));
|
||||||
wxUtil.sendTextMessage(wxid,
|
wxUtil.sendTextMessage(wxid,
|
||||||
"不开礼金,只转链的方案:\n",
|
"不开礼金,只转链的方案:\n",
|
||||||
1, wxid);
|
1, wxid, false);
|
||||||
wxUtil.sendTextMessage(wxid,
|
wxUtil.sendTextMessage(wxid,
|
||||||
finalWenAn,
|
finalWenAn,
|
||||||
1, wxid);
|
1, wxid, false);
|
||||||
} else {
|
} else {
|
||||||
wxUtil.sendTextMessage(wxid, "未找到商品信息,请重新开始流程", 1, wxid);
|
wxUtil.sendTextMessage(wxid, "未找到商品信息,请重新开始流程", 1, wxid, false);
|
||||||
}
|
}
|
||||||
state.reset();
|
state.reset();
|
||||||
cacheMap.remove("productData" + wxid);
|
cacheMap.remove("productData" + wxid);
|
||||||
@@ -915,11 +915,11 @@ public class JDUtil {
|
|||||||
"请输入有效选项:\n" +
|
"请输入有效选项:\n" +
|
||||||
"回复 1 - 开通礼金\n" +
|
"回复 1 - 开通礼金\n" +
|
||||||
"回复 2 - 直接转链",
|
"回复 2 - 直接转链",
|
||||||
1, wxid);
|
1, wxid, false);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("处理礼金确认异常 - 用户: {}", wxid, e);
|
logger.error("处理礼金确认异常 - 用户: {}", wxid, e);
|
||||||
wxUtil.sendTextMessage(wxid, "处理请求时发生异常,请重试", 1, wxid);
|
wxUtil.sendTextMessage(wxid, "处理请求时发生异常,请重试", 1, wxid, false);
|
||||||
state.reset();
|
state.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -934,7 +934,7 @@ public class JDUtil {
|
|||||||
private void sendStepPrompt(String wxid, int step, int totalSteps) {
|
private void sendStepPrompt(String wxid, int step, int totalSteps) {
|
||||||
String progress = String.format("[%d/%d] ", step, totalSteps);
|
String progress = String.format("[%d/%d] ", step, totalSteps);
|
||||||
String message = progress + "请输入礼金金额(示例:20.50)";
|
String message = progress + "请输入礼金金额(示例:20.50)";
|
||||||
wxUtil.sendTextMessage(wxid, message, 1, wxid);
|
wxUtil.sendTextMessage(wxid, message, 1, wxid, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createPromotionWithGift(String fromWxid, String message) {
|
private void createPromotionWithGift(String fromWxid, String message) {
|
||||||
@@ -943,13 +943,13 @@ public class JDUtil {
|
|||||||
// 修改createPromotionWithGift方法中的校验逻辑
|
// 修改createPromotionWithGift方法中的校验逻辑
|
||||||
if (!state.validateStep(STEP_CONFIRM_GIFT)) {
|
if (!state.validateStep(STEP_CONFIRM_GIFT)) {
|
||||||
logger.warn("状态校验失败,预期步骤:{} 实际步骤:{}", STEP_CONFIRM_GIFT, state.getCurrentStep());
|
logger.warn("状态校验失败,预期步骤:{} 实际步骤:{}", STEP_CONFIRM_GIFT, state.getCurrentStep());
|
||||||
wxUtil.sendTextMessage(fromWxid, "流程顺序异常,请重新开始", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "流程顺序异常,请重新开始", 1, fromWxid, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 修改点3:在createPromotionWithGift方法开始处增加状态校验
|
// 修改点3:在createPromotionWithGift方法开始处增加状态校验
|
||||||
if (state == null || state.getCurrentStep() == null) {
|
if (state == null || state.getCurrentStep() == null) {
|
||||||
logger.warn("非法状态访问: {}", fromWxid);
|
logger.warn("非法状态访问: {}", fromWxid);
|
||||||
wxUtil.sendTextMessage(fromWxid, "⚠️ 会话超时,请重新开始流程", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "⚠️ 会话超时,请重新开始流程", 1, fromWxid, false);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
@@ -969,7 +969,7 @@ public class JDUtil {
|
|||||||
case STEP_CONFIRM_GIFT:
|
case STEP_CONFIRM_GIFT:
|
||||||
if ("1".equals(message)) {
|
if ("1".equals(message)) {
|
||||||
state.setCurrentStep(STEP_AMOUNT);
|
state.setCurrentStep(STEP_AMOUNT);
|
||||||
wxUtil.sendTextMessage(fromWxid, "请输入开通金额(元):", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "请输入开通金额(元):", 1, fromWxid, false);
|
||||||
} else if ("2".equals(message)) {
|
} else if ("2".equals(message)) {
|
||||||
// 不开通礼金,直接生成转链
|
// 不开通礼金,直接生成转链
|
||||||
String cachedData = cacheMap.get("productData" + fromWxid);
|
String cachedData = cacheMap.get("productData" + fromWxid);
|
||||||
@@ -977,25 +977,25 @@ public class JDUtil {
|
|||||||
JSONObject jsonObject = JSONObject.parseObject(cachedData);
|
JSONObject jsonObject = JSONObject.parseObject(cachedData);
|
||||||
String skuId = jsonObject.getString("materialUrl");
|
String skuId = jsonObject.getString("materialUrl");
|
||||||
String transferUrl = transfer(skuId, null);
|
String transferUrl = transfer(skuId, null);
|
||||||
wxUtil.sendTextMessage(fromWxid, "转链后的链接:\n" + transferUrl, 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "转链后的链接:\n" + transferUrl, 1, fromWxid, false);
|
||||||
} else {
|
} else {
|
||||||
wxUtil.sendTextMessage(fromWxid, "未找到缓存的商品链接,请重新开始流程", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "未找到缓存的商品链接,请重新开始流程", 1, fromWxid, false);
|
||||||
}
|
}
|
||||||
state.reset();
|
state.reset();
|
||||||
userInteractionStates.put(key, state); // 在外部保存
|
userInteractionStates.put(key, state); // 在外部保存
|
||||||
} else {
|
} else {
|
||||||
wxUtil.sendTextMessage(fromWxid, "无效的选择,请重新输入:\n回复 1 - 是\n回复 2 - 否", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "无效的选择,请重新输入:\n回复 1 - 是\n回复 2 - 否", 1, fromWxid, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STEP_AMOUNT:
|
case STEP_AMOUNT:
|
||||||
logger.debug("用户 {} 输入金额:{}", fromWxid, message);
|
logger.debug("用户 {} 输入金额:{}", fromWxid, message);
|
||||||
if (message == null || message.trim().isEmpty()) {
|
if (message == null || message.trim().isEmpty()) {
|
||||||
wxUtil.sendTextMessage(fromWxid, "金额不能为空,请输入数字(如:100.00)", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "金额不能为空,请输入数字(如:100.00)", 1, fromWxid, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!isValidAmount(message)) {
|
if (!isValidAmount(message)) {
|
||||||
wxUtil.sendTextMessage(fromWxid, "金额格式错误,请输入数字(如:100.00)", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "金额格式错误,请输入数字(如:100.00)", 1, fromWxid, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
double amount = Double.parseDouble(message);
|
double amount = Double.parseDouble(message);
|
||||||
@@ -1003,27 +1003,27 @@ public class JDUtil {
|
|||||||
state.getCollectedFields().put("amount", formattedAmount);
|
state.getCollectedFields().put("amount", formattedAmount);
|
||||||
state.setCurrentStep(STEP_QUANTITY);
|
state.setCurrentStep(STEP_QUANTITY);
|
||||||
userInteractionStates.put(key, state); // ▼▼▼ 保存点2 ▼▼▼
|
userInteractionStates.put(key, state); // ▼▼▼ 保存点2 ▼▼▼
|
||||||
wxUtil.sendTextMessage(fromWxid, "请输入数量(1-100):", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "请输入数量(1-100):", 1, fromWxid, false);
|
||||||
sendStepPrompt(fromWxid, 1, 3);
|
sendStepPrompt(fromWxid, 1, 3);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STEP_QUANTITY:
|
case STEP_QUANTITY:
|
||||||
logger.debug("用户 {} 输入数量:{}", fromWxid, message); // 新增
|
logger.debug("用户 {} 输入数量:{}", fromWxid, message); // 新增
|
||||||
if (!isValidQuantity(message)) {
|
if (!isValidQuantity(message)) {
|
||||||
wxUtil.sendTextMessage(fromWxid, "数量格式错误,请输入整数", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "数量格式错误,请输入整数", 1, fromWxid, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int quantity = Integer.parseInt(message);
|
int quantity = Integer.parseInt(message);
|
||||||
if (quantity < 1 || quantity > 100) {
|
if (quantity < 1 || quantity > 100) {
|
||||||
wxUtil.sendTextMessage(fromWxid, "数量需在1-100之间", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "数量需在1-100之间", 1, fromWxid, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从缓存中获取 amount
|
// 从缓存中获取 amount
|
||||||
String amountStr = state.getCollectedFields().get("amount");
|
String amountStr = state.getCollectedFields().get("amount");
|
||||||
if (amountStr == null || amountStr.trim().isEmpty()) {
|
if (amountStr == null || amountStr.trim().isEmpty()) {
|
||||||
wxUtil.sendTextMessage(fromWxid, "未找到金额,请重新开始流程", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "未找到金额,请重新开始流程", 1, fromWxid, false);
|
||||||
state.reset();
|
state.reset();
|
||||||
userInteractionStates.put(key, state); // 在外部保存
|
userInteractionStates.put(key, state); // 在外部保存
|
||||||
return;
|
return;
|
||||||
@@ -1043,7 +1043,7 @@ public class JDUtil {
|
|||||||
String giftKey = createGiftCoupon(skuId, amount, quantity, owner, skuName);
|
String giftKey = createGiftCoupon(skuId, amount, quantity, owner, skuName);
|
||||||
if (giftKey == null) {
|
if (giftKey == null) {
|
||||||
logger.error("用户 {} 礼金创建失败:SKU={}, 金额={}元,数量={}", fromWxid, skuId, amount, quantity); // 新增
|
logger.error("用户 {} 礼金创建失败:SKU={}, 金额={}元,数量={}", fromWxid, skuId, amount, quantity); // 新增
|
||||||
wxUtil.sendTextMessage(fromWxid, "❌ 礼金创建失败,请检查商品是否符合要求", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "❌ 礼金创建失败,请检查商品是否符合要求", 1, fromWxid, false);
|
||||||
state.reset();
|
state.reset();
|
||||||
userInteractionStates.put(key, state); // 在外部保存
|
userInteractionStates.put(key, state); // 在外部保存
|
||||||
|
|
||||||
@@ -1055,13 +1055,13 @@ public class JDUtil {
|
|||||||
|
|
||||||
// 生成转链
|
// 生成转链
|
||||||
String transferUrl = transfer(skuId, giftKey);
|
String transferUrl = transfer(skuId, giftKey);
|
||||||
wxUtil.sendTextMessage(fromWxid, "附带礼金的链接:\n" + transferUrl, 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "附带礼金的链接:\n" + transferUrl, 1, fromWxid, false);
|
||||||
|
|
||||||
wxUtil.sendTextMessage(fromWxid, "附带礼金的方案:\n" + finalWenAn.replaceAll(jsonObject.getString("url"), transferUrl), 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "附带礼金的方案:\n" + finalWenAn.replaceAll(jsonObject.getString("url"), transferUrl), 1, fromWxid, false);
|
||||||
state.reset();
|
state.reset();
|
||||||
userInteractionStates.put(key, state); // 在外部保存
|
userInteractionStates.put(key, state); // 在外部保存
|
||||||
} else {
|
} else {
|
||||||
wxUtil.sendTextMessage(fromWxid, "未找到缓存的商品链接,请重新开始流程", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "未找到缓存的商品链接,请重新开始流程", 1, fromWxid, false);
|
||||||
state.reset();
|
state.reset();
|
||||||
userInteractionStates.put(key, state); // 在外部保存
|
userInteractionStates.put(key, state); // 在外部保存
|
||||||
}
|
}
|
||||||
@@ -1069,12 +1069,12 @@ public class JDUtil {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
state.setCurrentStep(STEP_CONFIRM_GIFT);
|
state.setCurrentStep(STEP_CONFIRM_GIFT);
|
||||||
wxUtil.sendTextMessage(fromWxid, "是否需要开通礼金?\n回复 1 - 是\n回复 2 - 否", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "是否需要开通礼金?\n回复 1 - 是\n回复 2 - 否", 1, fromWxid, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("转链和礼金流程异常,用户 {} 当前步骤:{}", fromWxid, state.getCurrentStep(), e);
|
logger.error("转链和礼金流程异常,用户 {} 当前步骤:{}", fromWxid, state.getCurrentStep(), e);
|
||||||
wxUtil.sendTextMessage(fromWxid, "❌ 系统异常,请稍后重试", 1, fromWxid);
|
wxUtil.sendTextMessage(fromWxid, "❌ 系统异常,请稍后重试", 1, fromWxid, false);
|
||||||
state.reset();
|
state.reset();
|
||||||
userInteractionStates.put(key, state); // 在外部保存
|
userInteractionStates.put(key, state); // 在外部保存
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class OrderUtil {
|
|||||||
String content = getFormattedOrderInfo(orderRow, lastValidCode);
|
String content = getFormattedOrderInfo(orderRow, lastValidCode);
|
||||||
String wxId = getWxidFromJdid(orderRow.getUnionId().toString());
|
String wxId = getWxidFromJdid(orderRow.getUnionId().toString());
|
||||||
if (Util.isNotEmpty(wxId)) {
|
if (Util.isNotEmpty(wxId)) {
|
||||||
wxUtil.sendTextMessage(wxId, content, 1, wxId);
|
wxUtil.sendTextMessage(wxId, content, 1, wxId, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ public class OrderUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
if (Util.isNotEmpty(wxId)) {
|
if (Util.isNotEmpty(wxId)) {
|
||||||
wxUtil.sendTextMessage(wxId, content.toString(), 1, wxId);
|
wxUtil.sendTextMessage(wxId, content.toString(), 1, wxId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class WXUtil {
|
|||||||
jdidToWxidMap.put(admin2.getUnionId(), admin2.getWxid());
|
jdidToWxidMap.put(admin2.getUnionId(), admin2.getWxid());
|
||||||
//wxTsUtil.sendNotify("initSuperAdmins 初始化完成");
|
//wxTsUtil.sendNotify("initSuperAdmins 初始化完成");
|
||||||
//发送通知到微信
|
//发送通知到微信
|
||||||
sendTextMessage(default_super_admin_wxid, "Jarvis 重启完成 [亲亲][亲亲][亲亲] ", 1, default_super_admin_wxid);
|
sendTextMessage(default_super_admin_wxid, "Jarvis 重启完成 [亲亲][亲亲][亲亲] ", 1, default_super_admin_wxid, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,8 +123,7 @@ public class WXUtil {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送文本消息 msgType 1:私聊 2:群发
|
public void sendTextMessage(String wxid, String content, Integer msgType, String fromwxid, Boolean hiddenTime) {
|
||||||
public void sendTextMessage(String wxid, String content, Integer msgType, String fromwxid) {
|
|
||||||
// 全部打印
|
// 全部打印
|
||||||
//logger.info("发送文本消息 msgType: {} wxid: {} fromwxid: {} content: {}", msgType, wxid, fromwxid, content);
|
//logger.info("发送文本消息 msgType: {} wxid: {} fromwxid: {} content: {}", msgType, wxid, fromwxid, content);
|
||||||
// 先在content顶部插入时间戳
|
// 先在content顶部插入时间戳
|
||||||
|
|||||||
Reference in New Issue
Block a user