Commit 2e7c3e09a9b1d8deba1b2dffe24e3187b3efb905
1 parent
d0df0e8e
📖 CRM:code review 所有代码,补充对应 todo
Showing
14 changed files
with
102 additions
and
139 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java
| ... | ... | @@ -99,7 +99,6 @@ public class CrmBusinessController { |
| 99 | 99 | return success(buildBusinessDetailPageResult(pageResult)); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - | |
| 103 | 102 | @GetMapping("/page-by-contact") |
| 104 | 103 | @Operation(summary = "获得联系人的商机分页") |
| 105 | 104 | @PreAuthorize("@ss.hasPermission('crm:business:query')") |
| ... | ... | @@ -121,6 +120,12 @@ public class CrmBusinessController { |
| 121 | 120 | buildBusinessDetailPageResult(pageResult).getList()); |
| 122 | 121 | } |
| 123 | 122 | |
| 123 | + /** | |
| 124 | + * 构建详细的商机分页结果 | |
| 125 | + * | |
| 126 | + * @param pageResult 简单的商机分页结果 | |
| 127 | + * @return 详细的商机分页结果 | |
| 128 | + */ | |
| 124 | 129 | private PageResult<CrmBusinessRespVO> buildBusinessDetailPageResult(PageResult<CrmBusinessDO> pageResult) { |
| 125 | 130 | if (CollUtil.isEmpty(pageResult.getList())) { |
| 126 | 131 | return PageResult.empty(pageResult.getTotal()); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java
| ... | ... | @@ -121,7 +121,7 @@ public class CrmContactController { |
| 121 | 121 | @PreAuthorize("@ss.hasPermission('crm:contact:query')") |
| 122 | 122 | public CommonResult<PageResult<CrmContactRespVO>> getContactPage(@Valid CrmContactPageReqVO pageVO) { |
| 123 | 123 | PageResult<CrmContactDO> pageResult = contactService.getContactPage(pageVO, getLoginUserId()); |
| 124 | - return success(convertDetailContactPage(pageResult)); | |
| 124 | + return success(buildContactDetailPage(pageResult)); | |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | @GetMapping("/page-by-customer") |
| ... | ... | @@ -129,7 +129,7 @@ public class CrmContactController { |
| 129 | 129 | public CommonResult<PageResult<CrmContactRespVO>> getContactPageByCustomer(@Valid CrmContactPageReqVO pageVO) { |
| 130 | 130 | Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); |
| 131 | 131 | PageResult<CrmContactDO> pageResult = contactService.getContactPageByCustomerId(pageVO); |
| 132 | - return success(convertDetailContactPage(pageResult)); | |
| 132 | + return success(buildContactDetailPage(pageResult)); | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | @GetMapping("/export-excel") |
| ... | ... | @@ -141,16 +141,16 @@ public class CrmContactController { |
| 141 | 141 | exportReqVO.setPageNo(PAGE_SIZE_NONE); |
| 142 | 142 | PageResult<CrmContactDO> pageResult = contactService.getContactPage(exportReqVO, getLoginUserId()); |
| 143 | 143 | ExcelUtils.write(response, "联系人.xls", "数据", CrmContactRespVO.class, |
| 144 | - convertDetailContactPage(pageResult).getList()); | |
| 144 | + buildContactDetailPage(pageResult).getList()); | |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | /** |
| 148 | - * 转换成详细的联系人分页,即读取关联信息 | |
| 148 | + * 构建详细的联系人分页结果 | |
| 149 | 149 | * |
| 150 | - * @param pageResult 联系人分页 | |
| 151 | - * @return 详细的联系人分页 | |
| 150 | + * @param pageResult 简单的联系人分页结果 | |
| 151 | + * @return 详细的联系人分页结果 | |
| 152 | 152 | */ |
| 153 | - private PageResult<CrmContactRespVO> convertDetailContactPage(PageResult<CrmContactDO> pageResult) { | |
| 153 | + private PageResult<CrmContactRespVO> buildContactDetailPage(PageResult<CrmContactDO> pageResult) { | |
| 154 | 154 | List<CrmContactDO> contactList = pageResult.getList(); |
| 155 | 155 | if (CollUtil.isEmpty(contactList)) { |
| 156 | 156 | return PageResult.empty(pageResult.getTotal()); |
| ... | ... | @@ -175,10 +175,10 @@ public class CrmContactController { |
| 175 | 175 | return success(true); |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - // ================== 关联/取关商机 =================== | |
| 178 | + // ================== 关联/取关联系人 =================== | |
| 179 | 179 | |
| 180 | 180 | @PostMapping("/create-business-list") |
| 181 | - @Operation(summary = "创建联系人与商机的关联") | |
| 181 | + @Operation(summary = "创建联系人与联系人的关联") | |
| 182 | 182 | @PreAuthorize("@ss.hasPermission('crm:contact:create-business')") |
| 183 | 183 | public CommonResult<Boolean> createContactBusinessList(@Valid @RequestBody CrmContactBusinessReqVO createReqVO) { |
| 184 | 184 | contactBusinessLinkService.createContactBusinessList(createReqVO); |
| ... | ... | @@ -186,7 +186,7 @@ public class CrmContactController { |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | @DeleteMapping("/delete-business-list") |
| 189 | - @Operation(summary = "删除联系人与商机的关联") | |
| 189 | + @Operation(summary = "删除联系人与联系人的关联") | |
| 190 | 190 | @PreAuthorize("@ss.hasPermission('crm:contact:delete-business')") |
| 191 | 191 | public CommonResult<Boolean> deleteContactBusinessList(@Valid @RequestBody CrmContactBusinessReqVO deleteReqVO) { |
| 192 | 192 | contactBusinessLinkService.deleteContactBusinessList(deleteReqVO); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java
| ... | ... | @@ -88,7 +88,7 @@ public class CrmContractController { |
| 88 | 88 | @PreAuthorize("@ss.hasPermission('crm:contract:query')") |
| 89 | 89 | public CommonResult<PageResult<ContractRespVO>> getContractPage(@Valid CrmContractPageReqVO pageVO) { |
| 90 | 90 | PageResult<CrmContractDO> pageResult = contractService.getContractPage(pageVO, getLoginUserId()); |
| 91 | - return success(convertDetailContractPage(pageResult)); | |
| 91 | + return success(buildContractDetailPage(pageResult)); | |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | @GetMapping("/page-by-customer") |
| ... | ... | @@ -96,7 +96,7 @@ public class CrmContractController { |
| 96 | 96 | public CommonResult<PageResult<ContractRespVO>> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) { |
| 97 | 97 | Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); |
| 98 | 98 | PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomerId(pageVO); |
| 99 | - return success(convertDetailContractPage(pageResult)); | |
| 99 | + return success(buildContractDetailPage(pageResult)); | |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | @GetMapping("/export-excel") |
| ... | ... | @@ -112,12 +112,12 @@ public class CrmContractController { |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | - * 转换成详细的合同分页,即读取关联信息 | |
| 115 | + * 构建详细的合同分页结果 | |
| 116 | 116 | * |
| 117 | - * @param pageResult 合同分页 | |
| 118 | - * @return 详细的合同分页 | |
| 117 | + * @param pageResult 简单的合同分页结果 | |
| 118 | + * @return 详细的合同分页结果 | |
| 119 | 119 | */ |
| 120 | - private PageResult<ContractRespVO> convertDetailContractPage(PageResult<CrmContractDO> pageResult) { | |
| 120 | + private PageResult<ContractRespVO> buildContractDetailPage(PageResult<CrmContractDO> pageResult) { | |
| 121 | 121 | List<CrmContractDO> contactList = pageResult.getList(); |
| 122 | 122 | if (CollUtil.isEmpty(contactList)) { |
| 123 | 123 | return PageResult.empty(pageResult.getTotal()); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
| ... | ... | @@ -136,7 +136,7 @@ public class CrmCustomerController { |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | @PutMapping("/transfer") |
| 139 | - @Operation(summary = "客户转移") | |
| 139 | + @Operation(summary = "转移客户") | |
| 140 | 140 | @OperateLog(enable = false) // TODO 关闭原有日志记录 |
| 141 | 141 | @PreAuthorize("@ss.hasPermission('crm:customer:update')") |
| 142 | 142 | public CommonResult<Boolean> transfer(@Valid @RequestBody CrmCustomerTransferReqVO reqVO) { |
| ... | ... | @@ -184,6 +184,7 @@ public class CrmCustomerController { |
| 184 | 184 | return success(true); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | + // TODO @puhui999:需要搞个 VO 类 | |
| 187 | 188 | @PutMapping("/distribute") |
| 188 | 189 | @Operation(summary = "分配公海给对应负责人") |
| 189 | 190 | @Parameters({ |
| ... | ... | @@ -193,7 +194,6 @@ public class CrmCustomerController { |
| 193 | 194 | @PreAuthorize("@ss.hasPermission('crm:customer:distribute')") |
| 194 | 195 | public CommonResult<Boolean> distributeCustomer(@RequestParam(value = "ids") List<Long> ids, |
| 195 | 196 | @RequestParam(value = "ownerUserId") Long ownerUserId) { |
| 196 | - // 领取公海数据 | |
| 197 | 197 | customerService.receiveCustomer(ids, ownerUserId); |
| 198 | 198 | return success(true); |
| 199 | 199 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerTransferReqVO.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/permission/CrmPermissionController.java
| ... | ... | @@ -103,6 +103,7 @@ public class CrmPermissionController { |
| 103 | 103 | // 拼接数据 |
| 104 | 104 | List<AdminUserRespDTO> userList = adminUserApi.getUserList(convertSet(permission, CrmPermissionDO::getUserId)); |
| 105 | 105 | Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userList, AdminUserRespDTO::getDeptId)); |
| 106 | + // TODO @puhui999:可能 postIds 为空的时候,会导致报错,看看怎么 fix 下 | |
| 106 | 107 | Set<Long> postIds = CollectionUtils.convertSetByFlatMap(userList, AdminUserRespDTO::getPostIds, Collection::stream); |
| 107 | 108 | Map<Long, PostRespDTO> postMap = postApi.getPostMap(postIds); |
| 108 | 109 | return success(CrmPermissionConvert.INSTANCE.convert(permission, userList, deptMap, postMap)); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java
| ... | ... | @@ -93,7 +93,7 @@ public class CrmReceivableController { |
| 93 | 93 | @PreAuthorize("@ss.hasPermission('crm:receivable:query')") |
| 94 | 94 | public CommonResult<PageResult<CrmReceivableRespVO>> getReceivablePage(@Valid CrmReceivablePageReqVO pageReqVO) { |
| 95 | 95 | PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(pageReqVO, getLoginUserId()); |
| 96 | - return success(convertDetailReceivablePage(pageResult)); | |
| 96 | + return success(buildReceivableDetailPage(pageResult)); | |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | @GetMapping("/page-by-customer") |
| ... | ... | @@ -101,7 +101,7 @@ public class CrmReceivableController { |
| 101 | 101 | public CommonResult<PageResult<CrmReceivableRespVO>> getReceivablePageByCustomer(@Valid CrmReceivablePageReqVO pageReqVO) { |
| 102 | 102 | Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); |
| 103 | 103 | PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePageByCustomerId(pageReqVO); |
| 104 | - return success(convertDetailReceivablePage(pageResult)); | |
| 104 | + return success(buildReceivableDetailPage(pageResult)); | |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // TODO 芋艿:后面在优化导出 |
| ... | ... | @@ -115,16 +115,16 @@ public class CrmReceivableController { |
| 115 | 115 | PageResult<CrmReceivableDO> pageResult = receivableService.getReceivablePage(exportReqVO, getLoginUserId()); |
| 116 | 116 | // 导出 Excel |
| 117 | 117 | ExcelUtils.write(response, "回款.xls", "数据", CrmReceivableRespVO.class, |
| 118 | - convertDetailReceivablePage(pageResult).getList()); | |
| 118 | + buildReceivableDetailPage(pageResult).getList()); | |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | - * 转换成详细的回款分页,即读取关联信息 | |
| 122 | + * 构建详细的回款分页结果 | |
| 123 | 123 | * |
| 124 | - * @param pageResult 回款分页 | |
| 125 | - * @return 详细的回款分页 | |
| 124 | + * @param pageResult 简单的回款分页结果 | |
| 125 | + * @return 详细的回款分页结果 | |
| 126 | 126 | */ |
| 127 | - private PageResult<CrmReceivableRespVO> convertDetailReceivablePage(PageResult<CrmReceivableDO> pageResult) { | |
| 127 | + private PageResult<CrmReceivableRespVO> buildReceivableDetailPage(PageResult<CrmReceivableDO> pageResult) { | |
| 128 | 128 | List<CrmReceivableDO> receivableList = pageResult.getList(); |
| 129 | 129 | if (CollUtil.isEmpty(receivableList)) { |
| 130 | 130 | return PageResult.empty(pageResult.getTotal()); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java
| ... | ... | @@ -123,10 +123,10 @@ public class CrmReceivablePlanController { |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | - * 转换成详细的回款计划分页,即读取关联信息 | |
| 126 | + * 构建详细的回款计划分页结果 | |
| 127 | 127 | * |
| 128 | - * @param pageResult 回款计划分页 | |
| 129 | - * @return 详细的回款计划分页 | |
| 128 | + * @param pageResult 简单的回款计划分页结果 | |
| 129 | + * @return 详细的回款计划分页结果 | |
| 130 | 130 | */ |
| 131 | 131 | private PageResult<CrmReceivablePlanRespVO> convertDetailReceivablePlanPage(PageResult<CrmReceivablePlanDO> pageResult) { |
| 132 | 132 | List<CrmReceivablePlanDO> receivablePlanList = pageResult.getList(); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.convert.business; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 4 | 5 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*; |
| 5 | 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 6 | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; |
| ... | ... | @@ -9,7 +10,6 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 9 | 10 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| 10 | 11 | import org.mapstruct.Mapper; |
| 11 | 12 | import org.mapstruct.Mapping; |
| 12 | -import org.mapstruct.Mappings; | |
| 13 | 13 | import org.mapstruct.factory.Mappers; |
| 14 | 14 | |
| 15 | 15 | import java.util.List; |
| ... | ... | @@ -34,25 +34,23 @@ public interface CrmBusinessConvert { |
| 34 | 34 | CrmBusinessRespVO convert(CrmBusinessDO bean); |
| 35 | 35 | List<CrmBusinessRespVO> convert(List<CrmBusinessDO> bean); |
| 36 | 36 | |
| 37 | - PageResult<CrmBusinessRespVO> convertPage(PageResult<CrmBusinessDO> page); | |
| 38 | - | |
| 39 | 37 | List<CrmBusinessExcelVO> convertList02(List<CrmBusinessDO> list); |
| 40 | 38 | |
| 41 | 39 | @Mapping(target = "bizId", source = "reqVO.id") |
| 42 | 40 | CrmPermissionTransferReqBO convert(CrmBusinessTransferReqVO reqVO, Long userId); |
| 43 | 41 | |
| 44 | - default PageResult<CrmBusinessRespVO> convertPage(PageResult<CrmBusinessDO> page, List<CrmCustomerDO> customerList, | |
| 42 | + default PageResult<CrmBusinessRespVO> convertPage(PageResult<CrmBusinessDO> pageResult, List<CrmCustomerDO> customerList, | |
| 45 | 43 | List<CrmBusinessStatusTypeDO> statusTypeList, List<CrmBusinessStatusDO> statusList) { |
| 46 | - PageResult<CrmBusinessRespVO> result = convertPage(page); | |
| 44 | + PageResult<CrmBusinessRespVO> voPageResult = BeanUtils.toBean(pageResult, CrmBusinessRespVO.class); | |
| 47 | 45 | // 拼接关联字段 |
| 48 | 46 | Map<Long, String> customerMap = convertMap(customerList, CrmCustomerDO::getId, CrmCustomerDO::getName); |
| 49 | 47 | Map<Long, String> statusTypeMap = convertMap(statusTypeList, CrmBusinessStatusTypeDO::getId, CrmBusinessStatusTypeDO::getName); |
| 50 | 48 | Map<Long, String> statusMap = convertMap(statusList, CrmBusinessStatusDO::getId, CrmBusinessStatusDO::getName); |
| 51 | - result.getList().forEach(type -> type | |
| 49 | + voPageResult.getList().forEach(type -> type | |
| 52 | 50 | .setCustomerName(customerMap.get(type.getCustomerId())) |
| 53 | 51 | .setStatusTypeName(statusTypeMap.get(type.getStatusTypeId())) |
| 54 | 52 | .setStatusName(statusMap.get(type.getStatusId()))); |
| 55 | - return result; | |
| 53 | + return voPageResult; | |
| 56 | 54 | } |
| 57 | 55 | |
| 58 | 56 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/CrmContactConvert.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.convert.contact; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 5 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 5 | 6 | import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; |
| 6 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; |
| 7 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| ... | ... | @@ -18,7 +19,6 @@ import java.util.Map; |
| 18 | 19 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; |
| 19 | 20 | import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; |
| 20 | 21 | |
| 21 | -// TODO 芋艿:convert 后面在梳理下,略微有点乱 | |
| 22 | 22 | /** |
| 23 | 23 | * CRM 联系人 Convert |
| 24 | 24 | * |
| ... | ... | @@ -39,64 +39,39 @@ public interface CrmContactConvert { |
| 39 | 39 | |
| 40 | 40 | PageResult<CrmContactRespVO> convertPage(PageResult<CrmContactDO> page); |
| 41 | 41 | |
| 42 | - default PageResult<CrmContactRespVO> convertPage(PageResult<CrmContactDO> pageResult, Map<Long, AdminUserRespDTO> userMap, | |
| 43 | - List<CrmCustomerDO> customerList, List<CrmContactDO> parentContactList) { | |
| 44 | - List<CrmContactRespVO> list = converList(pageResult.getList(), userMap, customerList, parentContactList); | |
| 45 | - return convertPage(pageResult).setList(list); | |
| 46 | - } | |
| 47 | - | |
| 48 | 42 | List<CrmContactSimpleRespVO> convertAllList(List<CrmContactDO> list); |
| 49 | 43 | |
| 50 | 44 | @Mapping(target = "bizId", source = "reqVO.id") |
| 51 | 45 | CrmPermissionTransferReqBO convert(CrmContactTransferReqVO reqVO, Long userId); |
| 52 | 46 | |
| 53 | - /** | |
| 54 | - * 转换详情信息 | |
| 55 | - * | |
| 56 | - * @param contactDO 联系人 | |
| 57 | - * @param userMap 用户列表 | |
| 58 | - * @param customerDOList 客户 | |
| 59 | - * @return ContactRespVO | |
| 60 | - */ | |
| 47 | + default PageResult<CrmContactRespVO> convertPage(PageResult<CrmContactDO> pageResult, Map<Long, AdminUserRespDTO> userMap, | |
| 48 | + List<CrmCustomerDO> customerList, List<CrmContactDO> parentContactList) { | |
| 49 | + PageResult<CrmContactRespVO> voPageResult = BeanUtils.toBean(pageResult, CrmContactRespVO.class); | |
| 50 | + // 拼接关联字段 | |
| 51 | + Map<Long, CrmContactDO> parentContactMap = convertMap(parentContactList, CrmContactDO::getId); | |
| 52 | + Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId); | |
| 53 | + voPageResult.getList().forEach(item -> { | |
| 54 | + setUserInfo(item, userMap); | |
| 55 | + findAndThen(customerMap, item.getCustomerId(), customer -> item.setCustomerName(customer.getName())); | |
| 56 | + findAndThen(parentContactMap, item.getParentId(), contactDO -> item.setParentName(contactDO.getName())); | |
| 57 | + }); | |
| 58 | + return voPageResult; | |
| 59 | + } | |
| 60 | + | |
| 61 | 61 | default CrmContactRespVO convert(CrmContactDO contactDO, Map<Long, AdminUserRespDTO> userMap, |
| 62 | - List<CrmCustomerDO> customerDOList, List<CrmContactDO> contactList) { | |
| 62 | + List<CrmCustomerDO> customerList, List<CrmContactDO> parentContactList) { | |
| 63 | 63 | CrmContactRespVO contactVO = convert(contactDO); |
| 64 | 64 | setUserInfo(contactVO, userMap); |
| 65 | - Map<Long, CrmCustomerDO> customerMap = CollectionUtils.convertMap(customerDOList, CrmCustomerDO::getId); | |
| 66 | - Map<Long, CrmContactDO> contactMap = CollectionUtils.convertMap(contactList, CrmContactDO::getId); | |
| 65 | + Map<Long, CrmCustomerDO> customerMap = CollectionUtils.convertMap(customerList, CrmCustomerDO::getId); | |
| 66 | + Map<Long, CrmContactDO> contactMap = CollectionUtils.convertMap(parentContactList, CrmContactDO::getId); | |
| 67 | 67 | findAndThen(customerMap, contactDO.getCustomerId(), customer -> contactVO.setCustomerName(customer.getName())); |
| 68 | 68 | findAndThen(contactMap, contactDO.getParentId(), contact -> contactVO.setParentName(contact.getName())); |
| 69 | 69 | return contactVO; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - default List<CrmContactRespVO> converList(List<CrmContactDO> contactList, Map<Long, AdminUserRespDTO> userMap, | |
| 73 | - List<CrmCustomerDO> customerList, List<CrmContactDO> parentContactList) { | |
| 74 | - List<CrmContactRespVO> result = convertList(contactList); | |
| 75 | - Map<Long, CrmContactDO> parentContactMap = convertMap(parentContactList, CrmContactDO::getId); | |
| 76 | - Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId); | |
| 77 | - result.forEach(item -> { | |
| 78 | - setUserInfo(item, userMap); | |
| 79 | - findAndThen(customerMap, item.getCustomerId(), customer -> | |
| 80 | - item.setCustomerName(customer.getName()) | |
| 81 | - ); | |
| 82 | - findAndThen(parentContactMap, item.getParentId(), contactDO -> | |
| 83 | - item.setParentName(contactDO.getName()) | |
| 84 | - ); | |
| 85 | - }); | |
| 86 | - return result; | |
| 87 | - } | |
| 88 | - | |
| 89 | - /** | |
| 90 | - * 设置用户信息 | |
| 91 | - * | |
| 92 | - * @param contactRespVO 联系人Response VO | |
| 93 | - * @param userMap 用户信息 map | |
| 94 | - */ | |
| 95 | 72 | static void setUserInfo(CrmContactRespVO contactRespVO, Map<Long, AdminUserRespDTO> userMap) { |
| 96 | 73 | contactRespVO.setAreaName(AreaUtils.format(contactRespVO.getAreaId())); |
| 97 | - findAndThen(userMap, contactRespVO.getOwnerUserId(), user -> { | |
| 98 | - contactRespVO.setOwnerUserName(user == null ? "" : user.getNickname()); | |
| 99 | - }); | |
| 74 | + findAndThen(userMap, contactRespVO.getOwnerUserId(), user -> contactRespVO.setOwnerUserName(user.getNickname())); | |
| 100 | 75 | findAndThen(userMap, Long.parseLong(contactRespVO.getCreator()), user -> contactRespVO.setCreatorName(user.getNickname())); |
| 101 | 76 | } |
| 102 | 77 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/CrmContractConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.convert.contract; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 4 | 5 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; |
| 5 | 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; |
| 6 | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| ... | ... | @@ -43,23 +44,15 @@ public interface CrmContractConvert { |
| 43 | 44 | |
| 44 | 45 | default PageResult<ContractRespVO> convertPage(PageResult<CrmContractDO> pageResult, Map<Long, AdminUserRespDTO> userMap, |
| 45 | 46 | List<CrmCustomerDO> customerList) { |
| 46 | - return new PageResult<>(converList(pageResult.getList(), userMap, customerList), pageResult.getTotal()); | |
| 47 | - } | |
| 48 | - | |
| 49 | - default List<ContractRespVO> converList(List<CrmContractDO> contractList, Map<Long, AdminUserRespDTO> userMap, | |
| 50 | - List<CrmCustomerDO> customerList) { | |
| 51 | - List<ContractRespVO> result = convertList(contractList); | |
| 47 | + PageResult<ContractRespVO> voPageResult = BeanUtils.toBean(pageResult, ContractRespVO.class); | |
| 48 | + // 拼接关联字段 | |
| 52 | 49 | Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId); |
| 53 | - result.forEach(item -> { | |
| 54 | - setUserInfo(item, userMap); | |
| 55 | - findAndThen(customerMap, item.getCustomerId(), customer -> item.setCustomerName(customer.getName())); | |
| 50 | + voPageResult.getList().forEach(contract -> { | |
| 51 | + findAndThen(userMap, contract.getOwnerUserId(), user -> contract.setOwnerUserName(user.getNickname())); | |
| 52 | + findAndThen(userMap, Long.parseLong(contract.getCreator()), user -> contract.setCreatorName(user.getNickname())); | |
| 53 | + findAndThen(customerMap, contract.getCustomerId(), customer -> contract.setCustomerName(customer.getName())); | |
| 56 | 54 | }); |
| 57 | - return result; | |
| 58 | - } | |
| 59 | - | |
| 60 | - static void setUserInfo(ContractRespVO contract, Map<Long, AdminUserRespDTO> userMap) { | |
| 61 | - findAndThen(userMap, contract.getOwnerUserId(), user -> contract.setOwnerUserName(user.getNickname())); | |
| 62 | - findAndThen(userMap, Long.parseLong(contract.getCreator()), user -> contract.setCreatorName(user.getNickname())); | |
| 55 | + return voPageResult; | |
| 63 | 56 | } |
| 64 | 57 | |
| 65 | 58 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivableConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.convert.receivable; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 4 | 5 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO; |
| 5 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; |
| 6 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableTransferReqVO; |
| ... | ... | @@ -36,29 +37,19 @@ public interface CrmReceivableConvert { |
| 36 | 37 | |
| 37 | 38 | CrmReceivableRespVO convert(CrmReceivableDO bean); |
| 38 | 39 | |
| 39 | - List<CrmReceivableRespVO> convertList(List<CrmReceivableDO> list); | |
| 40 | - | |
| 41 | 40 | default PageResult<CrmReceivableRespVO> convertPage(PageResult<CrmReceivableDO> pageResult, Map<Long, AdminUserRespDTO> userMap, |
| 42 | 41 | List<CrmCustomerDO> customerList, List<CrmContractDO> contractList) { |
| 43 | - return new PageResult<>(converList(pageResult.getList(), userMap, customerList, contractList), pageResult.getTotal()); | |
| 44 | - } | |
| 45 | - | |
| 46 | - default List<CrmReceivableRespVO> converList(List<CrmReceivableDO> receivableList, Map<Long, AdminUserRespDTO> userMap, | |
| 47 | - List<CrmCustomerDO> customerList, List<CrmContractDO> contractList) { | |
| 48 | - List<CrmReceivableRespVO> result = convertList(receivableList); | |
| 42 | + PageResult<CrmReceivableRespVO> voPageResult = BeanUtils.toBean(pageResult, CrmReceivableRespVO.class); | |
| 43 | + // 拼接关联字段 | |
| 49 | 44 | Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId); |
| 50 | 45 | Map<Long, CrmContractDO> contractMap = convertMap(contractList, CrmContractDO::getId); |
| 51 | - result.forEach(item -> { | |
| 52 | - setUserInfo(item, userMap); | |
| 53 | - findAndThen(customerMap, item.getCustomerId(), customer -> item.setCustomerName(customer.getName())); | |
| 54 | - findAndThen(contractMap, item.getContractId(), contract -> item.setContractNo(contract.getNo())); | |
| 46 | + voPageResult.getList().forEach(receivable -> { | |
| 47 | + findAndThen(userMap, receivable.getOwnerUserId(), user -> receivable.setOwnerUserName(user.getNickname())); | |
| 48 | + findAndThen(userMap, Long.parseLong(receivable.getCreator()), user -> receivable.setCreatorName(user.getNickname())); | |
| 49 | + findAndThen(customerMap, receivable.getCustomerId(), customer -> receivable.setCustomerName(customer.getName())); | |
| 50 | + findAndThen(contractMap, receivable.getContractId(), contract -> receivable.setContractNo(contract.getNo())); | |
| 55 | 51 | }); |
| 56 | - return result; | |
| 57 | - } | |
| 58 | - | |
| 59 | - static void setUserInfo(CrmReceivableRespVO receivable, Map<Long, AdminUserRespDTO> userMap) { | |
| 60 | - findAndThen(userMap, receivable.getOwnerUserId(), user -> receivable.setOwnerUserName(user.getNickname())); | |
| 61 | - findAndThen(userMap, Long.parseLong(receivable.getCreator()), user -> receivable.setCreatorName(user.getNickname())); | |
| 52 | + return voPageResult; | |
| 62 | 53 | } |
| 63 | 54 | |
| 64 | 55 | @Mapping(target = "bizId", source = "reqVO.id") | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivablePlanConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.convert.receivable; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | |
| 4 | 5 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanCreateReqVO; |
| 5 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanRespVO; |
| 6 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanTransferReqVO; |
| ... | ... | @@ -37,33 +38,22 @@ public interface CrmReceivablePlanConvert { |
| 37 | 38 | |
| 38 | 39 | CrmReceivablePlanRespVO convert(CrmReceivablePlanDO bean); |
| 39 | 40 | |
| 40 | - List<CrmReceivablePlanRespVO> convertList(List<CrmReceivablePlanDO> list); | |
| 41 | - | |
| 42 | 41 | default PageResult<CrmReceivablePlanRespVO> convertPage(PageResult<CrmReceivablePlanDO> pageResult, Map<Long, AdminUserRespDTO> userMap, |
| 43 | 42 | List<CrmCustomerDO> customerList, List<CrmContractDO> contractList, |
| 44 | 43 | List<CrmReceivableDO> receivableList) { |
| 45 | - return new PageResult<>(converList(pageResult.getList(), userMap, customerList, contractList, receivableList), pageResult.getTotal()); | |
| 46 | - } | |
| 47 | - | |
| 48 | - default List<CrmReceivablePlanRespVO> converList(List<CrmReceivablePlanDO> receivablePlanList, Map<Long, AdminUserRespDTO> userMap, | |
| 49 | - List<CrmCustomerDO> customerList, List<CrmContractDO> contractList, | |
| 50 | - List<CrmReceivableDO> receivableList) { | |
| 51 | - List<CrmReceivablePlanRespVO> result = convertList(receivablePlanList); | |
| 44 | + PageResult<CrmReceivablePlanRespVO> voPageResult = BeanUtils.toBean(pageResult, CrmReceivablePlanRespVO.class); | |
| 45 | + // 拼接关联字段 | |
| 52 | 46 | Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId); |
| 53 | 47 | Map<Long, CrmContractDO> contractMap = convertMap(contractList, CrmContractDO::getId); |
| 54 | 48 | Map<Long, CrmReceivableDO> receivableMap = convertMap(receivableList, CrmReceivableDO::getId); |
| 55 | - result.forEach(item -> { | |
| 56 | - setUserInfo(item, userMap); | |
| 57 | - findAndThen(customerMap, item.getCustomerId(), customer -> item.setCustomerName(customer.getName())); | |
| 58 | - findAndThen(contractMap, item.getContractId(), contract -> item.setContractNo(contract.getNo())); | |
| 59 | - findAndThen(receivableMap, item.getReceivableId(), receivable -> item.setReturnType(receivable.getReturnType())); | |
| 49 | + voPageResult.getList().forEach(receivablePlan -> { | |
| 50 | + findAndThen(userMap, receivablePlan.getOwnerUserId(), user -> receivablePlan.setOwnerUserName(user.getNickname())); | |
| 51 | + findAndThen(userMap, Long.parseLong(receivablePlan.getCreator()), user -> receivablePlan.setCreatorName(user.getNickname())); | |
| 52 | + findAndThen(customerMap, receivablePlan.getCustomerId(), customer -> receivablePlan.setCustomerName(customer.getName())); | |
| 53 | + findAndThen(contractMap, receivablePlan.getContractId(), contract -> receivablePlan.setContractNo(contract.getNo())); | |
| 54 | + findAndThen(receivableMap, receivablePlan.getReceivableId(), receivable -> receivablePlan.setReturnType(receivable.getReturnType())); | |
| 60 | 55 | }); |
| 61 | - return result; | |
| 62 | - } | |
| 63 | - | |
| 64 | - static void setUserInfo(CrmReceivablePlanRespVO receivablePlan, Map<Long, AdminUserRespDTO> userMap) { | |
| 65 | - findAndThen(userMap, receivablePlan.getOwnerUserId(), user -> receivablePlan.setOwnerUserName(user.getNickname())); | |
| 66 | - findAndThen(userMap, Long.parseLong(receivablePlan.getCreator()), user -> receivablePlan.setCreatorName(user.getNickname())); | |
| 56 | + return voPageResult; | |
| 67 | 57 | } |
| 68 | 58 | |
| 69 | 59 | @Mapping(target = "bizId", source = "reqVO.id") | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| ... | ... | @@ -105,11 +105,13 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 105 | 105 | public void deleteCustomer(Long id) { |
| 106 | 106 | // 校验存在 |
| 107 | 107 | validateCustomerExists(id); |
| 108 | + // TODO @puhui999:如果有联系人、商机,则不允许删除; | |
| 108 | 109 | |
| 109 | 110 | // 删除 |
| 110 | 111 | customerMapper.deleteById(id); |
| 111 | 112 | // 删除数据权限 |
| 112 | 113 | permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), id); |
| 114 | + // TODO @puhui999:删除跟进记录 | |
| 113 | 115 | } |
| 114 | 116 | |
| 115 | 117 | private CrmCustomerDO validateCustomerExists(Long id) { |
| ... | ... | @@ -151,7 +153,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 151 | 153 | |
| 152 | 154 | @Override |
| 153 | 155 | @Transactional(rollbackFor = Exception.class) |
| 154 | - @LogRecord(type = CRM_CUSTOMER, subType = "客户转移", bizNo = "{{#reqVO.id}}", success = TRANSFER_CUSTOMER_LOG_SUCCESS) | |
| 156 | + @LogRecord(type = CRM_CUSTOMER, subType = "转移客户", bizNo = "{{#reqVO.id}}", success = TRANSFER_CUSTOMER_LOG_SUCCESS) | |
| 155 | 157 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) |
| 156 | 158 | public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) { |
| 157 | 159 | // 1.1 校验客户是否存在 |
| ... | ... | @@ -235,7 +237,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 235 | 237 | |
| 236 | 238 | @Override |
| 237 | 239 | @Transactional(rollbackFor = Exception.class) |
| 238 | - @LogRecord(type = CRM_CUSTOMER, subType = "客户放入公海", bizNo = "{{#id}}", success = "将客户放入了公海") | |
| 240 | + @LogRecord(type = CRM_CUSTOMER, subType = "客户放入公海", bizNo = "{{#id}}", success = "将客户放入了公海") // TODO @puhui999:将客户【】放入了公海 | |
| 239 | 241 | @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) |
| 240 | 242 | public void putCustomerPool(Long id) { |
| 241 | 243 | // 1. 校验存在 |
| ... | ... | @@ -256,10 +258,16 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 256 | 258 | // 3. 删除负责人数据权限 |
| 257 | 259 | permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), customer.getId(), |
| 258 | 260 | CrmPermissionLevelEnum.OWNER.getLevel()); |
| 261 | + // TODO @puhui999:联系人的负责人,也要设置为 null;这块和领取是对应的;因为领取后,负责人也要关联过来; | |
| 259 | 262 | } |
| 260 | 263 | |
| 261 | 264 | @Override |
| 262 | 265 | @Transactional(rollbackFor = Exception.class) |
| 266 | + // TODO @puhui999:权限校验 | |
| 267 | + | |
| 268 | + // TODO @puhui999:如果是分配,操作日志是 “将客户【】分配给【】” | |
| 269 | + // TODO @puhui999:如果是领取,操作日志是“领取客户【】”; | |
| 270 | + // TODO @puhui999:如果是多条,则需要记录多条操作日志;不然 bizId 不好关联 | |
| 263 | 271 | public void receiveCustomer(List<Long> ids, Long ownerUserId) { |
| 264 | 272 | // 1.1 校验存在 |
| 265 | 273 | List<CrmCustomerDO> customers = customerMapper.selectBatchIds(ids); |
| ... | ... | @@ -280,7 +288,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 280 | 288 | // 1.4 校验负责人是否到达上限 |
| 281 | 289 | validateCustomerExceedOwnerLimit(ownerUserId, customers.size()); |
| 282 | 290 | |
| 283 | - // 2. 领取公海数据 | |
| 291 | + // 2.1 领取公海数据 | |
| 284 | 292 | List<CrmCustomerDO> updateCustomers = new ArrayList<>(); |
| 285 | 293 | List<CrmPermissionCreateReqBO> createPermissions = new ArrayList<>(); |
| 286 | 294 | customers.forEach(customer -> { |
| ... | ... | @@ -290,11 +298,11 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 290 | 298 | createPermissions.add(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) |
| 291 | 299 | .setBizId(customer.getId()).setUserId(ownerUserId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); |
| 292 | 300 | }); |
| 293 | - | |
| 294 | - // 3.1 更新客户负责人 | |
| 301 | + // 2.2 更新客户负责人 | |
| 295 | 302 | customerMapper.updateBatch(updateCustomers); |
| 296 | - // 3.2 创建负责人数据权限 | |
| 303 | + // 2.3 创建负责人数据权限 | |
| 297 | 304 | permissionService.createPermissionBatch(createPermissions); |
| 305 | + // TODO @芋艿:要不要处理关联的联系人??? | |
| 298 | 306 | } |
| 299 | 307 | |
| 300 | 308 | private void validateCustomerOwnerExists(CrmCustomerDO customer, Boolean pool) { | ... | ... |