|
|
@@ -1,22 +1,17 @@
|
|
|
package com.jtzx.crm.module.sys.service;
|
|
|
|
|
|
|
|
|
-import cc.uncarbon.framework.core.context.UserContextHolder;
|
|
|
-import cc.uncarbon.framework.core.exception.BusinessException;
|
|
|
-import cc.uncarbon.framework.core.page.PageParam;
|
|
|
import cc.uncarbon.framework.core.page.PageResult;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.text.CharSequenceUtil;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.jtzx.crm.module.sys.entity.SysCustomerDataEntity;
|
|
|
-import com.jtzx.crm.module.sys.entity.SysCustomerFollowEntity;
|
|
|
import com.jtzx.crm.module.sys.entity.SysParamBaseDataEntity;
|
|
|
import com.jtzx.crm.module.sys.mapper.SysCustomerDataMapper;
|
|
|
-import com.jtzx.crm.module.sys.mapper.SysCustomerFollowMapper;
|
|
|
import com.jtzx.crm.module.sys.mapper.SysParamBaseDataMapper;
|
|
|
import com.jtzx.crm.module.sys.model.request.*;
|
|
|
import com.jtzx.crm.module.sys.model.response.*;
|
|
|
@@ -55,12 +50,15 @@ public class SysCustomerDataPublicService {
|
|
|
|
|
|
private final SysCustomerOperLogService sysCustomerOperLogService;
|
|
|
|
|
|
+ private final SysCustomerDataPermissionService permissionService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询公海客户页面顶部筛选条件数据
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
public SysCustomerPublicSelectBO queryHeadSelectData() {
|
|
|
+ permissionService.publicPrivateCustomerPermission();
|
|
|
//返回数据对象
|
|
|
SysCustomerPublicSelectBO resultData = SysCustomerPublicSelectBO.builder().build();
|
|
|
//学段信息
|
|
|
@@ -78,6 +76,7 @@ public class SysCustomerDataPublicService {
|
|
|
* 后台管理-公海客户(学校)分页列表
|
|
|
*/
|
|
|
public PageResult<SysCustomerDataPublicBO> adminList(AdminSysCustomerDataPublicListDTO dto) {
|
|
|
+ permissionService.publicPrivateCustomerPermission();
|
|
|
Page<SysCustomerDataEntity> entityPage = sysCustomerDataMapper.selectPage(
|
|
|
new Page<>(dto.getPageNum(), dto.getPageSize()),
|
|
|
new QueryWrapper<SysCustomerDataEntity>()
|
|
|
@@ -108,9 +107,7 @@ public class SysCustomerDataPublicService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void adminInsertCustomerData(AdminSysCustomerDataInsertOrUpdateDTO dto) {
|
|
|
- if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
|
|
|
- throw new BusinessException(400, "无权操作");
|
|
|
- }
|
|
|
+ permissionService.publicPrivateCustomerPermission();
|
|
|
sysCustomerDataService.adminInsert(dto);
|
|
|
}
|
|
|
|
|
|
@@ -121,9 +118,7 @@ public class SysCustomerDataPublicService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void adminUpdateCustomerData(AdminSysCustomerDataInsertOrUpdateDTO dto) {
|
|
|
- if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
|
|
|
- throw new BusinessException(400, "无权操作");
|
|
|
- }
|
|
|
+ permissionService.publicPrivateCustomerPermission();
|
|
|
sysCustomerDataService.adminUpdate(dto);
|
|
|
}
|
|
|
|
|
|
@@ -134,9 +129,7 @@ public class SysCustomerDataPublicService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void adminDeleteCustomerData(Long id) {
|
|
|
- if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
|
|
|
- throw new BusinessException(400, "无权操作");
|
|
|
- }
|
|
|
+ permissionService.publicPrivateCustomerPermission();
|
|
|
sysCustomerDataService.adminDelete(id);
|
|
|
}
|
|
|
|
|
|
@@ -147,6 +140,7 @@ public class SysCustomerDataPublicService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void claimCustomer(Long customerId) {
|
|
|
+ permissionService.publicPrivateCustomerPermission();
|
|
|
sysCustomerDataService.claimCustomer(customerId);
|
|
|
}
|
|
|
|
|
|
@@ -159,9 +153,7 @@ public class SysCustomerDataPublicService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void adminInsertCustomerPerson(AdminSysCustomerPersonInsertOrUpdateDTO dto) {
|
|
|
- if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
|
|
|
- throw new BusinessException(400, "无权操作");
|
|
|
- }
|
|
|
+ permissionService.publicPrivateCustomerPermission();
|
|
|
sysCustomerPersonService.adminInsert(dto);
|
|
|
}
|
|
|
|
|
|
@@ -173,9 +165,7 @@ public class SysCustomerDataPublicService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void adminUpdateCustomerPerson(AdminSysCustomerPersonInsertOrUpdateDTO dto) {
|
|
|
- if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
|
|
|
- throw new BusinessException(400, "无权操作");
|
|
|
- }
|
|
|
+ permissionService.publicPrivateCustomerPermission();
|
|
|
sysCustomerPersonService.adminUpdate(dto);
|
|
|
}
|
|
|
|
|
|
@@ -186,9 +176,7 @@ public class SysCustomerDataPublicService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void adminDeleteCustomerPerson(Long id) {
|
|
|
- if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
|
|
|
- throw new BusinessException(400, "无权操作");
|
|
|
- }
|
|
|
+ permissionService.publicPrivateCustomerPermission();
|
|
|
sysCustomerPersonService.adminDelete(id);
|
|
|
}
|
|
|
|
|
|
@@ -196,9 +184,7 @@ public class SysCustomerDataPublicService {
|
|
|
* 查询公海客户联系人
|
|
|
*/
|
|
|
public List<SysCustomerPersonBO> adminListCustomerPerson(CustomerPersonReqDTO dto) {
|
|
|
- if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
|
|
|
- throw new BusinessException(400, "无权操作");
|
|
|
- }
|
|
|
+ permissionService.publicPrivateCustomerPermission();
|
|
|
return sysCustomerPersonService.adminList(dto);
|
|
|
}
|
|
|
|
|
|
@@ -209,9 +195,7 @@ public class SysCustomerDataPublicService {
|
|
|
* @param dto
|
|
|
*/
|
|
|
public SysCustomerDetailBO queryCustomerDetail(AdminSysCustomerFollowReqDTO dto) {
|
|
|
- if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
|
|
|
- throw new BusinessException(400, "无权操作");
|
|
|
- }
|
|
|
+ permissionService.publicPrivateCustomerPermission();
|
|
|
SysCustomerDetailBO detailBO = SysCustomerDetailBO.builder().build();
|
|
|
//顶部筛选条件数据
|
|
|
SysCustomerFollowHistorySelectBO publicCustomerSelectData = sysCustomerDataFollowService.queryCustomerFollowSelectCommonData(dto.getCustomerId(), null);
|
|
|
@@ -230,10 +214,37 @@ public class SysCustomerDataPublicService {
|
|
|
* 操作日志列表查询
|
|
|
*/
|
|
|
public SysCustomerOperLogDataBO queryOperLogData(AdminSysCustomerOperLogListDTO dto) {
|
|
|
- if (CollUtil.isEmpty(UserContextHolder.getUserContext().getRoles()) || !UserContextHolder.getUserContext().getRoles().contains("Admin")) {
|
|
|
- throw new BusinessException(400, "无权操作");
|
|
|
+ permissionService.publicPrivateCustomerPermission();
|
|
|
+ List<Long> userIds = Lists.newArrayList();
|
|
|
+ if (dto.getOperUserId() != null) {
|
|
|
+ userIds.add(dto.getOperUserId());
|
|
|
+ }
|
|
|
+ List<Long> groupIds = Lists.newArrayList();
|
|
|
+ if (dto.getGroupId() != null) {
|
|
|
+ groupIds.add(dto.getGroupId());
|
|
|
+ }
|
|
|
+ SysCustomerSelectBO selectBO = sysCustomerUserCommonService.querySelectDataByType1(false,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, false, false);
|
|
|
+ return sysCustomerOperLogService.adminList(dto,userIds, groupIds,false, false);
|
|
|
}
|
|
|
|
|
|
|