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.*;
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.enums.message.MessageTypeEnum;
import com.linkwechat.common.enums.*;
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.query.WeAddGroupMessageQuery;
import com.linkwechat.domain.groupmsg.vo.WeGroupMessageExecuteUsertipVo;
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.*;
import com.linkwechat.domain.wecom.query.customer.tag.WeMarkTagQuery;
import com.linkwechat.domain.wecom.query.customer.transfer.WeTransferCustomerQuery;
import com.linkwechat.domain.wecom.vo.WeResultVo;
import com.linkwechat.domain.wecom.vo.customer.*;
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.apache.ibatis.annotations.Param;
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 javax.annotation.Resource;
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;
@Resource
private IWeMessageNotificationService weMessageNotificationService;
@Autowired
private IWeCustomerLinkService iWeCustomerLinkService;
@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 List<WeCustomersVo> findWeCustomerInfoFromWechat(List<String> externalUserids) {
List<WeCustomersVo> weCustomersVos = new ArrayList<>();
if (CollectionUtil.isNotEmpty(externalUserids)) {
List<WeCustomer> weCustomers = this.list(new LambdaQueryWrapper<WeCustomer>()
.in(WeCustomer::getExternalUserid, externalUserids));
externalUserids.stream().forEach(k -> {
WeCustomersVo weCustomersVo = new WeCustomersVo();
weCustomersVo.setCustomerName("@微信客户");
if (CollectionUtil.isNotEmpty(weCustomers)) {
List<WeCustomer> weCustomerss
= weCustomers.stream().filter(item -> item.getExternalUserid().equals(k)).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(weCustomerss)) {
weCustomersVo.setCustomerName(weCustomerss.stream().findFirst().get().getCustomerName());
}
}
weCustomersVo.setExternalUserid(k);
weCustomersVos.add(weCustomersVo);
});
}
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.noR
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
LinkWeChat 是基于企业微信的开源 SCRM 系统,前端采用 vue3 架构,后端采用主流的 Java 微服务架构,是企业私域流量管理与营销的综合解决方案,助力企业提高客户运营效率,强化营销能力,拓展盈利空间。
资源推荐
资源详情
资源评论
收起资源包目录
LinkWeChat 作为唯一 以开源为核心的 私域数智化解决方案提供商,是国内首批基于企业微信的开源SCRM (2000个子文件)
WeCustomerServiceImpl.java 62KB
WeMomentsTaskServiceImpl.java 59KB
WeMaterialServiceImpl.java 55KB
WeQrCodeServiceImpl.java 46KB
WeQiRuleServiceImpl.java 37KB
SysUserServiceImpl.java 34KB
WeFissionServiceImpl.java 31KB
WeTasksServiceImpl.java 30KB
WeGroupServiceImpl.java 29KB
WeRedEnvelopesServiceImpl.java 27KB
WeLiveServiceImpl.java 27KB
WeGroupCodeServiceImpl.java 25KB
RabbitMQConfig.java 24KB
Convert.java 24KB
WeGroupMessageTemplateServiceImpl.java 22KB
WeCustomerTrajectoryServiceImpl.java 21KB
WeCustomerClient.java 20KB
WeProductServiceImpl.java 20KB
WeProductOrderServiceImpl.java 20KB
WeTagGroupServiceImpl.java 20KB
WeContentViewRecordServiceImpl.java 20KB
SysUserController.java 19KB
WeLeaveUserServiceImpl.java 19KB
WeChatMsgQiRuleWeeklyTask.java 19KB
QwCustomerController.java 19KB
WeMomentsInteracteServiceImpl.java 18KB
WeMomentsUserServiceImpl.java 18KB
WeStrategicCrowdServiceImpl.java 16KB
WeSubstituteCustomerOrderServiceImpl.java 16KB
WePresTagGroupTaskServiceImpl.java 15KB
SysDeptServiceImpl.java 15KB
WeStoreCodeServiceImpl.java 15KB
UUID.java 15KB
RabbitMQSettingConfig.java 15KB
CrowdAttributesServiceImpl.java 14KB
WeContentSendRecordServiceImpl.java 14KB
QwCustomerClient.java 14KB
WeMsgAuditTask.java 13KB
StringUtils.java 13KB
WeCommunityNewGroupServiceImpl.java 13KB
WeShortLinkServiceImpl.java 13KB
QwCustomerServiceImpl.java 12KB
IWeOperationCenterServiceImpl.java 12KB
SysMenuServiceImpl.java 12KB
WeFormSurveyCatalogueServiceImpl.java 12KB
SysRoleServiceImpl.java 12KB
WeMomentsCustomerServiceImpl.java 12KB
WeCategoryServiceImpl.java 11KB
AccessLogFilter.java 11KB
WeGroupSopServiceImpl.java 11KB
QwChatMsgQiRuleListener.java 11KB
QwKfController.java 11KB
WeAppMsgQuery.java 10KB
IQwCustomerService.java 10KB
WeChatContactMsgServiceImpl.java 10KB
QwChatMsgAuditListener.java 10KB
WeCustomerLinkCountServiceImpl.java 10KB
SysLoginService.java 10KB
WeChatMsgQiRuleNoticeTask.java 9KB
WeMomentsAttachmentsServiceImpl.java 9KB
SysDeptController.java 9KB
WeMessagePushServiceImpl.java 9KB
AuthLogic.java 9KB
WeShortLinkStatServiceImpl.java 9KB
PromotionType.java 9KB
WeAgentMsgServiceImpl.java 9KB
WeMsgTemplateQuery.java 9KB
WeMsgTlpServiceImpl.java 9KB
Base64.java 9KB
QwCustomerFallbackFactory.java 8KB
QwAccessTokenServiceImpl.java 8KB
IWeCustomerService.java 8KB
WeLiveTipServiceImpl.java 8KB
WeGroupCodeTask.java 8KB
WeMomentsTaskStatisticServiceImpl.java 8KB
WeFormSurveyAnswerServiceImpl.java 8KB
WeCorpAccount.java 8KB
WeProductOrderSyncTask.java 8KB
WeKeywordGroupViewCountServiceImpl.java 8KB
WeAgentInfoServiceImpl.java 8KB
WeCustomerLinkServiceImpl.java 8KB
QREncode.java 7KB
QwKfClient.java 7KB
WeGroupRobotMsgServiceImpl.java 7KB
LogAspect.java 7KB
WeQrAddQuery.java 7KB
AuthFilter.java 7KB
WeLive.java 7KB
WeProductOrderStatisticsDataTask.java 7KB
WeKeyWordGroupSubServiceImpl.java 7KB
FinanceService.java 7KB
SysLoginController.java 7KB
WeEmpleCodeServiceImpl.java 7KB
SysRoleController.java 7KB
QwDataSyncListener.java 7KB
WeGroupChatStatisticTask.java 7KB
WeAddMsgTemplateQuery.java 6KB
WeDefaultQrCodeMsgServiceImpl.java 6KB
GlobalExceptionHandler.java 6KB
TokenService.java 6KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6833
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功