超时退出

This commit is contained in:
Van0313
2025-05-02 09:24:42 +08:00
parent 3995ba4ee0
commit f3a198f977

View File

@@ -919,23 +919,42 @@ public class JDUtil {
} else if ("2".equals(message)) {
// 用户选择不开通礼金
if (cachedData != null) {
JSONObject productInfo = JSON.parseObject(cachedData);
String skuUrl = productInfo.getString("materialUrl");
String transferUrl = transfer(skuUrl, null);
String finalWenAn = cacheMap.get("finalWenAn" + wxid);
try {
JSONArray dataArray = JSON.parseArray(cachedData); // 支持多个商品
String finalWenAn = cacheMap.get("finalWenAn" + wxid);
if (finalWenAn == null) {
wxUtil.sendTextMessage(wxid, "文案内容为空,请检查缓存数据", 1, wxid, true);
return;
}
finalWenAn = (finalWenAn.replace(productInfo.getString("url"), transferUrl));
wxUtil.sendTextMessage(wxid, "不开礼金,只转链的方案:\n", 1, wxid, false);
wxUtil.sendTextMessage(wxid, finalWenAn, 1, wxid, true);
StringBuilder allTransferUrls = new StringBuilder();
for (Object obj : dataArray) {
JSONObject productInfo = (JSONObject) obj;
String skuUrl = productInfo.getString("materialUrl");
String originalUrl = productInfo.getString("url");
String transferUrl = transfer(skuUrl, null);
if (transferUrl != null) {
finalWenAn = finalWenAn.replace(originalUrl, transferUrl);
allTransferUrls.append(transferUrl).append("\n");
}
}
wxUtil.sendTextMessage(wxid, "不开礼金,只转链的方案:\n", 1, wxid, false);
wxUtil.sendTextMessage(wxid, finalWenAn, 1, wxid, true);
// 清理缓存和状态
resetState(wxid, state);
cacheMap.remove("productData" + wxid);
cacheMap.remove("finalWenAn" + wxid);
wxUtil.sendTextMessage(wxid, "已清除商品信息缓存,可输入新的文案", 1, wxid, false);
} catch (Exception e) {
logger.error("处理不开礼金转链失败 - 用户: {}", wxid, e);
wxUtil.sendTextMessage(wxid, "处理失败:" + e.getMessage(), 1, wxid, false);
resetState(wxid, state);
}
}
state.reset();
cacheMap.remove("productData" + wxid);
cacheMap.remove("finalWenAn" + wxid);
wxUtil.sendTextMessage(wxid, "已清除商品信息缓存,可输入新的文案", 1, wxid, false);
// 进入输入方案流程
state.setCurrentState(INIT);
state.setCurrentField("content");
} else {
wxUtil.sendTextMessage(wxid, "处理请求时发生异常,请重试", 1, wxid, false);