mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-31 17:40:05 +08:00
Merge remote-tracking branch 'yudao/develop' into develop
# Conflicts: # yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java
This commit is contained in:
commit
dd6981d901
@ -10,6 +10,8 @@ import java.util.Arrays;
|
|||||||
/**
|
/**
|
||||||
* CRM 数据权限级别枚举
|
* CRM 数据权限级别枚举
|
||||||
*
|
*
|
||||||
|
* OWNER > WRITE > READ
|
||||||
|
*
|
||||||
* @author HUIHUI
|
* @author HUIHUI
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@ -17,8 +19,8 @@ import java.util.Arrays;
|
|||||||
public enum CrmPermissionLevelEnum implements IntArrayValuable {
|
public enum CrmPermissionLevelEnum implements IntArrayValuable {
|
||||||
|
|
||||||
OWNER(1, "负责人"),
|
OWNER(1, "负责人"),
|
||||||
READ(2, "读"),
|
READ(2, "只读"),
|
||||||
WRITE(3, "写");
|
WRITE(3, "读写");
|
||||||
|
|
||||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmPermissionLevelEnum::getLevel).toArray();
|
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmPermissionLevelEnum::getLevel).toArray();
|
||||||
|
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.enums.permission;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Crm 数据权限角色枚举
|
|
||||||
*
|
|
||||||
* @author HUIHUI
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum CrmPermissionRoleCodeEnum {
|
|
||||||
|
|
||||||
CRM_ADMIN("crm_admin", "CRM 管理员");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色标识
|
|
||||||
*/
|
|
||||||
private String code;
|
|
||||||
/**
|
|
||||||
* 角色名称
|
|
||||||
*/
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -3,10 +3,11 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer;
|
|||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO;
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert;
|
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
|
||||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigService;
|
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigService;
|
||||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||||
@ -71,11 +72,14 @@ public class CrmCustomerLimitConfigController {
|
|||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('crm:customer-limit-config:query')")
|
@PreAuthorize("@ss.hasPermission('crm:customer-limit-config:query')")
|
||||||
public CommonResult<CrmCustomerLimitConfigRespVO> getCustomerLimitConfig(@RequestParam("id") Long id) {
|
public CommonResult<CrmCustomerLimitConfigRespVO> getCustomerLimitConfig(@RequestParam("id") Long id) {
|
||||||
CrmCustomerLimitConfigDO customerLimitConfig = customerLimitConfigService.getCustomerLimitConfig(id);
|
CrmCustomerLimitConfigDO limitConfig = customerLimitConfigService.getCustomerLimitConfig(id);
|
||||||
// 拼接数据
|
// 拼接数据
|
||||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(customerLimitConfig.getUserIds());
|
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(limitConfig.getUserIds());
|
||||||
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(customerLimitConfig.getDeptIds());
|
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(limitConfig.getDeptIds());
|
||||||
return success(CrmCustomerLimitConfigConvert.INSTANCE.convert(customerLimitConfig, userMap, deptMap));
|
return success(BeanUtils.toBean(limitConfig, CrmCustomerLimitConfigRespVO.class, configVO -> {
|
||||||
|
configVO.setUsers(CollectionUtils.convertList(configVO.getUserIds(), userMap::get));
|
||||||
|
configVO.setDepts(CollectionUtils.convertList(configVO.getDeptIds(), deptMap::get));
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@ -91,7 +95,10 @@ public class CrmCustomerLimitConfigController {
|
|||||||
convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getUserIds, Collection::stream));
|
convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getUserIds, Collection::stream));
|
||||||
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(
|
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(
|
||||||
convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getDeptIds, Collection::stream));
|
convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getDeptIds, Collection::stream));
|
||||||
return success(CrmCustomerLimitConfigConvert.INSTANCE.convertPage(pageResult, userMap, deptMap));
|
return success(BeanUtils.toBean(pageResult, CrmCustomerLimitConfigRespVO.class, configVO -> {
|
||||||
|
configVO.setUsers(CollectionUtils.convertList(configVO.getUserIds(), userMap::get));
|
||||||
|
configVO.setDepts(CollectionUtils.convertList(configVO.getDeptIds(), deptMap::get));
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.convert.customer;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
|
||||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
||||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO;
|
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
|
|
||||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 客户限制配置 Convert
|
|
||||||
*
|
|
||||||
* @author Wanwan
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface CrmCustomerLimitConfigConvert {
|
|
||||||
|
|
||||||
CrmCustomerLimitConfigConvert INSTANCE = Mappers.getMapper(CrmCustomerLimitConfigConvert.class);
|
|
||||||
|
|
||||||
default PageResult<CrmCustomerLimitConfigRespVO> convertPage(
|
|
||||||
PageResult<CrmCustomerLimitConfigDO> pageResult,
|
|
||||||
Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) {
|
|
||||||
List<CrmCustomerLimitConfigRespVO> list = CollectionUtils.convertList(pageResult.getList(),
|
|
||||||
limitConfig -> convert(limitConfig, userMap, deptMap));
|
|
||||||
return new PageResult<>(list, pageResult.getTotal());
|
|
||||||
}
|
|
||||||
|
|
||||||
default CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO limitConfig,
|
|
||||||
Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) {
|
|
||||||
CrmCustomerLimitConfigRespVO limitConfigVO = BeanUtils.toBean(limitConfig, CrmCustomerLimitConfigRespVO.class);
|
|
||||||
limitConfigVO.setUsers(CollectionUtils.convertList(limitConfigVO.getUserIds(), userMap::get));
|
|
||||||
limitConfigVO.setDepts(CollectionUtils.convertList(limitConfigVO.getDeptIds(), deptMap::get));
|
|
||||||
return limitConfigVO;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -7,7 +7,7 @@ import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
|||||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils;
|
import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> {
|
|||||||
default PageResult<CrmBusinessDO> selectPage(CrmBusinessPageReqVO pageReqVO, Long userId) {
|
default PageResult<CrmBusinessDO> selectPage(CrmBusinessPageReqVO pageReqVO, Long userId) {
|
||||||
MPJLambdaWrapperX<CrmBusinessDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmBusinessDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 拼接数据权限的查询条件
|
// 拼接数据权限的查询条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_BUSINESS.getType(),
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_BUSINESS.getType(),
|
||||||
CrmBusinessDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE);
|
CrmBusinessDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE);
|
||||||
// 拼接自身的查询条件
|
// 拼接自身的查询条件
|
||||||
query.selectAll(CrmBusinessDO.class)
|
query.selectAll(CrmBusinessDO.class)
|
||||||
@ -57,7 +57,7 @@ public interface CrmBusinessMapper extends BaseMapperX<CrmBusinessDO> {
|
|||||||
default List<CrmBusinessDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
default List<CrmBusinessDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
||||||
MPJLambdaWrapperX<CrmBusinessDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmBusinessDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 拼接数据权限的查询条件
|
// 拼接数据权限的查询条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_BUSINESS.getType(), ids, userId);
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_BUSINESS.getType(), ids, userId);
|
||||||
// 拼接自身的查询条件
|
// 拼接自身的查询条件
|
||||||
query.selectAll(CrmBusinessDO.class).in(CrmBusinessDO::getId, ids).orderByDesc(CrmBusinessDO::getId);
|
query.selectAll(CrmBusinessDO.class).in(CrmBusinessDO::getId, ids).orderByDesc(CrmBusinessDO::getId);
|
||||||
return selectJoinList(CrmBusinessDO.class, query);
|
return selectJoinList(CrmBusinessDO.class, query);
|
||||||
|
@ -7,7 +7,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO;
|
|||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils;
|
import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -24,7 +24,7 @@ public interface CrmClueMapper extends BaseMapperX<CrmClueDO> {
|
|||||||
default PageResult<CrmClueDO> selectPage(CrmCluePageReqVO pageReqVO, Long userId) {
|
default PageResult<CrmClueDO> selectPage(CrmCluePageReqVO pageReqVO, Long userId) {
|
||||||
MPJLambdaWrapperX<CrmClueDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmClueDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 拼接数据权限的查询条件
|
// 拼接数据权限的查询条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CLUE.getType(),
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CLUE.getType(),
|
||||||
CrmClueDO::getId, userId, pageReqVO.getSceneType(), pageReqVO.getPool());
|
CrmClueDO::getId, userId, pageReqVO.getSceneType(), pageReqVO.getPool());
|
||||||
// 拼接自身的查询条件
|
// 拼接自身的查询条件
|
||||||
query.selectAll(CrmClueDO.class)
|
query.selectAll(CrmClueDO.class)
|
||||||
@ -43,7 +43,7 @@ public interface CrmClueMapper extends BaseMapperX<CrmClueDO> {
|
|||||||
default List<CrmClueDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
default List<CrmClueDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
||||||
MPJLambdaWrapperX<CrmClueDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmClueDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 拼接数据权限的查询条件
|
// 拼接数据权限的查询条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CLUE.getType(), ids, userId);
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CLUE.getType(), ids, userId);
|
||||||
query.selectAll(CrmClueDO.class).in(CrmClueDO::getId, ids).orderByDesc(CrmClueDO::getId);
|
query.selectAll(CrmClueDO.class).in(CrmClueDO::getId, ids).orderByDesc(CrmClueDO::getId);
|
||||||
// 拼接自身的查询条件
|
// 拼接自身的查询条件
|
||||||
return selectJoinList(CrmClueDO.class, query);
|
return selectJoinList(CrmClueDO.class, query);
|
||||||
@ -52,7 +52,7 @@ public interface CrmClueMapper extends BaseMapperX<CrmClueDO> {
|
|||||||
default Long selectCountByFollow(Long userId) {
|
default Long selectCountByFollow(Long userId) {
|
||||||
MPJLambdaWrapperX<CrmClueDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmClueDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 我负责的 + 非公海
|
// 我负责的 + 非公海
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CLUE.getType(),
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CLUE.getType(),
|
||||||
CrmClueDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE);
|
CrmClueDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE);
|
||||||
// 未跟进 + 未转化
|
// 未跟进 + 未转化
|
||||||
query.eq(CrmClueDO::getFollowUpStatus, false)
|
query.eq(CrmClueDO::getFollowUpStatus, false)
|
||||||
|
@ -7,7 +7,7 @@ import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
|
|||||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO;
|
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO;
|
||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils;
|
import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> {
|
|||||||
default PageResult<CrmContactDO> selectPage(CrmContactPageReqVO pageReqVO, Long userId) {
|
default PageResult<CrmContactDO> selectPage(CrmContactPageReqVO pageReqVO, Long userId) {
|
||||||
MPJLambdaWrapperX<CrmContactDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmContactDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 拼接数据权限的查询条件
|
// 拼接数据权限的查询条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTACT.getType(),
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTACT.getType(),
|
||||||
CrmContactDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE);
|
CrmContactDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE);
|
||||||
// 拼接自身的查询条件
|
// 拼接自身的查询条件
|
||||||
query.selectAll(CrmContactDO.class)
|
query.selectAll(CrmContactDO.class)
|
||||||
@ -72,7 +72,7 @@ public interface CrmContactMapper extends BaseMapperX<CrmContactDO> {
|
|||||||
default List<CrmContactDO> selectBatchIds(Collection<Long> ids, Long ownerUserId) {
|
default List<CrmContactDO> selectBatchIds(Collection<Long> ids, Long ownerUserId) {
|
||||||
MPJLambdaWrapperX<CrmContactDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmContactDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 拼接数据权限的查询条件
|
// 拼接数据权限的查询条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, ownerUserId);
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTACT.getType(), ids, ownerUserId);
|
||||||
query.selectAll(CrmContactDO.class).in(CrmContactDO::getId, ids).orderByDesc(CrmContactDO::getId);
|
query.selectAll(CrmContactDO.class).in(CrmContactDO::getId, ids).orderByDesc(CrmContactDO::getId);
|
||||||
return selectJoinList(CrmContactDO.class, query);
|
return selectJoinList(CrmContactDO.class, query);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
|||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils;
|
import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -42,7 +42,7 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
|
|||||||
default PageResult<CrmContractDO> selectPage(CrmContractPageReqVO pageReqVO, Long userId) {
|
default PageResult<CrmContractDO> selectPage(CrmContractPageReqVO pageReqVO, Long userId) {
|
||||||
MPJLambdaWrapperX<CrmContractDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmContractDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 拼接数据权限的查询条件
|
// 拼接数据权限的查询条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(),
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(),
|
||||||
CrmContractDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE);
|
CrmContractDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE);
|
||||||
// 拼接自身的查询条件
|
// 拼接自身的查询条件
|
||||||
query.selectAll(CrmContractDO.class)
|
query.selectAll(CrmContractDO.class)
|
||||||
@ -71,7 +71,7 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
|
|||||||
default List<CrmContractDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
default List<CrmContractDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
||||||
MPJLambdaWrapperX<CrmContractDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmContractDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 构建数据权限连表条件
|
// 构建数据权限连表条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(), ids, userId);
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(), ids, userId);
|
||||||
// 拼接自身的查询条件
|
// 拼接自身的查询条件
|
||||||
query.selectAll(CrmContractDO.class).in(CrmContractDO::getId, ids).orderByDesc(CrmContractDO::getId);
|
query.selectAll(CrmContractDO.class).in(CrmContractDO::getId, ids).orderByDesc(CrmContractDO::getId);
|
||||||
return selectJoinList(CrmContractDO.class, query);
|
return selectJoinList(CrmContractDO.class, query);
|
||||||
@ -88,7 +88,7 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
|
|||||||
default Long selectCheckContractCount(Long userId) {
|
default Long selectCheckContractCount(Long userId) {
|
||||||
MPJLambdaWrapperX<CrmContractDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmContractDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 我负责的 + 非公海
|
// 我负责的 + 非公海
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(),
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(),
|
||||||
CrmContractDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE);
|
CrmContractDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE);
|
||||||
// 未提交 or 审核不通过
|
// 未提交 or 审核不通过
|
||||||
query.in(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.DRAFT.getStatus(), CrmAuditStatusEnum.REJECT.getStatus());
|
query.in(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.DRAFT.getStatus(), CrmAuditStatusEnum.REJECT.getStatus());
|
||||||
@ -98,7 +98,7 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
|
|||||||
default Long selectEndContractCount(Long userId) {
|
default Long selectEndContractCount(Long userId) {
|
||||||
MPJLambdaWrapperX<CrmContractDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmContractDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 我负责的 + 非公海
|
// 我负责的 + 非公海
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(),
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CONTRACT.getType(),
|
||||||
CrmContractDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE);
|
CrmContractDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE);
|
||||||
// 即将到期
|
// 即将到期
|
||||||
LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now());
|
LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now());
|
||||||
|
@ -12,7 +12,7 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
|||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils;
|
import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
@ -52,7 +52,7 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
|
|||||||
default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO pageReqVO, Long ownerUserId) {
|
default PageResult<CrmCustomerDO> selectPage(CrmCustomerPageReqVO pageReqVO, Long ownerUserId) {
|
||||||
MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 拼接数据权限的查询条件
|
// 拼接数据权限的查询条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(),
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(),
|
||||||
CrmCustomerDO::getId, ownerUserId, pageReqVO.getSceneType(), pageReqVO.getPool());
|
CrmCustomerDO::getId, ownerUserId, pageReqVO.getSceneType(), pageReqVO.getPool());
|
||||||
// 拼接自身的查询条件
|
// 拼接自身的查询条件
|
||||||
query.selectAll(CrmCustomerDO.class)
|
query.selectAll(CrmCustomerDO.class)
|
||||||
@ -84,7 +84,7 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
|
|||||||
default List<CrmCustomerDO> selectBatchIds(Collection<Long> ids, Long ownerUserId) {
|
default List<CrmCustomerDO> selectBatchIds(Collection<Long> ids, Long ownerUserId) {
|
||||||
MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 拼接数据权限的查询条件
|
// 拼接数据权限的查询条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, ownerUserId);
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(), ids, ownerUserId);
|
||||||
// 拼接自身的查询条件
|
// 拼接自身的查询条件
|
||||||
query.selectAll(CrmCustomerDO.class).in(CrmCustomerDO::getId, ids).orderByDesc(CrmCustomerDO::getId);
|
query.selectAll(CrmCustomerDO.class).in(CrmCustomerDO::getId, ids).orderByDesc(CrmCustomerDO::getId);
|
||||||
return selectJoinList(CrmCustomerDO.class, query);
|
return selectJoinList(CrmCustomerDO.class, query);
|
||||||
@ -113,7 +113,7 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
|
|||||||
Long ownerUserId) {
|
Long ownerUserId) {
|
||||||
MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 拼接数据权限的查询条件
|
// 拼接数据权限的查询条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(),
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(),
|
||||||
CrmCustomerDO::getId, ownerUserId, pageReqVO.getSceneType(), null);
|
CrmCustomerDO::getId, ownerUserId, pageReqVO.getSceneType(), null);
|
||||||
|
|
||||||
// 未锁定 + 未成交
|
// 未锁定 + 未成交
|
||||||
@ -167,7 +167,7 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
|
|||||||
default Long selectCountByTodayContact(Long ownerUserId) {
|
default Long selectCountByTodayContact(Long ownerUserId) {
|
||||||
MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 我负责的 + 非公海
|
// 我负责的 + 非公海
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(),
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(),
|
||||||
CrmCustomerDO::getId, ownerUserId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE);
|
CrmCustomerDO::getId, ownerUserId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE);
|
||||||
// 今天需联系
|
// 今天需联系
|
||||||
LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now());
|
LocalDateTime beginOfToday = LocalDateTimeUtil.beginOfDay(LocalDateTime.now());
|
||||||
@ -179,7 +179,7 @@ public interface CrmCustomerMapper extends BaseMapperX<CrmCustomerDO> {
|
|||||||
default Long selectCountByFollow(Long ownerUserId) {
|
default Long selectCountByFollow(Long ownerUserId) {
|
||||||
MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmCustomerDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 我负责的 + 非公海
|
// 我负责的 + 非公海
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(),
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_CUSTOMER.getType(),
|
||||||
CrmCustomerDO::getId, ownerUserId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE);
|
CrmCustomerDO::getId, ownerUserId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE);
|
||||||
// 未跟进
|
// 未跟进
|
||||||
query.eq(CrmClueDO::getFollowUpStatus, false);
|
query.eq(CrmClueDO::getFollowUpStatus, false);
|
||||||
|
@ -10,8 +10,7 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO;
|
|||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils;
|
import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -25,12 +24,6 @@ import java.util.List;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface CrmReceivableMapper extends BaseMapperX<CrmReceivableDO> {
|
public interface CrmReceivableMapper extends BaseMapperX<CrmReceivableDO> {
|
||||||
|
|
||||||
default int updateOwnerUserIdById(Long id, Long ownerUserId) {
|
|
||||||
return update(new LambdaUpdateWrapper<CrmReceivableDO>()
|
|
||||||
.eq(CrmReceivableDO::getId, id)
|
|
||||||
.set(CrmReceivableDO::getOwnerUserId, ownerUserId));
|
|
||||||
}
|
|
||||||
|
|
||||||
default PageResult<CrmReceivableDO> selectPageByCustomerId(CrmReceivablePageReqVO reqVO) {
|
default PageResult<CrmReceivableDO> selectPageByCustomerId(CrmReceivablePageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<CrmReceivableDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<CrmReceivableDO>()
|
||||||
.eq(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) // 必须传递
|
.eq(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) // 必须传递
|
||||||
@ -42,7 +35,7 @@ public interface CrmReceivableMapper extends BaseMapperX<CrmReceivableDO> {
|
|||||||
default PageResult<CrmReceivableDO> selectPage(CrmReceivablePageReqVO pageReqVO, Long userId) {
|
default PageResult<CrmReceivableDO> selectPage(CrmReceivablePageReqVO pageReqVO, Long userId) {
|
||||||
MPJLambdaWrapperX<CrmReceivableDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmReceivableDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 拼接数据权限的查询条件
|
// 拼接数据权限的查询条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(),
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(),
|
||||||
CrmReceivableDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE);
|
CrmReceivableDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE);
|
||||||
// 拼接自身的查询条件
|
// 拼接自身的查询条件
|
||||||
query.selectAll(CrmReceivableDO.class)
|
query.selectAll(CrmReceivableDO.class)
|
||||||
@ -56,7 +49,7 @@ public interface CrmReceivableMapper extends BaseMapperX<CrmReceivableDO> {
|
|||||||
default List<CrmReceivableDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
default List<CrmReceivableDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
||||||
MPJLambdaWrapperX<CrmReceivableDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmReceivableDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 拼接数据权限的查询条件
|
// 拼接数据权限的查询条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(), ids, userId);
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(), ids, userId);
|
||||||
// 拼接自身的查询条件
|
// 拼接自身的查询条件
|
||||||
query.selectAll(CrmReceivableDO.class).in(CrmReceivableDO::getId, ids).orderByDesc(CrmReceivableDO::getId);
|
query.selectAll(CrmReceivableDO.class).in(CrmReceivableDO::getId, ids).orderByDesc(CrmReceivableDO::getId);
|
||||||
return selectJoinList(CrmReceivableDO.class, query);
|
return selectJoinList(CrmReceivableDO.class, query);
|
||||||
@ -65,7 +58,7 @@ public interface CrmReceivableMapper extends BaseMapperX<CrmReceivableDO> {
|
|||||||
default Long selectCheckReceivablesCount(Long userId) {
|
default Long selectCheckReceivablesCount(Long userId) {
|
||||||
MPJLambdaWrapperX<CrmReceivableDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmReceivableDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 我负责的 + 非公海
|
// 我负责的 + 非公海
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(),
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE.getType(),
|
||||||
CrmReceivableDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE);
|
CrmReceivableDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE);
|
||||||
// 未提交 or 审核不通过
|
// 未提交 or 审核不通过
|
||||||
query.in(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.DRAFT.getStatus(), CrmAuditStatusEnum.REJECT.getStatus());
|
query.in(CrmContractDO::getAuditStatus, CrmAuditStatusEnum.DRAFT.getStatus(), CrmAuditStatusEnum.REJECT.getStatus());
|
||||||
|
@ -9,7 +9,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceiv
|
|||||||
import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO;
|
import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils;
|
import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -34,7 +34,7 @@ public interface CrmReceivablePlanMapper extends BaseMapperX<CrmReceivablePlanDO
|
|||||||
default PageResult<CrmReceivablePlanDO> selectPage(CrmReceivablePlanPageReqVO pageReqVO, Long userId) {
|
default PageResult<CrmReceivablePlanDO> selectPage(CrmReceivablePlanPageReqVO pageReqVO, Long userId) {
|
||||||
MPJLambdaWrapperX<CrmReceivablePlanDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmReceivablePlanDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 拼接数据权限的查询条件
|
// 拼接数据权限的查询条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(),
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(),
|
||||||
CrmReceivablePlanDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE);
|
CrmReceivablePlanDO::getId, userId, pageReqVO.getSceneType(), Boolean.FALSE);
|
||||||
// 拼接自身的查询条件
|
// 拼接自身的查询条件
|
||||||
query.selectAll(CrmReceivablePlanDO.class)
|
query.selectAll(CrmReceivablePlanDO.class)
|
||||||
@ -64,7 +64,7 @@ public interface CrmReceivablePlanMapper extends BaseMapperX<CrmReceivablePlanDO
|
|||||||
default List<CrmReceivablePlanDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
default List<CrmReceivablePlanDO> selectBatchIds(Collection<Long> ids, Long userId) {
|
||||||
MPJLambdaWrapperX<CrmReceivablePlanDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmReceivablePlanDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 拼接数据权限的查询条件
|
// 拼接数据权限的查询条件
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), ids, userId);
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(), ids, userId);
|
||||||
// 拼接自身的查询条件
|
// 拼接自身的查询条件
|
||||||
query.selectAll(CrmReceivablePlanDO.class).in(CrmReceivablePlanDO::getId, ids).orderByDesc(CrmReceivablePlanDO::getId);
|
query.selectAll(CrmReceivablePlanDO.class).in(CrmReceivablePlanDO::getId, ids).orderByDesc(CrmReceivablePlanDO::getId);
|
||||||
return selectJoinList(CrmReceivablePlanDO.class, query);
|
return selectJoinList(CrmReceivablePlanDO.class, query);
|
||||||
@ -73,7 +73,7 @@ public interface CrmReceivablePlanMapper extends BaseMapperX<CrmReceivablePlanDO
|
|||||||
default Long selectRemindReceivablePlanCount(Long userId) {
|
default Long selectRemindReceivablePlanCount(Long userId) {
|
||||||
MPJLambdaWrapperX<CrmReceivablePlanDO> query = new MPJLambdaWrapperX<>();
|
MPJLambdaWrapperX<CrmReceivablePlanDO> query = new MPJLambdaWrapperX<>();
|
||||||
// 我负责的 + 非公海
|
// 我负责的 + 非公海
|
||||||
CrmQueryWrapperUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(),
|
CrmPermissionUtils.appendPermissionCondition(query, CrmBizTypeEnum.CRM_RECEIVABLE_PLAN.getType(),
|
||||||
CrmReceivablePlanDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE);
|
CrmReceivablePlanDO::getId, userId, CrmSceneTypeEnum.OWNER.getType(), Boolean.FALSE);
|
||||||
// TODO: @dhb52 需要配置 提前提醒天数
|
// TODO: @dhb52 需要配置 提前提醒天数
|
||||||
int REMIND_DAYS = 20;
|
int REMIND_DAYS = 20;
|
||||||
|
@ -9,7 +9,7 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
|
|||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||||
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
|
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
|
||||||
import cn.iocoder.yudao.module.crm.framework.permission.core.util.CrmPermissionUtils;
|
import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.crm.framework.permission.core.util;
|
|
||||||
|
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
|
||||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionRoleCodeEnum;
|
|
||||||
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据权限工具类
|
|
||||||
*
|
|
||||||
* @author HUIHUI
|
|
||||||
*/
|
|
||||||
public class CrmPermissionUtils {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验用户是否是 CRM 管理员
|
|
||||||
*
|
|
||||||
* @return 是/否
|
|
||||||
*/
|
|
||||||
public static boolean isCrmAdmin() {
|
|
||||||
return SingletonManager.getPermissionApi().hasAnyRoles(getLoginUserId(), CrmPermissionRoleCodeEnum.CRM_ADMIN.getCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 静态内部类实现单例获取
|
|
||||||
*
|
|
||||||
* @author HUIHUI
|
|
||||||
*/
|
|
||||||
private static class SingletonManager {
|
|
||||||
|
|
||||||
private static final PermissionApi PERMISSION_API = SpringUtil.getBean(PermissionApi.class);
|
|
||||||
|
|
||||||
public static PermissionApi getPermissionApi() {
|
|
||||||
return PERMISSION_API;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -63,7 +63,7 @@ public class CrmContractServiceImpl implements CrmContractService {
|
|||||||
/**
|
/**
|
||||||
* BPM 合同审批流程标识
|
* BPM 合同审批流程标识
|
||||||
*/
|
*/
|
||||||
public static final String CONTRACT_APPROVE = "contract-approve";
|
public static final String BPM_PROCESS_DEFINITION_KEY = "crm-contract-audit";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CrmContractMapper contractMapper;
|
private CrmContractMapper contractMapper;
|
||||||
@ -288,7 +288,7 @@ public class CrmContractServiceImpl implements CrmContractService {
|
|||||||
|
|
||||||
// 2. 创建合同审批流程实例
|
// 2. 创建合同审批流程实例
|
||||||
String processInstanceId = bpmProcessInstanceApi.createProcessInstance(userId, new BpmProcessInstanceCreateReqDTO()
|
String processInstanceId = bpmProcessInstanceApi.createProcessInstance(userId, new BpmProcessInstanceCreateReqDTO()
|
||||||
.setProcessDefinitionKey(CONTRACT_APPROVE).setBusinessKey(String.valueOf(id)));
|
.setProcessDefinitionKey(BPM_PROCESS_DEFINITION_KEY).setBusinessKey(String.valueOf(id)));
|
||||||
|
|
||||||
// 3. 更新合同工作流编号
|
// 3. 更新合同工作流编号
|
||||||
contractMapper.updateById(new CrmContractDO().setId(id).setProcessInstanceId(processInstanceId)
|
contractMapper.updateById(new CrmContractDO().setId(id).setProcessInstanceId(processInstanceId)
|
||||||
|
@ -20,7 +20,7 @@ public class CrmContractResultListener extends BpmProcessInstanceResultEventList
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProcessDefinitionKey() {
|
public String getProcessDefinitionKey() {
|
||||||
return CrmContractServiceImpl.CONTRACT_APPROVE;
|
return CrmContractServiceImpl.BPM_PROCESS_DEFINITION_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -241,9 +241,9 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_CREATE_SUB_TYPE, bizNo = "{{#customer.id}}",
|
@LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_CREATE_SUB_TYPE, bizNo = "{{#customer.id}}",
|
||||||
success = CRM_CUSTOMER_CREATE_SUCCESS)
|
success = CRM_CUSTOMER_CREATE_SUCCESS)
|
||||||
public Long createCustomer(CrmCustomerCreateReqBO customerCreateReq, Long userId) {
|
public Long createCustomer(CrmCustomerCreateReqBO createReqBO, Long userId) {
|
||||||
// 1. 插入客户
|
// 1. 插入客户
|
||||||
CrmCustomerDO customer = BeanUtils.toBean(customerCreateReq, CrmCustomerDO.class).setOwnerUserId(userId);
|
CrmCustomerDO customer = initCustomer(createReqBO, userId);
|
||||||
customerMapper.insert(customer);
|
customerMapper.insert(customer);
|
||||||
|
|
||||||
// 2. 创建数据权限
|
// 2. 创建数据权限
|
||||||
@ -422,12 +422,14 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
|||||||
if (updateOwnerUserIncr == 0) {
|
if (updateOwnerUserIncr == 0) {
|
||||||
throw exception(CUSTOMER_UPDATE_OWNER_USER_FAIL);
|
throw exception(CUSTOMER_UPDATE_OWNER_USER_FAIL);
|
||||||
}
|
}
|
||||||
// 2. 删除负责人数据权限
|
|
||||||
|
// 2. 联系人的负责人,也要设置为 null。因为:因为领取后,负责人也要关联过来,这块和 receiveCustomer 是对应的
|
||||||
|
contactService.updateOwnerUserIdByCustomerId(customer.getId(), null);
|
||||||
|
|
||||||
|
// 3. 删除负责人数据权限
|
||||||
|
// 注意:需要放在 contactService 后面,不然【客户】数据权限已经被删除,无法操作!
|
||||||
permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), customer.getId(),
|
permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), customer.getId(),
|
||||||
CrmPermissionLevelEnum.OWNER.getLevel());
|
CrmPermissionLevelEnum.OWNER.getLevel());
|
||||||
|
|
||||||
// 3. 联系人的负责人,也要设置为 null。因为:因为领取后,负责人也要关联过来,这块和 receiveCustomer 是对应的
|
|
||||||
contactService.updateOwnerUserIdByCustomerId(customer.getId(), null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_RECEIVE_SUB_TYPE, bizNo = "{{#customer.id}}",
|
@LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_RECEIVE_SUB_TYPE, bizNo = "{{#customer.id}}",
|
||||||
|
@ -9,7 +9,7 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
|
|||||||
import cn.iocoder.yudao.module.crm.dal.mysql.permission.CrmPermissionMapper;
|
import cn.iocoder.yudao.module.crm.dal.mysql.permission.CrmPermissionMapper;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||||
import cn.iocoder.yudao.module.crm.framework.permission.core.util.CrmPermissionUtils;
|
import cn.iocoder.yudao.module.crm.util.CrmPermissionUtils;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
|
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
|
@ -70,10 +70,11 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService {
|
|||||||
validateRelationDataExists(createReqVO);
|
validateRelationDataExists(createReqVO);
|
||||||
// 1.2 查验关联合同回款数量
|
// 1.2 查验关联合同回款数量
|
||||||
Long count = receivableService.getReceivableCountByContractId(createReqVO.getContractId());
|
Long count = receivableService.getReceivableCountByContractId(createReqVO.getContractId());
|
||||||
|
int period = (int) (count + 1);
|
||||||
|
|
||||||
// 2. 插入还款计划
|
// 2. 插入还款计划
|
||||||
CrmReceivablePlanDO receivablePlan = BeanUtils.toBean(createReqVO, CrmReceivablePlanDO.class).setId(null)
|
CrmReceivablePlanDO receivablePlan = BeanUtils.toBean(createReqVO, CrmReceivablePlanDO.class)
|
||||||
.setPeriod((int) (count + 1)).setFinishStatus(false);
|
.setPeriod(period).setFinishStatus(false);
|
||||||
receivablePlanMapper.insert(receivablePlan);
|
receivablePlanMapper.insert(receivablePlan);
|
||||||
|
|
||||||
// 3. 创建数据权限
|
// 3. 创建数据权限
|
||||||
|
@ -7,9 +7,10 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
|
|||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||||
import cn.iocoder.yudao.module.crm.framework.permission.core.util.CrmPermissionUtils;
|
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
||||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||||
import com.github.yulichang.autoconfigure.MybatisPlusJoinProperties;
|
import com.github.yulichang.autoconfigure.MybatisPlusJoinProperties;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
@ -18,13 +19,24 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||||
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CRM 查询工具类
|
* 数据权限工具类
|
||||||
*
|
*
|
||||||
* @author HUIHUI
|
* @author HUIHUI
|
||||||
*/
|
*/
|
||||||
public class CrmQueryWrapperUtils {
|
public class CrmPermissionUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验用户是否是 CRM 管理员
|
||||||
|
*
|
||||||
|
* @return 是/否
|
||||||
|
*/
|
||||||
|
public static boolean isCrmAdmin() {
|
||||||
|
PermissionApi permissionApi = SpringUtil.getBean(PermissionApi.class);
|
||||||
|
return permissionApi.hasAnyRoles(getLoginUserId(), RoleCodeEnum.CRM_ADMIN.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造 CRM 数据类型数据分页查询条件
|
* 构造 CRM 数据类型数据分页查询条件
|
||||||
@ -38,7 +50,8 @@ public class CrmQueryWrapperUtils {
|
|||||||
*/
|
*/
|
||||||
public static <T extends MPJLambdaWrapper<?>, S> void appendPermissionCondition(T query, Integer bizType, SFunction<S, ?> bizId,
|
public static <T extends MPJLambdaWrapper<?>, S> void appendPermissionCondition(T query, Integer bizType, SFunction<S, ?> bizId,
|
||||||
Long userId, Integer sceneType, Boolean pool) {
|
Long userId, Integer sceneType, Boolean pool) {
|
||||||
final String ownerUserIdField = SingletonManager.getMybatisPlusJoinProperties().getTableAlias() + ".owner_user_id";
|
MybatisPlusJoinProperties mybatisPlusJoinProperties = SpringUtil.getBean(MybatisPlusJoinProperties.class);
|
||||||
|
final String ownerUserIdField = mybatisPlusJoinProperties.getTableAlias() + ".owner_user_id";
|
||||||
// 1. 构建数据权限连表条件
|
// 1. 构建数据权限连表条件
|
||||||
if (!CrmPermissionUtils.isCrmAdmin() && ObjUtil.notEqual(pool, Boolean.TRUE)) { // 管理员,公海不需要数据权限
|
if (!CrmPermissionUtils.isCrmAdmin() && ObjUtil.notEqual(pool, Boolean.TRUE)) { // 管理员,公海不需要数据权限
|
||||||
query.innerJoin(CrmPermissionDO.class, on -> on.eq(CrmPermissionDO::getBizType, bizType)
|
query.innerJoin(CrmPermissionDO.class, on -> on.eq(CrmPermissionDO::getBizType, bizType)
|
||||||
@ -56,7 +69,8 @@ public class CrmQueryWrapperUtils {
|
|||||||
}
|
}
|
||||||
// 2.3 场景三:下属负责的数据
|
// 2.3 场景三:下属负责的数据
|
||||||
if (CrmSceneTypeEnum.isSubordinate(sceneType)) {
|
if (CrmSceneTypeEnum.isSubordinate(sceneType)) {
|
||||||
List<AdminUserRespDTO> subordinateUsers = SingletonManager.getAdminUserApi().getUserListBySubordinate(userId);
|
AdminUserApi adminUserApi = SpringUtil.getBean(AdminUserApi.class);
|
||||||
|
List<AdminUserRespDTO> subordinateUsers = adminUserApi.getUserListBySubordinate(userId);
|
||||||
if (CollUtil.isEmpty(subordinateUsers)) {
|
if (CollUtil.isEmpty(subordinateUsers)) {
|
||||||
query.eq(ownerUserIdField, -1); // 不返回任何结果
|
query.eq(ownerUserIdField, -1); // 不返回任何结果
|
||||||
} else {
|
} else {
|
||||||
@ -81,7 +95,7 @@ public class CrmQueryWrapperUtils {
|
|||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
*/
|
*/
|
||||||
public static <T extends MPJLambdaWrapper<?>> void appendPermissionCondition(T query, Integer bizType, Collection<Long> bizIds, Long userId) {
|
public static <T extends MPJLambdaWrapper<?>> void appendPermissionCondition(T query, Integer bizType, Collection<Long> bizIds, Long userId) {
|
||||||
if (CrmPermissionUtils.isCrmAdmin()) {// 管理员不需要数据权限
|
if (isCrmAdmin()) {// 管理员不需要数据权限
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
query.innerJoin(CrmPermissionDO.class, on ->
|
query.innerJoin(CrmPermissionDO.class, on ->
|
||||||
@ -89,25 +103,4 @@ public class CrmQueryWrapperUtils {
|
|||||||
.eq(CollUtil.isNotEmpty(bizIds), CrmPermissionDO::getUserId, userId));
|
.eq(CollUtil.isNotEmpty(bizIds), CrmPermissionDO::getUserId, userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 静态内部类实现单例获取
|
|
||||||
*
|
|
||||||
* @author HUIHUI
|
|
||||||
*/
|
|
||||||
private static class SingletonManager {
|
|
||||||
|
|
||||||
private static final AdminUserApi ADMIN_USER_API = SpringUtil.getBean(AdminUserApi.class);
|
|
||||||
|
|
||||||
private static final MybatisPlusJoinProperties MYBATIS_PLUS_JOIN_PROPERTIES = SpringUtil.getBean(MybatisPlusJoinProperties.class);
|
|
||||||
|
|
||||||
public static AdminUserApi getAdminUserApi() {
|
|
||||||
return ADMIN_USER_API;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MybatisPlusJoinProperties getMybatisPlusJoinProperties() {
|
|
||||||
return MYBATIS_PLUS_JOIN_PROPERTIES;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -13,6 +13,7 @@ public enum RoleCodeEnum {
|
|||||||
|
|
||||||
SUPER_ADMIN("super_admin", "超级管理员"),
|
SUPER_ADMIN("super_admin", "超级管理员"),
|
||||||
TENANT_ADMIN("tenant_admin", "租户管理员"),
|
TENANT_ADMIN("tenant_admin", "租户管理员"),
|
||||||
|
CRM_ADMIN("crm_admin", "CRM 管理员"); // CRM 系统专用
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user