|
|
@@ -52,14 +52,14 @@ public class SysCustomerDataPrivateService {
|
|
|
|
|
|
private final SysCustomerOperLogService sysCustomerOperLogService;
|
|
|
|
|
|
- private final SysCustomerDataPermissionService permissionService;
|
|
|
+ private final SysUserGroupRelationMapper sysUserGroupRelationMapper;
|
|
|
|
|
|
/**
|
|
|
* 查询私域(我的)客户页面顶部筛选条件数据
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- public SysCustomerPrivateSelectBO queryHeadSelectPrivateData() throws BusinessException{
|
|
|
+ public SysCustomerPrivateSelectBO queryHeadSelectPrivateData() throws BusinessException {
|
|
|
// permissionService.publicPrivateCustomerPermission();
|
|
|
SysCustomerPrivateSelectBO resultData = SysCustomerPrivateSelectBO.builder().build();
|
|
|
//类型
|
|
|
@@ -67,7 +67,7 @@ public class SysCustomerDataPrivateService {
|
|
|
//学段信息
|
|
|
resultData.setStageData(sysCustomerUserCommonService.handleStageData());
|
|
|
//省市信息
|
|
|
- SysCustomerSelectBO sysCustomerSelectBO = sysCustomerUserCommonService.querySelectDataByType1( true);
|
|
|
+ SysCustomerSelectBO sysCustomerSelectBO = sysCustomerUserCommonService.querySelectDataByType3(true);
|
|
|
if (sysCustomerSelectBO != null) {
|
|
|
resultData.setRegionData(sysCustomerSelectBO.getRegionData());
|
|
|
resultData.setGroupData(sysCustomerSelectBO.getGroupData());
|
|
|
@@ -80,39 +80,61 @@ public class SysCustomerDataPrivateService {
|
|
|
/**
|
|
|
* 后台管理-我的客户(学校)分页列表
|
|
|
*/
|
|
|
- public PageResult<SysCustomerDataPrivateBO> adminList(AdminSysCustomerDataPrivateListDTO dto) throws BusinessException{
|
|
|
-// permissionService.publicPrivateCustomerPermission();
|
|
|
+ public PageResult<SysCustomerDataPrivateBO> adminList(AdminSysCustomerDataPrivateListDTO dto) throws BusinessException {
|
|
|
List<Long> userIds = Lists.newArrayList();
|
|
|
+ List<Long> groupIds = Lists.newArrayList();
|
|
|
+ List<Long> provinceIds = Lists.newArrayList();
|
|
|
+ List<Long> cityIds = Lists.newArrayList();
|
|
|
+ if (!UserContextHolder.getUserContext().getRoles().contains("Admin")) {
|
|
|
+ userIds.add(UserContextHolder.getUserId());
|
|
|
+ //查询用户的小组信息
|
|
|
+ List<SysUserGroupRelationEntity> userGroupRelationList = sysUserGroupRelationMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<SysUserGroupRelationEntity>()
|
|
|
+ .select(
|
|
|
+ SysUserGroupRelationEntity::getId,
|
|
|
+ SysUserGroupRelationEntity::getProvinceId,
|
|
|
+ SysUserGroupRelationEntity::getCityId,
|
|
|
+ SysUserGroupRelationEntity::getGroupId
|
|
|
+ )
|
|
|
+ .eq(SysUserGroupRelationEntity::getUserId, UserContextHolder.getUserId())
|
|
|
+ );
|
|
|
+ if (CollUtil.isEmpty(userGroupRelationList)) {
|
|
|
+ throw new BusinessException("用户小组信息不存在");
|
|
|
+ }
|
|
|
+ provinceIds.addAll(
|
|
|
+ userGroupRelationList.stream()
|
|
|
+ .map(SysUserGroupRelationEntity::getProvinceId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct().toList());
|
|
|
+ cityIds.addAll(
|
|
|
+ userGroupRelationList.stream()
|
|
|
+ .map(SysUserGroupRelationEntity::getCityId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct().toList());
|
|
|
+ groupIds.addAll(
|
|
|
+ userGroupRelationList.stream()
|
|
|
+ .map(SysUserGroupRelationEntity::getGroupId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .distinct().toList());
|
|
|
+ }
|
|
|
if (dto.getUserId() != null) {
|
|
|
+ userIds.clear();
|
|
|
userIds.add(dto.getUserId());
|
|
|
- }else {
|
|
|
- if(!UserContextHolder.getUserContext().getRoles().contains("Admin")){
|
|
|
- userIds.add(UserContextHolder.getUserId());
|
|
|
- }
|
|
|
}
|
|
|
- List<Long> groupIds = Lists.newArrayList();
|
|
|
if (dto.getGroupId() != null) {
|
|
|
+ groupIds.clear();
|
|
|
groupIds.add(dto.getGroupId());
|
|
|
}
|
|
|
- List<Long> cityIds = Lists.newArrayList();
|
|
|
- if (dto.getProvinceId() != null) {
|
|
|
- cityIds.addAll(sysCustomerUserCommonService.queryUserCityIds(dto.getProvinceId()));
|
|
|
- List<BindUserBO> bindUserBOS = sysCustomerUserCommonService.queryBindUserListByCityId(cityIds);
|
|
|
- if (CollUtil.isNotEmpty(bindUserBOS)) {
|
|
|
- if (CollUtil.isEmpty(userIds)) {
|
|
|
- userIds.addAll(
|
|
|
- bindUserBOS.stream()
|
|
|
- .map(BindUserBO::getId).toList());
|
|
|
- }
|
|
|
|
|
|
- if (CollUtil.isEmpty(groupIds)) {
|
|
|
- groupIds.addAll(
|
|
|
- bindUserBOS.stream()
|
|
|
- .map(BindUserBO::getGroupId).distinct().toList());
|
|
|
- }
|
|
|
- }
|
|
|
+ if (dto.getProvinceId() != null) {
|
|
|
+ provinceIds.clear();
|
|
|
+ provinceIds.add(dto.getProvinceId());
|
|
|
}
|
|
|
|
|
|
+ if (dto.getCityId() != null) {
|
|
|
+ cityIds.clear();
|
|
|
+ cityIds.add(dto.getCityId());
|
|
|
+ }
|
|
|
Page<SysCustomerDataEntity> entityPage = sysCustomerDataMapper.selectPage(
|
|
|
new Page<>(dto.getPageNum(), dto.getPageSize()),
|
|
|
new QueryWrapper<SysCustomerDataEntity>()
|
|
|
@@ -122,19 +144,20 @@ public class SysCustomerDataPrivateService {
|
|
|
//存量客户判断
|
|
|
.in(dto.getTypeId() != null && dto.getTypeId().equals(2) && CollUtil.isNotEmpty(userIds), SysCustomerDataEntity::getSuccessUserId, userIds)
|
|
|
//查询存量客户判断
|
|
|
- .eq(dto.getTypeId() != null && dto.getTypeId().equals(2) , SysCustomerDataEntity::getSuccessStatus, 1)
|
|
|
+ .eq(dto.getTypeId() != null && dto.getTypeId().equals(2), SysCustomerDataEntity::getSuccessStatus, 1)
|
|
|
//首单客户判断
|
|
|
- .in(dto.getTypeId() != null && dto.getTypeId().equals(1)&& CollUtil.isNotEmpty(userIds), SysCustomerDataEntity::getClaimUserId, userIds)
|
|
|
- .in(dto.getTypeId()==null && CollUtil.isNotEmpty(userIds), SysCustomerDataEntity::getClaimUserId, userIds)
|
|
|
+ .in(dto.getTypeId() != null && dto.getTypeId().equals(1) && CollUtil.isNotEmpty(userIds), SysCustomerDataEntity::getClaimUserId, userIds)
|
|
|
+ .eq(dto.getTypeId() != null && dto.getTypeId().equals(1), SysCustomerDataEntity::getSuccessStatus, 0)
|
|
|
+ .in(dto.getTypeId() == null && CollUtil.isNotEmpty(userIds), SysCustomerDataEntity::getClaimUserId, userIds)
|
|
|
// 学段id(param_base_data表主id)
|
|
|
.eq(Objects.nonNull(dto.getStageId()), SysCustomerDataEntity::getStageId, dto.getStageId())
|
|
|
// 省份id(省份表主id)
|
|
|
- .eq(Objects.nonNull(dto.getProvinceId()), SysCustomerDataEntity::getProvinceId, dto.getProvinceId())
|
|
|
+ .in(CollUtil.isNotEmpty(provinceIds), SysCustomerDataEntity::getProvinceId, provinceIds)
|
|
|
// 城市id(不为空时)
|
|
|
- .eq(Objects.nonNull(dto.getCityId()), SysCustomerDataEntity::getCityId, dto.getCityId())
|
|
|
+ .in(CollUtil.isNotEmpty(cityIds), SysCustomerDataEntity::getCityId, cityIds)
|
|
|
// 城市id(为空时)
|
|
|
- .in(Objects.isNull(dto.getCityId())&&CollUtil.isNotEmpty(cityIds), SysCustomerDataEntity::getCityId, cityIds)
|
|
|
- .in(CollUtil.isNotEmpty(groupIds),SysCustomerDataEntity::getClaimUserGroupId, groupIds)
|
|
|
+ .in(Objects.isNull(dto.getCityId()) && CollUtil.isNotEmpty(cityIds), SysCustomerDataEntity::getCityId, cityIds)
|
|
|
+ .in(CollUtil.isNotEmpty(groupIds), SysCustomerDataEntity::getClaimUserGroupId, groupIds)
|
|
|
//必须是已认领的,不认领的是不能出现在我的客户里面的,所有必须加这个过滤,不管是存量还是首单客户都要加这个参数
|
|
|
.eq(SysCustomerDataEntity::getClaimStatus, 1)
|
|
|
|
|
|
@@ -151,7 +174,7 @@ public class SysCustomerDataPrivateService {
|
|
|
* @param dto
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void adminUpdateCustomerData(AdminSysCustomerDataInsertOrUpdateDTO dto) throws BusinessException{
|
|
|
+ public void adminUpdateCustomerData(AdminSysCustomerDataInsertOrUpdateDTO dto) throws BusinessException {
|
|
|
// permissionService.publicPrivateCustomerPermission();
|
|
|
sysCustomerDataService.adminUpdate(dto);
|
|
|
}
|
|
|
@@ -163,7 +186,7 @@ public class SysCustomerDataPrivateService {
|
|
|
* @param customerId
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void returnCustomerPublicData(Long customerId) throws BusinessException{
|
|
|
+ public void returnCustomerPublicData(Long customerId) throws BusinessException {
|
|
|
sysCustomerDataService.returnCustomerData(customerId);
|
|
|
}
|
|
|
|
|
|
@@ -175,7 +198,7 @@ public class SysCustomerDataPrivateService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void adminInsertCustomerPerson(AdminSysCustomerPersonInsertOrUpdateDTO dto) throws BusinessException{
|
|
|
+ public void adminInsertCustomerPerson(AdminSysCustomerPersonInsertOrUpdateDTO dto) throws BusinessException {
|
|
|
// permissionService.publicPrivateCustomerPermission();
|
|
|
sysCustomerPersonService.adminInsert(dto);
|
|
|
}
|
|
|
@@ -187,7 +210,7 @@ public class SysCustomerDataPrivateService {
|
|
|
* @param dto
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void adminUpdateCustomerPerson(AdminSysCustomerPersonInsertOrUpdateDTO dto) throws BusinessException{
|
|
|
+ public void adminUpdateCustomerPerson(AdminSysCustomerPersonInsertOrUpdateDTO dto) throws BusinessException {
|
|
|
// permissionService.publicPrivateCustomerPermission();
|
|
|
sysCustomerPersonService.adminUpdate(dto);
|
|
|
}
|
|
|
@@ -198,7 +221,7 @@ public class SysCustomerDataPrivateService {
|
|
|
* @param id
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void adminDeleteCustomerPerson(Long id) throws BusinessException{
|
|
|
+ public void adminDeleteCustomerPerson(Long id) throws BusinessException {
|
|
|
// permissionService.publicPrivateCustomerPermission();
|
|
|
sysCustomerPersonService.adminDelete(id);
|
|
|
}
|
|
|
@@ -207,7 +230,7 @@ public class SysCustomerDataPrivateService {
|
|
|
/**
|
|
|
* 查询我的客户联系人
|
|
|
*/
|
|
|
- public List<SysCustomerPersonBO> adminListCustomerPerson(CustomerPersonReqDTO dto) throws BusinessException{
|
|
|
+ public List<SysCustomerPersonBO> adminListCustomerPerson(CustomerPersonReqDTO dto) throws BusinessException {
|
|
|
// permissionService.publicPrivateCustomerPermission();
|
|
|
|
|
|
return sysCustomerPersonService.adminList(dto);
|
|
|
@@ -220,7 +243,7 @@ public class SysCustomerDataPrivateService {
|
|
|
* @param customerId
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<TransferUserReqBO> queryTransferUser(Long customerId) throws BusinessException{
|
|
|
+ public List<TransferUserReqBO> queryTransferUser(Long customerId) throws BusinessException {
|
|
|
|
|
|
// permissionService.publicPrivateCustomerPermission();
|
|
|
return sysCustomerDataService.queryTransferUser(customerId);
|
|
|
@@ -231,7 +254,7 @@ public class SysCustomerDataPrivateService {
|
|
|
*
|
|
|
* @param dto
|
|
|
*/
|
|
|
- public void transferUser(TransferUserReqDTO dto) throws BusinessException{
|
|
|
+ public void transferUser(TransferUserReqDTO dto) throws BusinessException {
|
|
|
// permissionService.publicPrivateCustomerPermission();
|
|
|
sysCustomerDataService.transferUser(dto);
|
|
|
}
|
|
|
@@ -242,25 +265,19 @@ public class SysCustomerDataPrivateService {
|
|
|
*
|
|
|
* @param dto
|
|
|
*/
|
|
|
- public SysCustomerDetailBO queryCustomerDetail(AdminSysCustomerFollowReqDTO dto) throws BusinessException{
|
|
|
-// permissionService.publicPrivateCustomerPermission();
|
|
|
-
|
|
|
+ public SysCustomerDetailBO queryCustomerDetail(AdminSysCustomerFollowReqDTO dto) throws BusinessException {
|
|
|
SysCustomerDetailBO detailBO = SysCustomerDetailBO.builder().build();
|
|
|
- dto.setUserId(UserContextHolder.getUserId());
|
|
|
- if(UserContextHolder.getUserContext().getRoles().contains("Admin")){
|
|
|
- SysCustomerDataEntity entity =
|
|
|
- sysCustomerDataMapper.selectOne(
|
|
|
- new LambdaQueryWrapper<>(SysCustomerDataEntity.class)
|
|
|
- .select(
|
|
|
- SysCustomerDataEntity::getId,
|
|
|
- SysCustomerDataEntity::getClaimUserId
|
|
|
- )
|
|
|
- .eq(SysCustomerDataEntity::getId,dto.getCustomerId())
|
|
|
- );
|
|
|
- if(entity == null){
|
|
|
- throw new BusinessException(400, "参数错误,客户不存在");
|
|
|
- }
|
|
|
- dto.setUserId(entity.getClaimUserId());
|
|
|
+ SysCustomerDataEntity entity =
|
|
|
+ sysCustomerDataMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<>(SysCustomerDataEntity.class)
|
|
|
+ .select(
|
|
|
+ SysCustomerDataEntity::getId,
|
|
|
+ SysCustomerDataEntity::getClaimUserId
|
|
|
+ )
|
|
|
+ .eq(SysCustomerDataEntity::getId, dto.getCustomerId())
|
|
|
+ );
|
|
|
+ if (entity == null) {
|
|
|
+ throw new BusinessException(400, "参数错误,客户不存在");
|
|
|
}
|
|
|
//顶部筛选条件数据
|
|
|
SysCustomerFollowHistorySelectBO publicCustomerSelectData = sysCustomerDataFollowService.queryCustomerFollowSelectCommonData(dto.getCustomerId(), dto.getUserId());
|
|
|
@@ -270,11 +287,11 @@ public class SysCustomerDataPrivateService {
|
|
|
detailBO.setDataPageList(dataPageList);
|
|
|
detailBO.setProductCount(0);
|
|
|
//跟进状态查询
|
|
|
- List<CustomerStatusOverViewBO> statusOverViewData = sysCustomerFollowService.queryStatusOverViewData(dto.getCustomerId(),dto.getUserId());
|
|
|
+ List<CustomerStatusOverViewBO> statusOverViewData = sysCustomerFollowService.queryStatusOverViewData(dto.getCustomerId(), dto.getUserId());
|
|
|
detailBO.setStatusOverviewData(statusOverViewData);
|
|
|
|
|
|
//跟进产品信息总览
|
|
|
- List<CustomerProductOverViewBO> overViewBOS = sysCustomerFollowService.queryProductOverViewData(dto.getCustomerId(),dto.getUserId());
|
|
|
+ List<CustomerProductOverViewBO> overViewBOS = sysCustomerFollowService.queryProductOverViewData(dto.getCustomerId(), dto.getUserId());
|
|
|
if (CollUtil.isNotEmpty(overViewBOS)) {
|
|
|
int productCount = overViewBOS.stream().map(CustomerProductOverViewBO::getCount).reduce(0, Integer::sum);
|
|
|
detailBO.setProductCount(productCount);
|
|
|
@@ -297,40 +314,14 @@ public class SysCustomerDataPrivateService {
|
|
|
* 操作日志列表查询
|
|
|
*/
|
|
|
public SysCustomerOperLogDataBO queryOperLogData(AdminSysCustomerOperLogListDTO dto) {
|
|
|
-// permissionService.publicPrivateCustomerPermission();
|
|
|
List<Long> userIds = Lists.newArrayList();
|
|
|
- if (dto.getOperUserId() != null) {
|
|
|
- userIds.add(dto.getOperUserId());
|
|
|
- }else {
|
|
|
- if(!UserContextHolder.getUserContext().getRoles().contains("Admin")){
|
|
|
- userIds.add(UserContextHolder.getUserId());
|
|
|
- }
|
|
|
+ if (!UserContextHolder.getUserContext().getRoles().contains("Admin")) {
|
|
|
+ userIds.add(UserContextHolder.getUserId());
|
|
|
}
|
|
|
List<Long> groupIds = Lists.newArrayList();
|
|
|
if (dto.getGroupId() != null) {
|
|
|
groupIds.add(dto.getGroupId());
|
|
|
}
|
|
|
-// SysCustomerSelectBO selectBO = sysCustomerUserCommonService.querySelectDataByType1( true);
|
|
|
-// if (selectBO != null && CollUtil.isNotEmpty(selectBO.getRegionData())) {
|
|
|
-// List<Long> cityIds = Lists.newArrayList();
|
|
|
-// selectBO.getRegionData()
|
|
|
-// .forEach(provinceRegion ->
|
|
|
-// provinceRegion.getSubData()
|
|
|
-// .forEach(city -> cityIds.add(city.getId())));
|
|
|
-// List<BindUserBO> bindUserBOS = sysCustomerUserCommonService.queryBindUserListByCityId(cityIds);
|
|
|
-// if (CollUtil.isNotEmpty(bindUserBOS)) {
|
|
|
-// if (CollUtil.isEmpty(userIds)) {
|
|
|
-// userIds.addAll(
|
|
|
-// bindUserBOS.stream()
|
|
|
-// .map(BindUserBO::getId).toList());
|
|
|
-// }
|
|
|
-// if (CollUtil.isEmpty(groupIds)) {
|
|
|
-// groupIds.addAll(
|
|
|
-// bindUserBOS.stream()
|
|
|
-// .map(BindUserBO::getGroupId).distinct().toList());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
return sysCustomerOperLogService.adminList(dto, userIds, groupIds, true, false);
|
|
|
}
|
|
|
|
|
|
@@ -366,7 +357,7 @@ public class SysCustomerDataPrivateService {
|
|
|
.map(SysCustomerDataEntity::getClaimUserGroupId)
|
|
|
.filter(Objects::nonNull).distinct().toList();
|
|
|
List<SysGroupEntity> groupEntityList = Lists.newArrayList();
|
|
|
- if(CollUtil.isNotEmpty(groupIds)){
|
|
|
+ if (CollUtil.isNotEmpty(groupIds)) {
|
|
|
groupEntityList.addAll(sysGroupMapper.selectByIds(groupIds));
|
|
|
}
|
|
|
//查询学段
|
|
|
@@ -387,11 +378,9 @@ public class SysCustomerDataPrivateService {
|
|
|
SysCustomerFollowEntity::getClaimDatetime
|
|
|
)
|
|
|
.in(SysCustomerFollowEntity::getCustomerId, entityList.stream().map(SysCustomerDataEntity::getId).toList())
|
|
|
- .in(CollUtil.isNotEmpty(groupIds),SysCustomerFollowEntity::getClaimUserGroupId, groupIds)
|
|
|
- .eq(SysCustomerFollowEntity::getClaimUserId, UserContextHolder.getUserId())
|
|
|
+// .in(!UserContextHolder.getUserContext().getRoles().contains("Admin") && CollUtil.isNotEmpty(groupIds), SysCustomerFollowEntity::getClaimUserGroupId, groupIds)
|
|
|
+ .eq(!UserContextHolder.getUserContext().getRoles().contains("Admin"), SysCustomerFollowEntity::getClaimUserId, UserContextHolder.getUserId())
|
|
|
);
|
|
|
-
|
|
|
-
|
|
|
// 深拷贝
|
|
|
List<SysCustomerDataPrivateBO> ret = new ArrayList<>(entityList.size());
|
|
|
entityList.forEach(
|
|
|
@@ -410,15 +399,19 @@ public class SysCustomerDataPrivateService {
|
|
|
.ifPresent(e -> bo.setStageName(e.getTitle()));
|
|
|
}
|
|
|
if (CollUtil.isNotEmpty(followEntityList)) {
|
|
|
- List<SysCustomerFollowEntity> userFollowEntityList =
|
|
|
- followEntityList.stream()
|
|
|
- .filter(x -> x.getCustomerId().equals(entity.getId()))
|
|
|
- .filter(x -> x.getClaimUserGroupId()!=null && x.getClaimUserGroupId().equals(entity.getClaimUserGroupId()))
|
|
|
- .filter(x -> x.getClaimUserId().equals(entity.getClaimUserId()))
|
|
|
- .sorted(Comparator.comparing(SysCustomerFollowEntity::getClaimDatetime).reversed())
|
|
|
- .toList();
|
|
|
- if (CollUtil.isNotEmpty(userFollowEntityList)) {
|
|
|
- bo.setLastFollowDatetime(userFollowEntityList.getFirst().getClaimDatetime());
|
|
|
+ SysCustomerFollowEntity customerFollow = followEntityList.stream()
|
|
|
+ .filter(x -> x.getCustomerId().equals(entity.getId()))
|
|
|
+ .max(Comparator.comparing(SysCustomerFollowEntity::getClaimDatetime))
|
|
|
+ .orElse(null);
|
|
|
+ if(!UserContextHolder.getUserContext().getRoles().contains("Admin")){
|
|
|
+ customerFollow = followEntityList.stream()
|
|
|
+ .filter(x -> x.getCustomerId().equals(entity.getId()))
|
|
|
+ .filter(x -> x.getClaimUserId().equals(UserContextHolder.getUserId()))
|
|
|
+ .max(Comparator.comparing(SysCustomerFollowEntity::getClaimDatetime))
|
|
|
+ .orElse(null);
|
|
|
+ }
|
|
|
+ if (customerFollow!=null) {
|
|
|
+ bo.setLastFollowDatetime(customerFollow.getClaimDatetime());
|
|
|
}
|
|
|
}
|
|
|
ret.add(bo);
|