|
|
@@ -0,0 +1,40 @@
|
|
|
+package cn.tr.module.smart.wx.handler;
|
|
|
+
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.tr.module.smart.common.repository.BizWxUserMpCareRepository;
|
|
|
+import cn.tr.module.smart.wx.constant.WxAppletSubscribeStatusStringType;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
+import me.chanjar.weixin.common.session.WxSessionManager;
|
|
|
+import me.chanjar.weixin.mp.api.WxMpMessageHandler;
|
|
|
+import me.chanjar.weixin.mp.api.WxMpService;
|
|
|
+import me.chanjar.weixin.mp.bean.message.WxMpSubscribeMsgEvent;
|
|
|
+import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
|
|
|
+import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Component
|
|
|
+@Slf4j
|
|
|
+public class SubscribeMsgPopupEventHandler implements WxMpMessageHandler {
|
|
|
+ @Autowired
|
|
|
+ private BizWxUserMpCareRepository wxUserMpCareRepository;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) throws WxErrorException {
|
|
|
+ WxMpSubscribeMsgEvent.SubscribeMsgPopupEvent subscribeMsgPopupEvent = wxMessage.getSubscribeMsgPopupEvent();
|
|
|
+ String unionId = wxMessage.getUnionId();
|
|
|
+ for (WxMpSubscribeMsgEvent.PopupEvent popupEvent : subscribeMsgPopupEvent.getList()) {
|
|
|
+ String subscribeStatusString = popupEvent.getSubscribeStatusString();
|
|
|
+ String templateId = popupEvent.getTemplateId();
|
|
|
+ if (StrUtil.equals(subscribeStatusString, WxAppletSubscribeStatusStringType.ACCEPT)) {
|
|
|
+ log.debug("[WxMpSubscribeMsgEvent] unionId:{},templateId:{},subscribeStatusString:{}", unionId, templateId, subscribeStatusString);
|
|
|
+ }else if (StrUtil.equals(subscribeStatusString, WxAppletSubscribeStatusStringType.REJECT)) {
|
|
|
+ log.debug("[WxMpSubscribeMsgEvent] unionId:{},templateId:{},subscribeStatusString:{}", unionId, templateId, subscribeStatusString);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|