@Override public Message clickEvent(Message message, IWxApi wxApi) { String opendid = message.getFromUserName(); Message result = new Message(); result.setFromUserName(message.getToUserName()); result.setToUserName(message.getFromUserName()); result.setCreateTime(System.currentTimeMillis()); result.setMsgType(MsgType.text); String content; if (CLICK_LOGIN_BIND.equals(message.getEventKey())) { // 免登陆功能按钮key // 免登陆功能按钮 Map<String, String> paramsMap = new HashMap<>(); paramsMap.put("openId", opendid); FenlibaoApi<AutoLogin> fenlibaoApi = this.httpsPost( this.connectionSettings.getServerBind(), paramsMap, new TypeReference<FenlibaoApi<AutoLogin>>() {}); if (fenlibaoApi == null || fenlibaoApi.getData() != null && fenlibaoApi.getData().getWeixinStatus() != WeixinStatus.BINDED) { // 绑定提示 content = this.robotMsgByKeyword("开启免登录", message.getFromUserName()); } else { content = this.robotMsgByKeyword("取消免登录", message.getFromUserName()); } } else if (CLICK_WEIXIN_CUSTOMER.equals(message.getEventKey())) { // 微信客服 int dayOfWeek = this.getDayOfWeek(); if (dayOfWeek > 1 && dayOfWeek < 7) { content = this.robotMsgByKeyword("工作日客服消息", message.getFromUserName()); } else { content = this.robotMsgByKeyword("休息日客服消息", message.getFromUserName()); } } else { content = this.robotMsgByKeyword(message.getEventKey(), message.getFromUserName()); } if (content != null) { result.setContent(content); return result; } else { return null; } }
/** * 序列化关注渠道 * * @param message */ private String serializeSubscribe(Message message) { String eventKey = message.getEventKey(); String openId = message.getFromUserName(); if (eventKey != null && eventKey.startsWith("qrscene_")) { eventKey = eventKey.substring("qrscene_".length()); } else if (eventKey == null || eventKey.equals("")) { eventKey = DEFAULT_EVENT_KEY; } this.subscribeService.save(new Subscribe(openId, eventKey)); return eventKey; }