Sfoglia il codice sorgente

校验是否 绑定业主

java110 6 anni fa
parent
commit
78db1ec263

+ 52 - 24
java110-utils/src/main/java/com/java110/utils/cache/MappingCache.java

@@ -1,8 +1,8 @@
 package com.java110.utils.cache;
 
+import com.java110.entity.mapping.Mapping;
 import com.java110.utils.constant.DomainContant;
 import com.java110.utils.util.SerializeUtil;
-import com.java110.entity.mapping.Mapping;
 import redis.clients.jedis.Jedis;
 
 import java.util.List;
@@ -18,23 +18,24 @@ public class MappingCache extends BaseCache {
 
     /**
      * 获取值
+     *
      * @param domain
      * @param key
      * @return
      */
-    public static String getValue(String domain,String key){
+    public static String getValue(String domain, String key) {
         Jedis redis = null;
         try {
             redis = getJedis();
-            Object object = SerializeUtil.unserialize(redis.get((domain + key+_SUFFIX_MAPPING).getBytes()));
+            Object object = SerializeUtil.unserialize(redis.get((domain + key + _SUFFIX_MAPPING).getBytes()));
             if (object == null) {
                 return null;
             }
 
             Mapping mapping = (Mapping) object;
             return mapping.getValue();
-        }finally {
-            if(redis != null){
+        } finally {
+            if (redis != null) {
                 redis.close();
             }
         }
@@ -42,24 +43,25 @@ public class MappingCache extends BaseCache {
 
     /**
      * 获取公用域下的key值
+     *
      * @param key
      * @return
      */
-    public static String getValue(String key){
+    public static String getValue(String key) {
         Mapping mapping = getMapping(key);
-        return mapping == null ? "":mapping.getValue();
+        return mapping == null ? "" : mapping.getValue();
     }
 
-    public static Mapping getMapping(String key){
+    public static Mapping getMapping(String key) {
         Jedis redis = null;
         try {
             redis = getJedis();
-            Object obj = SerializeUtil.unserialize(redis.get((DomainContant.COMMON_DOMAIN+key+_SUFFIX_MAPPING).getBytes()));
-            if(obj instanceof Mapping){
+            Object obj = SerializeUtil.unserialize(redis.get((DomainContant.COMMON_DOMAIN + key + _SUFFIX_MAPPING).getBytes()));
+            if (obj instanceof Mapping) {
                 return (Mapping) obj;
             }
-        }finally {
-            if(redis != null){
+        } finally {
+            if (redis != null) {
                 redis.close();
             }
         }
@@ -68,16 +70,17 @@ public class MappingCache extends BaseCache {
 
     /**
      * 获取 域下的所有数据
+     *
      * @param domain
      * @return
      */
-    public static List<Mapping> getValueByDomain(String domain){
+    public static List<Mapping> getValueByDomain(String domain) {
         Jedis redis = null;
         try {
             redis = getJedis();
-            return SerializeUtil.unserializeList(redis.get((domain+_SUFFIX_MAPPING).getBytes()),Mapping.class);
-        }finally {
-            if(redis != null){
+            return SerializeUtil.unserializeList(redis.get((domain + _SUFFIX_MAPPING).getBytes()), Mapping.class);
+        } finally {
+            if (redis != null) {
                 redis.close();
             }
         }
@@ -85,15 +88,16 @@ public class MappingCache extends BaseCache {
 
     /**
      * 保存数据
+     *
      * @param mapping
      */
-    public static void setVaule(Mapping mapping){
+    public static void setVaule(Mapping mapping) {
         Jedis redis = null;
         try {
             redis = getJedis();
-            redis.set((mapping.getDomain()+mapping.getKey()+_SUFFIX_MAPPING).getBytes(),SerializeUtil.serialize(mapping));
-        }finally {
-            if(redis != null){
+            redis.set((mapping.getDomain() + mapping.getKey() + _SUFFIX_MAPPING).getBytes(), SerializeUtil.serialize(mapping));
+        } finally {
+            if (redis != null) {
                 redis.close();
             }
         }
@@ -101,21 +105,45 @@ public class MappingCache extends BaseCache {
 
     /**
      * 保存list 数据
+     *
      * @param mappings
      */
-    public static void setValue(List<Mapping> mappings){
+    public static void setValue(List<Mapping> mappings) {
         Jedis redis = null;
         try {
             redis = getJedis();
-            redis.set((mappings.get(0).getDomain()+_SUFFIX_MAPPING).getBytes(),SerializeUtil.serializeList(mappings));
-        }finally {
-            if(redis != null){
+            redis.set((mappings.get(0).getDomain() + _SUFFIX_MAPPING).getBytes(), SerializeUtil.serializeList(mappings));
+        } finally {
+            if (redis != null) {
                 redis.close();
             }
         }
     }
 
+    /**
+     * 获取值
+     *
+     * @param domain
+     * @param key
+     * @return
+     */
+    public static String getRemark(String domain, String key) {
+        Jedis redis = null;
+        try {
+            redis = getJedis();
+            Object object = SerializeUtil.unserialize(redis.get((domain + key + _SUFFIX_MAPPING).getBytes()));
+            if (object == null) {
+                return null;
+            }
 
+            Mapping mapping = (Mapping) object;
+            return mapping.getRemark();
+        } finally {
+            if (redis != null) {
+                redis.close();
+            }
+        }
+    }
 
 
 }

+ 10 - 1
java110-utils/src/main/java/com/java110/utils/constant/WechatConstant.java

@@ -10,7 +10,15 @@ package com.java110.utils.constant;
  **/
 public class WechatConstant {
 
-    public static final String TOKEN = "java110";
+    //微信域
+    public static final String WECHAT_DOMAIN = "WECHAT";
+
+    public static final String TOKEN = "TOKEN";
+    public static final String WELCOME = "WELCOME";
+    public static final String DEFAULT_WELCOME = "HC小区物业管理系统是由java110团队于2017年4月份发起的前后端分离、分布式架构开源项目,目前我们的代码开源在github 和gitee上,开源项目由HC小区管理系统后端,HC小区管理系统前端,HC小区管理系统业主手机版和HC小区管理系统物业手机版,业务技术交流群:827669685";
+
+    public static final String NO_BIND_OWNER_RESPONSE_MESSAGE = "亲,您还没有绑定业主请先<a href=\"https://owner.demo.winqi.cn/#/pages/login/login\">绑定</a>";
+
 
     public static final String MSG_TYPE_TEXT = "text";
     public static final String MSG_TYPE_LOCATION = "location";
@@ -21,4 +29,5 @@ public class WechatConstant {
     public static final String MSG_REGX_TYPE_PART = "0";
     public static final String MSG_REGX_TYPE_ALL = "1";
     public static final String MSG_MENU_ID = "menu";
+
 }

+ 43 - 172
service-front/src/main/java/com/java110/front/controller/WechatGatewayController.java

@@ -1,9 +1,13 @@
 package com.java110.front.controller;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.java110.core.base.controller.BaseController;
+import com.java110.core.context.IPageData;
+import com.java110.core.context.PageData;
 import com.java110.core.factory.AuthenticationFactory;
-import com.java110.core.factory.WechatFactory;
+import com.java110.front.smo.wechatGateway.IWechatGatewaySMO;
+import com.java110.utils.cache.MappingCache;
 import com.java110.utils.constant.WechatConstant;
 import com.java110.utils.util.StringUtil;
 import org.dom4j.Document;
@@ -11,6 +15,7 @@ import org.dom4j.DocumentHelper;
 import org.dom4j.Element;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -18,11 +23,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.servlet.ServletInputStream;
 import javax.servlet.http.HttpServletRequest;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
 import java.util.Arrays;
 
 /**
@@ -39,6 +40,9 @@ public class WechatGatewayController extends BaseController {
 
     private final static Logger logger = LoggerFactory.getLogger(WechatGatewayController.class);
 
+    @Autowired
+    private IWechatGatewaySMO wechatGatewaySMOImpl;
+
 
     /**
      * 微信登录接口
@@ -48,7 +52,7 @@ public class WechatGatewayController extends BaseController {
     @RequestMapping(path = "/gateway", method = RequestMethod.GET)
     public ResponseEntity<String> gateway(HttpServletRequest request) {
 
-        String token = WechatConstant.TOKEN;
+        String token = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.TOKEN);
         String signature = request.getParameter("signature");
         String timestamp = request.getParameter("timestamp");
         String nonce = request.getParameter("nonce");
@@ -66,47 +70,7 @@ public class WechatGatewayController extends BaseController {
         logger.debug("sourceString = " + sourceString + "||||" + "signature1 = " + signature1);
         try {
             if (signature1.equals(signature)) {
-                if (echostr == null) {
-                    String postStr = this.readStreamParameter(request.getInputStream());
-                    if (StringUtil.isEmpty(postStr)) {
-                        responseStr = "未输入任何内容";
-                    } else {
-                    /*if (postStr.equals(new String(postStr.getBytes("ISO-8859-1"), "ISO-8859-1"))) {
-                        logger.debug(" This type is  iso-8859-1");
-                        postStr = new String(postStr.getBytes("ISO-8859-1"), "UTF-8");
-
-                    }
-                    if (postStr.equals(new String(postStr.getBytes("GB2312"), "GB2312"))) {
-                        logger.debug(" This type is  GB2312" + postStr);
-                        postStr = new String(postStr.getBytes("GB2312"), "UTF-8");
-                        logger.debug(" change postStr to utf-8 " + postStr);
-                    }
-                    if (postStr.equals(new String(postStr.getBytes("GBK"), "GBK"))) {
-                        logger.debug(" This type is  GBK");
-                        postStr = new String(postStr.getBytes("GBK"), "UTF-8");
-
-                    }
-                    postStr = new String(postStr.getBytes("GB2312"), "UTF-8");*/
-                        Document document = DocumentHelper.parseText(postStr);
-                        Element root = document.getRootElement();
-                        String fromUserName = root.elementText("FromUserName");
-                        String toUserName = root.elementText("ToUserName");
-                        String keyword = root.elementTextTrim("Content");
-                        String msgType = root.elementTextTrim("MsgType");
-                        String event = root.elementText("Event");
-                        String eventKey = root.elementText("EventKey");
-                        if (WechatConstant.MSG_TYPE_TEXT.equals(msgType)) {
-                            responseStr = textResponseHandler(fromUserName, toUserName, keyword);
-                        } else if (WechatConstant.MSG_TYPE_EVENT.equals(msgType)) {
-                            responseStr = eventResponseHandler(fromUserName, toUserName, keyword, event, eventKey);
-                        } else {
-                            responseStr = eventResponseHandler(fromUserName, toUserName, keyword, event, eventKey);
-                        }
-
-                    }
-                } else {
-                    responseStr = echostr;
-                }
+                responseStr = echostr;
                 logger.debug(">>>>>>>>>>>>>..responseStr>>>>>>>>>>>>>>>" + responseStr);
             } else {
                 responseStr = "亲,非法访问,签名失败";
@@ -128,12 +92,14 @@ public class WechatGatewayController extends BaseController {
     @RequestMapping(path = "/gateway", method = RequestMethod.POST)
     public ResponseEntity<String> gateway(@RequestBody String param, HttpServletRequest request) {
 
-        String token = WechatConstant.TOKEN;
+        String token = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.TOKEN);
         String signature = request.getParameter("signature");
         String timestamp = request.getParameter("timestamp");
         String nonce = request.getParameter("nonce");
         String openId = request.getParameter("openid");
+        String java110AppId = request.getParameter("java110AppId");
         String responseStr = "";
+        ResponseEntity<String> responseEntity = null;
         logger.debug("token = " + token + "||||" + "signature = " + signature + "|||" + "timestamp = "
                 + timestamp + "|||" + "nonce = " + nonce + "|||| param = " + param + "|||| openId= " + openId);
         String sourceString = "";
@@ -145,137 +111,42 @@ public class WechatGatewayController extends BaseController {
         String signature1 = AuthenticationFactory.SHA1Encode(sourceString).toLowerCase();
         logger.debug("sourceString = " + sourceString + "||||" + "signature1 = " + signature1);
         try {
-            if (signature1.equals(signature)) {
-                String postStr = param;//this.readStreamParameter(request.getInputStream());
-                if (StringUtil.isEmpty(postStr)) {
-                    responseStr = "未输入任何内容";
-                } else {
-                    /*if (postStr.equals(new String(postStr.getBytes("ISO-8859-1"), "ISO-8859-1"))) {
-                        logger.debug(" This type is  iso-8859-1");
-                        postStr = new String(postStr.getBytes("ISO-8859-1"), "UTF-8");
-
-                    }
-                    if (postStr.equals(new String(postStr.getBytes("GB2312"), "GB2312"))) {
-                        logger.debug(" This type is  GB2312" + postStr);
-                        postStr = new String(postStr.getBytes("GB2312"), "UTF-8");
-                        logger.debug(" change postStr to utf-8 " + postStr);
-                    }
-                    if (postStr.equals(new String(postStr.getBytes("GBK"), "GBK"))) {
-                        logger.debug(" This type is  GBK");
-                        postStr = new String(postStr.getBytes("GBK"), "UTF-8");
-
-                    }
-                    postStr = new String(postStr.getBytes("GB2312"), "UTF-8");*/
-                    Document document = DocumentHelper.parseText(postStr);
-                    Element root = document.getRootElement();
-                    String fromUserName = root.elementText("FromUserName");
-                    String toUserName = root.elementText("ToUserName");
-                    String keyword = root.elementTextTrim("Content");
-                    String msgType = root.elementTextTrim("MsgType");
-                    String event = root.elementText("Event");
-                    String eventKey = root.elementText("EventKey");
-                    if (WechatConstant.MSG_TYPE_TEXT.equals(msgType)) {
-                        responseStr = textResponseHandler(fromUserName, toUserName, keyword);
-                    } else if (WechatConstant.MSG_TYPE_EVENT.equals(msgType)) {
-                        responseStr = eventResponseHandler(fromUserName, toUserName, keyword, event, eventKey);
-                    } else {
-                        responseStr = eventResponseHandler(fromUserName, toUserName, keyword, event, eventKey);
-                    }
-
-                }
-
-                logger.debug(">>>>>>>>>>>>>..responseStr>>>>>>>>>>>>>>>" + responseStr);
-            } else {
+            if (!signature1.equals(signature)) {
                 responseStr = "亲,非法访问,签名失败";
+                return new ResponseEntity<String>(responseStr, HttpStatus.OK);
+            }
+            String postStr = param;
+            if (StringUtil.isEmpty(postStr)) {
+                responseStr = "未输入任何内容";
+                return new ResponseEntity<String>(responseStr, HttpStatus.OK);
             }
+            Document document = DocumentHelper.parseText(postStr);
+            Element root = document.getRootElement();
+            String fromUserName = root.elementText("FromUserName");
+            String toUserName = root.elementText("ToUserName");
+            String keyword = root.elementTextTrim("Content");
+            String msgType = root.elementTextTrim("MsgType");
+            String event = root.elementText("Event");
+            String eventKey = root.elementText("EventKey");
+            JSONObject paramIn = new JSONObject();
+            paramIn.put("fromUserName", fromUserName);
+            paramIn.put("toUserName", toUserName);
+            paramIn.put("keyword", keyword);
+            paramIn.put("msgType", msgType);
+            paramIn.put("event", event);
+            paramIn.put("eventKey", eventKey);
+            IPageData pd = PageData.newInstance().builder("", "", "", paramIn.toJSONString(),
+                    "", "", "", "",
+                    java110AppId);
+            responseEntity = wechatGatewaySMOImpl.gateway(pd);
+
         } catch (Exception e) {
             // TODO Auto-generated catch block
             logger.error("处理失败", e);
             responseStr = "亲,网络超时,请稍后重试";
+            responseEntity = new ResponseEntity<String>(responseStr, HttpStatus.OK);
         }
 
-        return new ResponseEntity<String>(responseStr, HttpStatus.OK);
-    }
-
-    /**
-     * 鏂囨湰淇℃伅鍥炲
-     *
-     * @param fromUserName
-     * @param toUserName
-     * @param keyword
-     * @return
-     */
-    private String textResponseHandler(String fromUserName, String toUserName,
-                                       String keyword) {
-        if (keyword == null || keyword.length() == 0) {
-            return WechatFactory
-                    .formatText(toUserName, fromUserName, "未包含任何信息");
-        } else {
-            String responseStr = keyWordHandler(fromUserName, toUserName,
-                    keyword);
-            return WechatFactory
-                    .formatText(toUserName, fromUserName, responseStr);
-        }
-    }
-
-    private String keyWordHandler(String fromUserName, String toUserName,
-                                  String keyword) {
-        // TODO Auto-generated method stub
-        String domain = WechatConstant.TOKEN;
-        //String url = domain + "/IMSS/indexPage.do";
-        return "HC小区物业管理系统是由java110团队于2017年4月份发起的前后端分离、分布式架构开源项目,目前我们的代码开源在github 和gitee上,开源项目由HC小区管理系统后端,HC小区管理系统前端,HC小区管理系统业主手机版和HC小区管理系统物业手机版,业务技术交流群:827669685";
-    }
-
-    /**
-     * 事件处理
-     *
-     * @param fromUserName
-     * @param toUserName
-     * @param event
-     * @param eventKey
-     * @return
-     * @throws Exception
-     */
-    @SuppressWarnings({"unchecked"})
-    public String eventResponseHandler(String fromUserName, String toUserName, String keyWords, String event,
-                                       String eventKey) throws Exception {
-        String resultStr = "";
-        //
-        if (event.equals("subscribe")) {
-            resultStr = "HC小区物业管理系统是由java110团队于2017年4月份发起的前后端分离、分布式架构开源项目,目前我们的代码开源在github 和gitee上,开源项目由HC小区管理系统后端,HC小区管理系统前端,HC小区管理系统业主手机版和HC小区管理系统物业手机版,业务技术交流群:827669685";
-        } else if (event.equals("unsubscribe")) {
-
-        } else if (event.equalsIgnoreCase("CLICK")) {
-            resultStr = textResponseHandler(fromUserName, toUserName,
-                    eventKey);
-        } else {
-
-        }
-        return WechatFactory.formatText(toUserName, fromUserName, resultStr);
-    }
-
-    public String readStreamParameter(ServletInputStream in) {
-        StringBuilder buffer = new StringBuilder();
-        BufferedReader reader = null;
-        try {
-            reader = new BufferedReader(new InputStreamReader(in));
-            String line = null;
-            while ((line = reader.readLine()) != null) {
-                buffer.append(line);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            if (null != reader) {
-                try {
-                    reader.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
-        }
-
-        logger.debug("公众号内容:" + buffer.toString());
-        return buffer.toString();
+        return responseEntity;
     }
 }

+ 22 - 0
service-front/src/main/java/com/java110/front/smo/wechatGateway/IWechatGatewaySMO.java

@@ -0,0 +1,22 @@
+package com.java110.front.smo.wechatGateway;
+
+import com.java110.core.context.IPageData;
+import com.java110.utils.exception.SMOException;
+import org.springframework.http.ResponseEntity;
+
+/**
+ * 组织管理管理服务接口类
+ * <p>
+ * add by wuxw 2019-06-29
+ */
+public interface IWechatGatewaySMO {
+
+    /**
+     * 获取微信回话信息
+     *
+     * @param pd 页面数据封装
+     * @return ResponseEntity 对象数据
+     * @throws SMOException 业务代码层
+     */
+    ResponseEntity<String> gateway(IPageData pd) throws Exception;
+}

+ 186 - 0
service-front/src/main/java/com/java110/front/smo/wechatGateway/impl/WechatGatewaySMOImpl.java

@@ -0,0 +1,186 @@
+package com.java110.front.smo.wechatGateway.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.java110.core.context.IPageData;
+import com.java110.core.factory.WechatFactory;
+import com.java110.front.properties.WechatAuthProperties;
+import com.java110.front.smo.AppAbstractComponentSMO;
+import com.java110.front.smo.wechatGateway.IWechatGatewaySMO;
+import com.java110.utils.cache.MappingCache;
+import com.java110.utils.constant.ServiceConstant;
+import com.java110.utils.constant.WechatConstant;
+import com.java110.utils.util.Assert;
+import com.java110.utils.util.StringUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+import org.thymeleaf.util.StringUtils;
+
+/**
+ * wx登录
+ */
+@Service("ownerAppLoginSMOImpl")
+public class WechatGatewaySMOImpl extends AppAbstractComponentSMO implements IWechatGatewaySMO {
+
+    private final static Logger logger = LoggerFactory.getLogger(WechatGatewaySMOImpl.class);
+
+    @Autowired
+    private RestTemplate restTemplate;
+
+    @Autowired
+    private RestTemplate outRestTemplate;
+
+    @Autowired
+    private WechatAuthProperties wechatAuthProperties;
+
+    @Override
+    public ResponseEntity<String>
+    gateway(IPageData pd) throws Exception {
+        return businessProcess(pd);
+    }
+
+    @Override
+    protected void validate(IPageData pd, JSONObject paramIn) {
+        Assert.hasKeyAndValue(paramIn, "fromUserName", "请求报文中未包含fromUserName");
+        Assert.hasKeyAndValue(paramIn, "toUserName", "请求报文中未包含toUserName");
+    }
+
+    @Override
+    protected ResponseEntity<String> doBusinessProcess(IPageData pd, JSONObject paramIn) throws Exception {
+
+        logger.debug("doLogin入参:" + paramIn.toJSONString());
+        String responseStr = "";
+
+        String fromUserName = paramIn.getString("fromUserName");
+        String toUserName = paramIn.getString("toUserName");
+        String keyword = paramIn.getString("keyword");
+        String msgType = paramIn.getString("msgType");
+        String event = paramIn.getString("event");
+        String eventKey = paramIn.getString("eventKey");
+        //判断用户是否绑定业主
+        boolean bindFlag = judgeBindOwner(pd, fromUserName);
+        if (!bindFlag) {
+            responseStr = WechatFactory.formatText(toUserName, fromUserName, WechatConstant.NO_BIND_OWNER_RESPONSE_MESSAGE);
+            return new ResponseEntity<String>(responseStr, HttpStatus.OK);
+        }
+
+        if (WechatConstant.MSG_TYPE_TEXT.equals(msgType)) {
+            responseStr = textResponseHandler(fromUserName, toUserName, keyword);
+        } else if (WechatConstant.MSG_TYPE_EVENT.equals(msgType)) {
+            responseStr = eventResponseHandler(fromUserName, toUserName, keyword, event, eventKey);
+        } else {
+            responseStr = eventResponseHandler(fromUserName, toUserName, keyword, event, eventKey);
+        }
+        return new ResponseEntity<>(responseStr, HttpStatus.OK);
+    }
+
+    public RestTemplate getRestTemplate() {
+        return restTemplate;
+    }
+
+    public void setRestTemplate(RestTemplate restTemplate) {
+        this.restTemplate = restTemplate;
+    }
+
+    /**
+     * 文字处理
+     *
+     * @param fromUserName
+     * @param toUserName
+     * @param keyword
+     * @return
+     */
+    private String textResponseHandler(String fromUserName, String toUserName,
+                                       String keyword) {
+        if (StringUtils.isEmpty(keyword)) {
+            return WechatFactory
+                    .formatText(toUserName, fromUserName, "未包含任何信息");
+        } else {
+            String responseStr = keyWordHandler(fromUserName, toUserName,
+                    keyword);
+            return WechatFactory
+                    .formatText(toUserName, fromUserName, responseStr);
+        }
+    }
+
+    /**
+     * 事件处理
+     *
+     * @param fromUserName
+     * @param toUserName
+     * @param keyword
+     * @return
+     */
+    private String keyWordHandler(String fromUserName, String toUserName,
+                                  String keyword) {
+        // TODO Auto-generated method stub
+        String domain = WechatConstant.TOKEN;
+        //String url = domain + "/IMSS/indexPage.do";
+        String remark = MappingCache.getRemark(WechatConstant.WECHAT_DOMAIN, WechatConstant.WELCOME);
+
+        if (StringUtil.isEmpty(remark)) {
+            remark = WechatConstant.DEFAULT_WELCOME;
+        }
+
+        return remark;
+    }
+
+    /**
+     * 事件处理
+     *
+     * @param fromUserName
+     * @param toUserName
+     * @param event
+     * @param eventKey
+     * @return
+     * @throws Exception
+     */
+    @SuppressWarnings({"unchecked"})
+    public String eventResponseHandler(String fromUserName, String toUserName, String keyWords, String event,
+                                       String eventKey) throws Exception {
+        String resultStr = "";
+        //
+        if (event.equals("subscribe")) {
+            resultStr = MappingCache.getRemark(WechatConstant.WECHAT_DOMAIN, WechatConstant.WELCOME);
+        } else if (event.equals("unsubscribe")) {
+
+        } else if (event.equalsIgnoreCase("CLICK")) {
+            resultStr = textResponseHandler(fromUserName, toUserName,
+                    eventKey);
+        } else {
+
+        }
+        if (StringUtil.isEmpty(resultStr)) {
+            resultStr = WechatConstant.DEFAULT_WELCOME;
+        }
+        return WechatFactory.formatText(toUserName, fromUserName, resultStr);
+    }
+
+    /**
+     * 判断是否绑定业主
+     *
+     * @param openId
+     * @return
+     */
+    private boolean judgeBindOwner(IPageData pd, String openId) {
+
+        ResponseEntity responseEntity = this.callCenterService(restTemplate, pd, "", ServiceConstant.SERVICE_API_URL + "/api/owner.listAppUserBindingOwners?openId=" + openId, HttpMethod.GET);
+
+        if (responseEntity.getStatusCode() != HttpStatus.OK) {
+            return true;
+        }
+
+        JSONObject ownerInfo = JSONObject.parseObject(responseEntity.getBody().toString());
+
+        if (ownerInfo.getInteger("total") != 1) {
+            return false;
+        }
+        return true;
+    }
+
+}