微信客服系统开发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

相关文章
|
人工智能 自然语言处理 BI
基于阿里云人工智能平台的智能客服系统开发与部署
随着人工智能技术的发展,智能客服系统成为企业提升服务效率和用户体验的重要工具。阿里云提供包括自然语言处理(NLP)、语音识别(ASR)、机器学习(PAI)等在内的完整AI平台,助力企业快速构建智能客服系统。本文将通过电商平台案例,展示如何基于阿里云AI平台从零开始开发、部署智能客服系统,并介绍其核心优势与最佳实践,涵盖文本和语音客服、知识库管理及数据分析等功能,显著提升客户服务效率和用户满意度。
|
小程序 PHP
微信小程序给 thinkphp后端发送请求出现错误 Wrong number of segments 问题的解决 【踩坑记录】
本文记录了微信小程序向ThinkPHP后端发送请求时出现"Wrong number of segments"错误的解决方法。问题原因是小程序请求header中的token变量名写错,导致token未正确传递至后端。作者提供了详细的检查步骤和建议,包括验证URL路径、参数规范和路由配置的匹配,以确保请求能正确发送和处理。
|
小程序 开发者
微信小程序之网络数据请求 wx:request的简单使用
这篇文章介绍了微信小程序中如何使用wx.request进行网络数据请求,包括请求的配置、请求的格式以及如何在开发阶段关闭请求的合法检验。
微信小程序之网络数据请求 wx:request的简单使用
|
安全 前端开发 关系型数据库
IM即时通讯系统开发技术规则
IM即时通讯系统开发涵盖客户端与服务器端,涉及前端、后端、网络通信及多媒体处理等技术领域,支持文字、语音、图片、视频等多种实时交流方式。开发流程包括需求分析、技术选型、系统设计、开发实现、测试优化及部署维护等阶段,需关注网络通信、多媒体处理、安全性及可扩展性等关键技术点,广泛应用于社交、客服、团队协作及游戏等领域。
|
人工智能 数据可视化 API
10 分钟构建 AI 客服并应用到网站、钉钉或微信中测试评
10 分钟构建 AI 客服并应用到网站、钉钉或微信中测试评
485 2
|
存储 API 开发工具
【Azure 环境】在Azure虚拟机(经典) 的资源中,使用SDK导出VM列表的办法
【Azure 环境】在Azure虚拟机(经典) 的资源中,使用SDK导出VM列表的办法
269 0
|
Java 开发工具
【Azure Developer】Azure Graph SDK获取用户列表的问题: SDK中GraphServiceClient如何指向中国区的Endpoint:https://microsoftgraph.chinacloudapi.cn/v1.0
【Azure Developer】Azure Graph SDK获取用户列表的问题: SDK中GraphServiceClient如何指向中国区的Endpoint:https://microsoftgraph.chinacloudapi.cn/v1.0
286 0
|
人工智能 自然语言处理 搜索推荐
评测:AI客服接入钉钉与微信的对比分析
【8月更文第22天】随着人工智能技术的发展,越来越多的企业开始尝试将AI客服集成到自己的业务流程中。本文将基于《10分钟构建AI客服并应用到网站、钉钉或微信中》的解决方案,详细评测AI客服在钉钉和微信中的接入流程及实际应用效果,并结合个人体验分享一些心得。
10935 10
|
人工智能
10 分钟构建 AI 客服并应用到网站、钉钉或微信中简说
10 分钟构建 AI 客服并应用到网站、钉钉或微信
|
编解码 Linux 开发工具
大牛直播SDK跨平台RTMP直播推送模块技术设计和功能列表
大牛直播SDK是一款跨平台RTMP直播推送模块,支持Windows、Linux(x64_64与aarch64架构)、Android及iOS平台。该SDK功能全面,包括摄像头、屏幕、麦克风等数据采集与推送,并支持编码前后数据对接。其架构设计优秀,确保低延迟与高效率,结合SmartPlayer播放器实现毫秒级延迟体验。具备全自研框架,易于扩展且支持多种数据源接入,如外部YUV/RGB/H.264等格式。此外,各平台支持特性丰富,如Windows平台支持多摄像头合成,Android与iOS平台支持前后摄像头实时切换等。大牛直播SDK还提供了多个示例项目以帮助开发者快速上手。
706 0

热门文章

最新文章