Commit 2e7c3e09a9b1d8deba1b2dffe24e3187b3efb905

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