微信客服系统开发SDK使用教程- 拉取当前微信个人号列表请求(立即)

简介: 微信客服系统开发SDK使用教程- 拉取当前微信个人号列表请求(立即)

微信客服系统开发SDK- 拉取当前微信个人号列表请求(立即)


case "GetWeChatsReq": {// 拉取当前微信个人号列表请求(立即)

log.debug("websocket:msgtype=GetWeChatsReq。。。。。");
getWeChatsReqWebsocketHandler.handleMsg(ctx, vo,contentJsonStr);
break;
}
package com.jubotech.framework.netty.handler.websocket;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.google.protobuf.util.JsonFormat;
import com.jubotech.business.web.domain.AccountInfo;
import com.jubotech.business.web.domain.WeChatAccountInfo;
import com.jubotech.business.web.service.AccountService;
import com.jubotech.business.web.service.WeChatAccountService;
import com.jubotech.framework.netty.common.Constant;
import com.jubotech.framework.netty.utils.MessageUtil;
import Jubo.JuLiao.IM.Wx.Proto.GetWeChatsReq.GetWeChatsReqMessage;
import Jubo.JuLiao.IM.Wx.Proto.GetWeChatsRsp.GetWeChatsRspMessage;
import Jubo.JuLiao.IM.Wx.Proto.GetWeChatsRsp.WeChatRspMessage;
import Jubo.JuLiao.IM.Wx.Proto.TransportMessageOuterClass.EnumAccountType;
import Jubo.JuLiao.IM.Wx.Proto.TransportMessageOuterClass.EnumErrorCode;
import Jubo.JuLiao.IM.Wx.Proto.TransportMessageOuterClass.EnumMsgType;
import Jubo.JuLiao.IM.Wx.Proto.TransportMessageOuterClass.TransportMessage;
import io.netty.channel.ChannelHandlerContext;
@Service
public class GetWeChatsReqWebsocketHandler{
Logger log = LoggerFactory.getLogger(getClass());
@Autowired
private WeChatAccountService weChatAccountService;
@Autowired
private AccountService accountService;
/**
* 拉取当前微信个人号列表响应
* @author wechatno:tangjinjinwx
* @param ctx
* @param vo
*/
public void handleMsg(ChannelHandlerContext ctx ,TransportMessage vo, String contentJsonStr) {
try {
log.info(contentJsonStr);
GetWeChatsReqMessage.Builder bd = GetWeChatsReqMessage.newBuilder();
JsonFormat.parser().merge(contentJsonStr, bd);
GetWeChatsReqMessage req = bd.build();
//1、校验用户信息
log.info("账号:"+req.getUnionId());
if(null != req){
Integer id = (int) req.getUnionId();
            AccountInfo  account = accountService.findAccountInfoByid(id);
            if(null != account){
                
                List<WeChatAccountInfo> list =  weChatAccountService.findWeChatAccountInfo(account.getCid(), account.getId());
// if(null == list || list.isEmpty()){
// list = weChatAccountService.findWeChatAccountInfo(account.getCid(), null);
// }
List weChatrspList = getWechatList(list);
                GetWeChatsRspMessage.Builder builder = GetWeChatsRspMessage.newBuilder();
                builder.setUnionId(req.getUnionId());
                builder.setAccountType(EnumAccountType.SubUser);
                builder.setSupplierId(account.getCid());
                if(null != weChatrspList && weChatrspList.size()>0){
                    builder.addAllWeChats(weChatrspList);
                }
                
                GetWeChatsRspMessage resp = builder.build();
                
                //3、告诉PC客户端消息已收到
                MessageUtil.sendJsonMsg(ctx, EnumMsgType.GetWeChatsRsp, vo.getAccessToken(), vo.getId(), resp);
            }else{
                MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam,Constant.ERROR_MSG_PARAMERROR);
            }
        } 
    } catch (Exception e) {
        e.printStackTrace();
        MessageUtil.sendJsonErrMsg(ctx, EnumErrorCode.InvalidParam, Constant.ERROR_MSG_DECODFAIL);
    }
}
 
/**
 * 封装返回对象
 * @param list
 * @return
 */
private static List<WeChatRspMessage>  getWechatList(List<WeChatAccountInfo> list){
    List<WeChatRspMessage> weChatrspList = null;
    if(null != list && list.size()>0){
        weChatrspList = new ArrayList<>();
        for(int i=0;i<list.size();i++){
            WeChatAccountInfo info = list.get(i);
            boolean online = false;
            if(null != info.getIsonline() && info.getIsonline()==0){
                online = true;
            }
            boolean logined = false;
            if(null != info.getIslogined() && info.getIslogined()==0){
                logined = true;
            }
            WeChatRspMessage.Builder builder = WeChatRspMessage.newBuilder();
            if(null != info.getWechatid()){
                builder.setWeChatId(info.getWechatid());
            }
            if(null != info.getWechatno()){
                builder.setWeChatNo(info.getWechatno());
            }
            if(null !=info.getWechatnick()){
                builder.setWeChatNick(info.getWechatnick());
            }
            if(null != info.getAvatar()){
                builder.setAvatar(info.getAvatar());
            }
            if(null != info.getCountry()){
                builder.setCountry(info.getCountry());
            }
            if(null != info.getProvince()){
                builder.setProvince(info.getProvince());
            }
            if(null != info.getCity()){
                builder.setCity(info.getCity());
            }
            if(null != info.getGender()){
                builder.setGenderValue(info.getGender());
            }
            if(null != info.getLogin_time()){
                builder.setLoginTime(info.getLogin_time().getTime());
            }
            if(null != info.getModify_time()){
                builder.setModifyTime(info.getModify_time().getTime());
            }
            if(null != info.getDeviceid()){
                builder.setDeviceName(info.getDeviceid());
            }
            if(null != info.getAccountid()){
                builder.setLoginUnionId(info.getAccountid());
            }
            builder.setIsOnline(online);
            builder.setIsLogined(logined);
            builder.setIsDelete(false);
            builder.setIsUpgrading(false);
                      
            weChatrspList.add(builder.build());
        }
    }
    
    return weChatrspList;
}

}

项目地址:https://www.wuliaokankan.cn/url301/138.html

接口参考:http://www.yunlauncher.com/Blog/articles/119.html

相关文章
|
8天前
|
人工智能 数据可视化 API
10 分钟构建 AI 客服并应用到网站、钉钉或微信中测试评
10 分钟构建 AI 客服并应用到网站、钉钉或微信中测试评
35 2
|
30天前
|
人工智能
10 分钟构建 AI 客服并应用到网站、钉钉或微信中简说
10 分钟构建 AI 客服并应用到网站、钉钉或微信
|
3天前
|
人工智能 运维 负载均衡
10 分钟构建 AI 客服并应用到网站、钉钉或微信中
《10分钟构建AI客服并应用到网站、钉钉或微信中》的解决方案通过详尽的文档和示例代码,使具有一定编程基础的用户能够快速上手,顺利完成AI客服集成。方案涵盖高可用性、负载均衡及定制化选项,满足生产环境需求。然而,若文档不清晰或存在信息缺失,则可能导致部署障碍。实际部署中可能遇到网络、权限等问题,需逐一排查。云产品的功能、性能及操作配置便捷性直接影响解决方案效果,详尽的产品手册有助于快速解决问题。总体而言,该方案在各方面表现出色,值得推荐。
|
3天前
详细教程:扫码提交表单后,数据直接推送到企业微信、钉钉、飞书群聊
在草料制作的表单中,填表人扫码填写并提交数据后,这些信息可以立即通过企业微信、钉钉或飞书自动推送到相应的群聊中,实现即时共享和沟通,提升团队协作效率。
|
30天前
|
人工智能 自然语言处理 搜索推荐
评测:AI客服接入钉钉与微信的对比分析
【8月更文第22天】随着人工智能技术的发展,越来越多的企业开始尝试将AI客服集成到自己的业务流程中。本文将基于《10分钟构建AI客服并应用到网站、钉钉或微信中》的解决方案,详细评测AI客服在钉钉和微信中的接入流程及实际应用效果,并结合个人体验分享一些心得。
9910 9
|
1月前
|
小程序 编译器 数据安全/隐私保护
小白保姆级教程:微信公众号开发,从0到1
【8月更文挑战第8天】小白保姆级教程:微信公众号开发,从0到1
63 3
小白保姆级教程:微信公众号开发,从0到1
|
1月前
|
编解码 缓存 开发工具
Pico Neo 3教程☀️ 三、SDK 的进阶功能
Pico Neo 3教程☀️ 三、SDK 的进阶功能
|
1月前
|
开发工具 图形学 Android开发
Pico Neo 3教程☀️ 二、从 PicoVR Unity SDK 迁移至 Unity XR SDK
Pico Neo 3教程☀️ 二、从 PicoVR Unity SDK 迁移至 Unity XR SDK
|
1月前
|
开发工具 vr&ar 图形学
Pico Neo 3教程☀️ 一、SDK的下载与快速入门
Pico Neo 3教程☀️ 一、SDK的下载与快速入门
|
1月前
|
缓存 JavaScript 前端开发
微信 JS-SDK Demo “分享信息设置” API 及数字签名生成方法(NodeJS版本)
微信 JS-SDK Demo “分享信息设置” API 及数字签名生成方法(NodeJS版本)更新时间(2020-10-29)

热门文章

最新文章