update 扫码/关注/取消关注的 文案

pull/26/head
3y 2 years ago
parent 4e17380d42
commit 5517212ab7

@ -37,9 +37,11 @@ public class OfficialAccountParamConstant {
/**
*
* //
*/
public static final String SUBSCRIBE_TIPS = "关注公众号Java3y 回复 austin 可获取项目笔记哟!";
public static final String SCAN_TIPS = "咋又扫码啦?重新关注一波吧!";
public static final String UNSUBSCRIBE_TIPS = "老乡别走!";

@ -1,8 +1,5 @@
package com.java3y.austin.web.handler;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.OfficialAccountParamConstant;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.session.WxSessionManager;
@ -10,8 +7,6 @@ import me.chanjar.weixin.mp.api.WxMpMessageHandler;
import me.chanjar.weixin.mp.api.WxMpService;
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.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.util.Map;
@ -24,11 +19,8 @@ import java.util.Map;
@Slf4j
public class ScanHandler implements WxMpMessageHandler {
@Autowired
private StringRedisTemplate redisTemplate;
/**
*
* ()
*
* @param wxMessage
* @param context
@ -38,15 +30,8 @@ public class ScanHandler implements WxMpMessageHandler {
*/
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) {
String content = DateUtil.now() + StrUtil.COLON + wxMessage.getFromUser() + StrUtil.COLON + OfficialAccountParamConstant.SCAN_HANDLER;
try {
// WxMpUser user = wxMpService.getUserService().userInfo(wxMessage.getFromUser());
// redisTemplate.opsForValue().set(wxMessage.getEventKey(), JSON.toJSONString(user), 30, TimeUnit.MINUTES);
} catch (Exception e) {
log.error("ScanHandler#handle fail:{}", Throwables.getStackTraceAsString(e));
}
return WxMpXmlOutMessage.TEXT().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
.content(content).build();
.content(OfficialAccountParamConstant.SCAN_TIPS).build();
}
}

@ -41,7 +41,8 @@ public class SubscribeHandler implements WxMpMessageHandler {
* @return
*/
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) {
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService
, WxSessionManager sessionManager) {
try {
WxMpUser user = wxMpService.getUserService().userInfo(wxMessage.getFromUser());
String eventKey = wxMessage.getEventKey().replaceAll(OfficialAccountParamConstant.QR_CODE_SCENE_PREFIX, CommonConstant.EMPTY_STRING);

@ -1,8 +1,5 @@
package com.java3y.austin.web.handler;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.google.common.base.Throwables;
import com.java3y.austin.common.constant.OfficialAccountParamConstant;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.session.WxSessionManager;
@ -10,29 +7,21 @@ import me.chanjar.weixin.mp.api.WxMpMessageHandler;
import me.chanjar.weixin.mp.api.WxMpService;
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.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* @author 3y
*/
@Component("unSubscribeHandler")
@Slf4j
public class UnSubscribeHandler implements WxMpMessageHandler {
@Autowired
private StringRedisTemplate redisTemplate;
@Override
public WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, WxMpService wxMpService, WxSessionManager sessionManager) {
String content = DateUtil.now() + StrUtil.COLON + wxMessage.getFromUser() + StrUtil.COLON + OfficialAccountParamConstant.UNSUBSCRIBE_HANDLER;
try {
// String eventKey = wxMessage.getEventKey().replaceAll(OfficialAccountParamConstant.QR_CODE_SCENE_PREFIX, CommonConstant.EMPTY_STRING);
// String userInfo = redisTemplate.opsForValue().get(eventKey);
// redisTemplate.opsForValue().set(eventKey, JSON.toJSONString(userInfo), 30, TimeUnit.DAYS);
} catch (Exception e) {
log.error("UnSubscribeHandler#handle fail:{}", Throwables.getStackTraceAsString(e));
}
return WxMpXmlOutMessage.TEXT().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser())
.content(content).build();
.content(OfficialAccountParamConstant.UNSUBSCRIBE_TIPS).build();
}
}

@ -347,7 +347,8 @@ public class Convert4Amis {
"return payload;";
CommonAmisVo service = CommonAmisVo.builder().type("service").api(CommonAmisVo.ApiDTO.builder().url("${ls:backend_url}/officialAccount/check/login?sceneId=" + id)
CommonAmisVo service = CommonAmisVo.builder().type("service")
.api(CommonAmisVo.ApiDTO.builder().url("${ls:backend_url}/officialAccount/check/login?sceneId=" + id)
.adaptor(adaptor).requestAdaptor(requestAdaptor).build()).interval(2000).silentPolling(true).build();
return CommonAmisVo.builder().type("form").title("登录").mode("horizontal").body(Arrays.asList(image, service)).build();

Loading…
Cancel
Save