Commit 6a63f2f078759025905e160893a672119d78b1ee
1 parent
59e6f237
CRM-CONTRACT: 完善合同编辑回显
Showing
10 changed files
with
110 additions
and
29 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java
| @@ -10,10 +10,14 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | @@ -10,10 +10,14 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 10 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | 10 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 11 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; | 11 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; |
| 12 | import cn.iocoder.yudao.module.crm.convert.contract.CrmContractConvert; | 12 | import cn.iocoder.yudao.module.crm.convert.contract.CrmContractConvert; |
| 13 | +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; | ||
| 13 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; | 14 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; |
| 14 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | 15 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 16 | +import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; | ||
| 17 | +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessProductService; | ||
| 15 | import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; | 18 | import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; |
| 16 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; | 19 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| 20 | +import cn.iocoder.yudao.module.crm.service.product.CrmProductService; | ||
| 17 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | 21 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 18 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | 22 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 19 | import io.swagger.v3.oas.annotations.Operation; | 23 | import io.swagger.v3.oas.annotations.Operation; |
| @@ -32,8 +36,8 @@ import java.util.Map; | @@ -32,8 +36,8 @@ import java.util.Map; | ||
| 32 | import java.util.stream.Stream; | 36 | import java.util.stream.Stream; |
| 33 | 37 | ||
| 34 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 38 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 35 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; | ||
| 36 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | 39 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; |
| 40 | +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | ||
| 37 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | 41 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 38 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | 42 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 39 | 43 | ||
| @@ -47,6 +51,10 @@ public class CrmContractController { | @@ -47,6 +51,10 @@ public class CrmContractController { | ||
| 47 | private CrmContractService contractService; | 51 | private CrmContractService contractService; |
| 48 | @Resource | 52 | @Resource |
| 49 | private CrmCustomerService customerService; | 53 | private CrmCustomerService customerService; |
| 54 | + @Resource | ||
| 55 | + private CrmBusinessProductService businessProductService; | ||
| 56 | + @Resource | ||
| 57 | + private CrmProductService productService; | ||
| 50 | 58 | ||
| 51 | @Resource | 59 | @Resource |
| 52 | private AdminUserApi adminUserApi; | 60 | private AdminUserApi adminUserApi; |
| @@ -81,7 +89,18 @@ public class CrmContractController { | @@ -81,7 +89,18 @@ public class CrmContractController { | ||
| 81 | @PreAuthorize("@ss.hasPermission('crm:contract:query')") | 89 | @PreAuthorize("@ss.hasPermission('crm:contract:query')") |
| 82 | public CommonResult<CrmContractRespVO> getContract(@RequestParam("id") Long id) { | 90 | public CommonResult<CrmContractRespVO> getContract(@RequestParam("id") Long id) { |
| 83 | CrmContractDO contract = contractService.getContract(id); | 91 | CrmContractDO contract = contractService.getContract(id); |
| 84 | - return success(BeanUtils.toBean(contract, CrmContractRespVO.class)); | 92 | + CrmContractRespVO respVO = BeanUtils.toBean(contract, CrmContractRespVO.class); |
| 93 | + List<CrmBusinessProductDO> businessProductList = businessProductService.getBusinessProductListByContractId(id); | ||
| 94 | + Map<Long, CrmBusinessProductDO> businessProductMap = convertMap(businessProductList, CrmBusinessProductDO::getProductId); | ||
| 95 | + List<CrmProductDO> productList = productService.getProductListByIds(convertSet(businessProductList, CrmBusinessProductDO::getProductId)); | ||
| 96 | + respVO.setProductItems(convertList(productList, product -> { | ||
| 97 | + CrmContractRespVO.CrmContractProductItemRespVO productItemRespVO = BeanUtils.toBean(product, CrmContractRespVO.CrmContractProductItemRespVO.class); | ||
| 98 | + findAndThen(businessProductMap, product.getId(), businessProduct -> { | ||
| 99 | + productItemRespVO.setCount(businessProduct.getCount()).setDiscountPercent(businessProduct.getDiscountPercent()); | ||
| 100 | + }); | ||
| 101 | + return productItemRespVO; | ||
| 102 | + })); | ||
| 103 | + return success(respVO); | ||
| 85 | } | 104 | } |
| 86 | 105 | ||
| 87 | @GetMapping("/page") | 106 | @GetMapping("/page") |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractRespVO.java
| @@ -3,10 +3,13 @@ package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; | @@ -3,10 +3,13 @@ package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; | ||
| 3 | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | 3 | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| 4 | import com.alibaba.excel.annotation.ExcelProperty; | 4 | import com.alibaba.excel.annotation.ExcelProperty; |
| 5 | import io.swagger.v3.oas.annotations.media.Schema; | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | +import lombok.AllArgsConstructor; | ||
| 6 | import lombok.Data; | 7 | import lombok.Data; |
| 8 | +import lombok.NoArgsConstructor; | ||
| 7 | import org.springframework.format.annotation.DateTimeFormat; | 9 | import org.springframework.format.annotation.DateTimeFormat; |
| 8 | 10 | ||
| 9 | import java.time.LocalDateTime; | 11 | import java.time.LocalDateTime; |
| 12 | +import java.util.List; | ||
| 10 | 13 | ||
| 11 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | 14 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 12 | 15 | ||
| @@ -113,4 +116,36 @@ public class CrmContractRespVO { | @@ -113,4 +116,36 @@ public class CrmContractRespVO { | ||
| 113 | @ExcelProperty("审批状态") | 116 | @ExcelProperty("审批状态") |
| 114 | private Integer auditStatus; | 117 | private Integer auditStatus; |
| 115 | 118 | ||
| 119 | + @Schema(description = "产品列表") | ||
| 120 | + private List<CrmContractProductItemRespVO> productItems; | ||
| 121 | + | ||
| 122 | + @Schema(description = "产品列表") | ||
| 123 | + @Data | ||
| 124 | + @NoArgsConstructor | ||
| 125 | + @AllArgsConstructor | ||
| 126 | + public static class CrmContractProductItemRespVO { | ||
| 127 | + | ||
| 128 | + @Schema(description = "产品编号", example = "20529") | ||
| 129 | + private Long id; | ||
| 130 | + | ||
| 131 | + @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") | ||
| 132 | + private String name; | ||
| 133 | + | ||
| 134 | + @Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") | ||
| 135 | + private String no; | ||
| 136 | + | ||
| 137 | + @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") | ||
| 138 | + private Integer unit; | ||
| 139 | + | ||
| 140 | + @Schema(description = "价格,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") | ||
| 141 | + private Integer price; | ||
| 142 | + | ||
| 143 | + @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") | ||
| 144 | + private Integer count; | ||
| 145 | + | ||
| 146 | + @Schema(description = "产品折扣") | ||
| 147 | + private Integer discountPercent; | ||
| 148 | + | ||
| 149 | + } | ||
| 150 | + | ||
| 116 | } | 151 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractSaveReqVO.java
| @@ -93,7 +93,7 @@ public class CrmContractSaveReqVO { | @@ -93,7 +93,7 @@ public class CrmContractSaveReqVO { | ||
| 93 | @Schema(description = "产品列表") | 93 | @Schema(description = "产品列表") |
| 94 | private List<CrmContractProductItem> productItems; | 94 | private List<CrmContractProductItem> productItems; |
| 95 | 95 | ||
| 96 | - @Schema(description = "商品属性") | 96 | + @Schema(description = "产品列表") |
| 97 | @Data | 97 | @Data |
| 98 | @NoArgsConstructor | 98 | @NoArgsConstructor |
| 99 | @AllArgsConstructor | 99 | @AllArgsConstructor |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductMapper.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.dal.mysql.product; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.dal.mysql.product; | ||
| 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.mybatis.core.mapper.BaseMapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 5 | import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; |
| 6 | import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; | 7 | import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; |
| 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; |
| @@ -9,6 +10,9 @@ import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | @@ -9,6 +10,9 @@ import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; | ||
| 9 | import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils; | 10 | import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils; |
| 10 | import org.apache.ibatis.annotations.Mapper; | 11 | import org.apache.ibatis.annotations.Mapper; |
| 11 | 12 | ||
| 13 | +import java.util.Collection; | ||
| 14 | +import java.util.List; | ||
| 15 | + | ||
| 12 | /** | 16 | /** |
| 13 | * CRM 产品 Mapper | 17 | * CRM 产品 Mapper |
| 14 | * | 18 | * |
| @@ -34,4 +38,8 @@ public interface CrmProductMapper extends BaseMapperX<CrmProductDO> { | @@ -34,4 +38,8 @@ public interface CrmProductMapper extends BaseMapperX<CrmProductDO> { | ||
| 34 | return selectOne(CrmProductDO::getNo, no); | 38 | return selectOne(CrmProductDO::getNo, no); |
| 35 | } | 39 | } |
| 36 | 40 | ||
| 41 | + default List<CrmProductDO> selectListByIds(Collection<Long> ids) { | ||
| 42 | + return selectList(new LambdaQueryWrapperX<CrmProductDO>().in(CrmProductDO::getId, ids)); | ||
| 43 | + } | ||
| 44 | + | ||
| 37 | } | 45 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessProductService.java
| @@ -18,35 +18,35 @@ public interface CrmBusinessProductService { | @@ -18,35 +18,35 @@ public interface CrmBusinessProductService { | ||
| 18 | * | 18 | * |
| 19 | * @param list 商机产品集合 | 19 | * @param list 商机产品集合 |
| 20 | */ | 20 | */ |
| 21 | - void insertBatch(List<CrmBusinessProductDO> list); | 21 | + void createBusinessProductBatch(List<CrmBusinessProductDO> list); |
| 22 | 22 | ||
| 23 | /** | 23 | /** |
| 24 | * 根据商机id获取商机产品关联数据集合 | 24 | * 根据商机id获取商机产品关联数据集合 |
| 25 | * | 25 | * |
| 26 | * @param businessId 商机id | 26 | * @param businessId 商机id |
| 27 | */ | 27 | */ |
| 28 | - List<CrmBusinessProductDO> selectListByBusinessId(Long businessId); | 28 | + List<CrmBusinessProductDO> getBusinessProductListByBusinessId(Long businessId); |
| 29 | 29 | ||
| 30 | /** | 30 | /** |
| 31 | * 批量更新商机产品表 | 31 | * 批量更新商机产品表 |
| 32 | * | 32 | * |
| 33 | * @param list 商机产品数据集合 | 33 | * @param list 商机产品数据集合 |
| 34 | */ | 34 | */ |
| 35 | - void updateBatch(List<CrmBusinessProductDO> list); | 35 | + void updateBusinessProductBatch(List<CrmBusinessProductDO> list); |
| 36 | 36 | ||
| 37 | /** | 37 | /** |
| 38 | * 批量删除 | 38 | * 批量删除 |
| 39 | * | 39 | * |
| 40 | * @param list 需要删除的商机产品集合 | 40 | * @param list 需要删除的商机产品集合 |
| 41 | */ | 41 | */ |
| 42 | - void deleteBatch(List<CrmBusinessProductDO> list); | 42 | + void deleteBusinessProductBatch(List<CrmBusinessProductDO> list); |
| 43 | 43 | ||
| 44 | /** | 44 | /** |
| 45 | * 根据商机id删除商机产品关联数据 | 45 | * 根据商机id删除商机产品关联数据 |
| 46 | * | 46 | * |
| 47 | * @param businessId 商机id | 47 | * @param businessId 商机id |
| 48 | */ | 48 | */ |
| 49 | - void deleteByBusinessId(Long businessId); | 49 | + void deleteBusinessProductByBusinessId(Long businessId); |
| 50 | 50 | ||
| 51 | /** | 51 | /** |
| 52 | * 获得合同关联的商品列表 | 52 | * 获得合同关联的商品列表 |
| @@ -54,6 +54,6 @@ public interface CrmBusinessProductService { | @@ -54,6 +54,6 @@ public interface CrmBusinessProductService { | ||
| 54 | * @param contractId 合同编号 | 54 | * @param contractId 合同编号 |
| 55 | * @return 关联的商品列表 | 55 | * @return 关联的商品列表 |
| 56 | */ | 56 | */ |
| 57 | - List<CrmBusinessProductDO> selectListByContractId(Long contractId); | 57 | + List<CrmBusinessProductDO> getBusinessProductListByContractId(Long contractId); |
| 58 | 58 | ||
| 59 | } | 59 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessProductServiceImpl.java
| @@ -22,33 +22,33 @@ public class CrmBusinessProductServiceImpl implements CrmBusinessProductService | @@ -22,33 +22,33 @@ public class CrmBusinessProductServiceImpl implements CrmBusinessProductService | ||
| 22 | private CrmBusinessProductMapper businessProductMapper; | 22 | private CrmBusinessProductMapper businessProductMapper; |
| 23 | 23 | ||
| 24 | @Override | 24 | @Override |
| 25 | - public void insertBatch(List<CrmBusinessProductDO> list) { | 25 | + public void createBusinessProductBatch(List<CrmBusinessProductDO> list) { |
| 26 | businessProductMapper.insertBatch(list); | 26 | businessProductMapper.insertBatch(list); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | @Override | 29 | @Override |
| 30 | - public List<CrmBusinessProductDO> selectListByBusinessId(Long businessId) { | 30 | + public List<CrmBusinessProductDO> getBusinessProductListByBusinessId(Long businessId) { |
| 31 | return businessProductMapper.selectList(CrmBusinessProductDO::getBusinessId, businessId); | 31 | return businessProductMapper.selectList(CrmBusinessProductDO::getBusinessId, businessId); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | @Override | 34 | @Override |
| 35 | - public void updateBatch(List<CrmBusinessProductDO> list) { | 35 | + public void updateBusinessProductBatch(List<CrmBusinessProductDO> list) { |
| 36 | businessProductMapper.updateBatch(list); | 36 | businessProductMapper.updateBatch(list); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | // TODO @lzxhqs:这个方法,可以直接调用 deleteList 方法,然后传递 ids 就好了; | 39 | // TODO @lzxhqs:这个方法,可以直接调用 deleteList 方法,然后传递 ids 就好了; |
| 40 | @Override | 40 | @Override |
| 41 | - public void deleteBatch(List<CrmBusinessProductDO> list) { | 41 | + public void deleteBusinessProductBatch(List<CrmBusinessProductDO> list) { |
| 42 | businessProductMapper.deleteBatchIds(CollectionUtils.convertList(list, CrmBusinessProductDO::getId)); | 42 | businessProductMapper.deleteBatchIds(CollectionUtils.convertList(list, CrmBusinessProductDO::getId)); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | @Override | 45 | @Override |
| 46 | - public void deleteByBusinessId(Long businessId) { | 46 | + public void deleteBusinessProductByBusinessId(Long businessId) { |
| 47 | businessProductMapper.deleteByBusinessId(businessId); | 47 | businessProductMapper.deleteByBusinessId(businessId); |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | @Override | 50 | @Override |
| 51 | - public List<CrmBusinessProductDO> selectListByContractId(Long contractId) { | 51 | + public List<CrmBusinessProductDO> getBusinessProductListByContractId(Long contractId) { |
| 52 | return businessProductMapper.selectList(CrmBusinessProductDO::getContractId, contractId); | 52 | return businessProductMapper.selectList(CrmBusinessProductDO::getContractId, contractId); |
| 53 | } | 53 | } |
| 54 | 54 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| @@ -120,20 +120,20 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -120,20 +120,20 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 120 | CrmBusinessProductConvert.INSTANCE.convert(product).setBusinessId(businessId)); | 120 | CrmBusinessProductConvert.INSTANCE.convert(product).setBusinessId(businessId)); |
| 121 | if (Boolean.TRUE.equals(updateFlag)) { | 121 | if (Boolean.TRUE.equals(updateFlag)) { |
| 122 | // 根据商机 id从商机产品关联表中获取已存在的数据集合 | 122 | // 根据商机 id从商机产品关联表中获取已存在的数据集合 |
| 123 | - List<CrmBusinessProductDO> oldProducts = businessProductService.selectListByBusinessId(businessId); | 123 | + List<CrmBusinessProductDO> oldProducts = businessProductService.getBusinessProductListByBusinessId(businessId); |
| 124 | List<List<CrmBusinessProductDO>> diffList = CollectionUtils.diffList(oldProducts, list, (oldValue, newValue) -> | 124 | List<List<CrmBusinessProductDO>> diffList = CollectionUtils.diffList(oldProducts, list, (oldValue, newValue) -> |
| 125 | ObjectUtil.equal(oldValue.getProductId(), newValue.getProductId())); | 125 | ObjectUtil.equal(oldValue.getProductId(), newValue.getProductId())); |
| 126 | if (CollUtil.isNotEmpty(diffList.getFirst())) { | 126 | if (CollUtil.isNotEmpty(diffList.getFirst())) { |
| 127 | - businessProductService.insertBatch(diffList.getFirst()); | 127 | + businessProductService.createBusinessProductBatch(diffList.getFirst()); |
| 128 | } | 128 | } |
| 129 | if (CollUtil.isNotEmpty(diffList.get(1))) { | 129 | if (CollUtil.isNotEmpty(diffList.get(1))) { |
| 130 | - businessProductService.updateBatch(diffList.get(1)); | 130 | + businessProductService.updateBusinessProductBatch(diffList.get(1)); |
| 131 | } | 131 | } |
| 132 | if (CollUtil.isNotEmpty(diffList.get(2))) { | 132 | if (CollUtil.isNotEmpty(diffList.get(2))) { |
| 133 | - businessProductService.deleteBatch(diffList.get(2)); | 133 | + businessProductService.deleteBusinessProductBatch(diffList.get(2)); |
| 134 | } | 134 | } |
| 135 | } else { | 135 | } else { |
| 136 | - businessProductService.insertBatch(list); | 136 | + businessProductService.createBusinessProductBatch(list); |
| 137 | } | 137 | } |
| 138 | } | 138 | } |
| 139 | 139 | ||
| @@ -154,7 +154,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | @@ -154,7 +154,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { | ||
| 154 | if (CollUtil.isNotEmpty(updateReqVO.getProducts())) { | 154 | if (CollUtil.isNotEmpty(updateReqVO.getProducts())) { |
| 155 | createBusinessProducts(updateReqVO.getProducts(), updateReqVO.getId(), true); | 155 | createBusinessProducts(updateReqVO.getProducts(), updateReqVO.getId(), true); |
| 156 | } else { | 156 | } else { |
| 157 | - businessProductService.deleteByBusinessId(updateReqVO.getId()); | 157 | + businessProductService.deleteBusinessProductByBusinessId(updateReqVO.getId()); |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | // TODO @商机待定:如果状态发生变化,插入商机状态变更记录表 | 160 | // TODO @商机待定:如果状态发生变化,插入商机状态变更记录表 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java
| @@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjUtil; | @@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjUtil; | ||
| 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; | 8 | import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; |
| 9 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 9 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 10 | +import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; | ||
| 10 | import cn.iocoder.yudao.module.bpm.api.listener.dto.BpmResultListenerRespDTO; | 11 | import cn.iocoder.yudao.module.bpm.api.listener.dto.BpmResultListenerRespDTO; |
| 11 | import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; | 12 | import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi; |
| 12 | import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; | 13 | import cn.iocoder.yudao.module.bpm.api.task.dto.BpmProcessInstanceCreateReqDTO; |
| @@ -91,7 +92,8 @@ public class CrmContractServiceImpl implements CrmContractService { | @@ -91,7 +92,8 @@ public class CrmContractServiceImpl implements CrmContractService { | ||
| 91 | // 1.2 插入商机关联商品 | 92 | // 1.2 插入商机关联商品 |
| 92 | if (CollUtil.isNotEmpty(createReqVO.getProductItems())) { // 如果有的话 | 93 | if (CollUtil.isNotEmpty(createReqVO.getProductItems())) { // 如果有的话 |
| 93 | List<CrmBusinessProductDO> businessProduct = convertBusinessProductList(createReqVO, contract.getId()); | 94 | List<CrmBusinessProductDO> businessProduct = convertBusinessProductList(createReqVO, contract.getId()); |
| 94 | - businessProductService.insertBatch(businessProduct); | 95 | + businessProductService.createBusinessProductBatch(businessProduct); |
| 96 | + // 更新合同商品总金额 | ||
| 95 | } | 97 | } |
| 96 | 98 | ||
| 97 | // 2. 创建数据权限 | 99 | // 2. 创建数据权限 |
| @@ -113,8 +115,8 @@ public class CrmContractServiceImpl implements CrmContractService { | @@ -113,8 +115,8 @@ public class CrmContractServiceImpl implements CrmContractService { | ||
| 113 | Assert.notNull(updateReqVO.getId(), "合同编号不能为空"); | 115 | Assert.notNull(updateReqVO.getId(), "合同编号不能为空"); |
| 114 | CrmContractDO contract = validateContractExists(updateReqVO.getId()); | 116 | CrmContractDO contract = validateContractExists(updateReqVO.getId()); |
| 115 | // 只有草稿、审批中,可以编辑; | 117 | // 只有草稿、审批中,可以编辑; |
| 116 | - if (ObjUtil.notEqual(contract.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus()) || | ||
| 117 | - ObjUtil.notEqual(contract.getAuditStatus(), CrmAuditStatusEnum.PROCESS.getStatus())) { | 118 | + if (!ObjectUtils.equalsAny(contract.getAuditStatus(), CrmAuditStatusEnum.DRAFT.getStatus(), |
| 119 | + CrmAuditStatusEnum.PROCESS.getStatus())) { | ||
| 118 | throw exception(CONTRACT_UPDATE_FAIL_EDITING_PROHIBITED); | 120 | throw exception(CONTRACT_UPDATE_FAIL_EDITING_PROHIBITED); |
| 119 | } | 121 | } |
| 120 | validateRelationDataExists(updateReqVO); | 122 | validateRelationDataExists(updateReqVO); |
| @@ -136,7 +138,7 @@ public class CrmContractServiceImpl implements CrmContractService { | @@ -136,7 +138,7 @@ public class CrmContractServiceImpl implements CrmContractService { | ||
| 136 | return; | 138 | return; |
| 137 | } | 139 | } |
| 138 | List<CrmBusinessProductDO> newProductList = convertBusinessProductList(updateReqVO, contractId); | 140 | List<CrmBusinessProductDO> newProductList = convertBusinessProductList(updateReqVO, contractId); |
| 139 | - List<CrmBusinessProductDO> oldProductList = businessProductService.selectListByContractId(contractId); | 141 | + List<CrmBusinessProductDO> oldProductList = businessProductService.getBusinessProductListByContractId(contractId); |
| 140 | List<List<CrmBusinessProductDO>> diffList = diffList(oldProductList, newProductList, (oldObj, newObj) -> { | 142 | List<List<CrmBusinessProductDO>> diffList = diffList(oldProductList, newProductList, (oldObj, newObj) -> { |
| 141 | if (ObjUtil.notEqual(oldObj.getProductId(), newObj.getProductId())) { | 143 | if (ObjUtil.notEqual(oldObj.getProductId(), newObj.getProductId())) { |
| 142 | return false; | 144 | return false; |
| @@ -145,13 +147,13 @@ public class CrmContractServiceImpl implements CrmContractService { | @@ -145,13 +147,13 @@ public class CrmContractServiceImpl implements CrmContractService { | ||
| 145 | return true; | 147 | return true; |
| 146 | }); | 148 | }); |
| 147 | if (CollUtil.isNotEmpty(diffList.getFirst())) { | 149 | if (CollUtil.isNotEmpty(diffList.getFirst())) { |
| 148 | - businessProductService.insertBatch(diffList.getFirst()); | 150 | + businessProductService.createBusinessProductBatch(diffList.getFirst()); |
| 149 | } | 151 | } |
| 150 | if (CollUtil.isNotEmpty(diffList.get(1))) { | 152 | if (CollUtil.isNotEmpty(diffList.get(1))) { |
| 151 | - businessProductService.updateBatch(diffList.get(1)); | 153 | + businessProductService.updateBusinessProductBatch(diffList.get(1)); |
| 152 | } | 154 | } |
| 153 | if (CollUtil.isNotEmpty(diffList.get(2))) { | 155 | if (CollUtil.isNotEmpty(diffList.get(2))) { |
| 154 | - businessProductService.deleteBatch(diffList.get(2)); | 156 | + businessProductService.deleteBusinessProductBatch(diffList.get(2)); |
| 155 | } | 157 | } |
| 156 | } | 158 | } |
| 157 | 159 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductService.java
| @@ -69,4 +69,13 @@ public interface CrmProductService { | @@ -69,4 +69,13 @@ public interface CrmProductService { | ||
| 69 | * @return 产品 | 69 | * @return 产品 |
| 70 | */ | 70 | */ |
| 71 | CrmProductDO getProductByCategoryId(Long categoryId); | 71 | CrmProductDO getProductByCategoryId(Long categoryId); |
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * 获得产品列表 | ||
| 75 | + * | ||
| 76 | + * @param ids 产品编号 | ||
| 77 | + * @return 产品列表 | ||
| 78 | + */ | ||
| 79 | + List<CrmProductDO> getProductListByIds(Collection<Long> ids); | ||
| 80 | + | ||
| 72 | } | 81 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java
| @@ -155,4 +155,12 @@ public class CrmProductServiceImpl implements CrmProductService { | @@ -155,4 +155,12 @@ public class CrmProductServiceImpl implements CrmProductService { | ||
| 155 | return productMapper.selectOne(new LambdaQueryWrapper<CrmProductDO>().eq(CrmProductDO::getCategoryId, categoryId)); | 155 | return productMapper.selectOne(new LambdaQueryWrapper<CrmProductDO>().eq(CrmProductDO::getCategoryId, categoryId)); |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | + @Override | ||
| 159 | + public List<CrmProductDO> getProductListByIds(Collection<Long> ids) { | ||
| 160 | + if (CollUtil.isEmpty(ids)) { | ||
| 161 | + return Collections.emptyList(); | ||
| 162 | + } | ||
| 163 | + return productMapper.selectListByIds(ids); | ||
| 164 | + } | ||
| 165 | + | ||
| 158 | } | 166 | } |