Commit 0fba56cda88f443e4fd2fb651a99ef5cfba349de
1 parent
c6041da3
📖 CRM:code review 合同逻辑
Showing
11 changed files
with
33 additions
and
21 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessSaveReqVO.java
| ... | ... | @@ -77,6 +77,7 @@ public class CrmBusinessSaveReqVO { |
| 77 | 77 | @Schema(description = "联系人编号", example = "110") |
| 78 | 78 | private Long contactId; // 使用场景,在【联系人详情】添加商机时,如果需要关联两者,需要传递 contactId 字段 |
| 79 | 79 | |
| 80 | + // TODO @puhui999:传递 items 就行啦; | |
| 80 | 81 | @Schema(description = "产品列表") |
| 81 | 82 | private List<CrmBusinessProductItem> productItems; |
| 82 | 83 | |
| ... | ... | @@ -86,7 +87,7 @@ public class CrmBusinessSaveReqVO { |
| 86 | 87 | @AllArgsConstructor |
| 87 | 88 | public static class CrmBusinessProductItem { |
| 88 | 89 | |
| 89 | - @Schema(description = "产品编号", example = "20529") | |
| 90 | + @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") | |
| 90 | 91 | @NotNull(message = "产品编号不能为空") |
| 91 | 92 | private Long id; |
| 92 | 93 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java
| ... | ... | @@ -46,6 +46,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 46 | 46 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; |
| 47 | 47 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 48 | 48 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 49 | +import static java.util.Collections.singletonList; | |
| 49 | 50 | |
| 50 | 51 | @Tag(name = "管理后台 - CRM 合同") |
| 51 | 52 | @RestController |
| ... | ... | @@ -102,7 +103,7 @@ public class CrmContractController { |
| 102 | 103 | } |
| 103 | 104 | |
| 104 | 105 | // 2. 拼接合同信息 |
| 105 | - List<CrmContractRespVO> respVOList = buildContractDetailList(Collections.singletonList(contract)); | |
| 106 | + List<CrmContractRespVO> respVOList = buildContractDetailList(singletonList(contract)); | |
| 106 | 107 | return success(respVOList.get(0)); |
| 107 | 108 | } |
| 108 | 109 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractRespVO.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/CrmContractConvert.java
| ... | ... | @@ -61,9 +61,8 @@ public interface CrmContractConvert { |
| 61 | 61 | List<CrmProductDO> productList) { |
| 62 | 62 | respVO.setProductItems(CollectionUtils.convertList(productList, product -> { |
| 63 | 63 | CrmContractRespVO.CrmContractProductItemRespVO productItemRespVO = BeanUtils.toBean(product, CrmContractRespVO.CrmContractProductItemRespVO.class); |
| 64 | - findAndThen(contractProductMap, product.getId(), contractProduct -> { | |
| 65 | - productItemRespVO.setCount(contractProduct.getCount()).setDiscountPercent(contractProduct.getDiscountPercent()); | |
| 66 | - }); | |
| 64 | + findAndThen(contractProductMap, product.getId(), contractProduct -> | |
| 65 | + productItemRespVO.setCount(contractProduct.getCount()).setDiscountPercent(contractProduct.getDiscountPercent())); | |
| 67 | 66 | return productItemRespVO; |
| 68 | 67 | })); |
| 69 | 68 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractProductDO.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java
| ... | ... | @@ -16,15 +16,17 @@ import java.util.List; |
| 16 | 16 | @Mapper |
| 17 | 17 | public interface CrmBusinessProductMapper extends BaseMapperX<CrmBusinessProductDO> { |
| 18 | 18 | |
| 19 | - default void deleteByBusinessId(Long id) { // TODO @lzxhqs:第一个方法,和类之间最好空一行; | |
| 20 | - delete(CrmBusinessProductDO::getBusinessId, id); | |
| 19 | + // TODO @puhui999:用不到的方法,看看是不是删除哈 | |
| 20 | + default void deleteByBusinessId(Long getBusinessId) { // TODO @lzxhqs:第一个方法,和类之间最好空一行; | |
| 21 | + delete(CrmBusinessProductDO::getBusinessId, getBusinessId); | |
| 21 | 22 | } |
| 22 | 23 | |
| 23 | - default CrmBusinessProductDO selectByBusinessId(Long id) { | |
| 24 | - return selectOne(CrmBusinessProductDO::getBusinessId, id); | |
| 24 | + default CrmBusinessProductDO selectByBusinessId(Long getBusinessId) { | |
| 25 | + return selectOne(CrmBusinessProductDO::getBusinessId, getBusinessId); | |
| 25 | 26 | } |
| 26 | 27 | |
| 27 | 28 | default List<CrmBusinessProductDO> selectListByBusinessId(Long businessId) { |
| 29 | + // TODO @puhui999:可以简化,selectList(CrmBusinessProductDO::getBusinessId, businessId) | |
| 28 | 30 | return selectList(new LambdaQueryWrapperX<CrmBusinessProductDO>().eq(CrmBusinessProductDO::getBusinessId, businessId)); |
| 29 | 31 | } |
| 30 | 32 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractProductMapper.java
| ... | ... | @@ -16,6 +16,7 @@ import java.util.List; |
| 16 | 16 | @Mapper |
| 17 | 17 | public interface CrmContractProductMapper extends BaseMapperX<CrmContractProductDO> { |
| 18 | 18 | |
| 19 | + // TODO @puhui999:用不到的方法,看看是不是删除哈 | |
| 19 | 20 | default void deleteByContractId(Long contractId) { // TODO @lzxhqs:第一个方法,和类之间最好空一行; |
| 20 | 21 | delete(CrmContractProductDO::getContractId, contractId); |
| 21 | 22 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| ... | ... | @@ -81,13 +81,13 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 81 | 81 | businessMapper.insert(business); |
| 82 | 82 | // 1.2 插入商机关联商品 |
| 83 | 83 | if (CollUtil.isNotEmpty(createReqVO.getProductItems())) { // 如果有的话 |
| 84 | - List<CrmBusinessProductDO> productList = convertBusinessProductList(createReqVO.getProductItems(), business.getId()); | |
| 84 | + List<CrmBusinessProductDO> productList = buildBusinessProductList(createReqVO.getProductItems(), business.getId()); | |
| 85 | 85 | businessProductMapper.insertBatch(productList); |
| 86 | 86 | // 更新合同商品总金额 |
| 87 | 87 | businessMapper.updateById(new CrmBusinessDO().setId(business.getId()).setProductPrice( |
| 88 | 88 | getSumValue(productList, CrmBusinessProductDO::getTotalPrice, Integer::sum))); |
| 89 | 89 | } |
| 90 | - // TODO 商机待定:在联系人的详情页,如果直接【新建商机】,则需要关联下。这里要搞个 CrmContactBusinessDO 表 | |
| 90 | + // TODO @puhui999:在联系人的详情页,如果直接【新建商机】,则需要关联下。这里要搞个 CrmContactBusinessDO 表 | |
| 91 | 91 | createContactBusiness(business.getId(), createReqVO.getContactId()); |
| 92 | 92 | |
| 93 | 93 | // 2. 创建数据权限 |
| ... | ... | @@ -95,7 +95,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 95 | 95 | permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()) |
| 96 | 96 | .setBizId(business.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); |
| 97 | 97 | |
| 98 | - // 4. 记录操作日志上下文 | |
| 98 | + // 3. 记录操作日志上下文 | |
| 99 | 99 | LogRecordContext.putVariable("business", business); |
| 100 | 100 | return business.getId(); |
| 101 | 101 | } |
| ... | ... | @@ -121,7 +121,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 121 | 121 | CrmBusinessDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessDO.class); |
| 122 | 122 | businessMapper.updateById(updateObj); |
| 123 | 123 | // 2.2 更新商机关联商品 |
| 124 | - List<CrmBusinessProductDO> productList = convertBusinessProductList(updateReqVO.getProductItems(), updateObj.getId()); | |
| 124 | + List<CrmBusinessProductDO> productList = buildBusinessProductList(updateReqVO.getProductItems(), updateObj.getId()); | |
| 125 | 125 | updateBusinessProduct(productList, updateObj.getId()); |
| 126 | 126 | |
| 127 | 127 | // TODO @商机待定:如果状态发生变化,插入商机状态变更记录表 |
| ... | ... | @@ -175,7 +175,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - private List<CrmBusinessProductDO> convertBusinessProductList(List<CrmBusinessSaveReqVO.CrmBusinessProductItem> productItems, Long businessId) { | |
| 178 | + private List<CrmBusinessProductDO> buildBusinessProductList(List<CrmBusinessSaveReqVO.CrmBusinessProductItem> productItems, | |
| 179 | + Long businessId) { | |
| 179 | 180 | // 校验商品存在 |
| 180 | 181 | Set<Long> productIds = convertSet(productItems, CrmBusinessSaveReqVO.CrmBusinessProductItem::getId); |
| 181 | 182 | List<CrmProductDO> productList = productService.getProductList(productIds); |
| ... | ... | @@ -235,7 +236,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 235 | 236 | @Override |
| 236 | 237 | public void updateBusinessProduct(CrmBusinessUpdateProductReqBO updateProductReqBO) { |
| 237 | 238 | // 更新商机关联商品 |
| 238 | - List<CrmBusinessProductDO> productList = convertBusinessProductList( | |
| 239 | + List<CrmBusinessProductDO> productList = buildBusinessProductList( | |
| 239 | 240 | BeanUtils.toBean(updateProductReqBO.getProductItems(), CrmBusinessSaveReqVO.CrmBusinessProductItem.class), updateProductReqBO.getId()); |
| 240 | 241 | updateBusinessProduct(productList, updateProductReqBO.getId()); |
| 241 | 242 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/bo/CrmBusinessUpdateProductReqBO.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java
| ... | ... | @@ -61,7 +61,10 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_E |
| 61 | 61 | @Validated |
| 62 | 62 | public class CrmContractServiceImpl implements CrmContractService { |
| 63 | 63 | |
| 64 | - public static final String CONTRACT_APPROVE = "contract-approve"; // 合同审批流程标识 | |
| 64 | + /** | |
| 65 | + * BPM 合同审批流程标识 | |
| 66 | + */ | |
| 67 | + public static final String CONTRACT_APPROVE = "contract-approve"; | |
| 65 | 68 | |
| 66 | 69 | @Resource |
| 67 | 70 | private CrmContractMapper contractMapper; |
| ... | ... | @@ -149,11 +152,11 @@ public class CrmContractServiceImpl implements CrmContractService { |
| 149 | 152 | List<CrmContractProductDO> newProductList = convertContractProductList(updateReqVO, contractId); |
| 150 | 153 | List<CrmContractProductDO> oldProductList = contractProductMapper.selectListByContractId(contractId); |
| 151 | 154 | List<List<CrmContractProductDO>> diffList = diffList(oldProductList, newProductList, (oldObj, newObj) -> { |
| 152 | - boolean equal = ObjUtil.equal(oldObj.getProductId(), newObj.getProductId()); | |
| 153 | - if (equal) { | |
| 155 | + boolean match = ObjUtil.equal(oldObj.getProductId(), newObj.getProductId()); | |
| 156 | + if (match) { | |
| 154 | 157 | newObj.setId(oldObj.getId()); // 设置一下老的编号更新时需要使用 |
| 155 | 158 | } |
| 156 | - return equal; | |
| 159 | + return match; | |
| 157 | 160 | }); |
| 158 | 161 | if (CollUtil.isNotEmpty(diffList.get(0))) { |
| 159 | 162 | contractProductMapper.insertBatch(diffList.get(0)); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| ... | ... | @@ -266,10 +266,10 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { |
| 266 | 266 | CrmCustomerDO customer = initCustomer(importCustomer, importReqVO.getOwnerUserId()); |
| 267 | 267 | customerMapper.insert(customer); |
| 268 | 268 | respVO.getCreateCustomerNames().add(importCustomer.getName()); |
| 269 | + // 1.2 创建数据权限 | |
| 269 | 270 | if (importReqVO.getOwnerUserId() != null) { |
| 270 | - // 1.2 创建数据权限 | |
| 271 | 271 | permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) |
| 272 | - .setBizId(customer.getId()).setUserId(importReqVO.getOwnerUserId()).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 | |
| 272 | + .setBizId(customer.getId()).setUserId(importReqVO.getOwnerUserId()).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); | |
| 273 | 273 | } |
| 274 | 274 | // 1.3 记录操作日志 |
| 275 | 275 | getSelf().importCustomerLog(customer, false); | ... | ... |