package com.linkwechat.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.linkwechat.common.annotation.SynchRecord;
import com.linkwechat.common.constant.Constants;
import com.linkwechat.common.constant.HttpStatus;
import com.linkwechat.common.constant.SynchRecordConstants;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.context.SecurityContextHolder;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.domain.entity.SysUser;
import com.linkwechat.common.core.domain.model.LoginUser;
import com.linkwechat.common.core.page.PageDomain;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.CustomerAddWay;
import com.linkwechat.common.enums.MessageNoticeType;
import com.linkwechat.common.enums.TrajectorySceneType;
import com.linkwechat.common.enums.WeErrorCodeEnum;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.bean.BeanUtils;
import com.linkwechat.config.rabbitmq.RabbitMQSettingConfig;
import com.linkwechat.domain.*;
import com.linkwechat.domain.customer.WeBacthMakeCustomerTag;
import com.linkwechat.domain.customer.WeMakeCustomerTag;
import com.linkwechat.domain.customer.query.WeCustomersQuery;
import com.linkwechat.domain.customer.query.WeOnTheJobCustomerQuery;
import com.linkwechat.domain.customer.vo.*;
import com.linkwechat.domain.groupmsg.vo.WeGroupMessageExecuteUsertipVo;
import com.linkwechat.domain.tag.vo.WeTagVo;
import com.linkwechat.domain.wecom.entity.customer.WeCustomerFollowInfoEntity;
import com.linkwechat.domain.wecom.entity.customer.WeCustomerFollowUserEntity;
import com.linkwechat.domain.wecom.query.WeBaseQuery;
import com.linkwechat.domain.wecom.query.customer.UnionidToExternalUserIdQuery;
import com.linkwechat.domain.wecom.query.customer.WeBatchCustomerQuery;
import com.linkwechat.domain.wecom.query.customer.WeCustomerQuery;
import com.linkwechat.domain.wecom.query.customer.tag.WeMarkTagQuery;
import com.linkwechat.domain.wecom.query.customer.transfer.WeTransferCustomerQuery;
import com.linkwechat.domain.wecom.vo.customer.UnionidToExternalUserIdVo;
import com.linkwechat.domain.wecom.vo.customer.WeBatchCustomerDetailVo;
import com.linkwechat.domain.wecom.vo.customer.WeCustomerDetailVo;
import com.linkwechat.domain.wecom.vo.customer.WeFollowUserListVo;
import com.linkwechat.domain.wecom.vo.customer.transfer.WeTransferCustomerVo;
import com.linkwechat.fegin.QwCustomerClient;
import com.linkwechat.mapper.WeCustomerMapper;
import com.linkwechat.service.*;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service
public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCustomer> implements IWeCustomerService {
@Autowired
private QwCustomerClient qwCustomerClient;
@Autowired
private IWeFlowerCustomerTagRelService iWeFlowerCustomerTagRelService;
@Autowired
private IWeTagService iWeTagService;
@Autowired
private IWeCustomerTrajectoryService iWeCustomerTrajectoryService;
@Autowired
private IWeAllocateCustomerService iWeAllocateCustomerService;
@Autowired
@Lazy
private IWeGroupService iWeGroupService;
@Autowired
private RabbitMQSettingConfig rabbitMQSettingConfig;
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
private IWeMessagePushService iWeMessagePushService;
@Autowired
private IWeCustomerSeasService iWeCustomerSeasService;
@Autowired
private IWeCustomerInfoExpandService iWeCustomerInfoExpandService;
@Autowired
@Lazy
private IWeFissionService iWeFissionService;
@Override
public List<WeCustomersVo> findWeCustomerList(WeCustomersQuery weCustomersQuery, PageDomain pageDomain) {
List<WeCustomersVo> weCustomersVos = new ArrayList<>();
List<String> ids = this.baseMapper.findWeCustomerListIds(weCustomersQuery, pageDomain);
if (CollectionUtil.isNotEmpty(ids)) {
weCustomersVos = this.baseMapper.findWeCustomerList(ids);
}
return weCustomersVos;
}
@Override
public TableDataInfo<List<WeCustomersVo>> findWeCustomerListByApp(WeCustomersQuery weCustomersQuery, PageDomain pageDomain) {
TableDataInfo<List<WeCustomersVo>> tableDataInfo = new TableDataInfo<>();
tableDataInfo.setCode(HttpStatus.SUCCESS);
if (weCustomersQuery.getDataScope()) {//这里指的全部数据,是角色的那些数据
tableDataInfo.setRows(
this.findWeCustomerList(weCustomersQuery, pageDomain)
);
tableDataInfo.setTotal(
this.countWeCustomerList(weCustomersQuery)
);
} else {//个人数据
weCustomersQuery.setFirstUserId(
SecurityUtils.getLoginUser().getSysUser().getWeUserId()
);
List<String> customerIds = this.baseMapper.findWeCustomerListIdsByApp(weCustomersQuery, pageDomain);
if (CollectionUtil.isNotEmpty(customerIds)) {
tableDataInfo.setRows(
this.baseMapper.findWeCustomerList(customerIds)
);
tableDataInfo.setTotal(
this.countWeCustomerListByApp(weCustomersQuery)
);
}
}
List<WeCustomersVo> rows = tableDataInfo.getRows();
if (CollectionUtil.isEmpty(rows)) {
tableDataInfo.setRows(new ArrayList<>());
}
return tableDataInfo;
}
@Override
public long countWeCustomerList(WeCustomersQuery weCustomersQuery) {
return this.baseMapper.countWeCustomerList(weCustomersQuery);
}
@Override
public long countWeCustomerListByApp(WeCustomersQuery weCustomersQuery) {
return this.baseMapper.countWeCustomerListByApp(weCustomersQuery);
}
@Override
public long noRepeatCountCustomer(WeCustomersQuery weCustomersQuery) {
return this.baseMapper.noRepeatCountCustomer(weCustomersQuery);
}
@Override
@SynchRecord(synchType = SynchRecordConstants.SYNCH_CUSTOMER)
public void synchWeCustomer() {
LoginUser loginUser = SecurityUtils.getLoginUser();
rabbitTemplate.convertAndSend(rabbitMQSettingConfig.getWeSyncEx(), rabbitMQSettingConfig.getWeCustomerRk(), JSONObject.toJSONString(loginUser));
}
@Override
@Async
public void synchWeCustomerHandler(String msg) {
LoginUser loginUser = JSONObject.parseObject(msg, LoginUser.class);
SecurityContextHolder.setCorpId(loginUser.getCorpId());
SecurityContextHolder.setUserName(loginUser.getUserName());
SecurityContextHolder.setUserId(String.valueOf(loginUser.getSysUser().getUserId()));
SecurityContextHolder.setUserType(loginUser.getUserType());
WeFollowUserListVo followUserList = qwCustomerClient.getFollowUserList(new WeBaseQuery()).getData();
if (null != followUserList && CollectionUtil.isNotEmpty(followUserList.getFollowUser())) {
this.synchWe
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
LinkWeChat 是基于企业微信的开源 SCRM 系统,采用主流的 Java 微服务架构,是企业私域流量管理与营销的综合解决方案,助力企业提高客户运营效率,强化营销能力,拓展盈利空间。
资源推荐
资源详情
资源评论
收起资源包目录
基于企业微信的开源 SCRM 系统,采用主流的 Java 微服务架构 (1835个子文件)
.gitignore 156B
jump.html 7KB
com.linkwechat.scheduler.processor.IPowerJobProcessor 0B
WeCustomerServiceImpl.java 55KB
WeErrorCodeEnum.java 45KB
WeMaterialServiceImpl.java 43KB
SysUserServiceImpl.java 34KB
WeFormSurveyStatisticsController.java 31KB
WeLxQrCodeServiceImpl.java 31KB
ExcelUtil.java 30KB
WeProductAnalyzeController.java 28KB
ImageUtils.java 27KB
WeRedEnvelopesServiceImpl.java 27KB
WeMomentsServiceImpl.java 27KB
WeFissionServiceImpl.java 26KB
WeLiveServiceImpl.java 26KB
WeGroupMessageTemplateServiceImpl.java 25KB
Convert.java 25KB
Convert.java 24KB
WeGroupServiceImpl.java 21KB
WeProductServiceImpl.java 20KB
WeProductOrderServiceImpl.java 20KB
WeCustomerTrajectoryServiceImpl.java 20KB
HTMLFilter.java 19KB
WeRedEnvelopesController.java 19KB
WeQrCodeServiceImpl.java 19KB
WeLeaveUserServiceImpl.java 19KB
WeContentViewRecordServiceImpl.java 19KB
WeCustomerClient.java 18KB
WeMaterialController.java 18KB
WeStoreCodeController.java 18KB
DateUtils.java 18KB
SysUserController.java 17KB
WePresTagGroupTaskServiceImpl.java 17KB
WeStrategicCrowdServiceImpl.java 16KB
FileUploadUtils.java 16KB
CrowdAttributesServiceImpl.java 16KB
RabbitMQConfig.java 15KB
UUID.java 15KB
UUID.java 15KB
QwCustomerController.java 15KB
StringUtils.java 14KB
ReflectUtils.java 14KB
WeContentSendRecordServiceImpl.java 14KB
WeTagGroupServiceImpl.java 13KB
SysDeptServiceImpl.java 13KB
StringUtils.java 13KB
WeCommunityNewGroupServiceImpl.java 12KB
WeOperationCenterController.java 12KB
SysRoleServiceImpl.java 12KB
FileUtils.java 12KB
RedisService.java 12KB
SysMenuServiceImpl.java 12KB
WeShortLinkServiceImpl.java 12KB
WeFormSurveyStatisticsServiceImpl.java 11KB
WxCryptUtil.java 11KB
QwCustomerClient.java 11KB
FinanceService.java 11KB
WeGroupCodeServiceImpl.java 11KB
WeGroupSopServiceImpl.java 11KB
FileUploadUtils.java 11KB
IWeOperationCenterServiceImpl.java 11KB
QwKfController.java 11KB
WeCategoryServiceImpl.java 10KB
AccessLogFilter.java 10KB
QwCustomerServiceImpl.java 10KB
WeAppMsgQuery.java 10KB
PlaceholderResolver.java 10KB
BeanUtils.java 10KB
RabbitMQSettingConfig.java 9KB
WeFormSurveyCatalogueServiceImpl.java 9KB
WeCustomerController.java 9KB
WeCustomerSeasController.java 9KB
SysUser.java 9KB
WeProductOrderController.java 9KB
Base64.java 9KB
HttpUtils.java 9KB
AuthLogic.java 9KB
WeShortLinkStatServiceImpl.java 9KB
WeFormSurveySiteStatsTask.java 9KB
WeAgentMsgServiceImpl.java 9KB
Base64.java 9KB
WeContentTalkController.java 8KB
ReflectionUtils.java 8KB
IpUtils.java 8KB
QwAccessTokenServiceImpl.java 8KB
WeCustomerPortraitController.java 8KB
WeLiveTipServiceImpl.java 8KB
LinkWeChatConfig.java 8KB
IQwCustomerService.java 8KB
WeMessagePushServiceImpl.java 8KB
SysLoginService.java 8KB
WeLiveController.java 8KB
WeProductOrderSyncTask.java 8KB
WeMsgTemplateQuery.java 8KB
WeStoreCodeServiceImpl.java 8KB
WeAgentInfoServiceImpl.java 8KB
ServletUtils.java 7KB
QREncode.java 7KB
QwKfClient.java 7KB
共 1835 条
- 1
- 2
- 3
- 4
- 5
- 6
- 19
资源评论
- weixin_453956132023-08-07资源太好了,解决了我当下遇到的难题,抱紧大佬的大腿~
Java程序员-张凯
- 粉丝: 1w+
- 资源: 7361
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于JavaFX和MySQL的医院挂号管理系统.zip
- (源码)基于IdentityServer4和Finbuckle.MultiTenant的多租户身份认证系统.zip
- (源码)基于Spring Boot和Vue3+ElementPlus的后台管理系统.zip
- (源码)基于C++和Qt框架的dearoot配置管理系统.zip
- (源码)基于 .NET 和 EasyHook 的虚拟文件系统.zip
- (源码)基于Python的金融文档智能分析系统.zip
- (源码)基于Java的医药管理系统.zip
- (源码)基于Java和MySQL的学生信息管理系统.zip
- (源码)基于ASP.NET Core的零售供应链管理系统.zip
- (源码)基于PythonSpleeter的戏曲音频处理系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功