|
|
@@ -57,8 +57,8 @@ public class SysCustomerPersonService {
|
|
|
// .eq(dto.getUserId()!=null,SysCustomerPersonEntity::getCreatedBy,dto.getUserId())
|
|
|
// 职务id(param_base_data表主id)
|
|
|
.eq(dto.getPositionId() != null, SysCustomerPersonEntity::getPositionId, dto.getPositionId())
|
|
|
- .and(StrUtil.isNotEmpty(dto.getQueryStr()),z->z.like(SysCustomerPersonEntity::getName,dto.getQueryStr())
|
|
|
- .or().like(SysCustomerPersonEntity::getPhoneNo,dto.getQueryStr())
|
|
|
+ .and(StrUtil.isNotEmpty(dto.getQueryStr()), z -> z.like(SysCustomerPersonEntity::getName, dto.getQueryStr())
|
|
|
+ .or().like(SysCustomerPersonEntity::getPhoneNo, dto.getQueryStr())
|
|
|
.or().like(SysCustomerPersonEntity::getOfficePhoneNo, dto.getQueryStr())
|
|
|
.or().like(SysCustomerPersonEntity::getCreatedBy, dto.getQueryStr())
|
|
|
)
|
|
|
@@ -94,7 +94,7 @@ public class SysCustomerPersonService {
|
|
|
dto.setId(null);
|
|
|
SysCustomerPersonEntity entity = new SysCustomerPersonEntity();
|
|
|
BeanUtil.copyProperties(dto, entity);
|
|
|
-
|
|
|
+ entity.setOperUserId(UserContextHolder.getUserId());
|
|
|
sysCustomerPersonMapper.insert(entity);
|
|
|
|
|
|
//新增联系人日志
|
|
|
@@ -113,7 +113,6 @@ public class SysCustomerPersonService {
|
|
|
.content(dto.getStr())
|
|
|
.build();
|
|
|
sysCustomerOperLogMapper.insert(logEntity);
|
|
|
-
|
|
|
return entity.getId();
|
|
|
}
|
|
|
|
|
|
@@ -127,6 +126,11 @@ public class SysCustomerPersonService {
|
|
|
if (entity == null) {
|
|
|
throw new BusinessException(400, "无效客户(学校)数据ID");
|
|
|
}
|
|
|
+ SysCustomerPersonEntity sysCustomerPersonEntity = sysCustomerPersonMapper.selectById(dto.getId());
|
|
|
+ if (!UserContextHolder.getUserContext().getRoles().contains("Admin") ||
|
|
|
+ sysCustomerPersonEntity.getOperUserId().equals(UserContextHolder.getUserId())) {
|
|
|
+ throw new BusinessException(400, "无权操作");
|
|
|
+ }
|
|
|
//查询用户的小组数据
|
|
|
SysUserGroupRelationEntity userGroupRelation = sysUserGroupRelationMapper.selectOne(
|
|
|
new LambdaQueryWrapper<SysUserGroupRelationEntity>()
|
|
|
@@ -139,8 +143,6 @@ public class SysCustomerPersonService {
|
|
|
.eq(SysUserGroupRelationEntity::getCityId, entity.getCityId())
|
|
|
.last("limit 1")
|
|
|
);
|
|
|
- SysCustomerPersonEntity sysCustomerPersonEntity = sysCustomerPersonMapper.selectById(dto.getId());
|
|
|
-
|
|
|
|
|
|
SysCustomerOperLogEntity logEntity = SysCustomerOperLogEntity.builder()
|
|
|
.customerId(entity.getId())
|
|
|
@@ -175,6 +177,11 @@ public class SysCustomerPersonService {
|
|
|
if (sysCustomerPersonEntity == null) {
|
|
|
throw new BusinessException(400, "联系人不存在");
|
|
|
}
|
|
|
+ if (!UserContextHolder.getUserContext().getRoles().contains("Admin") ||
|
|
|
+ sysCustomerPersonEntity.getOperUserId().equals(UserContextHolder.getUserId())) {
|
|
|
+ throw new BusinessException(400, "无权操作");
|
|
|
+ }
|
|
|
+
|
|
|
SysCustomerDataEntity entity = sysCustomerDataMapper.selectById(sysCustomerPersonEntity.getCustomerId());
|
|
|
if (entity == null) {
|
|
|
throw new BusinessException(400, "无效客户(学校)数据ID");
|
|
|
@@ -209,8 +216,6 @@ public class SysCustomerPersonService {
|
|
|
logEntity.setOperUserGroupId(userGroupRelation.getGroupId());
|
|
|
}
|
|
|
sysCustomerOperLogMapper.insert(logEntity);
|
|
|
-
|
|
|
-
|
|
|
sysCustomerPersonMapper.deleteById(id);
|
|
|
}
|
|
|
|
|
|
@@ -234,9 +239,13 @@ public class SysCustomerPersonService {
|
|
|
|
|
|
SysCustomerPersonBO bo = new SysCustomerPersonBO();
|
|
|
BeanUtil.copyProperties(entity, bo);
|
|
|
-
|
|
|
// 可以在此处为BO填充字段
|
|
|
-
|
|
|
+ bo.setOperUserId(entity.getOperUserId());
|
|
|
+ bo.setDeleteStatus(false);
|
|
|
+ if (UserContextHolder.getUserContext().getRoles().contains("Admin") ||
|
|
|
+ entity.getOperUserId().equals(UserContextHolder.getUserId())) {
|
|
|
+ bo.setDeleteStatus(true);
|
|
|
+ }
|
|
|
return bo;
|
|
|
}
|
|
|
|
|
|
@@ -270,14 +279,14 @@ public class SysCustomerPersonService {
|
|
|
entityList.forEach(
|
|
|
entity -> {
|
|
|
SysCustomerPersonBO bo = this.entity2BO(entity);
|
|
|
- if(CollUtil.isNotEmpty(lastFollowEntityList)){
|
|
|
+ if (CollUtil.isNotEmpty(lastFollowEntityList)) {
|
|
|
List<SysCustomerFollowEntity> list = lastFollowEntityList.stream()
|
|
|
.filter(lastFollowEntity -> lastFollowEntity.getPositionId().equals(entity.getPositionId()))
|
|
|
.sorted(Comparator.comparing(SysCustomerFollowEntity::getCreatedAt).reversed())
|
|
|
.toList();
|
|
|
- if(CollUtil.isNotEmpty(list)){
|
|
|
+ if (CollUtil.isNotEmpty(list)) {
|
|
|
bo.setLastFollowDate(
|
|
|
- list.getFirst().getCreatedAt());
|
|
|
+ list.getFirst().getCreatedAt());
|
|
|
}
|
|
|
}
|
|
|
ret.add(bo);
|