diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessSaveReqVO.java index c3b167ef1..0be6264eb 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessSaveReqVO.java +++ b/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 { @Schema(description = "联系人编号", example = "110") private Long contactId; // 使用场景,在【联系人详情】添加商机时,如果需要关联两者,需要传递 contactId 字段 + // TODO @puhui999:传递 items 就行啦; @Schema(description = "产品列表") private List productItems; @@ -86,7 +87,7 @@ public class CrmBusinessSaveReqVO { @AllArgsConstructor public static class CrmBusinessProductItem { - @Schema(description = "产品编号", example = "20529") + @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20529") @NotNull(message = "产品编号不能为空") private Long id; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java index 7574e534a..ace5d1817 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java +++ b/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; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; +import static java.util.Collections.singletonList; @Tag(name = "管理后台 - CRM 合同") @RestController @@ -102,7 +103,7 @@ public class CrmContractController { } // 2. 拼接合同信息 - List respVOList = buildContractDetailList(Collections.singletonList(contract)); + List respVOList = buildContractDetailList(singletonList(contract)); return success(respVOList.get(0)); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractRespVO.java index 6b60afc2a..da6239414 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractRespVO.java @@ -132,6 +132,7 @@ public class CrmContractRespVO { @Schema(description = "产品列表") private List productItems; + // TODO @puhui999:可以直接叫 Item @Schema(description = "产品列表") @Data @NoArgsConstructor diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/CrmContractConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/CrmContractConvert.java index 444876040..0d2e49934 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/CrmContractConvert.java +++ b/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 { List productList) { respVO.setProductItems(CollectionUtils.convertList(productList, product -> { CrmContractRespVO.CrmContractProductItemRespVO productItemRespVO = BeanUtils.toBean(product, CrmContractRespVO.CrmContractProductItemRespVO.class); - findAndThen(contractProductMap, product.getId(), contractProduct -> { - productItemRespVO.setCount(contractProduct.getCount()).setDiscountPercent(contractProduct.getDiscountPercent()); - }); + findAndThen(contractProductMap, product.getId(), contractProduct -> + productItemRespVO.setCount(contractProduct.getCount()).setDiscountPercent(contractProduct.getDiscountPercent())); return productItemRespVO; })); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractProductDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractProductDO.java index f0f506857..bc977c78f 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractProductDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractProductDO.java @@ -57,6 +57,8 @@ public class CrmContractProductDO extends BaseDO { private Integer discountPercent; /** * 总计价格(折扣后价格) + * + * TODO @puhui999:可以写下计算公式哈; */ private Integer totalPrice; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java index 35fccdbdf..2d1471c73 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java +++ b/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; @Mapper public interface CrmBusinessProductMapper extends BaseMapperX { - default void deleteByBusinessId(Long id) { // TODO @lzxhqs:第一个方法,和类之间最好空一行; - delete(CrmBusinessProductDO::getBusinessId, id); + // TODO @puhui999:用不到的方法,看看是不是删除哈 + default void deleteByBusinessId(Long getBusinessId) { // TODO @lzxhqs:第一个方法,和类之间最好空一行; + delete(CrmBusinessProductDO::getBusinessId, getBusinessId); } - default CrmBusinessProductDO selectByBusinessId(Long id) { - return selectOne(CrmBusinessProductDO::getBusinessId, id); + default CrmBusinessProductDO selectByBusinessId(Long getBusinessId) { + return selectOne(CrmBusinessProductDO::getBusinessId, getBusinessId); } default List selectListByBusinessId(Long businessId) { + // TODO @puhui999:可以简化,selectList(CrmBusinessProductDO::getBusinessId, businessId) return selectList(new LambdaQueryWrapperX().eq(CrmBusinessProductDO::getBusinessId, businessId)); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractProductMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractProductMapper.java index fd6347a9e..814024125 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractProductMapper.java +++ b/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; @Mapper public interface CrmContractProductMapper extends BaseMapperX { + // TODO @puhui999:用不到的方法,看看是不是删除哈 default void deleteByContractId(Long contractId) { // TODO @lzxhqs:第一个方法,和类之间最好空一行; delete(CrmContractProductDO::getContractId, contractId); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java index 5f80e5337..535578fd2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java +++ b/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 { businessMapper.insert(business); // 1.2 插入商机关联商品 if (CollUtil.isNotEmpty(createReqVO.getProductItems())) { // 如果有的话 - List productList = convertBusinessProductList(createReqVO.getProductItems(), business.getId()); + List productList = buildBusinessProductList(createReqVO.getProductItems(), business.getId()); businessProductMapper.insertBatch(productList); // 更新合同商品总金额 businessMapper.updateById(new CrmBusinessDO().setId(business.getId()).setProductPrice( getSumValue(productList, CrmBusinessProductDO::getTotalPrice, Integer::sum))); } - // TODO 商机待定:在联系人的详情页,如果直接【新建商机】,则需要关联下。这里要搞个 CrmContactBusinessDO 表 + // TODO @puhui999:在联系人的详情页,如果直接【新建商机】,则需要关联下。这里要搞个 CrmContactBusinessDO 表 createContactBusiness(business.getId(), createReqVO.getContactId()); // 2. 创建数据权限 @@ -95,7 +95,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType()) .setBizId(business.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - // 4. 记录操作日志上下文 + // 3. 记录操作日志上下文 LogRecordContext.putVariable("business", business); return business.getId(); } @@ -121,7 +121,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { CrmBusinessDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessDO.class); businessMapper.updateById(updateObj); // 2.2 更新商机关联商品 - List productList = convertBusinessProductList(updateReqVO.getProductItems(), updateObj.getId()); + List productList = buildBusinessProductList(updateReqVO.getProductItems(), updateObj.getId()); updateBusinessProduct(productList, updateObj.getId()); // TODO @商机待定:如果状态发生变化,插入商机状态变更记录表 @@ -175,7 +175,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { } } - private List convertBusinessProductList(List productItems, Long businessId) { + private List buildBusinessProductList(List productItems, + Long businessId) { // 校验商品存在 Set productIds = convertSet(productItems, CrmBusinessSaveReqVO.CrmBusinessProductItem::getId); List productList = productService.getProductList(productIds); @@ -235,7 +236,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { @Override public void updateBusinessProduct(CrmBusinessUpdateProductReqBO updateProductReqBO) { // 更新商机关联商品 - List productList = convertBusinessProductList( + List productList = buildBusinessProductList( BeanUtils.toBean(updateProductReqBO.getProductItems(), CrmBusinessSaveReqVO.CrmBusinessProductItem.class), updateProductReqBO.getId()); updateBusinessProduct(productList, updateProductReqBO.getId()); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/bo/CrmBusinessUpdateProductReqBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/bo/CrmBusinessUpdateProductReqBO.java index 4291df262..34b2fa381 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/bo/CrmBusinessUpdateProductReqBO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/bo/CrmBusinessUpdateProductReqBO.java @@ -23,6 +23,7 @@ public class CrmBusinessUpdateProductReqBO { @NotNull(message = "商机编号不能为空") private Long id; + // TODO @芋艿:再想想 @NotEmpty(message = "产品列表不能为空") private List productItems; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java index fbf736699..79d05263c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java +++ b/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 @Validated public class CrmContractServiceImpl implements CrmContractService { - public static final String CONTRACT_APPROVE = "contract-approve"; // 合同审批流程标识 + /** + * BPM 合同审批流程标识 + */ + public static final String CONTRACT_APPROVE = "contract-approve"; @Resource private CrmContractMapper contractMapper; @@ -149,11 +152,11 @@ public class CrmContractServiceImpl implements CrmContractService { List newProductList = convertContractProductList(updateReqVO, contractId); List oldProductList = contractProductMapper.selectListByContractId(contractId); List> diffList = diffList(oldProductList, newProductList, (oldObj, newObj) -> { - boolean equal = ObjUtil.equal(oldObj.getProductId(), newObj.getProductId()); - if (equal) { + boolean match = ObjUtil.equal(oldObj.getProductId(), newObj.getProductId()); + if (match) { newObj.setId(oldObj.getId()); // 设置一下老的编号更新时需要使用 } - return equal; + return match; }); if (CollUtil.isNotEmpty(diffList.get(0))) { contractProductMapper.insertBatch(diffList.get(0)); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java index 8230ba4e2..bc02a6b71 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ b/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 { CrmCustomerDO customer = initCustomer(importCustomer, importReqVO.getOwnerUserId()); customerMapper.insert(customer); respVO.getCreateCustomerNames().add(importCustomer.getName()); + // 1.2 创建数据权限 if (importReqVO.getOwnerUserId() != null) { - // 1.2 创建数据权限 permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()) - .setBizId(customer.getId()).setUserId(importReqVO.getOwnerUserId()).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 + .setBizId(customer.getId()).setUserId(importReqVO.getOwnerUserId()).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); } // 1.3 记录操作日志 getSelf().importCustomerLog(customer, false);