Commit a8f6a3d324c0914bd7a37a4c69444b395cf0ea9a
1 parent
e53a0ca8
✨ CRM:完善 CRM 相关实现
Showing
6 changed files
with
26 additions
and
59 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerLimitConfigController.java
| @@ -3,10 +3,11 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer; | @@ -3,10 +3,11 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer; | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 7 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; | 8 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; |
| 7 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO; | 9 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO; |
| 8 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; | 10 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; |
| 9 | -import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert; | ||
| 10 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; | 11 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; |
| 11 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigService; | 12 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigService; |
| 12 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; | 13 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| @@ -71,11 +72,14 @@ public class CrmCustomerLimitConfigController { | @@ -71,11 +72,14 @@ public class CrmCustomerLimitConfigController { | ||
| 71 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 72 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 72 | @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:query')") | 73 | @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:query')") |
| 73 | public CommonResult<CrmCustomerLimitConfigRespVO> getCustomerLimitConfig(@RequestParam("id") Long id) { | 74 | public CommonResult<CrmCustomerLimitConfigRespVO> getCustomerLimitConfig(@RequestParam("id") Long id) { |
| 74 | - CrmCustomerLimitConfigDO customerLimitConfig = customerLimitConfigService.getCustomerLimitConfig(id); | 75 | + CrmCustomerLimitConfigDO limitConfig = customerLimitConfigService.getCustomerLimitConfig(id); |
| 75 | // 拼接数据 | 76 | // 拼接数据 |
| 76 | - Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(customerLimitConfig.getUserIds()); | ||
| 77 | - Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(customerLimitConfig.getDeptIds()); | ||
| 78 | - return success(CrmCustomerLimitConfigConvert.INSTANCE.convert(customerLimitConfig, userMap, deptMap)); | 77 | + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(limitConfig.getUserIds()); |
| 78 | + Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(limitConfig.getDeptIds()); | ||
| 79 | + return success(BeanUtils.toBean(limitConfig, CrmCustomerLimitConfigRespVO.class, configVO -> { | ||
| 80 | + configVO.setUsers(CollectionUtils.convertList(configVO.getUserIds(), userMap::get)); | ||
| 81 | + configVO.setDepts(CollectionUtils.convertList(configVO.getDeptIds(), deptMap::get)); | ||
| 82 | + })); | ||
| 79 | } | 83 | } |
| 80 | 84 | ||
| 81 | @GetMapping("/page") | 85 | @GetMapping("/page") |
| @@ -91,7 +95,10 @@ public class CrmCustomerLimitConfigController { | @@ -91,7 +95,10 @@ public class CrmCustomerLimitConfigController { | ||
| 91 | convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getUserIds, Collection::stream)); | 95 | convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getUserIds, Collection::stream)); |
| 92 | Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap( | 96 | Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap( |
| 93 | convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getDeptIds, Collection::stream)); | 97 | convertSetByFlatMap(pageResult.getList(), CrmCustomerLimitConfigDO::getDeptIds, Collection::stream)); |
| 94 | - return success(CrmCustomerLimitConfigConvert.INSTANCE.convertPage(pageResult, userMap, deptMap)); | 98 | + return success(BeanUtils.toBean(pageResult, CrmCustomerLimitConfigRespVO.class, configVO -> { |
| 99 | + configVO.setUsers(CollectionUtils.convertList(configVO.getUserIds(), userMap::get)); | ||
| 100 | + configVO.setDepts(CollectionUtils.convertList(configVO.getDeptIds(), deptMap::get)); | ||
| 101 | + })); | ||
| 95 | } | 102 | } |
| 96 | 103 | ||
| 97 | } | 104 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerLimitConfigConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.convert.customer; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 5 | -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO; | ||
| 7 | -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; | ||
| 8 | -import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | ||
| 9 | -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | ||
| 10 | -import org.mapstruct.Mapper; | ||
| 11 | -import org.mapstruct.factory.Mappers; | ||
| 12 | - | ||
| 13 | -import java.util.List; | ||
| 14 | -import java.util.Map; | ||
| 15 | - | ||
| 16 | -/** | ||
| 17 | - * 客户限制配置 Convert | ||
| 18 | - * | ||
| 19 | - * @author Wanwan | ||
| 20 | - */ | ||
| 21 | -@Mapper | ||
| 22 | -public interface CrmCustomerLimitConfigConvert { | ||
| 23 | - | ||
| 24 | - CrmCustomerLimitConfigConvert INSTANCE = Mappers.getMapper(CrmCustomerLimitConfigConvert.class); | ||
| 25 | - | ||
| 26 | - default PageResult<CrmCustomerLimitConfigRespVO> convertPage( | ||
| 27 | - PageResult<CrmCustomerLimitConfigDO> pageResult, | ||
| 28 | - Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) { | ||
| 29 | - List<CrmCustomerLimitConfigRespVO> list = CollectionUtils.convertList(pageResult.getList(), | ||
| 30 | - limitConfig -> convert(limitConfig, userMap, deptMap)); | ||
| 31 | - return new PageResult<>(list, pageResult.getTotal()); | ||
| 32 | - } | ||
| 33 | - | ||
| 34 | - default CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO limitConfig, | ||
| 35 | - Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) { | ||
| 36 | - CrmCustomerLimitConfigRespVO limitConfigVO = BeanUtils.toBean(limitConfig, CrmCustomerLimitConfigRespVO.class); | ||
| 37 | - limitConfigVO.setUsers(CollectionUtils.convertList(limitConfigVO.getUserIds(), userMap::get)); | ||
| 38 | - limitConfigVO.setDepts(CollectionUtils.convertList(limitConfigVO.getDeptIds(), deptMap::get)); | ||
| 39 | - return limitConfigVO; | ||
| 40 | - } | ||
| 41 | - | ||
| 42 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java
| @@ -63,7 +63,7 @@ public class CrmContractServiceImpl implements CrmContractService { | @@ -63,7 +63,7 @@ public class CrmContractServiceImpl implements CrmContractService { | ||
| 63 | /** | 63 | /** |
| 64 | * BPM 合同审批流程标识 | 64 | * BPM 合同审批流程标识 |
| 65 | */ | 65 | */ |
| 66 | - public static final String CONTRACT_APPROVE = "contract-approve"; | 66 | + public static final String BPM_PROCESS_DEFINITION_KEY = "crm-contract-audit"; |
| 67 | 67 | ||
| 68 | @Resource | 68 | @Resource |
| 69 | private CrmContractMapper contractMapper; | 69 | private CrmContractMapper contractMapper; |
| @@ -288,7 +288,7 @@ public class CrmContractServiceImpl implements CrmContractService { | @@ -288,7 +288,7 @@ public class CrmContractServiceImpl implements CrmContractService { | ||
| 288 | 288 | ||
| 289 | // 2. 创建合同审批流程实例 | 289 | // 2. 创建合同审批流程实例 |
| 290 | String processInstanceId = bpmProcessInstanceApi.createProcessInstance(userId, new BpmProcessInstanceCreateReqDTO() | 290 | String processInstanceId = bpmProcessInstanceApi.createProcessInstance(userId, new BpmProcessInstanceCreateReqDTO() |
| 291 | - .setProcessDefinitionKey(CONTRACT_APPROVE).setBusinessKey(String.valueOf(id))); | 291 | + .setProcessDefinitionKey(BPM_PROCESS_DEFINITION_KEY).setBusinessKey(String.valueOf(id))); |
| 292 | 292 | ||
| 293 | // 3. 更新合同工作流编号 | 293 | // 3. 更新合同工作流编号 |
| 294 | contractMapper.updateById(new CrmContractDO().setId(id).setProcessInstanceId(processInstanceId) | 294 | contractMapper.updateById(new CrmContractDO().setId(id).setProcessInstanceId(processInstanceId) |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/listener/CrmContractResultListener.java
| @@ -20,7 +20,7 @@ public class CrmContractResultListener extends BpmProcessInstanceResultEventList | @@ -20,7 +20,7 @@ public class CrmContractResultListener extends BpmProcessInstanceResultEventList | ||
| 20 | 20 | ||
| 21 | @Override | 21 | @Override |
| 22 | public String getProcessDefinitionKey() { | 22 | public String getProcessDefinitionKey() { |
| 23 | - return CrmContractServiceImpl.CONTRACT_APPROVE; | 23 | + return CrmContractServiceImpl.BPM_PROCESS_DEFINITION_KEY; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | @Override | 26 | @Override |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| @@ -240,9 +240,9 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -240,9 +240,9 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 240 | @Transactional(rollbackFor = Exception.class) | 240 | @Transactional(rollbackFor = Exception.class) |
| 241 | @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_CREATE_SUB_TYPE, bizNo = "{{#customer.id}}", | 241 | @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_CREATE_SUB_TYPE, bizNo = "{{#customer.id}}", |
| 242 | success = CRM_CUSTOMER_CREATE_SUCCESS) | 242 | success = CRM_CUSTOMER_CREATE_SUCCESS) |
| 243 | - public Long createCustomer(CrmCustomerCreateReqBO customerCreateReq, Long userId) { | 243 | + public Long createCustomer(CrmCustomerCreateReqBO createReqBO, Long userId) { |
| 244 | // 1. 插入客户 | 244 | // 1. 插入客户 |
| 245 | - CrmCustomerDO customer = BeanUtils.toBean(customerCreateReq, CrmCustomerDO.class).setOwnerUserId(userId); | 245 | + CrmCustomerDO customer = initCustomer(createReqBO, userId); |
| 246 | customerMapper.insert(customer); | 246 | customerMapper.insert(customer); |
| 247 | 247 | ||
| 248 | // 2. 创建数据权限 | 248 | // 2. 创建数据权限 |
| @@ -419,12 +419,14 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -419,12 +419,14 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 419 | if (updateOwnerUserIncr == 0) { | 419 | if (updateOwnerUserIncr == 0) { |
| 420 | throw exception(CUSTOMER_UPDATE_OWNER_USER_FAIL); | 420 | throw exception(CUSTOMER_UPDATE_OWNER_USER_FAIL); |
| 421 | } | 421 | } |
| 422 | - // 2. 删除负责人数据权限 | ||
| 423 | - permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), customer.getId(), | ||
| 424 | - CrmPermissionLevelEnum.OWNER.getLevel()); | ||
| 425 | 422 | ||
| 426 | - // 3. 联系人的负责人,也要设置为 null。因为:因为领取后,负责人也要关联过来,这块和 receiveCustomer 是对应的 | 423 | + // 2. 联系人的负责人,也要设置为 null。因为:因为领取后,负责人也要关联过来,这块和 receiveCustomer 是对应的 |
| 427 | contactService.updateOwnerUserIdByCustomerId(customer.getId(), null); | 424 | contactService.updateOwnerUserIdByCustomerId(customer.getId(), null); |
| 425 | + | ||
| 426 | + // 3. 删除负责人数据权限 | ||
| 427 | + // 注意:需要放在 contactService 后面,不然【客户】数据权限已经被删除,无法操作! | ||
| 428 | + permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), customer.getId(), | ||
| 429 | + CrmPermissionLevelEnum.OWNER.getLevel()); | ||
| 428 | } | 430 | } |
| 429 | 431 | ||
| 430 | @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_RECEIVE_SUB_TYPE, bizNo = "{{#customer.id}}", | 432 | @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_RECEIVE_SUB_TYPE, bizNo = "{{#customer.id}}", |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java
| @@ -71,10 +71,10 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { | @@ -71,10 +71,10 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { | ||
| 71 | // 1.2 查验关联合同回款数量 | 71 | // 1.2 查验关联合同回款数量 |
| 72 | Long count = receivableService.getReceivableCountByContractId(createReqVO.getContractId()); | 72 | Long count = receivableService.getReceivableCountByContractId(createReqVO.getContractId()); |
| 73 | int period = (int) (count + 1); | 73 | int period = (int) (count + 1); |
| 74 | - createReqVO.setPeriod(createReqVO.getPeriod() != period ? period : createReqVO.getPeriod()); // 如果期数不对则纠正 | ||
| 75 | 74 | ||
| 76 | // 2. 插入还款计划 | 75 | // 2. 插入还款计划 |
| 77 | - CrmReceivablePlanDO receivablePlan = BeanUtils.toBean(createReqVO, CrmReceivablePlanDO.class).setId(null).setFinishStatus(false); | 76 | + CrmReceivablePlanDO receivablePlan = BeanUtils.toBean(createReqVO, CrmReceivablePlanDO.class) |
| 77 | + .setPeriod(period).setFinishStatus(false); | ||
| 78 | receivablePlanMapper.insert(receivablePlan); | 78 | receivablePlanMapper.insert(receivablePlan); |
| 79 | 79 | ||
| 80 | // 3. 创建数据权限 | 80 | // 3. 创建数据权限 |