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

相关文章
|
12月前
|
安全 前端开发 关系型数据库
IM即时通讯系统开发技术规则
IM即时通讯系统开发涵盖客户端与服务器端,涉及前端、后端、网络通信及多媒体处理等技术领域,支持文字、语音、图片、视频等多种实时交流方式。开发流程包括需求分析、技术选型、系统设计、开发实现、测试优化及部署维护等阶段,需关注网络通信、多媒体处理、安全性及可扩展性等关键技术点,广泛应用于社交、客服、团队协作及游戏等领域。
|
4月前
|
JSON 机器人 API
gewe微信机器人搭建教程
GeWe开放平台是基于 微信开放平台的二次封装API服务,开发者可以使用本服务来处理微信中的各种事件,并可以通过后台调用对应的 API 来驱动微信自动执行任务,如自动收发消息、自动化应答、自动群邀请、群管理等,封装了 RPA技术流程,简化开发者二次开发难度,提供了开发者与微信对接的能力,使用简单,操作快捷,支持多种语言接入。
185 17
|
7月前
|
人工智能 开发框架 机器人
AstrBot:轻松将大模型接入QQ、微信等消息平台,打造多功能AI聊天机器人的开发框架,附详细教程
AstrBot 是一个开源的多平台聊天机器人及开发框架,支持多种大语言模型和消息平台,具备多轮对话、语音转文字等功能。
4377 15
AstrBot:轻松将大模型接入QQ、微信等消息平台,打造多功能AI聊天机器人的开发框架,附详细教程
|
人工智能 数据可视化 API
10 分钟构建 AI 客服并应用到网站、钉钉或微信中测试评
10 分钟构建 AI 客服并应用到网站、钉钉或微信中测试评
303 2
|
6月前
|
存储 API UED
鸿蒙特效教程02-微信语音录制动画效果实现教程
本教程适合HarmonyOS初学者,通过简单到复杂的步骤,一步步实现类似微信APP中的语音录制动画效果。
258 0
鸿蒙特效教程02-微信语音录制动画效果实现教程
|
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
144 0
|
7月前
|
人工智能 自然语言处理 BI
基于阿里云人工智能平台的智能客服系统开发与部署
随着人工智能技术的发展,智能客服系统成为企业提升服务效率和用户体验的重要工具。阿里云提供包括自然语言处理(NLP)、语音识别(ASR)、机器学习(PAI)等在内的完整AI平台,助力企业快速构建智能客服系统。本文将通过电商平台案例,展示如何基于阿里云AI平台从零开始开发、部署智能客服系统,并介绍其核心优势与最佳实践,涵盖文本和语音客服、知识库管理及数据分析等功能,显著提升客户服务效率和用户满意度。
|
人工智能 运维 负载均衡
10 分钟构建 AI 客服并应用到网站、钉钉或微信中
《10分钟构建AI客服并应用到网站、钉钉或微信中》的解决方案通过详尽的文档和示例代码,使具有一定编程基础的用户能够快速上手,顺利完成AI客服集成。方案涵盖高可用性、负载均衡及定制化选项,满足生产环境需求。然而,若文档不清晰或存在信息缺失,则可能导致部署障碍。实际部署中可能遇到网络、权限等问题,需逐一排查。云产品的功能、性能及操作配置便捷性直接影响解决方案效果,详尽的产品手册有助于快速解决问题。总体而言,该方案在各方面表现出色,值得推荐。
504 34
|
12月前
|
小程序 开发者
微信小程序之网络数据请求 wx:request的简单使用
这篇文章介绍了微信小程序中如何使用wx.request进行网络数据请求,包括请求的配置、请求的格式以及如何在开发阶段关闭请求的合法检验。
微信小程序之网络数据请求 wx:request的简单使用
详细教程:扫码提交表单后,数据直接推送到企业微信、钉钉、飞书群聊
在草料制作的表单中,填表人扫码填写并提交数据后,这些信息可以立即通过企业微信、钉钉或飞书自动推送到相应的群聊中,实现即时共享和沟通,提升团队协作效率。
428 2

热门文章

最新文章