Commit 84f3b230d20b8db543861835500197b55318b7f8
1 parent
e66ded28
CRM-合同: 新增合同关联商品
Showing
24 changed files
with
302 additions
and
397 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessStatusTypeController.java
| ... | ... | @@ -14,8 +14,8 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusiness |
| 14 | 14 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO; |
| 15 | 15 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeRespVO; |
| 16 | 16 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeSaveReqVO; |
| 17 | -import cn.iocoder.yudao.module.crm.convert.businessstatus.CrmBusinessStatusConvert; | |
| 18 | -import cn.iocoder.yudao.module.crm.convert.businessstatustype.CrmBusinessStatusTypeConvert; | |
| 17 | +import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessStatusConvert; | |
| 18 | +import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessStatusTypeConvert; | |
| 19 | 19 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; |
| 20 | 20 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO; |
| 21 | 21 | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessStatusService; | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/business/CrmBusinessSaveReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.product.CrmBusinessProductSaveReqVO; | |
| 5 | 4 | import cn.iocoder.yudao.module.crm.enums.business.CrmBizEndStatus; |
| 6 | 5 | import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerParseFunction; |
| 7 | 6 | import com.mzt.logapi.starter.annotation.DiffLogField; |
| 8 | 7 | import io.swagger.v3.oas.annotations.media.Schema; |
| 9 | 8 | import jakarta.validation.constraints.NotNull; |
| 9 | +import lombok.AllArgsConstructor; | |
| 10 | 10 | import lombok.Data; |
| 11 | +import lombok.NoArgsConstructor; | |
| 11 | 12 | import org.springframework.format.annotation.DateTimeFormat; |
| 12 | 13 | |
| 13 | 14 | import java.math.BigDecimal; |
| 14 | 15 | import java.time.LocalDateTime; |
| 15 | -import java.util.ArrayList; | |
| 16 | 16 | import java.util.List; |
| 17 | 17 | |
| 18 | 18 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| ... | ... | @@ -58,7 +58,6 @@ public class CrmBusinessSaveReqVO { |
| 58 | 58 | @DiffLogField(name = "商机金额") |
| 59 | 59 | private Integer price; |
| 60 | 60 | |
| 61 | - // TODO @lzxhqs:折扣使用 Integer 类型,存储时,默认 * 100;展示的时候,前端需要 / 100;避免精度丢失问题 | |
| 62 | 61 | @Schema(description = "整单折扣") |
| 63 | 62 | @DiffLogField(name = "整单折扣") |
| 64 | 63 | private Integer discountPercent; |
| ... | ... | @@ -75,11 +74,29 @@ public class CrmBusinessSaveReqVO { |
| 75 | 74 | @InEnum(CrmBizEndStatus.class) |
| 76 | 75 | private Integer endStatus; |
| 77 | 76 | |
| 78 | - // TODO @lzxhqs:不设置默认 new ArrayList<>();一般 pojo 不设置默认值哈 | |
| 79 | - @Schema(description = "商机产品列表") | |
| 80 | - private List<CrmBusinessProductSaveReqVO> products = new ArrayList<>(); | |
| 81 | - | |
| 82 | 77 | @Schema(description = "联系人编号", example = "110") |
| 83 | 78 | private Long contactId; // 使用场景,在【联系人详情】添加商机时,如果需要关联两者,需要传递 contactId 字段 |
| 84 | 79 | |
| 80 | + @Schema(description = "产品列表") | |
| 81 | + private List<CrmBusinessProductItem> productItems; | |
| 82 | + | |
| 83 | + @Schema(description = "产品列表") | |
| 84 | + @Data | |
| 85 | + @NoArgsConstructor | |
| 86 | + @AllArgsConstructor | |
| 87 | + public static class CrmBusinessProductItem { | |
| 88 | + | |
| 89 | + @Schema(description = "产品编号", example = "20529") | |
| 90 | + @NotNull(message = "产品编号不能为空") | |
| 91 | + private Long id; | |
| 92 | + | |
| 93 | + @Schema(description = "产品数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") | |
| 94 | + @NotNull(message = "产品数量不能为空") | |
| 95 | + private Integer count; | |
| 96 | + | |
| 97 | + @Schema(description = "产品折扣") | |
| 98 | + private Integer discountPercent; | |
| 99 | + | |
| 100 | + } | |
| 101 | + | |
| 85 | 102 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/product/CrmBusinessProductPageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.product; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | -import lombok.Data; | |
| 6 | -import lombok.EqualsAndHashCode; | |
| 7 | -import lombok.ToString; | |
| 8 | - | |
| 9 | -// TODO @lzxhqs:这个类,如果没用到,可以考虑删除哈 | |
| 10 | -@Schema(description = "管理后台 - 商机产品分页 Request VO") | |
| 11 | -@Data | |
| 12 | -@EqualsAndHashCode(callSuper = true) | |
| 13 | -@ToString(callSuper = true) | |
| 14 | -public class CrmBusinessProductPageReqVO extends PageParam { | |
| 15 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/product/CrmBusinessProductRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.product; | |
| 2 | - | |
| 3 | -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | |
| 4 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | -import lombok.Data; | |
| 6 | - | |
| 7 | -@Schema(description = "管理后台 - 商机产品关联 Response VO") | |
| 8 | -@Data | |
| 9 | -@ExcelIgnoreUnannotated | |
| 10 | -public class CrmBusinessProductRespVO { | |
| 11 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/product/CrmBusinessProductSaveReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.business.vo.product; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import jakarta.validation.constraints.NotEmpty; | |
| 5 | -import jakarta.validation.constraints.NotNull; | |
| 6 | -import lombok.Data; | |
| 7 | - | |
| 8 | -import java.math.BigDecimal; | |
| 9 | - | |
| 10 | -@Schema(description = "管理后台 - CRM 商机产品关联表 创建/更新 Request VO") | |
| 11 | -@Data | |
| 12 | -public class CrmBusinessProductSaveReqVO { | |
| 13 | - | |
| 14 | - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") | |
| 15 | - private Long id; | |
| 16 | - | |
| 17 | - @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") | |
| 18 | - @NotNull(message = "商机编号不能为空") | |
| 19 | - private Long businessId; | |
| 20 | - | |
| 21 | - @Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") | |
| 22 | - @NotNull(message = "产品编号不能为空") | |
| 23 | - private Long productId; | |
| 24 | - | |
| 25 | - @Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") | |
| 26 | - @NotNull(message = "产品单价不能为空") | |
| 27 | - private BigDecimal price; | |
| 28 | - | |
| 29 | - @Schema(description = "销售价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") | |
| 30 | - @NotNull(message = "销售价格不能为空") | |
| 31 | - private BigDecimal salesPrice; | |
| 32 | - | |
| 33 | - @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") | |
| 34 | - @NotNull(message = "数量不能为空") | |
| 35 | - private BigDecimal num; | |
| 36 | - | |
| 37 | - @Schema(description = "折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") | |
| 38 | - @NotNull(message = "折扣不能为空") | |
| 39 | - private BigDecimal discount; | |
| 40 | - | |
| 41 | - @Schema(description = "小计(折扣后价格)", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") | |
| 42 | - @NotNull(message = "小计(折扣后价格)不能为空") | |
| 43 | - private BigDecimal subtotal; | |
| 44 | - | |
| 45 | - @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") | |
| 46 | - @NotEmpty(message = "单位不能为空") | |
| 47 | - private String unit; | |
| 48 | - | |
| 49 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java
| ... | ... | @@ -11,12 +11,11 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 11 | 11 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; |
| 12 | 12 | import cn.iocoder.yudao.module.crm.convert.contract.CrmContractConvert; |
| 13 | 13 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 14 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; | |
| 15 | 14 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| 16 | 15 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; |
| 16 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO; | |
| 17 | 17 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 18 | 18 | import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; |
| 19 | -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessProductService; | |
| 20 | 19 | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; |
| 21 | 20 | import cn.iocoder.yudao.module.crm.service.contact.CrmContactService; |
| 22 | 21 | import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; |
| ... | ... | @@ -30,7 +29,6 @@ import io.swagger.v3.oas.annotations.tags.Tag; |
| 30 | 29 | import jakarta.annotation.Resource; |
| 31 | 30 | import jakarta.servlet.http.HttpServletResponse; |
| 32 | 31 | import jakarta.validation.Valid; |
| 33 | -import org.springframework.context.annotation.Lazy; | |
| 34 | 32 | import org.springframework.security.access.prepost.PreAuthorize; |
| 35 | 33 | import org.springframework.validation.annotation.Validated; |
| 36 | 34 | import org.springframework.web.bind.annotation.*; |
| ... | ... | @@ -43,7 +41,6 @@ import java.util.stream.Stream; |
| 43 | 41 | |
| 44 | 42 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 45 | 43 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; |
| 46 | -import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | |
| 47 | 44 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 48 | 45 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 49 | 46 | |
| ... | ... | @@ -62,11 +59,7 @@ public class CrmContractController { |
| 62 | 59 | @Resource |
| 63 | 60 | private CrmBusinessService businessService; |
| 64 | 61 | @Resource |
| 65 | - @Lazy | |
| 66 | - private CrmBusinessProductService businessProductService; | |
| 67 | - @Resource | |
| 68 | 62 | private CrmProductService productService; |
| 69 | - | |
| 70 | 63 | @Resource |
| 71 | 64 | private AdminUserApi adminUserApi; |
| 72 | 65 | |
| ... | ... | @@ -105,22 +98,9 @@ public class CrmContractController { |
| 105 | 98 | return success(null); |
| 106 | 99 | } |
| 107 | 100 | |
| 108 | - // 2.1 拼接合同信息 | |
| 101 | + // 2. 拼接合同信息 | |
| 109 | 102 | List<CrmContractRespVO> respVOList = buildContractDetailList(Collections.singletonList(contract)); |
| 110 | - // 2.2 拼接产品信息 | |
| 111 | - // TODO @puhui999:下面这块也可以搞到 convert 里哈;可以在 ContractDetailList 加个开关,是不是查询商品信息;ps:jdk21 的方法不太能去用,因为 jdk8 项目要兼容; | |
| 112 | - CrmContractRespVO respVO = respVOList.get(0); | |
| 113 | - List<CrmBusinessProductDO> businessProductList = businessProductService.getBusinessProductListByContractId(id); | |
| 114 | - Map<Long, CrmBusinessProductDO> businessProductMap = convertMap(businessProductList, CrmBusinessProductDO::getProductId); | |
| 115 | - List<CrmProductDO> productList = productService.getProductListByIds(convertSet(businessProductList, CrmBusinessProductDO::getProductId)); | |
| 116 | - respVO.setProductItems(convertList(productList, product -> { | |
| 117 | - CrmContractRespVO.CrmContractProductItemRespVO productItemRespVO = BeanUtils.toBean(product, CrmContractRespVO.CrmContractProductItemRespVO.class); | |
| 118 | - findAndThen(businessProductMap, product.getId(), businessProduct -> { | |
| 119 | - productItemRespVO.setCount(businessProduct.getCount()).setDiscountPercent(businessProduct.getDiscountPercent()); | |
| 120 | - }); | |
| 121 | - return productItemRespVO; | |
| 122 | - })); | |
| 123 | - return success(respVO); | |
| 103 | + return success(respVOList.get(0)); | |
| 124 | 104 | } |
| 125 | 105 | |
| 126 | 106 | @GetMapping("/page") |
| ... | ... | @@ -151,6 +131,22 @@ public class CrmContractController { |
| 151 | 131 | BeanUtils.toBean(pageResult.getList(), CrmContractExcelVO.class)); |
| 152 | 132 | } |
| 153 | 133 | |
| 134 | + @PutMapping("/transfer") | |
| 135 | + @Operation(summary = "合同转移") | |
| 136 | + @PreAuthorize("@ss.hasPermission('crm:contract:update')") | |
| 137 | + public CommonResult<Boolean> transferContract(@Valid @RequestBody CrmContractTransferReqVO reqVO) { | |
| 138 | + contractService.transferContract(reqVO, getLoginUserId()); | |
| 139 | + return success(true); | |
| 140 | + } | |
| 141 | + | |
| 142 | + @PutMapping("/submit") | |
| 143 | + @Operation(summary = "提交合同审批") | |
| 144 | + @PreAuthorize("@ss.hasPermission('crm:contract:update')") | |
| 145 | + public CommonResult<Boolean> submitContract(@RequestParam("id") Long id) { | |
| 146 | + contractService.submitContract(id, getLoginUserId()); | |
| 147 | + return success(true); | |
| 148 | + } | |
| 149 | + | |
| 154 | 150 | /** |
| 155 | 151 | * 构建详细的合同结果 |
| 156 | 152 | * |
| ... | ... | @@ -173,23 +169,15 @@ public class CrmContractController { |
| 173 | 169 | // 4. 获取商机 |
| 174 | 170 | Map<Long, CrmBusinessDO> businessMap = convertMap(businessService.getBusinessList(convertSet(contractList, |
| 175 | 171 | CrmContractDO::getBusinessId)), CrmBusinessDO::getId); |
| 176 | - return CrmContractConvert.INSTANCE.convertList(contractList, userMap, customerList, contactMap, businessMap); | |
| 177 | - } | |
| 178 | - | |
| 179 | - @PutMapping("/transfer") | |
| 180 | - @Operation(summary = "合同转移") | |
| 181 | - @PreAuthorize("@ss.hasPermission('crm:contract:update')") | |
| 182 | - public CommonResult<Boolean> transferContract(@Valid @RequestBody CrmContractTransferReqVO reqVO) { | |
| 183 | - contractService.transferContract(reqVO, getLoginUserId()); | |
| 184 | - return success(true); | |
| 185 | - } | |
| 186 | - | |
| 187 | - @PutMapping("/submit") | |
| 188 | - @Operation(summary = "提交合同审批") | |
| 189 | - @PreAuthorize("@ss.hasPermission('crm:contract:update')") | |
| 190 | - public CommonResult<Boolean> submitContract(@RequestParam("id") Long id) { | |
| 191 | - contractService.submitContract(id, getLoginUserId()); | |
| 192 | - return success(true); | |
| 172 | + // 5. 获取合同关联的商品 | |
| 173 | + Map<Long, CrmContractProductDO> contractProductMap = null; | |
| 174 | + List<CrmProductDO> productList = null; | |
| 175 | + if (contractList.size() == 1) { | |
| 176 | + List<CrmContractProductDO> contractProductList = contractService.getContractProductListByContractId(contractList.get(0).getId()); | |
| 177 | + contractProductMap = convertMap(contractProductList, CrmContractProductDO::getProductId); | |
| 178 | + productList = productService.getProductListByIds(convertSet(contractProductList, CrmContractProductDO::getProductId)); | |
| 179 | + } | |
| 180 | + return CrmContractConvert.INSTANCE.convertList(contractList, userMap, customerList, contactMap, businessMap, contractProductMap, productList); | |
| 193 | 181 | } |
| 194 | 182 | |
| 195 | 183 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatus/CrmBusinessStatusConvert.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessStatusConvert.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatustype/CrmBusinessStatusTypeConvert.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessStatusTypeConvert.java
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessproduct/CrmBusinessProductConvert.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.convert.businessproduct; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.product.CrmBusinessProductSaveReqVO; | |
| 4 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; | |
| 5 | -import org.mapstruct.Mapper; | |
| 6 | -import org.mapstruct.factory.Mappers; | |
| 7 | - | |
| 8 | -// TODO @lzxhqs:看看是不是用 BeanUtils 替代了 | |
| 9 | -/** | |
| 10 | - * @author lzxhqs | |
| 11 | - * @version 1.0 | |
| 12 | - * @title CrmBusinessProductConvert | |
| 13 | - * @description | |
| 14 | - * @create 2024/1/12 | |
| 15 | - */ | |
| 16 | -@Mapper | |
| 17 | -public interface CrmBusinessProductConvert { | |
| 18 | - CrmBusinessProductConvert INSTANCE = Mappers.getMapper(CrmBusinessProductConvert.class); | |
| 19 | - | |
| 20 | - CrmBusinessProductDO convert(CrmBusinessProductSaveReqVO product); | |
| 21 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/CrmContractConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.convert.contract; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 3 | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 4 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractRespVO; |
| 5 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO; |
| 6 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 7 | 9 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO; |
| 8 | 10 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; |
| 11 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO; | |
| 9 | 12 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 13 | +import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; | |
| 10 | 14 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; |
| 11 | 15 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 12 | 16 | import org.mapstruct.Mapper; |
| ... | ... | @@ -34,7 +38,8 @@ public interface CrmContractConvert { |
| 34 | 38 | |
| 35 | 39 | default List<CrmContractRespVO> convertList(List<CrmContractDO> contractList, Map<Long, AdminUserRespDTO> userMap, |
| 36 | 40 | List<CrmCustomerDO> customerList, Map<Long, CrmContactDO> contactMap, |
| 37 | - Map<Long, CrmBusinessDO> businessMap) { | |
| 41 | + Map<Long, CrmBusinessDO> businessMap, Map<Long, CrmContractProductDO> contractProductMap, | |
| 42 | + List<CrmProductDO> productList) { | |
| 38 | 43 | List<CrmContractRespVO> respVOList = BeanUtils.toBean(contractList, CrmContractRespVO.class); |
| 39 | 44 | // 拼接关联字段 |
| 40 | 45 | Map<Long, CrmCustomerDO> customerMap = convertMap(customerList, CrmCustomerDO::getId); |
| ... | ... | @@ -46,7 +51,21 @@ public interface CrmContractConvert { |
| 46 | 51 | findAndThen(contactMap, contract.getContactId(), contact -> contract.setContactName(contact.getName())); |
| 47 | 52 | findAndThen(businessMap, contract.getBusinessId(), business -> contract.setBusinessName(business.getName())); |
| 48 | 53 | }); |
| 54 | + if (CollUtil.isNotEmpty(respVOList) && respVOList.size() == 1) { | |
| 55 | + setContractRespVOProductItems(respVOList.get(0), contractProductMap, productList); | |
| 56 | + } | |
| 49 | 57 | return respVOList; |
| 50 | 58 | } |
| 51 | 59 | |
| 60 | + default void setContractRespVOProductItems(CrmContractRespVO respVO, Map<Long, CrmContractProductDO> contractProductMap, | |
| 61 | + List<CrmProductDO> productList) { | |
| 62 | + respVO.setProductItems(CollectionUtils.convertList(productList, product -> { | |
| 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 | + }); | |
| 67 | + return productItemRespVO; | |
| 68 | + })); | |
| 69 | + } | |
| 70 | + | |
| 52 | 71 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessProductDO.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.dal.dataobject.business; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; | |
| 5 | 4 | import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; |
| 6 | -import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; | |
| 7 | 5 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 8 | 6 | import com.baomidou.mybatisplus.annotation.TableId; |
| 9 | 7 | import com.baomidou.mybatisplus.annotation.TableName; |
| ... | ... | @@ -41,19 +39,10 @@ public class CrmBusinessProductDO extends BaseDO { |
| 41 | 39 | * 关联 {@link CrmProductDO#getId()} |
| 42 | 40 | */ |
| 43 | 41 | private Long productId; |
| 44 | - // TODO 芋艿:需要在看下 CRM | |
| 45 | - /** | |
| 46 | - * 合同编号 | |
| 47 | - * | |
| 48 | - * 关联 {@link CrmContractDO#getId()} | |
| 49 | - */ | |
| 50 | - private Long contractId; | |
| 51 | - | |
| 52 | 42 | /** |
| 53 | 43 | * 产品单价 |
| 54 | 44 | */ |
| 55 | 45 | private Integer price; |
| 56 | - | |
| 57 | 46 | /** |
| 58 | 47 | * 销售价格, 单位:分 |
| 59 | 48 | */ |
| ... | ... | @@ -71,11 +60,4 @@ public class CrmBusinessProductDO extends BaseDO { |
| 71 | 60 | */ |
| 72 | 61 | private Integer totalPrice; |
| 73 | 62 | |
| 74 | - /** | |
| 75 | - * 单位 | |
| 76 | - * | |
| 77 | - * 字典 {@link DictTypeConstants#CRM_PRODUCT_UNIT} | |
| 78 | - */ | |
| 79 | - private Integer unit; | |
| 80 | - | |
| 81 | 63 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractProductDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.dal.dataobject.contract; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; | |
| 5 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | +import lombok.*; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 合同产品关联表 DO | |
| 12 | + * | |
| 13 | + * @author HUIHUI | |
| 14 | + */ | |
| 15 | +@TableName("crm_contract_product") | |
| 16 | +@KeySequence("crm_contract_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 17 | +@Data | |
| 18 | +@EqualsAndHashCode(callSuper = true) | |
| 19 | +@ToString(callSuper = true) | |
| 20 | +@Builder | |
| 21 | +@NoArgsConstructor | |
| 22 | +@AllArgsConstructor | |
| 23 | +public class CrmContractProductDO extends BaseDO { | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 主键 | |
| 27 | + */ | |
| 28 | + @TableId | |
| 29 | + private Long id; | |
| 30 | + /** | |
| 31 | + * 产品编号 | |
| 32 | + * | |
| 33 | + * 关联 {@link CrmProductDO#getId()} | |
| 34 | + */ | |
| 35 | + private Long productId; | |
| 36 | + /** | |
| 37 | + * 合同编号 | |
| 38 | + * | |
| 39 | + * 关联 {@link CrmContractDO#getId()} | |
| 40 | + */ | |
| 41 | + private Long contractId; | |
| 42 | + /** | |
| 43 | + * 产品单价 | |
| 44 | + */ | |
| 45 | + private Integer price; | |
| 46 | + /** | |
| 47 | + * 销售价格, 单位:分 | |
| 48 | + */ | |
| 49 | + private Integer salesPrice; | |
| 50 | + /** | |
| 51 | + * 数量 | |
| 52 | + */ | |
| 53 | + private Integer count; | |
| 54 | + /** | |
| 55 | + * 折扣 | |
| 56 | + */ | |
| 57 | + private Integer discountPercent; | |
| 58 | + /** | |
| 59 | + * 总计价格(折扣后价格) | |
| 60 | + */ | |
| 61 | + private Integer totalPrice; | |
| 62 | + | |
| 63 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/package-info.java deleted
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessProductMapper.java
| ... | ... | @@ -2,9 +2,12 @@ package cn.iocoder.yudao.module.crm.dal.mysql.business; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 5 | 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; |
| 6 | 7 | import org.apache.ibatis.annotations.Mapper; |
| 7 | 8 | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 8 | 11 | /** |
| 9 | 12 | * 商机产品 Mapper |
| 10 | 13 | * |
| ... | ... | @@ -21,4 +24,8 @@ public interface CrmBusinessProductMapper extends BaseMapperX<CrmBusinessProduct |
| 21 | 24 | return selectOne(CrmBusinessProductDO::getBusinessId, id); |
| 22 | 25 | } |
| 23 | 26 | |
| 27 | + default List<CrmBusinessProductDO> selectListByBusinessId(Long businessId) { | |
| 28 | + return selectList(new LambdaQueryWrapperX<CrmBusinessProductDO>().eq(CrmBusinessProductDO::getBusinessId, businessId)); | |
| 29 | + } | |
| 30 | + | |
| 24 | 31 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractProductMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.crm.dal.mysql.contract; | |
| 2 | + | |
| 3 | + | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO; | |
| 7 | +import org.apache.ibatis.annotations.Mapper; | |
| 8 | + | |
| 9 | +import java.util.List; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 合同产品 Mapper | |
| 13 | + * | |
| 14 | + * @author HUIHUI | |
| 15 | + */ | |
| 16 | +@Mapper | |
| 17 | +public interface CrmContractProductMapper extends BaseMapperX<CrmContractProductDO> { | |
| 18 | + | |
| 19 | + default void deleteByContractId(Long contractId) { // TODO @lzxhqs:第一个方法,和类之间最好空一行; | |
| 20 | + delete(CrmContractProductDO::getContractId, contractId); | |
| 21 | + } | |
| 22 | + | |
| 23 | + default CrmContractProductDO selectByContractId(Long contractId) { | |
| 24 | + return selectOne(CrmContractProductDO::getContractId, contractId); | |
| 25 | + } | |
| 26 | + | |
| 27 | + default List<CrmContractProductDO> selectListByContractId(Long contractId) { | |
| 28 | + return selectList(new LambdaQueryWrapperX<CrmContractProductDO>().eq(CrmContractProductDO::getContractId, contractId)); | |
| 29 | + } | |
| 30 | + | |
| 31 | +} | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/CrmProductMapper.java
| ... | ... | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.dal.mysql.product; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX; |
| 7 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; |
| 8 | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; |
| ... | ... | @@ -10,9 +9,6 @@ import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 10 | 9 | import cn.iocoder.yudao.module.crm.util.CrmQueryWrapperUtils; |
| 11 | 10 | import org.apache.ibatis.annotations.Mapper; |
| 12 | 11 | |
| 13 | -import java.util.Collection; | |
| 14 | -import java.util.List; | |
| 15 | - | |
| 16 | 12 | /** |
| 17 | 13 | * CRM 产品 Mapper |
| 18 | 14 | * |
| ... | ... | @@ -38,9 +34,4 @@ public interface CrmProductMapper extends BaseMapperX<CrmProductDO> { |
| 38 | 34 | return selectOne(CrmProductDO::getNo, no); |
| 39 | 35 | } |
| 40 | 36 | |
| 41 | - // TODO @puhui999:selectBatchIds | |
| 42 | - default List<CrmProductDO> selectListByIds(Collection<Long> ids) { | |
| 43 | - return selectList(new LambdaQueryWrapperX<CrmProductDO>().in(CrmProductDO::getId, ids)); | |
| 44 | - } | |
| 45 | - | |
| 46 | 37 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessProductService.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.business; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; | |
| 4 | - | |
| 5 | -import java.util.List; | |
| 6 | - | |
| 7 | -/** | |
| 8 | - * 商机产品关联表 Service 接口 | |
| 9 | - * | |
| 10 | - * @author lzxhqs | |
| 11 | - */ | |
| 12 | -public interface CrmBusinessProductService { | |
| 13 | - | |
| 14 | - /** | |
| 15 | - * 批量新增商机产品关联数据 | |
| 16 | - * | |
| 17 | - * @param list 商机产品集合 | |
| 18 | - */ | |
| 19 | - void createBusinessProductBatch(List<CrmBusinessProductDO> list); | |
| 20 | - | |
| 21 | - /** | |
| 22 | - * 批量更新商机产品表 | |
| 23 | - * | |
| 24 | - * @param list 商机产品数据集合 | |
| 25 | - */ | |
| 26 | - void updateBusinessProductBatch(List<CrmBusinessProductDO> list); | |
| 27 | - | |
| 28 | - /** | |
| 29 | - * 批量删除 | |
| 30 | - * | |
| 31 | - * @param list 需要删除的商机产品集合 | |
| 32 | - */ | |
| 33 | - void deleteBusinessProductBatch(List<CrmBusinessProductDO> list); | |
| 34 | - | |
| 35 | - /** | |
| 36 | - * 根据商机编号,删除商机产品关联数据 | |
| 37 | - * | |
| 38 | - * @param businessId 商机id | |
| 39 | - */ | |
| 40 | - void deleteBusinessProductByBusinessId(Long businessId); | |
| 41 | - | |
| 42 | - /** | |
| 43 | - * 根据商机编号,获取商机产品关联数据集合 | |
| 44 | - * | |
| 45 | - * @param businessId 商机编号 | |
| 46 | - */ | |
| 47 | - List<CrmBusinessProductDO> getBusinessProductListByBusinessId(Long businessId); | |
| 48 | - | |
| 49 | - /** | |
| 50 | - * 根据合同编号,获得合同关联的商品列表 | |
| 51 | - * | |
| 52 | - * @param contractId 合同编号 | |
| 53 | - * @return 关联的商品列表 | |
| 54 | - */ | |
| 55 | - List<CrmBusinessProductDO> getBusinessProductListByContractId(Long contractId); | |
| 56 | - | |
| 57 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessProductServiceImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.service.business; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 4 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; | |
| 5 | -import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessProductMapper; | |
| 6 | -import jakarta.annotation.Resource; | |
| 7 | -import org.springframework.stereotype.Service; | |
| 8 | -import org.springframework.validation.annotation.Validated; | |
| 9 | - | |
| 10 | -import java.util.List; | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * 商机产品关联表 Service 实现类 | |
| 14 | - * | |
| 15 | - * @author lzxhqs | |
| 16 | - */ | |
| 17 | -@Service | |
| 18 | -@Validated | |
| 19 | -public class CrmBusinessProductServiceImpl implements CrmBusinessProductService { | |
| 20 | - | |
| 21 | - @Resource | |
| 22 | - private CrmBusinessProductMapper businessProductMapper; | |
| 23 | - | |
| 24 | - @Override | |
| 25 | - public void createBusinessProductBatch(List<CrmBusinessProductDO> list) { | |
| 26 | - businessProductMapper.insertBatch(list); | |
| 27 | - } | |
| 28 | - | |
| 29 | - @Override | |
| 30 | - public void updateBusinessProductBatch(List<CrmBusinessProductDO> list) { | |
| 31 | - businessProductMapper.updateBatch(list); | |
| 32 | - } | |
| 33 | - | |
| 34 | - // TODO @puhui999:这个方法,可以直接调用 deleteList 方法,然后传递 ids 就好了; | |
| 35 | - @Override | |
| 36 | - public void deleteBusinessProductBatch(List<CrmBusinessProductDO> list) { | |
| 37 | - businessProductMapper.deleteBatchIds(CollectionUtils.convertList(list, CrmBusinessProductDO::getId)); | |
| 38 | - } | |
| 39 | - | |
| 40 | - @Override | |
| 41 | - public void deleteBusinessProductByBusinessId(Long businessId) { | |
| 42 | - businessProductMapper.deleteByBusinessId(businessId); | |
| 43 | - } | |
| 44 | - | |
| 45 | - @Override | |
| 46 | - public List<CrmBusinessProductDO> getBusinessProductListByContractId(Long contractId) { | |
| 47 | - return businessProductMapper.selectList(CrmBusinessProductDO::getContractId, contractId); | |
| 48 | - } | |
| 49 | - | |
| 50 | - @Override | |
| 51 | - public List<CrmBusinessProductDO> getBusinessProductListByBusinessId(Long businessId) { | |
| 52 | - return businessProductMapper.selectList(CrmBusinessProductDO::getBusinessId, businessId); | |
| 53 | - } | |
| 54 | - | |
| 55 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
| ... | ... | @@ -5,17 +5,18 @@ import cn.hutool.core.collection.ListUtil; |
| 5 | 5 | import cn.hutool.core.util.ObjectUtil; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 8 | +import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; | |
| 8 | 9 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 9 | 10 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO; |
| 10 | 11 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO; |
| 11 | 12 | import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO; |
| 12 | -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.product.CrmBusinessProductSaveReqVO; | |
| 13 | 13 | import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; |
| 14 | -import cn.iocoder.yudao.module.crm.convert.businessproduct.CrmBusinessProductConvert; | |
| 15 | 14 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; |
| 16 | 15 | import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; |
| 17 | 16 | import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; |
| 17 | +import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; | |
| 18 | 18 | import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; |
| 19 | +import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessProductMapper; | |
| 19 | 20 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 20 | 21 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 21 | 22 | import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; |
| ... | ... | @@ -24,6 +25,7 @@ import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; |
| 24 | 25 | import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO; |
| 25 | 26 | import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; |
| 26 | 27 | import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; |
| 28 | +import cn.iocoder.yudao.module.crm.service.product.CrmProductService; | |
| 27 | 29 | import com.mzt.logapi.context.LogRecordContext; |
| 28 | 30 | import com.mzt.logapi.service.impl.DiffParseFunction; |
| 29 | 31 | import com.mzt.logapi.starter.annotation.LogRecord; |
| ... | ... | @@ -35,11 +37,12 @@ import org.springframework.validation.annotation.Validated; |
| 35 | 37 | |
| 36 | 38 | import java.util.Collection; |
| 37 | 39 | import java.util.List; |
| 40 | +import java.util.Map; | |
| 41 | +import java.util.Set; | |
| 38 | 42 | |
| 39 | 43 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 40 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 41 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_CONTRACT_EXISTS; | |
| 42 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; | |
| 44 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | |
| 45 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; | |
| 43 | 46 | import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; |
| 44 | 47 | |
| 45 | 48 | /** |
| ... | ... | @@ -53,9 +56,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 53 | 56 | |
| 54 | 57 | @Resource |
| 55 | 58 | private CrmBusinessMapper businessMapper; |
| 56 | - | |
| 57 | 59 | @Resource |
| 58 | - private CrmBusinessProductService businessProductService; | |
| 60 | + private CrmBusinessProductMapper businessProductMapper; | |
| 61 | + | |
| 59 | 62 | @Resource |
| 60 | 63 | @Lazy // 延迟加载,避免循环依赖 |
| 61 | 64 | private CrmContractService contractService; |
| ... | ... | @@ -63,6 +66,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 63 | 66 | private CrmPermissionService permissionService; |
| 64 | 67 | @Resource |
| 65 | 68 | private CrmContactBusinessService contactBusinessService; |
| 69 | + @Resource | |
| 70 | + private CrmProductService productService; | |
| 66 | 71 | |
| 67 | 72 | @Override |
| 68 | 73 | @Transactional(rollbackFor = Exception.class) |
| ... | ... | @@ -71,12 +76,15 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 71 | 76 | public Long createBusiness(CrmBusinessSaveReqVO createReqVO, Long userId) { |
| 72 | 77 | createReqVO.setId(null); |
| 73 | 78 | // 1. 插入商机 |
| 74 | - CrmBusinessDO business = BeanUtils.toBean(createReqVO, CrmBusinessDO.class) | |
| 75 | - .setOwnerUserId(userId); | |
| 79 | + CrmBusinessDO business = BeanUtils.toBean(createReqVO, CrmBusinessDO.class).setOwnerUserId(userId); | |
| 76 | 80 | businessMapper.insert(business); |
| 77 | - // TODO 商机待定:插入商机与产品的关联表;校验商品存在 | |
| 78 | - if (CollUtil.isNotEmpty(createReqVO.getProducts())) { | |
| 79 | - createBusinessProducts(createReqVO.getProducts(), business.getId(), false); | |
| 81 | + // 1.2 插入商机关联商品 | |
| 82 | + if (CollUtil.isNotEmpty(createReqVO.getProductItems())) { // 如果有的话 | |
| 83 | + List<CrmBusinessProductDO> productList = convertBusinessProductList(createReqVO, business.getId()); | |
| 84 | + businessProductMapper.insertBatch(productList); | |
| 85 | + // 更新合同商品总金额 | |
| 86 | + businessMapper.updateById(new CrmBusinessDO().setId(business.getId()).setProductPrice( | |
| 87 | + getSumValue(productList, CrmBusinessProductDO::getTotalPrice, Integer::sum))); | |
| 80 | 88 | } |
| 81 | 89 | // TODO 商机待定:在联系人的详情页,如果直接【新建商机】,则需要关联下。这里要搞个 CrmContactBusinessDO 表 |
| 82 | 90 | createContactBusiness(business.getId(), createReqVO.getContactId()); |
| ... | ... | @@ -92,13 +100,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 92 | 100 | } |
| 93 | 101 | |
| 94 | 102 | // TODO @lzxhqs:CrmContactBusinessService 调用这个;这样逻辑才能收敛哈; |
| 95 | - /** | |
| 96 | - * @param businessId 商机id | |
| 97 | - * @param contactId 联系人id | |
| 98 | - * @throws | |
| 99 | - * @description 联系人与商机的关联 | |
| 100 | - * @author lzxhqs | |
| 101 | - */ | |
| 102 | 103 | private void createContactBusiness(Long businessId, Long contactId) { |
| 103 | 104 | CrmContactBusinessDO contactBusiness = new CrmContactBusinessDO(); |
| 104 | 105 | contactBusiness.setBusinessId(businessId); |
| ... | ... | @@ -106,37 +107,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 106 | 107 | contactBusinessService.insert(contactBusiness); |
| 107 | 108 | } |
| 108 | 109 | |
| 109 | - // TODO @lzxhqs:这个方法注释格式不对;删除@description,然后把 插入商机产品关联表 作为方法注释; | |
| 110 | - /** | |
| 111 | - * 插入商机产品关联表 | |
| 112 | - * | |
| 113 | - * @param products 产品集合 | |
| 114 | - * @param businessId 商机id | |
| 115 | - * @param updateFlag 更新标识 true 代表更新 | |
| 116 | - * @author lzxhqs | |
| 117 | - */ | |
| 118 | - private void createBusinessProducts(List<CrmBusinessProductSaveReqVO> products, Long businessId, Boolean updateFlag) { | |
| 119 | - List<CrmBusinessProductDO> list = CollectionUtils.convertList(products, product -> | |
| 120 | - CrmBusinessProductConvert.INSTANCE.convert(product).setBusinessId(businessId)); | |
| 121 | - if (Boolean.TRUE.equals(updateFlag)) { | |
| 122 | -// 根据商机 id从商机产品关联表中获取已存在的数据集合 | |
| 123 | - List<CrmBusinessProductDO> oldProducts = businessProductService.getBusinessProductListByBusinessId(businessId); | |
| 124 | - List<List<CrmBusinessProductDO>> diffList = CollectionUtils.diffList(oldProducts, list, (oldValue, newValue) -> | |
| 125 | - ObjectUtil.equal(oldValue.getProductId(), newValue.getProductId())); | |
| 126 | - if (CollUtil.isNotEmpty(diffList.getFirst())) { | |
| 127 | - businessProductService.createBusinessProductBatch(diffList.getFirst()); | |
| 128 | - } | |
| 129 | - if (CollUtil.isNotEmpty(diffList.get(1))) { | |
| 130 | - businessProductService.updateBusinessProductBatch(diffList.get(1)); | |
| 131 | - } | |
| 132 | - if (CollUtil.isNotEmpty(diffList.get(2))) { | |
| 133 | - businessProductService.deleteBusinessProductBatch(diffList.get(2)); | |
| 134 | - } | |
| 135 | - } else { | |
| 136 | - businessProductService.createBusinessProductBatch(list); | |
| 137 | - } | |
| 138 | - } | |
| 139 | - | |
| 140 | 110 | @Override |
| 141 | 111 | @Transactional(rollbackFor = Exception.class) |
| 142 | 112 | @LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", |
| ... | ... | @@ -146,16 +116,12 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 146 | 116 | // 1. 校验存在 |
| 147 | 117 | CrmBusinessDO oldBusiness = validateBusinessExists(updateReqVO.getId()); |
| 148 | 118 | |
| 149 | - // 2. 更新商机 | |
| 119 | + // 2.1 更新商机 | |
| 150 | 120 | CrmBusinessDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessDO.class); |
| 151 | 121 | businessMapper.updateById(updateObj); |
| 152 | - // TODO 商机待定:插入商机与产品的关联表;校验商品存在 | |
| 153 | - // TODO @lzxhqs:createBusinessProducts 可以抽成两个方法,一个新增;一个修改,修改需要把 businessProductService.deleteByBusinessId(updateReqVO.getId()); 一起处理进去; | |
| 154 | - if (CollUtil.isNotEmpty(updateReqVO.getProducts())) { | |
| 155 | - createBusinessProducts(updateReqVO.getProducts(), updateReqVO.getId(), true); | |
| 156 | - } else { | |
| 157 | - businessProductService.deleteBusinessProductByBusinessId(updateReqVO.getId()); | |
| 158 | - } | |
| 122 | + // 2.2 更新商机关联商品 | |
| 123 | + List<CrmBusinessProductDO> productList = convertBusinessProductList(updateReqVO, updateObj.getId()); | |
| 124 | + updateBusinessProduct(productList, updateObj.getId()); | |
| 159 | 125 | |
| 160 | 126 | // TODO @商机待定:如果状态发生变化,插入商机状态变更记录表 |
| 161 | 127 | // 3. 记录操作日志上下文 |
| ... | ... | @@ -188,6 +154,43 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { |
| 188 | 154 | LogRecordContext.putVariable("businessName", business.getName()); |
| 189 | 155 | } |
| 190 | 156 | |
| 157 | + private void updateBusinessProduct(List<CrmBusinessProductDO> newProductList, Long businessId) { | |
| 158 | + List<CrmBusinessProductDO> oldProducts = businessProductMapper.selectListByBusinessId(businessId); | |
| 159 | + List<List<CrmBusinessProductDO>> diffList = CollectionUtils.diffList(oldProducts, newProductList, (oldValue, newValue) -> { | |
| 160 | + boolean condition = ObjectUtil.equal(oldValue.getProductId(), newValue.getProductId()); | |
| 161 | + if (condition) { | |
| 162 | + newValue.setId(oldValue.getId()); // 更新需要原始编号 | |
| 163 | + } | |
| 164 | + return condition; | |
| 165 | + }); | |
| 166 | + if (CollUtil.isNotEmpty(diffList.get(0))) { | |
| 167 | + businessProductMapper.insertBatch(diffList.get(0)); | |
| 168 | + } | |
| 169 | + if (CollUtil.isNotEmpty(diffList.get(1))) { | |
| 170 | + businessProductMapper.updateBatch(diffList.get(1)); | |
| 171 | + } | |
| 172 | + if (CollUtil.isNotEmpty(diffList.get(2))) { | |
| 173 | + businessProductMapper.deleteBatchIds(convertSet(diffList.get(2), CrmBusinessProductDO::getId)); | |
| 174 | + } | |
| 175 | + } | |
| 176 | + | |
| 177 | + private List<CrmBusinessProductDO> convertBusinessProductList(CrmBusinessSaveReqVO reqVO, Long businessId) { | |
| 178 | + // 校验商品存在 | |
| 179 | + Set<Long> productIds = convertSet(reqVO.getProductItems(), CrmBusinessSaveReqVO.CrmBusinessProductItem::getId); | |
| 180 | + List<CrmProductDO> productList = productService.getProductList(productIds); | |
| 181 | + if (CollUtil.isEmpty(productIds) || productList.size() != productIds.size()) { | |
| 182 | + throw exception(PRODUCT_NOT_EXISTS); | |
| 183 | + } | |
| 184 | + Map<Long, CrmProductDO> productMap = convertMap(productList, CrmProductDO::getId); | |
| 185 | + return convertList(reqVO.getProductItems(), productItem -> { | |
| 186 | + CrmProductDO product = productMap.get(productItem.getId()); | |
| 187 | + return BeanUtils.toBean(product, CrmBusinessProductDO.class) | |
| 188 | + .setId(null).setProductId(productItem.getId()).setBusinessId(businessId) | |
| 189 | + .setCount(productItem.getCount()).setDiscountPercent(productItem.getDiscountPercent()) | |
| 190 | + .setTotalPrice(MoneyUtils.calculator(product.getPrice(), productItem.getCount(), productItem.getDiscountPercent())); | |
| 191 | + }); | |
| 192 | + } | |
| 193 | + | |
| 191 | 194 | /** |
| 192 | 195 | * 删除校验合同是关联合同 |
| 193 | 196 | * | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java
| ... | ... | @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageR |
| 6 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractSaveReqVO; |
| 7 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; |
| 9 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO; | |
| 9 | 10 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; |
| 10 | 11 | import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO; |
| 11 | 12 | import jakarta.validation.Valid; |
| ... | ... | @@ -134,4 +135,12 @@ public interface CrmContractService { |
| 134 | 135 | */ |
| 135 | 136 | Long getContractCountByBusinessId(Long businessId); |
| 136 | 137 | |
| 138 | + /** | |
| 139 | + * 获取合同商品列表 | |
| 140 | + * | |
| 141 | + * @param contactId 合同编号 | |
| 142 | + * @return 合同商品列表 | |
| 143 | + */ | |
| 144 | + List<CrmContractProductDO> getContractProductListByContractId(Long contactId); | |
| 145 | + | |
| 137 | 146 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java
| ... | ... | @@ -15,15 +15,15 @@ import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageR |
| 15 | 15 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractSaveReqVO; |
| 16 | 16 | import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO; |
| 17 | 17 | import cn.iocoder.yudao.module.crm.convert.contract.CrmContractConvert; |
| 18 | -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; | |
| 19 | 18 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; |
| 19 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractProductDO; | |
| 20 | 20 | import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; |
| 21 | 21 | import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper; |
| 22 | +import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractProductMapper; | |
| 22 | 23 | import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; |
| 23 | 24 | import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; |
| 24 | 25 | import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; |
| 25 | 26 | import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; |
| 26 | -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessProductService; | |
| 27 | 27 | import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; |
| 28 | 28 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; |
| 29 | 29 | import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO; |
| ... | ... | @@ -63,12 +63,12 @@ public class CrmContractServiceImpl implements CrmContractService { |
| 63 | 63 | |
| 64 | 64 | @Resource |
| 65 | 65 | private CrmContractMapper contractMapper; |
| 66 | + @Resource | |
| 67 | + private CrmContractProductMapper contractProductMapper; | |
| 66 | 68 | |
| 67 | 69 | @Resource |
| 68 | 70 | private CrmPermissionService crmPermissionService; |
| 69 | 71 | @Resource |
| 70 | - private CrmBusinessProductService businessProductService; | |
| 71 | - @Resource | |
| 72 | 72 | private CrmProductService productService; |
| 73 | 73 | @Resource |
| 74 | 74 | private CrmCustomerService customerService; |
| ... | ... | @@ -89,11 +89,14 @@ public class CrmContractServiceImpl implements CrmContractService { |
| 89 | 89 | // 1.1 插入合同 |
| 90 | 90 | CrmContractDO contract = BeanUtils.toBean(createReqVO, CrmContractDO.class).setId(null); |
| 91 | 91 | contractMapper.insert(contract); |
| 92 | - // 1.2 插入商机关联商品 | |
| 92 | + // 1.2 插入合同关联商品 | |
| 93 | 93 | if (CollUtil.isNotEmpty(createReqVO.getProductItems())) { // 如果有的话 |
| 94 | - List<CrmBusinessProductDO> businessProduct = convertBusinessProductList(createReqVO, contract.getId()); | |
| 95 | - businessProductService.createBusinessProductBatch(businessProduct); | |
| 94 | + List<CrmContractProductDO> productList = convertContractProductList(createReqVO, contract.getId()); | |
| 95 | + contractProductMapper.insertBatch(productList); | |
| 96 | 96 | // 更新合同商品总金额 |
| 97 | + contractMapper.updateById(new CrmContractDO().setId(contract.getId()).setProductPrice( | |
| 98 | + getSumValue(productList, CrmContractProductDO::getTotalPrice, Integer::sum))); | |
| 99 | + // TODO @puhui999: 如果存在合同关联了商机则更新商机商品关联 | |
| 97 | 100 | } |
| 98 | 101 | |
| 99 | 102 | // 2. 创建数据权限 |
| ... | ... | @@ -137,29 +140,29 @@ public class CrmContractServiceImpl implements CrmContractService { |
| 137 | 140 | if (CollUtil.isEmpty(updateReqVO.getProductItems())) { |
| 138 | 141 | return; |
| 139 | 142 | } |
| 140 | - List<CrmBusinessProductDO> newProductList = convertBusinessProductList(updateReqVO, contractId); | |
| 141 | - List<CrmBusinessProductDO> oldProductList = businessProductService.getBusinessProductListByContractId(contractId); | |
| 142 | - List<List<CrmBusinessProductDO>> diffList = diffList(oldProductList, newProductList, (oldObj, newObj) -> { | |
| 143 | - if (ObjUtil.notEqual(oldObj.getProductId(), newObj.getProductId())) { | |
| 144 | - return false; | |
| 143 | + List<CrmContractProductDO> newProductList = convertContractProductList(updateReqVO, contractId); | |
| 144 | + List<CrmContractProductDO> oldProductList = contractProductMapper.selectListByContractId(contractId); | |
| 145 | + List<List<CrmContractProductDO>> diffList = diffList(oldProductList, newProductList, (oldObj, newObj) -> { | |
| 146 | + boolean equal = ObjUtil.equal(oldObj.getProductId(), newObj.getProductId()); | |
| 147 | + if (equal) { | |
| 148 | + newObj.setId(oldObj.getId()); // 设置一下老的编号更新时需要使用 | |
| 145 | 149 | } |
| 146 | - newObj.setId(oldObj.getId()); // 设置一下老的编号更新时需要使用 | |
| 147 | - return true; | |
| 150 | + return equal; | |
| 148 | 151 | }); |
| 149 | - if (CollUtil.isNotEmpty(diffList.getFirst())) { | |
| 150 | - businessProductService.createBusinessProductBatch(diffList.getFirst()); | |
| 152 | + if (CollUtil.isNotEmpty(diffList.get(0))) { | |
| 153 | + contractProductMapper.insertBatch(diffList.get(0)); | |
| 151 | 154 | } |
| 152 | 155 | if (CollUtil.isNotEmpty(diffList.get(1))) { |
| 153 | - businessProductService.updateBusinessProductBatch(diffList.get(1)); | |
| 156 | + contractProductMapper.updateBatch(diffList.get(1)); | |
| 154 | 157 | } |
| 155 | 158 | if (CollUtil.isNotEmpty(diffList.get(2))) { |
| 156 | - businessProductService.deleteBusinessProductBatch(diffList.get(2)); | |
| 159 | + contractProductMapper.deleteBatchIds(convertList(diffList.get(2), CrmContractProductDO::getId)); | |
| 157 | 160 | } |
| 158 | 161 | } |
| 159 | 162 | |
| 160 | 163 | // TODO @合同待定:缺一个取消合同的接口;只有草稿、审批中可以取消;CrmAuditStatusEnum |
| 161 | 164 | |
| 162 | - private List<CrmBusinessProductDO> convertBusinessProductList(CrmContractSaveReqVO reqVO, Long contractId) { | |
| 165 | + private List<CrmContractProductDO> convertContractProductList(CrmContractSaveReqVO reqVO, Long contractId) { | |
| 163 | 166 | // 校验商品存在 |
| 164 | 167 | Set<Long> productIds = convertSet(reqVO.getProductItems(), CrmContractSaveReqVO.CrmContractProductItem::getId); |
| 165 | 168 | List<CrmProductDO> productList = productService.getProductList(productIds); |
| ... | ... | @@ -169,8 +172,8 @@ public class CrmContractServiceImpl implements CrmContractService { |
| 169 | 172 | Map<Long, CrmProductDO> productMap = convertMap(productList, CrmProductDO::getId); |
| 170 | 173 | return convertList(reqVO.getProductItems(), productItem -> { |
| 171 | 174 | CrmProductDO product = productMap.get(productItem.getId()); |
| 172 | - return BeanUtils.toBean(product, CrmBusinessProductDO.class) | |
| 173 | - .setId(null).setBusinessId(reqVO.getBusinessId()).setProductId(productItem.getId()).setContractId(contractId) | |
| 175 | + return BeanUtils.toBean(product, CrmContractProductDO.class) | |
| 176 | + .setId(null).setProductId(productItem.getId()).setContractId(contractId) | |
| 174 | 177 | .setCount(productItem.getCount()).setDiscountPercent(productItem.getDiscountPercent()) |
| 175 | 178 | .setTotalPrice(MoneyUtils.calculator(product.getPrice(), productItem.getCount(), productItem.getDiscountPercent())); |
| 176 | 179 | }); |
| ... | ... | @@ -313,5 +316,11 @@ public class CrmContractServiceImpl implements CrmContractService { |
| 313 | 316 | public Long getContractCountByBusinessId(Long businessId) { |
| 314 | 317 | return contractMapper.selectCountByBusinessId(businessId); |
| 315 | 318 | } |
| 319 | + | |
| 320 | + @Override | |
| 321 | + public List<CrmContractProductDO> getContractProductListByContractId(Long contactId) { | |
| 322 | + return contractProductMapper.selectListByContractId(contactId); | |
| 323 | + } | |
| 324 | + | |
| 316 | 325 | // TODO @合同待定:需要新增一个 ContractConfigDO 表,合同配置,重点是到期提醒; |
| 317 | 326 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java
| ... | ... | @@ -160,7 +160,7 @@ public class CrmProductServiceImpl implements CrmProductService { |
| 160 | 160 | if (CollUtil.isEmpty(ids)) { |
| 161 | 161 | return Collections.emptyList(); |
| 162 | 162 | } |
| 163 | - return productMapper.selectListByIds(ids); | |
| 163 | + return productMapper.selectBatchIds(ids); | |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | } | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/test/java/cn/iocoder/yudao/module/erp/service/product/ErpProductUnitServiceImplTest.java
| 1 | 1 | package cn.iocoder.yudao.module.erp.service.product; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 3 | 5 | import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitPageReqVO; |
| 4 | 6 | import cn.iocoder.yudao.module.erp.controller.admin.product.vo.unit.ErpProductUnitSaveReqVO; |
| 5 | -import org.junit.jupiter.api.Disabled; | |
| 6 | -import org.junit.jupiter.api.Test; | |
| 7 | - | |
| 8 | -import jakarta.annotation.Resource; | |
| 9 | - | |
| 10 | -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 11 | - | |
| 12 | 7 | import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; |
| 13 | 8 | import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductUnitMapper; |
| 14 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 15 | - | |
| 9 | +import jakarta.annotation.Resource; | |
| 10 | +import org.junit.jupiter.api.Disabled; | |
| 11 | +import org.junit.jupiter.api.Test; | |
| 16 | 12 | import org.springframework.context.annotation.Import; |
| 17 | 13 | |
| 18 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; | |
| 19 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | |
| 20 | -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; | |
| 21 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; | |
| 14 | +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; | |
| 15 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 16 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 17 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 18 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 19 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 20 | +import static cn.iocoder.yudao.module.erp.ErrorCodeConstants.PRODUCT_UNIT_NOT_EXISTS; | |
| 22 | 21 | import static org.junit.jupiter.api.Assertions.*; |
| 23 | 22 | |
| 24 | 23 | /** | ... | ... |
yudao-module-erp/yudao-module-erp-biz/src/test/java/cn/iocoder/yudao/module/erp/service/product/ProductServiceImplTest.java
| 1 | 1 | package cn.iocoder.yudao.module.erp.service.product; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 3 | 5 | import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductPageReqVO; |
| 4 | 6 | import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO; |
| 5 | -import org.junit.jupiter.api.Disabled; | |
| 6 | -import org.junit.jupiter.api.Test; | |
| 7 | - | |
| 8 | -import jakarta.annotation.Resource; | |
| 9 | - | |
| 10 | -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 11 | - | |
| 12 | 7 | import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; |
| 13 | 8 | import cn.iocoder.yudao.module.erp.dal.mysql.product.ErpProductMapper; |
| 14 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 15 | - | |
| 9 | +import jakarta.annotation.Resource; | |
| 10 | +import org.junit.jupiter.api.Disabled; | |
| 11 | +import org.junit.jupiter.api.Test; | |
| 16 | 12 | import org.springframework.context.annotation.Import; |
| 17 | 13 | |
| 18 | -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; | |
| 19 | -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | |
| 20 | -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; | |
| 21 | -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; | |
| 14 | +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; | |
| 15 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 16 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 17 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 18 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 19 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 20 | +import static cn.iocoder.yudao.module.erp.ErrorCodeConstants.PRODUCT_NOT_EXISTS; | |
| 22 | 21 | import static org.junit.jupiter.api.Assertions.*; |
| 23 | 22 | |
| 24 | 23 | /** | ... | ... |