Przeglądaj źródła

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

# Conflicts:
#	common/common-entity/sql记录
yeshijie 3 lat temu
rodzic
commit
9aab9a0724

+ 21 - 2
common/common-util/src/main/java/com/yihu/jw/util/wechat/WeiXinMessageReplyUtils.java

@ -1,6 +1,5 @@
package com.yihu.jw.util.wechat;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -26,7 +25,7 @@ public class WeiXinMessageReplyUtils {
        result.append("<xml>");
        result.append("<ToUserName>" + toUser + "</ToUserName>");
        result.append("<FromUserName>" + fromUser + "</FromUserName>");
        result.append("<CreateTime>" + new Date().getTime() + "</CreateTime>");
        result.append("<CreateTime>" + System.currentTimeMillis() + "</CreateTime>");
        result.append("<MsgType>news</MsgType>");
        result.append("<ArticleCount>" + articles.size() + "</ArticleCount>");
        result.append("<Articles>");
@ -45,4 +44,24 @@ public class WeiXinMessageReplyUtils {
        return result.toString();
    }
    /**
     * 文本消息
     * @param toUser
     * @param fromUser
     * @param articles
     * @return
     * @throws Exception
     */
    public static String replyMessage(String toUser,String fromUser,String articles) throws Exception {
        StringBuilder result = new StringBuilder();
        result.append("<xml>");
        result.append("<ToUserName>" + toUser + "</ToUserName>");
        result.append("<FromUserName>" + fromUser + "</FromUserName>");
        result.append("<CreateTime>" + System.currentTimeMillis() + "</CreateTime>");
        result.append("<MsgType>text</MsgType>");
        result.append("<Content>" + articles + "</Content>");
        result.append("</xml>");
        return result.toString();
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/wechat/WechatCoreController.java

@ -93,6 +93,7 @@ public class WechatCoreController extends EnvelopRestEndpoint {
            if (validate(signature, timestamp, nonce)) {
                String xmlStr = weiXinCoreService.messageProcess(request, wxAccessTokenDO.getAccessToken());
                // 判断返回值是xml、json格式(取关是空串)
                System.out.println("xmlStr==="+xmlStr);
                Boolean flag = weiXinCoreService.isXML(xmlStr);
                if (xmlStr == "error") {
                    // 服务器错误
@ -101,7 +102,6 @@ public class WechatCoreController extends EnvelopRestEndpoint {
                    JSONObject json = new JSONObject(xmlStr);
                    if (json.has("openId")) {
                        if (StringUtils.isNotEmpty(json.getString("openId")) && !("undefined".equals(json.getString("openId")))) {
                            logger.info("调用眼科微信模板消息接口的入参:AccessToken="+wxAccessTokenDO.getAccessToken()+"---Openid="+json.getString(""));
                            WxTemplateConfigDO wxTemplateConfigDO = new WxTemplateConfigDO();
                            wxTemplateConfigDO.setRemark(json.toString());
                            weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), json.getString("openId"), wxTemplateConfigDO);

+ 66 - 11
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/wechat/WeiXinEventProcess.java

@ -29,6 +29,8 @@ public class WeiXinEventProcess {
    @Value("${wechat.id}")
    private String wechatId;
    @Value("${wechat.appId}")
    private String appId;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
@ -49,9 +51,9 @@ public class WeiXinEventProcess {
                if (message.containsKey("EventKey") && StringUtils.isNotEmpty(message.get("EventKey")) && message.containsKey("Ticket")
                        && StringUtils.isNotEmpty(message.get("Ticket"))) {
                    result = scanEventProcess(message);
                } /*else {
                } else {
                    result = subscribeEventProcess(message);
                }*/
                }
                break;
            /*case WeiXinMessageUtils.EVENT_TYPE_UNSUBSCRIBE: // 取消订阅事件
                 result = unsubscribeEventProcess(message);
@ -65,6 +67,24 @@ public class WeiXinEventProcess {
        return result;
    }
    /**
     * 关注事件消息构建回复消息体(图文消息xml,模板消息json串)
     *
     * @param message
     * @return
     * @throws Exception
     */
    private String subscribeEventProcess(Map<String, String> message) throws Exception {
        String result = "";
        // 场景值
        String eventKey = message.get("EventKey");
        List<Map<String, String>> articles = new ArrayList<>();
        setUrlItems(articles);
        result = WeiXinMessageReplyUtils.replyNewsMessage(message.get("FromUserName"), message.get("ToUserName"), articles);
        return result;
    }
    /**
     * 微信扫码事件处理(封装图文消息体)
     *
@ -93,17 +113,11 @@ public class WeiXinEventProcess {
            }
            // 医生二维码跳转URL
            if ("xm_ykyy_wx".equalsIgnoreCase(wechatId)){
                url = "https://intel.yanketong.com/ims-wx/#/doctorInfo?doctorCode="+keys[0];
                picUrl = "https://intel.yanketong.com/"+picUrl;
                article.put("Url", url);
                article.put("Title", keys[1] + "医生个人诊间");
                article.put("Description", "厦门眼科中心医院互联网医院");
                article.put("PicUrl", picUrl);
                articles.add(article);
            }else {
                url = "https://intm/ims-wx/#/doctorInfo?doctorCode="+keys[0];
                picUrl = "https://im/"+picUrl;
                article.put("Url", url);
                article.put("Title", keys[1] + "医生个人诊间");
                article.put("Description", "海沧医院互联网医院");
                article.put("Description", "医养云照护");
                article.put("PicUrl", picUrl);
                articles.add(article);
            }
@ -122,5 +136,46 @@ public class WeiXinEventProcess {
        return result;
    }
    /**
     * 设置微信公共的图文消息
     *
     * @param articles
     */
    public void setUrlItems(List<Map<String, String>> articles) {
        Map<String, String> articleBooking = new HashMap<>();
        // 图文URL
        String urlBooking = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=http%3A%2F%2Fhzijk.cityihealth.com%2Fmedical-care-patient%2Fhome%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        urlBooking = urlBooking.replace("{appId}", appId);
        articleBooking.put("Url", urlBooking);
        articleBooking.put("Title", "你好啊,欢迎来到朝晖云照护!");
        articleBooking.put("Description", "这里是智慧养老和健康管理服务社区+幼儿成长教育服务平台\n" +
                "我们陪你一起,关爱老人,呵护孩子!\n" +
                "感谢关注,点击下方菜单直接进入朝晖云照护平台");
        articleBooking.put("PicUrl", "http://hzijk.cityihealth.com/image/index.png");
        articles.add(articleBooking);
        Map<String, String> articleDevice = new HashMap<>();
        // 图文URL
        String urlDevice = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=http%3A%2F%2Fhzijk.cityihealth.com%2Fmedical-care-patient%2FonlineRegistration%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        urlDevice = urlDevice.replace("{appId}", appId);
        articleDevice.put("Url", urlDevice);
        articleDevice.put("Title", "在线入园");
        articleDevice.put("Description", "申请专业托育机构入园资格");
        articleDevice.put("PicUrl", "http://hzijk.cityihealth.com/image/doorCoach.png");
        articles.add(articleDevice);
        Map<String, String> articleFamily = new HashMap<>();
        // 图文URL
        String urlFamily = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=http%3A%2F%2Fhzijk.cityihealth.com%2Fmedical-care-patient%2FlifeCare%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        urlFamily = urlFamily.replace("{appId}", appId);
        articleFamily.put("Url", urlFamily);
        articleFamily.put("Title", "上门预约");
        articleFamily.put("Description", "预约幼儿教育专家上门育儿指导");
        articleFamily.put("PicUrl", "http://hzijk.cityihealth.com/image/online.png");
        articles.add(articleFamily);
    }
}

BIN
svr/svr-cloud-care/src/main/resources/image/doorCoach.png


BIN
svr/svr-cloud-care/src/main/resources/image/index.png


BIN
svr/svr-cloud-care/src/main/resources/image/online.png