mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-31 17:40:05 +08:00
✨ CRM:完善 CRM 相关实现
This commit is contained in:
parent
e53a0ca884
commit
a8f6a3d324
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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
|
||||||
|
@ -240,9 +240,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. 创建数据权限
|
||||||
@ -419,12 +419,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}}",
|
||||||
|
@ -71,10 +71,10 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService {
|
|||||||
// 1.2 查验关联合同回款数量
|
// 1.2 查验关联合同回款数量
|
||||||
Long count = receivableService.getReceivableCountByContractId(createReqVO.getContractId());
|
Long count = receivableService.getReceivableCountByContractId(createReqVO.getContractId());
|
||||||
int period = (int) (count + 1);
|
int period = (int) (count + 1);
|
||||||
createReqVO.setPeriod(createReqVO.getPeriod() != period ? period : createReqVO.getPeriod()); // 如果期数不对则纠正
|
|
||||||
|
|
||||||
// 2. 插入还款计划
|
// 2. 插入还款计划
|
||||||
CrmReceivablePlanDO receivablePlan = BeanUtils.toBean(createReqVO, CrmReceivablePlanDO.class).setId(null).setFinishStatus(false);
|
CrmReceivablePlanDO receivablePlan = BeanUtils.toBean(createReqVO, CrmReceivablePlanDO.class)
|
||||||
|
.setPeriod(period).setFinishStatus(false);
|
||||||
receivablePlanMapper.insert(receivablePlan);
|
receivablePlanMapper.insert(receivablePlan);
|
||||||
|
|
||||||
// 3. 创建数据权限
|
// 3. 创建数据权限
|
||||||
|
Loading…
Reference in New Issue
Block a user