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

转载于:https://www.cnblogs.com/wuliaokankan/p/10681775.html

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

  1. 微信个人号多开定制SCRM客服系统开发教程

    使用聚播群控二次开发sdk实现微信个人号多开定制SCRM客服系统开发教程!出自秋天不穿秋裤,天冷也要风度的程序猿之手,必属精品! 今天给大家介绍如何使用聚播群控sdk(微信二次开发SDK)快速开发一个 ...

  2. 智能客服系统开发(技术方案)

    一个智能客服系统,负责全部的开发任务:主要包括前端页面开发,后台逻辑设计,中间客服与用户之间的对话流设计(算法部分),以及系统部署. 前端页面采用vue框架(最近比较火的一个框架,vuejs比较贴合p ...

  3. php 微信客服聊天开发,客服服务

    企业客服服务 客服服务是企业号为企业提供的客服功能,如下图所示,目前支持两种客服场景: 外部客户客服:外部客户在公众号或企业自有门户进行问题咨询,客服人员在企业号聊天进行咨询回复. 内部客户客服:企业 ...

  4. 在线客服系统开发重点难点

    背景 公司决定将内部稳定运营支撑上10万商家的客服系统独立出来,独立成一个产品,对外提供服务.在此记录一下此系统对外提供服务遇到的问题及其解决方法. 效果 # 消息支持 我们设置了消息体参数,核心参数 ...

  5. 小程序,公众号微信客服消息开发

    背景:第三方公司已经开发好微信的客服消息对话框.要求我们公司开发的小程序和公众号增加一个按钮,点击后会跳转到第三方公司开发好的客服消息对话框里. 首先,小程序的要去小程序管理后台,绑定对应的企业ID和 ...

  6. 微信客服消息开发,报45047,44004错误码

    中途接手的项目,需求是为微信小程序接入智能客服功能,我在实现后台功能代码后,测试发现自定义的客服回复消息没有发送过来,后台返回45047错误码: 45047错误码 小程序发送客服消息 返回:{&quo ...

  7. 小程序接入微信客服系统

    在小程序中加入客服消息按钮 小程序接入微信「客服消息」功能模块,开发者只需要调用按钮,触发微信的客服消息功能即可,不需要自行在小程序中实现. 加入客服消息按钮有两个方法,大家可以根据自己的实际需求,任 ...

  8. 12月最新辰光PHP在线客服系统3.6IM即时通讯聊天源码微信公众号小程序全开

    csdn下载地址: https://download.csdn.net/download/dujiangdu123/13745650 PHP订单系统手机微信多产品在线下单网站PHP单页竞价管理源码 后 ...

  9. jym在线客服系统源码搭建教程

    教程:php5.6以上,修改数据库账号密码直接使用. 源码带有教程! 下载程序:https://pan.baidu.com/s/16lN3gvRIZm7pqhvVMYYecQ?pwd=6zw3

最新文章

  1. 你必须非常努力,才能看起来毫不费力
  2. ExecutorService为创建的线程池ExecutorService pool = Executors.newFixedThreadPool(POOL_SIZE)
  3. Log4j2的性能为什么这么好?
  4. Docker 安装MySQL以及外部访问
  5. linux用户和账号管理
  6. python装饰器-简易版
  7. 转载 hashtable和dictionary的区别
  8. SSM房屋租赁系统,房屋合租系统 租房系统 SpringBoot租房系统
  9. 树莓派 armv几_如何在具有armv6处理器的树莓派板上安装和使用Java 11和JavaFX 11
  10. wps桌面图标不显示问题
  11. 学生HTML个人网页作业作品:基于HTML实现教育培训机构网站模板毕业源码(8页)
  12. 单片机复位电路是怎么工作的?
  13. Hyper-v安装及使用详细教程
  14. 云浮农村生活污水处理设备——水生态环境保护“十四五”规划
  15. 英语学习经验分享(四六级、竞赛、口语)
  16. Python实现多任务
  17. weblogic(一).简介与安装
  18. Serializers - Django REST framework
  19. 【Python+C#】手把手搭建基于Hugging Face模型的离线翻译系统,并通过C#代码进行访问...
  20. gcc 查看默认的编译标准

热门文章

  1. linux下oracle数据库由于参数文件丢失导致的数据库服务启动失败,报“failure in processing system parameters“错误问题解决
  2. CTFshow php特性 web128
  3. CTFshow php特性 web90
  4. tkinter中的canvas的边框问题
  5. istringstream
  6. log--求自然对数
  7. cvCalcBackProject的例子
  8. PNN神经网络预测类别的例子
  9. t1plus 用什么服务器系统,T1 Plus商贸宝普及版与用友T1系统哪个更好呢?
  10. HZOJ 斐波那契(fibonacci)