Search in sources :

Example 1 with WxMpXmlOutNewsMessage

use of me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage in project summer by foxsugar.

the class MenuHandler method handle_download.

private WxMpXmlOutMessage handle_download(WxMpXmlMessage wxMessage, WxMpService wxService) {
    WxMpXmlOutNewsMessage.Item item = new WxMpXmlOutNewsMessage.Item();
    item.setTitle("下载地址");
    // item.setDescription("点击进入专属界面");
    WxMpXmlOutNewsMessage.Item item1 = new WxMpXmlOutNewsMessage.Item();
    // todo 展示二维码 链接
    item1.setPicUrl("https://mmbiz.qpic.cn/mmbiz_png/wj1STzkg04h46BuribmuoJnsMQgc2m70558p3mE91j6zq4sph6RavCicfUiahTSRj4CVRSRN9ecdJKic6ysZeBCZiag/0?wx_fmt=png");
    item1.setTitle("棋牌室");
    item1.setUrl("/game/wecha");
    WxMpXmlOutNewsMessage m = WxMpXmlOutMessage.NEWS().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).addArticle(item, item1).build();
    return m;
}
Also used : WxMpXmlOutNewsMessage(me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage)

Example 2 with WxMpXmlOutNewsMessage

use of me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage in project summer by foxsugar.

the class MenuHandler method handle_kefu.

private WxMpXmlOutMessage handle_kefu(WxMpXmlMessage wxMessage, WxMpService wxService) {
    WxMpXmlOutNewsMessage.Item item = new WxMpXmlOutNewsMessage.Item();
    item.setTitle("客服微信号:17189556611");
    item.setPicUrl("https://mmbiz.qpic.cn/mmbiz_png/wj1STzkg04h46BuribmuoJnsMQgc2m705YQuY91HglHYhZVzZs971Lb6HVfLHCweYc4QeddBAZVNdCAj5F86fog/0?wx_fmt=png");
    // item.setDescription("点击进入专属界面");
    WxMpXmlOutNewsMessage.Item item1 = new WxMpXmlOutNewsMessage.Item();
    // todo 展示二维码 链接
    item1.setPicUrl("https://mmbiz.qpic.cn/mmbiz_png/wj1STzkg04h46BuribmuoJnsMQgc2m70558p3mE91j6zq4sph6RavCicfUiahTSRj4CVRSRN9ecdJKic6ysZeBCZiag/0?wx_fmt=png");
    item1.setTitle("客服微信号:17189556611");
    WxMpXmlOutNewsMessage m = WxMpXmlOutMessage.NEWS().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).addArticle(item, item1).build();
    return m;
}
Also used : WxMpXmlOutNewsMessage(me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage)

Example 3 with WxMpXmlOutNewsMessage

use of me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage in project summer by foxsugar.

the class MenuHandler method handle_link.

/**
 * 处理链接
 *
 * @param wxMessage
 * @param wxService
 * @return
 */
private WxMpXmlOutMessage handle_link(WxMpXmlMessage wxMessage, WxMpService wxService) {
    Long agentId = null;
    try {
        WxMpUser wxMpUser = wxService.getUserService().userInfo(wxMessage.getFromUser());
        String unionId = wxMpUser.getUnionId();
        agentId = gameAgentService.getGameAgentDao().getUserIdByUnionId(unionId);
        if (agentId == null || agentId == 0) {
            return new TextBuilder().build("代理不存在", wxMessage, wxService);
        }
        // gameAgent 是否已经生成ticket
        AgentBean agentBean = RedisManager.getAgentRedisService().getAgentBean(agentId);
        if (agentBean.getOpenId() == null || agentBean.getQrTicket() == null || "".equals(agentBean.getQrTicket())) {
            agentBean.setImage(wxMpUser.getHeadImgUrl());
            agentBean.setOpenId(wxMpUser.getOpenId());
            // 根据unionId生成二维码 todo 加上游戏key
            WxMpQrCodeTicket ticket = wxService.getQrcodeService().qrCodeCreateLastTicket(serverConfig.getDomainMapKey() + "|" + unionId);
            agentBean.setQrTicket(ticket.getTicket());
            RedisManager.getAgentRedisService().updateAgentBean(agentBean);
        }
        RedisManager.getAgentRedisService().updateAgentBean(agentBean);
    } catch (WxErrorException e) {
        e.printStackTrace();
    }
    WxMpXmlOutNewsMessage.Item item = new WxMpXmlOutNewsMessage.Item();
    item.setTitle("您有如下专属代理链接");
    item.setDescription("点击进入专属界面");
    WxMpXmlOutNewsMessage.Item item1 = new WxMpXmlOutNewsMessage.Item();
    // todo 展示二维码 链接
    item1.setPicUrl("https://mmbiz.qpic.cn/mmbiz_png/wj1STzkg04h46BuribmuoJnsMQgc2m70558p3mE91j6zq4sph6RavCicfUiahTSRj4CVRSRN9ecdJKic6ysZeBCZiag/0?wx_fmt=png");
    item1.setTitle("棋牌");
    item1.setDescription("点击进入专属界面");
    // String url = "http://" + serverConfig.getDomain() + "/game/wechat/clickLink";
    String sid = "" + System.currentTimeMillis() + "_" + new Random().nextInt(999999);
    String url = MessageFormat.format("http://" + serverConfig.getDomain() + "/agent/#/sharelink?id={0}&sid={1}&in=1", "" + agentId, sid);
    // String url = MessageFormat.format("http://" + serverConfig.getDomain() +"/game/wechat/showLink?agentId={0}&sid={1}", ""+agentId, sid);
    logger.info("设置专属链接地址 : " + url);
    item1.setUrl(url);
    item1.setDescription("");
    WxMpXmlOutNewsMessage m = WxMpXmlOutMessage.NEWS().fromUser(wxMessage.getToUser()).toUser(wxMessage.getFromUser()).addArticle(item, item1).build();
    return m;
}
Also used : AgentBean(com.code.server.constant.game.AgentBean) WxMpQrCodeTicket(me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket) TextBuilder(com.code.server.login.wechat.builder.TextBuilder) Random(java.util.Random) WxMpUser(me.chanjar.weixin.mp.bean.result.WxMpUser) WxMpXmlOutNewsMessage(me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage) WxErrorException(me.chanjar.weixin.common.exception.WxErrorException)

Aggregations

WxMpXmlOutNewsMessage (me.chanjar.weixin.mp.bean.message.WxMpXmlOutNewsMessage)3 AgentBean (com.code.server.constant.game.AgentBean)1 TextBuilder (com.code.server.login.wechat.builder.TextBuilder)1 Random (java.util.Random)1 WxErrorException (me.chanjar.weixin.common.exception.WxErrorException)1 WxMpQrCodeTicket (me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket)1 WxMpUser (me.chanjar.weixin.mp.bean.result.WxMpUser)1