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.base.Joiner;
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.*;
import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.DateUtils;
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.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.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.linkwechat.common.utils.SecurityUtils;
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
private IWeGroupService iWeGroupService;
@Autowired
private RabbitMQSettingConfig rabbitMQSettingConfig;
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
private IWeMessagePushService iWeMessagePushService;
@Autowired
private IWeCustomerSeasService iWeCustomerSeasService;
@Autowired
private IWeCustomerInfoExpandService iWeCustomerInfoExpandService;
@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.synchWeCustomerByAddIds(followUserList.getFollowUser());
}
}
/**
* 通过跟进人id同步客户
* @param followUserIds
* @return
*/
@Override
public void synchWeCustomerByAddIds(List<String> followUserIds){
if(CollectionUtil.isNotEmpty(followUserIds)){
List<List<String>> partition = Lists.part
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
link-wechat-master.zip (1771个子文件)
.gitignore 156B
jump.html 7KB
com.linkwechat.scheduler.processor.IPowerJobProcessor 0B
WeCustomerServiceImpl.java 53KB
WeErrorCodeEnum.java 45KB
WeMaterialServiceImpl.java 42KB
SysUserServiceImpl.java 34KB
WeFormSurveyStatisticsController.java 31KB
ExcelUtil.java 30KB
WeTaskFissionServiceImpl.java 30KB
WeProductAnalyzeController.java 28KB
ImageUtils.java 27KB
WeMomentsServiceImpl.java 27KB
WeLiveServiceImpl.java 26KB
WeRedEnvelopesServiceImpl.java 25KB
WeGroupMessageTemplateServiceImpl.java 25KB
Convert.java 25KB
Convert.java 24KB
WeGroupServiceImpl.java 20KB
WeProductServiceImpl.java 20KB
WeProductOrderServiceImpl.java 20KB
WeCustomerTrajectoryServiceImpl.java 20KB
HTMLFilter.java 19KB
WeRedEnvelopesController.java 19KB
QwWelcomeMsgListener.java 19KB
WeQrCodeServiceImpl.java 19KB
WeLeaveUserServiceImpl.java 19KB
WeContentViewRecordServiceImpl.java 19KB
WeCustomerClient.java 18KB
WeMaterialController.java 18KB
DateUtils.java 18KB
WeStoreCodeController.java 18KB
SysUserController.java 17KB
WePresTagGroupTaskServiceImpl.java 17KB
WeStrategicCrowdServiceImpl.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
FileUploadUtils.java 14KB
WeTagGroupServiceImpl.java 13KB
SysDeptServiceImpl.java 13KB
StringUtils.java 13KB
WeCommunityNewGroupServiceImpl.java 12KB
WeOperationCenterController.java 12KB
FileUtils.java 12KB
SysRoleServiceImpl.java 12KB
RedisService.java 12KB
SysMenuServiceImpl.java 12KB
WeShortLinkServiceImpl.java 12KB
WeFormSurveyStatisticsServiceImpl.java 11KB
WxCryptUtil.java 11KB
QwCustomerClient.java 11KB
FinanceService.java 11KB
WeGroupSopServiceImpl.java 11KB
FileUploadUtils.java 11KB
IWeOperationCenterServiceImpl.java 11KB
QwKfController.java 11KB
QwCustomerServiceImpl.java 10KB
WeAppMsgQuery.java 10KB
PlaceholderResolver.java 10KB
WeCategoryServiceImpl.java 10KB
WeGroupCodeServiceImpl.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
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
SysDeptController.java 7KB
WeGroupRobotMsgServiceImpl.java 7KB
共 1771 条
- 1
- 2
- 3
- 4
- 5
- 6
- 18
资源评论
m0_72731342
- 粉丝: 2
- 资源: 1832
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功