From 2d9f5cc4d0992af69f4ba7971de82840a97e7c6f Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 30 Nov 2023 19:12:37 +0800 Subject: [PATCH] =?UTF-8?q?crm:=201=EF=BC=89=E8=B0=83=E6=95=B4=E5=90=88?= =?UTF-8?q?=E5=90=8C=E7=9A=84=20CRM=20=E5=89=8D=E7=BC=80=EF=BC=9B2?= =?UTF-8?q?=EF=BC=89=E5=A2=9E=E5=8A=A0=E5=9F=BA=E4=BA=8E=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=90=88=E5=90=8C=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/AuditStatusEnum.java | 61 ------------- .../module/crm/enums/DictTypeConstants.java | 2 +- .../module/crm/enums/ReturnTypeEnum.java | 8 -- .../crm/enums/common/CrmAuditStatusEnum.java | 34 +++++++ .../crm/enums/common/CrmBizTypeEnum.java | 2 +- .../admin/contact/CrmContactController.java | 2 +- ...roller.java => CrmContractController.java} | 72 ++++++++++++--- .../contract/vo/ContractExportReqVO.java | 37 -------- .../admin/contract/vo/ContractRespVO.java | 17 +++- ...ractBaseVO.java => CrmContractBaseVO.java} | 3 +- ...ReqVO.java => CrmContractCreateReqVO.java} | 2 +- ...ctExcelVO.java => CrmContractExcelVO.java} | 2 +- ...geReqVO.java => CrmContractPageReqVO.java} | 23 +---- .../contract/vo/CrmContractTransferReqVO.java | 10 +-- ...ReqVO.java => CrmContractUpdateReqVO.java} | 2 +- .../receivable/vo/CrmReceivableBaseVO.java | 4 +- .../receivable/vo/CrmReceivableExcelVO.java | 2 +- .../vo/CrmReceivablePlanBaseVO.java | 4 +- .../vo/CrmReceivablePlanExcelVO.java | 2 +- .../crm/convert/contact/ContactConvert.java | 2 + .../crm/convert/contract/ContractConvert.java | 41 +++++++-- .../{ContractDO.java => CrmContractDO.java} | 20 ++++- .../receivable/CrmReceivableDO.java | 5 +- .../receivable/CrmReceivablePlanDO.java | 2 +- .../dal/mysql/contact/CrmContactMapper.java | 2 +- .../dal/mysql/contract/ContractMapper.java | 45 ---------- .../dal/mysql/contract/CrmContractMapper.java | 36 ++++++++ .../contact/CrmContactServiceImpl.java | 14 +-- .../crm/service/contract/ContractService.java | 81 ----------------- .../service/contract/CrmContractService.java | 89 +++++++++++++++++++ ...eImpl.java => CrmContractServiceImpl.java} | 52 ++++++----- .../crm/service/contract/package-info.java | 4 - .../CrmReceivablePlanServiceImpl.java | 12 +-- .../receivable/CrmReceivableServiceImpl.java | 12 +-- .../contract/ContractServiceImplTest.java | 42 ++++----- 35 files changed, 379 insertions(+), 369 deletions(-) delete mode 100644 yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/AuditStatusEnum.java delete mode 100644 yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ReturnTypeEnum.java create mode 100644 yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmAuditStatusEnum.java rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/{ContractController.java => CrmContractController.java} (52%) delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractExportReqVO.java rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/{ContractBaseVO.java => CrmContractBaseVO.java} (96%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/{ContractCreateReqVO.java => CrmContractCreateReqVO.java} (84%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/{ContractExcelVO.java => CrmContractExcelVO.java} (97%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/{ContractPageReqVO.java => CrmContractPageReqVO.java} (52%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/{ContractUpdateReqVO.java => CrmContractUpdateReqVO.java} (89%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/{ContractDO.java => CrmContractDO.java} (81%) delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/ContractMapper.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/ContractService.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/{ContractServiceImpl.java => CrmContractServiceImpl.java} (59%) delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/package-info.java diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/AuditStatusEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/AuditStatusEnum.java deleted file mode 100644 index 85236fdd2..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/AuditStatusEnum.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums; - -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; - -import java.util.Arrays; - -// TODO @liuhongfeng:这个状态,还是搞成专属 CrmReceivableDO 专属的 status; -/** - * 流程审批状态枚举类 - * 0 未审核 1 审核通过 2 审核拒绝 3 审核中 4 已撤回 TODO @liuhongfeng:这一行可以删除,因为已经有枚举属性了哈; - * @author 赤焰 - */ -// TODO @liuhongfeng:可以使用 @Getter、@AllArgsConstructor 简化 get、构造方法 -public enum AuditStatusEnum implements IntArrayValuable { - - // TODO @liuhongfeng:草稿 0;10 审核中;20 审核通过;30 审核拒绝;40 已撤回;主要是留好间隙,万一每个地方要做点拓展; 然后,枚举字段的顺序调整下,审批中,一定要放两个审批通过、拒绝前面哈; - /** - * 未审批 - */ - AUDIT_NEW(0, "未审批"), - /** - * 审核通过 - */ - AUDIT_FINISH(1, "审核通过"), - /** - * 审核拒绝 - */ - AUDIT_REJECT(2, "审核拒绝"), - /** - * 审核中 - */ - AUDIT_DOING(3, "审核中"), - /** - * 已撤回 - */ - AUDIT_RETURN(4, "已撤回"); - - // TODO liuhongfeng:value 改成 status;desc 改成 name; - private final Integer value; - private final String desc; - - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AuditStatusEnum::getValue).toArray(); - - AuditStatusEnum(Integer value, String desc) { - this.value = value; - this.desc = desc; - } - - public Integer getValue() { - return value; - } - - public String getDesc() { - return desc; - } - - @Override - public int[] array() { - return ARRAYS; - } -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java index 71f550775..a7313f91a 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java @@ -11,6 +11,6 @@ public interface DictTypeConstants { String CRM_CUSTOMER_INDUSTRY = "crm_customer_industry"; // CRM 客户所属行业 String CRM_CUSTOMER_LEVEL = "crm_customer_level"; // CRM 客户等级 String CRM_CUSTOMER_SOURCE = "crm_customer_source"; // CRM 客户来源 - String CRM_RECEIVABLE_CHECK_STATUS = "crm_receivable_check_status"; // CRM 审批状态 + String CRM_AUDIT_STATUS = "crm_audit_status"; // CRM 审批状态 } diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ReturnTypeEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ReturnTypeEnum.java deleted file mode 100644 index e6074c432..000000000 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ReturnTypeEnum.java +++ /dev/null @@ -1,8 +0,0 @@ -package cn.iocoder.yudao.module.crm.enums; - -// TODO @liuhongfeng:这个的作用是? -/** - * @author 赤焰 - */ -public enum ReturnTypeEnum { -} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmAuditStatusEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmAuditStatusEnum.java new file mode 100644 index 000000000..67709e95b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmAuditStatusEnum.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.enums.common; + +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +import java.util.Arrays; + +/** + * CRM 的审批状态 + * + * @author 赤焰 + */ +@RequiredArgsConstructor +@Getter +public enum CrmAuditStatusEnum implements IntArrayValuable { + + DRAFT(0, "未提交"), + PROCESS(10, "审批中"), + APPROVE(20, "审核通过"), + REJECT(30, "审核不通过"), + CANCEL(40, "已取消"); + + private final Integer status; + private final String name; + + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmAuditStatusEnum::getStatus).toArray(); + + @Override + public int[] array() { + return ARRAYS; + } + +} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmBizTypeEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmBizTypeEnum.java index 539bfc291..3e92ff18e 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmBizTypeEnum.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/CrmBizTypeEnum.java @@ -19,7 +19,7 @@ public enum CrmBizTypeEnum implements IntArrayValuable { CRM_LEADS(1, "线索"), CRM_CUSTOMER(2, "客户"), - CRM_CONTACTS(3, "联系人"), + CRM_CONTACT(3, "联系人"), CRM_BUSINESS(4, "商机"), CRM_CONTRACT(5, "合同"); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java index b39331338..f39f67ac4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java @@ -151,7 +151,7 @@ public class CrmContactController { // 1. 获取客户列表 List crmCustomerDOList = customerService.getCustomerList( convertSet(contactList, CrmContactDO::getCustomerId)); - // 2. 获取创建人、责任人列表 + // 2. 获取创建人、负责人列表 Map userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); // 3. 直属上级 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/ContractController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java similarity index 52% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/ContractController.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java index 1028929db..70b124196 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/ContractController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java @@ -1,13 +1,20 @@ package cn.iocoder.yudao.module.crm.controller.admin.contract; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.number.NumberUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; import cn.iocoder.yudao.module.crm.convert.contract.ContractConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; -import cn.iocoder.yudao.module.crm.service.contract.ContractService; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; +import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -20,8 +27,12 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; import java.util.List; +import java.util.Map; +import java.util.stream.Stream; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @@ -29,22 +40,27 @@ import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUti @RestController @RequestMapping("/crm/contract") @Validated -public class ContractController { +public class CrmContractController { @Resource - private ContractService contractService; + private CrmContractService contractService; + @Resource + private CrmCustomerService customerService; + + @Resource + private AdminUserApi adminUserApi; @PostMapping("/create") @Operation(summary = "创建合同") @PreAuthorize("@ss.hasPermission('crm:contract:create')") - public CommonResult createContract(@Valid @RequestBody ContractCreateReqVO createReqVO) { + public CommonResult createContract(@Valid @RequestBody CrmContractCreateReqVO createReqVO) { return success(contractService.createContract(createReqVO, getLoginUserId())); } @PutMapping("/update") @Operation(summary = "更新合同") @PreAuthorize("@ss.hasPermission('crm:contract:update')") - public CommonResult updateContract(@Valid @RequestBody ContractUpdateReqVO updateReqVO) { + public CommonResult updateContract(@Valid @RequestBody CrmContractUpdateReqVO updateReqVO) { contractService.updateContract(updateReqVO); return success(true); } @@ -63,28 +79,56 @@ public class ContractController { @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('crm:contract:query')") public CommonResult getContract(@RequestParam("id") Long id) { - ContractDO contract = contractService.getContract(id); + CrmContractDO contract = contractService.getContract(id); return success(ContractConvert.INSTANCE.convert(contract)); } @GetMapping("/page") @Operation(summary = "获得合同分页") @PreAuthorize("@ss.hasPermission('crm:contract:query')") - public CommonResult> getContractPage(@Valid ContractPageReqVO pageVO) { - PageResult pageResult = contractService.getContractPage(pageVO); - return success(ContractConvert.INSTANCE.convertPage(pageResult)); + public CommonResult> getContractPage(@Valid CrmContractPageReqVO pageVO) { + PageResult pageResult = contractService.getContractPage(pageVO); + return success(convertDetailContractPage(pageResult)); + } + + @GetMapping("/page-by-customer") + @Operation(summary = "获得联系人分页,基于指定客户") + public CommonResult> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) { + Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空"); + PageResult pageResult = contractService.getContractPageByCustomer(pageVO); + return success(convertDetailContractPage(pageResult)); } @GetMapping("/export-excel") @Operation(summary = "导出合同 Excel") @PreAuthorize("@ss.hasPermission('crm:contract:export')") @OperateLog(type = EXPORT) - public void exportContractExcel(@Valid ContractExportReqVO exportReqVO, + public void exportContractExcel(@Valid CrmContractPageReqVO exportReqVO, HttpServletResponse response) throws IOException { - List list = contractService.getContractList(exportReqVO); + PageResult pageResult = contractService.getContractPage(exportReqVO); // 导出 Excel - List datas = ContractConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "合同.xls", "数据", ContractExcelVO.class, datas); + ExcelUtils.write(response, "合同.xls", "数据", CrmContractExcelVO.class, + ContractConvert.INSTANCE.convertList02(pageResult.getList())); + } + + /** + * 转换成详细的联系人分页,即读取关联信息 + * + * @param pageResult 联系人分页 + * @return 详细的联系人分页 + */ + private PageResult convertDetailContractPage(PageResult pageResult) { + List contactList = pageResult.getList(); + if (CollUtil.isEmpty(contactList)) { + return PageResult.empty(pageResult.getTotal()); + } + // 1. 获取客户列表 + List customerList = customerService.getCustomerList( + convertSet(contactList, CrmContractDO::getCustomerId)); + // 2. 获取创建人、负责人列表 + Map userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, + contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); + return ContractConvert.INSTANCE.convertPage(pageResult, userMap, customerList); } @PutMapping("/transfer") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractExportReqVO.java deleted file mode 100644 index 003e1f57c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractExportReqVO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 合同 Excel 导出 Request VO,参数和 ContractPageReqVO 是一致的") -@Data -public class ContractExportReqVO { - - @Schema(description = "合同名称", example = "王五") - private String name; - - @Schema(description = "客户编号", example = "18336") - private Long customerId; - - @Schema(description = "商机编号", example = "10864") - private Long businessId; - - @Schema(description = "下单日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] orderDate; - - @Schema(description = "合同编号") - private String no; - - @Schema(description = "整单折扣") - private Integer discountPercent; - - @Schema(description = "产品总金额", example = "19510") - private Integer productPrice; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractRespVO.java index 4a22251b0..cfe746bcb 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractRespVO.java @@ -11,7 +11,7 @@ import java.time.LocalDateTime; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ContractRespVO extends ContractBaseVO { +public class ContractRespVO extends CrmContractBaseVO { @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") private Long id; @@ -19,4 +19,19 @@ public class ContractRespVO extends ContractBaseVO { @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) private LocalDateTime createTime; + @Schema(description = "创建人", example = "25682") + private String creator; + + @Schema(description = "创建人名字", example = "test") + private String creatorName; + + @Schema(description = "客户名字", example = "test") + private String customerName; + + @Schema(description = "负责人", example = "test") + private String ownerUserName; + + @Schema(description = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") + private Integer auditStatus; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractBaseVO.java similarity index 96% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractBaseVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractBaseVO.java index 756ee0d1f..5dd46e976 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractBaseVO.java @@ -9,13 +9,12 @@ import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -// TODO @dhb52:所有类,带下 Crm 前缀,避免和别的模块重复 /** * 合同 Base VO,提供给添加、修改、详细的子 VO 使用 * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 */ @Data -public class ContractBaseVO { +public class CrmContractBaseVO { // TODO @dhb52:类似 no 字段的 example 要写xia 哈; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractCreateReqVO.java similarity index 84% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractCreateReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractCreateReqVO.java index 7793d7737..17196473a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractCreateReqVO.java @@ -9,6 +9,6 @@ import lombok.ToString; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ContractCreateReqVO extends ContractBaseVO { +public class CrmContractCreateReqVO extends CrmContractBaseVO { } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractExcelVO.java similarity index 97% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractExcelVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractExcelVO.java index 2fb521321..72f9f3cfa 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractExcelVO.java @@ -11,7 +11,7 @@ import java.time.LocalDateTime; * @author dhb52 */ @Data -public class ContractExcelVO { +public class CrmContractExcelVO { @ExcelProperty("合同编号") private Long id; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractPageReqVO.java similarity index 52% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractPageReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractPageReqVO.java index 36c7e14be..e2f286a99 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractPageReqVO.java @@ -5,17 +5,15 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @Schema(description = "管理后台 - CRM 合同分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ContractPageReqVO extends PageParam { +public class CrmContractPageReqVO extends PageParam { + + @Schema(description = "合同编号", example = "XYZ008") + private String no; @Schema(description = "合同名称", example = "王五") private String name; @@ -26,17 +24,4 @@ public class ContractPageReqVO extends PageParam { @Schema(description = "商机编号", example = "10864") private Long businessId; - @Schema(description = "下单日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] orderDate; - - @Schema(description = "合同编号") - private String no; - - @Schema(description = "整单折扣") - private Integer discountPercent; - - @Schema(description = "产品总金额", example = "19510") - private Integer productPrice; - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractTransferReqVO.java index 09ce1e9f3..f13af856c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractTransferReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractTransferReqVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; +import cn.iocoder.yudao.framework.common.validation.InEnum; import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; @@ -14,19 +15,12 @@ public class CrmContractTransferReqVO { @NotNull(message = "联系人编号不能为空") private Long id; - /** - * 新负责人的用户编号 - */ @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") @NotNull(message = "新负责人的用户编号不能为空") private Long newOwnerUserId; - /** - * 老负责人加入团队后的权限级别。如果 null 说明移除 - * - * 关联 {@link CrmPermissionLevelEnum} - */ @Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @InEnum(value = CrmPermissionLevelEnum.class) private Integer oldOwnerPermissionLevel; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractUpdateReqVO.java similarity index 89% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractUpdateReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractUpdateReqVO.java index 34a9797f4..5892cb789 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractUpdateReqVO.java @@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ContractUpdateReqVO extends ContractBaseVO { +public class CrmContractUpdateReqVO extends CrmContractBaseVO { @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") @NotNull(message = "合同编号不能为空") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableBaseVO.java index 7b3ffd881..aeefd94cc 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableBaseVO.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; +import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; @@ -34,7 +34,7 @@ public class CrmReceivableBaseVO { // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的 @Schema(description = "审批状态", example = "1") - @InEnum(AuditStatusEnum.class) + @InEnum(CrmAuditStatusEnum.class) private Integer checkStatus; @Schema(description = "回款日期") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExcelVO.java index 291431e2c..3d81378a8 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExcelVO.java @@ -28,7 +28,7 @@ public class CrmReceivableExcelVO { private Long contractId; @ExcelProperty(value = "审批状态", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_RECEIVABLE_CHECK_STATUS) + @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_AUDIT_STATUS) private Integer checkStatus; @ExcelProperty("工作流编号") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanBaseVO.java index eaba43dce..517ac9811 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanBaseVO.java @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; +import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; @@ -28,7 +28,7 @@ public class CrmReceivablePlanBaseVO { private Integer status; @Schema(description = "审批状态", example = "1") - @InEnum(AuditStatusEnum.class) + @InEnum(CrmAuditStatusEnum.class) private Integer checkStatus; @Schema(description = "计划回款金额", example = "29675") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExcelVO.java index f4dd28366..7c25bf18e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExcelVO.java @@ -31,7 +31,7 @@ public class CrmReceivablePlanExcelVO { private Integer status; @ExcelProperty(value = "审批状态", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_RECEIVABLE_CHECK_STATUS) + @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_AUDIT_STATUS) private Integer checkStatus; //@ExcelProperty("工作流编号") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java index 9b214941a..636835be7 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java @@ -19,6 +19,7 @@ import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; +// TODO 芋艿:convert 后面在梳理下,略微有点乱 /** * CRM 联系人 Convert * @@ -44,6 +45,7 @@ public interface ContactConvert { List list = converList(pageResult.getList(), userMap, customerList, parentContactList); return convertPage(pageResult).setList(list); } + List convertAllList(List list); @Mappings({ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/ContractConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/ContractConvert.java index 09c61dd6d..2041ba5de 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/ContractConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/ContractConvert.java @@ -2,14 +2,20 @@ package cn.iocoder.yudao.module.crm.convert.contract; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; /** * 合同 Convert @@ -21,17 +27,17 @@ public interface ContractConvert { ContractConvert INSTANCE = Mappers.getMapper(ContractConvert.class); - ContractDO convert(ContractCreateReqVO bean); + CrmContractDO convert(CrmContractCreateReqVO bean); - ContractDO convert(ContractUpdateReqVO bean); + CrmContractDO convert(CrmContractUpdateReqVO bean); - ContractRespVO convert(ContractDO bean); + ContractRespVO convert(CrmContractDO bean); - List convertList(List list); + List convertList(List list); - PageResult convertPage(PageResult page); + PageResult convertPage(PageResult page); - List convertList02(List list); + List convertList02(List list); @Mappings({ @Mapping(target = "bizId", source = "reqVO.id"), @@ -39,4 +45,25 @@ public interface ContractConvert { }) CrmPermissionTransferReqBO convert(CrmContractTransferReqVO reqVO, Long userId); + default PageResult convertPage(PageResult pageResult, Map userMap, + List customerList) { + return new PageResult<>(converList(pageResult.getList(), userMap, customerList), pageResult.getTotal()); + } + + default List converList(List contractList, Map userMap, + List customerList) { + List result = convertList(contractList); + Map customerMap = convertMap(customerList, CrmCustomerDO::getId); + result.forEach(item -> { + setUserInfo(item, userMap); + findAndThen(customerMap, item.getCustomerId(), customer -> item.setCustomerName(customer.getName())); + }); + return result; + } + + static void setUserInfo(ContractRespVO contract, Map userMap) { + findAndThen(userMap, contract.getOwnerUserId(), user -> contract.setOwnerUserName(user.getNickname())); + findAndThen(userMap, Long.parseLong(contract.getCreator()), user -> contract.setCreatorName(user.getNickname())); + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/ContractDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractDO.java similarity index 81% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/ContractDO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractDO.java index f32786791..bdaff7271 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/ContractDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/CrmContractDO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.contract; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -8,8 +9,9 @@ import lombok.*; import java.time.LocalDateTime; +// TODO 芋艿:实体的梳理 /** - * 合同 DO + * CRM 合同 DO * * @author dhb52 */ @@ -21,7 +23,7 @@ import java.time.LocalDateTime; @Builder @NoArgsConstructor @AllArgsConstructor -public class ContractDO extends BaseDO { +public class CrmContractDO extends BaseDO { /** * 合同编号 @@ -89,4 +91,18 @@ public class ContractDO extends BaseDO { */ private String remark; + /** + * 负责人的用户编号 + * + * 关联 AdminUserDO 的 id 字段 + */ + private Long ownerUserId; + + /** + * 审批状态 + * + * 枚举 {@link CrmAuditStatusEnum} + */ + private Integer auditStatus; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java index a8c3e3fed..16cbebe56 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -50,13 +51,13 @@ public class CrmReceivableDO extends BaseDO { /** * 合同 ID * - * 对应实体 {@link cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO} + * 对应实体 {@link CrmContractDO} */ private Long contractId; // TODO @liuhongfeng:“对应字典”,参考别的模块,枚举 {@link XXXX};另外,这个字段就叫 status,整体状态,不只审批 /** * 审批状态 - * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_RECEIVABLE_CHECK_STATUS} + * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_AUDIT_STATUS} */ private Integer checkStatus; /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java index 52c0d2745..bec57cc9e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java @@ -48,7 +48,7 @@ public class CrmReceivablePlanDO extends BaseDO { /** * 审批状态 * - * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_RECEIVABLE_CHECK_STATUS} + * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_AUDIT_STATUS} * // TODO @liuhongfeng:关联的枚举 */ private Integer checkStatus; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java index b459e8f5c..4c8f82f1a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/CrmContactMapper.java @@ -30,7 +30,7 @@ public interface CrmContactMapper extends BaseMapperX { default PageResult selectPageByCustomer(CrmContactPageReqVO pageVO) { return selectPage(pageVO, new LambdaQueryWrapperX() - .eq(CrmContactDO::getCustomerId, pageVO.getCustomerId()) + .eq(CrmContactDO::getCustomerId, pageVO.getCustomerId()) // 必须传递 .likeIfPresent(CrmContactDO::getName, pageVO.getName()) .eqIfPresent(CrmContactDO::getMobile, pageVO.getMobile()) .eqIfPresent(CrmContactDO::getTelephone, pageVO.getTelephone()) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/ContractMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/ContractMapper.java deleted file mode 100644 index 47337518b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/ContractMapper.java +++ /dev/null @@ -1,45 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.contract; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractPageReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * 合同 Mapper - * - * @author dhb52 - */ -@Mapper -public interface ContractMapper extends BaseMapperX { - - default PageResult selectPage(ContractPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .likeIfPresent(ContractDO::getName, reqVO.getName()) - .eqIfPresent(ContractDO::getCustomerId, reqVO.getCustomerId()) - .eqIfPresent(ContractDO::getBusinessId, reqVO.getBusinessId()) - .betweenIfPresent(ContractDO::getOrderDate, reqVO.getOrderDate()) - .eqIfPresent(ContractDO::getNo, reqVO.getNo()) - .eqIfPresent(ContractDO::getDiscountPercent, reqVO.getDiscountPercent()) - .eqIfPresent(ContractDO::getProductPrice, reqVO.getProductPrice()) - .orderByDesc(ContractDO::getId)); - } - - default List selectList(ContractExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .likeIfPresent(ContractDO::getName, reqVO.getName()) - .eqIfPresent(ContractDO::getCustomerId, reqVO.getCustomerId()) - .eqIfPresent(ContractDO::getBusinessId, reqVO.getBusinessId()) - .betweenIfPresent(ContractDO::getOrderDate, reqVO.getOrderDate()) - .eqIfPresent(ContractDO::getNo, reqVO.getNo()) - .eqIfPresent(ContractDO::getDiscountPercent, reqVO.getDiscountPercent()) - .eqIfPresent(ContractDO::getProductPrice, reqVO.getProductPrice()) - .orderByDesc(ContractDO::getId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java new file mode 100644 index 000000000..a22912162 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/CrmContractMapper.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.contract; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * CRM 合同 Mapper + * + * @author dhb52 + */ +@Mapper +public interface CrmContractMapper extends BaseMapperX { + + default PageResult selectPage(CrmContractPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(CrmContractDO::getNo, reqVO.getNo()) + .likeIfPresent(CrmContractDO::getName, reqVO.getName()) + .eqIfPresent(CrmContractDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(CrmContractDO::getBusinessId, reqVO.getBusinessId()) + .orderByDesc(CrmContractDO::getId)); + } + + default PageResult selectPageByCustomer(CrmContractPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eq(CrmContractDO::getCustomerId, reqVO.getCustomerId()) // 必须传递 + .likeIfPresent(CrmContractDO::getNo, reqVO.getNo()) + .likeIfPresent(CrmContractDO::getName, reqVO.getName()) + .eqIfPresent(CrmContractDO::getBusinessId, reqVO.getBusinessId()) + .orderByDesc(CrmContractDO::getId)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java index d5e908400..57ebdf4e1 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java @@ -61,13 +61,13 @@ public class CrmContactServiceImpl implements CrmContactService { // 2. 创建数据权限 crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(userId) - .setBizType(CrmBizTypeEnum.CRM_CONTACTS.getType()).setBizId(contact.getId()) + .setBizType(CrmBizTypeEnum.CRM_CONTACT.getType()).setBizId(contact.getId()) .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); return contact.getId(); } @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) public void updateContact(CrmContactUpdateReqVO updateReqVO) { // 1. 校验存在 validateContactExists(updateReqVO.getId()); @@ -98,7 +98,7 @@ public class CrmContactServiceImpl implements CrmContactService { } @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) public void deleteContact(Long id) { // 校验存在 validateContactExists(id); @@ -114,7 +114,7 @@ public class CrmContactServiceImpl implements CrmContactService { // TODO 芋艿:是否要做数据权限的校验??? @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACTS, bizId = "#id", level = CrmPermissionLevelEnum.READ) + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.READ) public CrmContactDO getContact(Long id) { return contactMapper.selectById(id); } @@ -134,9 +134,9 @@ public class CrmContactServiceImpl implements CrmContactService { } @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageVO.customerId", level = CrmPermissionLevelEnum.READ) - public PageResult getContactPageByCustomer(CrmContactPageReqVO pageVO) { - return contactMapper.selectPageByCustomer(pageVO); + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) + public PageResult getContactPageByCustomer(CrmContactPageReqVO pageReqVO) { + return contactMapper.selectPageByCustomer(pageReqVO); } @Override diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/ContractService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/ContractService.java deleted file mode 100644 index 201684bd8..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/ContractService.java +++ /dev/null @@ -1,81 +0,0 @@ -package cn.iocoder.yudao.module.crm.service.contract; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; - -import javax.validation.Valid; -import java.util.Collection; -import java.util.List; - -/** - * 合同 Service 接口 - * - * @author dhb52 - */ -public interface ContractService { - - /** - * 创建合同 - * - * @param createReqVO 创建信息 - * @param userId 用户编号 - * @return 编号 - */ - Long createContract(@Valid ContractCreateReqVO createReqVO, Long userId); - - /** - * 更新合同 - * - * @param updateReqVO 更新信息 - */ - void updateContract(@Valid ContractUpdateReqVO updateReqVO); - - /** - * 删除合同 - * - * @param id 编号 - */ - void deleteContract(Long id); - - /** - * 获得合同 - * - * @param id 编号 - * @return 合同 - */ - ContractDO getContract(Long id); - - /** - * 获得合同列表 - * - * @param ids 编号 - * @return 合同列表 - */ - List getContractList(Collection ids); - - /** - * 获得合同分页 - * - * @param pageReqVO 分页查询 - * @return 合同分页 - */ - PageResult getContractPage(ContractPageReqVO pageReqVO); - - /** - * 获得合同列表, 用于 Excel 导出 - * - * @param exportReqVO 查询条件 - * @return 合同列表 - */ - List getContractList(ContractExportReqVO exportReqVO); - - /** - * 合同转移 - * - * @param reqVO 请求 - * @param userId 用户编号 - */ - void transferContract(CrmContractTransferReqVO reqVO, Long userId); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java new file mode 100644 index 000000000..3b16d7778 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractService.java @@ -0,0 +1,89 @@ +package cn.iocoder.yudao.module.crm.service.contract; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; + +/** + * CRM 合同 Service 接口 + * + * @author dhb52 + */ +public interface CrmContractService { + + /** + * 创建合同 + * + * @param createReqVO 创建信息 + * @param userId 用户编号 + * @return 编号 + */ + Long createContract(@Valid CrmContractCreateReqVO createReqVO, Long userId); + + /** + * 更新合同 + * + * @param updateReqVO 更新信息 + */ + void updateContract(@Valid CrmContractUpdateReqVO updateReqVO); + + /** + * 删除合同 + * + * @param id 编号 + */ + void deleteContract(Long id); + + /** + * 获得合同 + * + * @param id 编号 + * @return 合同 + */ + CrmContractDO getContract(Long id); + + /** + * 获得合同列表 + * + * @param ids 编号 + * @return 合同列表 + */ + List getContractList(Collection ids); + + /** + * 获得合同分页 + * + * 数据权限:基于 {@link CrmContractDO} 读取 + * + * @param pageReqVO 分页查询 + * @return 合同分页 + */ + PageResult getContractPage(CrmContractPageReqVO pageReqVO); + + /** + * 获得合同分页,基于指定客户 + * + * 数据权限:基于 {@link CrmCustomerDO} 读取 + * + * @param pageReqVO 分页查询 + * @return 联系人分页 + */ + PageResult getContractPageByCustomer(CrmContractPageReqVO pageReqVO); + + /** + * 合同转移 + * + * @param reqVO 请求 + * @param userId 用户编号 + */ + void transferContract(CrmContractTransferReqVO reqVO, Long userId); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java similarity index 59% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImpl.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java index a3d139e8a..0445dfca2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/CrmContractServiceImpl.java @@ -3,13 +3,16 @@ package cn.iocoder.yudao.module.crm.service.contract; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO; import cn.iocoder.yudao.module.crm.convert.contract.ContractConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; -import cn.iocoder.yudao.module.crm.dal.mysql.contract.ContractMapper; -import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; +import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper; import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; +import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; import org.springframework.stereotype.Service; @@ -24,48 +27,47 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS; /** - * 合同 Service 实现类 + * CRM 合同 Service 实现类 * * @author dhb52 */ @Service @Validated -public class ContractServiceImpl implements ContractService { +public class CrmContractServiceImpl implements CrmContractService { @Resource - private ContractMapper contractMapper; + private CrmContractMapper contractMapper; @Resource private CrmPermissionService crmPermissionService; @Override - public Long createContract(ContractCreateReqVO createReqVO, Long userId) { + public Long createContract(CrmContractCreateReqVO createReqVO, Long userId) { // 插入 - ContractDO contract = ContractConvert.INSTANCE.convert(createReqVO); + CrmContractDO contract = ContractConvert.INSTANCE.convert(createReqVO); contractMapper.insert(contract); // 创建数据权限 - crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CONTRACT.getType()) - .setBizId(contract.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人 - - // 返回 + crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(userId) + .setBizType(CrmBizTypeEnum.CRM_CONTRACT.getType()).setBizId(contract.getId()) + .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); return contract.getId(); } @Override @Transactional(rollbackFor = Exception.class) @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, level = CrmPermissionLevelEnum.WRITE) - public void updateContract(ContractUpdateReqVO updateReqVO) { + public void updateContract(CrmContractUpdateReqVO updateReqVO) { // 校验存在 validateContractExists(updateReqVO.getId()); // 更新 - ContractDO updateObj = ContractConvert.INSTANCE.convert(updateReqVO); + CrmContractDO updateObj = ContractConvert.INSTANCE.convert(updateReqVO); contractMapper.updateById(updateObj); } @Override @Transactional(rollbackFor = Exception.class) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, level = CrmPermissionLevelEnum.WRITE) + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.WRITE) public void deleteContract(Long id) { // 校验存在 validateContractExists(id); @@ -73,22 +75,23 @@ public class ContractServiceImpl implements ContractService { contractMapper.deleteById(id); } - private ContractDO validateContractExists(Long id) { - ContractDO contract = contractMapper.selectById(id); + private CrmContractDO validateContractExists(Long id) { + CrmContractDO contract = contractMapper.selectById(id); if (contract == null) { throw exception(CONTRACT_NOT_EXISTS); } return contract; } + // TODO 芋艿:是否要做数据权限的校验??? @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, level = CrmPermissionLevelEnum.READ) - public ContractDO getContract(Long id) { + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTRACT, bizId = "#id", level = CrmPermissionLevelEnum.READ) + public CrmContractDO getContract(Long id) { return contractMapper.selectById(id); } @Override - public List getContractList(Collection ids) { + public List getContractList(Collection ids) { if (CollUtil.isEmpty(ids)) { return ListUtil.empty(); } @@ -96,13 +99,14 @@ public class ContractServiceImpl implements ContractService { } @Override - public PageResult getContractPage(ContractPageReqVO pageReqVO) { + public PageResult getContractPage(CrmContractPageReqVO pageReqVO) { return contractMapper.selectPage(pageReqVO); } @Override - public List getContractList(ContractExportReqVO exportReqVO) { - return contractMapper.selectList(exportReqVO); + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) + public PageResult getContractPageByCustomer(CrmContractPageReqVO pageReqVO) { + return contractMapper.selectPageByCustomer(pageReqVO); } @Override diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/package-info.java deleted file mode 100644 index 743f159b7..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 合同 - */ -package cn.iocoder.yudao.module.crm.service.contract; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java index 30523a095..1946c7ece 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java @@ -10,12 +10,12 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableP import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanPageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanUpdateReqVO; import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivablePlanConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivablePlanMapper; -import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; -import cn.iocoder.yudao.module.crm.service.contract.ContractService; +import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; +import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -40,7 +40,7 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { @Resource private CrmReceivablePlanMapper crmReceivablePlanMapper; @Resource - private ContractService contractService; + private CrmContractService contractService; @Resource private CrmCustomerService crmCustomerService; @@ -52,7 +52,7 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { receivablePlan.setStatus(CommonStatusEnum.ENABLE.getStatus()); } if (ObjectUtil.isNull(receivablePlan.getCheckStatus())){ - receivablePlan.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue()); + receivablePlan.setCheckStatus(CrmAuditStatusEnum.DRAFT.getStatus()); } checkReceivablePlan(receivablePlan); @@ -68,7 +68,7 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { throw exception(CONTRACT_NOT_EXISTS); } - ContractDO contract = contractService.getContract(receivablePlan.getContractId()); + CrmContractDO contract = contractService.getContract(receivablePlan.getContractId()); if(ObjectUtil.isNull(contract)){ throw exception(CONTRACT_NOT_EXISTS); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java index 08d97d8fe..b1b9d3ede 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java @@ -10,13 +10,13 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableE import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableUpdateReqVO; import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivableConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivableMapper; -import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; -import cn.iocoder.yudao.module.crm.service.contract.ContractService; +import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; +import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -41,7 +41,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { @Resource private CrmReceivableMapper crmReceivableMapper; @Resource - private ContractService contractService; + private CrmContractService contractService; @Resource private CrmCustomerService crmCustomerService; @Resource @@ -57,7 +57,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { receivable.setStatus(CommonStatusEnum.ENABLE.getStatus()); } if (ObjectUtil.isNull(receivable.getCheckStatus())){ - receivable.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue()); + receivable.setCheckStatus(CrmAuditStatusEnum.DRAFT.getStatus()); } // TODO @liuhongfeng:一般来说,逻辑的写法,是要先检查,后操作 db;所以,你这个 check 应该放到 CrmReceivableDO receivable 之前; @@ -75,7 +75,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { throw exception(CONTRACT_NOT_EXISTS); } - ContractDO contract = contractService.getContract(receivable.getContractId()); + CrmContractDO contract = contractService.getContract(receivable.getContractId()); if(ObjectUtil.isNull(contract)){ throw exception(CONTRACT_NOT_EXISTS); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java index 1406b5916..2e80a6955 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java @@ -2,12 +2,12 @@ package cn.iocoder.yudao.module.crm.service.contract; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractCreateReqVO; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractUpdateReqVO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; -import cn.iocoder.yudao.module.crm.dal.mysql.contract.ContractMapper; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; +import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Import; @@ -26,54 +26,54 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_ import static org.junit.jupiter.api.Assertions.*; /** - * {@link ContractServiceImpl} 的单元测试类 + * {@link CrmContractServiceImpl} 的单元测试类 * * @author dhb52 */ -@Import(ContractServiceImpl.class) +@Import(CrmContractServiceImpl.class) public class ContractServiceImplTest extends BaseDbUnitTest { @Resource - private ContractServiceImpl contractService; + private CrmContractServiceImpl contractService; @Resource - private ContractMapper contractMapper; + private CrmContractMapper contractMapper; @Test public void testCreateContract_success() { // 准备参数 - ContractCreateReqVO reqVO = randomPojo(ContractCreateReqVO.class); + CrmContractCreateReqVO reqVO = randomPojo(CrmContractCreateReqVO.class); // 调用 Long contractId = contractService.createContract(reqVO, getLoginUserId()); // 断言 assertNotNull(contractId); // 校验记录的属性是否正确 - ContractDO contract = contractMapper.selectById(contractId); + CrmContractDO contract = contractMapper.selectById(contractId); assertPojoEquals(reqVO, contract); } @Test public void testUpdateContract_success() { // mock 数据 - ContractDO dbContract = randomPojo(ContractDO.class); + CrmContractDO dbContract = randomPojo(CrmContractDO.class); contractMapper.insert(dbContract);// @Sql: 先插入出一条存在的数据 // 准备参数 - ContractUpdateReqVO reqVO = randomPojo(ContractUpdateReqVO.class, o -> { + CrmContractUpdateReqVO reqVO = randomPojo(CrmContractUpdateReqVO.class, o -> { o.setId(dbContract.getId()); // 设置更新的 ID }); // 调用 contractService.updateContract(reqVO); // 校验是否更新正确 - ContractDO contract = contractMapper.selectById(reqVO.getId()); // 获取最新的 + CrmContractDO contract = contractMapper.selectById(reqVO.getId()); // 获取最新的 assertPojoEquals(reqVO, contract); } @Test public void testUpdateContract_notExists() { // 准备参数 - ContractUpdateReqVO reqVO = randomPojo(ContractUpdateReqVO.class); + CrmContractUpdateReqVO reqVO = randomPojo(CrmContractUpdateReqVO.class); // 调用, 并断言异常 assertServiceException(() -> contractService.updateContract(reqVO), CONTRACT_NOT_EXISTS); @@ -82,7 +82,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest { @Test public void testDeleteContract_success() { // mock 数据 - ContractDO dbContract = randomPojo(ContractDO.class); + CrmContractDO dbContract = randomPojo(CrmContractDO.class); contractMapper.insert(dbContract);// @Sql: 先插入出一条存在的数据 // 准备参数 Long id = dbContract.getId(); @@ -106,7 +106,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest { @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 public void testGetContractPage() { // mock 数据 - ContractDO dbContract = randomPojo(ContractDO.class, o -> { // 等会查询到 + CrmContractDO dbContract = randomPojo(CrmContractDO.class, o -> { // 等会查询到 o.setName(null); o.setCustomerId(null); o.setBusinessId(null); @@ -131,7 +131,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest { // 测试 productPrice 不匹配 contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setProductPrice(null))); // 准备参数 - ContractPageReqVO reqVO = new ContractPageReqVO(); + CrmContractPageReqVO reqVO = new CrmContractPageReqVO(); reqVO.setName(null); reqVO.setCustomerId(null); reqVO.setBusinessId(null); @@ -141,7 +141,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest { reqVO.setProductPrice(null); // 调用 - PageResult pageResult = contractService.getContractPage(reqVO); + PageResult pageResult = contractService.getContractPage(reqVO); // 断言 assertEquals(1, pageResult.getTotal()); assertEquals(1, pageResult.getList().size()); @@ -152,7 +152,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest { @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 public void testGetContractList() { // mock 数据 - ContractDO dbContract = randomPojo(ContractDO.class, o -> { // 等会查询到 + CrmContractDO dbContract = randomPojo(CrmContractDO.class, o -> { // 等会查询到 o.setName("合同名称"); o.setCustomerId(null); o.setBusinessId(null); @@ -187,7 +187,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest { reqVO.setProductPrice(null); // 调用 - List list = contractService.getContractList(reqVO); + List list = contractService.getContractList(reqVO); // 断言 assertEquals(1, list.size()); assertPojoEquals(dbContract, list.get(0));