diff --git a/v1/src/main/java/com/v1/config/WeChatQrcodeUtils.java b/v1/src/main/java/com/v1/config/WeChatQrcodeUtils.java
index 4851ede2..7dad0633 100644
--- a/v1/src/main/java/com/v1/config/WeChatQrcodeUtils.java
+++ b/v1/src/main/java/com/v1/config/WeChatQrcodeUtils.java
@@ -1,6 +1,7 @@
package com.v1.config;
+import com.alibaba.fastjson.JSONObject;
import com.hai.model.TextMessage;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
@@ -182,5 +183,23 @@ public class WeChatQrcodeUtils {
return xml;
}
+ /**
+ * @Author Sum1Dream
+ * @Name paramPars
+ * @Description // 微信二维码参数解析
+ * @Date 13:50 2022/9/22
+ * @Param [param]
+ * @Return com.alibaba.fastjson.JSONObject
+ */
+ public JSONObject paramPars(String param) {
+ String[] paramArray = param.split("&");
+ JSONObject object = new JSONObject();
+ for (String s : paramArray) {
+ String[] array = s.split("=");
+ object.put(array[0] , array[1]);
+ }
+ return object;
+ }
+
}
diff --git a/v1/src/main/java/com/v1/controller/WxMsgController.java b/v1/src/main/java/com/v1/controller/WxMsgController.java
index 18bd1f49..9f85c429 100644
--- a/v1/src/main/java/com/v1/controller/WxMsgController.java
+++ b/v1/src/main/java/com/v1/controller/WxMsgController.java
@@ -1,5 +1,6 @@
package com.v1.controller;
+import com.alibaba.druid.sql.visitor.functions.If;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
@@ -9,6 +10,7 @@ import com.hai.common.pay.util.XmlUtil;
import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.common.utils.WxUtils;
+import com.hai.config.CommonSysConst;
import com.hai.model.HighMerchantStoreModel;
import com.hai.model.ResponseData;
import com.hai.model.TextMessage;
@@ -42,6 +44,7 @@ import java.io.BufferedOutputStream;
import java.io.StringReader;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
import java.util.SortedMap;
/**
@@ -86,7 +89,25 @@ public class WxMsgController {
String event = map.get("Event");
// 区分消息类型
String msgType = map.get("MsgType");
+ // 二维码参数
+ String eventKey = map.get("EventKey");
+ String linkContent;
+ String content = null;
+ if (eventKey != null) {
+ JSONObject object = weChatQrcodeUtils.paramPars(eventKey);
+ // type = 1 推广扫码 type = 2
+ if (Objects.equals(object.getString("qrscene_type"), "1")) {
+ linkContent = "点击注册\n\n";
+ } else {
+ // 商户门店
+ HighMerchantStoreModel store = merchantStoreService.getMerchantStoreByKey(object.getString("code"));
+ linkContent = "欢迎来到" + store.getStoreName() + "[哇][哇][哇]\n\n点击这里一键加油\n\n";
+ }
+ } else {
+ linkContent = "点击注册\n\n";
+ }
+ log.info("二维码参数:" + eventKey);
// 普通消息
if ("text".equals(msgType)) {
// todo 处理文本消息
@@ -102,33 +123,42 @@ public class WxMsgController {
// 用户关注公众号
if ("subscribe".equals(event)) {
log.info("进入扫码关注流程:" + event);
- // 商户门店
- HighMerchantStoreModel store = merchantStoreService.getMerchantStoreByKey(map.get("EventKey"));
// todo 业务处理
- String content = "欢迎来到" + store.getStoreName() + "点击这里一键加油";
-
- map.put("content" , content);
- String mapToXml = weChatQrcodeUtils.handleEventSubscribe(map);
- response.setCharacterEncoding("UTF-8");
- response.getWriter().print(mapToXml);
+ content =
+ "终于等到你,还好我没放弃[玫瑰][玫瑰][玫瑰]\n\n" +
+ "您好,感谢关注嗨森逛商城!\n\n" +
+ linkContent +
+ "在线等你来撩~[哇][哇][哇]\n\n" +
+ "特意为您奉上" +
+ "5张优惠券" +
+ ",放在您的"+
+ "卡包"+
+ "里面,记得及时使用哦[爱心][爱心][爱心]\n\n" +
+ "【如遇任何问题请致电客服:400-678-0738】"
+ ;
// todo 业务处理
}
// 用户扫码进入公众号
else if ("SCAN".equals(event)) {
- // 商户门店
- HighMerchantStoreModel store = merchantStoreService.getMerchantStoreByKey(map.get("EventKey"));
// todo 业务处理
- String content = "欢迎来到" + store.getStoreName() + "点击这里一键加油";
+ content =
+ "油价很贵,诗和远方也很贵[可怜]\n\n" +
+ "“一键加油”有”油“惠[红包][红包][红包]\n\n" +
+ linkContent +
+ "多重好礼为您助力\n\n" +
+ "加油的时候少点心疼,踩油门的时候多点豪横![得意][得意][得意]\n\n" +
+ "【如遇任何问题请致电客服:400-678-0738】"
+ ;
+
- map.put("content" , content);
- String mapToXml = weChatQrcodeUtils.handleEventSubscribe(map);
- response.setCharacterEncoding("UTF-8");
- response.getWriter().print(mapToXml);
}else if ("unsubscribe".equals(event)) {
// todo 取消关注 业务处理
}
-
+ map.put("content" , content);
+ String mapToXml = weChatQrcodeUtils.handleEventSubscribe(map);
+ response.setCharacterEncoding("UTF-8");
+ response.getWriter().print(mapToXml);
}
} catch (Exception e) {
// return null;