From 599d13b1ac54968e4d26a3e8e811bbf6f67987aa Mon Sep 17 00:00:00 2001 From: youkehai <717407966@qq.com> Date: Tue, 10 Oct 2023 11:36:24 +0800 Subject: [PATCH 001/101] =?UTF-8?q?feat:=20=E9=9A=8F=E4=BE=BF=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/iocoder/yudao/framework/common/package-info.java | 1 + 1 file changed, 1 insertion(+) diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/package-info.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/package-info.java index f3f2574e5..09c43f748 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/package-info.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/package-info.java @@ -1,6 +1,7 @@ /** * 基础的通用类,和框架无关 * + * sdadsdsd * 例如说,CommonResult 为通用返回 */ package cn.iocoder.yudao.framework.common; From 7e312aae027efd02b2e83d8429c13ac2a159520b Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 15 Oct 2023 20:16:46 +0800 Subject: [PATCH 002/101] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=20crm=20?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 1 + .../enums/ServiceErrorCodeRange.java | 5 +- yudao-module-crm/pom.xml | 25 +++++++++ yudao-module-crm/yudao-module-crm-api/pom.xml | 33 +++++++++++ .../yudao/module/crm/api/package-info.java | 4 ++ .../module/crm/enums/ErrorCodeConstants.java | 12 ++++ yudao-module-crm/yudao-module-crm-biz/pom.xml | 55 +++++++++++++++++++ .../yudao/module/crm/api/package-info.java | 4 ++ .../admin/business/package-info.java | 4 ++ .../controller/admin/clue/package-info.java | 4 ++ .../admin/contact/package-info.java | 4 ++ .../admin/contract/package-info.java | 4 ++ .../admin/customer/CrmCustomerController.http | 4 ++ .../admin/customer/CrmCustomerController.java | 23 ++++++++ .../admin/product/package-info.java | 4 ++ .../admin/receivable/package-info.java | 4 ++ .../crm/controller/app/package-info.java | 4 ++ .../module/crm/controller/package-info.java | 6 ++ .../module/crm/convert/package-info.java | 6 ++ ...道 Spring Boot 对象转换 MapStruct 入门》.md | 1 + .../dal/dataobject/business/package-info.java | 4 ++ .../crm/dal/dataobject/clue/package-info.java | 4 ++ .../dal/dataobject/contact/package-info.java | 4 ++ .../dal/dataobject/contract/package-info.java | 4 ++ .../dal/dataobject/customer/package-info.java | 4 ++ .../dal/dataobject/product/package-info.java | 4 ++ .../dataobject/receivable/package-info.java | 4 ++ .../crm/dal/mysql/business/package-info.java | 4 ++ .../crm/dal/mysql/clue/package-info.java | 4 ++ .../crm/dal/mysql/contact/package-info.java | 4 ++ .../crm/dal/mysql/contract/package-info.java | 4 ++ .../crm/dal/mysql/customer/package-info.java | 4 ++ .../crm/dal/mysql/product/package-info.java | 4 ++ .../dal/mysql/receivable/package-info.java | 4 ++ .../module/crm/framework/package-info.java | 6 ++ .../yudao/module/crm/package-info.java | 10 ++++ .../crm/service/business/package-info.java | 4 ++ .../module/crm/service/clue/package-info.java | 4 ++ .../crm/service/contact/package-info.java | 4 ++ .../crm/service/contract/package-info.java | 4 ++ .../crm/service/customer/package-info.java | 4 ++ .../crm/service/product/package-info.java | 4 ++ .../crm/service/receivable/package-info.java | 4 ++ yudao-server/pom.xml | 7 +++ 44 files changed, 313 insertions(+), 1 deletion(-) create mode 100644 yudao-module-crm/pom.xml create mode 100644 yudao-module-crm/yudao-module-crm-api/pom.xml create mode 100644 yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/pom.xml create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.http create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/app/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/package-info.java diff --git a/pom.xml b/pom.xml index f0d7064c7..45f82f2b4 100644 --- a/pom.xml +++ b/pom.xml @@ -21,6 +21,7 @@ + yudao-module-crm yudao-example diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/ServiceErrorCodeRange.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/ServiceErrorCodeRange.java index be22815eb..94dd67c9e 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/ServiceErrorCodeRange.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/ServiceErrorCodeRange.java @@ -35,9 +35,12 @@ public class ServiceErrorCodeRange { // 模块 member 错误码区间 [1-004-000-000 ~ 1-005-000-000) // 模块 mp 错误码区间 [1-006-000-000 ~ 1-007-000-000) // 模块 pay 错误码区间 [1-007-000-000 ~ 1-008-000-000) - // 模块 product 错误码区间 [1-008-000-000 ~ 1-009-000-000) // 模块 bpm 错误码区间 [1-009-000-000 ~ 1-010-000-000) + + // 模块 product 错误码区间 [1-008-000-000 ~ 1-009-000-000) // 模块 trade 错误码区间 [1-011-000-000 ~ 1-012-000-000) // 模块 promotion 错误码区间 [1-013-000-000 ~ 1-014-000-000) + // 模块 crm 错误码区间 [1-020-000-000 ~ 1-021-000-000) + } diff --git a/yudao-module-crm/pom.xml b/yudao-module-crm/pom.xml new file mode 100644 index 000000000..2a7b748c3 --- /dev/null +++ b/yudao-module-crm/pom.xml @@ -0,0 +1,25 @@ + + + + cn.iocoder.boot + yudao + ${revision} + + + yudao-module-crm-api + yudao-module-crm-biz + + 4.0.0 + yudao-module-crm + pom + + ${project.artifactId} + + + crm 包下,客户关系管理(Customer Relationship Management)。 + 例如说:客户、联系人、商机、合同、回款等等 + + + diff --git a/yudao-module-crm/yudao-module-crm-api/pom.xml b/yudao-module-crm/yudao-module-crm-api/pom.xml new file mode 100644 index 000000000..94e129626 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-api/pom.xml @@ -0,0 +1,33 @@ + + + + cn.iocoder.boot + yudao-module-crm + ${revision} + + 4.0.0 + yudao-module-crm-api + jar + + ${project.artifactId} + + crm 模块 API,暴露给其它模块调用 + + + + + cn.iocoder.boot + yudao-common + + + + + org.springframework.boot + spring-boot-starter-validation + true + + + + diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java new file mode 100644 index 000000000..c38bde7f5 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java @@ -0,0 +1,4 @@ +/** + * crm API 包,定义暴露给其它模块的 API + */ +package cn.iocoder.yudao.module.crm.api; diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java new file mode 100644 index 000000000..b59eae2bd --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -0,0 +1,12 @@ +package cn.iocoder.yudao.module.crm.enums; + +/** + * CRM 错误码枚举类 + *

+ * crm 系统,使用 1-020-000-000 段 + */ +public interface ErrorCodeConstants { + + + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/pom.xml b/yudao-module-crm/yudao-module-crm-biz/pom.xml new file mode 100644 index 000000000..dc2818da9 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/pom.xml @@ -0,0 +1,55 @@ + + + + cn.iocoder.boot + yudao-module-crm + ${revision} + + 4.0.0 + yudao-module-crm-biz + + ${project.artifactId} + + crm 包下,客户关系管理(Customer Relationship Management)。 + 例如说:客户、联系人、商机、合同、回款等等 + + + + + cn.iocoder.boot + yudao-module-system-api + ${revision} + + + + + cn.iocoder.boot + yudao-spring-boot-starter-biz-operatelog + + + + + cn.iocoder.boot + yudao-spring-boot-starter-web + + + + cn.iocoder.boot + yudao-spring-boot-starter-security + + + + + cn.iocoder.boot + yudao-spring-boot-starter-mybatis + + + + + cn.iocoder.boot + yudao-spring-boot-starter-test + + + diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java new file mode 100644 index 000000000..5c4e2493e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/api/package-info.java @@ -0,0 +1,4 @@ +/** + * crm API 实现类,定义暴露给其它模块的 API + */ +package cn.iocoder.yudao.module.crm.api; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/package-info.java new file mode 100644 index 000000000..07dec89b1 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/package-info.java @@ -0,0 +1,4 @@ +/** + * 商机(销售机会) + */ +package cn.iocoder.yudao.module.crm.controller.admin.business; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/package-info.java new file mode 100644 index 000000000..0dc110844 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/package-info.java @@ -0,0 +1,4 @@ +/** + * 线索 + */ +package cn.iocoder.yudao.module.crm.controller.admin.clue; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/package-info.java new file mode 100644 index 000000000..9b4afafef --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/package-info.java @@ -0,0 +1,4 @@ +/** + * 联系人 + */ +package cn.iocoder.yudao.module.crm.controller.admin.contact; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/package-info.java new file mode 100644 index 000000000..b2f4b7b4a --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/package-info.java @@ -0,0 +1,4 @@ +/** + * 合同 + */ +package cn.iocoder.yudao.module.crm.controller.admin.contract; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.http b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.http new file mode 100644 index 000000000..1dfa2c691 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.http @@ -0,0 +1,4 @@ +### 请求 /crm/customer/test 接口 => 成功 +GET {{baseUrl}}/crm/customer/test +tenant-id: 1 +Authorization: Bearer {{token}} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java new file mode 100644 index 000000000..b5aee837e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.module.crm.controller.admin.customer; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 客户信息") +@RestController +@RequestMapping("/crm/customer") +@Validated +public class CrmCustomerController { + + @GetMapping("/test") + public CommonResult test() { + return success("hello"); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/package-info.java new file mode 100644 index 000000000..6500da0b8 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/package-info.java @@ -0,0 +1,4 @@ +/** + * 产品表 + */ +package cn.iocoder.yudao.module.crm.controller.admin.product; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/package-info.java new file mode 100644 index 000000000..199398287 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/package-info.java @@ -0,0 +1,4 @@ +/** + * 回款 + */ +package cn.iocoder.yudao.module.crm.controller.admin.receivable; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/app/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/app/package-info.java new file mode 100644 index 000000000..78d85635c --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/app/package-info.java @@ -0,0 +1,4 @@ +/** + * 占位 + */ +package cn.iocoder.yudao.module.crm.controller.app; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/package-info.java new file mode 100644 index 000000000..8354b3176 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/package-info.java @@ -0,0 +1,6 @@ +/** + * 提供 RESTful API 给前端: + * 1. admin 包:提供给管理后台 yudao-ui-admin 前端项目 + * 2. app 包:提供给用户 APP yudao-ui-app 前端项目,它的 Controller 和 VO 都要添加 App 前缀,用于和管理后台进行区分 + */ +package cn.iocoder.yudao.module.crm.controller; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/package-info.java new file mode 100644 index 000000000..6fbc52508 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/package-info.java @@ -0,0 +1,6 @@ +/** + * 提供 POJO 类的实体转换 + * + * 目前使用 MapStruct 框架 + */ +package cn.iocoder.yudao.module.crm.convert; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md new file mode 100644 index 000000000..8153487b7 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/《芋道 Spring Boot 对象转换 MapStruct 入门》.md @@ -0,0 +1 @@ + diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/package-info.java new file mode 100644 index 000000000..df6e44536 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/package-info.java @@ -0,0 +1,4 @@ +/** + * 商机(销售机会) + */ +package cn.iocoder.yudao.module.crm.dal.dataobject.business; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/package-info.java new file mode 100644 index 000000000..929b9b6fe --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/package-info.java @@ -0,0 +1,4 @@ +/** + * 线索 + */ +package cn.iocoder.yudao.module.crm.dal.dataobject.clue; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/package-info.java new file mode 100644 index 000000000..dfe0898e3 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/package-info.java @@ -0,0 +1,4 @@ +/** + * 联系人 + */ +package cn.iocoder.yudao.module.crm.dal.dataobject.contact; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/package-info.java new file mode 100644 index 000000000..a981b5dfc --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/package-info.java @@ -0,0 +1,4 @@ +/** + * 合同 + */ +package cn.iocoder.yudao.module.crm.dal.dataobject.contract; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/package-info.java new file mode 100644 index 000000000..78e98bcd9 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/package-info.java @@ -0,0 +1,4 @@ +/** + * 客户 + */ +package cn.iocoder.yudao.module.crm.dal.dataobject.customer; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/package-info.java new file mode 100644 index 000000000..4c7282d73 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/product/package-info.java @@ -0,0 +1,4 @@ +/** + * 产品表 + */ +package cn.iocoder.yudao.module.crm.dal.dataobject.product; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/package-info.java new file mode 100644 index 000000000..f27442cdf --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/package-info.java @@ -0,0 +1,4 @@ +/** + * 回款 + */ +package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/package-info.java new file mode 100644 index 000000000..72863e1f4 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/package-info.java @@ -0,0 +1,4 @@ +/** + * 商机(销售机会) + */ +package cn.iocoder.yudao.module.crm.dal.mysql.business; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/package-info.java new file mode 100644 index 000000000..f9978e868 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/package-info.java @@ -0,0 +1,4 @@ +/** + * 线索 + */ +package cn.iocoder.yudao.module.crm.dal.mysql.clue; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/package-info.java new file mode 100644 index 000000000..6cb7d4be2 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/package-info.java @@ -0,0 +1,4 @@ +/** + * 联系人 + */ +package cn.iocoder.yudao.module.crm.dal.mysql.contact; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/package-info.java new file mode 100644 index 000000000..fb8045878 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/package-info.java @@ -0,0 +1,4 @@ +/** + * 合同 + */ +package cn.iocoder.yudao.module.crm.dal.mysql.contract; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/package-info.java new file mode 100644 index 000000000..4173c0180 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/package-info.java @@ -0,0 +1,4 @@ +/** + * 客户 + */ +package cn.iocoder.yudao.module.crm.dal.mysql.customer; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/package-info.java new file mode 100644 index 000000000..be0fa00a9 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/product/package-info.java @@ -0,0 +1,4 @@ +/** + * 产品表 + */ +package cn.iocoder.yudao.module.crm.dal.mysql.product; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/package-info.java new file mode 100644 index 000000000..65b30aa92 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/package-info.java @@ -0,0 +1,4 @@ +/** + * 回款 + */ +package cn.iocoder.yudao.module.crm.dal.mysql.receivable; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/package-info.java new file mode 100644 index 000000000..281e36c45 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/package-info.java @@ -0,0 +1,6 @@ +/** + * 属于 crm 模块的 framework 封装 + * + * @author 芋道源码 + */ +package cn.iocoder.yudao.module.crm.framework; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/package-info.java new file mode 100644 index 000000000..2ea5f9f41 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/package-info.java @@ -0,0 +1,10 @@ +/** + * crm 包下,客户关系管理(Customer Relationship Management)。 + * 例如说:客户、联系人、商机、合同、回款等等 + * + * 1. Controller URL:以 /crm/ 开头,避免和其它 Module 冲突 + * 2. DataObject 表名:以 crm_ 开头,方便在数据库中区分 + * + * 注意,由于 Crm 模块下,容易和其它模块重名,所以类名都加载 Crm 的前缀~ + */ +package cn.iocoder.yudao.module.crm; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/package-info.java new file mode 100644 index 000000000..8995e1242 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/package-info.java @@ -0,0 +1,4 @@ +/** + * 商机(销售机会) + */ +package cn.iocoder.yudao.module.crm.service.business; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/package-info.java new file mode 100644 index 000000000..5cb8b6ec7 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/package-info.java @@ -0,0 +1,4 @@ +/** + * 线索 + */ +package cn.iocoder.yudao.module.crm.service.clue; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/package-info.java new file mode 100644 index 000000000..e72077dd7 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/package-info.java @@ -0,0 +1,4 @@ +/** + * 联系人 + */ +package cn.iocoder.yudao.module.crm.service.contact; 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 new file mode 100644 index 000000000..743f159b7 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/package-info.java @@ -0,0 +1,4 @@ +/** + * 合同 + */ +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/customer/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/package-info.java new file mode 100644 index 000000000..1ae12a3df --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/package-info.java @@ -0,0 +1,4 @@ +/** + * 客户 + */ +package cn.iocoder.yudao.module.crm.service.customer; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/package-info.java new file mode 100644 index 000000000..cae179aea --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/package-info.java @@ -0,0 +1,4 @@ +/** + * 产品表 + */ +package cn.iocoder.yudao.module.crm.service.product; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/package-info.java new file mode 100644 index 000000000..4004b301d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/package-info.java @@ -0,0 +1,4 @@ +/** + * 回款 + */ +package cn.iocoder.yudao.module.crm.service.receivable; diff --git a/yudao-server/pom.xml b/yudao-server/pom.xml index 5f0d12f33..2b7742246 100644 --- a/yudao-server/pom.xml +++ b/yudao-server/pom.xml @@ -91,6 +91,13 @@ + + + cn.iocoder.boot + yudao-module-crm-biz + ${revision} + + org.springframework.boot From e26bd20a5b121f729cc42e5aa6168806a73f394f Mon Sep 17 00:00:00 2001 From: dhb52 Date: Mon, 16 Oct 2023 23:45:18 +0800 Subject: [PATCH 003/101] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E9=85=8D=E7=BD=AE=E5=8F=8Aexcel=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-module-crm/yudao-module-crm-biz/pom.xml | 15 +++++- .../test/resources/application-unit-test.yaml | 50 +++++++++++++++++++ .../src/test/resources/logback.xml | 4 ++ 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/test/resources/logback.xml diff --git a/yudao-module-crm/yudao-module-crm-biz/pom.xml b/yudao-module-crm/yudao-module-crm-biz/pom.xml index dc2818da9..5bedf5eac 100644 --- a/yudao-module-crm/yudao-module-crm-biz/pom.xml +++ b/yudao-module-crm/yudao-module-crm-biz/pom.xml @@ -1,6 +1,6 @@ - cn.iocoder.boot @@ -22,6 +22,11 @@ yudao-module-system-api ${revision} + + cn.iocoder.boot + yudao-module-crm-api + ${revision} + @@ -46,6 +51,12 @@ yudao-spring-boot-starter-mybatis + + + cn.iocoder.boot + yudao-spring-boot-starter-excel + + cn.iocoder.boot diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml new file mode 100644 index 000000000..767f2526f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/application-unit-test.yaml @@ -0,0 +1,50 @@ +spring: + main: + lazy-initialization: true # 开启懒加载,加快速度 + banner-mode: off # 单元测试,禁用 Banner + +--- #################### 数据库相关配置 #################### + +spring: + # 数据源配置项 + datasource: + name: ruoyi-vue-pro + url: jdbc:h2:mem:testdb;MODE=MYSQL;DATABASE_TO_UPPER=false;NON_KEYWORDS=value; # MODE 使用 MySQL 模式;DATABASE_TO_UPPER 配置表和字段使用小写 + driver-class-name: org.h2.Driver + username: sa + password: + druid: + async-init: true # 单元测试,异步初始化 Druid 连接池,提升启动速度 + initial-size: 1 # 单元测试,配置为 1,提升启动速度 + sql: + init: + schema-locations: classpath:/sql/create_tables.sql + + # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 + redis: + host: 127.0.0.1 # 地址 + port: 16379 # 端口(单元测试,使用 16379 端口) + database: 0 # 数据库索引 + +mybatis-plus: + lazy-initialization: true # 单元测试,设置 MyBatis Mapper 延迟加载,加速每个单元测试 + type-aliases-package: ${yudao.info.base-package}.module.*.dal.dataobject + +--- #################### 定时任务相关配置 #################### + +--- #################### 配置中心相关配置 #################### + +--- #################### 服务保障相关配置 #################### + +# Lock4j 配置项(单元测试,禁用 Lock4j) + +# Resilience4j 配置项 + +--- #################### 监控相关配置 #################### + +--- #################### 芋道相关配置 #################### + +# 芋道配置项,设置当前项目所有自定义的配置 +yudao: + info: + base-package: cn.iocoder.yudao diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/logback.xml b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/logback.xml new file mode 100644 index 000000000..1d071e479 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/logback.xml @@ -0,0 +1,4 @@ + + + + From eedb528412f5c790250d55663d88689821c52d3a Mon Sep 17 00:00:00 2001 From: dhb52 Date: Mon, 16 Oct 2023 23:53:17 +0800 Subject: [PATCH 004/101] =?UTF-8?q?feat:=20CRM/=E5=90=88=E5=90=8C=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20-=20crud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/ErrorCodeConstants.java | 5 +- .../admin/contact/package-info.java | 4 - .../admin/contract/ContractController.java | 99 +++++++++ .../admin/contract/vo/ContractBaseVO.java | 72 +++++++ .../contract/vo/ContractCreateReqVO.java | 20 ++ .../admin/contract/vo/ContractExcelVO.java | 70 +++++++ .../contract/vo/ContractExportReqVO.java | 37 ++++ .../admin/contract/vo/ContractPageReqVO.java | 42 ++++ .../admin/contract/vo/ContractRespVO.java | 22 ++ .../contract/vo/ContractUpdateReqVO.java | 26 +++ .../crm/convert/contract/ContractConvert.java | 36 ++++ .../dal/dataobject/contract/ContractDO.java | 104 ++++++++++ .../dal/mysql/contract/ContractMapper.java | 45 ++++ .../crm/service/contract/ContractService.java | 75 +++++++ .../service/contract/ContractServiceImpl.java | 90 ++++++++ .../contract/ContractServiceImplTest.java | 195 ++++++++++++++++++ 16 files changed, 937 insertions(+), 5 deletions(-) delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/ContractController.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractBaseVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractCreateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractExcelVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractExportReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractPageReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractUpdateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/ContractConvert.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/ContractDO.java create 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/service/contract/ContractService.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImpl.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index b59eae2bd..532533d6c 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.crm.enums; +import cn.iocoder.yudao.framework.common.exception.ErrorCode; + /** * CRM 错误码枚举类 *

@@ -7,6 +9,7 @@ package cn.iocoder.yudao.module.crm.enums; */ public interface ErrorCodeConstants { - + // ========== 合同管理 1-020-000-000 ========== + ErrorCode CONTRACT_NOT_EXISTS = new ErrorCode(1_020_000_000, "合同不存在"); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/package-info.java deleted file mode 100644 index 9b4afafef..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 联系人 - */ -package cn.iocoder.yudao.module.crm.controller.admin.contact; 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/ContractController.java new file mode 100644 index 000000000..3bc52c038 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/ContractController.java @@ -0,0 +1,99 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contract; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +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 io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; + +@Tag(name = "管理后台 - 合同") +@RestController +@RequestMapping("/crm/contract") +@Validated +public class ContractController { + + @Resource + private ContractService contractService; + + @PostMapping("/create") + @Operation(summary = "创建合同") + @PreAuthorize("@ss.hasPermission('crm:contract:create')") + public CommonResult createContract(@Valid @RequestBody ContractCreateReqVO createReqVO) { + return success(contractService.createContract(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新合同") + @PreAuthorize("@ss.hasPermission('crm:contract:update')") + public CommonResult updateContract(@Valid @RequestBody ContractUpdateReqVO updateReqVO) { + contractService.updateContract(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除合同") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('crm:contract:delete')") + public CommonResult deleteContract(@RequestParam("id") Long id) { + contractService.deleteContract(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得合同") + @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); + return success(ContractConvert.INSTANCE.convert(contract)); + } + + @GetMapping("/list") + @Operation(summary = "获得合同列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('crm:contract:query')") + public CommonResult> getContractList(@RequestParam("ids") Collection ids) { + List list = contractService.getContractList(ids); + return success(ContractConvert.INSTANCE.convertList(list)); + } + + @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)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出合同 Excel") + @PreAuthorize("@ss.hasPermission('crm:contract:export')") + @OperateLog(type = EXPORT) + public void exportContractExcel(@Valid ContractExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = contractService.getContractList(exportReqVO); + // 导出 Excel + List datas = ContractConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "合同.xls", "数据", ContractExcelVO.class, datas); + } + +} 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/ContractBaseVO.java new file mode 100644 index 000000000..ad43604a1 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractBaseVO.java @@ -0,0 +1,72 @@ +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 javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * 合同 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class ContractBaseVO { + + @Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") + @NotNull(message = "合同名称不能为空") + private String name; + + @Schema(description = "客户编号", example = "18336") + private Long customerId; + + @Schema(description = "商机编号", example = "10864") + private Long businessId; + + @Schema(description = "工作流编号", example = "1043") + private Long processInstanceId; + + @Schema(description = "下单日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime orderDate; + + @Schema(description = "负责人的用户编号", example = "17144") + private Long ownerUserId; + + @Schema(description = "合同编号") + private String no; + + @Schema(description = "开始时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime startTime; + + @Schema(description = "结束时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime endTime; + + @Schema(description = "合同金额", example = "5617") + private Integer price; + + @Schema(description = "整单折扣") + private Integer discountPercent; + + @Schema(description = "产品总金额", example = "19510") + private Integer productPrice; + + @Schema(description = "联系人编号", example = "18546") + private Long contactId; + + @Schema(description = "公司签约人", example = "14036") + private Long signUserId; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime contactLastTime; + + @Schema(description = "备注", example = "你猜") + private String remark; + +} 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/ContractCreateReqVO.java new file mode 100644 index 000000000..38c95d23f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractCreateReqVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - 合同创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ContractCreateReqVO extends ContractBaseVO { + + @Schema(description = "只读权限的用户编号数组") + private String roUserIds; + + @Schema(description = "读写权限的用户编号数组") + private String rwUserIds; + +} 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/ContractExcelVO.java new file mode 100644 index 000000000..895ac821a --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractExcelVO.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * 合同 Excel VO + * + * @author dhb52 + */ +@Data +public class ContractExcelVO { + + @ExcelProperty("合同编号") + private Long id; + + @ExcelProperty("合同名称") + private String name; + + @ExcelProperty("客户编号") + private Long customerId; + + @ExcelProperty("商机编号") + private Long businessId; + + @ExcelProperty("工作流编号") + private Long processInstanceId; + + @ExcelProperty("下单日期") + private LocalDateTime orderDate; + + @ExcelProperty("负责人的用户编号") + private Long ownerUserId; + + @ExcelProperty("合同编号") + private String no; + + @ExcelProperty("开始时间") + private LocalDateTime startTime; + + @ExcelProperty("结束时间") + private LocalDateTime endTime; + + @ExcelProperty("合同金额") + private Integer price; + + @ExcelProperty("整单折扣") + private Integer discountPercent; + + @ExcelProperty("产品总金额") + private Integer productPrice; + + @ExcelProperty("联系人编号") + private Long contactId; + + @ExcelProperty("公司签约人") + private Long signUserId; + + @ExcelProperty("最后跟进时间") + private LocalDateTime contactLastTime; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} 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 new file mode 100644 index 000000000..8de3b4c1b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractExportReqVO.java @@ -0,0 +1,37 @@ +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 = "管理后台 - 合同 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/ContractPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractPageReqVO.java new file mode 100644 index 000000000..01562be1b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractPageReqVO.java @@ -0,0 +1,42 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +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 = "管理后台 - 合同分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ContractPageReqVO extends PageParam { + + @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 new file mode 100644 index 000000000..a0ab1d248 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractRespVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 合同 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ContractRespVO extends ContractBaseVO { + + @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + private Long id; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + +} 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/ContractUpdateReqVO.java new file mode 100644 index 000000000..f38ac7677 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/ContractUpdateReqVO.java @@ -0,0 +1,26 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 合同更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ContractUpdateReqVO extends ContractBaseVO { + + @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "合同编号不能为空") + private Long id; + + @Schema(description = "只读权限的用户编号数组") + private String roUserIds; + + @Schema(description = "读写权限的用户编号数组") + private String rwUserIds; + +} 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 new file mode 100644 index 000000000..906dd7562 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contract/ContractConvert.java @@ -0,0 +1,36 @@ +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.ContractCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractExcelVO; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractUpdateReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 合同 Convert + * + * @author dhb52 + */ +@Mapper +public interface ContractConvert { + + ContractConvert INSTANCE = Mappers.getMapper(ContractConvert.class); + + ContractDO convert(ContractCreateReqVO bean); + + ContractDO convert(ContractUpdateReqVO bean); + + ContractRespVO convert(ContractDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} 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/ContractDO.java new file mode 100644 index 000000000..8caa4d2cb --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contract/ContractDO.java @@ -0,0 +1,104 @@ +package cn.iocoder.yudao.module.crm.dal.dataobject.contract; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +import java.time.LocalDateTime; + +/** + * 合同 DO + * + * @author dhb52 + */ +@TableName("crm_contract") +@KeySequence("crm_contract_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ContractDO extends BaseDO { + + /** + * 合同编号 + */ + @TableId + private Long id; + /** + * 合同名称 + */ + private String name; + /** + * 客户编号 + */ + private Long customerId; + /** + * 商机编号 + */ + private Long businessId; + /** + * 工作流编号 + */ + private Long processInstanceId; + /** + * 下单日期 + */ + private LocalDateTime orderDate; + /** + * 负责人的用户编号 + */ + private Long ownerUserId; + /** + * 合同编号 + */ + private String no; + /** + * 开始时间 + */ + private LocalDateTime startTime; + /** + * 结束时间 + */ + private LocalDateTime endTime; + /** + * 合同金额 + */ + private Integer price; + /** + * 整单折扣 + */ + private Integer discountPercent; + /** + * 产品总金额 + */ + private Integer productPrice; + /** + * 只读权限的用户编号数组 + */ + private String roUserIds; + /** + * 读写权限的用户编号数组 + */ + private String rwUserIds; + /** + * 联系人编号 + */ + private Long contactId; + /** + * 公司签约人 + */ + private Long signUserId; + /** + * 最后跟进时间 + */ + private LocalDateTime contactLastTime; + /** + * 备注 + */ + private String remark; + +} 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 new file mode 100644 index 000000000..47337518b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/ContractMapper.java @@ -0,0 +1,45 @@ +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/service/contract/ContractService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/ContractService.java new file mode 100644 index 000000000..6d6c9fe9f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/ContractService.java @@ -0,0 +1,75 @@ +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.ContractCreateReqVO; +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 javax.validation.Valid; +import java.util.Collection; +import java.util.List; + +/** + * 合同 Service 接口 + * + * @author dhb52 + */ +public interface ContractService { + + /** + * 创建合同 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createContract(@Valid ContractCreateReqVO createReqVO); + + /** + * 更新合同 + * + * @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); + +} 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/ContractServiceImpl.java new file mode 100644 index 000000000..e840626b9 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImpl.java @@ -0,0 +1,90 @@ +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.ContractCreateReqVO; +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.convert.contract.ContractConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; +import cn.iocoder.yudao.module.crm.dal.mysql.contract.ContractMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS; + +/** + * 合同 Service 实现类 + * + * @author dhb52 + */ +@Service +@Validated +public class ContractServiceImpl implements ContractService { + + @Resource + private ContractMapper contractMapper; + + @Override + public Long createContract(ContractCreateReqVO createReqVO) { + // 插入 + ContractDO contract = ContractConvert.INSTANCE.convert(createReqVO); + contractMapper.insert(contract); + // 返回 + return contract.getId(); + } + + @Override + public void updateContract(ContractUpdateReqVO updateReqVO) { + // 校验存在 + validateContractExists(updateReqVO.getId()); + // 更新 + ContractDO updateObj = ContractConvert.INSTANCE.convert(updateReqVO); + contractMapper.updateById(updateObj); + } + + @Override + public void deleteContract(Long id) { + // 校验存在 + validateContractExists(id); + // 删除 + contractMapper.deleteById(id); + } + + private void validateContractExists(Long id) { + if (contractMapper.selectById(id) == null) { + throw exception(CONTRACT_NOT_EXISTS); + } + } + + @Override + public ContractDO getContract(Long id) { + return contractMapper.selectById(id); + } + + @Override + public List getContractList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return contractMapper.selectBatchIds(ids); + } + + @Override + public PageResult getContractPage(ContractPageReqVO pageReqVO) { + return contractMapper.selectPage(pageReqVO); + } + + @Override + public List getContractList(ContractExportReqVO exportReqVO) { + return contractMapper.selectList(exportReqVO); + } + +} 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 new file mode 100644 index 000000000..f9cbe3a38 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java @@ -0,0 +1,195 @@ +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.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 org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS; +import static org.junit.jupiter.api.Assertions.*; + +/** + * {@link ContractServiceImpl} 的单元测试类 + * + * @author dhb52 + */ +@Import(ContractServiceImpl.class) +public class ContractServiceImplTest extends BaseDbUnitTest { + + @Resource + private ContractServiceImpl contractService; + + @Resource + private ContractMapper contractMapper; + + @Test + public void testCreateContract_success() { + // 准备参数 + ContractCreateReqVO reqVO = randomPojo(ContractCreateReqVO.class); + + // 调用 + Long contractId = contractService.createContract(reqVO); + // 断言 + assertNotNull(contractId); + // 校验记录的属性是否正确 + ContractDO contract = contractMapper.selectById(contractId); + assertPojoEquals(reqVO, contract); + } + + @Test + public void testUpdateContract_success() { + // mock 数据 + ContractDO dbContract = randomPojo(ContractDO.class); + contractMapper.insert(dbContract);// @Sql: 先插入出一条存在的数据 + // 准备参数 + ContractUpdateReqVO reqVO = randomPojo(ContractUpdateReqVO.class, o -> { + o.setId(dbContract.getId()); // 设置更新的 ID + }); + + // 调用 + contractService.updateContract(reqVO); + // 校验是否更新正确 + ContractDO contract = contractMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, contract); + } + + @Test + public void testUpdateContract_notExists() { + // 准备参数 + ContractUpdateReqVO reqVO = randomPojo(ContractUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> contractService.updateContract(reqVO), CONTRACT_NOT_EXISTS); + } + + @Test + public void testDeleteContract_success() { + // mock 数据 + ContractDO dbContract = randomPojo(ContractDO.class); + contractMapper.insert(dbContract);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbContract.getId(); + + // 调用 + contractService.deleteContract(id); + // 校验数据不存在了 + assertNull(contractMapper.selectById(id)); + } + + @Test + public void testDeleteContract_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> contractService.deleteContract(id), CONTRACT_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetContractPage() { + // mock 数据 + ContractDO dbContract = randomPojo(ContractDO.class, o -> { // 等会查询到 + o.setName(null); + o.setCustomerId(null); + o.setBusinessId(null); + o.setOrderDate(null); + o.setNo(null); + o.setDiscountPercent(null); + o.setProductPrice(null); + }); + contractMapper.insert(dbContract); + // 测试 name 不匹配 + contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setName(null))); + // 测试 customerId 不匹配 + contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setCustomerId(null))); + // 测试 businessId 不匹配 + contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setBusinessId(null))); + // 测试 orderDate 不匹配 + contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setOrderDate(null))); + // 测试 no 不匹配 + contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setNo(null))); + // 测试 discountPercent 不匹配 + contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setDiscountPercent(null))); + // 测试 productPrice 不匹配 + contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setProductPrice(null))); + // 准备参数 + ContractPageReqVO reqVO = new ContractPageReqVO(); + reqVO.setName(null); + reqVO.setCustomerId(null); + reqVO.setBusinessId(null); + reqVO.setOrderDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setNo(null); + reqVO.setDiscountPercent(null); + reqVO.setProductPrice(null); + + // 调用 + PageResult pageResult = contractService.getContractPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbContract, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetContractList() { + // mock 数据 + ContractDO dbContract = randomPojo(ContractDO.class, o -> { // 等会查询到 + o.setName("合同名称"); + o.setCustomerId(null); + o.setBusinessId(null); + o.setOrderDate(null); + o.setNo(null); + o.setDiscountPercent(null); + o.setProductPrice(null); + }); + contractMapper.insert(dbContract); + // 测试 name 不匹配 + contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setName(null))); + // 测试 customerId 不匹配 + contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setCustomerId(null))); + // 测试 businessId 不匹配 + contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setBusinessId(null))); + // 测试 orderDate 不匹配 + contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setOrderDate(null))); + // 测试 no 不匹配 + contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setNo(null))); + // 测试 discountPercent 不匹配 + contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setDiscountPercent(null))); + // 测试 productPrice 不匹配 + contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setProductPrice(null))); + // 准备参数 + ContractExportReqVO reqVO = new ContractExportReqVO(); + reqVO.setName(null); + reqVO.setCustomerId(null); + reqVO.setBusinessId(null); + reqVO.setOrderDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setNo(null); + reqVO.setDiscountPercent(null); + reqVO.setProductPrice(null); + + // 调用 + List list = contractService.getContractList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbContract, list.get(0)); + } + +} From 164be5732b4c022b61d42403019c899f8ecb2fbe Mon Sep 17 00:00:00 2001 From: dhb52 Date: Mon, 16 Oct 2023 23:53:27 +0800 Subject: [PATCH 005/101] =?UTF-8?q?feat:=20CRM/=E5=90=88=E5=90=8C=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20-=20SQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 39 ++++++++++++ sql/mysql/crm_menu.sql | 63 +++++++++++++++++++ .../src/test/resources/sql/clean.sql | 1 + .../src/test/resources/sql/create_tables.sql | 27 ++++++++ 4 files changed, 130 insertions(+) create mode 100644 sql/mysql/crm.sql create mode 100644 sql/mysql/crm_menu.sql create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql new file mode 100644 index 000000000..eeb2d12ac --- /dev/null +++ b/sql/mysql/crm.sql @@ -0,0 +1,39 @@ +SET NAMES utf8mb4; + +-- ---------------------------- +-- 合同表 +-- ---------------------------- +DROP TABLE IF EXISTS `crm_contract`; +CREATE TABLE `crm_contract` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,主键自增', + `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '合同名称', + `customer_id` bigint DEFAULT NULL COMMENT '客户编号', + `business_id` bigint DEFAULT NULL COMMENT '商机编号', + `process_instance_id` bigint DEFAULT NULL COMMENT '工作流编号', + `order_date` datetime DEFAULT NULL COMMENT '下单日期', + `owner_user_id` bigint DEFAULT NULL COMMENT '负责人的用户编号', + `no` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '合同编号', + `start_time` datetime DEFAULT NULL COMMENT '开始时间', + `end_time` datetime DEFAULT NULL COMMENT '结束时间', + `price` int DEFAULT NULL COMMENT '合同金额', + `discount_percent` int DEFAULT NULL COMMENT '整单折扣', + `product_price` int DEFAULT NULL COMMENT '产品总金额', + `ro_user_ids` varchar(4096) DEFAULT NULL COMMENT '只读权限的用户编号数组', + `rw_user_ids` varchar(4096) DEFAULT NULL COMMENT '读写权限的用户编号数组', + `contact_id` bigint DEFAULT NULL COMMENT '联系人编号', + `sign_user_id` bigint DEFAULT NULL COMMENT '公司签约人', + `contact_last_time` datetime DEFAULT NULL COMMENT '最后跟进时间', + + -- 通用字段 + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB + CHARACTER SET = utf8mb4 + COLLATE = utf8mb4_unicode_ci COMMENT ='合同表'; diff --git a/sql/mysql/crm_menu.sql b/sql/mysql/crm_menu.sql new file mode 100644 index 000000000..83e5ae29d --- /dev/null +++ b/sql/mysql/crm_menu.sql @@ -0,0 +1,63 @@ +-- ---------------------------- +-- 合同菜单 +-- ---------------------------- + +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '合同管理', '', 2, 0, 1254, + 'contract', '', 'crm/contract/index', 0, 'Contract' +); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '合同查询', 'crm:contract:query', 3, 1, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '合同创建', 'crm:contract:create', 3, 2, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '合同更新', 'crm:contract:update', 3, 3, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '合同删除', 'crm:contract:delete', 3, 4, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '合同导出', 'crm:contract:export', 3, 5, @parentId, + '', '', '', 0 +); + +-- ---------------------------- +-- ...菜单 +-- ---------------------------- \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql new file mode 100644 index 000000000..c45d2602e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql @@ -0,0 +1 @@ +DELETE FROM "crm_contract"; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql new file mode 100644 index 000000000..c25a80e44 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql @@ -0,0 +1,27 @@ +CREATE TABLE IF NOT EXISTS "crm_contract" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar NOT NULL, + "customer_id" bigint, + "business_id" bigint, + "process_instance_id" bigint, + "order_date" varchar, + "owner_user_id" bigint, + "no" varchar, + "start_time" varchar, + "end_time" varchar, + "price" int, + "discount_percent" int, + "product_price" int, + "ro_user_ids" varchar, + "rw_user_ids" varchar, + "contact_id" bigint, + "sign_user_id" bigint, + "contact_last_time" varchar, + "remark" varchar, + "creator" varchar DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") + ) COMMENT '合同表'; \ No newline at end of file From b133acd8cdd741ded5bce27225ba12fefc3f2da2 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 17 Oct 2023 22:52:14 +0800 Subject: [PATCH 006/101] =?UTF-8?q?code=20review=EF=BC=9Acrm=20=E5=90=88?= =?UTF-8?q?=E5=90=8C=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/contract/ContractController.java | 10 ---------- .../controller/admin/contract/vo/ContractBaseVO.java | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) 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/ContractController.java index 3bc52c038..fd8b14afd 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/ContractController.java @@ -19,7 +19,6 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; -import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -67,15 +66,6 @@ public class ContractController { return success(ContractConvert.INSTANCE.convert(contract)); } - @GetMapping("/list") - @Operation(summary = "获得合同列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('crm:contract:query')") - public CommonResult> getContractList(@RequestParam("ids") Collection ids) { - List list = contractService.getContractList(ids); - return success(ContractConvert.INSTANCE.convertList(list)); - } - @GetMapping("/page") @Operation(summary = "获得合同分页") @PreAuthorize("@ss.hasPermission('crm:contract:query')") 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/ContractBaseVO.java index ad43604a1..756ee0d1f 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/ContractBaseVO.java @@ -9,6 +9,7 @@ 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 文档生成 @@ -16,10 +17,13 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class ContractBaseVO { + // TODO @dhb52:类似 no 字段的 example 要写xia 哈; + @Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五") @NotNull(message = "合同名称不能为空") private String name; + // TODO @dhb52:这个必须传递 @Schema(description = "客户编号", example = "18336") private Long customerId; @@ -29,13 +33,17 @@ public class ContractBaseVO { @Schema(description = "工作流编号", example = "1043") private Long processInstanceId; + // TODO @dhb52:这个必须传递 @Schema(description = "下单日期") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime orderDate; + // TODO @dhb52:这个必须传递 @Schema(description = "负责人的用户编号", example = "17144") private Long ownerUserId; + // TODO @芋艿:未来应该支持自动生成; + // TODO @dhb52:这个必须传递; @Schema(description = "合同编号") private String no; @@ -69,4 +77,6 @@ public class ContractBaseVO { @Schema(description = "备注", example = "你猜") private String remark; + // TODO @dhb52:增加一个 status 字段:具体有哪些值,你来枚举下;主要页面上有个【草稿】【提交审核】的流程,可以看看。然后要对接工作流,这块也可以看看,不确定的地方问我。 + } From a09ee495b674411d312dce4e18b29360b6ec7e38 Mon Sep 17 00:00:00 2001 From: "913752709@qq.com" <913752709@qq.com> Date: Wed, 18 Oct 2023 19:53:15 +0800 Subject: [PATCH 007/101] =?UTF-8?q?feat:=20CRM=20=E7=BA=BF=E7=B4=A2?= =?UTF-8?q?=E8=A1=A8=20crud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 24 ++ sql/mysql/crm_menu.sql | 60 ++++- .../module/crm/enums/ErrorCodeConstants.java | 2 + .../admin/clue/CrmClueController.java | 102 ++++++++ .../admin/clue/vo/CrmClueBaseVO.java | 64 +++++ .../admin/clue/vo/CrmClueCreateReqVO.java | 14 ++ .../admin/clue/vo/CrmClueExcelVO.java | 65 +++++ .../admin/clue/vo/CrmClueExportReqVO.java | 52 ++++ .../admin/clue/vo/CrmCluePageReqVO.java | 54 ++++ .../admin/clue/vo/CrmClueRespVO.java | 19 ++ .../admin/clue/vo/CrmClueUpdateReqVO.java | 18 ++ .../crm/convert/clue/CrmClueConvert.java | 34 +++ .../crm/dal/dataobject/clue/CrmClueDO.java | 81 ++++++ .../crm/dal/mysql/clue/CrmClueMapper.java | 52 ++++ .../crm/service/clue/CrmClueService.java | 70 ++++++ .../crm/service/clue/CrmClueServiceImpl.java | 88 +++++++ .../resources/mapper/clue/CrmClueMapper.xml | 12 + .../service/clue/CrmClueServiceImplTest.java | 231 ++++++++++++++++++ .../src/test/resources/sql/clean.sql | 2 + .../src/test/resources/sql/create_tables.sql | 24 +- 20 files changed, 1065 insertions(+), 3 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueCreateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExcelVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExportReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/clue/CrmClueMapper.xml create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index eeb2d12ac..6c5594068 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -37,3 +37,27 @@ CREATE TABLE `crm_contract` ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT ='合同表'; + + +DROP TABLE IF EXISTS `crm_clue`; +CREATE TABLE `crm_clue` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,主键自增', + `transform_status` tinyint NOT NULL COMMENT '转化状态', + `follow_up_status` tinyint NOT NULL COMMENT '跟进状态', + `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '线索名称', + `customer_id` bigint NOT NULL COMMENT '客户id', + `contact_next_time` datetime NULL DEFAULT NULL COMMENT '下次联系时间', + `telephone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '电话', + `mobile` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '手机号', + `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '地址', + `owner_user_id` bigint NULL DEFAULT NULL COMMENT '负责人的用户编号', + `contact_last_time` datetime NULL DEFAULT NULL COMMENT '最后跟进时间', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线索表' ROW_FORMAT = Dynamic; \ No newline at end of file diff --git a/sql/mysql/crm_menu.sql b/sql/mysql/crm_menu.sql index 83e5ae29d..cf0fe00fd 100644 --- a/sql/mysql/crm_menu.sql +++ b/sql/mysql/crm_menu.sql @@ -59,5 +59,61 @@ VALUES ( ); -- ---------------------------- --- ...菜单 --- ---------------------------- \ No newline at end of file +-- 线索菜单 +-- ---------------------------- + +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '线索管理', '', 2, 0, 2375, + 'clue', '', 'crm/clue/index', 0, 'CrmClue' +); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '线索查询', 'crm:clue:query', 3, 1, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '线索创建', 'crm:clue:create', 3, 2, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '线索更新', 'crm:clue:update', 3, 3, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '线索删除', 'crm:clue:delete', 3, 4, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '线索导出', 'crm:clue:export', 3, 5, @parentId, + '', '', '', 0 +); diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 532533d6c..85eb929fc 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -12,4 +12,6 @@ public interface ErrorCodeConstants { // ========== 合同管理 1-020-000-000 ========== ErrorCode CONTRACT_NOT_EXISTS = new ErrorCode(1_020_000_000, "合同不存在"); + ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_000_001, "线索不存在"); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java new file mode 100644 index 000000000..a1979b99a --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java @@ -0,0 +1,102 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; +import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; +import cn.iocoder.yudao.module.crm.service.clue.CrmClueService; + +@Tag(name = "管理后台 - 线索") +@RestController +@RequestMapping("/crm/clue") +@Validated +public class CrmClueController { + + @Resource + private CrmClueService clueService; + + @PostMapping("/create") + @Operation(summary = "创建线索") + @PreAuthorize("@ss.hasPermission('crm:clue:create')") + public CommonResult createClue(@Valid @RequestBody CrmClueCreateReqVO createReqVO) { + return success(clueService.createClue(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新线索") + @PreAuthorize("@ss.hasPermission('crm:clue:update')") + public CommonResult updateClue(@Valid @RequestBody CrmClueUpdateReqVO updateReqVO) { + clueService.updateClue(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除线索") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('crm:clue:delete')") + public CommonResult deleteClue(@RequestParam("id") Long id) { + clueService.deleteClue(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得线索") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('crm:clue:query')") + public CommonResult getClue(@RequestParam("id") Long id) { + CrmClueDO clue = clueService.getClue(id); + return success(CrmClueConvert.INSTANCE.convert(clue)); + } + + @GetMapping("/list") + @Operation(summary = "获得线索列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('crm:clue:query')") + public CommonResult> getClueList(@RequestParam("ids") Collection ids) { + List list = clueService.getClueList(ids); + return success(CrmClueConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得线索分页") + @PreAuthorize("@ss.hasPermission('crm:clue:query')") + public CommonResult> getCluePage(@Valid CrmCluePageReqVO pageVO) { + PageResult pageResult = clueService.getCluePage(pageVO); + return success(CrmClueConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出线索 Excel") + @PreAuthorize("@ss.hasPermission('crm:clue:export')") + @OperateLog(type = EXPORT) + public void exportClueExcel(@Valid CrmClueExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = clueService.getClueList(exportReqVO); + // 导出 Excel + List datas = CrmClueConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "线索.xls", "数据", CrmClueExcelVO.class, datas); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java new file mode 100644 index 000000000..285f8029f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java @@ -0,0 +1,64 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; + +import cn.iocoder.yudao.framework.common.validation.Mobile; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * 线索 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class CrmClueBaseVO { + + @Schema(description = "转化状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @NotNull(message = "转化状态不能为空") + private Boolean transformStatus; + + @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @NotNull(message = "跟进状态不能为空") + private Boolean followUpStatus; + + @Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx") + @NotNull(message = "线索名称不能为空") + private String name; + + @Schema(description = "客户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "520") + @NotNull(message = "客户id不能为空") + private Long customerId; + + @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime contactNextTime; + + @Mobile(message = "电话格式不正确") + @Schema(description = "电话", example = "18000000000") + private String telephone; + + @Mobile(message = "手机号格式不正确") + @Schema(description = "手机号", example = "18000000000") + private String mobile; + + @Schema(description = "地址", example = "北京市海淀区") + private String address; + + @Schema(description = "负责人的用户编号", example = "27199") + private Long ownerUserId; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime contactLastTime; + + @Schema(description = "备注", example = "随便") + private String remark; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueCreateReqVO.java new file mode 100644 index 000000000..0d43e15a6 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 线索创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmClueCreateReqVO extends CrmClueBaseVO { + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExcelVO.java new file mode 100644 index 000000000..13bc9c42b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExcelVO.java @@ -0,0 +1,65 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + + +/** + * 线索 Excel VO + * + * @author Wanwan + */ +@Data +public class CrmClueExcelVO { + + @ExcelProperty("编号,主键自增") + private Long id; + + @ExcelProperty(value = "转化状态", converter = DictConvert.class) + @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private Boolean transformStatus; + + @ExcelProperty(value = "跟进状态", converter = DictConvert.class) + @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private Boolean followUpStatus; + + @ExcelProperty("线索名称") + private String name; + + @ExcelProperty("客户id") + private Long customerId; + + @ExcelProperty("下次联系时间") + private LocalDateTime contactNextTime; + + @ExcelProperty("电话") + private String telephone; + + @ExcelProperty("手机号") + private String mobile; + + @ExcelProperty("地址") + private String address; + + @ExcelProperty("负责人的用户编号") + private Long ownerUserId; + + @ExcelProperty("最后跟进时间") + private LocalDateTime contactLastTime; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExportReqVO.java new file mode 100644 index 000000000..fe061b365 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExportReqVO.java @@ -0,0 +1,52 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import java.time.LocalDateTime; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 线索 Excel 导出 Request VO,参数和 CrmCluePageReqVO 是一致的") +@Data +public class CrmClueExportReqVO { + + @Schema(description = "转化状态", example = "true") + private Boolean transformStatus; + + @Schema(description = "跟进状态", example = "true") + private Boolean followUpStatus; + + @Schema(description = "线索名称", example = "线索xxx") + private String name; + + @Schema(description = "客户id", example = "520") + private Long customerId; + + @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] contactNextTime; + + @Schema(description = "电话", example = "18000000000") + private String telephone; + + @Schema(description = "手机号", example = "18000000000") + private String mobile; + + @Schema(description = "地址", example = "北京市海淀区") + private String address; + + @Schema(description = "负责人的用户编号", example = "27199") + private Long ownerUserId; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] contactLastTime; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java new file mode 100644 index 000000000..b9cf71c42 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +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 = "管理后台 - 线索分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmCluePageReqVO extends PageParam { + + @Schema(description = "转化状态", example = "true") + private Boolean transformStatus; + + @Schema(description = "跟进状态", example = "true") + private Boolean followUpStatus; + + @Schema(description = "线索名称", example = "线索xxx") + private String name; + + @Schema(description = "客户id", example = "520") + private Long customerId; + + @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] contactNextTime; + + @Schema(description = "电话", example = "18000000000") + private String telephone; + + @Schema(description = "手机号", example = "18000000000") + private String mobile; + + @Schema(description = "地址", example = "北京市海淀区") + private String address; + + @Schema(description = "负责人的用户编号", example = "27199") + private Long ownerUserId; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] contactLastTime; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java new file mode 100644 index 000000000..60eb2939b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 线索 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmClueRespVO extends CrmClueBaseVO { + + @Schema(description = "编号,主键自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969") + private Long id; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java new file mode 100644 index 000000000..2a264de97 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 线索更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmClueUpdateReqVO extends CrmClueBaseVO { + + @Schema(description = "编号,主键自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969") + @NotNull(message = "编号,主键自增不能为空") + private Long id; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java new file mode 100644 index 000000000..144a77da6 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.convert.clue; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; + +/** + * 线索 Convert + * + * @author Wanwan + */ +@Mapper +public interface CrmClueConvert { + + CrmClueConvert INSTANCE = Mappers.getMapper(CrmClueConvert.class); + + CrmClueDO convert(CrmClueCreateReqVO bean); + + CrmClueDO convert(CrmClueUpdateReqVO bean); + + CrmClueRespVO convert(CrmClueDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java new file mode 100644 index 000000000..22e1b8912 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java @@ -0,0 +1,81 @@ +package cn.iocoder.yudao.module.crm.dal.dataobject.clue; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 线索 DO + * + * @author Wanwan + */ +@TableName("crm_clue") +@KeySequence("crm_clue_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CrmClueDO extends BaseDO { + + /** + * 编号,主键自增 + */ + @TableId + private Long id; + /** + * 转化状态 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean transformStatus; + /** + * 跟进状态 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean followUpStatus; + /** + * 线索名称 + */ + private String name; + /** + * 客户id + */ + private Long customerId; + /** + * 下次联系时间 + */ + private LocalDateTime contactNextTime; + /** + * 电话 + */ + private String telephone; + /** + * 手机号 + */ + private String mobile; + /** + * 地址 + */ + private String address; + /** + * 负责人的用户编号 + */ + private Long ownerUserId; + /** + * 最后跟进时间 + */ + private LocalDateTime contactLastTime; + /** + * 备注 + */ + private String remark; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java new file mode 100644 index 000000000..044615bcf --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java @@ -0,0 +1,52 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.clue; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; + +/** + * 线索 Mapper + * + * @author Wanwan + */ +@Mapper +public interface CrmClueMapper extends BaseMapperX { + + default PageResult selectPage(CrmCluePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(CrmClueDO::getTransformStatus, reqVO.getTransformStatus()) + .eqIfPresent(CrmClueDO::getFollowUpStatus, reqVO.getFollowUpStatus()) + .likeIfPresent(CrmClueDO::getName, reqVO.getName()) + .eqIfPresent(CrmClueDO::getCustomerId, reqVO.getCustomerId()) + .betweenIfPresent(CrmClueDO::getContactNextTime, reqVO.getContactNextTime()) + .likeIfPresent(CrmClueDO::getTelephone, reqVO.getTelephone()) + .likeIfPresent(CrmClueDO::getMobile, reqVO.getMobile()) + .likeIfPresent(CrmClueDO::getAddress, reqVO.getAddress()) + .eqIfPresent(CrmClueDO::getOwnerUserId, reqVO.getOwnerUserId()) + .betweenIfPresent(CrmClueDO::getContactLastTime, reqVO.getContactLastTime()) + .betweenIfPresent(CrmClueDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(CrmClueDO::getId)); + } + + default List selectList(CrmClueExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(CrmClueDO::getTransformStatus, reqVO.getTransformStatus()) + .eqIfPresent(CrmClueDO::getFollowUpStatus, reqVO.getFollowUpStatus()) + .likeIfPresent(CrmClueDO::getName, reqVO.getName()) + .eqIfPresent(CrmClueDO::getCustomerId, reqVO.getCustomerId()) + .betweenIfPresent(CrmClueDO::getContactNextTime, reqVO.getContactNextTime()) + .likeIfPresent(CrmClueDO::getTelephone, reqVO.getTelephone()) + .likeIfPresent(CrmClueDO::getMobile, reqVO.getMobile()) + .likeIfPresent(CrmClueDO::getAddress, reqVO.getAddress()) + .eqIfPresent(CrmClueDO::getOwnerUserId, reqVO.getOwnerUserId()) + .betweenIfPresent(CrmClueDO::getContactLastTime, reqVO.getContactLastTime()) + .betweenIfPresent(CrmClueDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(CrmClueDO::getId)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java new file mode 100644 index 000000000..3bf627f5f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.crm.service.clue; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * 线索 Service 接口 + * + * @author Wanwan + */ +public interface CrmClueService { + + /** + * 创建线索 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createClue(@Valid CrmClueCreateReqVO createReqVO); + + /** + * 更新线索 + * + * @param updateReqVO 更新信息 + */ + void updateClue(@Valid CrmClueUpdateReqVO updateReqVO); + + /** + * 删除线索 + * + * @param id 编号 + */ + void deleteClue(Long id); + + /** + * 获得线索 + * + * @param id 编号 + * @return 线索 + */ + CrmClueDO getClue(Long id); + + /** + * 获得线索列表 + * + * @param ids 编号 + * @return 线索列表 + */ + List getClueList(Collection ids); + + /** + * 获得线索分页 + * + * @param pageReqVO 分页查询 + * @return 线索分页 + */ + PageResult getCluePage(CrmCluePageReqVO pageReqVO); + + /** + * 获得线索列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 线索列表 + */ + List getClueList(CrmClueExportReqVO exportReqVO); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java new file mode 100644 index 000000000..92193361f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java @@ -0,0 +1,88 @@ +package cn.iocoder.yudao.module.crm.service.clue; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; +import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; + +/** + * 线索 Service 实现类 + * + * @author Wanwan + */ +@Service +@Validated +public class CrmClueServiceImpl implements CrmClueService { + + @Resource + private CrmClueMapper clueMapper; + + @Override + public Long createClue(CrmClueCreateReqVO createReqVO) { + // 插入 + CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO); + clueMapper.insert(clue); + // 返回 + return clue.getId(); + } + + @Override + public void updateClue(CrmClueUpdateReqVO updateReqVO) { + // 校验存在 + validateClueExists(updateReqVO.getId()); + // 更新 + CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO); + clueMapper.updateById(updateObj); + } + + @Override + public void deleteClue(Long id) { + // 校验存在 + validateClueExists(id); + // 删除 + clueMapper.deleteById(id); + } + + private void validateClueExists(Long id) { + if (clueMapper.selectById(id) == null) { + throw exception(CLUE_NOT_EXISTS); + } + } + + @Override + public CrmClueDO getClue(Long id) { + return clueMapper.selectById(id); + } + + @Override + public List getClueList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return clueMapper.selectBatchIds(ids); + } + + @Override + public PageResult getCluePage(CrmCluePageReqVO pageReqVO) { + return clueMapper.selectPage(pageReqVO); + } + + @Override + public List getClueList(CrmClueExportReqVO exportReqVO) { + return clueMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/clue/CrmClueMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/clue/CrmClueMapper.xml new file mode 100644 index 000000000..3f15cf766 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/clue/CrmClueMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java new file mode 100644 index 000000000..ce68734c1 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java @@ -0,0 +1,231 @@ +package cn.iocoder.yudao.module.crm.service.clue; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; +import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link CrmClueServiceImpl} 的单元测试类 + * + * @author Wanwan + */ +@Import(CrmClueServiceImpl.class) +public class CrmClueServiceImplTest extends BaseDbUnitTest { + + @Resource + private CrmClueServiceImpl clueService; + + @Resource + private CrmClueMapper clueMapper; + + @Test + public void testCreateClue_success() { + // 准备参数 + CrmClueCreateReqVO reqVO = randomPojo(CrmClueCreateReqVO.class); + + // 调用 + Long clueId = clueService.createClue(reqVO); + // 断言 + assertNotNull(clueId); + // 校验记录的属性是否正确 + CrmClueDO clue = clueMapper.selectById(clueId); + assertPojoEquals(reqVO, clue); + } + + @Test + public void testUpdateClue_success() { + // mock 数据 + CrmClueDO dbClue = randomPojo(CrmClueDO.class); + clueMapper.insert(dbClue);// @Sql: 先插入出一条存在的数据 + // 准备参数 + CrmClueUpdateReqVO reqVO = randomPojo(CrmClueUpdateReqVO.class, o -> { + o.setId(dbClue.getId()); // 设置更新的 ID + }); + + // 调用 + clueService.updateClue(reqVO); + // 校验是否更新正确 + CrmClueDO clue = clueMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, clue); + } + + @Test + public void testUpdateClue_notExists() { + // 准备参数 + CrmClueUpdateReqVO reqVO = randomPojo(CrmClueUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> clueService.updateClue(reqVO), CLUE_NOT_EXISTS); + } + + @Test + public void testDeleteClue_success() { + // mock 数据 + CrmClueDO dbClue = randomPojo(CrmClueDO.class); + clueMapper.insert(dbClue);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbClue.getId(); + + // 调用 + clueService.deleteClue(id); + // 校验数据不存在了 + assertNull(clueMapper.selectById(id)); + } + + @Test + public void testDeleteClue_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> clueService.deleteClue(id), CLUE_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetCluePage() { + // mock 数据 + CrmClueDO dbClue = randomPojo(CrmClueDO.class, o -> { // 等会查询到 + o.setTransformStatus(null); + o.setFollowUpStatus(null); + o.setName(null); + o.setCustomerId(null); + o.setContactNextTime(null); + o.setTelephone(null); + o.setMobile(null); + o.setAddress(null); + o.setOwnerUserId(null); + o.setContactLastTime(null); + o.setCreateTime(null); + }); + clueMapper.insert(dbClue); + // 测试 transformStatus 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTransformStatus(null))); + // 测试 followUpStatus 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setFollowUpStatus(null))); + // 测试 name 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setName(null))); + // 测试 customerId 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCustomerId(null))); + // 测试 contactNextTime 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactNextTime(null))); + // 测试 telephone 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTelephone(null))); + // 测试 mobile 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null))); + // 测试 address 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null))); + // 测试 ownerUserId 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setOwnerUserId(null))); + // 测试 contactLastTime 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null))); + // 测试 createTime 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCreateTime(null))); + // 准备参数 + CrmCluePageReqVO reqVO = new CrmCluePageReqVO(); + reqVO.setTransformStatus(null); + reqVO.setFollowUpStatus(null); + reqVO.setName(null); + reqVO.setCustomerId(null); + reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setTelephone(null); + reqVO.setMobile(null); + reqVO.setAddress(null); + reqVO.setOwnerUserId(null); + reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = clueService.getCluePage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbClue, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetClueList() { + // mock 数据 + CrmClueDO dbClue = randomPojo(CrmClueDO.class, o -> { // 等会查询到 + o.setTransformStatus(null); + o.setFollowUpStatus(null); + o.setName(null); + o.setCustomerId(null); + o.setContactNextTime(null); + o.setTelephone(null); + o.setMobile(null); + o.setAddress(null); + o.setOwnerUserId(null); + o.setContactLastTime(null); + o.setCreateTime(null); + }); + clueMapper.insert(dbClue); + // 测试 transformStatus 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTransformStatus(null))); + // 测试 followUpStatus 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setFollowUpStatus(null))); + // 测试 name 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setName(null))); + // 测试 customerId 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCustomerId(null))); + // 测试 contactNextTime 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactNextTime(null))); + // 测试 telephone 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTelephone(null))); + // 测试 mobile 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null))); + // 测试 address 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null))); + // 测试 ownerUserId 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setOwnerUserId(null))); + // 测试 contactLastTime 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null))); + // 测试 createTime 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCreateTime(null))); + // 准备参数 + CrmClueExportReqVO reqVO = new CrmClueExportReqVO(); + reqVO.setTransformStatus(null); + reqVO.setFollowUpStatus(null); + reqVO.setName(null); + reqVO.setCustomerId(null); + reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setTelephone(null); + reqVO.setMobile(null); + reqVO.setAddress(null); + reqVO.setOwnerUserId(null); + reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + List list = clueService.getClueList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbClue, list.get(0)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql index c45d2602e..983e53ab3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql @@ -1 +1,3 @@ DELETE FROM "crm_contract"; + +DELETE FROM "crm_clue"; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql index c25a80e44..816264e66 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql @@ -24,4 +24,26 @@ CREATE TABLE IF NOT EXISTS "crm_contract" ( "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, "deleted" bit NOT NULL DEFAULT FALSE, PRIMARY KEY ("id") - ) COMMENT '合同表'; \ No newline at end of file +) COMMENT '合同表'; + +CREATE TABLE IF NOT EXISTS "crm_clue" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "transform_status" bit NOT NULL, + "follow_up_status" bit NOT NULL, + "name" varchar NOT NULL, + "customer_id" bigint NOT NULL, + "contact_next_time" varchar, + "telephone" varchar, + "mobile" varchar, + "address" varchar, + "owner_user_id" bigint, + "contact_last_time" varchar, + "remark" varchar, + "creator" varchar DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + "tenant_id" bigint NOT NULL, + PRIMARY KEY ("id") +) COMMENT '线索表'; \ No newline at end of file From 1b6c8574cde00a79675b90d6e49042c61f55e495 Mon Sep 17 00:00:00 2001 From: "913752709@qq.com" <913752709@qq.com> Date: Wed, 18 Oct 2023 20:02:53 +0800 Subject: [PATCH 008/101] =?UTF-8?q?feat:=20CRM=20=E7=BA=BF=E7=B4=A2?= =?UTF-8?q?=E8=A1=A8=20crud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/module/crm/dal/dataobject/clue/CrmClueDO.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java index 22e1b8912..986d933e8 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.clue; +import com.sun.xml.bind.v2.TODO; import lombok.*; import java.util.*; import java.time.LocalDateTime; @@ -70,7 +71,7 @@ public class CrmClueDO extends BaseDO { */ private Long ownerUserId; /** - * 最后跟进时间 + * 最后跟进时间 TODO 添加跟进记录时更新该值 */ private LocalDateTime contactLastTime; /** From 48661f980c59c92f66e33ce2a74be4e3abec4e62 Mon Sep 17 00:00:00 2001 From: wanwan <913752709@qq.com> Date: Thu, 19 Oct 2023 14:52:16 +0000 Subject: [PATCH 009/101] =?UTF-8?q?!679=20feat:=20CRM=20=E7=BA=BF=E7=B4=A2?= =?UTF-8?q?=E8=A1=A8=20crud=20*=20feat:=20CRM=20=E7=BA=BF=E7=B4=A2?= =?UTF-8?q?=E8=A1=A8=20crud=20*=20feat:=20CRM=20=E7=BA=BF=E7=B4=A2?= =?UTF-8?q?=E8=A1=A8=20crud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 24 ++ sql/mysql/crm_menu.sql | 60 ++++- .../module/crm/enums/ErrorCodeConstants.java | 2 + .../admin/clue/CrmClueController.java | 102 ++++++++ .../admin/clue/vo/CrmClueBaseVO.java | 64 +++++ .../admin/clue/vo/CrmClueCreateReqVO.java | 14 ++ .../admin/clue/vo/CrmClueExcelVO.java | 65 +++++ .../admin/clue/vo/CrmClueExportReqVO.java | 52 ++++ .../admin/clue/vo/CrmCluePageReqVO.java | 54 ++++ .../admin/clue/vo/CrmClueRespVO.java | 19 ++ .../admin/clue/vo/CrmClueUpdateReqVO.java | 18 ++ .../crm/convert/clue/CrmClueConvert.java | 34 +++ .../crm/dal/dataobject/clue/CrmClueDO.java | 82 +++++++ .../crm/dal/mysql/clue/CrmClueMapper.java | 52 ++++ .../crm/service/clue/CrmClueService.java | 70 ++++++ .../crm/service/clue/CrmClueServiceImpl.java | 88 +++++++ .../resources/mapper/clue/CrmClueMapper.xml | 12 + .../service/clue/CrmClueServiceImplTest.java | 231 ++++++++++++++++++ .../src/test/resources/sql/clean.sql | 2 + .../src/test/resources/sql/create_tables.sql | 24 +- 20 files changed, 1066 insertions(+), 3 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueCreateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExcelVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExportReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/clue/CrmClueMapper.xml create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index eeb2d12ac..6c5594068 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -37,3 +37,27 @@ CREATE TABLE `crm_contract` ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT ='合同表'; + + +DROP TABLE IF EXISTS `crm_clue`; +CREATE TABLE `crm_clue` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,主键自增', + `transform_status` tinyint NOT NULL COMMENT '转化状态', + `follow_up_status` tinyint NOT NULL COMMENT '跟进状态', + `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '线索名称', + `customer_id` bigint NOT NULL COMMENT '客户id', + `contact_next_time` datetime NULL DEFAULT NULL COMMENT '下次联系时间', + `telephone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '电话', + `mobile` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '手机号', + `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '地址', + `owner_user_id` bigint NULL DEFAULT NULL COMMENT '负责人的用户编号', + `contact_last_time` datetime NULL DEFAULT NULL COMMENT '最后跟进时间', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线索表' ROW_FORMAT = Dynamic; \ No newline at end of file diff --git a/sql/mysql/crm_menu.sql b/sql/mysql/crm_menu.sql index 83e5ae29d..cf0fe00fd 100644 --- a/sql/mysql/crm_menu.sql +++ b/sql/mysql/crm_menu.sql @@ -59,5 +59,61 @@ VALUES ( ); -- ---------------------------- --- ...菜单 --- ---------------------------- \ No newline at end of file +-- 线索菜单 +-- ---------------------------- + +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '线索管理', '', 2, 0, 2375, + 'clue', '', 'crm/clue/index', 0, 'CrmClue' +); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '线索查询', 'crm:clue:query', 3, 1, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '线索创建', 'crm:clue:create', 3, 2, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '线索更新', 'crm:clue:update', 3, 3, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '线索删除', 'crm:clue:delete', 3, 4, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '线索导出', 'crm:clue:export', 3, 5, @parentId, + '', '', '', 0 +); diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 532533d6c..85eb929fc 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -12,4 +12,6 @@ public interface ErrorCodeConstants { // ========== 合同管理 1-020-000-000 ========== ErrorCode CONTRACT_NOT_EXISTS = new ErrorCode(1_020_000_000, "合同不存在"); + ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_000_001, "线索不存在"); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java new file mode 100644 index 000000000..a1979b99a --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java @@ -0,0 +1,102 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; +import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; +import cn.iocoder.yudao.module.crm.service.clue.CrmClueService; + +@Tag(name = "管理后台 - 线索") +@RestController +@RequestMapping("/crm/clue") +@Validated +public class CrmClueController { + + @Resource + private CrmClueService clueService; + + @PostMapping("/create") + @Operation(summary = "创建线索") + @PreAuthorize("@ss.hasPermission('crm:clue:create')") + public CommonResult createClue(@Valid @RequestBody CrmClueCreateReqVO createReqVO) { + return success(clueService.createClue(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新线索") + @PreAuthorize("@ss.hasPermission('crm:clue:update')") + public CommonResult updateClue(@Valid @RequestBody CrmClueUpdateReqVO updateReqVO) { + clueService.updateClue(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除线索") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('crm:clue:delete')") + public CommonResult deleteClue(@RequestParam("id") Long id) { + clueService.deleteClue(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得线索") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('crm:clue:query')") + public CommonResult getClue(@RequestParam("id") Long id) { + CrmClueDO clue = clueService.getClue(id); + return success(CrmClueConvert.INSTANCE.convert(clue)); + } + + @GetMapping("/list") + @Operation(summary = "获得线索列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('crm:clue:query')") + public CommonResult> getClueList(@RequestParam("ids") Collection ids) { + List list = clueService.getClueList(ids); + return success(CrmClueConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得线索分页") + @PreAuthorize("@ss.hasPermission('crm:clue:query')") + public CommonResult> getCluePage(@Valid CrmCluePageReqVO pageVO) { + PageResult pageResult = clueService.getCluePage(pageVO); + return success(CrmClueConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出线索 Excel") + @PreAuthorize("@ss.hasPermission('crm:clue:export')") + @OperateLog(type = EXPORT) + public void exportClueExcel(@Valid CrmClueExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = clueService.getClueList(exportReqVO); + // 导出 Excel + List datas = CrmClueConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "线索.xls", "数据", CrmClueExcelVO.class, datas); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java new file mode 100644 index 000000000..285f8029f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java @@ -0,0 +1,64 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; + +import cn.iocoder.yudao.framework.common.validation.Mobile; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * 线索 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class CrmClueBaseVO { + + @Schema(description = "转化状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @NotNull(message = "转化状态不能为空") + private Boolean transformStatus; + + @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @NotNull(message = "跟进状态不能为空") + private Boolean followUpStatus; + + @Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx") + @NotNull(message = "线索名称不能为空") + private String name; + + @Schema(description = "客户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "520") + @NotNull(message = "客户id不能为空") + private Long customerId; + + @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime contactNextTime; + + @Mobile(message = "电话格式不正确") + @Schema(description = "电话", example = "18000000000") + private String telephone; + + @Mobile(message = "手机号格式不正确") + @Schema(description = "手机号", example = "18000000000") + private String mobile; + + @Schema(description = "地址", example = "北京市海淀区") + private String address; + + @Schema(description = "负责人的用户编号", example = "27199") + private Long ownerUserId; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime contactLastTime; + + @Schema(description = "备注", example = "随便") + private String remark; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueCreateReqVO.java new file mode 100644 index 000000000..0d43e15a6 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 线索创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmClueCreateReqVO extends CrmClueBaseVO { + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExcelVO.java new file mode 100644 index 000000000..13bc9c42b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExcelVO.java @@ -0,0 +1,65 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + + +/** + * 线索 Excel VO + * + * @author Wanwan + */ +@Data +public class CrmClueExcelVO { + + @ExcelProperty("编号,主键自增") + private Long id; + + @ExcelProperty(value = "转化状态", converter = DictConvert.class) + @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private Boolean transformStatus; + + @ExcelProperty(value = "跟进状态", converter = DictConvert.class) + @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private Boolean followUpStatus; + + @ExcelProperty("线索名称") + private String name; + + @ExcelProperty("客户id") + private Long customerId; + + @ExcelProperty("下次联系时间") + private LocalDateTime contactNextTime; + + @ExcelProperty("电话") + private String telephone; + + @ExcelProperty("手机号") + private String mobile; + + @ExcelProperty("地址") + private String address; + + @ExcelProperty("负责人的用户编号") + private Long ownerUserId; + + @ExcelProperty("最后跟进时间") + private LocalDateTime contactLastTime; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExportReqVO.java new file mode 100644 index 000000000..fe061b365 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExportReqVO.java @@ -0,0 +1,52 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import java.time.LocalDateTime; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 线索 Excel 导出 Request VO,参数和 CrmCluePageReqVO 是一致的") +@Data +public class CrmClueExportReqVO { + + @Schema(description = "转化状态", example = "true") + private Boolean transformStatus; + + @Schema(description = "跟进状态", example = "true") + private Boolean followUpStatus; + + @Schema(description = "线索名称", example = "线索xxx") + private String name; + + @Schema(description = "客户id", example = "520") + private Long customerId; + + @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] contactNextTime; + + @Schema(description = "电话", example = "18000000000") + private String telephone; + + @Schema(description = "手机号", example = "18000000000") + private String mobile; + + @Schema(description = "地址", example = "北京市海淀区") + private String address; + + @Schema(description = "负责人的用户编号", example = "27199") + private Long ownerUserId; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] contactLastTime; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java new file mode 100644 index 000000000..b9cf71c42 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +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 = "管理后台 - 线索分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmCluePageReqVO extends PageParam { + + @Schema(description = "转化状态", example = "true") + private Boolean transformStatus; + + @Schema(description = "跟进状态", example = "true") + private Boolean followUpStatus; + + @Schema(description = "线索名称", example = "线索xxx") + private String name; + + @Schema(description = "客户id", example = "520") + private Long customerId; + + @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] contactNextTime; + + @Schema(description = "电话", example = "18000000000") + private String telephone; + + @Schema(description = "手机号", example = "18000000000") + private String mobile; + + @Schema(description = "地址", example = "北京市海淀区") + private String address; + + @Schema(description = "负责人的用户编号", example = "27199") + private Long ownerUserId; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] contactLastTime; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java new file mode 100644 index 000000000..60eb2939b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 线索 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmClueRespVO extends CrmClueBaseVO { + + @Schema(description = "编号,主键自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969") + private Long id; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java new file mode 100644 index 000000000..2a264de97 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 线索更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmClueUpdateReqVO extends CrmClueBaseVO { + + @Schema(description = "编号,主键自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969") + @NotNull(message = "编号,主键自增不能为空") + private Long id; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java new file mode 100644 index 000000000..144a77da6 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.convert.clue; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; + +/** + * 线索 Convert + * + * @author Wanwan + */ +@Mapper +public interface CrmClueConvert { + + CrmClueConvert INSTANCE = Mappers.getMapper(CrmClueConvert.class); + + CrmClueDO convert(CrmClueCreateReqVO bean); + + CrmClueDO convert(CrmClueUpdateReqVO bean); + + CrmClueRespVO convert(CrmClueDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java new file mode 100644 index 000000000..986d933e8 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java @@ -0,0 +1,82 @@ +package cn.iocoder.yudao.module.crm.dal.dataobject.clue; + +import com.sun.xml.bind.v2.TODO; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 线索 DO + * + * @author Wanwan + */ +@TableName("crm_clue") +@KeySequence("crm_clue_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CrmClueDO extends BaseDO { + + /** + * 编号,主键自增 + */ + @TableId + private Long id; + /** + * 转化状态 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean transformStatus; + /** + * 跟进状态 + * + * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean followUpStatus; + /** + * 线索名称 + */ + private String name; + /** + * 客户id + */ + private Long customerId; + /** + * 下次联系时间 + */ + private LocalDateTime contactNextTime; + /** + * 电话 + */ + private String telephone; + /** + * 手机号 + */ + private String mobile; + /** + * 地址 + */ + private String address; + /** + * 负责人的用户编号 + */ + private Long ownerUserId; + /** + * 最后跟进时间 TODO 添加跟进记录时更新该值 + */ + private LocalDateTime contactLastTime; + /** + * 备注 + */ + private String remark; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java new file mode 100644 index 000000000..044615bcf --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java @@ -0,0 +1,52 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.clue; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; + +/** + * 线索 Mapper + * + * @author Wanwan + */ +@Mapper +public interface CrmClueMapper extends BaseMapperX { + + default PageResult selectPage(CrmCluePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(CrmClueDO::getTransformStatus, reqVO.getTransformStatus()) + .eqIfPresent(CrmClueDO::getFollowUpStatus, reqVO.getFollowUpStatus()) + .likeIfPresent(CrmClueDO::getName, reqVO.getName()) + .eqIfPresent(CrmClueDO::getCustomerId, reqVO.getCustomerId()) + .betweenIfPresent(CrmClueDO::getContactNextTime, reqVO.getContactNextTime()) + .likeIfPresent(CrmClueDO::getTelephone, reqVO.getTelephone()) + .likeIfPresent(CrmClueDO::getMobile, reqVO.getMobile()) + .likeIfPresent(CrmClueDO::getAddress, reqVO.getAddress()) + .eqIfPresent(CrmClueDO::getOwnerUserId, reqVO.getOwnerUserId()) + .betweenIfPresent(CrmClueDO::getContactLastTime, reqVO.getContactLastTime()) + .betweenIfPresent(CrmClueDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(CrmClueDO::getId)); + } + + default List selectList(CrmClueExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(CrmClueDO::getTransformStatus, reqVO.getTransformStatus()) + .eqIfPresent(CrmClueDO::getFollowUpStatus, reqVO.getFollowUpStatus()) + .likeIfPresent(CrmClueDO::getName, reqVO.getName()) + .eqIfPresent(CrmClueDO::getCustomerId, reqVO.getCustomerId()) + .betweenIfPresent(CrmClueDO::getContactNextTime, reqVO.getContactNextTime()) + .likeIfPresent(CrmClueDO::getTelephone, reqVO.getTelephone()) + .likeIfPresent(CrmClueDO::getMobile, reqVO.getMobile()) + .likeIfPresent(CrmClueDO::getAddress, reqVO.getAddress()) + .eqIfPresent(CrmClueDO::getOwnerUserId, reqVO.getOwnerUserId()) + .betweenIfPresent(CrmClueDO::getContactLastTime, reqVO.getContactLastTime()) + .betweenIfPresent(CrmClueDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(CrmClueDO::getId)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java new file mode 100644 index 000000000..3bf627f5f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueService.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.crm.service.clue; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * 线索 Service 接口 + * + * @author Wanwan + */ +public interface CrmClueService { + + /** + * 创建线索 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createClue(@Valid CrmClueCreateReqVO createReqVO); + + /** + * 更新线索 + * + * @param updateReqVO 更新信息 + */ + void updateClue(@Valid CrmClueUpdateReqVO updateReqVO); + + /** + * 删除线索 + * + * @param id 编号 + */ + void deleteClue(Long id); + + /** + * 获得线索 + * + * @param id 编号 + * @return 线索 + */ + CrmClueDO getClue(Long id); + + /** + * 获得线索列表 + * + * @param ids 编号 + * @return 线索列表 + */ + List getClueList(Collection ids); + + /** + * 获得线索分页 + * + * @param pageReqVO 分页查询 + * @return 线索分页 + */ + PageResult getCluePage(CrmCluePageReqVO pageReqVO); + + /** + * 获得线索列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 线索列表 + */ + List getClueList(CrmClueExportReqVO exportReqVO); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java new file mode 100644 index 000000000..92193361f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java @@ -0,0 +1,88 @@ +package cn.iocoder.yudao.module.crm.service.clue; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; +import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; + +/** + * 线索 Service 实现类 + * + * @author Wanwan + */ +@Service +@Validated +public class CrmClueServiceImpl implements CrmClueService { + + @Resource + private CrmClueMapper clueMapper; + + @Override + public Long createClue(CrmClueCreateReqVO createReqVO) { + // 插入 + CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO); + clueMapper.insert(clue); + // 返回 + return clue.getId(); + } + + @Override + public void updateClue(CrmClueUpdateReqVO updateReqVO) { + // 校验存在 + validateClueExists(updateReqVO.getId()); + // 更新 + CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO); + clueMapper.updateById(updateObj); + } + + @Override + public void deleteClue(Long id) { + // 校验存在 + validateClueExists(id); + // 删除 + clueMapper.deleteById(id); + } + + private void validateClueExists(Long id) { + if (clueMapper.selectById(id) == null) { + throw exception(CLUE_NOT_EXISTS); + } + } + + @Override + public CrmClueDO getClue(Long id) { + return clueMapper.selectById(id); + } + + @Override + public List getClueList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return clueMapper.selectBatchIds(ids); + } + + @Override + public PageResult getCluePage(CrmCluePageReqVO pageReqVO) { + return clueMapper.selectPage(pageReqVO); + } + + @Override + public List getClueList(CrmClueExportReqVO exportReqVO) { + return clueMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/clue/CrmClueMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/clue/CrmClueMapper.xml new file mode 100644 index 000000000..3f15cf766 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/clue/CrmClueMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java new file mode 100644 index 000000000..ce68734c1 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java @@ -0,0 +1,231 @@ +package cn.iocoder.yudao.module.crm.service.clue; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; +import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link CrmClueServiceImpl} 的单元测试类 + * + * @author Wanwan + */ +@Import(CrmClueServiceImpl.class) +public class CrmClueServiceImplTest extends BaseDbUnitTest { + + @Resource + private CrmClueServiceImpl clueService; + + @Resource + private CrmClueMapper clueMapper; + + @Test + public void testCreateClue_success() { + // 准备参数 + CrmClueCreateReqVO reqVO = randomPojo(CrmClueCreateReqVO.class); + + // 调用 + Long clueId = clueService.createClue(reqVO); + // 断言 + assertNotNull(clueId); + // 校验记录的属性是否正确 + CrmClueDO clue = clueMapper.selectById(clueId); + assertPojoEquals(reqVO, clue); + } + + @Test + public void testUpdateClue_success() { + // mock 数据 + CrmClueDO dbClue = randomPojo(CrmClueDO.class); + clueMapper.insert(dbClue);// @Sql: 先插入出一条存在的数据 + // 准备参数 + CrmClueUpdateReqVO reqVO = randomPojo(CrmClueUpdateReqVO.class, o -> { + o.setId(dbClue.getId()); // 设置更新的 ID + }); + + // 调用 + clueService.updateClue(reqVO); + // 校验是否更新正确 + CrmClueDO clue = clueMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, clue); + } + + @Test + public void testUpdateClue_notExists() { + // 准备参数 + CrmClueUpdateReqVO reqVO = randomPojo(CrmClueUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> clueService.updateClue(reqVO), CLUE_NOT_EXISTS); + } + + @Test + public void testDeleteClue_success() { + // mock 数据 + CrmClueDO dbClue = randomPojo(CrmClueDO.class); + clueMapper.insert(dbClue);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbClue.getId(); + + // 调用 + clueService.deleteClue(id); + // 校验数据不存在了 + assertNull(clueMapper.selectById(id)); + } + + @Test + public void testDeleteClue_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> clueService.deleteClue(id), CLUE_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetCluePage() { + // mock 数据 + CrmClueDO dbClue = randomPojo(CrmClueDO.class, o -> { // 等会查询到 + o.setTransformStatus(null); + o.setFollowUpStatus(null); + o.setName(null); + o.setCustomerId(null); + o.setContactNextTime(null); + o.setTelephone(null); + o.setMobile(null); + o.setAddress(null); + o.setOwnerUserId(null); + o.setContactLastTime(null); + o.setCreateTime(null); + }); + clueMapper.insert(dbClue); + // 测试 transformStatus 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTransformStatus(null))); + // 测试 followUpStatus 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setFollowUpStatus(null))); + // 测试 name 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setName(null))); + // 测试 customerId 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCustomerId(null))); + // 测试 contactNextTime 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactNextTime(null))); + // 测试 telephone 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTelephone(null))); + // 测试 mobile 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null))); + // 测试 address 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null))); + // 测试 ownerUserId 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setOwnerUserId(null))); + // 测试 contactLastTime 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null))); + // 测试 createTime 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCreateTime(null))); + // 准备参数 + CrmCluePageReqVO reqVO = new CrmCluePageReqVO(); + reqVO.setTransformStatus(null); + reqVO.setFollowUpStatus(null); + reqVO.setName(null); + reqVO.setCustomerId(null); + reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setTelephone(null); + reqVO.setMobile(null); + reqVO.setAddress(null); + reqVO.setOwnerUserId(null); + reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = clueService.getCluePage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbClue, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetClueList() { + // mock 数据 + CrmClueDO dbClue = randomPojo(CrmClueDO.class, o -> { // 等会查询到 + o.setTransformStatus(null); + o.setFollowUpStatus(null); + o.setName(null); + o.setCustomerId(null); + o.setContactNextTime(null); + o.setTelephone(null); + o.setMobile(null); + o.setAddress(null); + o.setOwnerUserId(null); + o.setContactLastTime(null); + o.setCreateTime(null); + }); + clueMapper.insert(dbClue); + // 测试 transformStatus 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTransformStatus(null))); + // 测试 followUpStatus 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setFollowUpStatus(null))); + // 测试 name 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setName(null))); + // 测试 customerId 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCustomerId(null))); + // 测试 contactNextTime 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactNextTime(null))); + // 测试 telephone 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setTelephone(null))); + // 测试 mobile 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null))); + // 测试 address 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null))); + // 测试 ownerUserId 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setOwnerUserId(null))); + // 测试 contactLastTime 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null))); + // 测试 createTime 不匹配 + clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCreateTime(null))); + // 准备参数 + CrmClueExportReqVO reqVO = new CrmClueExportReqVO(); + reqVO.setTransformStatus(null); + reqVO.setFollowUpStatus(null); + reqVO.setName(null); + reqVO.setCustomerId(null); + reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setTelephone(null); + reqVO.setMobile(null); + reqVO.setAddress(null); + reqVO.setOwnerUserId(null); + reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + List list = clueService.getClueList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbClue, list.get(0)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql index c45d2602e..983e53ab3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql @@ -1 +1,3 @@ DELETE FROM "crm_contract"; + +DELETE FROM "crm_clue"; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql index c25a80e44..816264e66 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql @@ -24,4 +24,26 @@ CREATE TABLE IF NOT EXISTS "crm_contract" ( "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, "deleted" bit NOT NULL DEFAULT FALSE, PRIMARY KEY ("id") - ) COMMENT '合同表'; \ No newline at end of file +) COMMENT '合同表'; + +CREATE TABLE IF NOT EXISTS "crm_clue" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "transform_status" bit NOT NULL, + "follow_up_status" bit NOT NULL, + "name" varchar NOT NULL, + "customer_id" bigint NOT NULL, + "contact_next_time" varchar, + "telephone" varchar, + "mobile" varchar, + "address" varchar, + "owner_user_id" bigint, + "contact_last_time" varchar, + "remark" varchar, + "creator" varchar DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + "tenant_id" bigint NOT NULL, + PRIMARY KEY ("id") +) COMMENT '线索表'; \ No newline at end of file From 439edcd1be2c503260a5c0411468c979c175a87f Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 19 Oct 2023 23:15:18 +0800 Subject: [PATCH 010/101] =?UTF-8?q?code=20review=EF=BC=9Acrm=20=E7=BA=BF?= =?UTF-8?q?=E7=B4=A2=E7=9A=84=20crud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/ErrorCodeConstants.java | 1 + .../admin/clue/CrmClueController.java | 47 +++++++------------ .../admin/clue/vo/CrmClueBaseVO.java | 19 ++++---- .../admin/clue/vo/CrmCluePageReqVO.java | 10 ++-- .../crm/dal/dataobject/clue/CrmClueDO.java | 20 +++++--- .../service/clue/CrmClueServiceImplTest.java | 37 +++++++-------- 6 files changed, 66 insertions(+), 68 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 85eb929fc..3538b16ee 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -12,6 +12,7 @@ public interface ErrorCodeConstants { // ========== 合同管理 1-020-000-000 ========== ErrorCode CONTRACT_NOT_EXISTS = new ErrorCode(1_020_000_000, "合同不存在"); + // TODO @wanwan:要单独一个分段噢 ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_000_001, "线索不存在"); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java index a1979b99a..8892a8e71 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/CrmClueController.java @@ -1,32 +1,28 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue; -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - +import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; import cn.iocoder.yudao.module.crm.service.clue.CrmClueService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; @Tag(name = "管理后台 - 线索") @RestController @@ -70,15 +66,6 @@ public class CrmClueController { return success(CrmClueConvert.INSTANCE.convert(clue)); } - @GetMapping("/list") - @Operation(summary = "获得线索列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('crm:clue:query')") - public CommonResult> getClueList(@RequestParam("ids") Collection ids) { - List list = clueService.getClueList(ids); - return success(CrmClueConvert.INSTANCE.convertList(list)); - } - @GetMapping("/page") @Operation(summary = "获得线索分页") @PreAuthorize("@ss.hasPermission('crm:clue:query')") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java index 285f8029f..9a36c9175 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java @@ -2,15 +2,12 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; import cn.iocoder.yudao.framework.common.validation.Mobile; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import javax.validation.constraints.*; +import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; /** @@ -20,18 +17,21 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class CrmClueBaseVO { + // TODO @wanwan:转化状态,新增和修改的时候,应该不传递的哈;而是在未来的时候,才会更新到 @Schema(description = "转化状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") @NotNull(message = "转化状态不能为空") private Boolean transformStatus; + // TODO @wanwan:同 transformStatus @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") @NotNull(message = "跟进状态不能为空") private Boolean followUpStatus; @Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx") - @NotNull(message = "线索名称不能为空") + @NotNull(message = "线索名称不能为空") // TODO @wanwan:应该是 NotEmpty 噢。空串都无法接受 private String name; + // TODO @wanwan:中英文之间,要有个空格;例如说,客户 id 不能为空 @Schema(description = "客户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "520") @NotNull(message = "客户id不能为空") private Long customerId; @@ -40,10 +40,12 @@ public class CrmClueBaseVO { @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime contactNextTime; + // TODO @wanwan:@Schema 在 @Mobile 之前,要保持统一的顺序;2)可以加个 @Telephone 的校验格式;应该不是手机的格式哈 @Mobile(message = "电话格式不正确") @Schema(description = "电话", example = "18000000000") private String telephone; + // TODO @wanwan:@Schema 在 @Mobile 之前,要保持统一的顺序;2)类似 @Mobile 这个提示如果是默认的,就可以不写 message @Mobile(message = "手机号格式不正确") @Schema(description = "手机号", example = "18000000000") private String mobile; @@ -52,6 +54,7 @@ public class CrmClueBaseVO { private String address; @Schema(description = "负责人的用户编号", example = "27199") + // TODO @wanwan:这个是必填字段哈; private Long ownerUserId; @Schema(description = "最后跟进时间") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java index b9cf71c42..f4cba8fed 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java @@ -1,10 +1,12 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; import cn.iocoder.yudao.framework.common.pojo.PageParam; +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; @@ -15,6 +17,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class CrmCluePageReqVO extends PageParam { + // TODO @wanwan:目前只要支持 name、mobile、telephone 的搜索即可;其它字段应该暂时不需要哈; + @Schema(description = "转化状态", example = "true") private Boolean transformStatus; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java index 986d933e8..de30e1301 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java @@ -1,15 +1,15 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.clue; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import com.sun.xml.bind.v2.TODO; import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import java.time.LocalDateTime; + +// TODO 芋艿:字段的顺序,需要整理下; /** * 线索 DO * @@ -68,6 +68,8 @@ public class CrmClueDO extends BaseDO { private String address; /** * 负责人的用户编号 + * + * 关联 AdminUserDO 的 id 字段 */ private Long ownerUserId; /** @@ -79,4 +81,8 @@ public class CrmClueDO extends BaseDO { */ private String remark; + // TODO 芋艿:客户级别; + // TODO 芋艿:线索来源; + // TODO 芋艿:客户行业; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java index ce68734c1..1051b2fcf 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java @@ -1,33 +1,30 @@ package cn.iocoder.yudao.module.crm.service.clue; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - +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.clue.vo.*; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; +import java.util.List; -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_NOT_EXISTS; import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; +// TODO 芋艿:单测后续补; /** * {@link CrmClueServiceImpl} 的单元测试类 * From bee6f41211ce9702aef054e4577d059f9faedd9e Mon Sep 17 00:00:00 2001 From: ljlleo Date: Fri, 20 Oct 2023 16:01:54 +0800 Subject: [PATCH 011/101] =?UTF-8?q?=E5=95=86=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/ErrorCodeConstants.java | 3 + .../admin/business/CrmBusinessController.java | 99 ++++++ .../admin/business/vo/CrmBusinessBaseVO.java | 78 +++++ .../business/vo/CrmBusinessCreateReqVO.java | 14 + .../admin/business/vo/CrmBusinessExcelVO.java | 82 +++++ .../business/vo/CrmBusinessExportReqVO.java | 74 +++++ .../business/vo/CrmBusinessPageReqVO.java | 79 +++++ .../admin/business/vo/CrmBusinessRespVO.java | 19 ++ .../business/vo/CrmBusinessUpdateReqVO.java | 18 ++ .../convert/business/CrmBusinessConvert.java | 34 +++ .../dataobject/business/CrmBusinessDO.java | 101 +++++++ .../dal/mysql/business/CrmBusinessMapper.java | 67 +++++ .../service/business/CrmBusinessService.java | 75 +++++ .../business/CrmBusinessServiceImpl.java | 90 ++++++ .../mapper/business/CrmBusinessMapper.xml | 12 + .../business/CrmBusinessServiceImplTest.java | 283 ++++++++++++++++++ 16 files changed, 1128 insertions(+) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessBaseVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExcelVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExportReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessPageReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/business/CrmBusinessMapper.xml create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 3538b16ee..66f2abc1f 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -15,4 +15,7 @@ public interface ErrorCodeConstants { // TODO @wanwan:要单独一个分段噢 ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_000_001, "线索不存在"); + // ========== 商机管理 1-020-001-000 ========== + ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_001_000, "商机不存在"); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java new file mode 100644 index 000000000..85cc48f79 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java @@ -0,0 +1,99 @@ +package cn.iocoder.yudao.module.crm.controller.admin.business; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +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.business.vo.*; +import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; + +@Tag(name = "管理后台 - 商机") +@RestController +@RequestMapping("/crm/business") +@Validated +public class CrmBusinessController { + + @Resource + private CrmBusinessService businessService; + + @PostMapping("/create") + @Operation(summary = "创建商机") + @PreAuthorize("@ss.hasPermission('crm:business:create')") + public CommonResult createBusiness(@Valid @RequestBody CrmBusinessCreateReqVO createReqVO) { + return success(businessService.createBusiness(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新商机") + @PreAuthorize("@ss.hasPermission('crm:business:update')") + public CommonResult updateBusiness(@Valid @RequestBody CrmBusinessUpdateReqVO updateReqVO) { + businessService.updateBusiness(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除商机") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('crm:business:delete')") + public CommonResult deleteBusiness(@RequestParam("id") Long id) { + businessService.deleteBusiness(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得商机") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('crm:business:query')") + public CommonResult getBusiness(@RequestParam("id") Long id) { + CrmBusinessDO business = businessService.getBusiness(id); + return success(CrmBusinessConvert.INSTANCE.convert(business)); + } + + @GetMapping("/list") + @Operation(summary = "获得商机列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('crm:business:query')") + public CommonResult> getBusinessList(@RequestParam("ids") Collection ids) { + List list = businessService.getBusinessList(ids); + return success(CrmBusinessConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得商机分页") + @PreAuthorize("@ss.hasPermission('crm:business:query')") + public CommonResult> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) { + PageResult pageResult = businessService.getBusinessPage(pageVO); + return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出商机 Excel") + @PreAuthorize("@ss.hasPermission('crm:business:export')") + @OperateLog(type = EXPORT) + public void exportBusinessExcel(@Valid CrmBusinessExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = businessService.getBusinessList(exportReqVO); + // 导出 Excel + List datas = CrmBusinessConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessExcelVO.class, datas); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessBaseVO.java new file mode 100644 index 000000000..7e32feea0 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessBaseVO.java @@ -0,0 +1,78 @@ +package cn.iocoder.yudao.module.crm.controller.admin.business.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * 商机 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class CrmBusinessBaseVO { + + @Schema(description = "商机名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") + @NotNull(message = "商机名称不能为空") + private String name; + + @Schema(description = "商机状态类型编号", example = "25714") + @NotNull(message = "商机状态类型不能为空") + private Long statusTypeId; + + @Schema(description = "商机状态编号", example = "30320") + @NotNull(message = "商机状态不能为空") + private Long statusId; + + @Schema(description = "下次联系时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime contactNextTime; + + @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10299") + @NotNull(message = "客户不能为空") + private Long customerId; + + @Schema(description = "预计成交日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime dealTime; + + @Schema(description = "商机金额", example = "12371") + private BigDecimal price; + + @Schema(description = "整单折扣") + private BigDecimal discountPercent; + + @Schema(description = "产品总金额", example = "12025") + private BigDecimal productPrice; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "负责人的用户编号", example = "25562") + private Long ownerUserId; + + @Schema(description = "只读权限的用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED) + private String roUserIds; + + @Schema(description = "读写权限的用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED) + private String rwUserIds; + + @Schema(description = "1赢单2输单3无效", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Integer endStatus; + + @Schema(description = "结束时的备注", example = "你说的对") + private String endRemark; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime contactLastTime; + + @Schema(description = "跟进状态", example = "1") + private Integer followUpStatus; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java new file mode 100644 index 000000000..a03540cc6 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.crm.controller.admin.business.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 商机创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmBusinessCreateReqVO extends CrmBusinessBaseVO { + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExcelVO.java new file mode 100644 index 000000000..087deafb0 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExcelVO.java @@ -0,0 +1,82 @@ +package cn.iocoder.yudao.module.crm.controller.admin.business.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.math.BigDecimal; +import java.math.BigDecimal; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * 商机 Excel VO + * + * @author ljlleo + */ +@Data +public class CrmBusinessExcelVO { + + @ExcelProperty("主键") + private Long id; + + @ExcelProperty("商机名称") + private String name; + + @ExcelProperty("商机状态类型编号") + private Long statusTypeId; + + @ExcelProperty("商机状态编号") + private Long statusId; + + @ExcelProperty("下次联系时间") + private LocalDateTime contactNextTime; + + @ExcelProperty("客户编号") + private Long customerId; + + @ExcelProperty("预计成交日期") + private LocalDateTime dealTime; + + @ExcelProperty("商机金额") + private BigDecimal price; + + @ExcelProperty("整单折扣") + private BigDecimal discountPercent; + + @ExcelProperty("产品总金额") + private BigDecimal productPrice; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("负责人的用户编号") + private Long ownerUserId; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @ExcelProperty("只读权限的用户编号数组") + private String roUserIds; + + @ExcelProperty("读写权限的用户编号数组") + private String rwUserIds; + + @ExcelProperty("1赢单2输单3无效") + private Integer endStatus; + + @ExcelProperty("结束时的备注") + private String endRemark; + + @ExcelProperty("最后跟进时间") + private LocalDateTime contactLastTime; + + @ExcelProperty("跟进状态") + private Integer followUpStatus; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExportReqVO.java new file mode 100644 index 000000000..a44283112 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExportReqVO.java @@ -0,0 +1,74 @@ +package cn.iocoder.yudao.module.crm.controller.admin.business.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 商机 Excel 导出 Request VO,参数和 CrmBusinessPageReqVO 是一致的") +@Data +public class CrmBusinessExportReqVO { + + @Schema(description = "商机名称", example = "李四") + private String name; + + @Schema(description = "商机状态类型编号", example = "25714") + private Long statusTypeId; + + @Schema(description = "商机状态编号", example = "30320") + private Long statusId; + + @Schema(description = "下次联系时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] contactNextTime; + + @Schema(description = "客户编号", example = "10299") + private Long customerId; + + @Schema(description = "预计成交日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] dealTime; + + @Schema(description = "商机金额", example = "12371") + private BigDecimal price; + + @Schema(description = "整单折扣") + private BigDecimal discountPercent; + + @Schema(description = "产品总金额", example = "12025") + private BigDecimal productPrice; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "负责人的用户编号", example = "25562") + private Long ownerUserId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "只读权限的用户编号数组") + private String roUserIds; + + @Schema(description = "读写权限的用户编号数组") + private String rwUserIds; + + @Schema(description = "1赢单2输单3无效", example = "1") + private Integer endStatus; + + @Schema(description = "结束时的备注", example = "你说的对") + private String endRemark; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] contactLastTime; + + @Schema(description = "跟进状态", example = "1") + private Integer followUpStatus; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessPageReqVO.java new file mode 100644 index 000000000..636661a9f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessPageReqVO.java @@ -0,0 +1,79 @@ +package cn.iocoder.yudao.module.crm.controller.admin.business.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +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.math.BigDecimal; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 商机分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmBusinessPageReqVO extends PageParam { + + @Schema(description = "商机名称", example = "李四") + private String name; + + @Schema(description = "商机状态类型编号", example = "25714") + private Long statusTypeId; + + @Schema(description = "商机状态编号", example = "30320") + private Long statusId; + + @Schema(description = "下次联系时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] contactNextTime; + + @Schema(description = "客户编号", example = "10299") + private Long customerId; + + @Schema(description = "预计成交日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] dealTime; + + @Schema(description = "商机金额", example = "12371") + private BigDecimal price; + + @Schema(description = "整单折扣") + private BigDecimal discountPercent; + + @Schema(description = "产品总金额", example = "12025") + private BigDecimal productPrice; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "负责人的用户编号", example = "25562") + private Long ownerUserId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "只读权限的用户编号数组") + private String roUserIds; + + @Schema(description = "读写权限的用户编号数组") + private String rwUserIds; + + @Schema(description = "1赢单2输单3无效", example = "1") + private Integer endStatus; + + @Schema(description = "结束时的备注", example = "你说的对") + private String endRemark; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] contactLastTime; + + @Schema(description = "跟进状态", example = "1") + private Integer followUpStatus; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessRespVO.java new file mode 100644 index 000000000..672f99ec3 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.crm.controller.admin.business.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 商机 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmBusinessRespVO extends CrmBusinessBaseVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") + private Long id; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java new file mode 100644 index 000000000..8922ec99b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.crm.controller.admin.business.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 商机更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmBusinessUpdateReqVO extends CrmBusinessBaseVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129") + @NotNull(message = "主键不能为空") + private Long id; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java new file mode 100644 index 000000000..aa03ce0f0 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.convert.business; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; + +/** + * 商机 Convert + * + * @author ljlleo + */ +@Mapper +public interface CrmBusinessConvert { + + CrmBusinessConvert INSTANCE = Mappers.getMapper(CrmBusinessConvert.class); + + CrmBusinessDO convert(CrmBusinessCreateReqVO bean); + + CrmBusinessDO convert(CrmBusinessUpdateReqVO bean); + + CrmBusinessRespVO convert(CrmBusinessDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java new file mode 100644 index 000000000..620fb492e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java @@ -0,0 +1,101 @@ +package cn.iocoder.yudao.module.crm.dal.dataobject.business; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 商机 DO + * + * @author ljlleo + */ +@TableName("crm_business") +@KeySequence("crm_business_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CrmBusinessDO extends BaseDO { + + /** + * 主键 + */ + @TableId + private Long id; + /** + * 商机名称 + */ + private String name; + /** + * 商机状态类型编号 + */ + private Long statusTypeId; + /** + * 商机状态编号 + */ + private Long statusId; + /** + * 下次联系时间 + */ + private LocalDateTime contactNextTime; + /** + * 客户编号 + */ + private Long customerId; + /** + * 预计成交日期 + */ + private LocalDateTime dealTime; + /** + * 商机金额 + */ + private BigDecimal price; + /** + * 整单折扣 + */ + private BigDecimal discountPercent; + /** + * 产品总金额 + */ + private BigDecimal productPrice; + /** + * 备注 + */ + private String remark; + /** + * 负责人的用户编号 + */ + private Long ownerUserId; + /** + * 只读权限的用户编号数组 + */ + private String roUserIds; + /** + * 读写权限的用户编号数组 + */ + private String rwUserIds; + /** + * 1赢单2输单3无效 + */ + private Integer endStatus; + /** + * 结束时的备注 + */ + private String endRemark; + /** + * 最后跟进时间 + */ + private LocalDateTime contactLastTime; + /** + * 跟进状态 + */ + private Integer followUpStatus; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java new file mode 100644 index 000000000..aadec8517 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.business; + +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.business.vo.CrmBusinessExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 商机 Mapper + * + * @author ljlleo + */ +@Mapper +public interface CrmBusinessMapper extends BaseMapperX { + + default PageResult selectPage(CrmBusinessPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(CrmBusinessDO::getName, reqVO.getName()) + .eqIfPresent(CrmBusinessDO::getStatusTypeId, reqVO.getStatusTypeId()) + .eqIfPresent(CrmBusinessDO::getStatusId, reqVO.getStatusId()) + .betweenIfPresent(CrmBusinessDO::getContactNextTime, reqVO.getContactNextTime()) + .eqIfPresent(CrmBusinessDO::getCustomerId, reqVO.getCustomerId()) + .betweenIfPresent(CrmBusinessDO::getDealTime, reqVO.getDealTime()) + .eqIfPresent(CrmBusinessDO::getPrice, reqVO.getPrice()) + .eqIfPresent(CrmBusinessDO::getDiscountPercent, reqVO.getDiscountPercent()) + .eqIfPresent(CrmBusinessDO::getProductPrice, reqVO.getProductPrice()) + .eqIfPresent(CrmBusinessDO::getRemark, reqVO.getRemark()) + .eqIfPresent(CrmBusinessDO::getOwnerUserId, reqVO.getOwnerUserId()) + .betweenIfPresent(CrmBusinessDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(CrmBusinessDO::getRoUserIds, reqVO.getRoUserIds()) + .eqIfPresent(CrmBusinessDO::getRwUserIds, reqVO.getRwUserIds()) + .eqIfPresent(CrmBusinessDO::getEndStatus, reqVO.getEndStatus()) + .eqIfPresent(CrmBusinessDO::getEndRemark, reqVO.getEndRemark()) + .betweenIfPresent(CrmBusinessDO::getContactLastTime, reqVO.getContactLastTime()) + .eqIfPresent(CrmBusinessDO::getFollowUpStatus, reqVO.getFollowUpStatus()) + .orderByDesc(CrmBusinessDO::getId)); + } + + default List selectList(CrmBusinessExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .likeIfPresent(CrmBusinessDO::getName, reqVO.getName()) + .eqIfPresent(CrmBusinessDO::getStatusTypeId, reqVO.getStatusTypeId()) + .eqIfPresent(CrmBusinessDO::getStatusId, reqVO.getStatusId()) + .betweenIfPresent(CrmBusinessDO::getContactNextTime, reqVO.getContactNextTime()) + .eqIfPresent(CrmBusinessDO::getCustomerId, reqVO.getCustomerId()) + .betweenIfPresent(CrmBusinessDO::getDealTime, reqVO.getDealTime()) + .eqIfPresent(CrmBusinessDO::getPrice, reqVO.getPrice()) + .eqIfPresent(CrmBusinessDO::getDiscountPercent, reqVO.getDiscountPercent()) + .eqIfPresent(CrmBusinessDO::getProductPrice, reqVO.getProductPrice()) + .eqIfPresent(CrmBusinessDO::getRemark, reqVO.getRemark()) + .eqIfPresent(CrmBusinessDO::getOwnerUserId, reqVO.getOwnerUserId()) + .betweenIfPresent(CrmBusinessDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(CrmBusinessDO::getRoUserIds, reqVO.getRoUserIds()) + .eqIfPresent(CrmBusinessDO::getRwUserIds, reqVO.getRwUserIds()) + .eqIfPresent(CrmBusinessDO::getEndStatus, reqVO.getEndStatus()) + .eqIfPresent(CrmBusinessDO::getEndRemark, reqVO.getEndRemark()) + .betweenIfPresent(CrmBusinessDO::getContactLastTime, reqVO.getContactLastTime()) + .eqIfPresent(CrmBusinessDO::getFollowUpStatus, reqVO.getFollowUpStatus()) + .orderByDesc(CrmBusinessDO::getId)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java new file mode 100644 index 000000000..4bb352c58 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java @@ -0,0 +1,75 @@ +package cn.iocoder.yudao.module.crm.service.business; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessUpdateReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; + +/** + * 商机 Service 接口 + * + * @author ljlleo + */ +public interface CrmBusinessService { + + /** + * 创建商机 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createBusiness(@Valid CrmBusinessCreateReqVO createReqVO); + + /** + * 更新商机 + * + * @param updateReqVO 更新信息 + */ + void updateBusiness(@Valid CrmBusinessUpdateReqVO updateReqVO); + + /** + * 删除商机 + * + * @param id 编号 + */ + void deleteBusiness(Long id); + + /** + * 获得商机 + * + * @param id 编号 + * @return 商机 + */ + CrmBusinessDO getBusiness(Long id); + + /** + * 获得商机列表 + * + * @param ids 编号 + * @return 商机列表 + */ + List getBusinessList(Collection ids); + + /** + * 获得商机分页 + * + * @param pageReqVO 分页查询 + * @return 商机分页 + */ + PageResult getBusinessPage(CrmBusinessPageReqVO pageReqVO); + + /** + * 获得商机列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 商机列表 + */ + List getBusinessList(CrmBusinessExportReqVO exportReqVO); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java new file mode 100644 index 000000000..44fa74f80 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java @@ -0,0 +1,90 @@ +package cn.iocoder.yudao.module.crm.service.business; + +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.business.vo.CrmBusinessCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessUpdateReqVO; +import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; +import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; + +/** + * 商机 Service 实现类 + * + * @author ljlleo + */ +@Service +@Validated +public class CrmBusinessServiceImpl implements CrmBusinessService { + + @Resource + private CrmBusinessMapper businessMapper; + + @Override + public Long createBusiness(CrmBusinessCreateReqVO createReqVO) { + // 插入 + CrmBusinessDO business = CrmBusinessConvert.INSTANCE.convert(createReqVO); + businessMapper.insert(business); + // 返回 + return business.getId(); + } + + @Override + public void updateBusiness(CrmBusinessUpdateReqVO updateReqVO) { + // 校验存在 + validateBusinessExists(updateReqVO.getId()); + // 更新 + CrmBusinessDO updateObj = CrmBusinessConvert.INSTANCE.convert(updateReqVO); + businessMapper.updateById(updateObj); + } + + @Override + public void deleteBusiness(Long id) { + // 校验存在 + validateBusinessExists(id); + // 删除 + businessMapper.deleteById(id); + } + + private void validateBusinessExists(Long id) { + if (businessMapper.selectById(id) == null) { + throw exception(BUSINESS_NOT_EXISTS); + } + } + + @Override + public CrmBusinessDO getBusiness(Long id) { + return businessMapper.selectById(id); + } + + @Override + public List getBusinessList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return businessMapper.selectBatchIds(ids); + } + + @Override + public PageResult getBusinessPage(CrmBusinessPageReqVO pageReqVO) { + return businessMapper.selectPage(pageReqVO); + } + + @Override + public List getBusinessList(CrmBusinessExportReqVO exportReqVO) { + return businessMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/business/CrmBusinessMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/business/CrmBusinessMapper.xml new file mode 100644 index 000000000..c35aafec7 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/business/CrmBusinessMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java new file mode 100644 index 000000000..64d3f1e71 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java @@ -0,0 +1,283 @@ +package cn.iocoder.yudao.module.crm.service.business; + +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.business.vo.CrmBusinessCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessUpdateReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; +import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; +import static org.junit.jupiter.api.Assertions.*; + +/** + * {@link CrmBusinessServiceImpl} 的单元测试类 + * + * @author ljlleo + */ +@Import(CrmBusinessServiceImpl.class) +public class CrmBusinessServiceImplTest extends BaseDbUnitTest { + + @Resource + private CrmBusinessServiceImpl businessService; + + @Resource + private CrmBusinessMapper businessMapper; + + @Test + public void testCreateBusiness_success() { + // 准备参数 + CrmBusinessCreateReqVO reqVO = randomPojo(CrmBusinessCreateReqVO.class); + + // 调用 + Long businessId = businessService.createBusiness(reqVO); + // 断言 + assertNotNull(businessId); + // 校验记录的属性是否正确 + CrmBusinessDO business = businessMapper.selectById(businessId); + assertPojoEquals(reqVO, business); + } + + @Test + public void testUpdateBusiness_success() { + // mock 数据 + CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class); + businessMapper.insert(dbBusiness);// @Sql: 先插入出一条存在的数据 + // 准备参数 + CrmBusinessUpdateReqVO reqVO = randomPojo(CrmBusinessUpdateReqVO.class, o -> { + o.setId(dbBusiness.getId()); // 设置更新的 ID + }); + + // 调用 + businessService.updateBusiness(reqVO); + // 校验是否更新正确 + CrmBusinessDO business = businessMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, business); + } + + @Test + public void testUpdateBusiness_notExists() { + // 准备参数 + CrmBusinessUpdateReqVO reqVO = randomPojo(CrmBusinessUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> businessService.updateBusiness(reqVO), BUSINESS_NOT_EXISTS); + } + + @Test + public void testDeleteBusiness_success() { + // mock 数据 + CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class); + businessMapper.insert(dbBusiness);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbBusiness.getId(); + + // 调用 + businessService.deleteBusiness(id); + // 校验数据不存在了 + assertNull(businessMapper.selectById(id)); + } + + @Test + public void testDeleteBusiness_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> businessService.deleteBusiness(id), BUSINESS_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetBusinessPage() { + // mock 数据 + CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class, o -> { // 等会查询到 + o.setName(null); + o.setStatusTypeId(null); + o.setStatusId(null); + o.setContactNextTime(null); + o.setCustomerId(null); + o.setDealTime(null); + o.setPrice(null); + o.setDiscountPercent(null); + o.setProductPrice(null); + o.setRemark(null); + o.setOwnerUserId(null); + o.setCreateTime(null); + o.setRoUserIds(null); + o.setRwUserIds(null); + o.setEndStatus(null); + o.setEndRemark(null); + o.setContactLastTime(null); + o.setFollowUpStatus(null); + }); + businessMapper.insert(dbBusiness); + // 测试 name 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setName(null))); + // 测试 statusTypeId 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusTypeId(null))); + // 测试 statusId 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusId(null))); + // 测试 contactNextTime 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactNextTime(null))); + // 测试 customerId 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCustomerId(null))); + // 测试 dealTime 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDealTime(null))); + // 测试 price 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setPrice(null))); + // 测试 discountPercent 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDiscountPercent(null))); + // 测试 productPrice 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setProductPrice(null))); + // 测试 remark 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRemark(null))); + // 测试 ownerUserId 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setOwnerUserId(null))); + // 测试 createTime 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCreateTime(null))); + // 测试 roUserIds 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRoUserIds(null))); + // 测试 rwUserIds 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRwUserIds(null))); + // 测试 endStatus 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndStatus(null))); + // 测试 endRemark 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndRemark(null))); + // 测试 contactLastTime 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactLastTime(null))); + // 测试 followUpStatus 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setFollowUpStatus(null))); + // 准备参数 + CrmBusinessPageReqVO reqVO = new CrmBusinessPageReqVO(); + reqVO.setName(null); + reqVO.setStatusTypeId(null); + reqVO.setStatusId(null); + reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setCustomerId(null); + reqVO.setDealTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setPrice(null); + reqVO.setDiscountPercent(null); + reqVO.setProductPrice(null); + reqVO.setRemark(null); + reqVO.setOwnerUserId(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setRoUserIds(null); + reqVO.setRwUserIds(null); + reqVO.setEndStatus(null); + reqVO.setEndRemark(null); + reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setFollowUpStatus(null); + + // 调用 + PageResult pageResult = businessService.getBusinessPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbBusiness, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetBusinessList() { + // mock 数据 + CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class, o -> { // 等会查询到 + o.setName(null); + o.setStatusTypeId(null); + o.setStatusId(null); + o.setContactNextTime(null); + o.setCustomerId(null); + o.setDealTime(null); + o.setPrice(null); + o.setDiscountPercent(null); + o.setProductPrice(null); + o.setRemark(null); + o.setOwnerUserId(null); + o.setCreateTime(null); + o.setRoUserIds(null); + o.setRwUserIds(null); + o.setEndStatus(null); + o.setEndRemark(null); + o.setContactLastTime(null); + o.setFollowUpStatus(null); + }); + businessMapper.insert(dbBusiness); + // 测试 name 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setName(null))); + // 测试 statusTypeId 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusTypeId(null))); + // 测试 statusId 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusId(null))); + // 测试 contactNextTime 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactNextTime(null))); + // 测试 customerId 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCustomerId(null))); + // 测试 dealTime 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDealTime(null))); + // 测试 price 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setPrice(null))); + // 测试 discountPercent 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDiscountPercent(null))); + // 测试 productPrice 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setProductPrice(null))); + // 测试 remark 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRemark(null))); + // 测试 ownerUserId 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setOwnerUserId(null))); + // 测试 createTime 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCreateTime(null))); + // 测试 roUserIds 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRoUserIds(null))); + // 测试 rwUserIds 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRwUserIds(null))); + // 测试 endStatus 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndStatus(null))); + // 测试 endRemark 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndRemark(null))); + // 测试 contactLastTime 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactLastTime(null))); + // 测试 followUpStatus 不匹配 + businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setFollowUpStatus(null))); + // 准备参数 + CrmBusinessExportReqVO reqVO = new CrmBusinessExportReqVO(); + reqVO.setName(null); + reqVO.setStatusTypeId(null); + reqVO.setStatusId(null); + reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setCustomerId(null); + reqVO.setDealTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setPrice(null); + reqVO.setDiscountPercent(null); + reqVO.setProductPrice(null); + reqVO.setRemark(null); + reqVO.setOwnerUserId(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setRoUserIds(null); + reqVO.setRwUserIds(null); + reqVO.setEndStatus(null); + reqVO.setEndRemark(null); + reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setFollowUpStatus(null); + + // 调用 + List list = businessService.getBusinessList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbBusiness, list.get(0)); + } + +} From 01490c879c822f5732c5b9dc55831a002ee10f11 Mon Sep 17 00:00:00 2001 From: ljlleo Date: Fri, 20 Oct 2023 16:14:45 +0800 Subject: [PATCH 012/101] =?UTF-8?q?=E5=95=86=E6=9C=BAsql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 31 +++++++++++++++++++++- sql/mysql/crm_menu.sql | 60 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 6c5594068..24cc3c623 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -60,4 +60,33 @@ CREATE TABLE `crm_clue` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线索表' ROW_FORMAT = Dynamic; \ No newline at end of file +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线索表' ROW_FORMAT = Dynamic; + +DROP TABLE IF EXISTS `crm_business`; +CREATE TABLE `crm_business` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', + `name` varchar(100) NOT NULL COMMENT '商机名称', + `status_type_id` bigint DEFAULT NULL COMMENT '商机状态类型编号', + `status_id` bigint DEFAULT NULL COMMENT '商机状态编号', + `contact_next_time` datetime DEFAULT NULL COMMENT '下次联系时间', + `customer_id` bigint NOT NULL COMMENT '客户编号', + `deal_time` datetime DEFAULT NULL COMMENT '预计成交日期', + `price` decimal(18,2) DEFAULT NULL COMMENT '商机金额', + `discount_percent` decimal(10,2) DEFAULT NULL COMMENT '整单折扣', + `product_price` decimal(18,2) DEFAULT NULL COMMENT '产品总金额', + `remark` varchar(500) DEFAULT NULL COMMENT '备注', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '创建人', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '' COMMENT '更新人', + `owner_user_id` bigint DEFAULT NULL COMMENT '负责人的用户编号', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', + `ro_user_ids` longtext NOT NULL COMMENT '只读权限的用户编号数组', + `rw_user_ids` longtext NOT NULL COMMENT '读写权限的用户编号数组', + `end_status` int NOT NULL COMMENT '1赢单2输单3无效', + `end_remark` varchar(500) DEFAULT NULL COMMENT '结束时的备注', + `deleted` bit(1) DEFAULT b'0' COMMENT '逻辑删除', + `contact_last_time` datetime DEFAULT NULL COMMENT '最后跟进时间', + `follow_up_status` int DEFAULT NULL COMMENT '跟进状态', + `tenant_id` bigint DEFAULT '0' COMMENT '租户ID', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='商机表'; diff --git a/sql/mysql/crm_menu.sql b/sql/mysql/crm_menu.sql index cf0fe00fd..58c2fd194 100644 --- a/sql/mysql/crm_menu.sql +++ b/sql/mysql/crm_menu.sql @@ -117,3 +117,63 @@ VALUES ( '线索导出', 'crm:clue:export', 3, 5, @parentId, '', '', '', 0 ); + +-- ---------------------------- +-- 合同菜单 +-- ---------------------------- + +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '商机管理', '', 2, 0, '', + 'business', '', 'crm/business/index', 0, 'CrmBusiness' + ); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '商机查询', 'crm:business:query', 3, 1, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '商机创建', 'crm:business:create', 3, 2, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '商机更新', 'crm:business:update', 3, 3, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '商机删除', 'crm:business:delete', 3, 4, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '商机导出', 'crm:business:export', 3, 5, @parentId, + '', '', '', 0 + ); From 73f4fc8ceb4adbca1a9b9c75f87f684b7a98aaa6 Mon Sep 17 00:00:00 2001 From: liuhongfeng <291117974@qq.com> Date: Fri, 20 Oct 2023 22:16:34 +0800 Subject: [PATCH 013/101] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91?= =?UTF-8?q?=E5=9B=9E=E6=AC=BE=E7=AE=A1=E7=90=86=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 34 ++- sql/mysql/crm_data.sql | 19 ++ sql/mysql/crm_menu.sql | 69 ++++- .../module/crm/enums/ErrorCodeConstants.java | 2 + .../receivable/ReceivableController.java | 101 +++++++ .../admin/receivable/vo/ReceivableBaseVO.java | 72 +++++ .../receivable/vo/ReceivableCreateReqVO.java | 14 + .../receivable/vo/ReceivableExcelVO.java | 80 +++++ .../receivable/vo/ReceivableExportReqVO.java | 72 +++++ .../receivable/vo/ReceivablePageReqVO.java | 73 +++++ .../admin/receivable/vo/ReceivableRespVO.java | 19 ++ .../receivable/vo/ReceivableUpdateReqVO.java | 18 ++ .../convert/receivable/ReceivableConvert.java | 34 +++ .../dataobject/receivable/ReceivableDO.java | 101 +++++++ .../mysql/receivable/ReceivableMapper.java | 64 ++++ .../service/receivable/ReceivableService.java | 71 +++++ .../receivable/ReceivableServiceImpl.java | 87 ++++++ .../mapper/receivable/ReceivableMapper.xml | 12 + .../receivable/ReceivableServiceImplTest.java | 279 ++++++++++++++++++ .../src/test/resources/sql/clean.sql | 4 +- .../src/test/resources/sql/create_tables.sql | 28 +- 21 files changed, 1249 insertions(+), 4 deletions(-) create mode 100644 sql/mysql/crm_data.sql create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivableConvert.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableService.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivableMapper.xml create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 6c5594068..699f69307 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -60,4 +60,36 @@ CREATE TABLE `crm_clue` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线索表' ROW_FORMAT = Dynamic; \ No newline at end of file +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线索表' ROW_FORMAT = Dynamic; + + +-- ---------------------------- +-- 回款表 +-- ---------------------------- +DROP TABLE IF EXISTS `crm_receivable`; +CREATE TABLE `crm_receivable` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '回款编号', + `plan_id` bigint(20) NULL DEFAULT NULL COMMENT '回款计划ID', + `customer_id` bigint(20) NULL DEFAULT NULL COMMENT '客户ID', + `contract_id` bigint(20) NULL DEFAULT NULL COMMENT '合同ID', + `check_status` tinyint(4) NULL DEFAULT NULL COMMENT '审批状态', + `process_instance_id` bigint(20) NULL DEFAULT NULL COMMENT '工作流编号', + `return_time` datetime NULL DEFAULT NULL COMMENT '回款日期', + `return_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '回款方式', + `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '回款金额', + `owner_user_id` bigint(20) NULL DEFAULT NULL COMMENT '负责人的用户编号', + `batch_id` bigint(20) NULL DEFAULT NULL COMMENT '批次', + `sort` int(11) NULL DEFAULT NULL COMMENT '显示顺序', + `data_scope` tinyint(4) NULL DEFAULT 1 COMMENT '数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)', + `data_scope_dept_ids` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '数据范围(指定部门数组)', + `status` tinyint(4) NOT NULL COMMENT '状态(0正常 1停用)', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '回款管理' ROW_FORMAT = DYNAMIC; diff --git a/sql/mysql/crm_data.sql b/sql/mysql/crm_data.sql new file mode 100644 index 000000000..dfc1135f9 --- /dev/null +++ b/sql/mysql/crm_data.sql @@ -0,0 +1,19 @@ + +INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (184, '回款管理审批状态', 'crm_receivable_check_status', 0, '回款管理审批状态(0 未审核 1 审核通过 2 审核拒绝 3 审核中 4 已撤回)', '1', '2023-10-18 21:44:24', '1', '2023-10-18 21:44:24', b'0', '1970-01-01 00:00:00'); +INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (185, '回款管理-回款方式', 'crm_return_type', 0, '回款管理-回款方式', '1', '2023-10-18 21:54:10', '1', '2023-10-18 21:54:10', b'0', '1970-01-01 00:00:00'); + + +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1389, 0, '未审核', '0', 'crm_receivable_check_status', 0, 'default', '', '0 未审核 ', '1', '2023-10-18 21:46:00', '1', '2023-10-18 21:47:16', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1390, 1, '审核通过', '1', 'crm_receivable_check_status', 0, 'default', '', '1 审核通过', '1', '2023-10-18 21:46:18', '1', '2023-10-18 21:47:08', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1391, 2, '审核拒绝', '2', 'crm_receivable_check_status', 0, 'default', '', ' 2 审核拒绝', '1', '2023-10-18 21:46:58', '1', '2023-10-18 21:47:21', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1392, 3, '审核中', '3', 'crm_receivable_check_status', 0, 'default', '', ' 3 审核中', '1', '2023-10-18 21:47:35', '1', '2023-10-18 21:47:35', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1393, 4, '已撤回', '4', 'crm_receivable_check_status', 0, 'default', '', ' 4 已撤回', '1', '2023-10-18 21:47:46', '1', '2023-10-18 21:47:46', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1394, 1, '支票', '1', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:54:29', '1', '2023-10-18 21:54:29', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1395, 2, '现金', '2', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:54:41', '1', '2023-10-18 21:54:41', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1396, 3, '邮政汇款', '3', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:54:53', '1', '2023-10-18 21:54:53', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1397, 4, '电汇', '4', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:07', '1', '2023-10-18 21:55:07', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1398, 5, '网上转账', '5', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:24', '1', '2023-10-18 21:55:24', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1399, 6, '支付宝', '6', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:38', '1', '2023-10-18 21:55:38', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1400, 7, '微信支付', '7', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:53', '1', '2023-10-18 21:55:53', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1401, 8, '其他', '8', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:56:06', '1', '2023-10-18 21:56:06', b'0'); + diff --git a/sql/mysql/crm_menu.sql b/sql/mysql/crm_menu.sql index cf0fe00fd..25c07c6a8 100644 --- a/sql/mysql/crm_menu.sql +++ b/sql/mysql/crm_menu.sql @@ -8,7 +8,7 @@ INSERT INTO system_menu( path, icon, component, status, component_name ) VALUES ( - '合同管理', '', 2, 0, 1254, + '合同管理', '', 2, 0, 2375, 'contract', '', 'crm/contract/index', 0, 'Contract' ); @@ -117,3 +117,70 @@ VALUES ( '线索导出', 'crm:clue:export', 3, 5, @parentId, '', '', '', 0 ); + + +-- ---------------------------- +-- 客户管理菜单 +-- ---------------------------- +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2375, '客户管理', '', 1, 0, 0, '/crm', 'ep:avatar', '', '', 0, b'1', b'1', b'1', '1', '2023-10-20 00:36:13', '1', '2023-10-19 16:37:24', b'0'); + + +-- ---------------------------- +-- 回款菜单 +-- ---------------------------- + +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '回款管理', '', 2, 0, 2375, + 'receivable', '', 'crm/receivable/index', 0, 'Receivable' + ); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款管理查询', 'crm:receivable:query', 3, 1, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款管理创建', 'crm:receivable:create', 3, 2, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款管理更新', 'crm:receivable:update', 3, 3, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款管理删除', 'crm:receivable:delete', 3, 4, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款管理导出', 'crm:receivable:export', 3, 5, @parentId, + '', '', '', 0 + ); diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 3538b16ee..6c0d03d93 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -15,4 +15,6 @@ public interface ErrorCodeConstants { // TODO @wanwan:要单独一个分段噢 ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_000_001, "线索不存在"); + ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_030_000_001, "回款管理不存在"); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java new file mode 100644 index 000000000..94c3a1c70 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java @@ -0,0 +1,101 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +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.receivable.vo.*; +import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; +import cn.iocoder.yudao.module.crm.service.receivable.ReceivableService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.Collection; +import java.util.List; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; + +/** + * @author 赤焰 + */ +@Tag(name = "管理后台 - 回款管理") +@RestController +@RequestMapping("/crm/receivable") +@Validated +public class ReceivableController { + + @Resource + private ReceivableService receivableService; + + @PostMapping("/create") + @Operation(summary = "创建回款管理") + @PreAuthorize("@ss.hasPermission('crm:receivable:create')") + public CommonResult createReceivable(@Valid @RequestBody ReceivableCreateReqVO createReqVO) { + return success(receivableService.createReceivable(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新回款管理") + @PreAuthorize("@ss.hasPermission('crm:receivable:update')") + public CommonResult updateReceivable(@Valid @RequestBody ReceivableUpdateReqVO updateReqVO) { + receivableService.updateReceivable(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除回款管理") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('crm:receivable:delete')") + public CommonResult deleteReceivable(@RequestParam("id") Long id) { + receivableService.deleteReceivable(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得回款管理") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('crm:receivable:query')") + public CommonResult getReceivable(@RequestParam("id") Long id) { + ReceivableDO receivable = receivableService.getReceivable(id); + return success(ReceivableConvert.INSTANCE.convert(receivable)); + } + + @GetMapping("/list") + @Operation(summary = "获得回款管理列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('crm:receivable:query')") + public CommonResult> getReceivableList(@RequestParam("ids") Collection ids) { + List list = receivableService.getReceivableList(ids); + return success(ReceivableConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得回款管理分页") + @PreAuthorize("@ss.hasPermission('crm:receivable:query')") + public CommonResult> getReceivablePage(@Valid ReceivablePageReqVO pageVO) { + PageResult pageResult = receivableService.getReceivablePage(pageVO); + return success(ReceivableConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出回款管理 Excel") + @PreAuthorize("@ss.hasPermission('crm:receivable:export')") + @OperateLog(type = EXPORT) + public void exportReceivableExcel(@Valid ReceivableExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = receivableService.getReceivableList(exportReqVO); + // 导出 Excel + List datas = ReceivableConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "回款管理.xls", "数据", ReceivableExcelVO.class, datas); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java new file mode 100644 index 000000000..4b63f1466 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java @@ -0,0 +1,72 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * 回款管理 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class ReceivableBaseVO { + + @Schema(description = "回款编号") + private String no; + + @Schema(description = "回款计划ID", example = "31177") + private Long planId; + + @Schema(description = "客户ID", example = "4963") + private Long customerId; + + @Schema(description = "合同ID", example = "30305") + private Long contractId; + + @Schema(description = "审批状态", example = "1") + private Integer checkStatus; + + @Schema(description = "工作流编号", example = "16568") + private Long processInstanceId; + + @Schema(description = "回款日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime returnTime; + + @Schema(description = "回款方式", example = "2") + private String returnType; + + @Schema(description = "回款金额", example = "31859") + private BigDecimal price; + + @Schema(description = "负责人", example = "22202") + private Long ownerUserId; + + @Schema(description = "批次", example = "2539") + private Long batchId; + + @Schema(description = "显示顺序") + private Integer sort; + + @Schema(description = "数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") + private Integer dataScope; + + @Schema(description = "数据范围(指定部门数组)") + private String dataScopeDeptIds; + + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "状态不能为空") + private Integer status; + + @Schema(description = "备注", example = "随便") + private String remark; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java new file mode 100644 index 000000000..5bbb4fce2 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 回款管理创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivableCreateReqVO extends ReceivableBaseVO { + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java new file mode 100644 index 000000000..f60330c53 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java @@ -0,0 +1,80 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + + +/** + * 回款管理 Excel VO + * + * @author 赤焰 + */ +@Data +public class ReceivableExcelVO { + + @ExcelProperty("ID") + private Long id; + + @ExcelProperty("回款编号") + private String no; + + @ExcelProperty("回款计划ID") + private Long planId; + + @ExcelProperty("客户ID") + private Long customerId; + + @ExcelProperty("合同ID") + private Long contractId; + + @ExcelProperty(value = "审批状态", converter = DictConvert.class) + @DictFormat("crm_receivable_check_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private Integer checkStatus; + + @ExcelProperty("工作流编号") + private Long processInstanceId; + + @ExcelProperty("回款日期") + private LocalDateTime returnTime; + + @ExcelProperty("回款方式") + private String returnType; + + @ExcelProperty("回款金额") + private BigDecimal price; + + @ExcelProperty("负责人") + private Long ownerUserId; + + @ExcelProperty("批次") + private Long batchId; + + //@ExcelProperty("显示顺序") + //private Integer sort; + + //@ExcelProperty("数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") + //private Integer dataScope; + + //@ExcelProperty("数据范围(指定部门数组)") + //private String dataScopeDeptIds; + + @ExcelProperty(value = "状态", converter = DictConvert.class) + @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private Integer status; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java new file mode 100644 index 000000000..7ea31a0fb --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java @@ -0,0 +1,72 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * @author 赤焰 + */ +@Schema(description = "管理后台 - 回款管理 Excel 导出 Request VO,参数和 ReceivablePageReqVO 是一致的") +@Data +public class ReceivableExportReqVO { + + @Schema(description = "回款编号") + private String no; + + @Schema(description = "回款计划ID", example = "31177") + private Long planId; + + @Schema(description = "客户ID", example = "4963") + private Long customerId; + + @Schema(description = "合同ID", example = "30305") + private Long contractId; + + @Schema(description = "审批状态", example = "1") + private Integer checkStatus; + + @Schema(description = "工作流编号", example = "16568") + private Long processInstanceId; + + @Schema(description = "回款日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] returnTime; + + @Schema(description = "回款方式", example = "2") + private String returnType; + + @Schema(description = "回款金额", example = "31859") + private BigDecimal price; + + @Schema(description = "负责人", example = "22202") + private Long ownerUserId; + + @Schema(description = "批次", example = "2539") + private Long batchId; + + @Schema(description = "显示顺序") + private Integer sort; + + @Schema(description = "数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") + private Integer dataScope; + + @Schema(description = "数据范围(指定部门数组)") + private String dataScopeDeptIds; + + @Schema(description = "状态", example = "1") + private Integer status; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java new file mode 100644 index 000000000..7b9e9df6d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java @@ -0,0 +1,73 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import lombok.*; + +import java.math.BigDecimal; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +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 = "管理后台 - 回款管理分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivablePageReqVO extends PageParam { + + @Schema(description = "回款编号") + private String no; + + @Schema(description = "回款计划ID", example = "31177") + private Long planId; + + @Schema(description = "客户ID", example = "4963") + private Long customerId; + + @Schema(description = "合同ID", example = "30305") + private Long contractId; + + @Schema(description = "审批状态", example = "1") + private Integer checkStatus; + + @Schema(description = "工作流编号", example = "16568") + private Long processInstanceId; + + @Schema(description = "回款日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] returnTime; + + @Schema(description = "回款方式", example = "2") + private String returnType; + + @Schema(description = "回款金额", example = "31859") + private BigDecimal price; + + @Schema(description = "负责人", example = "22202") + private Long ownerUserId; + + @Schema(description = "批次", example = "2539") + private Long batchId; + + @Schema(description = "显示顺序") + private Integer sort; + + @Schema(description = "数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") + private Integer dataScope; + + @Schema(description = "数据范围(指定部门数组)") + private String dataScopeDeptIds; + + @Schema(description = "状态", example = "1") + private Integer status; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java new file mode 100644 index 000000000..fd26e312e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 回款管理 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivableRespVO extends ReceivableBaseVO { + + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25787") + private Long id; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java new file mode 100644 index 000000000..600b09943 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 回款管理更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivableUpdateReqVO extends ReceivableBaseVO { + + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25787") + @NotNull(message = "ID不能为空") + private Long id; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivableConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivableConvert.java new file mode 100644 index 000000000..7f14aaddd --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivableConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.convert.receivable; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; + +/** + * 回款管理 Convert + * + * @author 赤焰 + */ +@Mapper +public interface ReceivableConvert { + + ReceivableConvert INSTANCE = Mappers.getMapper(ReceivableConvert.class); + + ReceivableDO convert(ReceivableCreateReqVO bean); + + ReceivableDO convert(ReceivableUpdateReqVO bean); + + ReceivableRespVO convert(ReceivableDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java new file mode 100644 index 000000000..561765b09 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java @@ -0,0 +1,101 @@ +package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 回款管理 DO + * + * @author 赤焰 + */ +@TableName("crm_receivable") +@KeySequence("crm_receivable_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ReceivableDO extends BaseDO { + + /** + * ID + */ + @TableId + private Long id; + /** + * 回款编号 + */ + private String no; + /** + * 回款计划ID + */ + private Long planId; + /** + * 客户ID + */ + private Long customerId; + /** + * 合同ID + */ + private Long contractId; + /** + * 审批状态 + * + * 枚举 {@link TODO crm_receivable_check_status 对应的类} + */ + private Integer checkStatus; + /** + * 工作流编号 + */ + private Long processInstanceId; + /** + * 回款日期 + */ + private LocalDateTime returnTime; + /** + * 回款方式 + */ + private String returnType; + /** + * 回款金额 + */ + private BigDecimal price; + /** + * 负责人 + */ + private Long ownerUserId; + /** + * 批次 + */ + private Long batchId; + /** + * 显示顺序 + */ + private Integer sort; + /** + * 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限) + */ + private Integer dataScope; + /** + * 数据范围(指定部门数组) + */ + private String dataScopeDeptIds; + /** + * 状态 + * + * 枚举 {@link TODO common_status 对应的类} + */ + private Integer status; + /** + * 备注 + */ + private String remark; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java new file mode 100644 index 000000000..08031772c --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java @@ -0,0 +1,64 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.receivable; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; + +/** + * 回款管理 Mapper + * + * @author 赤焰 + */ +@Mapper +public interface ReceivableMapper extends BaseMapperX { + + default PageResult selectPage(ReceivablePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(ReceivableDO::getNo, reqVO.getNo()) + .eqIfPresent(ReceivableDO::getPlanId, reqVO.getPlanId()) + .eqIfPresent(ReceivableDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(ReceivableDO::getContractId, reqVO.getContractId()) + .eqIfPresent(ReceivableDO::getCheckStatus, reqVO.getCheckStatus()) + .eqIfPresent(ReceivableDO::getProcessInstanceId, reqVO.getProcessInstanceId()) + .betweenIfPresent(ReceivableDO::getReturnTime, reqVO.getReturnTime()) + .eqIfPresent(ReceivableDO::getReturnType, reqVO.getReturnType()) + .eqIfPresent(ReceivableDO::getPrice, reqVO.getPrice()) + .eqIfPresent(ReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) + .eqIfPresent(ReceivableDO::getBatchId, reqVO.getBatchId()) + .eqIfPresent(ReceivableDO::getSort, reqVO.getSort()) + .eqIfPresent(ReceivableDO::getDataScope, reqVO.getDataScope()) + .eqIfPresent(ReceivableDO::getDataScopeDeptIds, reqVO.getDataScopeDeptIds()) + .eqIfPresent(ReceivableDO::getStatus, reqVO.getStatus()) + .eqIfPresent(ReceivableDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(ReceivableDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(ReceivableDO::getId)); + } + + default List selectList(ReceivableExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(ReceivableDO::getNo, reqVO.getNo()) + .eqIfPresent(ReceivableDO::getPlanId, reqVO.getPlanId()) + .eqIfPresent(ReceivableDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(ReceivableDO::getContractId, reqVO.getContractId()) + .eqIfPresent(ReceivableDO::getCheckStatus, reqVO.getCheckStatus()) + .eqIfPresent(ReceivableDO::getProcessInstanceId, reqVO.getProcessInstanceId()) + .betweenIfPresent(ReceivableDO::getReturnTime, reqVO.getReturnTime()) + .eqIfPresent(ReceivableDO::getReturnType, reqVO.getReturnType()) + .eqIfPresent(ReceivableDO::getPrice, reqVO.getPrice()) + .eqIfPresent(ReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) + .eqIfPresent(ReceivableDO::getBatchId, reqVO.getBatchId()) + .eqIfPresent(ReceivableDO::getSort, reqVO.getSort()) + .eqIfPresent(ReceivableDO::getDataScope, reqVO.getDataScope()) + .eqIfPresent(ReceivableDO::getDataScopeDeptIds, reqVO.getDataScopeDeptIds()) + .eqIfPresent(ReceivableDO::getStatus, reqVO.getStatus()) + .eqIfPresent(ReceivableDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(ReceivableDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(ReceivableDO::getId)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableService.java new file mode 100644 index 000000000..a673ec99e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableService.java @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.crm.service.receivable; + +import java.util.*; +import javax.validation.*; + +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * 回款管理 Service 接口 + * + * @author 赤焰 + */ +public interface ReceivableService { + + /** + * 创建回款管理 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createReceivable(@Valid ReceivableCreateReqVO createReqVO); + + /** + * 更新回款管理 + * + * @param updateReqVO 更新信息 + */ + void updateReceivable(@Valid ReceivableUpdateReqVO updateReqVO); + + /** + * 删除回款管理 + * + * @param id 编号 + */ + void deleteReceivable(Long id); + + /** + * 获得回款管理 + * + * @param id 编号 + * @return 回款管理 + */ + ReceivableDO getReceivable(Long id); + + /** + * 获得回款管理列表 + * + * @param ids 编号 + * @return 回款管理列表 + */ + List getReceivableList(Collection ids); + + /** + * 获得回款管理分页 + * + * @param pageReqVO 分页查询 + * @return 回款管理分页 + */ + PageResult getReceivablePage(ReceivablePageReqVO pageReqVO); + + /** + * 获得回款管理列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 回款管理列表 + */ + List getReceivableList(ReceivableExportReqVO exportReqVO); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java new file mode 100644 index 000000000..2f5abe1fc --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java @@ -0,0 +1,87 @@ +package cn.iocoder.yudao.module.crm.service.receivable; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import java.util.*; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; + +import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; +import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; + +/** + * 回款管理 Service 实现类 + * + * @author 赤焰 + */ +@Service +@Validated +public class ReceivableServiceImpl implements ReceivableService { + + @Resource + private ReceivableMapper receivableMapper; + + @Override + public Long createReceivable(ReceivableCreateReqVO createReqVO) { + // 插入 + ReceivableDO receivable = ReceivableConvert.INSTANCE.convert(createReqVO); + receivableMapper.insert(receivable); + // 返回 + return receivable.getId(); + } + + @Override + public void updateReceivable(ReceivableUpdateReqVO updateReqVO) { + // 校验存在 + validateReceivableExists(updateReqVO.getId()); + // 更新 + ReceivableDO updateObj = ReceivableConvert.INSTANCE.convert(updateReqVO); + receivableMapper.updateById(updateObj); + } + + @Override + public void deleteReceivable(Long id) { + // 校验存在 + validateReceivableExists(id); + // 删除 + receivableMapper.deleteById(id); + } + + private void validateReceivableExists(Long id) { + if (receivableMapper.selectById(id) == null) { + throw exception(RECEIVABLE_NOT_EXISTS); + } + } + + @Override + public ReceivableDO getReceivable(Long id) { + return receivableMapper.selectById(id); + } + + @Override + public List getReceivableList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return receivableMapper.selectBatchIds(ids); + } + + @Override + public PageResult getReceivablePage(ReceivablePageReqVO pageReqVO) { + return receivableMapper.selectPage(pageReqVO); + } + + @Override + public List getReceivableList(ReceivableExportReqVO exportReqVO) { + return receivableMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivableMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivableMapper.xml new file mode 100644 index 000000000..b87beb08f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivableMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java new file mode 100644 index 000000000..3d1b47403 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java @@ -0,0 +1,279 @@ +package cn.iocoder.yudao.module.crm.service.receivable; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; +import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link ReceivableServiceImpl} 的单元测试类 + * + * @author 赤焰 + */ +@Import(ReceivableServiceImpl.class) +public class ReceivableServiceImplTest extends BaseDbUnitTest { + + @Resource + private ReceivableServiceImpl receivableService; + + @Resource + private ReceivableMapper receivableMapper; + + @Test + public void testCreateReceivable_success() { + // 准备参数 + ReceivableCreateReqVO reqVO = randomPojo(ReceivableCreateReqVO.class); + + // 调用 + Long receivableId = receivableService.createReceivable(reqVO); + // 断言 + assertNotNull(receivableId); + // 校验记录的属性是否正确 + ReceivableDO receivable = receivableMapper.selectById(receivableId); + assertPojoEquals(reqVO, receivable); + } + + @Test + public void testUpdateReceivable_success() { + // mock 数据 + ReceivableDO dbReceivable = randomPojo(ReceivableDO.class); + receivableMapper.insert(dbReceivable);// @Sql: 先插入出一条存在的数据 + // 准备参数 + ReceivableUpdateReqVO reqVO = randomPojo(ReceivableUpdateReqVO.class, o -> { + o.setId(dbReceivable.getId()); // 设置更新的 ID + }); + + // 调用 + receivableService.updateReceivable(reqVO); + // 校验是否更新正确 + ReceivableDO receivable = receivableMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, receivable); + } + + @Test + public void testUpdateReceivable_notExists() { + // 准备参数 + ReceivableUpdateReqVO reqVO = randomPojo(ReceivableUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> receivableService.updateReceivable(reqVO), RECEIVABLE_NOT_EXISTS); + } + + @Test + public void testDeleteReceivable_success() { + // mock 数据 + ReceivableDO dbReceivable = randomPojo(ReceivableDO.class); + receivableMapper.insert(dbReceivable);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbReceivable.getId(); + + // 调用 + receivableService.deleteReceivable(id); + // 校验数据不存在了 + assertNull(receivableMapper.selectById(id)); + } + + @Test + public void testDeleteReceivable_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> receivableService.deleteReceivable(id), RECEIVABLE_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetReceivablePage() { + // mock 数据 + ReceivableDO dbReceivable = randomPojo(ReceivableDO.class, o -> { // 等会查询到 + o.setNo(null); + o.setPlanId(null); + o.setCustomerId(null); + o.setContractId(null); + o.setCheckStatus(null); + o.setProcessInstanceId(null); + o.setReturnTime(null); + o.setReturnType(null); + o.setPrice(null); + o.setOwnerUserId(null); + o.setBatchId(null); + o.setSort(null); + o.setDataScope(null); + o.setDataScopeDeptIds(null); + o.setStatus(null); + o.setRemark(null); + o.setCreateTime(null); + }); + receivableMapper.insert(dbReceivable); + // 测试 no 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setNo(null))); + // 测试 planId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPlanId(null))); + // 测试 customerId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCustomerId(null))); + // 测试 contractId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setContractId(null))); + // 测试 checkStatus 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCheckStatus(null))); + // 测试 processInstanceId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setProcessInstanceId(null))); + // 测试 returnTime 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnTime(null))); + // 测试 returnType 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnType(null))); + // 测试 price 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPrice(null))); + // 测试 ownerUserId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setOwnerUserId(null))); + // 测试 batchId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setBatchId(null))); + // 测试 sort 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setSort(null))); + // 测试 dataScope 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScope(null))); + // 测试 dataScopeDeptIds 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScopeDeptIds(null))); + // 测试 status 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setStatus(null))); + // 测试 remark 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setRemark(null))); + // 测试 createTime 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCreateTime(null))); + // 准备参数 + ReceivablePageReqVO reqVO = new ReceivablePageReqVO(); + reqVO.setNo(null); + reqVO.setPlanId(null); + reqVO.setCustomerId(null); + reqVO.setContractId(null); + reqVO.setCheckStatus(null); + reqVO.setProcessInstanceId(null); + reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setReturnType(null); + reqVO.setPrice(null); + reqVO.setOwnerUserId(null); + reqVO.setBatchId(null); + reqVO.setSort(null); + reqVO.setDataScope(null); + reqVO.setDataScopeDeptIds(null); + reqVO.setStatus(null); + reqVO.setRemark(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = receivableService.getReceivablePage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbReceivable, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetReceivableList() { + // mock 数据 + ReceivableDO dbReceivable = randomPojo(ReceivableDO.class, o -> { // 等会查询到 + o.setNo(null); + o.setPlanId(null); + o.setCustomerId(null); + o.setContractId(null); + o.setCheckStatus(null); + o.setProcessInstanceId(null); + o.setReturnTime(null); + o.setReturnType(null); + o.setPrice(null); + o.setOwnerUserId(null); + o.setBatchId(null); + o.setSort(null); + o.setDataScope(null); + o.setDataScopeDeptIds(null); + o.setStatus(null); + o.setRemark(null); + o.setCreateTime(null); + }); + receivableMapper.insert(dbReceivable); + // 测试 no 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setNo(null))); + // 测试 planId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPlanId(null))); + // 测试 customerId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCustomerId(null))); + // 测试 contractId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setContractId(null))); + // 测试 checkStatus 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCheckStatus(null))); + // 测试 processInstanceId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setProcessInstanceId(null))); + // 测试 returnTime 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnTime(null))); + // 测试 returnType 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnType(null))); + // 测试 price 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPrice(null))); + // 测试 ownerUserId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setOwnerUserId(null))); + // 测试 batchId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setBatchId(null))); + // 测试 sort 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setSort(null))); + // 测试 dataScope 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScope(null))); + // 测试 dataScopeDeptIds 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScopeDeptIds(null))); + // 测试 status 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setStatus(null))); + // 测试 remark 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setRemark(null))); + // 测试 createTime 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCreateTime(null))); + // 准备参数 + ReceivableExportReqVO reqVO = new ReceivableExportReqVO(); + reqVO.setNo(null); + reqVO.setPlanId(null); + reqVO.setCustomerId(null); + reqVO.setContractId(null); + reqVO.setCheckStatus(null); + reqVO.setProcessInstanceId(null); + reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setReturnType(null); + reqVO.setPrice(null); + reqVO.setOwnerUserId(null); + reqVO.setBatchId(null); + reqVO.setSort(null); + reqVO.setDataScope(null); + reqVO.setDataScopeDeptIds(null); + reqVO.setStatus(null); + reqVO.setRemark(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + List list = receivableService.getReceivableList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbReceivable, list.get(0)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql index 983e53ab3..97305a2e2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql @@ -1,3 +1,5 @@ DELETE FROM "crm_contract"; -DELETE FROM "crm_clue"; \ No newline at end of file +DELETE FROM "crm_clue"; + +DELETE FROM "crm_receivable"; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql index 816264e66..cdea50a96 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql @@ -46,4 +46,30 @@ CREATE TABLE IF NOT EXISTS "crm_clue" ( "deleted" bit NOT NULL DEFAULT FALSE, "tenant_id" bigint NOT NULL, PRIMARY KEY ("id") -) COMMENT '线索表'; \ No newline at end of file +) COMMENT '线索表'; + +CREATE TABLE IF NOT EXISTS "crm_receivable" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "no" varchar, + "plan_id" bigint, + "customer_id" bigint, + "contract_id" bigint, + "check_status" int, + "process_instance_id" bigint, + "return_time" varchar, + "return_type" varchar, + "price" varchar, + "owner_user_id" bigint, + "batch_id" bigint, + "sort" int, + "data_scope" int, + "data_scope_dept_ids" varchar, + "status" int NOT NULL, + "remark" varchar, + "creator" varchar DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT '回款管理'; From e4943f0dfa547c72eede7a72dc9e93f04a763552 Mon Sep 17 00:00:00 2001 From: zyna Date: Fri, 20 Oct 2023 23:42:22 +0800 Subject: [PATCH 014/101] =?UTF-8?q?crm=E8=81=94=E7=B3=BB=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 26 ++++- .../module/crm/enums/ErrorCodeConstants.java | 1 + .../admin/contact/ContactController.java | 102 ++++++++++++++++++ .../admin/contact/vo/ContactBaseVO.java | 55 ++++++++++ .../admin/contact/vo/ContactCreateReqVO.java | 14 +++ .../admin/contact/vo/ContactExcelVO.java | 59 ++++++++++ .../admin/contact/vo/ContactExportReqVO.java | 55 ++++++++++ .../admin/contact/vo/ContactPageReqVO.java | 57 ++++++++++ .../admin/contact/vo/ContactRespVO.java | 20 ++++ .../admin/contact/vo/ContactUpdateReqVO.java | 17 +++ .../crm/convert/contact/ContactConvert.java | 34 ++++++ .../crm/dal/dataobject/contact/ContactDO.java | 76 +++++++++++++ .../crm/dal/mysql/contact/ContactMapper.java | 54 ++++++++++ .../crm/service/contact/ContactService.java | 70 ++++++++++++ .../service/contact/ContactServiceImpl.java | 88 +++++++++++++++ .../mapper/contact/ContactMapper.xml | 12 +++ 16 files changed, 739 insertions(+), 1 deletion(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExcelVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExportReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/contact/ContactMapper.xml diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 6c5594068..c01abbe54 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -60,4 +60,28 @@ CREATE TABLE `crm_clue` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线索表' ROW_FORMAT = Dynamic; \ No newline at end of file +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线索表' ROW_FORMAT = Dynamic; + +-- `ruoyi-vue-pro`.crm_contact definition + +CREATE TABLE `crm_contact` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', + `name` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '联系人名称', + `next_time` datetime DEFAULT NULL COMMENT '下次联系时间', + `mobile` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机号', + `telephone` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电话', + `email` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电子邮箱', + `post` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '职务', + `customer_id` bigint(20) DEFAULT NULL COMMENT '客户编号', + `address` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址', + `remark` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注', + `creator` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人', + `owner_user_id` bigint DEFAULT NULL COMMENT '负责人用户编号', + `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间', + `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间', + `last_time` timestamp NULL DEFAULT NULL COMMENT '最后跟进时间', + `updater` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人', + `deleted` bit(1) NOT NULL DEFAULT b'0', + `tenant_id` bigint DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='crm联系人'; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 3538b16ee..18c35dda7 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -14,5 +14,6 @@ public interface ErrorCodeConstants { // TODO @wanwan:要单独一个分段噢 ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_000_001, "线索不存在"); + ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_000_002, "线索不存在"); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java new file mode 100644 index 000000000..bafec03c1 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java @@ -0,0 +1,102 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; +import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; +import cn.iocoder.yudao.module.crm.service.contact.ContactService; + +@Tag(name = "管理后台 - crm联系人") +@RestController +@RequestMapping("/crm/contact") +@Validated +public class ContactController { + + @Resource + private ContactService contactService; + + @PostMapping("/create") + @Operation(summary = "创建crm联系人") + @PreAuthorize("@ss.hasPermission('crm:contact:create')") + public CommonResult createContact(@Valid @RequestBody ContactCreateReqVO createReqVO) { + return success(contactService.createContact(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新crm联系人") + @PreAuthorize("@ss.hasPermission('crm:contact:update')") + public CommonResult updateContact(@Valid @RequestBody ContactUpdateReqVO updateReqVO) { + contactService.updateContact(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除crm联系人") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('crm:contact:delete')") + public CommonResult deleteContact(@RequestParam("id") Long id) { + contactService.deleteContact(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得crm联系人") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('crm:contact:query')") + public CommonResult getContact(@RequestParam("id") Long id) { + ContactDO contact = contactService.getContact(id); + return success(ContactConvert.INSTANCE.convert(contact)); + } + + @GetMapping("/list") + @Operation(summary = "获得crm联系人列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('crm:contact:query')") + public CommonResult> getContactList(@RequestParam("ids") Collection ids) { + List list = contactService.getContactList(ids); + return success(ContactConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得crm联系人分页") + @PreAuthorize("@ss.hasPermission('crm:contact:query')") + public CommonResult> getContactPage(@Valid ContactPageReqVO pageVO) { + PageResult pageResult = contactService.getContactPage(pageVO); + return success(ContactConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出crm联系人 Excel") + @PreAuthorize("@ss.hasPermission('crm:contact:export')") + @OperateLog(type = EXPORT) + public void exportContactExcel(@Valid ContactExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = contactService.getContactList(exportReqVO); + // 导出 Excel + List datas = ContactConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "crm联系人.xls", "数据", ContactExcelVO.class, datas); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.java new file mode 100644 index 000000000..5b39c1f41 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * crm联系人 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class ContactBaseVO { + + @Schema(description = "联系人名称", example = "张三") + @NotNull(message = "姓名不能为空") + private String name; + + @Schema(description = "下次联系时间") + private LocalDateTime nextTime; + + @Schema(description = "手机号") + private String mobile; + + @Schema(description = "电话") + private String telephone; + + @Schema(description = "电子邮箱") + private String email; + + @Schema(description = "职务") + private String post; + + @Schema(description = "客户编号", example = "10795") + private Long customerId; + + @Schema(description = "地址") + private String address; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "负责人用户编号", example = "7648") + private Long ownerUserId; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime lastTime; +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java new file mode 100644 index 000000000..424d945dc --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - crm联系人创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ContactCreateReqVO extends ContactBaseVO { + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExcelVO.java new file mode 100644 index 000000000..3ac5f3765 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExcelVO.java @@ -0,0 +1,59 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * crm联系人 Excel VO + * + * @author 芋道源码 + */ +@Data +public class ContactExcelVO { + + @ExcelProperty("主键") + private Long id; + + @ExcelProperty("联系人名称") + private String name; + + @ExcelProperty("下次联系时间") + private LocalDateTime nextTime; + + @ExcelProperty("手机号") + private String mobile; + + @ExcelProperty("电话") + private String telephone; + + @ExcelProperty("电子邮箱") + private String email; + + @ExcelProperty("职务") + private String post; + + @ExcelProperty("客户编号") + private Long customerId; + + @ExcelProperty("地址") + private String address; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("负责人用户编号") + private Long ownerUserId; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @ExcelProperty("最后跟进时间") + private LocalDateTime lastTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExportReqVO.java new file mode 100644 index 000000000..df4bd59e1 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExportReqVO.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import java.time.LocalDateTime; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - crm联系人 Excel 导出 Request VO,参数和 ContactPageReqVO 是一致的") +@Data +public class ContactExportReqVO { + + @Schema(description = "联系人名称", example = "张三") + private String name; + + @Schema(description = "下次联系时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] nextTime; + + @Schema(description = "手机号") + private String mobile; + + @Schema(description = "电话") + private String telephone; + + @Schema(description = "电子邮箱") + private String email; + + @Schema(description = "职务") + private String post; + + @Schema(description = "客户编号", example = "10795") + private Long customerId; + + @Schema(description = "地址") + private String address; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "负责人用户编号", example = "7648") + private Long ownerUserId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] lastTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java new file mode 100644 index 000000000..058483926 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java @@ -0,0 +1,57 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +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 ContactPageReqVO extends PageParam { + + @Schema(description = "联系人名称", example = "张三") + private String name; + + @Schema(description = "下次联系时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] nextTime; + + @Schema(description = "手机号") + private String mobile; + + @Schema(description = "电话") + private String telephone; + + @Schema(description = "电子邮箱") + private String email; + + @Schema(description = "职务") + private String post; + + @Schema(description = "客户编号", example = "10795") + private Long customerId; + + @Schema(description = "地址") + private String address; + + @Schema(description = "备注", example = "你说的对") + private String remark; + + @Schema(description = "负责人用户编号", example = "7648") + private Long ownerUserId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] lastTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactRespVO.java new file mode 100644 index 000000000..acb6a737d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactRespVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - crm联系人 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ContactRespVO extends ContactBaseVO { + + @Schema(description = "主键", example = "23210") + private Long id; + + @Schema(description = "创建时间") + private LocalDateTime createTime; + @Schema(description = "创建人") + private String creator; +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java new file mode 100644 index 000000000..19db67297 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java @@ -0,0 +1,17 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - crm联系人更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ContactUpdateReqVO extends ContactBaseVO { + + @Schema(description = "主键", example = "23210") + private Long id; + +} 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 new file mode 100644 index 000000000..3892806c0 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/contact/ContactConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.convert.contact; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; + +/** + * crm联系人 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface ContactConvert { + + ContactConvert INSTANCE = Mappers.getMapper(ContactConvert.class); + + ContactDO convert(ContactCreateReqVO bean); + + ContactDO convert(ContactUpdateReqVO bean); + + ContactRespVO convert(ContactDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java new file mode 100644 index 000000000..ee735ae61 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java @@ -0,0 +1,76 @@ +package cn.iocoder.yudao.module.crm.dal.dataobject.contact; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * crm联系人 DO + * + * @author 芋道源码 + */ +@TableName("crm_contact") +@KeySequence("crm_contact_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ContactDO extends BaseDO { + + /** + * 主键 + */ + @TableId + private Long id; + /** + * 联系人名称 + */ + private String name; + /** + * 下次联系时间 + */ + private LocalDateTime nextTime; + /** + * 手机号 + */ + private String mobile; + /** + * 电话 + */ + private String telephone; + /** + * 电子邮箱 + */ + private String email; + /** + * 职务 + */ + private String post; + /** + * 客户编号 + */ + private Long customerId; + /** + * 地址 + */ + private String address; + /** + * 备注 + */ + private String remark; + /** + * 负责人用户编号 + */ + private Long ownerUserId; + /** + * 最后跟进时间 + */ + private LocalDateTime lastTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java new file mode 100644 index 000000000..dfefeba5d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.contact; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; + +/** + * crm联系人 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface ContactMapper extends BaseMapperX { + + default PageResult selectPage(ContactPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(ContactDO::getName, reqVO.getName()) + .betweenIfPresent(ContactDO::getNextTime, reqVO.getNextTime()) + .eqIfPresent(ContactDO::getMobile, reqVO.getMobile()) + .eqIfPresent(ContactDO::getTelephone, reqVO.getTelephone()) + .eqIfPresent(ContactDO::getEmail, reqVO.getEmail()) + .eqIfPresent(ContactDO::getPost, reqVO.getPost()) + .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(ContactDO::getAddress, reqVO.getAddress()) + .eqIfPresent(ContactDO::getRemark, reqVO.getRemark()) + .eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId()) + .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime()) + .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime()) + .orderByDesc(ContactDO::getId)); + } + + default List selectList(ContactExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .likeIfPresent(ContactDO::getName, reqVO.getName()) + .betweenIfPresent(ContactDO::getNextTime, reqVO.getNextTime()) + .eqIfPresent(ContactDO::getMobile, reqVO.getMobile()) + .eqIfPresent(ContactDO::getTelephone, reqVO.getTelephone()) + .eqIfPresent(ContactDO::getEmail, reqVO.getEmail()) + .eqIfPresent(ContactDO::getPost, reqVO.getPost()) + .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(ContactDO::getAddress, reqVO.getAddress()) + .eqIfPresent(ContactDO::getRemark, reqVO.getRemark()) + .eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId()) + .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime()) + .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime()) + .orderByDesc(ContactDO::getId)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java new file mode 100644 index 000000000..97a221ee4 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.crm.service.contact; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * crm联系人 Service 接口 + * + * @author 芋道源码 + */ +public interface ContactService { + + /** + * 创建crm联系人 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createContact(@Valid ContactCreateReqVO createReqVO); + + /** + * 更新crm联系人 + * + * @param updateReqVO 更新信息 + */ + void updateContact(@Valid ContactUpdateReqVO updateReqVO); + + /** + * 删除crm联系人 + * + * @param id 编号 + */ + void deleteContact(Long id); + + /** + * 获得crm联系人 + * + * @param id 编号 + * @return crm联系人 + */ + ContactDO getContact(Long id); + + /** + * 获得crm联系人列表 + * + * @param ids 编号 + * @return crm联系人列表 + */ + List getContactList(Collection ids); + + /** + * 获得crm联系人分页 + * + * @param pageReqVO 分页查询 + * @return crm联系人分页 + */ + PageResult getContactPage(ContactPageReqVO pageReqVO); + + /** + * 获得crm联系人列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return crm联系人列表 + */ + List getContactList(ContactExportReqVO exportReqVO); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java new file mode 100644 index 000000000..85ce3c269 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java @@ -0,0 +1,88 @@ +package cn.iocoder.yudao.module.crm.service.contact; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; +import cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; + +/** + * crm联系人 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class ContactServiceImpl implements ContactService { + + @Resource + private ContactMapper contactMapper; + + @Override + public Long createContact(ContactCreateReqVO createReqVO) { + // 插入 + ContactDO contact = ContactConvert.INSTANCE.convert(createReqVO); + contactMapper.insert(contact); + // 返回 + return contact.getId(); + } + + @Override + public void updateContact(ContactUpdateReqVO updateReqVO) { + // 校验存在 + validateContactExists(updateReqVO.getId()); + // 更新 + ContactDO updateObj = ContactConvert.INSTANCE.convert(updateReqVO); + contactMapper.updateById(updateObj); + } + + @Override + public void deleteContact(Long id) { + // 校验存在 + validateContactExists(id); + // 删除 + contactMapper.deleteById(id); + } + + private void validateContactExists(Long id) { + if (contactMapper.selectById(id) == null) { + throw exception(CONTACT_NOT_EXISTS); + } + } + + @Override + public ContactDO getContact(Long id) { + return contactMapper.selectById(id); + } + + @Override + public List getContactList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return contactMapper.selectBatchIds(ids); + } + + @Override + public PageResult getContactPage(ContactPageReqVO pageReqVO) { + return contactMapper.selectPage(pageReqVO); + } + + @Override + public List getContactList(ContactExportReqVO exportReqVO) { + return contactMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/contact/ContactMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/contact/ContactMapper.xml new file mode 100644 index 000000000..e2c69ca78 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/contact/ContactMapper.xml @@ -0,0 +1,12 @@ + + + + + + + From 34a5785768d6f14c0f05ab64c10ef095badfc3c3 Mon Sep 17 00:00:00 2001 From: liuhongfeng <291117974@qq.com> Date: Fri, 20 Oct 2023 23:48:19 +0800 Subject: [PATCH 015/101] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91?= =?UTF-8?q?=E5=9B=9E=E6=AC=BE=E8=AE=A1=E5=88=92=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 35 +++ sql/mysql/crm_menu.sql | 61 +++++ .../module/crm/enums/ErrorCodeConstants.java | 2 + .../receivable/ReceivablePlanController.java | 105 ++++++++ .../receivable/vo/ReceivablePlanBaseVO.java | 68 ++++++ .../vo/ReceivablePlanCreateReqVO.java | 14 ++ .../receivable/vo/ReceivablePlanExcelVO.java | 75 ++++++ .../vo/ReceivablePlanExportReqVO.java | 52 ++++ .../vo/ReceivablePlanPageReqVO.java | 54 ++++ .../receivable/vo/ReceivablePlanRespVO.java | 19 ++ .../vo/ReceivablePlanUpdateReqVO.java | 18 ++ .../receivable/ReceivablePlanConvert.java | 34 +++ .../receivable/ReceivablePlanDO.java | 94 +++++++ .../receivable/ReceivablePlanMapper.java | 52 ++++ .../receivable/ReceivablePlanService.java | 70 ++++++ .../receivable/ReceivablePlanServiceImpl.java | 93 +++++++ .../receivable/ReceivablePlanMapper.xml | 12 + .../ReceivablePlanServiceImplTest.java | 231 ++++++++++++++++++ .../src/test/resources/sql/clean.sql | 2 + .../src/test/resources/sql/create_tables.sql | 25 ++ 20 files changed, 1116 insertions(+) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanCreateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanUpdateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivablePlanConvert.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanService.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivablePlanMapper.xml create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 699f69307..8b3b72645 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -93,3 +93,38 @@ CREATE TABLE `crm_receivable` ( `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '回款管理' ROW_FORMAT = DYNAMIC; + + +-- ---------------------------- +-- 回款计划表 +-- ---------------------------- +DROP TABLE IF EXISTS `crm_receivable_plan`; +CREATE TABLE `crm_receivable_plan` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `index_no` bigint(20) NULL DEFAULT NULL COMMENT '期数', + `receivable_id` bigint(20) NULL DEFAULT NULL COMMENT '回款ID', + `status` tinyint(4) NOT NULL COMMENT '完成状态', + `check_status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '审批状态', + `process_instance_id` bigint(20) NULL DEFAULT NULL COMMENT '工作流编号', + `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '计划回款金额', + `return_time` datetime NULL DEFAULT NULL COMMENT '计划回款日期', + `remind_days` bigint(20) NULL DEFAULT NULL COMMENT '提前几天提醒', + `remind_time` datetime NULL DEFAULT NULL COMMENT '提醒日期', + `customer_id` bigint(20) NULL DEFAULT NULL COMMENT '客户ID', + `contract_id` bigint(20) NULL DEFAULT NULL COMMENT '合同ID', + `owner_user_id` bigint(20) NULL DEFAULT NULL COMMENT '负责人', + `sort` int(11) NULL DEFAULT NULL COMMENT '显示顺序', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '回款计划' ROW_FORMAT = DYNAMIC; + + + + + diff --git a/sql/mysql/crm_menu.sql b/sql/mysql/crm_menu.sql index 25c07c6a8..22680e81b 100644 --- a/sql/mysql/crm_menu.sql +++ b/sql/mysql/crm_menu.sql @@ -184,3 +184,64 @@ VALUES ( '回款管理导出', 'crm:receivable:export', 3, 5, @parentId, '', '', '', 0 ); + + +-- ---------------------------- +-- 回款计划菜单 +-- ---------------------------- + +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '回款计划管理', '', 2, 0, 2375, + 'receivable-plan', '', 'crm/receivablePlan/index', 0, 'ReceivablePlan' + ); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款计划查询', 'crm:receivable-plan:query', 3, 1, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款计划创建', 'crm:receivable-plan:create', 3, 2, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款计划更新', 'crm:receivable-plan:update', 3, 3, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款计划删除', 'crm:receivable-plan:delete', 3, 4, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款计划导出', 'crm:receivable-plan:export', 3, 5, @parentId, + '', '', '', 0 + ); diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 6c0d03d93..c0d996f17 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -17,4 +17,6 @@ public interface ErrorCodeConstants { ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_030_000_001, "回款管理不存在"); + ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_040_000_001, "回款计划不存在"); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java new file mode 100644 index 000000000..ae21a952d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java @@ -0,0 +1,105 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; +import cn.iocoder.yudao.module.crm.convert.receivable.ReceivablePlanConvert; +import cn.iocoder.yudao.module.crm.service.receivable.ReceivablePlanService; + +/** + * @author 赤焰 + */ +@Tag(name = "管理后台 - 回款计划") +@RestController +@RequestMapping("/crm/receivable-plan") +@Validated +public class ReceivablePlanController { + + @Resource + private ReceivablePlanService receivablePlanService; + + @PostMapping("/create") + @Operation(summary = "创建回款计划") + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:create')") + public CommonResult createReceivablePlan(@Valid @RequestBody ReceivablePlanCreateReqVO createReqVO) { + return success(receivablePlanService.createReceivablePlan(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新回款计划") + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:update')") + public CommonResult updateReceivablePlan(@Valid @RequestBody ReceivablePlanUpdateReqVO updateReqVO) { + receivablePlanService.updateReceivablePlan(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除回款计划") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:delete')") + public CommonResult deleteReceivablePlan(@RequestParam("id") Long id) { + receivablePlanService.deleteReceivablePlan(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得回款计划") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") + public CommonResult getReceivablePlan(@RequestParam("id") Long id) { + ReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(id); + return success(ReceivablePlanConvert.INSTANCE.convert(receivablePlan)); + } + + @GetMapping("/list") + @Operation(summary = "获得回款计划列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") + public CommonResult> getReceivablePlanList(@RequestParam("ids") Collection ids) { + List list = receivablePlanService.getReceivablePlanList(ids); + return success(ReceivablePlanConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得回款计划分页") + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") + public CommonResult> getReceivablePlanPage(@Valid ReceivablePlanPageReqVO pageVO) { + PageResult pageResult = receivablePlanService.getReceivablePlanPage(pageVO); + return success(ReceivablePlanConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出回款计划 Excel") + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:export')") + @OperateLog(type = EXPORT) + public void exportReceivablePlanExcel(@Valid ReceivablePlanExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = receivablePlanService.getReceivablePlanList(exportReqVO); + // 导出 Excel + List datas = ReceivablePlanConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "回款计划.xls", "数据", ReceivablePlanExcelVO.class, datas); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java new file mode 100644 index 000000000..638934a8e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java @@ -0,0 +1,68 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * 回款计划 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class ReceivablePlanBaseVO { + + @Schema(description = "期数") + private Long indexNo; + + @Schema(description = "回款ID", example = "19852") + private Long receivableId; + + @Schema(description = "完成状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + //@NotNull(message = "完成状态不能为空") + private Integer status; + + @Schema(description = "审批状态", example = "1") + private String checkStatus; + + @Schema(description = "工作流编号", example = "8909") + private Long processInstanceId; + + @Schema(description = "计划回款金额", example = "29675") + private BigDecimal price; + + @Schema(description = "计划回款日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime returnTime; + + @Schema(description = "提前几天提醒") + private Long remindDays; + + @Schema(description = "提醒日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime remindTime; + + @Schema(description = "客户ID", example = "18026") + private Long customerId; + + @Schema(description = "合同ID", example = "3473") + private Long contractId; + + @Schema(description = "负责人", example = "17828") + private Long ownerUserId; + + @Schema(description = "显示顺序") + private Integer sort; + + @Schema(description = "备注", example = "随便") + private String remark; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanCreateReqVO.java new file mode 100644 index 000000000..0d4fce3c8 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 回款计划创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivablePlanCreateReqVO extends ReceivablePlanBaseVO { + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java new file mode 100644 index 000000000..e12d5a1df --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java @@ -0,0 +1,75 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + + +/** + * 回款计划 Excel VO + * + * @author 芋道源码 + */ +@Data +public class ReceivablePlanExcelVO { + + @ExcelProperty("ID") + private Long id; + + @ExcelProperty("期数") + private Long indexNo; + + @ExcelProperty("回款ID") + private Long receivableId; + + @ExcelProperty(value = "完成状态", converter = DictConvert.class) + @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private Integer status; + + @ExcelProperty(value = "审批状态", converter = DictConvert.class) + @DictFormat("crm_receivable_check_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private String checkStatus; + + //@ExcelProperty("工作流编号") + //private Long processInstanceId; + + @ExcelProperty("计划回款金额") + private BigDecimal price; + + @ExcelProperty("计划回款日期") + private LocalDateTime returnTime; + + @ExcelProperty("提前几天提醒") + private Long remindDays; + + @ExcelProperty("提醒日期") + private LocalDateTime remindTime; + + @ExcelProperty("客户ID") + private Long customerId; + + @ExcelProperty("合同ID") + private Long contractId; + + @ExcelProperty("负责人") + private Long ownerUserId; + + //@ExcelProperty("显示顺序") + //private Integer sort; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java new file mode 100644 index 000000000..ca5d3f553 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java @@ -0,0 +1,52 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import java.time.LocalDateTime; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 回款计划 Excel 导出 Request VO,参数和 ReceivablePlanPageReqVO 是一致的") +@Data +public class ReceivablePlanExportReqVO { + + @Schema(description = "期数") + private Long indexNo; + + @Schema(description = "完成状态", example = "2") + private Integer status; + + @Schema(description = "审批状态", example = "1") + private String checkStatus; + + @Schema(description = "计划回款日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] returnTime; + + @Schema(description = "提前几天提醒") + private Long remindDays; + + @Schema(description = "提醒日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] remindTime; + + @Schema(description = "客户ID", example = "18026") + private Long customerId; + + @Schema(description = "合同ID", example = "3473") + private Long contractId; + + @Schema(description = "负责人", example = "17828") + private Long ownerUserId; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java new file mode 100644 index 000000000..2c1166d1c --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +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 = "管理后台 - 回款计划分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivablePlanPageReqVO extends PageParam { + + @Schema(description = "期数") + private Long indexNo; + + @Schema(description = "完成状态", example = "2") + private Integer status; + + @Schema(description = "审批状态", example = "1") + private String checkStatus; + + @Schema(description = "计划回款日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] returnTime; + + @Schema(description = "提前几天提醒") + private Long remindDays; + + @Schema(description = "提醒日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] remindTime; + + @Schema(description = "客户ID", example = "18026") + private Long customerId; + + @Schema(description = "合同ID", example = "3473") + private Long contractId; + + @Schema(description = "负责人", example = "17828") + private Long ownerUserId; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanRespVO.java new file mode 100644 index 000000000..d96f631de --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 回款计划 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivablePlanRespVO extends ReceivablePlanBaseVO { + + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25153") + private Long id; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanUpdateReqVO.java new file mode 100644 index 000000000..75f4ecca0 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 回款计划更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivablePlanUpdateReqVO extends ReceivablePlanBaseVO { + + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25153") + @NotNull(message = "ID不能为空") + private Long id; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivablePlanConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivablePlanConvert.java new file mode 100644 index 000000000..81ec646f3 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivablePlanConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.convert.receivable; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; + +/** + * 回款计划 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface ReceivablePlanConvert { + + ReceivablePlanConvert INSTANCE = Mappers.getMapper(ReceivablePlanConvert.class); + + ReceivablePlanDO convert(ReceivablePlanCreateReqVO bean); + + ReceivablePlanDO convert(ReceivablePlanUpdateReqVO bean); + + ReceivablePlanRespVO convert(ReceivablePlanDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java new file mode 100644 index 000000000..4447df053 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java @@ -0,0 +1,94 @@ +package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; + +import lombok.*; +import java.util.*; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 回款计划 DO + * + * @author 芋道源码 + */ +@TableName("crm_receivable_plan") +@KeySequence("crm_receivable_plan_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ReceivablePlanDO extends BaseDO { + + /** + * ID + */ + @TableId + private Long id; + /** + * 期数 + */ + private Long indexNo; + /** + * 回款ID + */ + private Long receivableId; + /** + * 完成状态 + * + * 枚举 {@link TODO common_status 对应的类} + */ + private Integer status; + /** + * 审批状态 + * + * 枚举 {@link TODO crm_receivable_check_status 对应的类} + */ + private String checkStatus; + /** + * 工作流编号 + */ + private Long processInstanceId; + /** + * 计划回款金额 + */ + private BigDecimal price; + /** + * 计划回款日期 + */ + private LocalDateTime returnTime; + /** + * 提前几天提醒 + */ + private Long remindDays; + /** + * 提醒日期 + */ + private LocalDateTime remindTime; + /** + * 客户ID + */ + private Long customerId; + /** + * 合同ID + */ + private Long contractId; + /** + * 负责人 + */ + private Long ownerUserId; + /** + * 显示顺序 + */ + private Integer sort; + /** + * 备注 + */ + private String remark; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java new file mode 100644 index 000000000..ac35133a7 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java @@ -0,0 +1,52 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.receivable; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; + +/** + * 回款计划 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface ReceivablePlanMapper extends BaseMapperX { + + default PageResult selectPage(ReceivablePlanPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(ReceivablePlanDO::getIndexNo, reqVO.getIndexNo()) + .eqIfPresent(ReceivablePlanDO::getStatus, reqVO.getStatus()) + .eqIfPresent(ReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus()) + .betweenIfPresent(ReceivablePlanDO::getReturnTime, reqVO.getReturnTime()) + .eqIfPresent(ReceivablePlanDO::getRemindDays, reqVO.getRemindDays()) + .betweenIfPresent(ReceivablePlanDO::getRemindTime, reqVO.getRemindTime()) + .eqIfPresent(ReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(ReceivablePlanDO::getContractId, reqVO.getContractId()) + .eqIfPresent(ReceivablePlanDO::getOwnerUserId, reqVO.getOwnerUserId()) + .eqIfPresent(ReceivablePlanDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(ReceivablePlanDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(ReceivablePlanDO::getId)); + } + + default List selectList(ReceivablePlanExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(ReceivablePlanDO::getIndexNo, reqVO.getIndexNo()) + .eqIfPresent(ReceivablePlanDO::getStatus, reqVO.getStatus()) + .eqIfPresent(ReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus()) + .betweenIfPresent(ReceivablePlanDO::getReturnTime, reqVO.getReturnTime()) + .eqIfPresent(ReceivablePlanDO::getRemindDays, reqVO.getRemindDays()) + .betweenIfPresent(ReceivablePlanDO::getRemindTime, reqVO.getRemindTime()) + .eqIfPresent(ReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(ReceivablePlanDO::getContractId, reqVO.getContractId()) + .eqIfPresent(ReceivablePlanDO::getOwnerUserId, reqVO.getOwnerUserId()) + .eqIfPresent(ReceivablePlanDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(ReceivablePlanDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(ReceivablePlanDO::getId)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanService.java new file mode 100644 index 000000000..163ebc26a --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanService.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.crm.service.receivable; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * 回款计划 Service 接口 + * + * @author 芋道源码 + */ +public interface ReceivablePlanService { + + /** + * 创建回款计划 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createReceivablePlan(@Valid ReceivablePlanCreateReqVO createReqVO); + + /** + * 更新回款计划 + * + * @param updateReqVO 更新信息 + */ + void updateReceivablePlan(@Valid ReceivablePlanUpdateReqVO updateReqVO); + + /** + * 删除回款计划 + * + * @param id 编号 + */ + void deleteReceivablePlan(Long id); + + /** + * 获得回款计划 + * + * @param id 编号 + * @return 回款计划 + */ + ReceivablePlanDO getReceivablePlan(Long id); + + /** + * 获得回款计划列表 + * + * @param ids 编号 + * @return 回款计划列表 + */ + List getReceivablePlanList(Collection ids); + + /** + * 获得回款计划分页 + * + * @param pageReqVO 分页查询 + * @return 回款计划分页 + */ + PageResult getReceivablePlanPage(ReceivablePlanPageReqVO pageReqVO); + + /** + * 获得回款计划列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 回款计划列表 + */ + List getReceivablePlanList(ReceivablePlanExportReqVO exportReqVO); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java new file mode 100644 index 000000000..1a1462388 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java @@ -0,0 +1,93 @@ +package cn.iocoder.yudao.module.crm.service.receivable; + +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.crm.convert.receivable.ReceivablePlanConvert; +import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivablePlanMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; + +/** + * 回款计划 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class ReceivablePlanServiceImpl implements ReceivablePlanService { + + @Resource + private ReceivablePlanMapper receivablePlanMapper; + + @Override + public Long createReceivablePlan(ReceivablePlanCreateReqVO createReqVO) { + // 插入 + ReceivablePlanDO receivablePlan = ReceivablePlanConvert.INSTANCE.convert(createReqVO); + if(ObjectUtil.isNull(receivablePlan.getStatus())){ + receivablePlan.setStatus(CommonStatusEnum.ENABLE.getStatus()); + } + receivablePlanMapper.insert(receivablePlan); + // 返回 + return receivablePlan.getId(); + } + + @Override + public void updateReceivablePlan(ReceivablePlanUpdateReqVO updateReqVO) { + // 校验存在 + validateReceivablePlanExists(updateReqVO.getId()); + // 更新 + ReceivablePlanDO updateObj = ReceivablePlanConvert.INSTANCE.convert(updateReqVO); + receivablePlanMapper.updateById(updateObj); + } + + @Override + public void deleteReceivablePlan(Long id) { + // 校验存在 + validateReceivablePlanExists(id); + // 删除 + receivablePlanMapper.deleteById(id); + } + + private void validateReceivablePlanExists(Long id) { + if (receivablePlanMapper.selectById(id) == null) { + throw exception(RECEIVABLE_PLAN_NOT_EXISTS); + } + } + + @Override + public ReceivablePlanDO getReceivablePlan(Long id) { + return receivablePlanMapper.selectById(id); + } + + @Override + public List getReceivablePlanList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return receivablePlanMapper.selectBatchIds(ids); + } + + @Override + public PageResult getReceivablePlanPage(ReceivablePlanPageReqVO pageReqVO) { + return receivablePlanMapper.selectPage(pageReqVO); + } + + @Override + public List getReceivablePlanList(ReceivablePlanExportReqVO exportReqVO) { + return receivablePlanMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivablePlanMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivablePlanMapper.xml new file mode 100644 index 000000000..f0e4c2e84 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivablePlanMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java new file mode 100644 index 000000000..0d90fd1aa --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java @@ -0,0 +1,231 @@ +package cn.iocoder.yudao.module.crm.service.receivable; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; +import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivablePlanMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link ReceivablePlanServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(ReceivablePlanServiceImpl.class) +public class ReceivablePlanServiceImplTest extends BaseDbUnitTest { + + @Resource + private ReceivablePlanServiceImpl receivablePlanService; + + @Resource + private ReceivablePlanMapper receivablePlanMapper; + + @Test + public void testCreateReceivablePlan_success() { + // 准备参数 + ReceivablePlanCreateReqVO reqVO = randomPojo(ReceivablePlanCreateReqVO.class); + + // 调用 + Long receivablePlanId = receivablePlanService.createReceivablePlan(reqVO); + // 断言 + assertNotNull(receivablePlanId); + // 校验记录的属性是否正确 + ReceivablePlanDO receivablePlan = receivablePlanMapper.selectById(receivablePlanId); + assertPojoEquals(reqVO, receivablePlan); + } + + @Test + public void testUpdateReceivablePlan_success() { + // mock 数据 + ReceivablePlanDO dbReceivablePlan = randomPojo(ReceivablePlanDO.class); + receivablePlanMapper.insert(dbReceivablePlan);// @Sql: 先插入出一条存在的数据 + // 准备参数 + ReceivablePlanUpdateReqVO reqVO = randomPojo(ReceivablePlanUpdateReqVO.class, o -> { + o.setId(dbReceivablePlan.getId()); // 设置更新的 ID + }); + + // 调用 + receivablePlanService.updateReceivablePlan(reqVO); + // 校验是否更新正确 + ReceivablePlanDO receivablePlan = receivablePlanMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, receivablePlan); + } + + @Test + public void testUpdateReceivablePlan_notExists() { + // 准备参数 + ReceivablePlanUpdateReqVO reqVO = randomPojo(ReceivablePlanUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> receivablePlanService.updateReceivablePlan(reqVO), RECEIVABLE_PLAN_NOT_EXISTS); + } + + @Test + public void testDeleteReceivablePlan_success() { + // mock 数据 + ReceivablePlanDO dbReceivablePlan = randomPojo(ReceivablePlanDO.class); + receivablePlanMapper.insert(dbReceivablePlan);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbReceivablePlan.getId(); + + // 调用 + receivablePlanService.deleteReceivablePlan(id); + // 校验数据不存在了 + assertNull(receivablePlanMapper.selectById(id)); + } + + @Test + public void testDeleteReceivablePlan_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> receivablePlanService.deleteReceivablePlan(id), RECEIVABLE_PLAN_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetReceivablePlanPage() { + // mock 数据 + ReceivablePlanDO dbReceivablePlan = randomPojo(ReceivablePlanDO.class, o -> { // 等会查询到 + o.setIndexNo(null); + o.setStatus(null); + o.setCheckStatus(null); + o.setReturnTime(null); + o.setRemindDays(null); + o.setRemindTime(null); + o.setCustomerId(null); + o.setContractId(null); + o.setOwnerUserId(null); + o.setRemark(null); + o.setCreateTime(null); + }); + receivablePlanMapper.insert(dbReceivablePlan); + // 测试 indexNo 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setIndexNo(null))); + // 测试 status 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setStatus(null))); + // 测试 checkStatus 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCheckStatus(null))); + // 测试 returnTime 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setReturnTime(null))); + // 测试 remindDays 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindDays(null))); + // 测试 remindTime 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindTime(null))); + // 测试 customerId 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCustomerId(null))); + // 测试 contractId 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setContractId(null))); + // 测试 ownerUserId 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setOwnerUserId(null))); + // 测试 remark 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemark(null))); + // 测试 createTime 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCreateTime(null))); + // 准备参数 + ReceivablePlanPageReqVO reqVO = new ReceivablePlanPageReqVO(); + reqVO.setIndexNo(null); + reqVO.setStatus(null); + reqVO.setCheckStatus(null); + reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setRemindDays(null); + reqVO.setRemindTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setCustomerId(null); + reqVO.setContractId(null); + reqVO.setOwnerUserId(null); + reqVO.setRemark(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = receivablePlanService.getReceivablePlanPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbReceivablePlan, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetReceivablePlanList() { + // mock 数据 + ReceivablePlanDO dbReceivablePlan = randomPojo(ReceivablePlanDO.class, o -> { // 等会查询到 + o.setIndexNo(null); + o.setStatus(null); + o.setCheckStatus(null); + o.setReturnTime(null); + o.setRemindDays(null); + o.setRemindTime(null); + o.setCustomerId(null); + o.setContractId(null); + o.setOwnerUserId(null); + o.setRemark(null); + o.setCreateTime(null); + }); + receivablePlanMapper.insert(dbReceivablePlan); + // 测试 indexNo 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setIndexNo(null))); + // 测试 status 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setStatus(null))); + // 测试 checkStatus 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCheckStatus(null))); + // 测试 returnTime 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setReturnTime(null))); + // 测试 remindDays 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindDays(null))); + // 测试 remindTime 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindTime(null))); + // 测试 customerId 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCustomerId(null))); + // 测试 contractId 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setContractId(null))); + // 测试 ownerUserId 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setOwnerUserId(null))); + // 测试 remark 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemark(null))); + // 测试 createTime 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCreateTime(null))); + // 准备参数 + ReceivablePlanExportReqVO reqVO = new ReceivablePlanExportReqVO(); + reqVO.setIndexNo(null); + reqVO.setStatus(null); + reqVO.setCheckStatus(null); + reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setRemindDays(null); + reqVO.setRemindTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setCustomerId(null); + reqVO.setContractId(null); + reqVO.setOwnerUserId(null); + reqVO.setRemark(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + List list = receivablePlanService.getReceivablePlanList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbReceivablePlan, list.get(0)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql index 97305a2e2..525391b33 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql @@ -3,3 +3,5 @@ DELETE FROM "crm_contract"; DELETE FROM "crm_clue"; DELETE FROM "crm_receivable"; + +DELETE FROM "crm_receivable_plan"; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql index cdea50a96..8d98883b4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql @@ -73,3 +73,28 @@ CREATE TABLE IF NOT EXISTS "crm_receivable" ( "deleted" bit NOT NULL DEFAULT FALSE, PRIMARY KEY ("id") ) COMMENT '回款管理'; + +CREATE TABLE IF NOT EXISTS "crm_receivable_plan" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "index_no" bigint, + "receivable_id" bigint, + "status" int NOT NULL, + "check_status" varchar, + "process_instance_id" bigint, + "price" varchar, + "return_time" varchar, + "remind_days" bigint, + "remind_time" varchar, + "customer_id" bigint, + "contract_id" bigint, + "owner_user_id" bigint, + "sort" int, + "remark" varchar, + "creator" varchar DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT '回款计划'; + From e4eeaa1d695887434caae1c0c6891424985c884d Mon Sep 17 00:00:00 2001 From: "913752709@qq.com" <913752709@qq.com> Date: Sat, 21 Oct 2023 00:53:18 +0800 Subject: [PATCH 016/101] =?UTF-8?q?feat:=20crm=20=E7=BA=BF=E7=B4=A2?= =?UTF-8?q?=E8=A1=A8=E5=AE=8C=E5=96=84=20review=20=E6=8F=90=E5=88=B0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 40 +++++++++---------- .../common/validation/Telephone.java | 28 +++++++++++++ .../common/validation/TelephoneValidator.java | 25 ++++++++++++ .../module/crm/enums/ErrorCodeConstants.java | 4 +- .../admin/clue/vo/CrmClueBaseVO.java | 27 ++++--------- .../admin/clue/vo/CrmClueExcelVO.java | 9 +++-- .../admin/clue/vo/CrmCluePageReqVO.java | 36 ----------------- .../admin/clue/vo/CrmClueRespVO.java | 8 ++++ .../crm/dal/mysql/clue/CrmClueMapper.java | 8 ---- 9 files changed, 96 insertions(+), 89 deletions(-) create mode 100644 yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/validation/Telephone.java create mode 100644 yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/validation/TelephoneValidator.java diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 6c5594068..f21a9d4b3 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -41,23 +41,23 @@ CREATE TABLE `crm_contract` DROP TABLE IF EXISTS `crm_clue`; CREATE TABLE `crm_clue` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,主键自增', - `transform_status` tinyint NOT NULL COMMENT '转化状态', - `follow_up_status` tinyint NOT NULL COMMENT '跟进状态', - `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '线索名称', - `customer_id` bigint NOT NULL COMMENT '客户id', - `contact_next_time` datetime NULL DEFAULT NULL COMMENT '下次联系时间', - `telephone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '电话', - `mobile` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '手机号', - `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '地址', - `owner_user_id` bigint NULL DEFAULT NULL COMMENT '负责人的用户编号', - `contact_last_time` datetime NULL DEFAULT NULL COMMENT '最后跟进时间', - `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线索表' ROW_FORMAT = Dynamic; \ No newline at end of file + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,主键自增', + `transform_status` tinyint DEFAULT NULL COMMENT '转化状态', + `follow_up_status` tinyint DEFAULT NULL COMMENT '跟进状态', + `name` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '线索名称', + `customer_id` bigint NOT NULL COMMENT '客户id', + `contact_next_time` datetime DEFAULT NULL COMMENT '下次联系时间', + `telephone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电话', + `mobile` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机号', + `address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址', + `owner_user_id` bigint NOT NULL COMMENT '负责人的用户编号', + `contact_last_time` datetime DEFAULT NULL COMMENT '最后跟进时间', + `remark` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB COMMENT = '线索表' ; \ No newline at end of file diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/validation/Telephone.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/validation/Telephone.java new file mode 100644 index 000000000..910601fd0 --- /dev/null +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/validation/Telephone.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.framework.common.validation; + +import javax.validation.Constraint; +import javax.validation.Payload; +import java.lang.annotation.*; + +@Target({ + ElementType.METHOD, + ElementType.FIELD, + ElementType.ANNOTATION_TYPE, + ElementType.CONSTRUCTOR, + ElementType.PARAMETER, + ElementType.TYPE_USE +}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Constraint( + validatedBy = TelephoneValidator.class +) +public @interface Telephone { + + String message() default "电话格式不正确"; + + Class[] groups() default {}; + + Class[] payload() default {}; + +} diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/validation/TelephoneValidator.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/validation/TelephoneValidator.java new file mode 100644 index 000000000..d214cfeef --- /dev/null +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/validation/TelephoneValidator.java @@ -0,0 +1,25 @@ +package cn.iocoder.yudao.framework.common.validation; + +import cn.hutool.core.text.CharSequenceUtil; +import cn.hutool.core.util.PhoneUtil; + +import javax.validation.ConstraintValidator; +import javax.validation.ConstraintValidatorContext; + +public class TelephoneValidator implements ConstraintValidator { + + @Override + public void initialize(Telephone annotation) { + } + + @Override + public boolean isValid(String value, ConstraintValidatorContext context) { + // 如果手机号为空,默认不校验,即校验通过 + if (CharSequenceUtil.isEmpty(value)) { + return true; + } + // 校验手机 + return PhoneUtil.isTel(value) || PhoneUtil.isPhone(value); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 3538b16ee..623c36842 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -12,7 +12,7 @@ public interface ErrorCodeConstants { // ========== 合同管理 1-020-000-000 ========== ErrorCode CONTRACT_NOT_EXISTS = new ErrorCode(1_020_000_000, "合同不存在"); - // TODO @wanwan:要单独一个分段噢 - ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_000_001, "线索不存在"); + // ========== 线索管理 1-020-001-000 ========== + ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在"); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java index 9a36c9175..a0efb99d6 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java @@ -1,10 +1,12 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; import cn.iocoder.yudao.framework.common.validation.Mobile; +import cn.iocoder.yudao.framework.common.validation.Telephone; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; +import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.time.LocalDateTime; @@ -17,44 +19,31 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class CrmClueBaseVO { - // TODO @wanwan:转化状态,新增和修改的时候,应该不传递的哈;而是在未来的时候,才会更新到 - @Schema(description = "转化状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "转化状态不能为空") - private Boolean transformStatus; - - // TODO @wanwan:同 transformStatus - @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "跟进状态不能为空") - private Boolean followUpStatus; - @Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx") - @NotNull(message = "线索名称不能为空") // TODO @wanwan:应该是 NotEmpty 噢。空串都无法接受 + @NotEmpty(message = "线索名称不能为空") private String name; - // TODO @wanwan:中英文之间,要有个空格;例如说,客户 id 不能为空 - @Schema(description = "客户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "520") - @NotNull(message = "客户id不能为空") + @Schema(description = "客户 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "520") + @NotNull(message = "客户不能为空") private Long customerId; @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime contactNextTime; - // TODO @wanwan:@Schema 在 @Mobile 之前,要保持统一的顺序;2)可以加个 @Telephone 的校验格式;应该不是手机的格式哈 - @Mobile(message = "电话格式不正确") @Schema(description = "电话", example = "18000000000") + @Telephone private String telephone; - // TODO @wanwan:@Schema 在 @Mobile 之前,要保持统一的顺序;2)类似 @Mobile 这个提示如果是默认的,就可以不写 message - @Mobile(message = "手机号格式不正确") @Schema(description = "手机号", example = "18000000000") + @Mobile private String mobile; @Schema(description = "地址", example = "北京市海淀区") private String address; @Schema(description = "负责人的用户编号", example = "27199") - // TODO @wanwan:这个是必填字段哈; + @NotNull(message = "负责人不能为空") private Long ownerUserId; @Schema(description = "最后跟进时间") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExcelVO.java index 13bc9c42b..d6457bd56 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueExcelVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; +import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; @@ -12,7 +13,6 @@ import com.alibaba.excel.annotation.ExcelProperty; import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; - /** * 线索 Excel VO * @@ -21,20 +21,21 @@ import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; @Data public class CrmClueExcelVO { - @ExcelProperty("编号,主键自增") + @ExcelProperty("编号") private Long id; @ExcelProperty(value = "转化状态", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + @DictFormat(DictTypeConstants.BOOLEAN_STRING) private Boolean transformStatus; @ExcelProperty(value = "跟进状态", converter = DictConvert.class) - @DictFormat("infra_boolean_string") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + @DictFormat(DictTypeConstants.BOOLEAN_STRING) private Boolean followUpStatus; @ExcelProperty("线索名称") private String name; + // TODO 这里需要导出成客户名称 @ExcelProperty("客户id") private Long customerId; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java index f4cba8fed..fa70be859 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java @@ -5,54 +5,18 @@ 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 = "管理后台 - 线索分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class CrmCluePageReqVO extends PageParam { - - // TODO @wanwan:目前只要支持 name、mobile、telephone 的搜索即可;其它字段应该暂时不需要哈; - - @Schema(description = "转化状态", example = "true") - private Boolean transformStatus; - - @Schema(description = "跟进状态", example = "true") - private Boolean followUpStatus; - @Schema(description = "线索名称", example = "线索xxx") private String name; - @Schema(description = "客户id", example = "520") - private Long customerId; - - @Schema(description = "下次联系时间", example = "2023-10-18 01:00:00") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] contactNextTime; - @Schema(description = "电话", example = "18000000000") private String telephone; @Schema(description = "手机号", example = "18000000000") private String mobile; - - @Schema(description = "地址", example = "北京市海淀区") - private String address; - - @Schema(description = "负责人的用户编号", example = "27199") - private Long ownerUserId; - - @Schema(description = "最后跟进时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] contactLastTime; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java index 60eb2939b..6d2d30334 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueRespVO.java @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; + +import javax.validation.constraints.NotNull; import java.time.LocalDateTime; @Schema(description = "管理后台 - 线索 Response VO") @@ -16,4 +18,10 @@ public class CrmClueRespVO extends CrmClueBaseVO { @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) private LocalDateTime createTime; + @Schema(description = "转化状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + private Boolean transformStatus; + + @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + private Boolean followUpStatus; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java index 044615bcf..8437337f4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java @@ -19,17 +19,9 @@ public interface CrmClueMapper extends BaseMapperX { default PageResult selectPage(CrmCluePageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CrmClueDO::getTransformStatus, reqVO.getTransformStatus()) - .eqIfPresent(CrmClueDO::getFollowUpStatus, reqVO.getFollowUpStatus()) .likeIfPresent(CrmClueDO::getName, reqVO.getName()) - .eqIfPresent(CrmClueDO::getCustomerId, reqVO.getCustomerId()) - .betweenIfPresent(CrmClueDO::getContactNextTime, reqVO.getContactNextTime()) .likeIfPresent(CrmClueDO::getTelephone, reqVO.getTelephone()) .likeIfPresent(CrmClueDO::getMobile, reqVO.getMobile()) - .likeIfPresent(CrmClueDO::getAddress, reqVO.getAddress()) - .eqIfPresent(CrmClueDO::getOwnerUserId, reqVO.getOwnerUserId()) - .betweenIfPresent(CrmClueDO::getContactLastTime, reqVO.getContactLastTime()) - .betweenIfPresent(CrmClueDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(CrmClueDO::getId)); } From 6f8fd383f7f6989616594966918f318c8d6f31fb Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 21 Oct 2023 21:35:35 +0800 Subject: [PATCH 017/101] =?UTF-8?q?code=20review=EF=BC=9ACRM=20=E5=95=86?= =?UTF-8?q?=E6=9C=BA=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/business/CrmBusinessController.java | 10 ---------- .../admin/business/vo/CrmBusinessBaseVO.java | 11 ++++++++++ .../business/vo/CrmBusinessCreateReqVO.java | 8 +++++--- .../business/vo/CrmBusinessPageReqVO.java | 2 ++ .../business/vo/CrmBusinessUpdateReqVO.java | 10 +++++++--- .../convert/business/CrmBusinessConvert.java | 2 -- .../dataobject/business/CrmBusinessDO.java | 20 +++++++++++++++++++ 7 files changed, 45 insertions(+), 18 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java index 85cc48f79..b622f23c3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java @@ -19,7 +19,6 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; -import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -67,15 +66,6 @@ public class CrmBusinessController { return success(CrmBusinessConvert.INSTANCE.convert(business)); } - @GetMapping("/list") - @Operation(summary = "获得商机列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('crm:business:query')") - public CommonResult> getBusinessList(@RequestParam("ids") Collection ids) { - List list = businessService.getBusinessList(ids); - return success(CrmBusinessConvert.INSTANCE.convertList(list)); - } - @GetMapping("/page") @Operation(summary = "获得商机分页") @PreAuthorize("@ss.hasPermission('crm:business:query')") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessBaseVO.java index 7e32feea0..061929ae6 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessBaseVO.java @@ -21,10 +21,12 @@ public class CrmBusinessBaseVO { @NotNull(message = "商机名称不能为空") private String name; + // TODO @ljileo:要写 requiredMode = Schema.RequiredMode.REQUIRED @Schema(description = "商机状态类型编号", example = "25714") @NotNull(message = "商机状态类型不能为空") private Long statusTypeId; + // TODO @ljileo:要写 requiredMode = Schema.RequiredMode.REQUIRED @Schema(description = "商机状态编号", example = "30320") @NotNull(message = "商机状态不能为空") private Long statusId; @@ -41,9 +43,11 @@ public class CrmBusinessBaseVO { @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime dealTime; + // TODO @ljileo:金额使用 Integer 类型,转换成分 @Schema(description = "商机金额", example = "12371") private BigDecimal price; + // TODO @ljileo:折扣使用 Integer 类型,存储时,默认 * 100;展示的时候,前端需要 / 100;避免精度丢失问题 @Schema(description = "整单折扣") private BigDecimal discountPercent; @@ -53,25 +57,32 @@ public class CrmBusinessBaseVO { @Schema(description = "备注", example = "随便") private String remark; + // TODO @ljileo:这个新建和修改的时候,应该不传递哈;应该新建的人,就是它的负责人 @Schema(description = "负责人的用户编号", example = "25562") private Long ownerUserId; + // TODO @ljileo:这个新建和修改的时候,应该不传递哈 @Schema(description = "只读权限的用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED) private String roUserIds; + // TODO @ljileo:这个新建和修改的时候,应该不传递哈 @Schema(description = "读写权限的用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED) private String rwUserIds; + // TODO @lijieo:新建的时候,不传递这个字段哈; @Schema(description = "1赢单2输单3无效", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") private Integer endStatus; + // TODO @lijieo:新建的时候,不传递这个字段哈; @Schema(description = "结束时的备注", example = "你说的对") private String endRemark; + // TODO @lijieo:新建的时候,不传递这个字段哈; @Schema(description = "最后跟进时间") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime contactLastTime; + // TODO @lijieo:新建的时候,不传递这个字段哈; @Schema(description = "跟进状态", example = "1") private Integer followUpStatus; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java index a03540cc6..f743c8469 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java @@ -1,9 +1,9 @@ package cn.iocoder.yudao.module.crm.controller.admin.business.vo; -import lombok.*; -import java.util.*; import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; @Schema(description = "管理后台 - 商机创建 Request VO") @Data @@ -11,4 +11,6 @@ import javax.validation.constraints.*; @ToString(callSuper = true) public class CrmBusinessCreateReqVO extends CrmBusinessBaseVO { + // TODO @ljileo:新建的时候,应该可以传递添加的产品; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessPageReqVO.java index 636661a9f..99a41d597 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessPageReqVO.java @@ -18,6 +18,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class CrmBusinessPageReqVO extends PageParam { + // TODO @ljileo:目前就使用 name 检索即可; + @Schema(description = "商机名称", example = "李四") private String name; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java index 8922ec99b..f137d4c5b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java @@ -1,9 +1,11 @@ package cn.iocoder.yudao.module.crm.controller.admin.business.vo; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import javax.validation.constraints.NotNull; @Schema(description = "管理后台 - 商机更新 Request VO") @Data @@ -15,4 +17,6 @@ public class CrmBusinessUpdateReqVO extends CrmBusinessBaseVO { @NotNull(message = "主键不能为空") private Long id; + // TODO @ljileo:修改的时候,应该可以传递添加的产品; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java index aa03ce0f0..72aad68de 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java @@ -25,8 +25,6 @@ public interface CrmBusinessConvert { CrmBusinessRespVO convert(CrmBusinessDO bean); - List convertList(List list); - PageResult convertPage(PageResult page); List convertList02(List list); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java index 620fb492e..795ddad39 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java @@ -35,10 +35,14 @@ public class CrmBusinessDO extends BaseDO { private String name; /** * 商机状态类型编号 + * + * TODO @ljileo:这个字段,后续要写下关联的实体哈 */ private Long statusTypeId; /** * 商机状态编号 + * + * TODO @ljileo:这个字段,后续要写下关联的实体哈 */ private Long statusId; /** @@ -47,6 +51,8 @@ public class CrmBusinessDO extends BaseDO { private LocalDateTime contactNextTime; /** * 客户编号 + * + * TODO @ljileo:这个字段,后续要写下关联的实体哈 */ private Long customerId; /** @@ -55,14 +61,20 @@ public class CrmBusinessDO extends BaseDO { private LocalDateTime dealTime; /** * 商机金额 + * + * TODO @lijie:Integer */ private BigDecimal price; /** * 整单折扣 + * + * TODO @lijie:Integer */ private BigDecimal discountPercent; /** * 产品总金额 + * + * TODO @lijie:Integer */ private BigDecimal productPrice; /** @@ -75,14 +87,20 @@ public class CrmBusinessDO extends BaseDO { private Long ownerUserId; /** * 只读权限的用户编号数组 + * + * TODO @lijie:应该是 List,然后使用下对应的 typehandler */ private String roUserIds; /** * 读写权限的用户编号数组 + * + * TODO @lijie:应该是 List,然后使用下对应的 typehandler */ private String rwUserIds; /** * 1赢单2输单3无效 + * + * TODO @lijie:搞个枚举; */ private Integer endStatus; /** @@ -95,6 +113,8 @@ public class CrmBusinessDO extends BaseDO { private LocalDateTime contactLastTime; /** * 跟进状态 + * + * TODO @lijie:目前就是 Boolean;是否跟进 */ private Integer followUpStatus; From f942e2c7f27529ddda2728e131559507b85fcc07 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 21 Oct 2023 21:55:21 +0800 Subject: [PATCH 018/101] =?UTF-8?q?code=20review=EF=BC=9ACRM=20=E5=9B=9E?= =?UTF-8?q?=E6=AC=BE=E8=AE=A1=E5=88=92=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../receivable/ReceivableController.java | 13 +---- .../receivable/ReceivablePlanController.java | 47 +++++++------------ .../admin/receivable/vo/ReceivableBaseVO.java | 20 +++++--- .../receivable/vo/ReceivablePageReqVO.java | 12 +++-- .../receivable/vo/ReceivablePlanBaseVO.java | 18 ++++--- .../vo/ReceivablePlanPageReqVO.java | 10 ++-- .../dataobject/receivable/ReceivableDO.java | 19 ++++++-- .../receivable/ReceivablePlanServiceImpl.java | 38 ++++++++------- .../receivable/ReceivableServiceImpl.java | 34 ++++++++------ .../ReceivablePlanServiceImplTest.java | 37 +++++++-------- .../receivable/ReceivableServiceImplTest.java | 37 +++++++-------- 11 files changed, 147 insertions(+), 138 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java index 94c3a1c70..564e06bdb 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; 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.receivable.vo.*; @@ -18,9 +19,8 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; -import java.util.Collection; import java.util.List; -import cn.iocoder.yudao.framework.common.pojo.PageResult; + import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; @@ -69,15 +69,6 @@ public class ReceivableController { return success(ReceivableConvert.INSTANCE.convert(receivable)); } - @GetMapping("/list") - @Operation(summary = "获得回款管理列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('crm:receivable:query')") - public CommonResult> getReceivableList(@RequestParam("ids") Collection ids) { - List list = receivableService.getReceivableList(ids); - return success(ReceivableConvert.INSTANCE.convertList(list)); - } - @GetMapping("/page") @Operation(summary = "获得回款管理分页") @PreAuthorize("@ss.hasPermission('crm:receivable:query')") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java index ae21a952d..9bf8d916a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java @@ -1,32 +1,28 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable; -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - +import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; import cn.iocoder.yudao.module.crm.convert.receivable.ReceivablePlanConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; import cn.iocoder.yudao.module.crm.service.receivable.ReceivablePlanService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; /** * @author 赤焰 @@ -73,15 +69,6 @@ public class ReceivablePlanController { return success(ReceivablePlanConvert.INSTANCE.convert(receivablePlan)); } - @GetMapping("/list") - @Operation(summary = "获得回款计划列表") - @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") - @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") - public CommonResult> getReceivablePlanList(@RequestParam("ids") Collection ids) { - List list = receivablePlanService.getReceivablePlanList(ids); - return success(ReceivablePlanConvert.INSTANCE.convertList(list)); - } - @GetMapping("/page") @Operation(summary = "获得回款计划分页") @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java index 4b63f1466..bb0bc5745 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java @@ -1,14 +1,12 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotNull; import java.math.BigDecimal; import java.time.LocalDateTime; -import java.time.LocalDateTime; -import javax.validation.constraints.*; -import org.springframework.format.annotation.DateTimeFormat; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -19,9 +17,13 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class ReceivableBaseVO { + // TODO @liuhongfeng:部分缺少 example 的字段,要补充下; + // TODO @liuhongfeng:部分字段,需要必传,要写 requiredMode = Schema.RequiredMode.REQUIRED,以及对应的 validator 非空校验 + @Schema(description = "回款编号") private String no; + // TODO @liuhongfeng:中英文之间,有个空格,这样更干净; @Schema(description = "回款计划ID", example = "31177") private Long planId; @@ -31,9 +33,12 @@ public class ReceivableBaseVO { @Schema(description = "合同ID", example = "30305") private Long contractId; + // TODO @liuhongfeng:这个字段,可以写个枚举,然后 InEnum 去校验下; + // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的 @Schema(description = "审批状态", example = "1") private Integer checkStatus; + // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; @Schema(description = "工作流编号", example = "16568") private Long processInstanceId; @@ -44,6 +49,7 @@ public class ReceivableBaseVO { @Schema(description = "回款方式", example = "2") private String returnType; + // TODO @liuhongfeng:使用 Int 哈,分; @Schema(description = "回款金额", example = "31859") private BigDecimal price; @@ -56,12 +62,14 @@ public class ReceivableBaseVO { @Schema(description = "显示顺序") private Integer sort; + // TODO @芋艿:这个字段在看看;dataScope、dataScopeDeptIds @Schema(description = "数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") private Integer dataScope; @Schema(description = "数据范围(指定部门数组)") private String dataScopeDeptIds; + // TODO @liuhongfeng:这个字段,这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @NotNull(message = "状态不能为空") private Integer status; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java index 7b9e9df6d..7abd7cb39 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java @@ -1,12 +1,13 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; -import lombok.*; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +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.math.BigDecimal; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -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; @@ -17,6 +18,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class ReceivablePageReqVO extends PageParam { + // TODO @liuhongfeng:目前就使用 no 检索即可; @Schema(description = "回款编号") private String no; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java index 638934a8e..59f333e4b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java @@ -1,15 +1,11 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + import java.math.BigDecimal; import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import javax.validation.constraints.*; -import org.springframework.format.annotation.DateTimeFormat; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -20,9 +16,11 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class ReceivablePlanBaseVO { + // TODO 芋艿:这个字段,在想想命名; @Schema(description = "期数") private Long indexNo; + // TODO @liuhongfeng:中英文之间,有个空格,这样更干净; @Schema(description = "回款ID", example = "19852") private Long receivableId; @@ -30,12 +28,16 @@ public class ReceivablePlanBaseVO { //@NotNull(message = "完成状态不能为空") private Integer status; + // TODO @liuhongfeng:这个字段,可以写个枚举,然后 InEnum 去校验下; + // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的 @Schema(description = "审批状态", example = "1") private String checkStatus; + // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; @Schema(description = "工作流编号", example = "8909") private Long processInstanceId; + // TODO @liuhongfeng:使用 Int 哈,分; @Schema(description = "计划回款金额", example = "29675") private BigDecimal price; @@ -43,6 +45,7 @@ public class ReceivablePlanBaseVO { @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime returnTime; + // TODO @liuhongfeng:这个字段,Integer @Schema(description = "提前几天提醒") private Long remindDays; @@ -56,6 +59,7 @@ public class ReceivablePlanBaseVO { @Schema(description = "合同ID", example = "3473") private Long contractId; + // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; @Schema(description = "负责人", example = "17828") private Long ownerUserId; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java index 2c1166d1c..2d0e7d5ae 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java @@ -1,10 +1,12 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; import cn.iocoder.yudao.framework.common.pojo.PageParam; +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; @@ -15,6 +17,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class ReceivablePlanPageReqVO extends PageParam { + // TODO 芋艿:筛选字段,需要去掉几个,在想想; + @Schema(description = "期数") private Long indexNo; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java index 561765b09..d80f76a91 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java @@ -1,13 +1,13 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; -import java.util.*; -import java.time.LocalDateTime; + import java.math.BigDecimal; import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; /** * 回款管理 DO @@ -35,14 +35,20 @@ public class ReceivableDO extends BaseDO { private String no; /** * 回款计划ID + * + * TODO @liuhongfeng:这个字段,后续要写下关联的实体哈 */ private Long planId; /** * 客户ID + * + * TODO @liuhongfeng:这个字段,后续要写下关联的实体哈 */ private Long customerId; /** * 合同ID + * + * TODO @liuhongfeng:这个字段,后续要写下关联的实体哈 */ private Long contractId; /** @@ -53,6 +59,8 @@ public class ReceivableDO extends BaseDO { private Integer checkStatus; /** * 工作流编号 + * + * TODO @liuhongfeng:这个字段,后续要写下关联的实体哈 */ private Long processInstanceId; /** @@ -79,6 +87,7 @@ public class ReceivableDO extends BaseDO { * 显示顺序 */ private Integer sort; + // TODO 芋艿:dataScope、dataScopeDeptIds 在想下; /** * 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限) */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java index 1a1462388..c0b236ac0 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java @@ -1,24 +1,26 @@ package cn.iocoder.yudao.module.crm.service.receivable; -import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; - -import java.util.*; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import cn.iocoder.yudao.module.crm.convert.receivable.ReceivablePlanConvert; -import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivablePlanMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; - import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanUpdateReqVO; +import cn.iocoder.yudao.module.crm.convert.receivable.ReceivablePlanConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; +import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivablePlanMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_PLAN_NOT_EXISTS; /** * 回款计划 Service 实现类 @@ -36,6 +38,7 @@ public class ReceivablePlanServiceImpl implements ReceivablePlanService { public Long createReceivablePlan(ReceivablePlanCreateReqVO createReqVO) { // 插入 ReceivablePlanDO receivablePlan = ReceivablePlanConvert.INSTANCE.convert(createReqVO); + // TODO @liuhongfeng:空格要注释;if (ObjectUtil.isNull(receivablePlan.getStatus())) { if(ObjectUtil.isNull(receivablePlan.getStatus())){ receivablePlan.setStatus(CommonStatusEnum.ENABLE.getStatus()); } @@ -48,6 +51,7 @@ public class ReceivablePlanServiceImpl implements ReceivablePlanService { public void updateReceivablePlan(ReceivablePlanUpdateReqVO updateReqVO) { // 校验存在 validateReceivablePlanExists(updateReqVO.getId()); + // 更新 ReceivablePlanDO updateObj = ReceivablePlanConvert.INSTANCE.convert(updateReqVO); receivablePlanMapper.updateById(updateObj); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java index 2f5abe1fc..94b25f6ed 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java @@ -1,21 +1,24 @@ package cn.iocoder.yudao.module.crm.service.receivable; -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import java.util.*; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; - -import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; -import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; - 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.receivable.vo.ReceivableCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableUpdateReqVO; +import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; +import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_NOT_EXISTS; /** * 回款管理 Service 实现类 @@ -31,6 +34,8 @@ public class ReceivableServiceImpl implements ReceivableService { @Override public Long createReceivable(ReceivableCreateReqVO createReqVO) { + // TODO @liuhongfeng:planId 是否存在,是否合法,需要去校验; + // TODO @liuhongfeng:其它类似 customerId、contractId 也需要去校验; // 插入 ReceivableDO receivable = ReceivableConvert.INSTANCE.convert(createReqVO); receivableMapper.insert(receivable); @@ -42,6 +47,7 @@ public class ReceivableServiceImpl implements ReceivableService { public void updateReceivable(ReceivableUpdateReqVO updateReqVO) { // 校验存在 validateReceivableExists(updateReqVO.getId()); + // 更新 ReceivableDO updateObj = ReceivableConvert.INSTANCE.convert(updateReqVO); receivableMapper.updateById(updateObj); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java index 0d90fd1aa..3739481c0 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java @@ -1,33 +1,30 @@ package cn.iocoder.yudao.module.crm.service.receivable; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - +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.receivable.vo.*; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanUpdateReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivablePlanMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; +import java.util.List; -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_PLAN_NOT_EXISTS; import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; +// TODO 芋艿:后续,需要补充测试用例 /** * {@link ReceivablePlanServiceImpl} 的单元测试类 * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java index 3d1b47403..b8d4018b4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java @@ -1,33 +1,30 @@ package cn.iocoder.yudao.module.crm.service.receivable; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.mock.mockito.MockBean; - -import javax.annotation.Resource; - +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.receivable.vo.*; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableUpdateReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; -import cn.iocoder.yudao.framework.common.pojo.PageResult; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; import javax.annotation.Resource; -import org.springframework.context.annotation.Import; -import java.util.*; -import java.time.LocalDateTime; +import java.util.List; -import static cn.hutool.core.util.RandomUtil.*; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; -import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; -import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_NOT_EXISTS; import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.*; +// TODO 芋艿:等实现完,在校验下; /** * {@link ReceivableServiceImpl} 的单元测试类 * From b5560fa0be71cdbda972fdc2d14510638a7ef6a1 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 21 Oct 2023 22:05:37 +0800 Subject: [PATCH 019/101] =?UTF-8?q?code=20review=EF=BC=9ACRM=20=E7=BA=BF?= =?UTF-8?q?=E7=B4=A2=E8=A1=A8=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/ErrorCodeConstants.java | 4 +-- .../admin/clue/vo/CrmCluePageReqVO.java | 2 ++ .../admin/clue/vo/CrmClueUpdateReqVO.java | 12 ++++--- .../crm/convert/clue/CrmClueConvert.java | 2 -- .../crm/dal/dataobject/clue/CrmClueDO.java | 9 ++--- .../crm/service/clue/CrmClueServiceImpl.java | 35 +++++++++++-------- .../service/clue/CrmClueServiceImplTest.java | 8 ----- 7 files changed, 34 insertions(+), 38 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 8a412a7e4..ace351d3b 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -15,8 +15,8 @@ public interface ErrorCodeConstants { // ========== 线索管理 1-020-001-000 ========== ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在"); - // ========== 商机管理 1-020-001-000 ========== - ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_001_000, "商机不存在"); + // ========== 商机管理 1-020-002-000 ========== + ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); // TODO @liuhongfeng:错误码分段; ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_030_000_001, "回款管理不存在"); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java index fa70be859..4d28ebc73 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmCluePageReqVO.java @@ -11,6 +11,7 @@ import lombok.ToString; @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class CrmCluePageReqVO extends PageParam { + @Schema(description = "线索名称", example = "线索xxx") private String name; @@ -19,4 +20,5 @@ public class CrmCluePageReqVO extends PageParam { @Schema(description = "手机号", example = "18000000000") private String mobile; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java index 2a264de97..4526fbd2b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueUpdateReqVO.java @@ -1,9 +1,11 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue.vo; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import javax.validation.constraints.NotNull; @Schema(description = "管理后台 - 线索更新 Request VO") @Data @@ -11,8 +13,8 @@ import javax.validation.constraints.*; @ToString(callSuper = true) public class CrmClueUpdateReqVO extends CrmClueBaseVO { - @Schema(description = "编号,主键自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969") - @NotNull(message = "编号,主键自增不能为空") + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969") + @NotNull(message = "编号不能为空") private Long id; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java index 144a77da6..76ea428c7 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/clue/CrmClueConvert.java @@ -25,8 +25,6 @@ public interface CrmClueConvert { CrmClueRespVO convert(CrmClueDO bean); - List convertList(List list); - PageResult convertPage(PageResult page); List convertList02(List list); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java index de30e1301..f9eee5b09 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java @@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.sun.xml.bind.v2.TODO; import lombok.*; import java.time.LocalDateTime; @@ -32,14 +31,10 @@ public class CrmClueDO extends BaseDO { private Long id; /** * 转化状态 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} */ private Boolean transformStatus; /** * 跟进状态 - * - * 枚举 {@link TODO infra_boolean_string 对应的类} */ private Boolean followUpStatus; /** @@ -47,7 +42,9 @@ public class CrmClueDO extends BaseDO { */ private String name; /** - * 客户id + * 客户 id + * + * // TODO @wanwan:要写下关联的实体,以及对应的属性哈 */ private Long customerId; /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java index 92193361f..5e461ff87 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java @@ -1,22 +1,24 @@ package cn.iocoder.yudao.module.crm.service.clue; -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; - -import java.util.*; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; -import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; - 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.clue.vo.CrmClueCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO; +import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; +import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_NOT_EXISTS; /** * 线索 Service 实现类 @@ -32,6 +34,7 @@ public class CrmClueServiceImpl implements CrmClueService { @Override public Long createClue(CrmClueCreateReqVO createReqVO) { + // TODO @wanwan:校验客户是否存在;以及类似的逻辑哈;如果目前还缺对应的模块的 service,可以先给自己写 todo; // 插入 CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO); clueMapper.insert(clue); @@ -41,8 +44,10 @@ public class CrmClueServiceImpl implements CrmClueService { @Override public void updateClue(CrmClueUpdateReqVO updateReqVO) { + // TODO @wanwan:校验客户是否存在;以及类似的逻辑哈;如果目前还缺对应的模块的 service,可以先给自己写 todo; // 校验存在 validateClueExists(updateReqVO.getId()); + // 更新 CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO); clueMapper.updateById(updateObj); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java index 1051b2fcf..63a838164 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java @@ -144,17 +144,9 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setCreateTime(null))); // 准备参数 CrmCluePageReqVO reqVO = new CrmCluePageReqVO(); - reqVO.setTransformStatus(null); - reqVO.setFollowUpStatus(null); reqVO.setName(null); - reqVO.setCustomerId(null); - reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); reqVO.setTelephone(null); reqVO.setMobile(null); - reqVO.setAddress(null); - reqVO.setOwnerUserId(null); - reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); // 调用 PageResult pageResult = clueService.getCluePage(reqVO); From 55f9e0131c85f27a65d3a2404866543630076f8d Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 21 Oct 2023 22:20:00 +0800 Subject: [PATCH 020/101] =?UTF-8?q?code=20review=EF=BC=9ACRM=20=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E8=81=94=E7=B3=BB=E4=BA=BA=E7=9A=84=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/contact/vo/ContactBaseVO.java | 18 ++++++---- .../admin/contact/vo/ContactPageReqVO.java | 10 ++++-- .../crm/dal/dataobject/contact/ContactDO.java | 18 ++++++---- .../service/contact/ContactServiceImpl.java | 35 +++++++++++-------- 4 files changed, 50 insertions(+), 31 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.java index 5b39c1f41..0f9da5c06 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactBaseVO.java @@ -1,14 +1,12 @@ package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import javax.validation.constraints.*; +import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; /** @@ -18,6 +16,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class ContactBaseVO { + // TODO @zyna:部分字段,缺少 example,需要补充; + @Schema(description = "联系人名称", example = "张三") @NotNull(message = "姓名不能为空") private String name; @@ -25,18 +25,22 @@ public class ContactBaseVO { @Schema(description = "下次联系时间") private LocalDateTime nextTime; + // TODO @zyna:缺少 validator 的校验 @Schema(description = "手机号") private String mobile; + // TODO @zyna:缺少 validator 的校验 @Schema(description = "电话") private String telephone; + // TODO @zyna:缺少 validator 的校验 @Schema(description = "电子邮箱") private String email; @Schema(description = "职务") private String post; + // TODO @zyna:非空校验 @Schema(description = "客户编号", example = "10795") private Long customerId; @@ -46,10 +50,12 @@ public class ContactBaseVO { @Schema(description = "备注", example = "你说的对") private String remark; + // TODO @zyna:这个新建的时候,应该不会传递;而是后端默认设置自己为负责人; @Schema(description = "负责人用户编号", example = "7648") private Long ownerUserId; @Schema(description = "最后跟进时间") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime lastTime; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java index 058483926..31ad2a1fb 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java @@ -1,10 +1,12 @@ package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; -import lombok.*; -import java.util.*; -import io.swagger.v3.oas.annotations.media.Schema; import cn.iocoder.yudao.framework.common.pojo.PageParam; +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; @@ -15,6 +17,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class ContactPageReqVO extends PageParam { + // TODO @芋艿:需要查询的字段; + @Schema(description = "联系人名称", example = "张三") private String name; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java index ee735ae61..2e7d2cfef 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java @@ -1,15 +1,15 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.contact; -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import com.baomidou.mybatisplus.annotation.*; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +import java.time.LocalDateTime; /** - * crm联系人 DO + * crm 联系人 DO * * @author 芋道源码 */ @@ -54,6 +54,8 @@ public class ContactDO extends BaseDO { private String post; /** * 客户编号 + * + * TODO @zyna:关联的字段,也要写下 */ private Long customerId; /** @@ -66,6 +68,8 @@ public class ContactDO extends BaseDO { private String remark; /** * 负责人用户编号 + * + * TODO @zyna:关联的字段,也要写下 */ private Long ownerUserId; /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java index 85ce3c269..b21fee020 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java @@ -1,22 +1,24 @@ package cn.iocoder.yudao.module.crm.service.contact; -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; - -import java.util.*; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; -import cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; - 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.contact.vo.ContactCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactUpdateReqVO; +import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; +import cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_NOT_EXISTS; /** * crm联系人 Service 实现类 @@ -32,6 +34,7 @@ public class ContactServiceImpl implements ContactService { @Override public Long createContact(ContactCreateReqVO createReqVO) { + // TODO @customerId:需要校验存在 // 插入 ContactDO contact = ContactConvert.INSTANCE.convert(createReqVO); contactMapper.insert(contact); @@ -43,6 +46,8 @@ public class ContactServiceImpl implements ContactService { public void updateContact(ContactUpdateReqVO updateReqVO) { // 校验存在 validateContactExists(updateReqVO.getId()); + // TODO @customerId:需要校验存在 + // 更新 ContactDO updateObj = ContactConvert.INSTANCE.convert(updateReqVO); contactMapper.updateById(updateObj); From 918ffc40aec60f1481896c14a8e67f6df0a07d9e Mon Sep 17 00:00:00 2001 From: zyna Date: Sun, 22 Oct 2023 16:40:57 +0800 Subject: [PATCH 021/101] =?UTF-8?q?crm=E8=81=94=E7=B3=BB=E4=BA=BA=E5=89=8D?= =?UTF-8?q?=E7=AB=AFinit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm_menu.sql | 55 +++ yudao-ui-admin/src/api/crm/contact/contact.js | 54 +++ .../src/views/crm/contact/index.vue | 316 ++++++++++++++++++ 3 files changed, 425 insertions(+) create mode 100644 yudao-ui-admin/src/api/crm/contact/contact.js create mode 100644 yudao-ui-admin/src/views/crm/contact/index.vue diff --git a/sql/mysql/crm_menu.sql b/sql/mysql/crm_menu.sql index d85c9496b..d3ef9418a 100644 --- a/sql/mysql/crm_menu.sql +++ b/sql/mysql/crm_menu.sql @@ -117,6 +117,61 @@ VALUES ( '线索导出', 'crm:clue:export', 3, 5, @parentId, '', '', '', 0 ); +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '联系人', '', 2, 0, ${table.parentMenuId}, + 'contact', '', 'crm/contact/index', 0, 'Contact' + ); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '联系人查询', 'crm:contact:query', 3, 1, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '联系人创建', 'crm:contact:create', 3, 2, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '联系人更新', 'crm:contact:update', 3, 3, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '联系人删除', 'crm:contact:delete', 3, 4, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '联系人导出', 'crm:contact:export', 3, 5, @parentId, + '', '', '', 0 + ); -- ---------------------------- -- 合同菜单 diff --git a/yudao-ui-admin/src/api/crm/contact/contact.js b/yudao-ui-admin/src/api/crm/contact/contact.js new file mode 100644 index 000000000..fd6e0c1ee --- /dev/null +++ b/yudao-ui-admin/src/api/crm/contact/contact.js @@ -0,0 +1,54 @@ +import request from '@/utils/request' + +// 创建crm联系人 +export function createContact(data) { + return request({ + url: '/crm/contact/create', + method: 'post', + data: data + }) +} + +// 更新crm联系人 +export function updateContact(data) { + return request({ + url: '/crm/contact/update', + method: 'put', + data: data + }) +} + +// 删除crm联系人 +export function deleteContact(id) { + return request({ + url: '/crm/contact/delete?id=' + id, + method: 'delete' + }) +} + +// 获得crm联系人 +export function getContact(id) { + return request({ + url: '/crm/contact/get?id=' + id, + method: 'get' + }) +} + +// 获得crm联系人分页 +export function getContactPage(query) { + return request({ + url: '/crm/contact/page', + method: 'get', + params: query + }) +} + +// 导出crm联系人 Excel +export function exportContactExcel(query) { + return request({ + url: '/crm/contact/export-excel', + method: 'get', + params: query, + responseType: 'blob' + }) +} diff --git a/yudao-ui-admin/src/views/crm/contact/index.vue b/yudao-ui-admin/src/views/crm/contact/index.vue new file mode 100644 index 000000000..acde3615d --- /dev/null +++ b/yudao-ui-admin/src/views/crm/contact/index.vue @@ -0,0 +1,316 @@ + + + From 04613af0cd9c7a547b6a9b3e838808963c672d3e Mon Sep 17 00:00:00 2001 From: Wanwan <913752709@qq.com> Date: Wed, 25 Oct 2023 00:25:00 +0800 Subject: [PATCH 022/101] =?UTF-8?q?feat:=20=E5=AE=A2=E6=88=B7=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=20crud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 32 ++++ sql/mysql/crm_menu.sql | 60 +++++++ .../module/crm/enums/ErrorCodeConstants.java | 3 + .../admin/customer/CrmCustomerController.java | 81 ++++++++- .../admin/customer/vo/CrmCustomerBaseVO.java | 72 ++++++++ .../customer/vo/CrmCustomerCreateReqVO.java | 20 +++ .../admin/customer/vo/CrmCustomerExcelVO.java | 74 ++++++++ .../customer/vo/CrmCustomerExportReqVO.java | 22 +++ .../customer/vo/CrmCustomerPageReqVO.java | 27 +++ .../admin/customer/vo/CrmCustomerRespVO.java | 25 +++ .../customer/vo/CrmCustomerUpdateReqVO.java | 26 +++ .../convert/customer/CrmCustomerConvert.java | 34 ++++ .../dataobject/customer/CrmCustomerDO.java | 107 +++++++++++ .../dal/mysql/customer/CrmCustomerMapper.java | 39 ++++ .../service/customer/CrmCustomerService.java | 75 ++++++++ .../customer/CrmCustomerServiceImpl.java | 88 +++++++++ .../mapper/customer/CrmCustomerMapper.xml | 12 ++ .../customer/CrmCustomerServiceImplTest.java | 170 ++++++++++++++++++ .../src/test/resources/sql/clean.sql | 2 + .../src/test/resources/sql/create_tables.sql | 27 +++ 20 files changed, 989 insertions(+), 7 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/customer/CrmCustomerMapper.xml create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 73cf99490..fc819787a 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -180,3 +180,35 @@ CREATE TABLE `crm_contact` ( `tenant_id` bigint DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='crm联系人'; + +-- ---------------------------- +-- 客户表 +-- ---------------------------- +CREATE TABLE `crm_customer` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,主键自增', + `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '客户名称', + `follow_up_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '跟进状态', + `lock_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '锁定状态', + `deal_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '成交状态', + `mobile` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机', + `telephone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电话', + `website` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '网址', + `remark` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注', + `owner_user_id` bigint DEFAULT NULL COMMENT '负责人的用户编号', + `ro_user_ids` varchar(4096) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '只读权限的用户编号数组', + `rw_user_ids` varchar(4096) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '读写权限的用户编号数组', + `area_id` bigint DEFAULT NULL COMMENT '地区编号', + `detail_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '详细地址', + `longitude` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地理位置经度', + `latitude` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地理位置维度', + `contact_last_time` datetime DEFAULT NULL COMMENT '最后跟进时间', + `contact_next_time` datetime DEFAULT NULL COMMENT '下次联系时间', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号', + PRIMARY KEY (`id`), + KEY `owner_user_id` (`owner_user_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='客户表'; \ No newline at end of file diff --git a/sql/mysql/crm_menu.sql b/sql/mysql/crm_menu.sql index d85c9496b..ec30b2dea 100644 --- a/sql/mysql/crm_menu.sql +++ b/sql/mysql/crm_menu.sql @@ -305,3 +305,63 @@ VALUES ( '回款计划导出', 'crm:receivable-plan:export', 3, 5, @parentId, '', '', '', 0 ); + +-- ---------------------------- +-- 客户管理菜单 +-- ---------------------------- + +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '客户管理', '', 2, 0, 2375, + 'customer', '', 'crm/customer/index', 0, 'CrmCustomer' +); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '客户查询', 'crm:customer:query', 3, 1, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '客户创建', 'crm:customer:create', 3, 2, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '客户更新', 'crm:customer:update', 3, 3, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '客户删除', 'crm:customer:delete', 3, 4, @parentId, + '', '', '', 0 +); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '客户导出', 'crm:customer:export', 3, 5, @parentId, + '', '', '', 0 +); diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 07d9b6d6a..37443fbc8 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -26,4 +26,7 @@ public interface ErrorCodeConstants { ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_040_000_001, "回款计划不存在"); + // ========== 客户管理 1_020_006_000 ========== + ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_020_006_000, "客户不存在"); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java index b5aee837e..7c91b4c1a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java @@ -1,23 +1,90 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +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.customer.vo.*; +import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.Collection; +import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -@Tag(name = "管理后台 - 客户信息") +@Tag(name = "管理后台 - 客户") @RestController @RequestMapping("/crm/customer") @Validated public class CrmCustomerController { - @GetMapping("/test") - public CommonResult test() { - return success("hello"); + @Resource + private CrmCustomerService customerService; + + @PostMapping("/create") + @Operation(summary = "创建客户") + @PreAuthorize("@ss.hasPermission('crm:customer:create')") + public CommonResult createCustomer(@Valid @RequestBody CrmCustomerCreateReqVO createReqVO) { + return success(customerService.createCustomer(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新客户") + @PreAuthorize("@ss.hasPermission('crm:customer:update')") + public CommonResult updateCustomer(@Valid @RequestBody CrmCustomerUpdateReqVO updateReqVO) { + customerService.updateCustomer(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除客户") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('crm:customer:delete')") + public CommonResult deleteCustomer(@RequestParam("id") Long id) { + customerService.deleteCustomer(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得客户") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('crm:customer:query')") + public CommonResult getCustomer(@RequestParam("id") Long id) { + CrmCustomerDO customer = customerService.getCustomer(id); + return success(CrmCustomerConvert.INSTANCE.convert(customer)); + } + + @GetMapping("/page") + @Operation(summary = "获得客户分页") + @PreAuthorize("@ss.hasPermission('crm:customer:query')") + public CommonResult> getCustomerPage(@Valid CrmCustomerPageReqVO pageVO) { + PageResult pageResult = customerService.getCustomerPage(pageVO); + return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出客户 Excel") + @PreAuthorize("@ss.hasPermission('crm:customer:export')") + @OperateLog(type = EXPORT) + public void exportCustomerExcel(@Valid CrmCustomerExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = customerService.getCustomerList(exportReqVO); + // 导出 Excel + List datas = CrmCustomerConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerExcelVO.class, datas); } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java new file mode 100644 index 000000000..039cda53a --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java @@ -0,0 +1,72 @@ +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; + +import cn.iocoder.yudao.framework.common.validation.Mobile; +import cn.iocoder.yudao.framework.common.validation.Telephone; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * 客户 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class CrmCustomerBaseVO { + + @Schema(description = "客户名称", example = "赵六") + @NotEmpty(message = "客户名称不能为空") + private String name; + + @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @NotNull(message = "跟进状态不能为空") + private Boolean followUpStatus; + + @Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + @NotNull(message = "锁定状态不能为空") + private Boolean lockStatus; + + @Schema(description = "手机", example = "18000000000") + @Mobile + private String mobile; + + @Schema(description = "电话", example = "18000000000") + @Telephone + private String telephone; + + @Schema(description = "网址", example = "https://www.baidu.com") + private String website; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "负责人的用户编号", example = "25682") + @NotNull(message = "负责人不能为空") + private Long ownerUserId; + + @Schema(description = "地区编号", example = "20158") + private Long areaId; + + @Schema(description = "详细地址", example = "北京市海淀区") + private String detailAddress; + + @Schema(description = "地理位置经度", example = "116.40341") + private String longitude; + + @Schema(description = "地理位置维度", example = "39.92409") + private String latitude; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime contactLastTime; + + @Schema(description = "下次联系时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime contactNextTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java new file mode 100644 index 000000000..dae9cf212 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - 客户创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmCustomerCreateReqVO extends CrmCustomerBaseVO { + + @Schema(description = "只读权限的用户编号数组") + private String roUserIds; + + @Schema(description = "读写权限的用户编号数组") + private String rwUserIds; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java new file mode 100644 index 000000000..6cf7cbd0f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java @@ -0,0 +1,74 @@ +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; + +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +import java.time.LocalDateTime; + + +/** + * 客户 Excel VO + * + * @author Wanwan + */ +@Data +public class CrmCustomerExcelVO { + + @ExcelProperty("编号") + private Long id; + + @ExcelProperty("客户名称") + private String name; + + @ExcelProperty(value = "跟进状态", converter = DictConvert.class) + @DictFormat(DictTypeConstants.BOOLEAN_STRING) + private Boolean followUpStatus; + + @ExcelProperty(value = "锁定状态", converter = DictConvert.class) + @DictFormat(DictTypeConstants.BOOLEAN_STRING) + private Boolean lockStatus; + + @ExcelProperty(value = "成交状态", converter = DictConvert.class) + @DictFormat(DictTypeConstants.BOOLEAN_STRING) + private Boolean dealStatus; + + @ExcelProperty("手机") + private String mobile; + + @ExcelProperty("电话") + private String telephone; + + @ExcelProperty("网址") + private String website; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("负责人的用户编号") + private Long ownerUserId; + + @ExcelProperty("地区编号") + private Long areaId; + + @ExcelProperty("详细地址") + private String detailAddress; + + @ExcelProperty("地理位置经度") + private String longitude; + + @ExcelProperty("地理位置维度") + private String latitude; + + @ExcelProperty("最后跟进时间") + private LocalDateTime contactLastTime; + + @ExcelProperty("下次联系时间") + private LocalDateTime contactNextTime; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java new file mode 100644 index 000000000..27198ff0d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理后台 - 客户 Excel 导出 Request VO,参数和 CrmCustomerPageReqVO 是一致的") +@Data +public class CrmCustomerExportReqVO { + + @Schema(description = "客户名称", example = "赵六") + private String name; + + @Schema(description = "手机", example = "18000000000") + private String mobile; + + @Schema(description = "电话", example = "18000000000") + private String telephone; + + @Schema(description = "网址", example = "https://www.baidu.com") + private String website; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java new file mode 100644 index 000000000..3871e422d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - 客户分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmCustomerPageReqVO extends PageParam { + + @Schema(description = "客户名称", example = "赵六") + private String name; + + @Schema(description = "手机", example = "18000000000") + private String mobile; + + @Schema(description = "电话", example = "18000000000") + private String telephone; + + @Schema(description = "网址", example = "https://www.baidu.com") + private String website; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java new file mode 100644 index 000000000..b5c9850bc --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java @@ -0,0 +1,25 @@ +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 客户 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmCustomerRespVO extends CrmCustomerBaseVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") + private Long id; + + @Schema(description = "成交状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + private Boolean dealStatus; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java new file mode 100644 index 000000000..a54938ea2 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java @@ -0,0 +1,26 @@ +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 客户更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmCustomerUpdateReqVO extends CrmCustomerBaseVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") + @NotNull(message = "编号不能为空") + private Long id; + + @Schema(description = "只读权限的用户编号数组") + private String roUserIds; + + @Schema(description = "读写权限的用户编号数组") + private String rwUserIds; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java new file mode 100644 index 000000000..da683fbfb --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.convert.customer; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; + +/** + * 客户 Convert + * + * @author Wanwan + */ +@Mapper +public interface CrmCustomerConvert { + + CrmCustomerConvert INSTANCE = Mappers.getMapper(CrmCustomerConvert.class); + + CrmCustomerDO convert(CrmCustomerCreateReqVO bean); + + CrmCustomerDO convert(CrmCustomerUpdateReqVO bean); + + CrmCustomerRespVO convert(CrmCustomerDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java new file mode 100644 index 000000000..d35650905 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java @@ -0,0 +1,107 @@ +package cn.iocoder.yudao.module.crm.dal.dataobject.customer; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.sun.xml.bind.v2.TODO; +import lombok.*; + +import java.time.LocalDateTime; + +/** + * 客户 DO + * + * @author Wanwan + */ +@TableName("crm_customer") +@KeySequence("crm_customer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CrmCustomerDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 客户名称 + */ + private String name; + /** + * 跟进状态 + *

+ * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean followUpStatus; + /** + * 锁定状态 + *

+ * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean lockStatus; + /** + * 成交状态 + *

+ * 枚举 {@link TODO infra_boolean_string 对应的类} + */ + private Boolean dealStatus; + /** + * 手机 + */ + private String mobile; + /** + * 电话 + */ + private String telephone; + /** + * 网址 + */ + private String website; + /** + * 备注 + */ + private String remark; + /** + * 负责人的用户编号 + */ + private Long ownerUserId; + /** + * 只读权限的用户编号数组 + */ + private String roUserIds; + /** + * 读写权限的用户编号数组 + */ + private String rwUserIds; + /** + * 地区编号 + */ + private Long areaId; + /** + * 详细地址 + */ + private String detailAddress; + /** + * 地理位置经度 + */ + private String longitude; + /** + * 地理位置维度 + */ + private String latitude; + /** + * 最后跟进时间 + */ + private LocalDateTime contactLastTime; + /** + * 下次联系时间 + */ + private LocalDateTime contactNextTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java new file mode 100644 index 000000000..647b6d812 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.customer; + +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.customer.vo.CrmCustomerExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 客户 Mapper + * + * @author Wanwan + */ +@Mapper +public interface CrmCustomerMapper extends BaseMapperX { + + default PageResult selectPage(CrmCustomerPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(CrmCustomerDO::getName, reqVO.getName()) + .eqIfPresent(CrmCustomerDO::getMobile, reqVO.getMobile()) + .eqIfPresent(CrmCustomerDO::getTelephone, reqVO.getTelephone()) + .likeIfPresent(CrmCustomerDO::getWebsite, reqVO.getWebsite()) + .orderByDesc(CrmCustomerDO::getId)); + } + + default List selectList(CrmCustomerExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .likeIfPresent(CrmCustomerDO::getName, reqVO.getName()) + .eqIfPresent(CrmCustomerDO::getMobile, reqVO.getMobile()) + .eqIfPresent(CrmCustomerDO::getTelephone, reqVO.getTelephone()) + .likeIfPresent(CrmCustomerDO::getWebsite, reqVO.getWebsite()) + .orderByDesc(CrmCustomerDO::getId)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java new file mode 100644 index 000000000..c2190ff94 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java @@ -0,0 +1,75 @@ +package cn.iocoder.yudao.module.crm.service.customer; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; + +/** + * 客户 Service 接口 + * + * @author Wanwan + */ +public interface CrmCustomerService { + + /** + * 创建客户 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createCustomer(@Valid CrmCustomerCreateReqVO createReqVO); + + /** + * 更新客户 + * + * @param updateReqVO 更新信息 + */ + void updateCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO); + + /** + * 删除客户 + * + * @param id 编号 + */ + void deleteCustomer(Long id); + + /** + * 获得客户 + * + * @param id 编号 + * @return 客户 + */ + CrmCustomerDO getCustomer(Long id); + + /** + * 获得客户列表 + * + * @param ids 编号 + * @return 客户列表 + */ + List getCustomerList(Collection ids); + + /** + * 获得客户分页 + * + * @param pageReqVO 分页查询 + * @return 客户分页 + */ + PageResult getCustomerPage(CrmCustomerPageReqVO pageReqVO); + + /** + * 获得客户列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 客户列表 + */ + List getCustomerList(CrmCustomerExportReqVO exportReqVO); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java new file mode 100644 index 000000000..0bb224e7f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java @@ -0,0 +1,88 @@ +package cn.iocoder.yudao.module.crm.service.customer; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; +import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; + +/** + * 客户 Service 实现类 + * + * @author Wanwan + */ +@Service +@Validated +public class CrmCustomerServiceImpl implements CrmCustomerService { + + @Resource + private CrmCustomerMapper customerMapper; + + @Override + public Long createCustomer(CrmCustomerCreateReqVO createReqVO) { + // 插入 + CrmCustomerDO customer = CrmCustomerConvert.INSTANCE.convert(createReqVO); + customerMapper.insert(customer); + // 返回 + return customer.getId(); + } + + @Override + public void updateCustomer(CrmCustomerUpdateReqVO updateReqVO) { + // 校验存在 + validateCustomerExists(updateReqVO.getId()); + // 更新 + CrmCustomerDO updateObj = CrmCustomerConvert.INSTANCE.convert(updateReqVO); + customerMapper.updateById(updateObj); + } + + @Override + public void deleteCustomer(Long id) { + // 校验存在 + validateCustomerExists(id); + // 删除 + customerMapper.deleteById(id); + } + + private void validateCustomerExists(Long id) { + if (customerMapper.selectById(id) == null) { + throw exception(CUSTOMER_NOT_EXISTS); + } + } + + @Override + public CrmCustomerDO getCustomer(Long id) { + return customerMapper.selectById(id); + } + + @Override + public List getCustomerList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return customerMapper.selectBatchIds(ids); + } + + @Override + public PageResult getCustomerPage(CrmCustomerPageReqVO pageReqVO) { + return customerMapper.selectPage(pageReqVO); + } + + @Override + public List getCustomerList(CrmCustomerExportReqVO exportReqVO) { + return customerMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/customer/CrmCustomerMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/customer/CrmCustomerMapper.xml new file mode 100644 index 000000000..85eb90d07 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/customer/CrmCustomerMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java new file mode 100644 index 000000000..2e7d17907 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java @@ -0,0 +1,170 @@ +package cn.iocoder.yudao.module.crm.service.customer; + +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.customer.vo.CrmCustomerCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; +import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; +import static org.junit.jupiter.api.Assertions.*; + +/** + * {@link CrmCustomerServiceImpl} 的单元测试类 + * + * @author Wanwan + */ +@Import(CrmCustomerServiceImpl.class) +public class CrmCustomerServiceImplTest extends BaseDbUnitTest { + + @Resource + private CrmCustomerServiceImpl customerService; + + @Resource + private CrmCustomerMapper customerMapper; + + @Test + public void testCreateCustomer_success() { + // 准备参数 + CrmCustomerCreateReqVO reqVO = randomPojo(CrmCustomerCreateReqVO.class); + + // 调用 + Long customerId = customerService.createCustomer(reqVO); + // 断言 + assertNotNull(customerId); + // 校验记录的属性是否正确 + CrmCustomerDO customer = customerMapper.selectById(customerId); + assertPojoEquals(reqVO, customer); + } + + @Test + public void testUpdateCustomer_success() { + // mock 数据 + CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class); + customerMapper.insert(dbCustomer);// @Sql: 先插入出一条存在的数据 + // 准备参数 + CrmCustomerUpdateReqVO reqVO = randomPojo(CrmCustomerUpdateReqVO.class, o -> { + o.setId(dbCustomer.getId()); // 设置更新的 ID + }); + + // 调用 + customerService.updateCustomer(reqVO); + // 校验是否更新正确 + CrmCustomerDO customer = customerMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, customer); + } + + @Test + public void testUpdateCustomer_notExists() { + // 准备参数 + CrmCustomerUpdateReqVO reqVO = randomPojo(CrmCustomerUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> customerService.updateCustomer(reqVO), CUSTOMER_NOT_EXISTS); + } + + @Test + public void testDeleteCustomer_success() { + // mock 数据 + CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class); + customerMapper.insert(dbCustomer);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbCustomer.getId(); + + // 调用 + customerService.deleteCustomer(id); + // 校验数据不存在了 + assertNull(customerMapper.selectById(id)); + } + + @Test + public void testDeleteCustomer_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> customerService.deleteCustomer(id), CUSTOMER_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetCustomerPage() { + // mock 数据 + CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class, o -> { // 等会查询到 + o.setName(null); + o.setMobile(null); + o.setTelephone(null); + o.setWebsite(null); + }); + customerMapper.insert(dbCustomer); + // 测试 name 不匹配 + customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setName(null))); + // 测试 mobile 不匹配 + customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setMobile(null))); + // 测试 telephone 不匹配 + customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setTelephone(null))); + // 测试 website 不匹配 + customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setWebsite(null))); + // 准备参数 + CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO(); + reqVO.setName(null); + reqVO.setMobile(null); + reqVO.setTelephone(null); + reqVO.setWebsite(null); + + // 调用 + PageResult pageResult = customerService.getCustomerPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbCustomer, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetCustomerList() { + // mock 数据 + CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class, o -> { // 等会查询到 + o.setName(null); + o.setMobile(null); + o.setTelephone(null); + o.setWebsite(null); + }); + customerMapper.insert(dbCustomer); + // 测试 name 不匹配 + customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setName(null))); + // 测试 mobile 不匹配 + customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setMobile(null))); + // 测试 telephone 不匹配 + customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setTelephone(null))); + // 测试 website 不匹配 + customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setWebsite(null))); + // 准备参数 + CrmCustomerExportReqVO reqVO = new CrmCustomerExportReqVO(); + reqVO.setName(null); + reqVO.setMobile(null); + reqVO.setTelephone(null); + reqVO.setWebsite(null); + + // 调用 + List list = customerService.getCustomerList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbCustomer, list.get(0)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql index 525391b33..c86e5a113 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql @@ -5,3 +5,5 @@ DELETE FROM "crm_clue"; DELETE FROM "crm_receivable"; DELETE FROM "crm_receivable_plan"; + +DELETE FROM "crm_customer"; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql index 8d98883b4..f7d25f7ef 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql @@ -98,3 +98,30 @@ CREATE TABLE IF NOT EXISTS "crm_receivable_plan" ( PRIMARY KEY ("id") ) COMMENT '回款计划'; +CREATE TABLE IF NOT EXISTS "crm_customer" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "name" varchar, + "follow_up_status" bit NOT NULL, + "lock_status" bit NOT NULL, + "deal_status" bit NOT NULL, + "mobile" varchar, + "telephone" varchar, + "website" varchar, + "remark" varchar, + "owner_user_id" bigint, + "ro_user_ids" varchar, + "rw_user_ids" varchar, + "area_id" bigint, + "detail_address" varchar, + "longitude" varchar, + "latitude" varchar, + "contact_last_time" varchar, + "contact_next_time" varchar, + "creator" varchar DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + "tenant_id" bigint NOT NULL, + PRIMARY KEY ("id") +) COMMENT '客户表'; \ No newline at end of file From 866eaedfeba5b3f6a038c106fc8e53285434b3d0 Mon Sep 17 00:00:00 2001 From: Wanwan <913752709@qq.com> Date: Wed, 25 Oct 2023 00:32:49 +0800 Subject: [PATCH 023/101] =?UTF-8?q?feat:=20=E5=AE=A2=E6=88=B7=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=20crud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../crm/dal/dataobject/clue/CrmClueDO.java | 4 ++-- .../crm/service/clue/CrmClueServiceImpl.java | 21 +++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java index f9eee5b09..067bec65c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.clue; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -43,8 +44,7 @@ public class CrmClueDO extends BaseDO { private String name; /** * 客户 id - * - * // TODO @wanwan:要写下关联的实体,以及对应的属性哈 + * 对应 {@link CrmCustomerDO#getId()} */ private Long customerId; /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java index 5e461ff87..3389c4b26 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java @@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO; import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert; import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper; +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -19,6 +20,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_NOT_EXISTS; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; /** * 线索 Service 实现类 @@ -31,10 +33,13 @@ public class CrmClueServiceImpl implements CrmClueService { @Resource private CrmClueMapper clueMapper; + @Resource + private CrmCustomerService customerService; @Override public Long createClue(CrmClueCreateReqVO createReqVO) { - // TODO @wanwan:校验客户是否存在;以及类似的逻辑哈;如果目前还缺对应的模块的 service,可以先给自己写 todo; + // 校验客户是否存在 + validateCustomerExists(createReqVO.getCustomerId()); // 插入 CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO); clueMapper.insert(clue); @@ -44,9 +49,10 @@ public class CrmClueServiceImpl implements CrmClueService { @Override public void updateClue(CrmClueUpdateReqVO updateReqVO) { - // TODO @wanwan:校验客户是否存在;以及类似的逻辑哈;如果目前还缺对应的模块的 service,可以先给自己写 todo; // 校验存在 validateClueExists(updateReqVO.getId()); + // 校验客户是否存在 + validateCustomerExists(updateReqVO.getCustomerId()); // 更新 CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO); @@ -90,4 +96,15 @@ public class CrmClueServiceImpl implements CrmClueService { return clueMapper.selectList(exportReqVO); } + /** + * 校验客户是否存在 + * + * @param customerId 客户id + */ + private void validateCustomerExists(Long customerId) { + if (customerService.getCustomer(customerId) == null) { + throw exception(CUSTOMER_NOT_EXISTS); + } + } + } From 75115bcc488053b339c010f5b4af834ac2f61442 Mon Sep 17 00:00:00 2001 From: ljlleo Date: Thu, 26 Oct 2023 16:22:44 +0800 Subject: [PATCH 024/101] =?UTF-8?q?1=E3=80=81=E5=95=86=E6=9C=BA=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E9=A1=B5=E9=9D=A2=EF=BC=9B=202=E3=80=81=E5=95=86?= =?UTF-8?q?=E6=9C=BA=E7=8A=B6=E6=80=81=E7=B1=BB=E5=9E=8B=E5=92=8C=E5=95=86?= =?UTF-8?q?=E6=9C=BA=E7=8A=B6=E6=80=81=E5=AD=97=E6=AE=B5=E7=9A=84=E5=A4=84?= =?UTF-8?q?=E7=90=86=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 34 ++ .../module/crm/enums/ErrorCodeConstants.java | 2 + .../admin/business/CrmBusinessController.java | 1 + .../admin/business/vo/CrmBusinessBaseVO.java | 40 +-- .../business/vo/CrmBusinessPageReqVO.java | 63 ---- .../CrmBusinessStatusController.java | 115 ++++++ .../vo/CrmBusinessStatusBaseVO.java | 29 ++ .../vo/CrmBusinessStatusCreateReqVO.java | 14 + .../vo/CrmBusinessStatusExcelVO.java | 32 ++ .../vo/CrmBusinessStatusExportReqVO.java | 24 ++ .../vo/CrmBusinessStatusPageReqVO.java | 18 + .../vo/CrmBusinessStatusRespVO.java | 15 + .../vo/CrmBusinessStatusUpdateReqVO.java | 18 + .../CrmBusinessStatusTypeController.java | 108 ++++++ .../vo/CrmBusinessStatusTypeBaseVO.java | 27 ++ .../vo/CrmBusinessStatusTypeCreateReqVO.java | 14 + .../vo/CrmBusinessStatusTypeExcelVO.java | 34 ++ .../vo/CrmBusinessStatusTypeExportReqVO.java | 29 ++ .../vo/CrmBusinessStatusTypePageReqVO.java | 21 ++ .../vo/CrmBusinessStatusTypeRespVO.java | 19 + .../vo/CrmBusinessStatusTypeUpdateReqVO.java | 18 + .../CrmBusinessStatusConvert.java | 34 ++ .../CrmBusinessStatusTypeConvert.java | 34 ++ .../dataobject/business/CrmBusinessDO.java | 16 +- .../businessstatus/CrmBusinessStatusDO.java | 44 +++ .../CrmBusinessStatusTypeDO.java | 40 +++ .../dal/mysql/business/CrmBusinessMapper.java | 17 - .../CrmBusinessStatusMapper.java | 40 +++ .../CrmBusinessStatusTypeMapper.java | 43 +++ .../CrmBusinessStatusService.java | 90 +++++ .../CrmBusinessStatusServiceImpl.java | 99 ++++++ .../CrmBusinessStatusTypeService.java | 83 +++++ .../CrmBusinessStatusTypeServiceImpl.java | 95 +++++ .../CrmBusinessStatusTypeMapper.xml | 12 + .../CrmBusinessStatusServiceImplTest.java | 170 +++++++++ .../CrmBusinessStatusTypeServiceImplTest.java | 171 +++++++++ yudao-ui-admin/src/api/crm/business.js | 54 +++ yudao-ui-admin/src/api/crm/businessStatus.js | 70 ++++ .../src/api/crm/businessStatusType.js | 62 ++++ .../src/views/crm/business/index.vue | 335 ++++++++++++++++++ 40 files changed, 2059 insertions(+), 125 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/CrmBusinessStatusController.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusBaseVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusCreateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExcelVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExportReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusPageReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusUpdateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/CrmBusinessStatusTypeController.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeBaseVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeCreateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExcelVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExportReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypePageReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeUpdateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatus/CrmBusinessStatusConvert.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatustype/CrmBusinessStatusTypeConvert.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatus/CrmBusinessStatusDO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatustype/CrmBusinessStatusTypeDO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatus/CrmBusinessStatusMapper.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatustype/CrmBusinessStatusTypeMapper.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusService.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImpl.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeService.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImpl.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/businessstatustype/CrmBusinessStatusTypeMapper.xml create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImplTest.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImplTest.java create mode 100644 yudao-ui-admin/src/api/crm/business.js create mode 100644 yudao-ui-admin/src/api/crm/businessStatus.js create mode 100644 yudao-ui-admin/src/api/crm/businessStatusType.js create mode 100644 yudao-ui-admin/src/views/crm/business/index.vue diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 73cf99490..0cff91996 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -62,6 +62,10 @@ CREATE TABLE `crm_clue` ( PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB COMMENT = '线索表' ; +-- ---------------------------- +-- 商机表 +-- ---------------------------- + DROP TABLE IF EXISTS `crm_business`; CREATE TABLE `crm_business` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', @@ -180,3 +184,33 @@ CREATE TABLE `crm_contact` ( `tenant_id` bigint DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='crm联系人'; + +-- ---------------------------- +-- 商机状态表 +-- ---------------------------- +DROP TABLE IF EXISTS `crm_business_status`; +CREATE TABLE `crm_business_status` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', + `type_id` bigint NOT NULL COMMENT '状态类型编号', + `name` varchar(100) NOT NULL COMMENT '状态名', + `percent` varchar(20) DEFAULT NULL COMMENT '赢单率', + `sort` int DEFAULT NULL COMMENT '排序', + `tenant_id` bigint DEFAULT '1' COMMENT '租户ID', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='商机状态表' + +-- ---------------------------- +-- 商机状态类型表 +-- ---------------------------- +DROP TABLE IF EXISTS `crm_business_status_type`; +CREATE TABLE `crm_business_status_type` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', + `name` varchar(100) NOT NULL COMMENT '状态类型名', + `dept_ids` varchar(200) NOT NULL COMMENT '使用的部门编号', + `status` bit(1) NOT NULL DEFAULT b'0' COMMENT '开启状态', + `creator` varchar(64) NOT NULL COMMENT '创建人', + `create_time` datetime NOT NULL COMMENT '创建时间', + `update_time` datetime DEFAULT NULL COMMENT '更新时间', + `tenant_id` bigint DEFAULT '1' COMMENT '租户ID', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='商机状态类型表' diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 07d9b6d6a..e7031ff13 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -17,6 +17,8 @@ public interface ErrorCodeConstants { // ========== 商机管理 1-020-002-000 ========== ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); + ErrorCode BUSINESS_STATUS_TYPE_NOT_EXISTS = new ErrorCode(1_020_002_001, "商机状态类型不存在"); + ErrorCode BUSINESS_STATUS_NOT_EXISTS = new ErrorCode(1_020_002_002, "商机状态不存在"); // ========== 联系人管理 1-020-003-000 ========== ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java index b622f23c3..d517a9f91 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java @@ -71,6 +71,7 @@ public class CrmBusinessController { @PreAuthorize("@ss.hasPermission('crm:business:query')") public CommonResult> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) { PageResult pageResult = businessService.getBusinessPage(pageVO); + return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult)); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessBaseVO.java index 061929ae6..9bcffb117 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessBaseVO.java @@ -21,13 +21,11 @@ public class CrmBusinessBaseVO { @NotNull(message = "商机名称不能为空") private String name; - // TODO @ljileo:要写 requiredMode = Schema.RequiredMode.REQUIRED - @Schema(description = "商机状态类型编号", example = "25714") + @Schema(description = "商机状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714") @NotNull(message = "商机状态类型不能为空") private Long statusTypeId; - // TODO @ljileo:要写 requiredMode = Schema.RequiredMode.REQUIRED - @Schema(description = "商机状态编号", example = "30320") + @Schema(description = "商机状态编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320") @NotNull(message = "商机状态不能为空") private Long statusId; @@ -43,13 +41,12 @@ public class CrmBusinessBaseVO { @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime dealTime; - // TODO @ljileo:金额使用 Integer 类型,转换成分 @Schema(description = "商机金额", example = "12371") - private BigDecimal price; + private Integer price; // TODO @ljileo:折扣使用 Integer 类型,存储时,默认 * 100;展示的时候,前端需要 / 100;避免精度丢失问题 @Schema(description = "整单折扣") - private BigDecimal discountPercent; + private Integer discountPercent; @Schema(description = "产品总金额", example = "12025") private BigDecimal productPrice; @@ -57,33 +54,4 @@ public class CrmBusinessBaseVO { @Schema(description = "备注", example = "随便") private String remark; - // TODO @ljileo:这个新建和修改的时候,应该不传递哈;应该新建的人,就是它的负责人 - @Schema(description = "负责人的用户编号", example = "25562") - private Long ownerUserId; - - // TODO @ljileo:这个新建和修改的时候,应该不传递哈 - @Schema(description = "只读权限的用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED) - private String roUserIds; - - // TODO @ljileo:这个新建和修改的时候,应该不传递哈 - @Schema(description = "读写权限的用户编号数组", requiredMode = Schema.RequiredMode.REQUIRED) - private String rwUserIds; - - // TODO @lijieo:新建的时候,不传递这个字段哈; - @Schema(description = "1赢单2输单3无效", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Integer endStatus; - - // TODO @lijieo:新建的时候,不传递这个字段哈; - @Schema(description = "结束时的备注", example = "你说的对") - private String endRemark; - - // TODO @lijieo:新建的时候,不传递这个字段哈; - @Schema(description = "最后跟进时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime contactLastTime; - - // TODO @lijieo:新建的时候,不传递这个字段哈; - @Schema(description = "跟进状态", example = "1") - private Integer followUpStatus; - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessPageReqVO.java index 99a41d597..c8368cce7 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessPageReqVO.java @@ -5,12 +5,6 @@ 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.math.BigDecimal; -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @Schema(description = "管理后台 - 商机分页 Request VO") @Data @@ -18,64 +12,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class CrmBusinessPageReqVO extends PageParam { - // TODO @ljileo:目前就使用 name 检索即可; - @Schema(description = "商机名称", example = "李四") private String name; - @Schema(description = "商机状态类型编号", example = "25714") - private Long statusTypeId; - - @Schema(description = "商机状态编号", example = "30320") - private Long statusId; - - @Schema(description = "下次联系时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] contactNextTime; - - @Schema(description = "客户编号", example = "10299") - private Long customerId; - - @Schema(description = "预计成交日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] dealTime; - - @Schema(description = "商机金额", example = "12371") - private BigDecimal price; - - @Schema(description = "整单折扣") - private BigDecimal discountPercent; - - @Schema(description = "产品总金额", example = "12025") - private BigDecimal productPrice; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "负责人的用户编号", example = "25562") - private Long ownerUserId; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - - @Schema(description = "只读权限的用户编号数组") - private String roUserIds; - - @Schema(description = "读写权限的用户编号数组") - private String rwUserIds; - - @Schema(description = "1赢单2输单3无效", example = "1") - private Integer endStatus; - - @Schema(description = "结束时的备注", example = "你说的对") - private String endRemark; - - @Schema(description = "最后跟进时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] contactLastTime; - - @Schema(description = "跟进状态", example = "1") - private Integer followUpStatus; - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/CrmBusinessStatusController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/CrmBusinessStatusController.java new file mode 100644 index 000000000..fddec8d8d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/CrmBusinessStatusController.java @@ -0,0 +1,115 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatus; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +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.businessstatus.vo.*; +import cn.iocoder.yudao.module.crm.convert.businessstatus.CrmBusinessStatusConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; +import cn.iocoder.yudao.module.crm.service.businessstatus.CrmBusinessStatusService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; + +@Tag(name = "管理后台 - 商机状态") +@RestController +@RequestMapping("/crm/business-status") +@Validated +public class CrmBusinessStatusController { + + @Resource + private CrmBusinessStatusService businessStatusService; + + @PostMapping("/create") + @Operation(summary = "创建商机状态") + @PreAuthorize("@ss.hasPermission('crm:business-status:create')") + public CommonResult createBusinessStatus(@Valid @RequestBody CrmBusinessStatusCreateReqVO createReqVO) { + return success(businessStatusService.createBusinessStatus(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新商机状态") + @PreAuthorize("@ss.hasPermission('crm:business-status:update')") + public CommonResult updateBusinessStatus(@Valid @RequestBody CrmBusinessStatusUpdateReqVO updateReqVO) { + businessStatusService.updateBusinessStatus(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除商机状态") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('crm:business-status:delete')") + public CommonResult deleteBusinessStatus(@RequestParam("id") Long id) { + businessStatusService.deleteBusinessStatus(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得商机状态") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('crm:business-status:query')") + public CommonResult getBusinessStatus(@RequestParam("id") Long id) { + CrmBusinessStatusDO businessStatus = businessStatusService.getBusinessStatus(id); + return success(CrmBusinessStatusConvert.INSTANCE.convert(businessStatus)); + } + + @GetMapping("/list") + @Operation(summary = "获得商机状态列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('crm:business-status:query')") + public CommonResult> getBusinessStatusList(@RequestParam("ids") Collection ids) { + List list = businessStatusService.getBusinessStatusList(ids); + return success(CrmBusinessStatusConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得商机状态分页") + @PreAuthorize("@ss.hasPermission('crm:business-status:query')") + public CommonResult> getBusinessStatusPage(@Valid CrmBusinessStatusPageReqVO pageVO) { + PageResult pageResult = businessStatusService.getBusinessStatusPage(pageVO); + return success(CrmBusinessStatusConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出商机状态 Excel") + @PreAuthorize("@ss.hasPermission('crm:business-status:export')") + @OperateLog(type = EXPORT) + public void exportBusinessStatusExcel(@Valid CrmBusinessStatusExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = businessStatusService.getBusinessStatusList(exportReqVO); + // 导出 Excel + List datas = CrmBusinessStatusConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "商机状态.xls", "数据", CrmBusinessStatusExcelVO.class, datas); + } + + @GetMapping("/get-simple-list") + @Operation(summary = "获得商机状态列表") + @PreAuthorize("@ss.hasPermission('crm:business-status:query')") + public CommonResult> getBusinessStatusListByTypeId(@RequestParam("typeId") Integer typeId) { + List list = businessStatusService.getBusinessStatusListByTypeId(typeId); + return success(CrmBusinessStatusConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/get-all-list") + @Operation(summary = "获得商机状态列表") + @PreAuthorize("@ss.hasPermission('crm:business-status:query')") + public CommonResult> getBusinessStatusList() { + List list = businessStatusService.getBusinessStatusList(); + return success(CrmBusinessStatusConvert.INSTANCE.convertList(list)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusBaseVO.java new file mode 100644 index 000000000..eec9de8b0 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusBaseVO.java @@ -0,0 +1,29 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * 商机状态 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class CrmBusinessStatusBaseVO { + + @Schema(description = "状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22882") + @NotNull(message = "状态类型编号不能为空") + private Long typeId; + + @Schema(description = "状态名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") + @NotNull(message = "状态名不能为空") + private String name; + + @Schema(description = "赢单率") + private String percent; + + @Schema(description = "排序") + private Integer sort; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusCreateReqVO.java new file mode 100644 index 000000000..04e999474 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 商机状态创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmBusinessStatusCreateReqVO extends CrmBusinessStatusBaseVO { + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExcelVO.java new file mode 100644 index 000000000..83002469e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExcelVO.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * 商机状态 Excel VO + * + * @author ljlleo + */ +@Data +public class CrmBusinessStatusExcelVO { + + @ExcelProperty("主键") + private Long id; + + @ExcelProperty("状态类型编号") + private Long typeId; + + @ExcelProperty("状态名") + private String name; + + @ExcelProperty("赢单率") + private String percent; + + @ExcelProperty("排序") + private Integer sort; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExportReqVO.java new file mode 100644 index 000000000..3fecb03ee --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExportReqVO.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +@Schema(description = "管理后台 - 商机状态 Excel 导出 Request VO,参数和 CrmBusinessStatusPageReqVO 是一致的") +@Data +public class CrmBusinessStatusExportReqVO { + + @Schema(description = "状态类型编号", example = "22882") + private Long typeId; + + @Schema(description = "状态名", example = "李四") + private String name; + + @Schema(description = "赢单率") + private String percent; + + @Schema(description = "排序") + private Integer sort; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusPageReqVO.java new file mode 100644 index 000000000..af03512af --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusPageReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - 商机状态分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmBusinessStatusPageReqVO extends PageParam { + + @Schema(description = "状态类型编号", example = "22882") + private Long typeId; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusRespVO.java new file mode 100644 index 000000000..2a0fa07a4 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusRespVO.java @@ -0,0 +1,15 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +@Schema(description = "管理后台 - 商机状态 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmBusinessStatusRespVO extends CrmBusinessStatusBaseVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "6802") + private Long id; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusUpdateReqVO.java new file mode 100644 index 000000000..11f403330 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 商机状态更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmBusinessStatusUpdateReqVO extends CrmBusinessStatusBaseVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "6802") + @NotNull(message = "主键不能为空") + private Long id; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/CrmBusinessStatusTypeController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/CrmBusinessStatusTypeController.java new file mode 100644 index 000000000..ae0c55d62 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/CrmBusinessStatusTypeController.java @@ -0,0 +1,108 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype; + +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +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.businessstatustype.vo.*; +import cn.iocoder.yudao.module.crm.convert.businessstatustype.CrmBusinessStatusTypeConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO; +import cn.iocoder.yudao.module.crm.service.businessstatustype.CrmBusinessStatusTypeService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; + +@Tag(name = "管理后台 - 商机状态类型") +@RestController +@RequestMapping("/crm/business-status-type") +@Validated +public class CrmBusinessStatusTypeController { + + @Resource + private CrmBusinessStatusTypeService businessStatusTypeService; + + @PostMapping("/create") + @Operation(summary = "创建商机状态类型") + @PreAuthorize("@ss.hasPermission('crm:business-status-type:create')") + public CommonResult createBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeCreateReqVO createReqVO) { + return success(businessStatusTypeService.createBusinessStatusType(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新商机状态类型") + @PreAuthorize("@ss.hasPermission('crm:business-status-type:update')") + public CommonResult updateBusinessStatusType(@Valid @RequestBody CrmBusinessStatusTypeUpdateReqVO updateReqVO) { + businessStatusTypeService.updateBusinessStatusType(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除商机状态类型") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('crm:business-status-type:delete')") + public CommonResult deleteBusinessStatusType(@RequestParam("id") Long id) { + businessStatusTypeService.deleteBusinessStatusType(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得商机状态类型") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')") + public CommonResult getBusinessStatusType(@RequestParam("id") Long id) { + CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeService.getBusinessStatusType(id); + return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(businessStatusType)); + } + + @GetMapping("/list") + @Operation(summary = "获得商机状态类型列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')") + public CommonResult> getBusinessStatusTypeList(@RequestParam("ids") Collection ids) { + List list = businessStatusTypeService.getBusinessStatusTypeList(ids); + return success(CrmBusinessStatusTypeConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得商机状态类型分页") + @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')") + public CommonResult> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageVO) { + PageResult pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageVO); + return success(CrmBusinessStatusTypeConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出商机状态类型 Excel") + @PreAuthorize("@ss.hasPermission('crm:business-status-type:export')") + @OperateLog(type = EXPORT) + public void exportBusinessStatusTypeExcel(@Valid CrmBusinessStatusTypeExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = businessStatusTypeService.getBusinessStatusTypeList(exportReqVO); + // 导出 Excel + List datas = CrmBusinessStatusTypeConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "商机状态类型.xls", "数据", CrmBusinessStatusTypeExcelVO.class, datas); + } + + @GetMapping("/get-simple-list") + @Operation(summary = "获得商机状态类型列表") + @PreAuthorize("@ss.hasPermission('crm:business-status-type:query')") + public CommonResult> getBusinessStatusTypeList() { + List list = businessStatusTypeService.getBusinessStatusTypeListByStatus(CommonStatusEnum.ENABLE.getStatus()); + return success(CrmBusinessStatusTypeConvert.INSTANCE.convertList(list)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeBaseVO.java new file mode 100644 index 000000000..c472a3471 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeBaseVO.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * 商机状态类型 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class CrmBusinessStatusTypeBaseVO { + + @Schema(description = "状态类型名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") + @NotNull(message = "状态类型名不能为空") + private String name; + + @Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "使用的部门编号不能为空") + private String deptIds; + + @Schema(description = "开启状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "开启状态不能为空") + private Boolean status; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeCreateReqVO.java new file mode 100644 index 000000000..e9f958a6c --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - 商机状态类型创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmBusinessStatusTypeCreateReqVO extends CrmBusinessStatusTypeBaseVO { + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExcelVO.java new file mode 100644 index 000000000..ea82616de --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExcelVO.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * 商机状态类型 Excel VO + * + * @author ljlleo + */ +@Data +public class CrmBusinessStatusTypeExcelVO { + + @ExcelProperty("主键") + private Long id; + + @ExcelProperty("状态类型名") + private String name; + + @ExcelProperty("使用的部门编号") + private String deptIds; + + @ExcelProperty("开启状态") + private Boolean status; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExportReqVO.java new file mode 100644 index 000000000..48d5bc7ed --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExportReqVO.java @@ -0,0 +1,29 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import java.time.LocalDateTime; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 商机状态类型 Excel 导出 Request VO,参数和 CrmBusinessStatusTypePageReqVO 是一致的") +@Data +public class CrmBusinessStatusTypeExportReqVO { + + @Schema(description = "状态类型名", example = "芋艿") + private String name; + + @Schema(description = "使用的部门编号") + private String deptIds; + + @Schema(description = "开启状态", example = "1") + private Boolean status; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypePageReqVO.java new file mode 100644 index 000000000..4b15210ac --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypePageReqVO.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - 商机状态类型分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmBusinessStatusTypePageReqVO extends PageParam { + + @Schema(description = "状态类型名", example = "芋艿") + private String name; + + @Schema(description = "开启状态", example = "1") + private Boolean status; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeRespVO.java new file mode 100644 index 000000000..a4e21c58e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 商机状态类型 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmBusinessStatusTypeRespVO extends CrmBusinessStatusTypeBaseVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "24019") + private Long id; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeUpdateReqVO.java new file mode 100644 index 000000000..5fab5fc2f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 商机状态类型更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmBusinessStatusTypeUpdateReqVO extends CrmBusinessStatusTypeBaseVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "24019") + @NotNull(message = "主键不能为空") + private Long id; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatus/CrmBusinessStatusConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatus/CrmBusinessStatusConvert.java new file mode 100644 index 000000000..c8b854144 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatus/CrmBusinessStatusConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.convert.businessstatus; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; + +/** + * 商机状态 Convert + * + * @author ljlleo + */ +@Mapper +public interface CrmBusinessStatusConvert { + + CrmBusinessStatusConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusConvert.class); + + CrmBusinessStatusDO convert(CrmBusinessStatusCreateReqVO bean); + + CrmBusinessStatusDO convert(CrmBusinessStatusUpdateReqVO bean); + + CrmBusinessStatusRespVO convert(CrmBusinessStatusDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatustype/CrmBusinessStatusTypeConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatustype/CrmBusinessStatusTypeConvert.java new file mode 100644 index 000000000..75f1aed4c --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/businessstatustype/CrmBusinessStatusTypeConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.convert.businessstatustype; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO; + +/** + * 商机状态类型 Convert + * + * @author ljlleo + */ +@Mapper +public interface CrmBusinessStatusTypeConvert { + + CrmBusinessStatusTypeConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusTypeConvert.class); + + CrmBusinessStatusTypeDO convert(CrmBusinessStatusTypeCreateReqVO bean); + + CrmBusinessStatusTypeDO convert(CrmBusinessStatusTypeUpdateReqVO bean); + + CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java index 795ddad39..2d6454838 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java @@ -1,12 +1,13 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.business; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; -import java.math.BigDecimal; import java.time.LocalDateTime; /** @@ -36,13 +37,13 @@ public class CrmBusinessDO extends BaseDO { /** * 商机状态类型编号 * - * TODO @ljileo:这个字段,后续要写下关联的实体哈 + * 关联 {@link CrmBusinessStatusTypeDO#getId()} */ private Long statusTypeId; /** * 商机状态编号 * - * TODO @ljileo:这个字段,后续要写下关联的实体哈 + * 关联 {@link CrmBusinessStatusDO#getId()} */ private Long statusId; /** @@ -62,21 +63,18 @@ public class CrmBusinessDO extends BaseDO { /** * 商机金额 * - * TODO @lijie:Integer */ - private BigDecimal price; + private Integer price; /** * 整单折扣 * - * TODO @lijie:Integer */ - private BigDecimal discountPercent; + private Integer discountPercent; /** * 产品总金额 * - * TODO @lijie:Integer */ - private BigDecimal productPrice; + private Integer productPrice; /** * 备注 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatus/CrmBusinessStatusDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatus/CrmBusinessStatusDO.java new file mode 100644 index 000000000..a60c6e40d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatus/CrmBusinessStatusDO.java @@ -0,0 +1,44 @@ +package cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus; + +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +/** + * 商机状态 DO + * + * @author ljlleo + */ +@TableName("crm_business_status") +@KeySequence("crm_business_status_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CrmBusinessStatusDO { + + /** + * 主键 + */ + @TableId + private Long id; + /** + * 状态类型编号 + */ + private Long typeId; + /** + * 状态名 + */ + private String name; + /** + * 赢单率 + */ + private String percent; + /** + * 排序 + */ + private Integer sort; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatustype/CrmBusinessStatusTypeDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatustype/CrmBusinessStatusTypeDO.java new file mode 100644 index 000000000..4a2005e49 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatustype/CrmBusinessStatusTypeDO.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype; + +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +/** + * 商机状态类型 DO + * + * @author ljlleo + */ +@TableName("crm_business_status_type") +@KeySequence("crm_business_status_type_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CrmBusinessStatusTypeDO { + + /** + * 主键 + */ + @TableId + private Long id; + /** + * 状态类型名 + */ + private String name; + /** + * 使用的部门编号 + */ + private String deptIds; + /** + * 开启状态 + */ + private Boolean status; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java index aadec8517..1429c0794 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java @@ -21,23 +21,6 @@ public interface CrmBusinessMapper extends BaseMapperX { default PageResult selectPage(CrmBusinessPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .likeIfPresent(CrmBusinessDO::getName, reqVO.getName()) - .eqIfPresent(CrmBusinessDO::getStatusTypeId, reqVO.getStatusTypeId()) - .eqIfPresent(CrmBusinessDO::getStatusId, reqVO.getStatusId()) - .betweenIfPresent(CrmBusinessDO::getContactNextTime, reqVO.getContactNextTime()) - .eqIfPresent(CrmBusinessDO::getCustomerId, reqVO.getCustomerId()) - .betweenIfPresent(CrmBusinessDO::getDealTime, reqVO.getDealTime()) - .eqIfPresent(CrmBusinessDO::getPrice, reqVO.getPrice()) - .eqIfPresent(CrmBusinessDO::getDiscountPercent, reqVO.getDiscountPercent()) - .eqIfPresent(CrmBusinessDO::getProductPrice, reqVO.getProductPrice()) - .eqIfPresent(CrmBusinessDO::getRemark, reqVO.getRemark()) - .eqIfPresent(CrmBusinessDO::getOwnerUserId, reqVO.getOwnerUserId()) - .betweenIfPresent(CrmBusinessDO::getCreateTime, reqVO.getCreateTime()) - .eqIfPresent(CrmBusinessDO::getRoUserIds, reqVO.getRoUserIds()) - .eqIfPresent(CrmBusinessDO::getRwUserIds, reqVO.getRwUserIds()) - .eqIfPresent(CrmBusinessDO::getEndStatus, reqVO.getEndStatus()) - .eqIfPresent(CrmBusinessDO::getEndRemark, reqVO.getEndRemark()) - .betweenIfPresent(CrmBusinessDO::getContactLastTime, reqVO.getContactLastTime()) - .eqIfPresent(CrmBusinessDO::getFollowUpStatus, reqVO.getFollowUpStatus()) .orderByDesc(CrmBusinessDO::getId)); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatus/CrmBusinessStatusMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatus/CrmBusinessStatusMapper.java new file mode 100644 index 000000000..2b9eeb4ae --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatus/CrmBusinessStatusMapper.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.businessstatus; + +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.businessstatus.vo.CrmBusinessStatusExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusPageReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 商机状态 Mapper + * + * @author ljlleo + */ +@Mapper +public interface CrmBusinessStatusMapper extends BaseMapperX { + + default PageResult selectPage(CrmBusinessStatusPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(CrmBusinessStatusDO::getTypeId, reqVO.getTypeId()) + .orderByDesc(CrmBusinessStatusDO::getId)); + } + + default List selectList(CrmBusinessStatusExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(CrmBusinessStatusDO::getTypeId, reqVO.getTypeId()) + .likeIfPresent(CrmBusinessStatusDO::getName, reqVO.getName()) + .eqIfPresent(CrmBusinessStatusDO::getPercent, reqVO.getPercent()) + .eqIfPresent(CrmBusinessStatusDO::getSort, reqVO.getSort()) + .orderByDesc(CrmBusinessStatusDO::getId)); + } + + default List getBusinessStatusListByTypeId(Integer typeId) { + return selectList(CrmBusinessStatusDO::getTypeId, typeId); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatustype/CrmBusinessStatusTypeMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatustype/CrmBusinessStatusTypeMapper.java new file mode 100644 index 000000000..bc23b2e8b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatustype/CrmBusinessStatusTypeMapper.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.businessstatustype; + +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.businessstatustype.vo.CrmBusinessStatusTypeExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypePageReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 商机状态类型 Mapper + * + * @author ljlleo + */ +@Mapper +public interface CrmBusinessStatusTypeMapper extends BaseMapperX { + + default PageResult selectPage(CrmBusinessStatusTypePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(CrmBusinessStatusTypeDO::getName, reqVO.getName()) + .eqIfPresent(CrmBusinessStatusTypeDO::getDeptIds, reqVO.getDeptIds()) + .eqIfPresent(CrmBusinessStatusTypeDO::getStatus, reqVO.getStatus()) + .orderByDesc(CrmBusinessStatusTypeDO::getId)); + } + + default List selectList(CrmBusinessStatusTypeExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .likeIfPresent(CrmBusinessStatusTypeDO::getName, reqVO.getName()) + .eqIfPresent(CrmBusinessStatusTypeDO::getDeptIds, reqVO.getDeptIds()) + .eqIfPresent(CrmBusinessStatusTypeDO::getStatus, reqVO.getStatus()) + .orderByDesc(CrmBusinessStatusTypeDO::getId)); + } + + default List getBusinessStatusTypeListByStatus(Integer status) { + return selectList(CrmBusinessStatusTypeDO::getStatus, status.byteValue()); + } + + + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusService.java new file mode 100644 index 000000000..a0dadcd17 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusService.java @@ -0,0 +1,90 @@ +package cn.iocoder.yudao.module.crm.service.businessstatus; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusUpdateReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; + +/** + * 商机状态 Service 接口 + * + * @author ljlleo + */ +public interface CrmBusinessStatusService { + + /** + * 创建商机状态 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createBusinessStatus(@Valid CrmBusinessStatusCreateReqVO createReqVO); + + /** + * 更新商机状态 + * + * @param updateReqVO 更新信息 + */ + void updateBusinessStatus(@Valid CrmBusinessStatusUpdateReqVO updateReqVO); + + /** + * 删除商机状态 + * + * @param id 编号 + */ + void deleteBusinessStatus(Long id); + + /** + * 获得商机状态 + * + * @param id 编号 + * @return 商机状态 + */ + CrmBusinessStatusDO getBusinessStatus(Long id); + + /** + * 获得商机状态列表 + * + * @param ids 编号 + * @return 商机状态列表 + */ + List getBusinessStatusList(Collection ids); + + /** + * 获得商机状态分页 + * + * @param pageReqVO 分页查询 + * @return 商机状态分页 + */ + PageResult getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO); + + /** + * 获得商机状态列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 商机状态列表 + */ + List getBusinessStatusList(CrmBusinessStatusExportReqVO exportReqVO); + + /** + * 根据类型ID获得商机状态列表 + * + * @param typeId 商机状态类型ID + * @return 商机状态列表 + */ + List getBusinessStatusListByTypeId(Integer typeId); + + /** + * 获得商机状态列表 + * + * @return 商机状态列表 + */ + List getBusinessStatusList(); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImpl.java new file mode 100644 index 000000000..e927fac74 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImpl.java @@ -0,0 +1,99 @@ +package cn.iocoder.yudao.module.crm.service.businessstatus; + +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.businessstatus.vo.CrmBusinessStatusCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusUpdateReqVO; +import cn.iocoder.yudao.module.crm.convert.businessstatus.CrmBusinessStatusConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; +import cn.iocoder.yudao.module.crm.dal.mysql.businessstatus.CrmBusinessStatusMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_NOT_EXISTS; + +/** + * 商机状态 Service 实现类 + * + * @author ljlleo + */ +@Service +@Validated +public class CrmBusinessStatusServiceImpl implements CrmBusinessStatusService { + + @Resource + private CrmBusinessStatusMapper businessStatusMapper; + + @Override + public Long createBusinessStatus(CrmBusinessStatusCreateReqVO createReqVO) { + // 插入 + CrmBusinessStatusDO businessStatus = CrmBusinessStatusConvert.INSTANCE.convert(createReqVO); + businessStatusMapper.insert(businessStatus); + // 返回 + return businessStatus.getId(); + } + + @Override + public void updateBusinessStatus(CrmBusinessStatusUpdateReqVO updateReqVO) { + // 校验存在 + validateBusinessStatusExists(updateReqVO.getId()); + // 更新 + CrmBusinessStatusDO updateObj = CrmBusinessStatusConvert.INSTANCE.convert(updateReqVO); + businessStatusMapper.updateById(updateObj); + } + + @Override + public void deleteBusinessStatus(Long id) { + // 校验存在 + validateBusinessStatusExists(id); + // 删除 + businessStatusMapper.deleteById(id); + } + + private void validateBusinessStatusExists(Long id) { + if (businessStatusMapper.selectById(id) == null) { + throw exception(BUSINESS_STATUS_NOT_EXISTS); + } + } + + @Override + public CrmBusinessStatusDO getBusinessStatus(Long id) { + return businessStatusMapper.selectById(id); + } + + @Override + public List getBusinessStatusList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return businessStatusMapper.selectBatchIds(ids); + } + + @Override + public PageResult getBusinessStatusPage(CrmBusinessStatusPageReqVO pageReqVO) { + return businessStatusMapper.selectPage(pageReqVO); + } + + @Override + public List getBusinessStatusList(CrmBusinessStatusExportReqVO exportReqVO) { + return businessStatusMapper.selectList(exportReqVO); + } + + @Override + public List getBusinessStatusListByTypeId(Integer typeId) { + return businessStatusMapper.getBusinessStatusListByTypeId(typeId); + } + + @Override + public List getBusinessStatusList() { + return businessStatusMapper.selectList(); + } +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeService.java new file mode 100644 index 000000000..3c473f62b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeService.java @@ -0,0 +1,83 @@ +package cn.iocoder.yudao.module.crm.service.businessstatustype; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypePageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeUpdateReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; + +/** + * 商机状态类型 Service 接口 + * + * @author ljlleo + */ +public interface CrmBusinessStatusTypeService { + + /** + * 创建商机状态类型 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createBusinessStatusType(@Valid CrmBusinessStatusTypeCreateReqVO createReqVO); + + /** + * 更新商机状态类型 + * + * @param updateReqVO 更新信息 + */ + void updateBusinessStatusType(@Valid CrmBusinessStatusTypeUpdateReqVO updateReqVO); + + /** + * 删除商机状态类型 + * + * @param id 编号 + */ + void deleteBusinessStatusType(Long id); + + /** + * 获得商机状态类型 + * + * @param id 编号 + * @return 商机状态类型 + */ + CrmBusinessStatusTypeDO getBusinessStatusType(Long id); + + /** + * 获得商机状态类型列表 + * + * @param ids 编号 + * @return 商机状态类型列表 + */ + List getBusinessStatusTypeList(Collection ids); + + /** + * 获得商机状态类型分页 + * + * @param pageReqVO 分页查询 + * @return 商机状态类型分页 + */ + PageResult getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO); + + /** + * 获得商机状态类型列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 商机状态类型列表 + */ + List getBusinessStatusTypeList(CrmBusinessStatusTypeExportReqVO exportReqVO); + + /** + * 获得商机状态类型列表 + * + * @param status 状态 + * @return 商机状态类型列表 + */ + List getBusinessStatusTypeListByStatus(Integer status); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImpl.java new file mode 100644 index 000000000..88b25ad1e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImpl.java @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.crm.service.businessstatustype; + +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.businessstatustype.vo.CrmBusinessStatusTypeCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypePageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeUpdateReqVO; +import cn.iocoder.yudao.module.crm.convert.businessstatustype.CrmBusinessStatusTypeConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO; +import cn.iocoder.yudao.module.crm.dal.mysql.businessstatustype.CrmBusinessStatusTypeMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NOT_EXISTS; + +/** + * 商机状态类型 Service 实现类 + * + * @author ljlleo + */ +@Service +@Validated +public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeService { + + @Resource + private CrmBusinessStatusTypeMapper businessStatusTypeMapper; + + @Override + public Long createBusinessStatusType(CrmBusinessStatusTypeCreateReqVO createReqVO) { + // 插入 + CrmBusinessStatusTypeDO businessStatusType = CrmBusinessStatusTypeConvert.INSTANCE.convert(createReqVO); + businessStatusTypeMapper.insert(businessStatusType); + // 返回 + return businessStatusType.getId(); + } + + @Override + public void updateBusinessStatusType(CrmBusinessStatusTypeUpdateReqVO updateReqVO) { + // 校验存在 + validateBusinessStatusTypeExists(updateReqVO.getId()); + // 更新 + CrmBusinessStatusTypeDO updateObj = CrmBusinessStatusTypeConvert.INSTANCE.convert(updateReqVO); + businessStatusTypeMapper.updateById(updateObj); + } + + @Override + public void deleteBusinessStatusType(Long id) { + // 校验存在 + validateBusinessStatusTypeExists(id); + // 删除 + businessStatusTypeMapper.deleteById(id); + } + + private void validateBusinessStatusTypeExists(Long id) { + if (businessStatusTypeMapper.selectById(id) == null) { + throw exception(BUSINESS_STATUS_TYPE_NOT_EXISTS); + } + } + + @Override + public CrmBusinessStatusTypeDO getBusinessStatusType(Long id) { + return businessStatusTypeMapper.selectById(id); + } + + @Override + public List getBusinessStatusTypeList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return businessStatusTypeMapper.selectBatchIds(ids); + } + + @Override + public PageResult getBusinessStatusTypePage(CrmBusinessStatusTypePageReqVO pageReqVO) { + return businessStatusTypeMapper.selectPage(pageReqVO); + } + + @Override + public List getBusinessStatusTypeList(CrmBusinessStatusTypeExportReqVO exportReqVO) { + return businessStatusTypeMapper.selectList(exportReqVO); + } + + @Override + public List getBusinessStatusTypeListByStatus(Integer status) { + return businessStatusTypeMapper.getBusinessStatusTypeListByStatus(status); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/businessstatustype/CrmBusinessStatusTypeMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/businessstatustype/CrmBusinessStatusTypeMapper.xml new file mode 100644 index 000000000..44fbd07ec --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/businessstatustype/CrmBusinessStatusTypeMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImplTest.java new file mode 100644 index 000000000..44030db3b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImplTest.java @@ -0,0 +1,170 @@ +package cn.iocoder.yudao.module.crm.service.businessstatus; + +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.businessstatus.vo.CrmBusinessStatusCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusUpdateReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; +import cn.iocoder.yudao.module.crm.dal.mysql.businessstatus.CrmBusinessStatusMapper; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_NOT_EXISTS; +import static org.junit.jupiter.api.Assertions.*; + +/** + * {@link CrmBusinessStatusServiceImpl} 的单元测试类 + * + * @author ljlleo + */ +@Import(CrmBusinessStatusServiceImpl.class) +public class CrmBusinessStatusServiceImplTest extends BaseDbUnitTest { + + @Resource + private CrmBusinessStatusServiceImpl businessStatusService; + + @Resource + private CrmBusinessStatusMapper businessStatusMapper; + + @Test + public void testCreateBusinessStatus_success() { + // 准备参数 + CrmBusinessStatusCreateReqVO reqVO = randomPojo(CrmBusinessStatusCreateReqVO.class); + + // 调用 + Long businessStatusId = businessStatusService.createBusinessStatus(reqVO); + // 断言 + assertNotNull(businessStatusId); + // 校验记录的属性是否正确 + CrmBusinessStatusDO businessStatus = businessStatusMapper.selectById(businessStatusId); + assertPojoEquals(reqVO, businessStatus); + } + + @Test + public void testUpdateBusinessStatus_success() { + // mock 数据 + CrmBusinessStatusDO dbBusinessStatus = randomPojo(CrmBusinessStatusDO.class); + businessStatusMapper.insert(dbBusinessStatus);// @Sql: 先插入出一条存在的数据 + // 准备参数 + CrmBusinessStatusUpdateReqVO reqVO = randomPojo(CrmBusinessStatusUpdateReqVO.class, o -> { + o.setId(dbBusinessStatus.getId()); // 设置更新的 ID + }); + + // 调用 + businessStatusService.updateBusinessStatus(reqVO); + // 校验是否更新正确 + CrmBusinessStatusDO businessStatus = businessStatusMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, businessStatus); + } + + @Test + public void testUpdateBusinessStatus_notExists() { + // 准备参数 + CrmBusinessStatusUpdateReqVO reqVO = randomPojo(CrmBusinessStatusUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> businessStatusService.updateBusinessStatus(reqVO), BUSINESS_STATUS_NOT_EXISTS); + } + + @Test + public void testDeleteBusinessStatus_success() { + // mock 数据 + CrmBusinessStatusDO dbBusinessStatus = randomPojo(CrmBusinessStatusDO.class); + businessStatusMapper.insert(dbBusinessStatus);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbBusinessStatus.getId(); + + // 调用 + businessStatusService.deleteBusinessStatus(id); + // 校验数据不存在了 + assertNull(businessStatusMapper.selectById(id)); + } + + @Test + public void testDeleteBusinessStatus_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> businessStatusService.deleteBusinessStatus(id), BUSINESS_STATUS_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetBusinessStatusPage() { + // mock 数据 + CrmBusinessStatusDO dbBusinessStatus = randomPojo(CrmBusinessStatusDO.class, o -> { // 等会查询到 + o.setTypeId(null); + o.setName(null); + o.setPercent(null); + o.setSort(null); + }); + businessStatusMapper.insert(dbBusinessStatus); + // 测试 typeId 不匹配 + businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setTypeId(null))); + // 测试 name 不匹配 + businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setName(null))); + // 测试 percent 不匹配 + businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setPercent(null))); + // 测试 sort 不匹配 + businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setSort(null))); + // 准备参数 + CrmBusinessStatusPageReqVO reqVO = new CrmBusinessStatusPageReqVO(); + reqVO.setTypeId(null); + reqVO.setName(null); + reqVO.setPercent(null); + reqVO.setSort(null); + + // 调用 + PageResult pageResult = businessStatusService.getBusinessStatusPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbBusinessStatus, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetBusinessStatusList() { + // mock 数据 + CrmBusinessStatusDO dbBusinessStatus = randomPojo(CrmBusinessStatusDO.class, o -> { // 等会查询到 + o.setTypeId(null); + o.setName(null); + o.setPercent(null); + o.setSort(null); + }); + businessStatusMapper.insert(dbBusinessStatus); + // 测试 typeId 不匹配 + businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setTypeId(null))); + // 测试 name 不匹配 + businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setName(null))); + // 测试 percent 不匹配 + businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setPercent(null))); + // 测试 sort 不匹配 + businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setSort(null))); + // 准备参数 + CrmBusinessStatusExportReqVO reqVO = new CrmBusinessStatusExportReqVO(); + reqVO.setTypeId(null); + reqVO.setName(null); + reqVO.setPercent(null); + reqVO.setSort(null); + + // 调用 + List list = businessStatusService.getBusinessStatusList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbBusinessStatus, list.get(0)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImplTest.java new file mode 100644 index 000000000..58f054b1c --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImplTest.java @@ -0,0 +1,171 @@ +package cn.iocoder.yudao.module.crm.service.businessstatustype; + +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.businessstatustype.vo.CrmBusinessStatusTypeCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypePageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo.CrmBusinessStatusTypeUpdateReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO; +import cn.iocoder.yudao.module.crm.dal.mysql.businessstatustype.CrmBusinessStatusTypeMapper; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.context.annotation.Import; + +import javax.annotation.Resource; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_STATUS_TYPE_NOT_EXISTS; +import static org.junit.jupiter.api.Assertions.*; + +/** + * {@link CrmBusinessStatusTypeServiceImpl} 的单元测试类 + * + * @author ljlleo + */ +@Import(CrmBusinessStatusTypeServiceImpl.class) +public class CrmBusinessStatusTypeServiceImplTest extends BaseDbUnitTest { + + @Resource + private CrmBusinessStatusTypeServiceImpl businessStatusTypeService; + + @Resource + private CrmBusinessStatusTypeMapper businessStatusTypeMapper; + + @Test + public void testCreateBusinessStatusType_success() { + // 准备参数 + CrmBusinessStatusTypeCreateReqVO reqVO = randomPojo(CrmBusinessStatusTypeCreateReqVO.class); + + // 调用 + Long businessStatusTypeId = businessStatusTypeService.createBusinessStatusType(reqVO); + // 断言 + assertNotNull(businessStatusTypeId); + // 校验记录的属性是否正确 + CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(businessStatusTypeId); + assertPojoEquals(reqVO, businessStatusType); + } + + @Test + public void testUpdateBusinessStatusType_success() { + // mock 数据 + CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class); + businessStatusTypeMapper.insert(dbBusinessStatusType);// @Sql: 先插入出一条存在的数据 + // 准备参数 + CrmBusinessStatusTypeUpdateReqVO reqVO = randomPojo(CrmBusinessStatusTypeUpdateReqVO.class, o -> { + o.setId(dbBusinessStatusType.getId()); // 设置更新的 ID + }); + + // 调用 + businessStatusTypeService.updateBusinessStatusType(reqVO); + // 校验是否更新正确 + CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, businessStatusType); + } + + @Test + public void testUpdateBusinessStatusType_notExists() { + // 准备参数 + CrmBusinessStatusTypeUpdateReqVO reqVO = randomPojo(CrmBusinessStatusTypeUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> businessStatusTypeService.updateBusinessStatusType(reqVO), BUSINESS_STATUS_TYPE_NOT_EXISTS); + } + + @Test + public void testDeleteBusinessStatusType_success() { + // mock 数据 + CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class); + businessStatusTypeMapper.insert(dbBusinessStatusType);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbBusinessStatusType.getId(); + + // 调用 + businessStatusTypeService.deleteBusinessStatusType(id); + // 校验数据不存在了 + assertNull(businessStatusTypeMapper.selectById(id)); + } + + @Test + public void testDeleteBusinessStatusType_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> businessStatusTypeService.deleteBusinessStatusType(id), BUSINESS_STATUS_TYPE_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetBusinessStatusTypePage() { + // mock 数据 + CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class, o -> { // 等会查询到 + o.setName(null); + o.setDeptIds(null); + o.setStatus(null); + o.setCreateTime(null); + }); + businessStatusTypeMapper.insert(dbBusinessStatusType); + // 测试 name 不匹配 + businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setName(null))); + // 测试 deptIds 不匹配 + businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setDeptIds(null))); + // 测试 status 不匹配 + businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setStatus(null))); + // 测试 createTime 不匹配 + businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setCreateTime(null))); + // 准备参数 + CrmBusinessStatusTypePageReqVO reqVO = new CrmBusinessStatusTypePageReqVO(); + reqVO.setName(null); + reqVO.setDeptIds(null); + reqVO.setStatus(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = businessStatusTypeService.getBusinessStatusTypePage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbBusinessStatusType, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetBusinessStatusTypeList() { + // mock 数据 + CrmBusinessStatusTypeDO dbBusinessStatusType = randomPojo(CrmBusinessStatusTypeDO.class, o -> { // 等会查询到 + o.setName(null); + o.setDeptIds(null); + o.setStatus(null); + o.setCreateTime(null); + }); + businessStatusTypeMapper.insert(dbBusinessStatusType); + // 测试 name 不匹配 + businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setName(null))); + // 测试 deptIds 不匹配 + businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setDeptIds(null))); + // 测试 status 不匹配 + businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setStatus(null))); + // 测试 createTime 不匹配 + businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setCreateTime(null))); + // 准备参数 + CrmBusinessStatusTypeExportReqVO reqVO = new CrmBusinessStatusTypeExportReqVO(); + reqVO.setName(null); + reqVO.setDeptIds(null); + reqVO.setStatus(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + List list = businessStatusTypeService.getBusinessStatusTypeList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbBusinessStatusType, list.get(0)); + } + +} diff --git a/yudao-ui-admin/src/api/crm/business.js b/yudao-ui-admin/src/api/crm/business.js new file mode 100644 index 000000000..24789df72 --- /dev/null +++ b/yudao-ui-admin/src/api/crm/business.js @@ -0,0 +1,54 @@ +import request from '@/utils/request' + +// 创建商机 +export function createBusiness(data) { + return request({ + url: '/crm/business/create', + method: 'post', + data: data + }) +} + +// 更新商机 +export function updateBusiness(data) { + return request({ + url: '/crm/business/update', + method: 'put', + data: data + }) +} + +// 删除商机 +export function deleteBusiness(id) { + return request({ + url: '/crm/business/delete?id=' + id, + method: 'delete' + }) +} + +// 获得商机 +export function getBusiness(id) { + return request({ + url: '/crm/business/get?id=' + id, + method: 'get' + }) +} + +// 获得商机分页 +export function getBusinessPage(query) { + return request({ + url: '/crm/business/page', + method: 'get', + params: query + }) +} + +// 导出商机 Excel +export function exportBusinessExcel(query) { + return request({ + url: '/crm/business/export-excel', + method: 'get', + params: query, + responseType: 'blob' + }) +} diff --git a/yudao-ui-admin/src/api/crm/businessStatus.js b/yudao-ui-admin/src/api/crm/businessStatus.js new file mode 100644 index 000000000..d4249d7ac --- /dev/null +++ b/yudao-ui-admin/src/api/crm/businessStatus.js @@ -0,0 +1,70 @@ +import request from '@/utils/request' + +// 创建商机状态 +export function createBusinessStatus(data) { + return request({ + url: '/crm/business-status/create', + method: 'post', + data: data + }) +} + +// 更新商机状态 +export function updateBusinessStatus(data) { + return request({ + url: '/crm/business-status/update', + method: 'put', + data: data + }) +} + +// 删除商机状态 +export function deleteBusinessStatus(id) { + return request({ + url: '/crm/business-status/delete?id=' + id, + method: 'delete' + }) +} + +// 获得商机状态 +export function getBusinessStatus(id) { + return request({ + url: '/crm/business-status/get?id=' + id, + method: 'get' + }) +} + +// 获得商机状态分页 +export function getBusinessStatusPage(query) { + return request({ + url: '/crm/business-status/page', + method: 'get', + params: query + }) +} + +// 导出商机状态 Excel +export function exportBusinessStatusExcel(query) { + return request({ + url: '/crm/business-status/export-excel', + method: 'get', + params: query, + responseType: 'blob' + }) +} + +// 根据类型ID获取商机状态信息列表 +export function getBusinessStatusListByTypeId(typeId) { + return request({ + url: '/crm/business-status/get-simple-list?typeId=' + typeId, + method: 'get' + }) +} + +// 获取商机状态信息列表 +export function getBusinessStatusList() { + return request({ + url: '/crm/business-status/get-all-list', + method: 'get' + }) +} diff --git a/yudao-ui-admin/src/api/crm/businessStatusType.js b/yudao-ui-admin/src/api/crm/businessStatusType.js new file mode 100644 index 000000000..5df0aff6c --- /dev/null +++ b/yudao-ui-admin/src/api/crm/businessStatusType.js @@ -0,0 +1,62 @@ +import request from '@/utils/request' + +// 创建商机状态类型 +export function createBusinessStatusType(data) { + return request({ + url: '/crm/business-status-type/create', + method: 'post', + data: data + }) +} + +// 更新商机状态类型 +export function updateBusinessStatusType(data) { + return request({ + url: '/crm/business-status-type/update', + method: 'put', + data: data + }) +} + +// 删除商机状态类型 +export function deleteBusinessStatusType(id) { + return request({ + url: '/crm/business-status-type/delete?id=' + id, + method: 'delete' + }) +} + +// 获得商机状态类型 +export function getBusinessStatusType(id) { + return request({ + url: '/crm/business-status-type/get?id=' + id, + method: 'get' + }) +} + +// 获得商机状态类型分页 +export function getBusinessStatusTypePage(query) { + return request({ + url: '/crm/business-status-type/page', + method: 'get', + params: query + }) +} + +// 导出商机状态类型 Excel +export function exportBusinessStatusTypeExcel(query) { + return request({ + url: '/crm/business-status-type/export-excel', + method: 'get', + params: query, + responseType: 'blob' + }) +} + +// 获取商机状态类型信息列表 +export function getBusinessStatusTypeList() { + return request({ + url: '/crm/business-status-type/get-simple-list', + method: 'get' + }) +} diff --git a/yudao-ui-admin/src/views/crm/business/index.vue b/yudao-ui-admin/src/views/crm/business/index.vue new file mode 100644 index 000000000..b877a33af --- /dev/null +++ b/yudao-ui-admin/src/views/crm/business/index.vue @@ -0,0 +1,335 @@ + + + From 74f786f8ed2a31e6bd947c42b3eadd92f34df43e Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 27 Oct 2023 22:56:46 +0800 Subject: [PATCH 025/101] =?UTF-8?q?code=20review=EF=BC=9A=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E8=A1=A8=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/customer/vo/CrmCustomerBaseVO.java | 7 ++++++- .../admin/customer/vo/CrmCustomerCreateReqVO.java | 2 ++ .../admin/customer/vo/CrmCustomerExcelVO.java | 2 +- .../admin/customer/vo/CrmCustomerExportReqVO.java | 1 + .../admin/customer/vo/CrmCustomerPageReqVO.java | 3 +++ .../admin/customer/vo/CrmCustomerUpdateReqVO.java | 1 + .../crm/convert/customer/CrmCustomerConvert.java | 2 -- .../module/crm/dal/dataobject/clue/CrmClueDO.java | 3 ++- .../crm/dal/dataobject/customer/CrmCustomerDO.java | 10 +++------- .../module/crm/service/clue/CrmClueServiceImpl.java | 1 + .../service/customer/CrmCustomerServiceImplTest.java | 1 + 11 files changed, 21 insertions(+), 12 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java index 039cda53a..0db54fa1f 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java @@ -19,14 +19,16 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class CrmCustomerBaseVO { - @Schema(description = "客户名称", example = "赵六") + @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") @NotEmpty(message = "客户名称不能为空") private String name; + // TODO wanwan:这个字段应该只有 RespVO 会有;创建和修改不传递; @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") @NotNull(message = "跟进状态不能为空") private Boolean followUpStatus; + // TODO wanwan:这个字段应该只有 RespVO 会有;创建和修改不传递; @Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") @NotNull(message = "锁定状态不能为空") private Boolean lockStatus; @@ -45,6 +47,7 @@ public class CrmCustomerBaseVO { @Schema(description = "备注", example = "随便") private String remark; + // TODO wanwan:这个字段应该只有 RespVO 会有;创建和修改不传递;因为它会在“移交”里面做哈 @Schema(description = "负责人的用户编号", example = "25682") @NotNull(message = "负责人不能为空") private Long ownerUserId; @@ -55,12 +58,14 @@ public class CrmCustomerBaseVO { @Schema(description = "详细地址", example = "北京市海淀区") private String detailAddress; + // TODO @芋艿:longitude、latitude 这两个字段删除; @Schema(description = "地理位置经度", example = "116.40341") private String longitude; @Schema(description = "地理位置维度", example = "39.92409") private String latitude; + // TODO wanwan:这个字段应该只有 RespVO 会有;创建和修改不传递; @Schema(description = "最后跟进时间") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime contactLastTime; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java index dae9cf212..a3ed7ef13 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java @@ -11,9 +11,11 @@ import lombok.ToString; @ToString(callSuper = true) public class CrmCustomerCreateReqVO extends CrmCustomerBaseVO { + // TODO @wanwan:类型应该是传递 List; 不过这个字段,默认新建的时候不传递,在“移交”功能里管理 @Schema(description = "只读权限的用户编号数组") private String roUserIds; + // TODO @wanwan:类型应该是传递 List; 不过这个字段,默认新建的时候不传递,在“移交”功能里管理 @Schema(description = "读写权限的用户编号数组") private String rwUserIds; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java index 6cf7cbd0f..3e37c30e7 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java @@ -8,7 +8,7 @@ import lombok.Data; import java.time.LocalDateTime; - +// TODO 芋艿:导出最后做,等基本确认的差不多之后; /** * 客户 Excel VO * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java index 27198ff0d..15776aa42 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +// TODO 芋艿:导出最后做,等基本确认的差不多之后; @Schema(description = "管理后台 - 客户 Excel 导出 Request VO,参数和 CrmCustomerPageReqVO 是一致的") @Data public class CrmCustomerExportReqVO { diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java index 3871e422d..7cb89adbc 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java @@ -18,10 +18,13 @@ public class CrmCustomerPageReqVO extends PageParam { @Schema(description = "手机", example = "18000000000") private String mobile; + // TODO @wanwan:这个字段不需要哈 @Schema(description = "电话", example = "18000000000") private String telephone; + // TODO @wanwan:这个字段不需要哈 @Schema(description = "网址", example = "https://www.baidu.com") private String website; + // TODO @芋艿:场景; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java index a54938ea2..59d440a35 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java @@ -17,6 +17,7 @@ public class CrmCustomerUpdateReqVO extends CrmCustomerBaseVO { @NotNull(message = "编号不能为空") private Long id; + // TODO @wanwan:下面两个字段,同 CrmCustomerCreateReqVO @Schema(description = "只读权限的用户编号数组") private String roUserIds; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java index da683fbfb..937705d99 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java @@ -25,8 +25,6 @@ public interface CrmCustomerConvert { CrmCustomerRespVO convert(CrmCustomerDO bean); - List convertList(List list); - PageResult convertPage(PageResult page); List convertList02(List list); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java index 067bec65c..1c6ccd608 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java @@ -44,7 +44,8 @@ public class CrmClueDO extends BaseDO { private String name; /** * 客户 id - * 对应 {@link CrmCustomerDO#getId()} + * + * 关联 {@link CrmCustomerDO#getId()} */ private Long customerId; /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java index d35650905..101d0dd27 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java @@ -4,11 +4,11 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import com.sun.xml.bind.v2.TODO; import lombok.*; import java.time.LocalDateTime; +// TODO 芋艿:调整下字段 /** * 客户 DO * @@ -35,20 +35,14 @@ public class CrmCustomerDO extends BaseDO { private String name; /** * 跟进状态 - *

- * 枚举 {@link TODO infra_boolean_string 对应的类} */ private Boolean followUpStatus; /** * 锁定状态 - *

- * 枚举 {@link TODO infra_boolean_string 对应的类} */ private Boolean lockStatus; /** * 成交状态 - *

- * 枚举 {@link TODO infra_boolean_string 对应的类} */ private Boolean dealStatus; /** @@ -71,6 +65,7 @@ public class CrmCustomerDO extends BaseDO { * 负责人的用户编号 */ private Long ownerUserId; + // TODO @wanwan:下面两个字段,使用 List,然后使用 typeHandler = LongListTypeHandler 解决持久化的问题;注意类上需要加 autoResultMap = true /** * 只读权限的用户编号数组 */ @@ -87,6 +82,7 @@ public class CrmCustomerDO extends BaseDO { * 详细地址 */ private String detailAddress; + // TODO @wanwan:下面两个字段:删除 /** * 地理位置经度 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java index 3389c4b26..32577dd24 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java @@ -96,6 +96,7 @@ public class CrmClueServiceImpl implements CrmClueService { return clueMapper.selectList(exportReqVO); } + // TODO @wanwan:可以在 CrmClueServiceImpl 中,增加一个方法,用于校验客户是否存在;validateCustomer;然后其它方法可以调用它。不过要注意,需要把 CustomerDO 返回,因为其它模块可能要它的信息 /** * 校验客户是否存在 * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java index 2e7d17907..adce8b163 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java @@ -23,6 +23,7 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; import static org.junit.jupiter.api.Assertions.*; +// TODO 芋艿:单测后续补 /** * {@link CrmCustomerServiceImpl} 的单元测试类 * From 81b6aebf476426e356fd0b68dda5f1b7fd7f3e66 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 27 Oct 2023 23:27:08 +0800 Subject: [PATCH 026/101] =?UTF-8?q?code=20review=EF=BC=9A=E5=95=86?= =?UTF-8?q?=E6=9C=BA=E8=A1=A8=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/module/crm/enums/ErrorCodeConstants.java | 3 +++ .../businessstatus/CrmBusinessStatusController.java | 4 ++++ .../businessstatus/vo/CrmBusinessStatusBaseVO.java | 4 ++++ .../businessstatus/vo/CrmBusinessStatusExcelVO.java | 6 ++---- .../vo/CrmBusinessStatusExportReqVO.java | 5 ++--- .../businessstatus/vo/CrmBusinessStatusRespVO.java | 2 +- .../vo/CrmBusinessStatusUpdateReqVO.java | 12 +++++++----- .../CrmBusinessStatusTypeController.java | 2 ++ .../vo/CrmBusinessStatusTypeCreateReqVO.java | 1 + .../vo/CrmBusinessStatusTypeExcelVO.java | 10 ++++------ .../vo/CrmBusinessStatusTypeExportReqVO.java | 8 ++++---- .../vo/CrmBusinessStatusTypeUpdateReqVO.java | 9 ++++++--- .../businessstatus/CrmBusinessStatusDO.java | 2 ++ .../businessstatustype/CrmBusinessStatusTypeDO.java | 2 ++ .../CrmBusinessStatusTypeMapper.java | 4 +--- .../businessstatus/CrmBusinessStatusService.java | 4 ++-- .../CrmBusinessStatusTypeServiceImpl.java | 3 +++ 17 files changed, 50 insertions(+), 31 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 374687e5e..124a70cb7 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -17,6 +17,9 @@ public interface ErrorCodeConstants { // ========== 商机管理 1-020-002-000 ========== ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); + + // TODO @lilleo:商机状态、商机类型,都单独错误码段 + ErrorCode BUSINESS_STATUS_TYPE_NOT_EXISTS = new ErrorCode(1_020_002_001, "商机状态类型不存在"); ErrorCode BUSINESS_STATUS_NOT_EXISTS = new ErrorCode(1_020_002_002, "商机状态不存在"); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/CrmBusinessStatusController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/CrmBusinessStatusController.java index fddec8d8d..275285098 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/CrmBusinessStatusController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/CrmBusinessStatusController.java @@ -25,6 +25,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; +// TODO @lilleo:这个模块,可以挪到 business 下;这样我打开 business 包下,就知道,噢~原来里面有 business 商机、有 type 状态类型、status 具体状态; @Tag(name = "管理后台 - 商机状态") @RestController @RequestMapping("/crm/business-status") @@ -67,6 +68,7 @@ public class CrmBusinessStatusController { return success(CrmBusinessStatusConvert.INSTANCE.convert(businessStatus)); } + // TODO @lilleo:这个接口,暂时用不到,可以考虑先删除掉 @GetMapping("/list") @Operation(summary = "获得商机状态列表") @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") @@ -96,6 +98,7 @@ public class CrmBusinessStatusController { ExcelUtils.write(response, "商机状态.xls", "数据", CrmBusinessStatusExcelVO.class, datas); } + // TODO 芋艿:后续再看看 @GetMapping("/get-simple-list") @Operation(summary = "获得商机状态列表") @PreAuthorize("@ss.hasPermission('crm:business-status:query')") @@ -104,6 +107,7 @@ public class CrmBusinessStatusController { return success(CrmBusinessStatusConvert.INSTANCE.convertList(list)); } + // TODO 芋艿:后续再看看 @GetMapping("/get-all-list") @Operation(summary = "获得商机状态列表") @PreAuthorize("@ss.hasPermission('crm:business-status:query')") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusBaseVO.java index eec9de8b0..401e35fbe 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusBaseVO.java @@ -12,6 +12,8 @@ import javax.validation.constraints.NotNull; @Data public class CrmBusinessStatusBaseVO { + // TODO @lilleo:example 要写下 + @Schema(description = "状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22882") @NotNull(message = "状态类型编号不能为空") private Long typeId; @@ -20,9 +22,11 @@ public class CrmBusinessStatusBaseVO { @NotNull(message = "状态名不能为空") private String name; + // TODO @lilleo:percent 应该是 Integer; @Schema(description = "赢单率") private String percent; + // TODO @lilleo:这个是不是不用前端新增和修改的时候传递,交给顺序计算出来,存储起来就好了; @Schema(description = "排序") private Integer sort; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExcelVO.java index 83002469e..78da092f7 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExcelVO.java @@ -1,11 +1,9 @@ package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; - import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; +// TODO @lilleo:这个暂时不需要;嘿嘿~不是每个模块都需要导出哈 /** * 商机状态 Excel VO * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExportReqVO.java index 3fecb03ee..7f7fba6c7 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExportReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusExportReqVO.java @@ -1,10 +1,9 @@ package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo; -import lombok.*; -import java.util.*; import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; +import lombok.Data; +// TODO @lilleo:这个暂时不需要;嘿嘿~不是每个模块都需要导出哈 @Schema(description = "管理后台 - 商机状态 Excel 导出 Request VO,参数和 CrmBusinessStatusPageReqVO 是一致的") @Data public class CrmBusinessStatusExportReqVO { diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusRespVO.java index 2a0fa07a4..54f675272 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusRespVO.java @@ -9,7 +9,7 @@ import lombok.*; @ToString(callSuper = true) public class CrmBusinessStatusRespVO extends CrmBusinessStatusBaseVO { - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "6802") + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6802") private Long id; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusUpdateReqVO.java index 11f403330..429902164 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatus/vo/CrmBusinessStatusUpdateReqVO.java @@ -1,9 +1,11 @@ package cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import javax.validation.constraints.NotNull; @Schema(description = "管理后台 - 商机状态更新 Request VO") @Data @@ -11,8 +13,8 @@ import javax.validation.constraints.*; @ToString(callSuper = true) public class CrmBusinessStatusUpdateReqVO extends CrmBusinessStatusBaseVO { - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "6802") - @NotNull(message = "主键不能为空") + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "6802") + @NotNull(message = "编号不能为空") private Long id; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/CrmBusinessStatusTypeController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/CrmBusinessStatusTypeController.java index ae0c55d62..25ba7448f 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/CrmBusinessStatusTypeController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/CrmBusinessStatusTypeController.java @@ -26,6 +26,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; +// TODO @lilleo:这个模块,可以挪到 business 下;这样我打开 business 包下,就知道,噢~原来里面有 business 商机、有 type 状态类型、status 具体状态; @Tag(name = "管理后台 - 商机状态类型") @RestController @RequestMapping("/crm/business-status-type") @@ -68,6 +69,7 @@ public class CrmBusinessStatusTypeController { return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(businessStatusType)); } + // TODO @lilleo:这个接口,暂时用不到,可以考虑先删除掉 @GetMapping("/list") @Operation(summary = "获得商机状态类型列表") @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeCreateReqVO.java index e9f958a6c..5000e25ee 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeCreateReqVO.java @@ -5,6 +5,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; +// TODO 状态类型和状态添加,是在一个请求里,所以需要把 CrmBusinessStatusCreateReqVO 融合进来; @Schema(description = "管理后台 - 商机状态类型创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExcelVO.java index ea82616de..cc6ed8502 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExcelVO.java @@ -1,13 +1,11 @@ package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; - import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; +import java.time.LocalDateTime; + +// TODO @lilleo:这个暂时不需要;嘿嘿~不是每个模块都需要导出哈 /** * 商机状态类型 Excel VO * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExportReqVO.java index 48d5bc7ed..1345565be 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExportReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeExportReqVO.java @@ -1,14 +1,14 @@ package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo; -import lombok.*; -import java.util.*; import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import java.time.LocalDateTime; +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; +// TODO @lilleo:这个暂时不需要;嘿嘿~不是每个模块都需要导出哈 @Schema(description = "管理后台 - 商机状态类型 Excel 导出 Request VO,参数和 CrmBusinessStatusTypePageReqVO 是一致的") @Data public class CrmBusinessStatusTypeExportReqVO { diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeUpdateReqVO.java index 5fab5fc2f..0eb93224c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/businessstatustype/vo/CrmBusinessStatusTypeUpdateReqVO.java @@ -1,10 +1,13 @@ package cn.iocoder.yudao.module.crm.controller.admin.businessstatustype.vo; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import javax.validation.constraints.NotNull; + +// TODO 状态类型和状态添加,是在一个请求里,所以需要把 CrmBusinessStatusUpdateReqVO 融合进来; @Schema(description = "管理后台 - 商机状态类型更新 Request VO") @Data @EqualsAndHashCode(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatus/CrmBusinessStatusDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatus/CrmBusinessStatusDO.java index a60c6e40d..3a1b66ad0 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatus/CrmBusinessStatusDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatus/CrmBusinessStatusDO.java @@ -26,6 +26,8 @@ public class CrmBusinessStatusDO { private Long id; /** * 状态类型编号 + * + * // TODO @ljlleo:要写下关联字段噢 */ private Long typeId; /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatustype/CrmBusinessStatusTypeDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatustype/CrmBusinessStatusTypeDO.java index 4a2005e49..fbc2e6857 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatustype/CrmBusinessStatusTypeDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/businessstatustype/CrmBusinessStatusTypeDO.java @@ -28,6 +28,7 @@ public class CrmBusinessStatusTypeDO { * 状态类型名 */ private String name; + // TODO @ljlleo:List 存储哈 /** * 使用的部门编号 */ @@ -35,6 +36,7 @@ public class CrmBusinessStatusTypeDO { /** * 开启状态 */ + // TODO @ljlleo:这个字段,使用 Integer,对应 CommonStatus private Boolean status; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatustype/CrmBusinessStatusTypeMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatustype/CrmBusinessStatusTypeMapper.java index bc23b2e8b..258477e4d 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatustype/CrmBusinessStatusTypeMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/businessstatustype/CrmBusinessStatusTypeMapper.java @@ -21,7 +21,7 @@ public interface CrmBusinessStatusTypeMapper extends BaseMapperX selectPage(CrmBusinessStatusTypePageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .likeIfPresent(CrmBusinessStatusTypeDO::getName, reqVO.getName()) - .eqIfPresent(CrmBusinessStatusTypeDO::getDeptIds, reqVO.getDeptIds()) +// .eqIfPresent(CrmBusinessStatusTypeDO::getDeptIds, reqVO.getDeptIds()) TODO 报错,临时注释掉 .eqIfPresent(CrmBusinessStatusTypeDO::getStatus, reqVO.getStatus()) .orderByDesc(CrmBusinessStatusTypeDO::getId)); } @@ -38,6 +38,4 @@ public interface CrmBusinessStatusTypeMapper extends BaseMapperX getBusinessStatusList(CrmBusinessStatusExportReqVO exportReqVO); /** - * 根据类型ID获得商机状态列表 + * 根据类型 ID 获得商机状态列表 * - * @param typeId 商机状态类型ID + * @param typeId 商机状态类型 ID * @return 商机状态列表 */ List getBusinessStatusListByTypeId(Integer typeId); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImpl.java index 88b25ad1e..f428c3836 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImpl.java @@ -34,6 +34,7 @@ public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeSe @Override public Long createBusinessStatusType(CrmBusinessStatusTypeCreateReqVO createReqVO) { + // TODO ljlleo:name 应该需要唯一哈; // 插入 CrmBusinessStatusTypeDO businessStatusType = CrmBusinessStatusTypeConvert.INSTANCE.convert(createReqVO); businessStatusTypeMapper.insert(businessStatusType); @@ -43,6 +44,7 @@ public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeSe @Override public void updateBusinessStatusType(CrmBusinessStatusTypeUpdateReqVO updateReqVO) { + // TODO ljlleo:name 应该需要唯一哈; // 校验存在 validateBusinessStatusTypeExists(updateReqVO.getId()); // 更新 @@ -54,6 +56,7 @@ public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeSe public void deleteBusinessStatusType(Long id) { // 校验存在 validateBusinessStatusTypeExists(id); + // TODO 艿艿:这里在看看,是不是要校验业务是否在使用; // 删除 businessStatusTypeMapper.deleteById(id); } From 301f497527edcc8a594dbc8fe79a91ab8eeec079 Mon Sep 17 00:00:00 2001 From: liuhongfeng <291117974@qq.com> Date: Sat, 28 Oct 2023 00:37:47 +0800 Subject: [PATCH 027/101] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91?= =?UTF-8?q?=E5=9B=9E=E6=AC=BE=E8=AE=A1=E5=88=92-=E5=AE=A1=E6=89=B9?= =?UTF-8?q?=E6=9E=9A=E4=B8=BE=E7=B1=BB=20=E3=80=90=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E3=80=91=E5=9B=9E=E6=AC=BE=E8=AE=A1=E5=88=92-=E5=9B=9E?= =?UTF-8?q?=E6=AC=BE=E6=96=B9=E5=BC=8F=E6=9E=9A=E4=B8=BE=E7=B1=BB=20?= =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91=E5=9B=9E=E6=AC=BE=E8=AE=A1?= =?UTF-8?q?=E5=88=92-=E6=9E=9A=E4=B8=BE=E7=B1=BB=E6=A0=A1=E9=AA=8C=20?= =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E5=9B=9E=E6=AC=BE=E8=AE=A1?= =?UTF-8?q?=E5=88=92-=E9=94=99=E8=AF=AF=E7=A0=81=E8=B0=83=E6=95=B4=20?= =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E4=BF=AE=E6=94=B9=E5=9B=9E?= =?UTF-8?q?=E6=AC=BE=E8=AE=A1=E5=88=92-=E5=88=9B=E5=BB=BA=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=90=88=E5=90=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9A=84=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/AuditStatusEnum.java | 61 +++++++++++++++++++ .../module/crm/enums/ErrorCodeConstants.java | 7 ++- .../module/crm/enums/ReturnTypeEnum.java | 8 +++ .../admin/receivable/vo/ReceivableBaseVO.java | 5 +- .../receivable/ReceivableServiceImpl.java | 26 ++++++++ 5 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/AuditStatusEnum.java create mode 100644 yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ReturnTypeEnum.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 new file mode 100644 index 000000000..ce04c18a1 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/AuditStatusEnum.java @@ -0,0 +1,61 @@ +package cn.iocoder.yudao.module.crm.enums; + +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; + +import java.util.Arrays; + +/** + * 流程审批状态枚举类 + * 0 未审核 1 审核通过 2 审核拒绝 3 审核中 4 已撤回 + * @author 赤焰 + */ +public enum AuditStatusEnum implements IntArrayValuable { + /** + * 未审批 + */ + AUDIT_NEW(0, "未审批"), + /** + * 审核通过 + */ + AUDIT_FINISH(0, "审核通过"), + /** + * 审核拒绝 + */ + AUDIT_REJECT(2, "审核拒绝"), + /** + * 审核中 + */ + AUDIT_DOING(3, "审核中"), + /** + * 已撤回 + */ + AUDIT_RETURN(4, "已撤回"); + + private final Integer value; + private final String desc; + + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AuditStatusEnum::getValue).toArray(); + + /** + * + * @param value + * @param desc + */ + 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/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 07d9b6d6a..ea0f2d51f 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -21,9 +21,10 @@ public interface ErrorCodeConstants { // ========== 联系人管理 1-020-003-000 ========== ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); - // TODO @liuhongfeng:错误码分段; - ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_030_000_001, "回款管理不存在"); + // ========== 回款管理 1-020-004-000 ========== + ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款管理不存在"); - ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_040_000_001, "回款计划不存在"); + // ========== 合同管理 1-020-005-000 ========== + ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_020_005_000, "回款计划不存在"); } 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 new file mode 100644 index 000000000..d9ca477be --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ReturnTypeEnum.java @@ -0,0 +1,8 @@ +package cn.iocoder.yudao.module.crm.enums; + +/** + * @author 赤焰 + */ + +public enum ReturnTypeEnum { +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java index bb0bc5745..8aa43e50b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java @@ -1,5 +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 io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; @@ -33,9 +35,8 @@ public class ReceivableBaseVO { @Schema(description = "合同ID", example = "30305") private Long contractId; - // TODO @liuhongfeng:这个字段,可以写个枚举,然后 InEnum 去校验下; - // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的 @Schema(description = "审批状态", example = "1") + @InEnum(AuditStatusEnum.class) private Integer checkStatus; // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java index 94b25f6ed..39de05fe1 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java @@ -2,14 +2,19 @@ package cn.iocoder.yudao.module.crm.service.receivable; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableCreateReqVO; import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableExportReqVO; import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableUpdateReqVO; import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; +import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; +import cn.iocoder.yudao.module.crm.service.contract.ContractService; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -18,6 +23,7 @@ import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS; import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_NOT_EXISTS; /** @@ -31,6 +37,8 @@ public class ReceivableServiceImpl implements ReceivableService { @Resource private ReceivableMapper receivableMapper; + @Resource + private ContractService contractService; @Override public Long createReceivable(ReceivableCreateReqVO createReqVO) { @@ -38,11 +46,29 @@ public class ReceivableServiceImpl implements ReceivableService { // TODO @liuhongfeng:其它类似 customerId、contractId 也需要去校验; // 插入 ReceivableDO receivable = ReceivableConvert.INSTANCE.convert(createReqVO); + + receivable.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue()); + //校验 + checkReceivable(receivable); + receivableMapper.insert(receivable); // 返回 return receivable.getId(); } + private void checkReceivable(ReceivableDO receivable) { + + if(ObjectUtil.isNull(receivable.getContractId())){ + throw exception(CONTRACT_NOT_EXISTS); + } + + ContractDO contract = contractService.getContract(receivable.getContractId()); + if(ObjectUtil.isNull(contract)){ + throw exception(CONTRACT_NOT_EXISTS); + } + + } + @Override public void updateReceivable(ReceivableUpdateReqVO updateReqVO) { // 校验存在 From c18f5baa4b35d45161439f6368f16c2c9a0df954 Mon Sep 17 00:00:00 2001 From: Wanwan <913752709@qq.com> Date: Sat, 28 Oct 2023 22:47:56 +0800 Subject: [PATCH 028/101] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E8=A1=A8=E7=9A=84=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 2 - .../admin/customer/CrmCustomerController.java | 1 - .../admin/customer/vo/CrmCustomerBaseVO.java | 46 ++++++++----------- .../customer/vo/CrmCustomerCreateReqVO.java | 8 ---- .../admin/customer/vo/CrmCustomerExcelVO.java | 18 +++++--- .../customer/vo/CrmCustomerExportReqVO.java | 6 --- .../customer/vo/CrmCustomerPageReqVO.java | 8 ---- .../admin/customer/vo/CrmCustomerRespVO.java | 16 +++++++ .../customer/vo/CrmCustomerUpdateReqVO.java | 7 --- .../dataobject/customer/CrmCustomerDO.java | 37 +++++++++------ .../dal/mysql/customer/CrmCustomerMapper.java | 4 -- .../crm/service/clue/CrmClueServiceImpl.java | 16 +------ .../service/customer/CrmCustomerService.java | 8 ++++ .../customer/CrmCustomerServiceImpl.java | 14 ++++++ .../src/test/resources/sql/create_tables.sql | 2 - 15 files changed, 95 insertions(+), 98 deletions(-) diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 95a81df8e..1b381bf04 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -203,8 +203,6 @@ CREATE TABLE `crm_customer` ( `rw_user_ids` varchar(4096) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '读写权限的用户编号数组', `area_id` bigint DEFAULT NULL COMMENT '地区编号', `detail_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '详细地址', - `longitude` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地理位置经度', - `latitude` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地理位置维度', `contact_last_time` datetime DEFAULT NULL COMMENT '最后跟进时间', `contact_next_time` datetime DEFAULT NULL COMMENT '下次联系时间', `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java index 7c91b4c1a..78ae1a20d 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java @@ -19,7 +19,6 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; -import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java index 0db54fa1f..fd061a39e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java @@ -6,8 +6,10 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; +import javax.validation.constraints.Email; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -23,16 +25,6 @@ public class CrmCustomerBaseVO { @NotEmpty(message = "客户名称不能为空") private String name; - // TODO wanwan:这个字段应该只有 RespVO 会有;创建和修改不传递; - @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "跟进状态不能为空") - private Boolean followUpStatus; - - // TODO wanwan:这个字段应该只有 RespVO 会有;创建和修改不传递; - @Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") - @NotNull(message = "锁定状态不能为空") - private Boolean lockStatus; - @Schema(description = "手机", example = "18000000000") @Mobile private String mobile; @@ -44,32 +36,32 @@ public class CrmCustomerBaseVO { @Schema(description = "网址", example = "https://www.baidu.com") private String website; + @Schema(description = "QQ", example = "123456789") + @Size(max = 20, message = "QQ长度不能超过20个字符") + private String qq; + + @Schema(description = "wechat", example = "123456789") + @Size(max = 255, message = "微信长度不能超过255个字符") + private String wechat; + + @Schema(description = "email", example = "123456789@qq.com") + @Email(message = "邮箱格式不正确") + @Size(max = 255, message = "邮箱长度不能超过255个字符") + private String email; + + @Schema(description = "客户描述", example = "任意文字") + @Size(max = 4096, message = "客户描述长度不能超过255个字符") + private String description; + @Schema(description = "备注", example = "随便") private String remark; - // TODO wanwan:这个字段应该只有 RespVO 会有;创建和修改不传递;因为它会在“移交”里面做哈 - @Schema(description = "负责人的用户编号", example = "25682") - @NotNull(message = "负责人不能为空") - private Long ownerUserId; - @Schema(description = "地区编号", example = "20158") private Long areaId; @Schema(description = "详细地址", example = "北京市海淀区") private String detailAddress; - // TODO @芋艿:longitude、latitude 这两个字段删除; - @Schema(description = "地理位置经度", example = "116.40341") - private String longitude; - - @Schema(description = "地理位置维度", example = "39.92409") - private String latitude; - - // TODO wanwan:这个字段应该只有 RespVO 会有;创建和修改不传递; - @Schema(description = "最后跟进时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime contactLastTime; - @Schema(description = "下次联系时间") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime contactNextTime; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java index a3ed7ef13..ab806b689 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java @@ -11,12 +11,4 @@ import lombok.ToString; @ToString(callSuper = true) public class CrmCustomerCreateReqVO extends CrmCustomerBaseVO { - // TODO @wanwan:类型应该是传递 List; 不过这个字段,默认新建的时候不传递,在“移交”功能里管理 - @Schema(description = "只读权限的用户编号数组") - private String roUserIds; - - // TODO @wanwan:类型应该是传递 List; 不过这个字段,默认新建的时候不传递,在“移交”功能里管理 - @Schema(description = "读写权限的用户编号数组") - private String rwUserIds; - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java index 3e37c30e7..35b864080 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java @@ -44,6 +44,18 @@ public class CrmCustomerExcelVO { @ExcelProperty("网址") private String website; + @ExcelProperty("QQ") + private String qq; + + @ExcelProperty("wechat") + private String wechat; + + @ExcelProperty("email") + private String email; + + @ExcelProperty("客户描述") + private String description; + @ExcelProperty("备注") private String remark; @@ -56,12 +68,6 @@ public class CrmCustomerExcelVO { @ExcelProperty("详细地址") private String detailAddress; - @ExcelProperty("地理位置经度") - private String longitude; - - @ExcelProperty("地理位置维度") - private String latitude; - @ExcelProperty("最后跟进时间") private LocalDateTime contactLastTime; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java index 15776aa42..03a3f2d4d 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java @@ -14,10 +14,4 @@ public class CrmCustomerExportReqVO { @Schema(description = "手机", example = "18000000000") private String mobile; - @Schema(description = "电话", example = "18000000000") - private String telephone; - - @Schema(description = "网址", example = "https://www.baidu.com") - private String website; - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java index 7cb89adbc..8bf2018f1 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java @@ -18,13 +18,5 @@ public class CrmCustomerPageReqVO extends PageParam { @Schema(description = "手机", example = "18000000000") private String mobile; - // TODO @wanwan:这个字段不需要哈 - @Schema(description = "电话", example = "18000000000") - private String telephone; - - // TODO @wanwan:这个字段不需要哈 - @Schema(description = "网址", example = "https://www.baidu.com") - private String website; - // TODO @芋艿:场景; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java index b5c9850bc..bdcf28f2c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java @@ -4,9 +4,12 @@ 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 = "管理后台 - 客户 Response VO") @Data @EqualsAndHashCode(callSuper = true) @@ -16,9 +19,22 @@ public class CrmCustomerRespVO extends CrmCustomerBaseVO { @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563") private Long id; + @Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + private Boolean followUpStatus; + + @Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") + private Boolean lockStatus; + @Schema(description = "成交状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") private Boolean dealStatus; + @Schema(description = "负责人的用户编号", example = "25682") + private Long ownerUserId; + + @Schema(description = "最后跟进时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime contactLastTime; + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) private LocalDateTime createTime; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java index 59d440a35..545643fd9 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java @@ -17,11 +17,4 @@ public class CrmCustomerUpdateReqVO extends CrmCustomerBaseVO { @NotNull(message = "编号不能为空") private Long id; - // TODO @wanwan:下面两个字段,同 CrmCustomerCreateReqVO - @Schema(description = "只读权限的用户编号数组") - private String roUserIds; - - @Schema(description = "读写权限的用户编号数组") - private String rwUserIds; - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java index 101d0dd27..bb45679bb 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java @@ -1,12 +1,15 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.customer; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; import java.time.LocalDateTime; +import java.util.List; // TODO 芋艿:调整下字段 /** @@ -14,7 +17,7 @@ import java.time.LocalDateTime; * * @author Wanwan */ -@TableName("crm_customer") +@TableName(value = "crm_customer", autoResultMap = true) @KeySequence("crm_customer_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @Data @EqualsAndHashCode(callSuper = true) @@ -57,6 +60,22 @@ public class CrmCustomerDO extends BaseDO { * 网址 */ private String website; + /** + * QQ + */ + private String qq; + /** + * wechat + */ + private String wechat; + /** + * email + */ + private String email; + /** + * 客户描述 + */ + private String description; /** * 备注 */ @@ -65,15 +84,16 @@ public class CrmCustomerDO extends BaseDO { * 负责人的用户编号 */ private Long ownerUserId; - // TODO @wanwan:下面两个字段,使用 List,然后使用 typeHandler = LongListTypeHandler 解决持久化的问题;注意类上需要加 autoResultMap = true /** * 只读权限的用户编号数组 */ - private String roUserIds; + @TableField(typeHandler = LongListTypeHandler.class) + private List roUserIds; /** * 读写权限的用户编号数组 */ - private String rwUserIds; + @TableField(typeHandler = LongListTypeHandler.class) + private List rwUserIds; /** * 地区编号 */ @@ -82,15 +102,6 @@ public class CrmCustomerDO extends BaseDO { * 详细地址 */ private String detailAddress; - // TODO @wanwan:下面两个字段:删除 - /** - * 地理位置经度 - */ - private String longitude; - /** - * 地理位置维度 - */ - private String latitude; /** * 最后跟进时间 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java index 647b6d812..bc684d7bc 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java @@ -22,8 +22,6 @@ public interface CrmCustomerMapper extends BaseMapperX { return selectPage(reqVO, new LambdaQueryWrapperX() .likeIfPresent(CrmCustomerDO::getName, reqVO.getName()) .eqIfPresent(CrmCustomerDO::getMobile, reqVO.getMobile()) - .eqIfPresent(CrmCustomerDO::getTelephone, reqVO.getTelephone()) - .likeIfPresent(CrmCustomerDO::getWebsite, reqVO.getWebsite()) .orderByDesc(CrmCustomerDO::getId)); } @@ -31,8 +29,6 @@ public interface CrmCustomerMapper extends BaseMapperX { return selectList(new LambdaQueryWrapperX() .likeIfPresent(CrmCustomerDO::getName, reqVO.getName()) .eqIfPresent(CrmCustomerDO::getMobile, reqVO.getMobile()) - .eqIfPresent(CrmCustomerDO::getTelephone, reqVO.getTelephone()) - .likeIfPresent(CrmCustomerDO::getWebsite, reqVO.getWebsite()) .orderByDesc(CrmCustomerDO::getId)); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java index 32577dd24..362637e30 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImpl.java @@ -39,7 +39,7 @@ public class CrmClueServiceImpl implements CrmClueService { @Override public Long createClue(CrmClueCreateReqVO createReqVO) { // 校验客户是否存在 - validateCustomerExists(createReqVO.getCustomerId()); + customerService.validateCustomer(createReqVO.getCustomerId()); // 插入 CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO); clueMapper.insert(clue); @@ -52,7 +52,7 @@ public class CrmClueServiceImpl implements CrmClueService { // 校验存在 validateClueExists(updateReqVO.getId()); // 校验客户是否存在 - validateCustomerExists(updateReqVO.getCustomerId()); + customerService.validateCustomer(updateReqVO.getCustomerId()); // 更新 CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO); @@ -96,16 +96,4 @@ public class CrmClueServiceImpl implements CrmClueService { return clueMapper.selectList(exportReqVO); } - // TODO @wanwan:可以在 CrmClueServiceImpl 中,增加一个方法,用于校验客户是否存在;validateCustomer;然后其它方法可以调用它。不过要注意,需要把 CustomerDO 返回,因为其它模块可能要它的信息 - /** - * 校验客户是否存在 - * - * @param customerId 客户id - */ - private void validateCustomerExists(Long customerId) { - if (customerService.getCustomer(customerId) == null) { - throw exception(CUSTOMER_NOT_EXISTS); - } - } - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java index c2190ff94..4e41fab25 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java @@ -72,4 +72,12 @@ public interface CrmCustomerService { */ List getCustomerList(CrmCustomerExportReqVO exportReqVO); + /** + * 校验客户是否存在 + * + * @param customerId 客户id + * @return + */ + CrmCustomerDO validateCustomer(Long customerId); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java index 0bb224e7f..d77953231 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java @@ -85,4 +85,18 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { return customerMapper.selectList(exportReqVO); } + /** + * 校验客户是否存在 + * + * @param customerId 客户id + * @return + */ + @Override + public CrmCustomerDO validateCustomer(Long customerId) { + CrmCustomerDO customer = getCustomer(customerId); + if (Objects.isNull(customer)) { + throw exception(CUSTOMER_NOT_EXISTS); + } + return customer; + } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql index f7d25f7ef..124edb883 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql @@ -113,8 +113,6 @@ CREATE TABLE IF NOT EXISTS "crm_customer" ( "rw_user_ids" varchar, "area_id" bigint, "detail_address" varchar, - "longitude" varchar, - "latitude" varchar, "contact_last_time" varchar, "contact_next_time" varchar, "creator" varchar DEFAULT '', From 3af9688383ea5aa48d727fefe4cc39917b239555 Mon Sep 17 00:00:00 2001 From: Wanwan <913752709@qq.com> Date: Sun, 29 Oct 2023 00:33:42 +0800 Subject: [PATCH 029/101] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E8=A1=A8=E7=9A=84=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 62 +++++++++++-------- sql/mysql/crm_data.sql | 39 ++++++++++++ .../module/crm/enums/DictTypeConstants.java | 15 +++++ .../enums/customer/CrmCustomerLevelEnum.java | 38 ++++++++++++ .../admin/customer/vo/CrmCustomerBaseVO.java | 12 ++++ .../admin/customer/vo/CrmCustomerExcelVO.java | 13 ++++ .../dataobject/customer/CrmCustomerDO.java | 16 +++++ .../dal/mysql/customer/CrmCustomerMapper.java | 1 + .../customer/CrmCustomerServiceImpl.java | 3 + 9 files changed, 173 insertions(+), 26 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java create mode 100644 yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 1b381bf04..51b57412a 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -188,32 +188,42 @@ CREATE TABLE `crm_contact` ( -- ---------------------------- -- 客户表 -- ---------------------------- -CREATE TABLE `crm_customer` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,主键自增', - `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '客户名称', - `follow_up_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '跟进状态', - `lock_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '锁定状态', - `deal_status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '成交状态', - `mobile` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机', - `telephone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电话', - `website` varchar(1024) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '网址', - `remark` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注', - `owner_user_id` bigint DEFAULT NULL COMMENT '负责人的用户编号', - `ro_user_ids` varchar(4096) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '只读权限的用户编号数组', - `rw_user_ids` varchar(4096) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '读写权限的用户编号数组', - `area_id` bigint DEFAULT NULL COMMENT '地区编号', - `detail_address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '详细地址', - `contact_last_time` datetime DEFAULT NULL COMMENT '最后跟进时间', - `contact_next_time` datetime DEFAULT NULL COMMENT '下次联系时间', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号', - PRIMARY KEY (`id`), - KEY `owner_user_id` (`owner_user_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='客户表'; +DROP TABLE IF EXISTS `crm_customer`; +CREATE TABLE `crm_customer` ( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,主键自增', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '客户名称', + `follow_up_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '跟进状态', + `lock_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '锁定状态', + `deal_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '成交状态', + `industry_id` int NULL DEFAULT NULL COMMENT '所属行业', + `level` int NULL DEFAULT NULL COMMENT '客户等级', + `source` int NULL DEFAULT NULL COMMENT '客户来源', + `mobile` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '手机', + `telephone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '电话', + `website` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '网址', + `qq` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'QQ', + `wechat` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '微信', + `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '邮箱', + `description` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '客户描述', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', + `owner_user_id` bigint NULL DEFAULT NULL COMMENT '负责人的用户编号', + `ro_user_ids` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '只读权限的用户编号数组', + `rw_user_ids` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '读写权限的用户编号数组', + `area_id` bigint NULL DEFAULT NULL COMMENT '地区编号', + `detail_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '详细地址', + `longitude` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '地理位置经度', + `latitude` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '地理位置维度', + `contact_last_time` datetime NULL DEFAULT NULL COMMENT '最后跟进时间', + `contact_next_time` datetime NULL DEFAULT NULL COMMENT '下次联系时间', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', + PRIMARY KEY (`id`) USING BTREE, + INDEX `owner_user_id`(`owner_user_id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '客户表' ROW_FORMAT = Dynamic; -- ---------------------------- -- 商机状态表 -- ---------------------------- diff --git a/sql/mysql/crm_data.sql b/sql/mysql/crm_data.sql index dfc1135f9..63b7d9f72 100644 --- a/sql/mysql/crm_data.sql +++ b/sql/mysql/crm_data.sql @@ -17,3 +17,42 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1400, 7, '微信支付', '7', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:53', '1', '2023-10-18 21:55:53', b'0'); INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1401, 8, '其他', '8', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:56:06', '1', '2023-10-18 21:56:06', b'0'); + + +INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (188, '客户来源', 'crm_customer_source', 0, 'CRM 客户来源', '1', '2023-10-28 23:00:34', '1', '2023-10-28 15:11:16', b'0', NULL); +INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (187, '客户等级', 'crm_customer_level', 0, 'CRM 客户等级', '1', '2023-10-28 22:59:12', '1', '2023-10-28 15:11:16', b'0', NULL); +INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (186, '客户所属行业', 'crm_customer_industry', 0, 'CRM 客户所属行业', '1', '2023-10-28 22:57:07', '1', '2023-10-28 15:11:16', b'0', NULL); + +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1434, 10, '邮件咨询', '10', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:10:33', '1', '2023-10-28 23:10:33', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1433, 9, '电话咨询', '9', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:10:18', '1', '2023-10-28 23:10:18', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1432, 8, '陌拜', '8', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:10:04', '1', '2023-10-28 23:10:04', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1431, 7, '预约上门', '7', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:09:39', '1', '2023-10-28 23:09:39', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1430, 6, '线上咨询', '6', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:09:22', '1', '2023-10-28 23:09:22', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1429, 5, '线上注册', '5', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:09:12', '1', '2023-10-28 23:09:12', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1428, 4, '转介绍', '4', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:08:58', '1', '2023-10-28 23:08:58', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1427, 3, '广告', '3', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:08:47', '1', '2023-10-28 23:08:47', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1426, 2, '搜索引擎', '2', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:08:39', '1', '2023-10-28 23:08:39', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1425, 1, '促销', '1', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:08:29', '1', '2023-10-28 23:08:29', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1424, 3, 'C (非优先客户)', '3', 'crm_customer_level', 0, 'default', '', '', '1', '2023-10-28 23:07:53', '1', '2023-10-28 23:07:53', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1423, 2, 'B (普通客户)', '2', 'crm_customer_level', 0, 'info', '', '', '1', '2023-10-28 23:07:35', '1', '2023-10-28 23:07:35', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1422, 1, 'A (重点客户)', '1', 'crm_customer_level', 0, 'primary', '', '', '1', '2023-10-28 23:07:13', '1', '2023-10-28 23:07:13', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1421, 20, 'T 国际组织', '20', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:06:15', '1', '2023-10-28 23:06:15', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1420, 19, 'S 公共管理、社会保障和社会组织', '19', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:06:05', '1', '2023-10-28 23:06:05', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1419, 18, 'R 文化、体育和娱乐业', '18', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:05:55', '1', '2023-10-28 23:05:55', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1418, 17, 'Q 卫生和社会工作', '17', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:05:44', '1', '2023-10-28 23:05:44', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1417, 16, 'P 教育', '16', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:05:15', '1', '2023-10-28 23:05:15', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1416, 15, 'O 居民服务、修理和其他服务业', '15', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:05:05', '1', '2023-10-28 23:05:05', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1415, 14, 'N 水利、环境和公共设施管理业', '14', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:04:53', '1', '2023-10-28 23:04:53', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1414, 13, 'M 科学研究和技术服务业', '13', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:04:43', '1', '2023-10-28 23:04:43', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1413, 12, 'L 租赁和商务服务业', '12', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:04:33', '1', '2023-10-28 23:04:33', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1412, 11, 'K 房地产业', '11', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:04:15', '1', '2023-10-28 23:04:22', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1411, 10, 'J 金融业', '10', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:57', '1', '2023-10-28 23:03:57', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1410, 9, 'I 信息传输、软件和信息技术服务业', '9', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:47', '1', '2023-10-28 23:03:47', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1409, 8, 'H 住宿和餐饮业', '8', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:37', '1', '2023-10-28 23:03:37', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1408, 7, 'G 交通运输、仓储和邮政业', '7', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:27', '1', '2023-10-28 23:03:27', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1407, 6, 'F 批发和零售业', '6', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:13', '1', '2023-10-28 23:03:13', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1406, 5, 'E 建筑业', '5', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:03', '1', '2023-10-28 23:03:03', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1405, 4, 'D 电力、热力、燃气及水生产和供应业', '4', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:02:54', '1', '2023-10-28 23:02:54', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1404, 3, 'C 制造业', '3', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:02:41', '1', '2023-10-28 23:02:41', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1403, 2, 'B 采矿业', '2', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:02:29', '1', '2023-10-28 23:02:29', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1402, 1, 'A 农、林、牧、渔业', '1', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:02:15', '1', '2023-10-28 23:02:15', b'0'); \ No newline at end of file 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 new file mode 100644 index 000000000..dd2c068d3 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/DictTypeConstants.java @@ -0,0 +1,15 @@ +package cn.iocoder.yudao.module.crm.enums; + +/** + * System 字典类型的枚举类 + * + * @author 芋道源码 + */ +public interface DictTypeConstants { + + // ========== CRM 模块 ========== + String CRM_CUSTOMER_INDUSTRY = "crm_customer_industry"; // CRM 客户所属行业 + String CRM_CUSTOMER_LEVEL = "crm_customer_level"; // CRM 客户等级 + String CRM_CUSTOMER_SOURCE = "crm_customer_source"; // CRM 客户来源 + +} diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java new file mode 100644 index 000000000..c2da3744e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.module.crm.enums.customer; + +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * CRM 客户等级 + * + * @author Wanwan + */ +@Getter +@AllArgsConstructor +public enum CrmCustomerLevelEnum implements IntArrayValuable { + + IMPORTANT(1, "A (重点客户)"), + GENERAL(2, "B (普通客户)"), + LOW_PRIORITY(3, "C (非优先客户)"); + + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmCustomerLevelEnum::getStatus).toArray(); + + /** + * 状态 + */ + private final Integer status; + /** + * 状态名 + */ + private final String name; + + @Override + public int[] array() { + return ARRAYS; + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java index fd061a39e..f3b81151c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java @@ -1,7 +1,9 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; +import cn.iocoder.yudao.framework.common.validation.InEnum; import cn.iocoder.yudao.framework.common.validation.Mobile; import cn.iocoder.yudao.framework.common.validation.Telephone; +import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLevelEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; @@ -25,6 +27,16 @@ public class CrmCustomerBaseVO { @NotEmpty(message = "客户名称不能为空") private String name; + @Schema(description = "所属行业", example = "1") + private Integer industryId; + + @Schema(description = "客户等级", example = "2") + @InEnum(CrmCustomerLevelEnum.class) + private Integer level; + + @Schema(description = "客户来源", example = "3") + private Integer source; + @Schema(description = "手机", example = "18000000000") @Mobile private String mobile; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java index 35b864080..0fee3df4c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; import cn.iocoder.yudao.module.infra.enums.DictTypeConstants; import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.time.LocalDateTime; @@ -35,6 +36,18 @@ public class CrmCustomerExcelVO { @DictFormat(DictTypeConstants.BOOLEAN_STRING) private Boolean dealStatus; + @ExcelProperty(value = "所属行业", converter = DictConvert.class) + @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY) + private Integer industryId; + + @ExcelProperty(value = "客户等级", converter = DictConvert.class) + @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL) + private Integer level; + + @ExcelProperty(value = "客户来源", converter = DictConvert.class) + @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE) + private Integer source; + @ExcelProperty("手机") private String mobile; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java index bb45679bb..a50ada4c5 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java @@ -12,6 +12,7 @@ import java.time.LocalDateTime; import java.util.List; // TODO 芋艿:调整下字段 + /** * 客户 DO * @@ -48,6 +49,21 @@ public class CrmCustomerDO extends BaseDO { * 成交状态 */ private Boolean dealStatus; + /** + * 所属行业 + * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY} + */ + private Integer industryId; + /** + * 客户等级 + * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL} + */ + private Integer level; + /** + * 客户来源 + * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE} + */ + private Integer source; /** * 手机 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java index bc684d7bc..838423086 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java @@ -19,6 +19,7 @@ import java.util.List; public interface CrmCustomerMapper extends BaseMapperX { default PageResult selectPage(CrmCustomerPageReqVO reqVO) { + // TODO @Wanwan 填充负责人,所属部门字段 return selectPage(reqVO, new LambdaQueryWrapperX() .likeIfPresent(CrmCustomerDO::getName, reqVO.getName()) .eqIfPresent(CrmCustomerDO::getMobile, reqVO.getMobile()) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java index d77953231..fb27d4ae9 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.crm.service.customer; +import cn.iocoder.yudao.module.system.api.dept.DeptApi; import org.springframework.stereotype.Service; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; @@ -29,6 +30,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @Resource private CrmCustomerMapper customerMapper; + @Resource + private DeptApi deptApi; @Override public Long createCustomer(CrmCustomerCreateReqVO createReqVO) { From d9f6fb241a1013c7da355f5d3ef376b44e3788fd Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sun, 29 Oct 2023 01:23:06 +0800 Subject: [PATCH 030/101] =?UTF-8?q?=E5=90=88=E5=90=8C=EF=BC=9A=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=90=88=E5=90=8C=E8=BD=AC=E7=A7=BB=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/ErrorCodeConstants.java | 1 + .../admin/contract/ContractController.java | 10 ++++++ .../contract/vo/ContractCreateReqVO.java | 6 ++-- .../contract/vo/ContractUpdateReqVO.java | 5 +-- .../contract/vo/CrmContractTransferReqVO.java | 20 +++++++++++ .../crm/convert/contract/ContractConvert.java | 15 +++++--- .../dal/dataobject/contract/ContractDO.java | 9 +++-- .../module/crm/framework/utils/AuthUtil.java | 34 +++++++++++++++++++ .../crm/service/contract/ContractService.java | 13 ++++--- .../service/contract/ContractServiceImpl.java | 30 ++++++++++++---- 10 files changed, 123 insertions(+), 20 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractTransferReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/AuthUtil.java diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 124a70cb7..dcb03a74d 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -11,6 +11,7 @@ public interface ErrorCodeConstants { // ========== 合同管理 1-020-000-000 ========== ErrorCode CONTRACT_NOT_EXISTS = new ErrorCode(1_020_000_000, "合同不存在"); + ErrorCode CONTRACT_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_000_001, "合同转移失败,原因:没有转移权限"); // ========== 线索管理 1-020-001-000 ========== ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在"); 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/ContractController.java index fd8b14afd..4898eb6c1 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/ContractController.java @@ -23,6 +23,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @Tag(name = "管理后台 - 合同") @RestController @@ -86,4 +87,13 @@ public class ContractController { ExcelUtils.write(response, "合同.xls", "数据", ContractExcelVO.class, datas); } + @PutMapping("/transfer") + @Operation(summary = "合同转移") + @PreAuthorize("@ss.hasPermission('crm:contract:update')") + public CommonResult transfer(@Valid @RequestBody CrmContractTransferReqVO reqVO) { + contractService.contractTransfer(reqVO, getLoginUserId()); + return success(true); + } + + } 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/ContractCreateReqVO.java index 38c95d23f..7b8c561b0 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/ContractCreateReqVO.java @@ -5,6 +5,8 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; +import java.util.Set; + @Schema(description = "管理后台 - 合同创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @@ -12,9 +14,9 @@ import lombok.ToString; public class ContractCreateReqVO extends ContractBaseVO { @Schema(description = "只读权限的用户编号数组") - private String roUserIds; + private Set roUserIds; @Schema(description = "读写权限的用户编号数组") - private String rwUserIds; + private Set rwUserIds; } 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/ContractUpdateReqVO.java index f38ac7677..e6f305ce4 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/ContractUpdateReqVO.java @@ -6,6 +6,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; import javax.validation.constraints.NotNull; +import java.util.Set; @Schema(description = "管理后台 - 合同更新 Request VO") @Data @@ -18,9 +19,9 @@ public class ContractUpdateReqVO extends ContractBaseVO { private Long id; @Schema(description = "只读权限的用户编号数组") - private String roUserIds; + private Set roUserIds; @Schema(description = "读写权限的用户编号数组") - private String rwUserIds; + private Set rwUserIds; } 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 new file mode 100644 index 000000000..5dfa5fe0a --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractTransferReqVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contract.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 合同转移 Request VO") +@Data +public class CrmContractTransferReqVO { + + @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "合同编号不能为空") + private Long id; + + @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "新负责人的用户编号不能为空") + private Long ownerUserId; // 新的负责人 + +} 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 906dd7562..023d4200b 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 @@ -1,15 +1,14 @@ package cn.iocoder.yudao.module.crm.convert.contract; +import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractExcelVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractRespVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractUpdateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*; import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; import java.util.List; +import java.util.Set; /** * 合同 Convert @@ -33,4 +32,12 @@ public interface ContractConvert { List convertList02(List list); + default ContractDO convert(ContractDO contract, CrmContractTransferReqVO reqVO, Long userId) { + Set rwUserIds = contract.getRwUserIds(); + rwUserIds.removeIf(item -> ObjUtil.equal(item, userId.toString())); // 移除老负责人 + rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 + return new ContractDO().setId(contract.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 + .setRwUserIds(rwUserIds); + } + } 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/ContractDO.java index 8caa4d2cb..2c5d0e44f 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/ContractDO.java @@ -1,12 +1,15 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.contract; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; import java.time.LocalDateTime; +import java.util.Set; /** * 合同 DO @@ -79,11 +82,13 @@ public class ContractDO extends BaseDO { /** * 只读权限的用户编号数组 */ - private String roUserIds; + @TableField(typeHandler = JsonLongSetTypeHandler.class) + private Set roUserIds; /** * 读写权限的用户编号数组 */ - private String rwUserIds; + @TableField(typeHandler = JsonLongSetTypeHandler.class) + private Set rwUserIds; /** * 联系人编号 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/AuthUtil.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/AuthUtil.java new file mode 100644 index 000000000..3c3d14bf2 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/AuthUtil.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.framework.utils; + +import java.util.Collection; + +/** + * 数据读写权限校验工具类 + * + * @author HUIHUI + */ +public class AuthUtil { + + /** + * 判断当前数据对用户来说是否是只读的 + * + * @param roUserIds 当前操作数据的只读权限的用户编号数组 + * @param userId 当前操作数据的用户编号 + * @return boolean 是/否 + */ + public static boolean isReadOnly(Collection roUserIds, Long userId) { + return roUserIds.contains(userId); + } + + /** + * 判断当前数据对用户来说是否是可读写的 + * + * @param rwUserIds 当前操作数据的读写权限的用户编号数组 + * @param userId 当前操作数据的用户编号 + * @return boolean 是/否 + */ + public static boolean isReadAndWrite(Collection rwUserIds, Long userId) { + return rwUserIds.contains(userId); + } + +} 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 index 6d6c9fe9f..af8bda185 100644 --- 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 @@ -1,10 +1,7 @@ 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.ContractCreateReqVO; -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.controller.admin.contract.vo.*; import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; import javax.validation.Valid; @@ -72,4 +69,12 @@ public interface ContractService { */ List getContractList(ContractExportReqVO exportReqVO); + /** + * 合同转移 + * + * @param reqVO 请求 + * @param userId 用户编号 + */ + void contractTransfer(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/ContractServiceImpl.java index e840626b9..4dadd6923 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/ContractServiceImpl.java @@ -3,10 +3,7 @@ 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.ContractCreateReqVO; -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.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.dal.mysql.contract.ContractMapper; @@ -19,6 +16,8 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_TRANSFER_FAIL_PERMISSION_DENIED; +import static cn.iocoder.yudao.module.crm.framework.utils.AuthUtil.isReadAndWrite; /** * 合同 Service 实现类 @@ -58,10 +57,12 @@ public class ContractServiceImpl implements ContractService { contractMapper.deleteById(id); } - private void validateContractExists(Long id) { - if (contractMapper.selectById(id) == null) { + private ContractDO validateContractExists(Long id) { + ContractDO contract = contractMapper.selectById(id); + if (contract == null) { throw exception(CONTRACT_NOT_EXISTS); } + return contract; } @Override @@ -87,4 +88,21 @@ public class ContractServiceImpl implements ContractService { return contractMapper.selectList(exportReqVO); } + @Override + public void contractTransfer(CrmContractTransferReqVO reqVO, Long userId) { + // 1. 校验合同是否存在 + ContractDO contract = validateContractExists(reqVO.getId()); + // 1.2. 校验用户是否拥有读写权限 + if (!isReadAndWrite(contract.getRwUserIds(), userId)) { + throw exception(CONTRACT_TRANSFER_FAIL_PERMISSION_DENIED); + } + + // 2. 更新新的负责人 + ContractDO updateContract = ContractConvert.INSTANCE.convert(contract, reqVO, userId); + contractMapper.updateById(updateContract); + + // 3. TODO 记录合同转移日志 + + } + } From 36a76c5ce63e8988e3c086cdb90d1a3080b0e254 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sun, 29 Oct 2023 01:42:22 +0800 Subject: [PATCH 031/101] =?UTF-8?q?CRM-=E8=81=94=E7=B3=BB=E4=BA=BA?= =?UTF-8?q?=EF=BC=9A=E6=96=B0=E5=A2=9E=E8=81=94=E7=B3=BB=E4=BA=BA=E8=BD=AC?= =?UTF-8?q?=E7=A7=BB=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/ErrorCodeConstants.java | 3 ++ .../admin/contact/ContactController.java | 48 +++++++++++-------- .../admin/contact/vo/ContactCreateReqVO.java | 14 ++++-- .../admin/contact/vo/ContactUpdateReqVO.java | 14 ++++-- .../contact/vo/CrmContactTransferReqVO.java | 20 ++++++++ .../crm/convert/contact/ContactConvert.java | 19 ++++++-- .../crm/dal/dataobject/contact/ContactDO.java | 14 ++++++ .../crm/service/contact/ContactService.java | 16 +++++-- .../service/contact/ContactServiceImpl.java | 41 +++++++++++++--- .../service/contract/ContractServiceImpl.java | 17 +++++-- 10 files changed, 160 insertions(+), 46 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index dcb03a74d..f5b5e078b 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -12,6 +12,7 @@ public interface ErrorCodeConstants { // ========== 合同管理 1-020-000-000 ========== ErrorCode CONTRACT_NOT_EXISTS = new ErrorCode(1_020_000_000, "合同不存在"); ErrorCode CONTRACT_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_000_001, "合同转移失败,原因:没有转移权限"); + ErrorCode CONTRACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_000_002, "合同转移失败,原因:负责人不存在"); // ========== 线索管理 1-020-001-000 ========== ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在"); @@ -26,6 +27,8 @@ public interface ErrorCodeConstants { // ========== 联系人管理 1-020-003-000 ========== ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); + ErrorCode CONTACT_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_003_001, "联系人转移失败,原因:没有转移权限"); + ErrorCode CONTACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_003_002, "联系人转移失败,原因:负责人不存在"); // TODO @liuhongfeng:错误码分段; ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_030_000_001, "回款管理不存在"); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java index bafec03c1..f28d27ef8 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java @@ -1,32 +1,30 @@ package cn.iocoder.yudao.module.crm.controller.admin.contact; -import org.springframework.web.bind.annotation.*; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; -import org.springframework.security.access.prepost.PreAuthorize; -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Operation; - -import javax.validation.constraints.*; -import javax.validation.*; -import javax.servlet.http.*; -import java.util.*; -import java.io.IOException; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; - +import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; - import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; - import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; import cn.iocoder.yudao.module.crm.service.contact.ContactService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.Collection; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @Tag(name = "管理后台 - crm联系人") @RestController @@ -99,4 +97,12 @@ public class ContactController { ExcelUtils.write(response, "crm联系人.xls", "数据", ContactExcelVO.class, datas); } + @PutMapping("/transfer") + @Operation(summary = "联系人转移") + @PreAuthorize("@ss.hasPermission('crm:contact:update')") + public CommonResult transfer(@Valid @RequestBody CrmContactTransferReqVO reqVO) { + contactService.contactTransfer(reqVO, getLoginUserId()); + return success(true); + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java index 424d945dc..64ea71084 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java @@ -1,9 +1,11 @@ package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; -import lombok.*; -import java.util.*; import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.Set; @Schema(description = "管理后台 - crm联系人创建 Request VO") @Data @@ -11,4 +13,10 @@ import javax.validation.constraints.*; @ToString(callSuper = true) public class ContactCreateReqVO extends ContactBaseVO { + @Schema(description = "只读权限的用户编号数组") + private Set roUserIds; + + @Schema(description = "读写权限的用户编号数组") + private Set rwUserIds; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java index 19db67297..60afd06f2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java @@ -1,9 +1,11 @@ package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import javax.validation.constraints.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.Set; @Schema(description = "管理后台 - crm联系人更新 Request VO") @Data @@ -14,4 +16,10 @@ public class ContactUpdateReqVO extends ContactBaseVO { @Schema(description = "主键", example = "23210") private Long id; + @Schema(description = "只读权限的用户编号数组") + private Set roUserIds; + + @Schema(description = "读写权限的用户编号数组") + private Set rwUserIds; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java new file mode 100644 index 000000000..517d77576 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.crm.controller.admin.contact.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 联系转移 Request VO") +@Data +public class CrmContactTransferReqVO { + + @Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "联系人编号不能为空") + private Long id; + + @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "新负责人的用户编号不能为空") + private Long ownerUserId; // 新的负责人 + +} 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 3892806c0..2718b339a 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 @@ -1,13 +1,14 @@ package cn.iocoder.yudao.module.crm.convert.contact; -import java.util.*; - +import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; +import java.util.Set; /** * crm联系人 Convert @@ -31,4 +32,12 @@ public interface ContactConvert { List convertList02(List list); + default ContactDO convert(ContactDO contact, CrmContactTransferReqVO reqVO, Long userId) { + Set rwUserIds = contact.getRwUserIds(); + rwUserIds.removeIf(item -> ObjUtil.equal(item, userId.toString())); // 移除老负责人 + rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 + return new ContactDO().setId(contact.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 + .setRwUserIds(rwUserIds); + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java index 2e7d2cfef..6c56ebe98 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java @@ -1,12 +1,15 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.contact; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; import java.time.LocalDateTime; +import java.util.Set; /** * crm 联系人 DO @@ -77,4 +80,15 @@ public class ContactDO extends BaseDO { */ private LocalDateTime lastTime; + /** + * 只读权限的用户编号数组 + */ + @TableField(typeHandler = JsonLongSetTypeHandler.class) + private Set roUserIds; + /** + * 读写权限的用户编号数组 + */ + @TableField(typeHandler = JsonLongSetTypeHandler.class) + private Set rwUserIds; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java index 97a221ee4..63b3449f2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java @@ -1,10 +1,12 @@ package cn.iocoder.yudao.module.crm.service.contact; -import java.util.*; -import javax.validation.*; +import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; /** * crm联系人 Service 接口 @@ -67,4 +69,12 @@ public interface ContactService { */ List getContactList(ContactExportReqVO exportReqVO); + /** + * 联系人编号 + * + * @param reqVO 请求 + * @param userId 用户编号 + */ + void contactTransfer(CrmContactTransferReqVO reqVO, Long userId); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java index b21fee020..eb2b97cbe 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java @@ -3,13 +3,12 @@ package cn.iocoder.yudao.module.crm.service.contact; 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.contact.vo.ContactCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactUpdateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; import cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -18,7 +17,8 @@ import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_NOT_EXISTS; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.module.crm.framework.utils.AuthUtil.isReadAndWrite; /** * crm联系人 Service 实现类 @@ -32,6 +32,9 @@ public class ContactServiceImpl implements ContactService { @Resource private ContactMapper contactMapper; + @Resource + private AdminUserApi adminUserApi; + @Override public Long createContact(ContactCreateReqVO createReqVO) { // TODO @customerId:需要校验存在 @@ -61,10 +64,12 @@ public class ContactServiceImpl implements ContactService { contactMapper.deleteById(id); } - private void validateContactExists(Long id) { - if (contactMapper.selectById(id) == null) { + private ContactDO validateContactExists(Long id) { + ContactDO contact = contactMapper.selectById(id); + if (contact == null) { throw exception(CONTACT_NOT_EXISTS); } + return contact; } @Override @@ -90,4 +95,26 @@ public class ContactServiceImpl implements ContactService { return contactMapper.selectList(exportReqVO); } + @Override + public void contactTransfer(CrmContactTransferReqVO reqVO, Long userId) { + // 1. 校验联系人是否存在 + ContactDO contact = validateContactExists(reqVO.getId()); + // 1.2. 校验用户是否拥有读写权限 + if (!isReadAndWrite(contact.getRwUserIds(), userId)) { + throw exception(CONTACT_TRANSFER_FAIL_PERMISSION_DENIED); + } + // 2. 校验新负责人是否存在 + AdminUserRespDTO user = adminUserApi.getUser(reqVO.getOwnerUserId()); + if (user == null) { + throw exception(CONTACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS); + } + + // 3. 更新新的负责人 + ContactDO updateContract = ContactConvert.INSTANCE.convert(contact, reqVO, userId); + contactMapper.updateById(updateContract); + + // 4. TODO 记录联系人转移日志 + + } + } 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/ContractServiceImpl.java index 4dadd6923..8cee161f0 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/ContractServiceImpl.java @@ -7,6 +7,8 @@ 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.dal.mysql.contract.ContractMapper; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -15,8 +17,7 @@ import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_TRANSFER_FAIL_PERMISSION_DENIED; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.crm.framework.utils.AuthUtil.isReadAndWrite; /** @@ -31,6 +32,9 @@ public class ContractServiceImpl implements ContractService { @Resource private ContractMapper contractMapper; + @Resource + private AdminUserApi adminUserApi; + @Override public Long createContract(ContractCreateReqVO createReqVO) { // 插入 @@ -96,12 +100,17 @@ public class ContractServiceImpl implements ContractService { if (!isReadAndWrite(contract.getRwUserIds(), userId)) { throw exception(CONTRACT_TRANSFER_FAIL_PERMISSION_DENIED); } + // 2. 校验新负责人是否存在 + AdminUserRespDTO user = adminUserApi.getUser(reqVO.getOwnerUserId()); + if (user == null) { + throw exception(CONTRACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS); + } - // 2. 更新新的负责人 + // 3. 更新新的负责人 ContractDO updateContract = ContractConvert.INSTANCE.convert(contract, reqVO, userId); contractMapper.updateById(updateContract); - // 3. TODO 记录合同转移日志 + // 4. TODO 记录合同转移日志 } From 722e9c8a044c9deea0cdf4e3f316bb5fbcc91c7f Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sun, 29 Oct 2023 02:04:26 +0800 Subject: [PATCH 032/101] =?UTF-8?q?CRM-=E5=95=86=E6=9C=BA=EF=BC=9A?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E6=9C=BA=E8=BD=AC=E7=A7=BB=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/ErrorCodeConstants.java | 2 + .../admin/business/CrmBusinessController.java | 11 ++++- .../business/vo/CrmBusinessCreateReqVO.java | 9 ++++ .../business/vo/CrmBusinessTransferReqVO.java | 20 +++++++++ .../business/vo/CrmBusinessUpdateReqVO.java | 8 ++++ .../contact/vo/CrmContactTransferReqVO.java | 2 +- .../convert/business/CrmBusinessConvert.java | 19 ++++++--- .../crm/convert/contact/ContactConvert.java | 2 +- .../crm/convert/contract/ContractConvert.java | 2 +- .../dataobject/business/CrmBusinessDO.java | 13 +++--- .../service/business/CrmBusinessService.java | 13 ++++-- .../business/CrmBusinessServiceImpl.java | 41 +++++++++++++++---- .../service/contact/ContactServiceImpl.java | 4 +- 13 files changed, 118 insertions(+), 28 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessTransferReqVO.java diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index f5b5e078b..7c1f351d8 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -19,6 +19,8 @@ public interface ErrorCodeConstants { // ========== 商机管理 1-020-002-000 ========== ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); + ErrorCode BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_002_001, "商机转移失败,原因:没有转移权限"); + ErrorCode BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_002_002, "商机转移失败,原因:负责人不存在"); // TODO @lilleo:商机状态、商机类型,都单独错误码段 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java index d517a9f91..8096176c9 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java @@ -23,6 +23,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @Tag(name = "管理后台 - 商机") @RestController @@ -80,11 +81,19 @@ public class CrmBusinessController { @PreAuthorize("@ss.hasPermission('crm:business:export')") @OperateLog(type = EXPORT) public void exportBusinessExcel(@Valid CrmBusinessExportReqVO exportReqVO, - HttpServletResponse response) throws IOException { + HttpServletResponse response) throws IOException { List list = businessService.getBusinessList(exportReqVO); // 导出 Excel List datas = CrmBusinessConvert.INSTANCE.convertList02(list); ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessExcelVO.class, datas); } + @PutMapping("/transfer") + @Operation(summary = "商机转移") + @PreAuthorize("@ss.hasPermission('crm:business:update')") + public CommonResult transfer(@Valid @RequestBody CrmBusinessTransferReqVO reqVO) { + businessService.businessTransfer(reqVO, getLoginUserId()); + return success(true); + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java index f743c8469..968a105c8 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java @@ -5,12 +5,21 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; +import java.util.Set; + @Schema(description = "管理后台 - 商机创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class CrmBusinessCreateReqVO extends CrmBusinessBaseVO { + @Schema(description = "只读权限的用户编号数组") + private Set roUserIds; + + @Schema(description = "读写权限的用户编号数组") + private Set rwUserIds; + + // TODO @ljileo:新建的时候,应该可以传递添加的产品; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessTransferReqVO.java new file mode 100644 index 000000000..993e4750e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessTransferReqVO.java @@ -0,0 +1,20 @@ +package cn.iocoder.yudao.module.crm.controller.admin.business.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 商机转移 Request VO") +@Data +public class CrmBusinessTransferReqVO { + + @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "联系人编号不能为空") + private Long id; + + @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "新负责人的用户编号不能为空") + private Long ownerUserId; // 新的负责人 + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java index f137d4c5b..2929535cf 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java @@ -6,6 +6,7 @@ import lombok.EqualsAndHashCode; import lombok.ToString; import javax.validation.constraints.NotNull; +import java.util.Set; @Schema(description = "管理后台 - 商机更新 Request VO") @Data @@ -17,6 +18,13 @@ public class CrmBusinessUpdateReqVO extends CrmBusinessBaseVO { @NotNull(message = "主键不能为空") private Long id; + @Schema(description = "只读权限的用户编号数组") + private Set roUserIds; + + @Schema(description = "读写权限的用户编号数组") + private Set rwUserIds; + + // TODO @ljileo:修改的时候,应该可以传递添加的产品; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java index 517d77576..90acc5645 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java @@ -5,7 +5,7 @@ import lombok.Data; import javax.validation.constraints.NotNull; -@Schema(description = "管理后台 - 联系转移 Request VO") +@Schema(description = "管理后台 - 联系人转移 Request VO") @Data public class CrmContactTransferReqVO { diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java index 72aad68de..2eabf7d4d 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java @@ -1,13 +1,14 @@ package cn.iocoder.yudao.module.crm.convert.business; -import java.util.*; - +import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; +import java.util.Set; /** * 商机 Convert @@ -29,4 +30,12 @@ public interface CrmBusinessConvert { List convertList02(List list); + default CrmBusinessDO convert(CrmBusinessDO business, CrmBusinessTransferReqVO reqVO, Long userId) { + Set rwUserIds = business.getRwUserIds(); + rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 + rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 + return new CrmBusinessDO().setId(business.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 + .setRwUserIds(rwUserIds); + } + } 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 2718b339a..0d1329819 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 @@ -34,7 +34,7 @@ public interface ContactConvert { default ContactDO convert(ContactDO contact, CrmContactTransferReqVO reqVO, Long userId) { Set rwUserIds = contact.getRwUserIds(); - rwUserIds.removeIf(item -> ObjUtil.equal(item, userId.toString())); // 移除老负责人 + rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 return new ContactDO().setId(contact.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 .setRwUserIds(rwUserIds); 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 023d4200b..d7547d4b8 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 @@ -34,7 +34,7 @@ public interface ContractConvert { default ContractDO convert(ContractDO contract, CrmContractTransferReqVO reqVO, Long userId) { Set rwUserIds = contract.getRwUserIds(); - rwUserIds.removeIf(item -> ObjUtil.equal(item, userId.toString())); // 移除老负责人 + rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 return new ContractDO().setId(contract.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 .setRwUserIds(rwUserIds); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java index 2d6454838..23d7ddb9a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java @@ -1,14 +1,17 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.business; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO; import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; import java.time.LocalDateTime; +import java.util.Set; /** * 商机 DO @@ -85,16 +88,14 @@ public class CrmBusinessDO extends BaseDO { private Long ownerUserId; /** * 只读权限的用户编号数组 - * - * TODO @lijie:应该是 List,然后使用下对应的 typehandler */ - private String roUserIds; + @TableField(typeHandler = JsonLongSetTypeHandler.class) + private Set roUserIds; /** * 读写权限的用户编号数组 - * - * TODO @lijie:应该是 List,然后使用下对应的 typehandler */ - private String rwUserIds; + @TableField(typeHandler = JsonLongSetTypeHandler.class) + private Set rwUserIds; /** * 1赢单2输单3无效 * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java index 4bb352c58..8a157440b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java @@ -1,10 +1,7 @@ package cn.iocoder.yudao.module.crm.service.business; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessUpdateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; import javax.validation.Valid; @@ -72,4 +69,12 @@ public interface CrmBusinessService { */ List getBusinessList(CrmBusinessExportReqVO exportReqVO); + /** + * 商机转移 + * + * @param reqVO 请求 + * @param userId 用户编号 + */ + void businessTransfer(CrmBusinessTransferReqVO reqVO, Long userId); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java index 44fa74f80..4ddb3363e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java @@ -3,13 +3,12 @@ package cn.iocoder.yudao.module.crm.service.business; 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.business.vo.CrmBusinessCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessUpdateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -18,7 +17,8 @@ import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.module.crm.framework.utils.AuthUtil.isReadAndWrite; /** * 商机 Service 实现类 @@ -32,6 +32,9 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { @Resource private CrmBusinessMapper businessMapper; + @Resource + private AdminUserApi adminUserApi; + @Override public Long createBusiness(CrmBusinessCreateReqVO createReqVO) { // 插入 @@ -58,10 +61,12 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { businessMapper.deleteById(id); } - private void validateBusinessExists(Long id) { - if (businessMapper.selectById(id) == null) { + private CrmBusinessDO validateBusinessExists(Long id) { + CrmBusinessDO crmBusiness = businessMapper.selectById(id); + if (crmBusiness == null) { throw exception(BUSINESS_NOT_EXISTS); } + return crmBusiness; } @Override @@ -87,4 +92,26 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { return businessMapper.selectList(exportReqVO); } + @Override + public void businessTransfer(CrmBusinessTransferReqVO reqVO, Long userId) { + // 1. 校验商机是否存在 + CrmBusinessDO business = validateBusinessExists(reqVO.getId()); + // 1.2. 校验用户是否拥有读写权限 + if (!isReadAndWrite(business.getRwUserIds(), userId)) { + throw exception(BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED); + } + // 2. 校验新负责人是否存在 + AdminUserRespDTO user = adminUserApi.getUser(reqVO.getOwnerUserId()); + if (user == null) { + throw exception(BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS); + } + + // 3. 更新新的负责人 + CrmBusinessDO updateBusiness = CrmBusinessConvert.INSTANCE.convert(business, reqVO, userId); + businessMapper.updateById(updateBusiness); + + // 4. TODO 记录商机转移日志 + + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java index eb2b97cbe..e47e2e155 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java @@ -110,8 +110,8 @@ public class ContactServiceImpl implements ContactService { } // 3. 更新新的负责人 - ContactDO updateContract = ContactConvert.INSTANCE.convert(contact, reqVO, userId); - contactMapper.updateById(updateContract); + ContactDO updateContact = ContactConvert.INSTANCE.convert(contact, reqVO, userId); + contactMapper.updateById(updateContact); // 4. TODO 记录联系人转移日志 From fe50356ae8cedc4ffacdcc87aca00e56535b4e4d Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 29 Oct 2023 17:38:59 +0800 Subject: [PATCH 033/101] =?UTF-8?q?code=20review=EF=BC=9Acrm=20=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E6=A8=A1=E5=9D=97=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 40 +---------- sql/mysql/crm_data.sql | 38 ----------- sql/mysql/crm_menu.sql | 67 ------------------- .../module/crm/enums/DictTypeConstants.java | 2 +- .../enums/customer/CrmCustomerLevelEnum.java | 7 +- .../admin/customer/vo/CrmCustomerBaseVO.java | 9 ++- .../customer/vo/CrmCustomerCreateReqVO.java | 2 + .../dataobject/customer/CrmCustomerDO.java | 9 ++- .../dal/mysql/customer/CrmCustomerMapper.java | 2 +- .../service/customer/CrmCustomerService.java | 4 +- .../customer/CrmCustomerServiceImpl.java | 44 +++++++----- 11 files changed, 48 insertions(+), 176 deletions(-) diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 51b57412a..677ea2881 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -185,45 +185,7 @@ CREATE TABLE `crm_contact` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='crm联系人'; --- ---------------------------- --- 客户表 --- ---------------------------- -DROP TABLE IF EXISTS `crm_customer`; -CREATE TABLE `crm_customer` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,主键自增', - `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '客户名称', - `follow_up_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '跟进状态', - `lock_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '锁定状态', - `deal_status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '成交状态', - `industry_id` int NULL DEFAULT NULL COMMENT '所属行业', - `level` int NULL DEFAULT NULL COMMENT '客户等级', - `source` int NULL DEFAULT NULL COMMENT '客户来源', - `mobile` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '手机', - `telephone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '电话', - `website` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '网址', - `qq` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT 'QQ', - `wechat` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '微信', - `email` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '邮箱', - `description` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '客户描述', - `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', - `owner_user_id` bigint NULL DEFAULT NULL COMMENT '负责人的用户编号', - `ro_user_ids` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '只读权限的用户编号数组', - `rw_user_ids` varchar(4096) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '读写权限的用户编号数组', - `area_id` bigint NULL DEFAULT NULL COMMENT '地区编号', - `detail_address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '详细地址', - `longitude` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '地理位置经度', - `latitude` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '地理位置维度', - `contact_last_time` datetime NULL DEFAULT NULL COMMENT '最后跟进时间', - `contact_next_time` datetime NULL DEFAULT NULL COMMENT '下次联系时间', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE, - INDEX `owner_user_id`(`owner_user_id`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '客户表' ROW_FORMAT = Dynamic; + -- ---------------------------- -- 商机状态表 -- ---------------------------- diff --git a/sql/mysql/crm_data.sql b/sql/mysql/crm_data.sql index 63b7d9f72..2d742698d 100644 --- a/sql/mysql/crm_data.sql +++ b/sql/mysql/crm_data.sql @@ -18,41 +18,3 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1401, 8, '其他', '8', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:56:06', '1', '2023-10-18 21:56:06', b'0'); - -INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (188, '客户来源', 'crm_customer_source', 0, 'CRM 客户来源', '1', '2023-10-28 23:00:34', '1', '2023-10-28 15:11:16', b'0', NULL); -INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (187, '客户等级', 'crm_customer_level', 0, 'CRM 客户等级', '1', '2023-10-28 22:59:12', '1', '2023-10-28 15:11:16', b'0', NULL); -INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (186, '客户所属行业', 'crm_customer_industry', 0, 'CRM 客户所属行业', '1', '2023-10-28 22:57:07', '1', '2023-10-28 15:11:16', b'0', NULL); - -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1434, 10, '邮件咨询', '10', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:10:33', '1', '2023-10-28 23:10:33', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1433, 9, '电话咨询', '9', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:10:18', '1', '2023-10-28 23:10:18', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1432, 8, '陌拜', '8', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:10:04', '1', '2023-10-28 23:10:04', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1431, 7, '预约上门', '7', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:09:39', '1', '2023-10-28 23:09:39', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1430, 6, '线上咨询', '6', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:09:22', '1', '2023-10-28 23:09:22', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1429, 5, '线上注册', '5', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:09:12', '1', '2023-10-28 23:09:12', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1428, 4, '转介绍', '4', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:08:58', '1', '2023-10-28 23:08:58', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1427, 3, '广告', '3', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:08:47', '1', '2023-10-28 23:08:47', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1426, 2, '搜索引擎', '2', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:08:39', '1', '2023-10-28 23:08:39', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1425, 1, '促销', '1', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:08:29', '1', '2023-10-28 23:08:29', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1424, 3, 'C (非优先客户)', '3', 'crm_customer_level', 0, 'default', '', '', '1', '2023-10-28 23:07:53', '1', '2023-10-28 23:07:53', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1423, 2, 'B (普通客户)', '2', 'crm_customer_level', 0, 'info', '', '', '1', '2023-10-28 23:07:35', '1', '2023-10-28 23:07:35', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1422, 1, 'A (重点客户)', '1', 'crm_customer_level', 0, 'primary', '', '', '1', '2023-10-28 23:07:13', '1', '2023-10-28 23:07:13', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1421, 20, 'T 国际组织', '20', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:06:15', '1', '2023-10-28 23:06:15', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1420, 19, 'S 公共管理、社会保障和社会组织', '19', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:06:05', '1', '2023-10-28 23:06:05', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1419, 18, 'R 文化、体育和娱乐业', '18', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:05:55', '1', '2023-10-28 23:05:55', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1418, 17, 'Q 卫生和社会工作', '17', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:05:44', '1', '2023-10-28 23:05:44', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1417, 16, 'P 教育', '16', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:05:15', '1', '2023-10-28 23:05:15', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1416, 15, 'O 居民服务、修理和其他服务业', '15', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:05:05', '1', '2023-10-28 23:05:05', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1415, 14, 'N 水利、环境和公共设施管理业', '14', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:04:53', '1', '2023-10-28 23:04:53', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1414, 13, 'M 科学研究和技术服务业', '13', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:04:43', '1', '2023-10-28 23:04:43', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1413, 12, 'L 租赁和商务服务业', '12', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:04:33', '1', '2023-10-28 23:04:33', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1412, 11, 'K 房地产业', '11', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:04:15', '1', '2023-10-28 23:04:22', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1411, 10, 'J 金融业', '10', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:57', '1', '2023-10-28 23:03:57', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1410, 9, 'I 信息传输、软件和信息技术服务业', '9', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:47', '1', '2023-10-28 23:03:47', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1409, 8, 'H 住宿和餐饮业', '8', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:37', '1', '2023-10-28 23:03:37', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1408, 7, 'G 交通运输、仓储和邮政业', '7', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:27', '1', '2023-10-28 23:03:27', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1407, 6, 'F 批发和零售业', '6', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:13', '1', '2023-10-28 23:03:13', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1406, 5, 'E 建筑业', '5', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:03', '1', '2023-10-28 23:03:03', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1405, 4, 'D 电力、热力、燃气及水生产和供应业', '4', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:02:54', '1', '2023-10-28 23:02:54', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1404, 3, 'C 制造业', '3', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:02:41', '1', '2023-10-28 23:02:41', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1403, 2, 'B 采矿业', '2', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:02:29', '1', '2023-10-28 23:02:29', b'0'); -INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1402, 1, 'A 农、林、牧、渔业', '1', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:02:15', '1', '2023-10-28 23:02:15', b'0'); \ No newline at end of file diff --git a/sql/mysql/crm_menu.sql b/sql/mysql/crm_menu.sql index f75e98f08..d0c9b6dce 100644 --- a/sql/mysql/crm_menu.sql +++ b/sql/mysql/crm_menu.sql @@ -233,13 +233,6 @@ VALUES ( '', '', '', 0 ); - --- ---------------------------- --- 客户管理菜单 --- ---------------------------- -INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2375, '客户管理', '', 1, 0, 0, '/crm', 'ep:avatar', '', '', 0, b'1', b'1', b'1', '1', '2023-10-20 00:36:13', '1', '2023-10-19 16:37:24', b'0'); - - -- ---------------------------- -- 回款菜单 -- ---------------------------- @@ -360,63 +353,3 @@ VALUES ( '回款计划导出', 'crm:receivable-plan:export', 3, 5, @parentId, '', '', '', 0 ); - --- ---------------------------- --- 客户管理菜单 --- ---------------------------- - --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '客户管理', '', 2, 0, 2375, - 'customer', '', 'crm/customer/index', 0, 'CrmCustomer' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '客户查询', 'crm:customer:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '客户创建', 'crm:customer:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '客户更新', 'crm:customer:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '客户删除', 'crm:customer:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '客户导出', 'crm:customer:export', 3, 5, @parentId, - '', '', '', 0 -); 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 dd2c068d3..0e412ee9b 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 @@ -1,7 +1,7 @@ package cn.iocoder.yudao.module.crm.enums; /** - * System 字典类型的枚举类 + * CRM 字典类型的枚举类 * * @author 芋道源码 */ diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java index c2da3744e..f58028314 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/customer/CrmCustomerLevelEnum.java @@ -15,12 +15,13 @@ import java.util.Arrays; @AllArgsConstructor public enum CrmCustomerLevelEnum implements IntArrayValuable { - IMPORTANT(1, "A (重点客户)"), - GENERAL(2, "B (普通客户)"), - LOW_PRIORITY(3, "C (非优先客户)"); + IMPORTANT(1, "A(重点客户)"), + GENERAL(2, "B(普通客户)"), + LOW_PRIORITY(3, "C(非优先客户)"); public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmCustomerLevelEnum::getStatus).toArray(); + // TODO @wanwan:这里的 status 字段,可以考虑改成 level /** * 状态 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java index f3b81151c..0e4d4463d 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java @@ -10,7 +10,6 @@ import org.springframework.format.annotation.DateTimeFormat; import javax.validation.constraints.Email; import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import java.time.LocalDateTime; @@ -49,20 +48,20 @@ public class CrmCustomerBaseVO { private String website; @Schema(description = "QQ", example = "123456789") - @Size(max = 20, message = "QQ长度不能超过20个字符") + @Size(max = 20, message = "QQ长度不能超过 20 个字符") private String qq; @Schema(description = "wechat", example = "123456789") - @Size(max = 255, message = "微信长度不能超过255个字符") + @Size(max = 255, message = "微信长度不能超过 255 个字符") private String wechat; @Schema(description = "email", example = "123456789@qq.com") @Email(message = "邮箱格式不正确") - @Size(max = 255, message = "邮箱长度不能超过255个字符") + @Size(max = 255, message = "邮箱长度不能超过 255 个字符") private String email; @Schema(description = "客户描述", example = "任意文字") - @Size(max = 4096, message = "客户描述长度不能超过255个字符") + @Size(max = 4096, message = "客户描述长度不能超过 4096 个字符") private String description; @Schema(description = "备注", example = "随便") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java index ab806b689..84462ddfa 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java @@ -11,4 +11,6 @@ import lombok.ToString; @ToString(callSuper = true) public class CrmCustomerCreateReqVO extends CrmCustomerBaseVO { + // TODO @wanwan:负责人 + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java index a50ada4c5..6e5026c94 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java @@ -51,17 +51,20 @@ public class CrmCustomerDO extends BaseDO { private Boolean dealStatus; /** * 所属行业 - * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY} + * + * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_CUSTOMER_INDUSTRY} */ private Integer industryId; /** * 客户等级 - * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL} + * + * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_CUSTOMER_LEVEL} */ private Integer level; /** * 客户来源 - * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE} + * + * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_CUSTOMER_SOURCE} */ private Integer source; /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java index 838423086..0b2497a7b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerMapper.java @@ -19,7 +19,7 @@ import java.util.List; public interface CrmCustomerMapper extends BaseMapperX { default PageResult selectPage(CrmCustomerPageReqVO reqVO) { - // TODO @Wanwan 填充负责人,所属部门字段 + // TODO @Wanwan 填充负责人,所属部门字段;这个可以在 controller 填哈; return selectPage(reqVO, new LambdaQueryWrapperX() .likeIfPresent(CrmCustomerDO::getName, reqVO.getName()) .eqIfPresent(CrmCustomerDO::getMobile, reqVO.getMobile()) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java index 4e41fab25..73c6af2b6 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java @@ -75,8 +75,8 @@ public interface CrmCustomerService { /** * 校验客户是否存在 * - * @param customerId 客户id - * @return + * @param customerId 客户 id + * @return 客户 */ CrmCustomerDO validateCustomer(Long customerId); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java index fb27d4ae9..15535f681 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java @@ -1,23 +1,26 @@ package cn.iocoder.yudao.module.crm.service.customer; -import cn.iocoder.yudao.module.system.api.dept.DeptApi; -import org.springframework.stereotype.Service; -import javax.annotation.Resource; -import org.springframework.validation.annotation.Validated; - -import java.util.*; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; -import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; - -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; - 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.customer.vo.CrmCustomerCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO; +import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; +import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; +import cn.iocoder.yudao.module.system.api.dept.DeptApi; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.Collection; +import java.util.List; +import java.util.Objects; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS; /** * 客户 Service 实现类 @@ -31,7 +34,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @Resource private CrmCustomerMapper customerMapper; @Resource - private DeptApi deptApi; + private DeptApi deptApi; // TODO @wanwan:拼接数据,可以放到 controller;所以这里的引入,可以考虑放到 controller 哈; @Override public Long createCustomer(CrmCustomerCreateReqVO createReqVO) { @@ -46,6 +49,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { public void updateCustomer(CrmCustomerUpdateReqVO updateReqVO) { // 校验存在 validateCustomerExists(updateReqVO.getId()); + // TODO 芋艿:数据权限,校验是否可以操作 + // 更新 CrmCustomerDO updateObj = CrmCustomerConvert.INSTANCE.convert(updateReqVO); customerMapper.updateById(updateObj); @@ -55,6 +60,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { public void deleteCustomer(Long id) { // 校验存在 validateCustomerExists(id); + // TODO 芋艿:数据权限,校验是否可以操作 + // 删除 customerMapper.deleteById(id); } @@ -80,6 +87,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @Override public PageResult getCustomerPage(CrmCustomerPageReqVO pageReqVO) { + // TODO 芋艿:数据权限,是否可以查询到; return customerMapper.selectPage(pageReqVO); } @@ -88,6 +96,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { return customerMapper.selectList(exportReqVO); } + // TODO wanwan:service 接口已经注释,实现类就不需要了。 /** * 校验客户是否存在 * @@ -102,4 +111,5 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { } return customer; } + } From 677e8ab2fc0c50185425ba24b90d0049099ab027 Mon Sep 17 00:00:00 2001 From: liuhongfeng <291117974@qq.com> Date: Sun, 29 Oct 2023 18:00:34 +0800 Subject: [PATCH 034/101] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91?= =?UTF-8?q?=E5=9B=9E=E6=AC=BE=E8=AE=A1=E5=88=92-=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B=20=E3=80=90=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E3=80=91=E4=BF=AE=E6=94=B9=E5=9B=9E=E6=AC=BE=E8=AE=A1?= =?UTF-8?q?=E5=88=92-=E5=88=9B=E5=BB=BA=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=A2=E6=88=B7=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/AuditStatusEnum.java | 2 +- .../receivable/vo/ReceivablePlanBaseVO.java | 2 +- .../receivable/vo/ReceivablePlanExcelVO.java | 2 +- .../vo/ReceivablePlanExportReqVO.java | 2 +- .../vo/ReceivablePlanPageReqVO.java | 2 +- .../receivable/ReceivablePlanDO.java | 2 +- .../receivable/ReceivablePlanServiceImpl.java | 39 +++++++++++++++++-- .../receivable/ReceivableServiceImpl.java | 21 ++++++++-- 8 files changed, 59 insertions(+), 13 deletions(-) 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 index ce04c18a1..6cc1012b6 100644 --- 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 @@ -17,7 +17,7 @@ public enum AuditStatusEnum implements IntArrayValuable { /** * 审核通过 */ - AUDIT_FINISH(0, "审核通过"), + AUDIT_FINISH(1, "审核通过"), /** * 审核拒绝 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java index 59f333e4b..53572e2c4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java @@ -31,7 +31,7 @@ public class ReceivablePlanBaseVO { // TODO @liuhongfeng:这个字段,可以写个枚举,然后 InEnum 去校验下; // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的 @Schema(description = "审批状态", example = "1") - private String checkStatus; + private Integer checkStatus; // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; @Schema(description = "工作流编号", example = "8909") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java index e12d5a1df..d08cfc6a7 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java @@ -37,7 +37,7 @@ public class ReceivablePlanExcelVO { @ExcelProperty(value = "审批状态", converter = DictConvert.class) @DictFormat("crm_receivable_check_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 - private String checkStatus; + private Integer checkStatus; //@ExcelProperty("工作流编号") //private Long processInstanceId; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java index ca5d3f553..e68427d29 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java @@ -20,7 +20,7 @@ public class ReceivablePlanExportReqVO { private Integer status; @Schema(description = "审批状态", example = "1") - private String checkStatus; + private Integer checkStatus; @Schema(description = "计划回款日期") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java index 2d0e7d5ae..acd4d5aa4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java @@ -26,7 +26,7 @@ public class ReceivablePlanPageReqVO extends PageParam { private Integer status; @Schema(description = "审批状态", example = "1") - private String checkStatus; + private Integer checkStatus; @Schema(description = "计划回款日期") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java index 4447df053..0c6f6e033 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java @@ -49,7 +49,7 @@ public class ReceivablePlanDO extends BaseDO { * * 枚举 {@link TODO crm_receivable_check_status 对应的类} */ - private String checkStatus; + private Integer checkStatus; /** * 工作流编号 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java index c0b236ac0..f8493a1ec 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java @@ -10,8 +10,14 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlan import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanPageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanUpdateReqVO; import cn.iocoder.yudao.module.crm.convert.receivable.ReceivablePlanConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivablePlanMapper; +import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; +import cn.iocoder.yudao.module.crm.service.contract.ContractService; +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -20,7 +26,7 @@ import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_PLAN_NOT_EXISTS; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; /** * 回款计划 Service 实现类 @@ -33,20 +39,47 @@ public class ReceivablePlanServiceImpl implements ReceivablePlanService { @Resource private ReceivablePlanMapper receivablePlanMapper; + @Resource + private ContractService contractService; + @Resource + private CrmCustomerService crmCustomerService; @Override public Long createReceivablePlan(ReceivablePlanCreateReqVO createReqVO) { // 插入 ReceivablePlanDO receivablePlan = ReceivablePlanConvert.INSTANCE.convert(createReqVO); - // TODO @liuhongfeng:空格要注释;if (ObjectUtil.isNull(receivablePlan.getStatus())) { - if(ObjectUtil.isNull(receivablePlan.getStatus())){ + if (ObjectUtil.isNull(receivablePlan.getStatus())){ receivablePlan.setStatus(CommonStatusEnum.ENABLE.getStatus()); } + if (ObjectUtil.isNull(receivablePlan.getCheckStatus())){ + receivablePlan.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue()); + } + + checkReceivablePlan(receivablePlan); + receivablePlanMapper.insert(receivablePlan); // 返回 return receivablePlan.getId(); } + private void checkReceivablePlan(ReceivablePlanDO receivablePlan) { + + if(ObjectUtil.isNull(receivablePlan.getContractId())){ + throw exception(CONTRACT_NOT_EXISTS); + } + + ContractDO contract = contractService.getContract(receivablePlan.getContractId()); + if(ObjectUtil.isNull(contract)){ + throw exception(CONTRACT_NOT_EXISTS); + } + + CrmCustomerDO customer = crmCustomerService.getCustomer(receivablePlan.getCustomerId()); + if(ObjectUtil.isNull(customer)){ + throw exception(CUSTOMER_NOT_EXISTS); + } + + } + @Override public void updateReceivablePlan(ReceivablePlanUpdateReqVO updateReqVO) { // 校验存在 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java index 39de05fe1..cf216d4d2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableCreateReqVO; import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableExportReqVO; @@ -11,10 +12,12 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePage import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableUpdateReqVO; import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; import cn.iocoder.yudao.module.crm.service.contract.ContractService; +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -23,8 +26,7 @@ import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_NOT_EXISTS; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; /** * 回款管理 Service 实现类 @@ -39,15 +41,21 @@ public class ReceivableServiceImpl implements ReceivableService { private ReceivableMapper receivableMapper; @Resource private ContractService contractService; + @Resource + private CrmCustomerService crmCustomerService; @Override public Long createReceivable(ReceivableCreateReqVO createReqVO) { // TODO @liuhongfeng:planId 是否存在,是否合法,需要去校验; - // TODO @liuhongfeng:其它类似 customerId、contractId 也需要去校验; // 插入 ReceivableDO receivable = ReceivableConvert.INSTANCE.convert(createReqVO); + if (ObjectUtil.isNull(receivable.getStatus())){ + receivable.setStatus(CommonStatusEnum.ENABLE.getStatus()); + } + if (ObjectUtil.isNull(receivable.getCheckStatus())){ + receivable.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue()); + } - receivable.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue()); //校验 checkReceivable(receivable); @@ -67,6 +75,11 @@ public class ReceivableServiceImpl implements ReceivableService { throw exception(CONTRACT_NOT_EXISTS); } + CrmCustomerDO customer = crmCustomerService.getCustomer(receivable.getCustomerId()); + if(ObjectUtil.isNull(customer)){ + throw exception(CUSTOMER_NOT_EXISTS); + } + } @Override From 67ac11b56c242df634a000315c8265e43fb2552a Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 29 Oct 2023 18:39:54 +0800 Subject: [PATCH 035/101] =?UTF-8?q?code=20review=EF=BC=9Acrm=20=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E8=BD=AC=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/module/crm/enums/ErrorCodeConstants.java | 6 +++--- .../admin/business/vo/CrmBusinessCreateReqVO.java | 9 --------- .../admin/business/vo/CrmBusinessTransferReqVO.java | 2 +- .../admin/business/vo/CrmBusinessUpdateReqVO.java | 8 -------- .../admin/contact/vo/ContactUpdateReqVO.java | 8 -------- .../admin/contact/vo/CrmContactTransferReqVO.java | 2 +- .../controller/admin/contract/ContractController.java | 1 - .../admin/contract/vo/ContractCreateReqVO.java | 8 -------- .../admin/contract/vo/ContractUpdateReqVO.java | 7 ------- .../admin/contract/vo/CrmContractTransferReqVO.java | 2 +- .../crm/convert/business/CrmBusinessConvert.java | 4 +++- .../module/crm/convert/contact/ContactConvert.java | 1 + .../module/crm/convert/contract/ContractConvert.java | 1 + .../yudao/module/crm/framework/utils/AuthUtil.java | 4 ++++ .../crm/service/business/CrmBusinessServiceImpl.java | 11 ++++++----- .../crm/service/contact/ContactServiceImpl.java | 1 + .../crm/service/contract/ContractServiceImpl.java | 1 + 17 files changed, 23 insertions(+), 53 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 7c1f351d8..69405a5b9 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -11,7 +11,7 @@ public interface ErrorCodeConstants { // ========== 合同管理 1-020-000-000 ========== ErrorCode CONTRACT_NOT_EXISTS = new ErrorCode(1_020_000_000, "合同不存在"); - ErrorCode CONTRACT_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_000_001, "合同转移失败,原因:没有转移权限"); + ErrorCode CONTRACT_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_000_001, "合同转移失败,原因:没有转移权限"); // TODO @puhui999:这个搞成 “合同操作失败,原因:没有权限” ErrorCode CONTRACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_000_002, "合同转移失败,原因:负责人不存在"); // ========== 线索管理 1-020-001-000 ========== @@ -19,7 +19,7 @@ public interface ErrorCodeConstants { // ========== 商机管理 1-020-002-000 ========== ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); - ErrorCode BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_002_001, "商机转移失败,原因:没有转移权限"); + ErrorCode BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_002_001, "商机转移失败,原因:没有转移权限"); // TODO @puhui999:这个搞成 “商机操作失败,原因:没有权限” ErrorCode BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_002_002, "商机转移失败,原因:负责人不存在"); // TODO @lilleo:商机状态、商机类型,都单独错误码段 @@ -29,7 +29,7 @@ public interface ErrorCodeConstants { // ========== 联系人管理 1-020-003-000 ========== ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); - ErrorCode CONTACT_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_003_001, "联系人转移失败,原因:没有转移权限"); + ErrorCode CONTACT_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_003_001, "联系人转移失败,原因:没有转移权限"); // TODO @puhui999:这个搞成 “联系人操作失败,原因:没有权限” ErrorCode CONTACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_003_002, "联系人转移失败,原因:负责人不存在"); // TODO @liuhongfeng:错误码分段; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java index 968a105c8..f743c8469 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessCreateReqVO.java @@ -5,21 +5,12 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import java.util.Set; - @Schema(description = "管理后台 - 商机创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class CrmBusinessCreateReqVO extends CrmBusinessBaseVO { - @Schema(description = "只读权限的用户编号数组") - private Set roUserIds; - - @Schema(description = "读写权限的用户编号数组") - private Set rwUserIds; - - // TODO @ljileo:新建的时候,应该可以传递添加的产品; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessTransferReqVO.java index 993e4750e..fd769e77c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessTransferReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessTransferReqVO.java @@ -15,6 +15,6 @@ public class CrmBusinessTransferReqVO { @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") @NotNull(message = "新负责人的用户编号不能为空") - private Long ownerUserId; // 新的负责人 + private Long ownerUserId; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java index 2929535cf..f137d4c5b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessUpdateReqVO.java @@ -6,7 +6,6 @@ import lombok.EqualsAndHashCode; import lombok.ToString; import javax.validation.constraints.NotNull; -import java.util.Set; @Schema(description = "管理后台 - 商机更新 Request VO") @Data @@ -18,13 +17,6 @@ public class CrmBusinessUpdateReqVO extends CrmBusinessBaseVO { @NotNull(message = "主键不能为空") private Long id; - @Schema(description = "只读权限的用户编号数组") - private Set roUserIds; - - @Schema(description = "读写权限的用户编号数组") - private Set rwUserIds; - - // TODO @ljileo:修改的时候,应该可以传递添加的产品; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java index 60afd06f2..f319b52f0 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java @@ -5,8 +5,6 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import java.util.Set; - @Schema(description = "管理后台 - crm联系人更新 Request VO") @Data @EqualsAndHashCode(callSuper = true) @@ -16,10 +14,4 @@ public class ContactUpdateReqVO extends ContactBaseVO { @Schema(description = "主键", example = "23210") private Long id; - @Schema(description = "只读权限的用户编号数组") - private Set roUserIds; - - @Schema(description = "读写权限的用户编号数组") - private Set rwUserIds; - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java index 90acc5645..de4c1cbb6 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java @@ -15,6 +15,6 @@ public class CrmContactTransferReqVO { @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") @NotNull(message = "新负责人的用户编号不能为空") - private Long ownerUserId; // 新的负责人 + private Long ownerUserId; } 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/ContractController.java index 4898eb6c1..7a7326cde 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/ContractController.java @@ -95,5 +95,4 @@ public class ContractController { return success(true); } - } 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/ContractCreateReqVO.java index 7b8c561b0..b21007f47 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/ContractCreateReqVO.java @@ -5,18 +5,10 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import java.util.Set; - @Schema(description = "管理后台 - 合同创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class ContractCreateReqVO extends ContractBaseVO { - @Schema(description = "只读权限的用户编号数组") - private Set roUserIds; - - @Schema(description = "读写权限的用户编号数组") - private Set rwUserIds; - } 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/ContractUpdateReqVO.java index e6f305ce4..ba38ca383 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/ContractUpdateReqVO.java @@ -6,7 +6,6 @@ import lombok.EqualsAndHashCode; import lombok.ToString; import javax.validation.constraints.NotNull; -import java.util.Set; @Schema(description = "管理后台 - 合同更新 Request VO") @Data @@ -18,10 +17,4 @@ public class ContractUpdateReqVO extends ContractBaseVO { @NotNull(message = "合同编号不能为空") private Long id; - @Schema(description = "只读权限的用户编号数组") - private Set roUserIds; - - @Schema(description = "读写权限的用户编号数组") - private Set rwUserIds; - } 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 5dfa5fe0a..b02834932 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 @@ -15,6 +15,6 @@ public class CrmContractTransferReqVO { @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") @NotNull(message = "新负责人的用户编号不能为空") - private Long ownerUserId; // 新的负责人 + private Long ownerUserId; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java index 2eabf7d4d..a025d3ed4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java @@ -32,8 +32,10 @@ public interface CrmBusinessConvert { default CrmBusinessDO convert(CrmBusinessDO business, CrmBusinessTransferReqVO reqVO, Long userId) { Set rwUserIds = business.getRwUserIds(); - rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 + rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 TODO puhui999:是不是直接 rwUserIds.remove(userId) + // TODO @puhui999:ownerUserId 不用添加到进去,它就是 ownerUserId 就够;因为一共有 3 个角色:负责人、读写、只读; rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 + // TODO @puhui999:对原负责人,加个类似的处理:移除、转化为团队成员(只读、读写) return new CrmBusinessDO().setId(business.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 .setRwUserIds(rwUserIds); } 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 0d1329819..c14ea7586 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 @@ -32,6 +32,7 @@ public interface ContactConvert { List convertList02(List list); + // TODO @puhui999:参考 CrmBusinessConvert 的修改建议 default ContactDO convert(ContactDO contact, CrmContactTransferReqVO reqVO, Long userId) { Set rwUserIds = contact.getRwUserIds(); rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 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 d7547d4b8..7d0dc84fa 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 @@ -32,6 +32,7 @@ public interface ContractConvert { List convertList02(List list); + // TODO @puhui999:参考 CrmBusinessConvert 的修改建议 default ContractDO convert(ContractDO contract, CrmContractTransferReqVO reqVO, Long userId) { Set rwUserIds = contract.getRwUserIds(); rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/AuthUtil.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/AuthUtil.java index 3c3d14bf2..fb66d6f0d 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/AuthUtil.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/AuthUtil.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.framework.utils; import java.util.Collection; +// TODO @puhui999:改成 CrmPermissionUtils; /** * 数据读写权限校验工具类 * @@ -9,6 +10,8 @@ import java.util.Collection; */ public class AuthUtil { + // TODO @puhui999:负责人是单独的字段哈; + // TODO @puhui999:额外校验,如果是管理员,可以查看所有;看着要做成有状态的了,可能要搞个 CrmPermissionService 咧; /** * 判断当前数据对用户来说是否是只读的 * @@ -17,6 +20,7 @@ public class AuthUtil { * @return boolean 是/否 */ public static boolean isReadOnly(Collection roUserIds, Long userId) { + // TODO @puhui999:从代码角度来说,最好使用 CollUtil.contains return roUserIds.contains(userId); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java index 4ddb3363e..fc01ec555 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java @@ -92,26 +92,27 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { return businessMapper.selectList(exportReqVO); } + // TODO @puhui999:动名词哈。transferBusiness @Override public void businessTransfer(CrmBusinessTransferReqVO reqVO, Long userId) { - // 1. 校验商机是否存在 + // 1.1 校验商机是否存在 CrmBusinessDO business = validateBusinessExists(reqVO.getId()); - // 1.2. 校验用户是否拥有读写权限 + // 1.2 校验用户是否拥有读写权限 if (!isReadAndWrite(business.getRwUserIds(), userId)) { throw exception(BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED); } - // 2. 校验新负责人是否存在 + // TODO @puhui999:如果已经是该负责人,抛个业务异常; + // 1.3 校验新负责人是否存在 AdminUserRespDTO user = adminUserApi.getUser(reqVO.getOwnerUserId()); if (user == null) { throw exception(BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS); } - // 3. 更新新的负责人 + // 2. 更新新的负责人 CrmBusinessDO updateBusiness = CrmBusinessConvert.INSTANCE.convert(business, reqVO, userId); businessMapper.updateById(updateBusiness); // 4. TODO 记录商机转移日志 - } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java index e47e2e155..cca752efa 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java @@ -95,6 +95,7 @@ public class ContactServiceImpl implements ContactService { return contactMapper.selectList(exportReqVO); } + // TODO @puhui999:参考 CrmBusinessServiceImpl 修改建议 @Override public void contactTransfer(CrmContactTransferReqVO reqVO, Long userId) { // 1. 校验联系人是否存在 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/ContractServiceImpl.java index 8cee161f0..05e1dadd7 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/ContractServiceImpl.java @@ -92,6 +92,7 @@ public class ContractServiceImpl implements ContractService { return contractMapper.selectList(exportReqVO); } + // TODO @puhui999:参考 CrmBusinessServiceImpl 修改建议 @Override public void contractTransfer(CrmContractTransferReqVO reqVO, Long userId) { // 1. 校验合同是否存在 From d1978d318bed325332ca65d0ced2b008a0fee58d Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 29 Oct 2023 19:05:36 +0800 Subject: [PATCH 036/101] =?UTF-8?q?code=20review=EF=BC=9Acrm=20=E5=90=88?= =?UTF-8?q?=E5=90=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 37 ------------ sql/mysql/crm_menu.sql | 59 ------------------- .../admin/business/vo/CrmBusinessExcelVO.java | 21 +++---- 3 files changed, 7 insertions(+), 110 deletions(-) diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 677ea2881..333e5be23 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -1,42 +1,5 @@ SET NAMES utf8mb4; --- ---------------------------- --- 合同表 --- ---------------------------- -DROP TABLE IF EXISTS `crm_contract`; -CREATE TABLE `crm_contract` -( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,主键自增', - `name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '合同名称', - `customer_id` bigint DEFAULT NULL COMMENT '客户编号', - `business_id` bigint DEFAULT NULL COMMENT '商机编号', - `process_instance_id` bigint DEFAULT NULL COMMENT '工作流编号', - `order_date` datetime DEFAULT NULL COMMENT '下单日期', - `owner_user_id` bigint DEFAULT NULL COMMENT '负责人的用户编号', - `no` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '合同编号', - `start_time` datetime DEFAULT NULL COMMENT '开始时间', - `end_time` datetime DEFAULT NULL COMMENT '结束时间', - `price` int DEFAULT NULL COMMENT '合同金额', - `discount_percent` int DEFAULT NULL COMMENT '整单折扣', - `product_price` int DEFAULT NULL COMMENT '产品总金额', - `ro_user_ids` varchar(4096) DEFAULT NULL COMMENT '只读权限的用户编号数组', - `rw_user_ids` varchar(4096) DEFAULT NULL COMMENT '读写权限的用户编号数组', - `contact_id` bigint DEFAULT NULL COMMENT '联系人编号', - `sign_user_id` bigint DEFAULT NULL COMMENT '公司签约人', - `contact_last_time` datetime DEFAULT NULL COMMENT '最后跟进时间', - - -- 通用字段 - `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB - CHARACTER SET = utf8mb4 - COLLATE = utf8mb4_unicode_ci COMMENT ='合同表'; DROP TABLE IF EXISTS `crm_clue`; diff --git a/sql/mysql/crm_menu.sql b/sql/mysql/crm_menu.sql index d0c9b6dce..ade69c658 100644 --- a/sql/mysql/crm_menu.sql +++ b/sql/mysql/crm_menu.sql @@ -1,62 +1,3 @@ --- ---------------------------- --- 合同菜单 --- ---------------------------- - --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '合同管理', '', 2, 0, 2375, - 'contract', '', 'crm/contract/index', 0, 'Contract' -); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '合同查询', 'crm:contract:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '合同创建', 'crm:contract:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '合同更新', 'crm:contract:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '合同删除', 'crm:contract:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '合同导出', 'crm:contract:export', 3, 5, @parentId, - '', '', '', 0 -); -- ---------------------------- -- 线索菜单 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExcelVO.java index 087deafb0..e7e3ef987 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessExcelVO.java @@ -1,18 +1,11 @@ package cn.iocoder.yudao.module.crm.controller.admin.business.vo; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.math.BigDecimal; -import java.math.BigDecimal; -import java.math.BigDecimal; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; - import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.Set; /** * 商机 Excel VO @@ -62,10 +55,10 @@ public class CrmBusinessExcelVO { private LocalDateTime createTime; @ExcelProperty("只读权限的用户编号数组") - private String roUserIds; + private Set roUserIds; @ExcelProperty("读写权限的用户编号数组") - private String rwUserIds; + private Set rwUserIds; @ExcelProperty("1赢单2输单3无效") private Integer endStatus; From 973b7109927b0803040045320b2ddcf70468b4b0 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 29 Oct 2023 19:14:15 +0800 Subject: [PATCH 037/101] =?UTF-8?q?code=20review=EF=BC=9Acrm=20=E5=95=86?= =?UTF-8?q?=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 87 ------------------------------- sql/mysql/crm_menu.sql | 116 ----------------------------------------- 2 files changed, 203 deletions(-) diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 333e5be23..e5b120ead 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -2,63 +2,6 @@ SET NAMES utf8mb4; -DROP TABLE IF EXISTS `crm_clue`; -CREATE TABLE `crm_clue` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号,主键自增', - `transform_status` tinyint DEFAULT NULL COMMENT '转化状态', - `follow_up_status` tinyint DEFAULT NULL COMMENT '跟进状态', - `name` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '线索名称', - `customer_id` bigint NOT NULL COMMENT '客户id', - `contact_next_time` datetime DEFAULT NULL COMMENT '下次联系时间', - `telephone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电话', - `mobile` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机号', - `address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址', - `owner_user_id` bigint NOT NULL COMMENT '负责人的用户编号', - `contact_last_time` datetime DEFAULT NULL COMMENT '最后跟进时间', - `remark` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者', - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB COMMENT = '线索表' ; - --- ---------------------------- --- 商机表 --- ---------------------------- - -DROP TABLE IF EXISTS `crm_business`; -CREATE TABLE `crm_business` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(100) NOT NULL COMMENT '商机名称', - `status_type_id` bigint DEFAULT NULL COMMENT '商机状态类型编号', - `status_id` bigint DEFAULT NULL COMMENT '商机状态编号', - `contact_next_time` datetime DEFAULT NULL COMMENT '下次联系时间', - `customer_id` bigint NOT NULL COMMENT '客户编号', - `deal_time` datetime DEFAULT NULL COMMENT '预计成交日期', - `price` decimal(18,2) DEFAULT NULL COMMENT '商机金额', - `discount_percent` decimal(10,2) DEFAULT NULL COMMENT '整单折扣', - `product_price` decimal(18,2) DEFAULT NULL COMMENT '产品总金额', - `remark` varchar(500) DEFAULT NULL COMMENT '备注', - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '创建人', - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '' COMMENT '更新人', - `owner_user_id` bigint DEFAULT NULL COMMENT '负责人的用户编号', - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', - `update_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间', - `ro_user_ids` longtext NOT NULL COMMENT '只读权限的用户编号数组', - `rw_user_ids` longtext NOT NULL COMMENT '读写权限的用户编号数组', - `end_status` int NOT NULL COMMENT '1赢单2输单3无效', - `end_remark` varchar(500) DEFAULT NULL COMMENT '结束时的备注', - `deleted` bit(1) DEFAULT b'0' COMMENT '逻辑删除', - `contact_last_time` datetime DEFAULT NULL COMMENT '最后跟进时间', - `follow_up_status` int DEFAULT NULL COMMENT '跟进状态', - `tenant_id` bigint DEFAULT '0' COMMENT '租户ID', - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='商机表'; - - -- ---------------------------- -- 回款表 @@ -148,33 +91,3 @@ CREATE TABLE `crm_contact` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='crm联系人'; - --- ---------------------------- --- 商机状态表 --- ---------------------------- -DROP TABLE IF EXISTS `crm_business_status`; -CREATE TABLE `crm_business_status` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `type_id` bigint NOT NULL COMMENT '状态类型编号', - `name` varchar(100) NOT NULL COMMENT '状态名', - `percent` varchar(20) DEFAULT NULL COMMENT '赢单率', - `sort` int DEFAULT NULL COMMENT '排序', - `tenant_id` bigint DEFAULT '1' COMMENT '租户ID', - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='商机状态表' - --- ---------------------------- --- 商机状态类型表 --- ---------------------------- -DROP TABLE IF EXISTS `crm_business_status_type`; -CREATE TABLE `crm_business_status_type` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(100) NOT NULL COMMENT '状态类型名', - `dept_ids` varchar(200) NOT NULL COMMENT '使用的部门编号', - `status` bit(1) NOT NULL DEFAULT b'0' COMMENT '开启状态', - `creator` varchar(64) NOT NULL COMMENT '创建人', - `create_time` datetime NOT NULL COMMENT '创建时间', - `update_time` datetime DEFAULT NULL COMMENT '更新时间', - `tenant_id` bigint DEFAULT '1' COMMENT '租户ID', - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='商机状态类型表' diff --git a/sql/mysql/crm_menu.sql b/sql/mysql/crm_menu.sql index ade69c658..be0595da1 100644 --- a/sql/mysql/crm_menu.sql +++ b/sql/mysql/crm_menu.sql @@ -1,63 +1,6 @@ --- ---------------------------- --- 线索菜单 --- ---------------------------- --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '线索管理', '', 2, 0, 2375, - 'clue', '', 'crm/clue/index', 0, 'CrmClue' -); --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '线索查询', 'crm:clue:query', 3, 1, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '线索创建', 'crm:clue:create', 3, 2, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '线索更新', 'crm:clue:update', 3, 3, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '线索删除', 'crm:clue:delete', 3, 4, @parentId, - '', '', '', 0 -); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '线索导出', 'crm:clue:export', 3, 5, @parentId, - '', '', '', 0 -); -- 菜单 SQL INSERT INTO system_menu( name, permission, type, sort, parent_id, @@ -114,65 +57,6 @@ VALUES ( '', '', '', 0 ); --- ---------------------------- --- 合同菜单 --- ---------------------------- - --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '商机管理', '', 2, 0, '', - 'business', '', 'crm/business/index', 0, 'CrmBusiness' - ); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '商机查询', 'crm:business:query', 3, 1, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '商机创建', 'crm:business:create', 3, 2, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '商机更新', 'crm:business:update', 3, 3, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '商机删除', 'crm:business:delete', 3, 4, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '商机导出', 'crm:business:export', 3, 5, @parentId, - '', '', '', 0 - ); -- ---------------------------- -- 回款菜单 From 53afce0bff2cef4d2dcbe2b9f5487825ee13bdfe Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 29 Oct 2023 19:22:09 +0800 Subject: [PATCH 038/101] =?UTF-8?q?code=20review=EF=BC=9Acrm=20=E5=9B=9E?= =?UTF-8?q?=E6=AC=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 28 ------- sql/mysql/crm_menu.sql | 180 ----------------------------------------- 2 files changed, 208 deletions(-) diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index e5b120ead..de7922d24 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -63,31 +63,3 @@ CREATE TABLE `crm_receivable_plan` ( `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '回款计划' ROW_FORMAT = DYNAMIC; - - - - - - -CREATE TABLE `crm_contact` ( - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键', - `name` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '联系人名称', - `next_time` datetime DEFAULT NULL COMMENT '下次联系时间', - `mobile` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '手机号', - `telephone` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电话', - `email` varchar(128) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '电子邮箱', - `post` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '职务', - `customer_id` bigint(20) DEFAULT NULL COMMENT '客户编号', - `address` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址', - `remark` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注', - `creator` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '创建人', - `owner_user_id` bigint DEFAULT NULL COMMENT '负责人用户编号', - `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间', - `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间', - `last_time` timestamp NULL DEFAULT NULL COMMENT '最后跟进时间', - `updater` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '更新人', - `deleted` bit(1) NOT NULL DEFAULT b'0', - `tenant_id` bigint DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='crm联系人'; - diff --git a/sql/mysql/crm_menu.sql b/sql/mysql/crm_menu.sql index be0595da1..e69de29bb 100644 --- a/sql/mysql/crm_menu.sql +++ b/sql/mysql/crm_menu.sql @@ -1,180 +0,0 @@ - - - --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '联系人', '', 2, 0, ${table.parentMenuId}, - 'contact', '', 'crm/contact/index', 0, 'Contact' - ); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '联系人查询', 'crm:contact:query', 3, 1, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '联系人创建', 'crm:contact:create', 3, 2, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '联系人更新', 'crm:contact:update', 3, 3, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '联系人删除', 'crm:contact:delete', 3, 4, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '联系人导出', 'crm:contact:export', 3, 5, @parentId, - '', '', '', 0 - ); - - --- ---------------------------- --- 回款菜单 --- ---------------------------- - --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '回款管理', '', 2, 0, 2375, - 'receivable', '', 'crm/receivable/index', 0, 'Receivable' - ); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '回款管理查询', 'crm:receivable:query', 3, 1, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '回款管理创建', 'crm:receivable:create', 3, 2, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '回款管理更新', 'crm:receivable:update', 3, 3, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '回款管理删除', 'crm:receivable:delete', 3, 4, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '回款管理导出', 'crm:receivable:export', 3, 5, @parentId, - '', '', '', 0 - ); - - --- ---------------------------- --- 回款计划菜单 --- ---------------------------- - --- 菜单 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status, component_name -) -VALUES ( - '回款计划管理', '', 2, 0, 2375, - 'receivable-plan', '', 'crm/receivablePlan/index', 0, 'ReceivablePlan' - ); - --- 按钮父菜单ID --- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 -SELECT @parentId := LAST_INSERT_ID(); - --- 按钮 SQL -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '回款计划查询', 'crm:receivable-plan:query', 3, 1, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '回款计划创建', 'crm:receivable-plan:create', 3, 2, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '回款计划更新', 'crm:receivable-plan:update', 3, 3, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '回款计划删除', 'crm:receivable-plan:delete', 3, 4, @parentId, - '', '', '', 0 - ); -INSERT INTO system_menu( - name, permission, type, sort, parent_id, - path, icon, component, status -) -VALUES ( - '回款计划导出', 'crm:receivable-plan:export', 3, 5, @parentId, - '', '', '', 0 - ); From 054d80b4725eafd88dee23b563094737b8aa4a30 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 29 Oct 2023 19:23:09 +0800 Subject: [PATCH 039/101] =?UTF-8?q?code=20review=EF=BC=9A=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=20crm=20=E6=9C=80=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/ruoyi-vue-pro.sql | 112 +++++++++++++++++++++++++++++++----- 1 file changed, 97 insertions(+), 15 deletions(-) diff --git a/sql/mysql/ruoyi-vue-pro.sql b/sql/mysql/ruoyi-vue-pro.sql index 0022811bb..b26915d5e 100644 --- a/sql/mysql/ruoyi-vue-pro.sql +++ b/sql/mysql/ruoyi-vue-pro.sql @@ -11,7 +11,7 @@ Target Server Version : 80034 File Encoding : 65001 - Date: 24/10/2023 20:48:38 + Date: 29/10/2023 19:22:42 */ SET NAMES utf8mb4; @@ -341,7 +341,8 @@ CREATE TABLE `infra_api_access_log` ( `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE + PRIMARY KEY (`id`) USING BTREE, + INDEX `idx_create_time`(`create_time` ASC) USING BTREE ) ENGINE = InnoDB AUTO_INCREMENT = 35832 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'API 访问日志表'; -- ---------------------------- @@ -384,7 +385,7 @@ CREATE TABLE `infra_api_error_log` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1745 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统异常日志'; +) ENGINE = InnoDB AUTO_INCREMENT = 1750 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统异常日志'; -- ---------------------------- -- Records of infra_api_error_log @@ -538,7 +539,7 @@ CREATE TABLE `infra_file` ( `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1108 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件表'; +) ENGINE = InnoDB AUTO_INCREMENT = 1109 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件表'; -- ---------------------------- -- Records of infra_file @@ -587,7 +588,7 @@ CREATE TABLE `infra_file_content` ( `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 201 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件表'; +) ENGINE = InnoDB AUTO_INCREMENT = 202 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件表'; -- ---------------------------- -- Records of infra_file_content @@ -768,7 +769,7 @@ CREATE TABLE `member_experience_record` ( PRIMARY KEY (`id`) USING BTREE, INDEX `idx_user_id`(`user_id` ASC) USING BTREE COMMENT '会员经验记录-用户编号', INDEX `idx_user_biz_type`(`user_id` ASC, `biz_type` ASC) USING BTREE COMMENT '会员经验记录-用户业务类型' -) ENGINE = InnoDB AUTO_INCREMENT = 41 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员经验记录'; +) ENGINE = InnoDB AUTO_INCREMENT = 42 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员经验记录'; -- ---------------------------- -- Records of member_experience_record @@ -884,7 +885,7 @@ CREATE TABLE `member_level_record` ( `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE, INDEX `idx_user_id`(`user_id` ASC) USING BTREE COMMENT '会员等级记录-用户编号' -) ENGINE = InnoDB AUTO_INCREMENT = 20 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员等级记录'; +) ENGINE = InnoDB AUTO_INCREMENT = 21 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员等级记录'; -- ---------------------------- -- Records of member_level_record @@ -914,7 +915,7 @@ CREATE TABLE `member_point_record` ( PRIMARY KEY (`id`) USING BTREE, INDEX `index_userId`(`user_id` ASC) USING BTREE, INDEX `index_title`(`title` ASC) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 60 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户积分记录'; +) ENGINE = InnoDB AUTO_INCREMENT = 61 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户积分记录'; -- ---------------------------- -- Records of member_point_record @@ -1434,6 +1435,39 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1395, 22, '订单积分奖励(整单取消)', '22', 'member_point_biz_type', 0, 'default', '', '', '1', '2023-10-11 07:42:55', '1', '2023-10-11 07:43:01', b'0'); INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1396, 23, '订单积分奖励(单个退款)', '23', 'member_point_biz_type', 0, 'default', '', '', '1', '2023-10-11 07:43:16', '1', '2023-10-11 07:43:16', b'0'); INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1397, 13, '下单奖励(单个退款)', '13', 'member_experience_biz_type', 0, 'warning', '', '', '1', '2023-10-11 07:45:24', '1', '2023-10-11 07:45:38', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1402, 1, 'A 农、林、牧、渔业', '1', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:02:15', '1', '2023-10-28 23:02:15', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1403, 2, 'B 采矿业', '2', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:02:29', '1', '2023-10-28 23:02:29', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1404, 3, 'C 制造业', '3', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:02:41', '1', '2023-10-28 23:02:41', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1405, 4, 'D 电力、热力、燃气及水生产和供应业', '4', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:02:54', '1', '2023-10-28 23:02:54', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1406, 5, 'E 建筑业', '5', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:03', '1', '2023-10-28 23:03:03', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1407, 6, 'F 批发和零售业', '6', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:13', '1', '2023-10-28 23:03:13', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1408, 7, 'G 交通运输、仓储和邮政业', '7', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:27', '1', '2023-10-28 23:03:27', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1409, 8, 'H 住宿和餐饮业', '8', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:37', '1', '2023-10-28 23:03:37', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1410, 9, 'I 信息传输、软件和信息技术服务业', '9', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:47', '1', '2023-10-28 23:03:47', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1411, 10, 'J 金融业', '10', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:03:57', '1', '2023-10-28 23:03:57', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1412, 11, 'K 房地产业', '11', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:04:15', '1', '2023-10-28 23:04:22', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1413, 12, 'L 租赁和商务服务业', '12', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:04:33', '1', '2023-10-28 23:04:33', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1414, 13, 'M 科学研究和技术服务业', '13', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:04:43', '1', '2023-10-28 23:04:43', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1415, 14, 'N 水利、环境和公共设施管理业', '14', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:04:53', '1', '2023-10-28 23:04:53', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1416, 15, 'O 居民服务、修理和其他服务业', '15', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:05:05', '1', '2023-10-28 23:05:05', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1417, 16, 'P 教育', '16', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:05:15', '1', '2023-10-28 23:05:15', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1418, 17, 'Q 卫生和社会工作', '17', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:05:44', '1', '2023-10-28 23:05:44', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1419, 18, 'R 文化、体育和娱乐业', '18', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:05:55', '1', '2023-10-28 23:05:55', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1420, 19, 'S 公共管理、社会保障和社会组织', '19', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:06:05', '1', '2023-10-28 23:06:05', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1421, 20, 'T 国际组织', '20', 'crm_customer_industry', 0, 'default', '', '', '1', '2023-10-28 23:06:15', '1', '2023-10-28 23:06:15', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1422, 1, 'A (重点客户)', '1', 'crm_customer_level', 0, 'primary', '', '', '1', '2023-10-28 23:07:13', '1', '2023-10-28 23:07:13', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1423, 2, 'B (普通客户)', '2', 'crm_customer_level', 0, 'info', '', '', '1', '2023-10-28 23:07:35', '1', '2023-10-28 23:07:35', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1424, 3, 'C (非优先客户)', '3', 'crm_customer_level', 0, 'default', '', '', '1', '2023-10-28 23:07:53', '1', '2023-10-28 23:07:53', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1425, 1, '促销', '1', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:08:29', '1', '2023-10-28 23:08:29', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1426, 2, '搜索引擎', '2', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:08:39', '1', '2023-10-28 23:08:39', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1427, 3, '广告', '3', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:08:47', '1', '2023-10-28 23:08:47', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1428, 4, '转介绍', '4', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:08:58', '1', '2023-10-28 23:08:58', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1429, 5, '线上注册', '5', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:09:12', '1', '2023-10-28 23:09:12', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1430, 6, '线上咨询', '6', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:09:22', '1', '2023-10-28 23:09:22', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1431, 7, '预约上门', '7', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:09:39', '1', '2023-10-28 23:09:39', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1432, 8, '陌拜', '8', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:10:04', '1', '2023-10-28 23:10:04', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1433, 9, '电话咨询', '9', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:10:18', '1', '2023-10-28 23:10:18', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1434, 10, '邮件咨询', '10', 'crm_customer_source', 0, 'default', '', '', '1', '2023-10-28 23:10:33', '1', '2023-10-28 23:10:33', b'0'); COMMIT; -- ---------------------------- @@ -1454,7 +1488,7 @@ CREATE TABLE `system_dict_type` ( `deleted_time` datetime NULL DEFAULT NULL COMMENT '删除时间', PRIMARY KEY (`id`) USING BTREE, UNIQUE INDEX `dict_type`(`type` ASC) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 185 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '字典类型表'; +) ENGINE = InnoDB AUTO_INCREMENT = 601 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '字典类型表'; -- ---------------------------- -- Records of system_dict_type @@ -1528,6 +1562,9 @@ INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creat INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (182, '佣金提现银行', 'brokerage_bank_name', 0, NULL, '', '2023-09-28 02:46:05', '', '2023-09-28 02:46:05', b'0', NULL); INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (183, '砍价记录的状态', 'promotion_bargain_record_status', 0, '', '1', '2023-10-05 10:41:08', '1', '2023-10-05 10:41:08', b'0', '1970-01-01 00:00:00'); INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (184, '拼团记录的状态', 'promotion_combination_record_status', 0, '', '1', '2023-10-08 07:24:25', '1', '2023-10-08 07:24:25', b'0', '1970-01-01 00:00:00'); +INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (186, '客户所属行业', 'crm_customer_industry', 0, 'CRM 客户所属行业', '1', '2023-10-28 22:57:07', '1', '2023-10-28 15:11:16', b'0', NULL); +INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (187, '客户等级', 'crm_customer_level', 0, 'CRM 客户等级', '1', '2023-10-28 22:59:12', '1', '2023-10-28 15:11:16', b'0', NULL); +INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (188, '客户来源', 'crm_customer_source', 0, 'CRM 客户来源', '1', '2023-10-28 23:00:34', '1', '2023-10-28 15:11:16', b'0', NULL); INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (600, 'Banner Position', 'promotion_banner_position', 0, '', '1', '2023-10-08 07:24:25', '1', '2023-10-08 07:24:25', b'0', '1970-01-01 00:00:00'); COMMIT; @@ -1577,7 +1614,7 @@ CREATE TABLE `system_login_log` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 2620 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统访问记录'; +) ENGINE = InnoDB AUTO_INCREMENT = 2626 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统访问记录'; -- ---------------------------- -- Records of system_login_log @@ -2203,6 +2240,49 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2388, '商城首页', '', 2, 1, 2362, 'home', 'ep:home-filled', 'mall/home/index', 'MallHome', 0, b'1', b'1', b'1', '', '2023-10-16 12:10:33', '', '2023-10-16 12:10:33', b'0'); INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2389, '核销订单', '', 2, 2, 2166, 'pick-up-order', 'ep:list', 'mall/trade/delivery/pickUpOrder/index', 'PickUpOrder', 0, b'1', b'1', b'1', '', '2023-10-19 16:09:51', '', '2023-10-19 16:09:51', b'0'); INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2390, '优惠活动', '', 1, 99, 2030, 'youhui', 'ep:aim', '', '', 0, b'1', b'1', b'1', '1', '2023-10-21 19:23:49', '1', '2023-10-21 19:23:49', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2391, '客户管理', '', 2, 0, 2397, 'customer', 'fa:address-book-o', 'crm/customer/index', 'CrmCustomer', 0, b'1', b'1', b'1', '', '2023-10-29 09:04:21', '1', '2023-10-29 17:11:03', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2392, '客户查询', 'crm:customer:query', 3, 1, 2391, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 09:04:21', '', '2023-10-29 09:04:21', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2393, '客户创建', 'crm:customer:create', 3, 2, 2391, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 09:04:21', '', '2023-10-29 09:04:21', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2394, '客户更新', 'crm:customer:update', 3, 3, 2391, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 09:04:21', '', '2023-10-29 09:04:21', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2395, '客户删除', 'crm:customer:delete', 3, 4, 2391, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 09:04:21', '', '2023-10-29 09:04:21', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2396, '客户导出', 'crm:customer:export', 3, 5, 2391, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 09:04:21', '', '2023-10-29 09:04:21', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2397, '客户管理系统', '', 1, 200, 0, '/crm', 'ep:avatar', '', '', 0, b'1', b'1', b'1', '1', '2023-10-29 17:08:30', '1', '2023-10-29 17:08:30', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2398, '合同管理', '', 2, 1, 2397, 'contract', 'ep:notebook', 'crm/contract/index', 'CrmContract', 0, b'1', b'1', b'1', '', '2023-10-29 10:50:41', '1', '2023-10-29 18:55:53', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2399, '合同查询', 'crm:contract:query', 3, 1, 2398, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 10:50:41', '', '2023-10-29 10:50:41', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2400, '合同创建', 'crm:contract:create', 3, 2, 2398, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 10:50:41', '', '2023-10-29 10:50:41', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2401, '合同更新', 'crm:contract:update', 3, 3, 2398, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 10:50:41', '', '2023-10-29 10:50:41', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2402, '合同删除', 'crm:contract:delete', 3, 4, 2398, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 10:50:41', '', '2023-10-29 10:50:41', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2403, '合同导出', 'crm:contract:export', 3, 5, 2398, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 10:50:41', '', '2023-10-29 10:50:41', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2404, '线索管理', '', 2, 0, 2397, 'clue', 'fa:pagelines', 'crm/clue/index', 'CrmClue', 0, b'1', b'1', b'1', '', '2023-10-29 11:06:29', '1', '2023-10-29 19:08:35', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2405, '线索查询', 'crm:clue:query', 3, 1, 2404, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:06:29', '', '2023-10-29 11:06:29', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2406, '线索创建', 'crm:clue:create', 3, 2, 2404, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:06:29', '', '2023-10-29 11:06:29', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2407, '线索更新', 'crm:clue:update', 3, 3, 2404, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:06:29', '', '2023-10-29 11:06:29', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2408, '线索删除', 'crm:clue:delete', 3, 4, 2404, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:06:29', '', '2023-10-29 11:06:29', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2409, '线索导出', 'crm:clue:export', 3, 5, 2404, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:06:29', '', '2023-10-29 11:06:29', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2410, '商机管理', '', 2, 0, 2397, 'business', 'fa:bus', 'crm/business/index', 'CrmBusiness', 0, b'1', b'1', b'1', '', '2023-10-29 11:12:35', '1', '2023-10-29 19:13:01', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2411, '商机查询', 'crm:business:query', 3, 1, 2410, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:12:35', '', '2023-10-29 11:12:35', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2412, '商机创建', 'crm:business:create', 3, 2, 2410, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:12:35', '', '2023-10-29 11:12:35', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2413, '商机更新', 'crm:business:update', 3, 3, 2410, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:12:35', '', '2023-10-29 11:12:35', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2414, '商机删除', 'crm:business:delete', 3, 4, 2410, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:12:35', '', '2023-10-29 11:12:35', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2415, '商机导出', 'crm:business:export', 3, 5, 2410, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:12:35', '', '2023-10-29 11:12:35', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2416, '联系人管理', '', 2, 0, 2397, 'contact', 'fa:address-book-o', 'crm/contact/index', 'Contact', 0, b'1', b'1', b'1', '', '2023-10-29 11:14:56', '1', '2023-10-29 19:15:32', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2417, '联系人查询', 'crm:contact:query', 3, 1, 2416, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:14:56', '', '2023-10-29 11:14:56', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2418, '联系人创建', 'crm:contact:create', 3, 2, 2416, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:14:56', '', '2023-10-29 11:14:56', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2419, '联系人更新', 'crm:contact:update', 3, 3, 2416, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:14:56', '', '2023-10-29 11:14:56', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2420, '联系人删除', 'crm:contact:delete', 3, 4, 2416, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:14:56', '', '2023-10-29 11:14:56', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2421, '联系人导出', 'crm:contact:export', 3, 5, 2416, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:14:56', '', '2023-10-29 11:14:56', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2422, '回款管理', '', 2, 0, 2397, 'receivable', 'ep:money', 'crm/receivable/index', 'CrmReceivable', 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '1', '2023-10-29 19:18:52', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2423, '回款管理查询', 'crm:receivable:query', 3, 1, 2422, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2424, '回款管理创建', 'crm:receivable:create', 3, 2, 2422, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2425, '回款管理更新', 'crm:receivable:update', 3, 3, 2422, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2426, '回款管理删除', 'crm:receivable:delete', 3, 4, 2422, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2427, '回款管理导出', 'crm:receivable:export', 3, 5, 2422, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2428, '回款计划管理', '', 2, 0, 2397, 'receivable-plan', 'fa:money', 'crm/receivablePlan/index', 'CrmReceivablePlan', 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '1', '2023-10-29 19:19:08', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2429, '回款计划查询', 'crm:receivable-plan:query', 3, 1, 2428, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2430, '回款计划创建', 'crm:receivable-plan:create', 3, 2, 2428, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2431, '回款计划更新', 'crm:receivable-plan:update', 3, 3, 2428, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2432, '回款计划删除', 'crm:receivable-plan:delete', 3, 4, 2428, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2433, '回款计划导出', 'crm:receivable-plan:export', 3, 5, 2428, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); COMMIT; -- ---------------------------- @@ -2320,8 +2400,10 @@ CREATE TABLE `system_oauth2_access_token` ( `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 3130 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 访问令牌'; + PRIMARY KEY (`id`) USING BTREE, + INDEX `idx_access_token`(`access_token` ASC) USING BTREE, + INDEX `idx_refresh_token`(`refresh_token` ASC) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 3137 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 访问令牌'; -- ---------------------------- -- Records of system_oauth2_access_token @@ -2443,7 +2525,7 @@ CREATE TABLE `system_oauth2_refresh_token` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1089 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 刷新令牌'; +) ENGINE = InnoDB AUTO_INCREMENT = 1094 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 刷新令牌'; -- ---------------------------- -- Records of system_oauth2_refresh_token @@ -2483,7 +2565,7 @@ CREATE TABLE `system_operate_log` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 8757 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '操作日志记录'; +) ENGINE = InnoDB AUTO_INCREMENT = 8766 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '操作日志记录'; -- ---------------------------- -- Records of system_operate_log @@ -3834,7 +3916,7 @@ CREATE TABLE `system_users` ( -- Records of system_users -- ---------------------------- BEGIN; -INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 'admin', '$2a$10$mRMIYLDtRHlf6.9ipiqH1.Z.bh/R9dO9d5iHiGYPigi6r5KOoR2Wm', '芋道源码', '管理员', 103, '[1]', 'aoteman@126.com', '15612345678', 1, 'http://127.0.0.1:48080/admin-api/infra/file/4/get/37e56010ecbee472cdd821ac4b608e151e62a74d9633f15d085aee026eedeb60.png', 0, '0:0:0:0:0:0:0:1', '2023-10-24 20:20:54', 'admin', '2021-01-05 17:03:47', NULL, '2023-10-24 20:20:54', b'0', 1); +INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 'admin', '$2a$10$mRMIYLDtRHlf6.9ipiqH1.Z.bh/R9dO9d5iHiGYPigi6r5KOoR2Wm', '芋道源码', '管理员', 103, '[1]', 'aoteman@126.com', '15612345678', 1, 'http://127.0.0.1:48080/admin-api/infra/file/4/get/37e56010ecbee472cdd821ac4b608e151e62a74d9633f15d085aee026eedeb60.png', 0, '0:0:0:0:0:0:0:1', '2023-10-29 17:06:12', 'admin', '2021-01-05 17:03:47', NULL, '2023-10-29 17:06:12', b'0', 1); INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (100, 'yudao', '$2a$10$11U48RhyJ5pSBYWSn12AD./ld671.ycSzJHbyrtpeoMeYiw31eo8a', '芋道', '不要吓我', 104, '[1]', 'yudao@iocoder.cn', '15601691300', 1, '', 1, '127.0.0.1', '2022-07-09 23:03:33', '', '2021-01-07 09:07:17', NULL, '2022-07-09 23:03:33', b'0', 1); INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (103, 'yuanma', '$2a$10$YMpimV4T6BtDhIaA8jSW.u8UTGBeGhc/qwXP4oxoMr4mOw9.qttt6', '源码', NULL, 106, NULL, 'yuanma@iocoder.cn', '15601701300', 0, '', 0, '127.0.0.1', '2022-07-08 01:26:27', '', '2021-01-13 23:50:35', NULL, '2022-07-08 01:26:27', b'0', 1); INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (104, 'test', '$2a$10$GP8zvqHB//TekuzYZSBYAuBQJiNq1.fxQVDYJ.uBCOnWCtDVKE4H6', '测试号', NULL, 107, '[1,2]', '111@qq.com', '15601691200', 1, '', 0, '0:0:0:0:0:0:0:1', '2023-09-24 18:21:19', '', '2021-01-21 02:13:53', NULL, '2023-09-24 18:21:19', b'0', 1); From bec8a27a21780c86c5b6d2c357a5522c61e42090 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 30 Oct 2023 00:49:36 +0800 Subject: [PATCH 040/101] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20CRM-=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9D=83=E9=99=90=20=E6=B3=A8=E8=A7=A3=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/ErrorCodeConstants.java | 5 +- .../admin/business/CrmBusinessController.http | 11 ++ .../admin/business/CrmBusinessController.java | 6 +- .../business/vo/CrmBusinessTransferReqVO.java | 20 --- .../business/vo/CrmTransferBusinessReqVO.java | 11 ++ .../convert/business/CrmBusinessConvert.java | 8 +- .../crm/convert/contract/ContractConvert.java | 2 +- .../dataobject/business/CrmBusinessDO.java | 21 +-- .../crm/dal/dataobject/contact/ContactDO.java | 24 +-- .../dal/dataobject/contract/ContractDO.java | 21 +-- .../dataobject/customer/CrmCustomerDO.java | 21 +-- .../core/annotations/CrmPermission.java | 34 ++++ .../core/aop/CrmPermissionAspect.java | 165 ++++++++++++++++++ .../crm/framework/core/package-info.java | 1 + .../dataobject/CrmPermissionBaseDO.java | 37 ++++ .../module/crm/framework/enums/CrmEnum.java | 34 ++++ .../framework/enums/OperationTypeEnum.java | 39 +++++ ...{AuthUtil.java => CrmPermissionUtils.java} | 21 ++- .../crm/framework/vo/CrmTransferBaseVO.java | 32 ++++ .../service/business/CrmBusinessService.java | 2 +- .../business/CrmBusinessServiceImpl.java | 23 +-- .../service/contact/ContactServiceImpl.java | 2 +- .../service/contract/ContractServiceImpl.java | 6 +- .../business/CrmBusinessServiceImplTest.java | 56 +++--- .../CrmBusinessStatusServiceImplTest.java | 26 ++- .../CrmBusinessStatusTypeServiceImplTest.java | 12 +- .../customer/CrmCustomerServiceImplTest.java | 8 +- 27 files changed, 469 insertions(+), 179 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.http delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessTransferReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmTransferBusinessReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/annotations/CrmPermission.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/dataobject/CrmPermissionBaseDO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/CrmEnum.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/OperationTypeEnum.java rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/{AuthUtil.java => CrmPermissionUtils.java} (60%) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/vo/CrmTransferBaseVO.java diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 69405a5b9..b4f909a8b 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -19,8 +19,9 @@ public interface ErrorCodeConstants { // ========== 商机管理 1-020-002-000 ========== ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); - ErrorCode BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_002_001, "商机转移失败,原因:没有转移权限"); // TODO @puhui999:这个搞成 “商机操作失败,原因:没有权限” - ErrorCode BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_002_002, "商机转移失败,原因:负责人不存在"); + ErrorCode BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_002_001, "商机操作失败,原因:没有权限"); + ErrorCode BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_002_002, "商机操作失败,原因:负责人不存在"); + ErrorCode BUSINESS_TRANSFER_FAIL_OWNER_USER_EXISTS = new ErrorCode(1_020_002_003, "商机操作失败,原因:转移对象已经是该负责人"); // TODO @lilleo:商机状态、商机类型,都单独错误码段 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.http b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.http new file mode 100644 index 000000000..631824e31 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.http @@ -0,0 +1,11 @@ +PUT {{baseUrl}}/crm/business/transfer +Content-Type: application/json +Authorization: Bearer {{token}} +tenant-id: {{adminTenentId}} + +{ + "id": 1, + "ownerUserId": 2, + "transferType": 2, + "permissionType": 2 +} \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java index 8096176c9..2082e80d3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.crm.controller.admin.business; +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; @@ -7,6 +8,7 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; +import cn.iocoder.yudao.module.crm.framework.utils.CrmPermissionUtils; import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -63,6 +65,7 @@ public class CrmBusinessController { @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('crm:business:query')") public CommonResult getBusiness(@RequestParam("id") Long id) { + CrmPermissionUtils.setCrmTransferInfo(getLoginUserId(), UserTypeEnum.ADMIN.getValue()); CrmBusinessDO business = businessService.getBusiness(id); return success(CrmBusinessConvert.INSTANCE.convert(business)); } @@ -91,7 +94,8 @@ public class CrmBusinessController { @PutMapping("/transfer") @Operation(summary = "商机转移") @PreAuthorize("@ss.hasPermission('crm:business:update')") - public CommonResult transfer(@Valid @RequestBody CrmBusinessTransferReqVO reqVO) { + public CommonResult transfer(@Valid @RequestBody CrmTransferBusinessReqVO reqVO) { + CrmPermissionUtils.setCrmTransferInfo(getLoginUserId(), UserTypeEnum.ADMIN.getValue(), reqVO); businessService.businessTransfer(reqVO, getLoginUserId()); return success(true); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessTransferReqVO.java deleted file mode 100644 index fd769e77c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmBusinessTransferReqVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.business.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -@Schema(description = "管理后台 - 商机转移 Request VO") -@Data -public class CrmBusinessTransferReqVO { - - @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "联系人编号不能为空") - private Long id; - - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long ownerUserId; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmTransferBusinessReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmTransferBusinessReqVO.java new file mode 100644 index 000000000..0ba2142db --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmTransferBusinessReqVO.java @@ -0,0 +1,11 @@ +package cn.iocoder.yudao.module.crm.controller.admin.business.vo; + +import cn.iocoder.yudao.module.crm.framework.vo.CrmTransferBaseVO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Schema(description = "管理后台 - 商机转移 Request VO") +@Data +public class CrmTransferBusinessReqVO extends CrmTransferBaseVO { + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java index a025d3ed4..16ef0433b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.crm.convert.business; -import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; @@ -30,11 +29,10 @@ public interface CrmBusinessConvert { List convertList02(List list); - default CrmBusinessDO convert(CrmBusinessDO business, CrmBusinessTransferReqVO reqVO, Long userId) { + default CrmBusinessDO convert(CrmBusinessDO business, CrmTransferBusinessReqVO reqVO, Long userId) { Set rwUserIds = business.getRwUserIds(); - rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 TODO puhui999:是不是直接 rwUserIds.remove(userId) - // TODO @puhui999:ownerUserId 不用添加到进去,它就是 ownerUserId 就够;因为一共有 3 个角色:负责人、读写、只读; - rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 + rwUserIds.remove(userId); + rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负责人 // TODO @puhui999:对原负责人,加个类似的处理:移除、转化为团队成员(只读、读写) return new CrmBusinessDO().setId(business.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 .setRwUserIds(rwUserIds); 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 7d0dc84fa..55df1d87b 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 @@ -37,7 +37,7 @@ public interface ContractConvert { Set rwUserIds = contract.getRwUserIds(); rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 - return new ContractDO().setId(contract.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 + return (ContractDO) new ContractDO().setId(contract.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 .setRwUserIds(rwUserIds); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java index 23d7ddb9a..a9e599b7c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java @@ -1,17 +1,14 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.business; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO; +import cn.iocoder.yudao.module.crm.framework.dataobject.CrmPermissionBaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; import java.time.LocalDateTime; -import java.util.Set; /** * 商机 DO @@ -26,7 +23,7 @@ import java.util.Set; @Builder @NoArgsConstructor @AllArgsConstructor -public class CrmBusinessDO extends BaseDO { +public class CrmBusinessDO extends CrmPermissionBaseDO { /** * 主键 @@ -82,20 +79,6 @@ public class CrmBusinessDO extends BaseDO { * 备注 */ private String remark; - /** - * 负责人的用户编号 - */ - private Long ownerUserId; - /** - * 只读权限的用户编号数组 - */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) - private Set roUserIds; - /** - * 读写权限的用户编号数组 - */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) - private Set rwUserIds; /** * 1赢单2输单3无效 * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java index 6c56ebe98..4e5dab7cf 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java @@ -1,15 +1,12 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.contact; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; +import cn.iocoder.yudao.module.crm.framework.dataobject.CrmPermissionBaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; import java.time.LocalDateTime; -import java.util.Set; /** * crm 联系人 DO @@ -24,7 +21,7 @@ import java.util.Set; @Builder @NoArgsConstructor @AllArgsConstructor -public class ContactDO extends BaseDO { +public class ContactDO extends CrmPermissionBaseDO { /** * 主键 @@ -69,26 +66,9 @@ public class ContactDO extends BaseDO { * 备注 */ private String remark; - /** - * 负责人用户编号 - * - * TODO @zyna:关联的字段,也要写下 - */ - private Long ownerUserId; /** * 最后跟进时间 */ private LocalDateTime lastTime; - /** - * 只读权限的用户编号数组 - */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) - private Set roUserIds; - /** - * 读写权限的用户编号数组 - */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) - private Set rwUserIds; - } 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/ContractDO.java index 2c5d0e44f..0ddce4c8b 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/ContractDO.java @@ -1,15 +1,12 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.contract; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; +import cn.iocoder.yudao.module.crm.framework.dataobject.CrmPermissionBaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; import java.time.LocalDateTime; -import java.util.Set; /** * 合同 DO @@ -24,7 +21,7 @@ import java.util.Set; @Builder @NoArgsConstructor @AllArgsConstructor -public class ContractDO extends BaseDO { +public class ContractDO extends CrmPermissionBaseDO { /** * 合同编号 @@ -51,10 +48,6 @@ public class ContractDO extends BaseDO { * 下单日期 */ private LocalDateTime orderDate; - /** - * 负责人的用户编号 - */ - private Long ownerUserId; /** * 合同编号 */ @@ -79,16 +72,6 @@ public class ContractDO extends BaseDO { * 产品总金额 */ private Integer productPrice; - /** - * 只读权限的用户编号数组 - */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) - private Set roUserIds; - /** - * 读写权限的用户编号数组 - */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) - private Set rwUserIds; /** * 联系人编号 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java index 6e5026c94..e66c42172 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java @@ -1,15 +1,12 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.customer; -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; +import cn.iocoder.yudao.module.crm.framework.dataobject.CrmPermissionBaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; -import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; import java.time.LocalDateTime; -import java.util.List; // TODO 芋艿:调整下字段 @@ -26,7 +23,7 @@ import java.util.List; @Builder @NoArgsConstructor @AllArgsConstructor -public class CrmCustomerDO extends BaseDO { +public class CrmCustomerDO extends CrmPermissionBaseDO { /** * 编号 @@ -99,20 +96,6 @@ public class CrmCustomerDO extends BaseDO { * 备注 */ private String remark; - /** - * 负责人的用户编号 - */ - private Long ownerUserId; - /** - * 只读权限的用户编号数组 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List roUserIds; - /** - * 读写权限的用户编号数组 - */ - @TableField(typeHandler = LongListTypeHandler.class) - private List rwUserIds; /** * 地区编号 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/annotations/CrmPermission.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/annotations/CrmPermission.java new file mode 100644 index 000000000..9d1733b30 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/annotations/CrmPermission.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.framework.core.annotations; + +import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; +import cn.iocoder.yudao.module.crm.framework.enums.OperationTypeEnum; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.METHOD; + +/** + * Crm 数据操作权限校验 AOP 注解 + * + * @author HUIHUI + */ +@Target({METHOD, ANNOTATION_TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface CrmPermission { + + /** + * crm 类型 + */ + CrmEnum crmType(); + + /** + * 操作类型 + */ + OperationTypeEnum operationType(); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java new file mode 100644 index 000000000..b0692185b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java @@ -0,0 +1,165 @@ +package cn.iocoder.yudao.module.crm.framework.core.aop; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjUtil; +import cn.iocoder.yudao.framework.common.core.KeyValue; +import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; +import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; +import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; +import cn.iocoder.yudao.module.crm.framework.enums.OperationTypeEnum; +import cn.iocoder.yudao.module.crm.framework.vo.CrmTransferBaseVO; +import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; +import cn.iocoder.yudao.module.crm.service.contact.ContactService; +import cn.iocoder.yudao.module.crm.service.contract.ContractService; +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.Collection; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; + +/** + * Crm 数据权限校验 AOP 切面 + * + * @author HUIHUI + */ +@Component +@Aspect +@Slf4j +public class CrmPermissionAspect { + + /** + * 用户编号 + */ + private static final ThreadLocal USER_ID = new ThreadLocal<>(); + /** + * 用户类型 + */ + private static final ThreadLocal USER_TYPE = new ThreadLocal<>(); + /** + * 操作数据编号 + */ + private static final ThreadLocal DATA_ID = new ThreadLocal<>(); + /** + * Crm 转换数据 VO 数据 + */ + private static final ThreadLocal CRM_TRANSFER_VO = new ThreadLocal<>(); + + @Resource + private CrmBusinessService crmBusinessService; + @Resource + private ContactService contactService; + @Resource + private ContractService contractService; + @Resource + private CrmCustomerService crmCustomerService; + + public static void setCrmTransferInfo(Long userId, Integer userType, Object crmTransferBaseVO) { + USER_ID.set(userId); + USER_TYPE.set(userType); + CRM_TRANSFER_VO.set((CrmTransferBaseVO) crmTransferBaseVO); + } + + public static void setCrmTransferInfo(Long userId, Integer userType) { + USER_ID.set(userId); + USER_TYPE.set(userType); + } + + private static void clear() { + USER_ID.remove(); + USER_TYPE.remove(); + DATA_ID.remove(); + CRM_TRANSFER_VO.remove(); + } + + @Before("@annotation(crmPermission)") + public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) { + try { + Integer crmType = crmPermission.crmType().getType(); + Integer operationType = crmPermission.operationType().getType(); + Long id = DATA_ID.get();// 获取操作数据的编号 + KeyValue, Collection> keyValue = new KeyValue<>(); // 数据权限 key 只读,value 读写 + // 客户 + if (ObjUtil.equal(crmType, CrmEnum.CRM_CUSTOMER.getType())) { + CrmCustomerDO customer = crmCustomerService.getCustomer(id); + if (customer == null) { + throw exception(CUSTOMER_NOT_EXISTS); + } + // 如果是自己则直接过 + if (ObjUtil.equal(customer.getOwnerUserId(), USER_ID.get())) { + return; + } + new KeyValue<>(customer.getRoUserIds(), customer.getRwUserIds()); + } + // 联系人 + if (ObjUtil.equal(crmType, CrmEnum.CRM_CONTACTS.getType())) { + ContactDO contact = contactService.getContact(id); + if (contact == null) { + throw exception(CONTACT_NOT_EXISTS); + } + // 如果是自己则直接过 + if (ObjUtil.equal(contact.getOwnerUserId(), USER_ID.get())) { + return; + } + new KeyValue<>(contact.getRoUserIds(), contact.getRwUserIds()); + } + // 商机 + if (ObjUtil.equal(crmType, CrmEnum.CRM_BUSINESS.getType())) { + CrmBusinessDO business = crmBusinessService.getBusiness(id); + if (business == null) { + throw exception(BUSINESS_NOT_EXISTS); + } + // 如果是自己则直接过 + if (ObjUtil.equal(business.getOwnerUserId(), USER_ID.get())) { + return; + } + new KeyValue<>(business.getRoUserIds(), business.getRwUserIds()); + } + // 合同 + if (ObjUtil.equal(crmType, CrmEnum.CRM_CONTRACT.getType())) { + ContractDO contract = contractService.getContract(id); + if (contract == null) { + throw exception(CONTRACT_NOT_EXISTS); + } + // 如果是自己则直接过 + if (ObjUtil.equal(contract.getOwnerUserId(), USER_ID.get())) { + return; + } + new KeyValue<>(contract.getRoUserIds(), contract.getRwUserIds()); + } + // 1. 校验是否有读权限 + if (OperationTypeEnum.isRead(operationType)) { + // 校验该数据当前用户是否可读 + boolean isRead = CollUtil.contains(keyValue.getKey(), item -> ObjUtil.equal(id, USER_ID.get())) + || CollUtil.contains(keyValue.getValue(), item -> ObjUtil.equal(id, USER_ID.get())); + if (isRead) { + return; + } + throw exception(CONTRACT_NOT_EXISTS); + } + // 2. 校验是否有编辑权限 + if (OperationTypeEnum.isEdit(operationType)) { + // 校验该数据当前用户是否可读写 + if (CollUtil.contains(keyValue.getValue(), item -> ObjUtil.equal(id, USER_ID.get()))) { + return; + } + throw exception(CONTRACT_NOT_EXISTS); + } + } catch (Exception ex) { + log.error("[doBefore][crmPermission({}) 数据校验错误]", toJsonString(crmPermission), ex); + } finally { + clear(); + } + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/package-info.java new file mode 100644 index 000000000..4a3e65722 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.yudao.module.crm.framework.core; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/dataobject/CrmPermissionBaseDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/dataobject/CrmPermissionBaseDO.java new file mode 100644 index 000000000..e7262165b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/dataobject/CrmPermissionBaseDO.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.crm.framework.dataobject; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; +import com.baomidou.mybatisplus.annotation.TableField; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.Set; + +/** + * crm 数据权限基础实体对象 + * + * @author HUIHUI + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmPermissionBaseDO extends BaseDO { + + /** + * 负责人的用户编号 关联 AdminUser#id + */ + private Long ownerUserId; + /** + * 只读权限的用户编号数组 + */ + @TableField(typeHandler = JsonLongSetTypeHandler.class) + private Set roUserIds; + /** + * 读写权限的用户编号数组 + */ + @TableField(typeHandler = JsonLongSetTypeHandler.class) + private Set rwUserIds; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/CrmEnum.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/CrmEnum.java new file mode 100644 index 000000000..1fbaea575 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/CrmEnum.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.framework.enums; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +/** + * Crm 类型枚举 + * + * @author HUIHUI + */ +@RequiredArgsConstructor +@Getter +public enum CrmEnum { + + CRM_LEADS(1, "线索"), + CRM_CUSTOMER(2, "客户"), + CRM_CONTACTS(3, "联系人"), + CRM_PRODUCT(4, "产品"), + CRM_BUSINESS(5, "商机"), + CRM_CONTRACT(6, "合同"), + CRM_RECEIVABLES(7, "回款"), + CRM_RECEIVABLES_PLAN(8, "回款计划"), + CRM_CUSTOMER_POOL(9, "客户公海"); + + /** + * 类型 + */ + private final Integer type; + /** + * 名称 + */ + private final String name; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/OperationTypeEnum.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/OperationTypeEnum.java new file mode 100644 index 000000000..beee6c93a --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/OperationTypeEnum.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.crm.framework.enums; + +import cn.hutool.core.util.ObjUtil; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +/** + * Crm 数据操作类型枚举 + * + * @author HUIHUI + */ +@RequiredArgsConstructor +@Getter +public enum OperationTypeEnum { + + DELETE(1, "删除"), + UPDATE(2, "修改"), + READ(3, "查询"), + TRANSFER(4, "转移"); + + /** + * 类型 + */ + private final Integer type; + + /** + * 名称 + */ + private final String name; + + public static boolean isRead(Integer type) { + return ObjUtil.equal(type, READ.getType()); + } + + public static boolean isEdit(Integer type) { + return ObjUtil.equal(type, UPDATE.getType()) || ObjUtil.equal(type, DELETE.getType()) || ObjUtil.equal(type, TRANSFER.getType()); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/AuthUtil.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/CrmPermissionUtils.java similarity index 60% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/AuthUtil.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/CrmPermissionUtils.java index fb66d6f0d..226c0e57b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/AuthUtil.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/CrmPermissionUtils.java @@ -1,17 +1,21 @@ package cn.iocoder.yudao.module.crm.framework.utils; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjUtil; +import cn.iocoder.yudao.module.crm.framework.core.aop.CrmPermissionAspect; + import java.util.Collection; -// TODO @puhui999:改成 CrmPermissionUtils; /** * 数据读写权限校验工具类 * * @author HUIHUI */ -public class AuthUtil { +public class CrmPermissionUtils { // TODO @puhui999:负责人是单独的字段哈; // TODO @puhui999:额外校验,如果是管理员,可以查看所有;看着要做成有状态的了,可能要搞个 CrmPermissionService 咧; + /** * 判断当前数据对用户来说是否是只读的 * @@ -20,8 +24,7 @@ public class AuthUtil { * @return boolean 是/否 */ public static boolean isReadOnly(Collection roUserIds, Long userId) { - // TODO @puhui999:从代码角度来说,最好使用 CollUtil.contains - return roUserIds.contains(userId); + return CollUtil.contains(roUserIds, id -> ObjUtil.equal(id, userId)); } /** @@ -32,7 +35,15 @@ public class AuthUtil { * @return boolean 是/否 */ public static boolean isReadAndWrite(Collection rwUserIds, Long userId) { - return rwUserIds.contains(userId); + return CollUtil.contains(rwUserIds, id -> ObjUtil.equal(id, userId)); + } + + public static void setCrmTransferInfo(Long userId, Integer userType, Object crmTransferBaseVO) { + CrmPermissionAspect.setCrmTransferInfo(userId, userType, crmTransferBaseVO); + } + + public static void setCrmTransferInfo(Long userId, Integer userType) { + CrmPermissionAspect.setCrmTransferInfo(userId, userType); } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/vo/CrmTransferBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/vo/CrmTransferBaseVO.java new file mode 100644 index 000000000..97cc6d167 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/vo/CrmTransferBaseVO.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.crm.framework.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * Crm 数据转移 Base VO,提供给转移的子 VO 使用 + * + * @author HUIHUI + */ +@Data +public class CrmTransferBaseVO { + + @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "联系人编号不能为空") + private Long id; + + @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "新负责人的用户编号不能为空") + private Long ownerUserId; + + @Schema(description = "原负责人移除方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "原负责人移除方式不能为空") + private Integer transferType; + + @Schema(description = "权限类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "权限类型不能为空") + private Integer permissionType; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java index 8a157440b..12689d49c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java @@ -75,6 +75,6 @@ public interface CrmBusinessService { * @param reqVO 请求 * @param userId 用户编号 */ - void businessTransfer(CrmBusinessTransferReqVO reqVO, Long userId); + void businessTransfer(CrmTransferBusinessReqVO reqVO, Long userId); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java index fc01ec555..c1adf4c9c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java @@ -2,11 +2,15 @@ package cn.iocoder.yudao.module.crm.service.business; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; +import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; +import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; +import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; +import cn.iocoder.yudao.module.crm.framework.enums.OperationTypeEnum; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import org.springframework.stereotype.Service; @@ -18,7 +22,6 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.framework.utils.AuthUtil.isReadAndWrite; /** * 商机 Service 实现类 @@ -70,6 +73,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { } @Override + @CrmPermission(crmType = CrmEnum.CRM_BUSINESS, operationType = OperationTypeEnum.READ) public CrmBusinessDO getBusiness(Long id) { return businessMapper.selectById(id); } @@ -92,17 +96,16 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { return businessMapper.selectList(exportReqVO); } - // TODO @puhui999:动名词哈。transferBusiness @Override - public void businessTransfer(CrmBusinessTransferReqVO reqVO, Long userId) { + @CrmPermission(crmType = CrmEnum.CRM_BUSINESS, operationType = OperationTypeEnum.TRANSFER) + public void businessTransfer(CrmTransferBusinessReqVO reqVO, Long userId) { // 1.1 校验商机是否存在 - CrmBusinessDO business = validateBusinessExists(reqVO.getId()); - // 1.2 校验用户是否拥有读写权限 - if (!isReadAndWrite(business.getRwUserIds(), userId)) { - throw exception(BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED); + CrmBusinessDO business = getBusiness(reqVO.getId()); + // 1.3 校验转移对象是否已经是该负责人 + if (ObjUtil.equal(business.getOwnerUserId(), reqVO.getOwnerUserId())) { + throw exception(BUSINESS_TRANSFER_FAIL_OWNER_USER_EXISTS); } - // TODO @puhui999:如果已经是该负责人,抛个业务异常; - // 1.3 校验新负责人是否存在 + // 1.4 校验新负责人是否存在 AdminUserRespDTO user = adminUserApi.getUser(reqVO.getOwnerUserId()); if (user == null) { throw exception(BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS); @@ -112,7 +115,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { CrmBusinessDO updateBusiness = CrmBusinessConvert.INSTANCE.convert(business, reqVO, userId); businessMapper.updateById(updateBusiness); - // 4. TODO 记录商机转移日志 + // 3. TODO 记录商机转移日志 } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java index cca752efa..f8fe72c12 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java @@ -18,7 +18,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.framework.utils.AuthUtil.isReadAndWrite; +import static cn.iocoder.yudao.module.crm.framework.utils.CrmPermissionUtils.isReadAndWrite; /** * crm联系人 Service 实现类 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/ContractServiceImpl.java index 05e1dadd7..8bf6a356e 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/ContractServiceImpl.java @@ -7,6 +7,9 @@ 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.dal.mysql.contract.ContractMapper; +import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; +import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; +import cn.iocoder.yudao.module.crm.framework.enums.OperationTypeEnum; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import org.springframework.stereotype.Service; @@ -18,7 +21,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.framework.utils.AuthUtil.isReadAndWrite; +import static cn.iocoder.yudao.module.crm.framework.utils.CrmPermissionUtils.isReadAndWrite; /** * 合同 Service 实现类 @@ -94,6 +97,7 @@ public class ContractServiceImpl implements ContractService { // TODO @puhui999:参考 CrmBusinessServiceImpl 修改建议 @Override + @CrmPermission(crmType = CrmEnum.CRM_CONTRACT, operationType = OperationTypeEnum.TRANSFER) public void contractTransfer(CrmContractTransferReqVO reqVO, Long userId) { // 1. 校验合同是否存在 ContractDO contract = validateContractExists(reqVO.getId()); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java index 64d3f1e71..40fb404d3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java @@ -1,10 +1,8 @@ package cn.iocoder.yudao.module.crm.service.business; -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.business.vo.CrmBusinessCreateReqVO; import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessPageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.business.vo.CrmBusinessUpdateReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; @@ -162,33 +160,33 @@ public class CrmBusinessServiceImplTest extends BaseDbUnitTest { businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactLastTime(null))); // 测试 followUpStatus 不匹配 businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setFollowUpStatus(null))); - // 准备参数 - CrmBusinessPageReqVO reqVO = new CrmBusinessPageReqVO(); - reqVO.setName(null); - reqVO.setStatusTypeId(null); - reqVO.setStatusId(null); - reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setCustomerId(null); - reqVO.setDealTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setPrice(null); - reqVO.setDiscountPercent(null); - reqVO.setProductPrice(null); - reqVO.setRemark(null); - reqVO.setOwnerUserId(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setRoUserIds(null); - reqVO.setRwUserIds(null); - reqVO.setEndStatus(null); - reqVO.setEndRemark(null); - reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setFollowUpStatus(null); - - // 调用 - PageResult pageResult = businessService.getBusinessPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbBusiness, pageResult.getList().get(0)); + //// 准备参数 + //CrmBusinessPageReqVO reqVO = new CrmBusinessPageReqVO(); + //reqVO.setName(null); + //reqVO.setStatusTypeId(null); + //reqVO.setStatusId(null); + //reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + //reqVO.setCustomerId(null); + //reqVO.setDealTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + //reqVO.setPrice(null); + //reqVO.setDiscountPercent(null); + //reqVO.setProductPrice(null); + //reqVO.setRemark(null); + //reqVO.setOwnerUserId(null); + //reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + //reqVO.setRoUserIds(null); + //reqVO.setRwUserIds(null); + //reqVO.setEndStatus(null); + //reqVO.setEndRemark(null); + //reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + //reqVO.setFollowUpStatus(null); + // + //// 调用 + //PageResult pageResult = businessService.getBusinessPage(reqVO); + //// 断言 + //assertEquals(1, pageResult.getTotal()); + //assertEquals(1, pageResult.getList().size()); + //assertPojoEquals(dbBusiness, pageResult.getList().get(0)); } @Test diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImplTest.java index 44030db3b..9a59f3bd2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatus/CrmBusinessStatusServiceImplTest.java @@ -1,10 +1,8 @@ package cn.iocoder.yudao.module.crm.service.businessstatus; -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.businessstatus.vo.CrmBusinessStatusCreateReqVO; import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusPageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.businessstatus.vo.CrmBusinessStatusUpdateReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; import cn.iocoder.yudao.module.crm.dal.mysql.businessstatus.CrmBusinessStatusMapper; @@ -120,18 +118,18 @@ public class CrmBusinessStatusServiceImplTest extends BaseDbUnitTest { // 测试 sort 不匹配 businessStatusMapper.insert(cloneIgnoreId(dbBusinessStatus, o -> o.setSort(null))); // 准备参数 - CrmBusinessStatusPageReqVO reqVO = new CrmBusinessStatusPageReqVO(); - reqVO.setTypeId(null); - reqVO.setName(null); - reqVO.setPercent(null); - reqVO.setSort(null); - - // 调用 - PageResult pageResult = businessStatusService.getBusinessStatusPage(reqVO); - // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbBusinessStatus, pageResult.getList().get(0)); + //CrmBusinessStatusPageReqVO reqVO = new CrmBusinessStatusPageReqVO(); + //reqVO.setTypeId(null); + //reqVO.setName(null); + //reqVO.setPercent(null); + //reqVO.setSort(null); + // + //// 调用 + //PageResult pageResult = businessStatusService.getBusinessStatusPage(reqVO); + //// 断言 + //assertEquals(1, pageResult.getTotal()); + //assertEquals(1, pageResult.getList().size()); + //assertPojoEquals(dbBusinessStatus, pageResult.getList().get(0)); } @Test diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImplTest.java index 58f054b1c..bf778b989 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/businessstatustype/CrmBusinessStatusTypeServiceImplTest.java @@ -109,7 +109,7 @@ public class CrmBusinessStatusTypeServiceImplTest extends BaseDbUnitTest { o.setName(null); o.setDeptIds(null); o.setStatus(null); - o.setCreateTime(null); + //o.setCreateTime(null); }); businessStatusTypeMapper.insert(dbBusinessStatusType); // 测试 name 不匹配 @@ -119,13 +119,13 @@ public class CrmBusinessStatusTypeServiceImplTest extends BaseDbUnitTest { // 测试 status 不匹配 businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setStatus(null))); // 测试 createTime 不匹配 - businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setCreateTime(null))); + //businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setCreateTime(null))); // 准备参数 CrmBusinessStatusTypePageReqVO reqVO = new CrmBusinessStatusTypePageReqVO(); reqVO.setName(null); - reqVO.setDeptIds(null); + //reqVO.setDeptIds(null); reqVO.setStatus(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + //reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); // 调用 PageResult pageResult = businessStatusTypeService.getBusinessStatusTypePage(reqVO); @@ -143,7 +143,7 @@ public class CrmBusinessStatusTypeServiceImplTest extends BaseDbUnitTest { o.setName(null); o.setDeptIds(null); o.setStatus(null); - o.setCreateTime(null); + //o.setCreateTime(null); }); businessStatusTypeMapper.insert(dbBusinessStatusType); // 测试 name 不匹配 @@ -153,7 +153,7 @@ public class CrmBusinessStatusTypeServiceImplTest extends BaseDbUnitTest { // 测试 status 不匹配 businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setStatus(null))); // 测试 createTime 不匹配 - businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setCreateTime(null))); + //businessStatusTypeMapper.insert(cloneIgnoreId(dbBusinessStatusType, o -> o.setCreateTime(null))); // 准备参数 CrmBusinessStatusTypeExportReqVO reqVO = new CrmBusinessStatusTypeExportReqVO(); reqVO.setName(null); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java index adce8b163..aa188f06a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java @@ -124,8 +124,8 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest { CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO(); reqVO.setName(null); reqVO.setMobile(null); - reqVO.setTelephone(null); - reqVO.setWebsite(null); + //reqVO.setTelephone(null); + //reqVO.setWebsite(null); // 调用 PageResult pageResult = customerService.getCustomerPage(reqVO); @@ -158,8 +158,8 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest { CrmCustomerExportReqVO reqVO = new CrmCustomerExportReqVO(); reqVO.setName(null); reqVO.setMobile(null); - reqVO.setTelephone(null); - reqVO.setWebsite(null); + //reqVO.setTelephone(null); + //reqVO.setWebsite(null); // 调用 List list = customerService.getCustomerList(reqVO); From 19c9b6ae93d42b440c87a505b8e4a82ac9c4edb8 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 30 Oct 2023 11:17:43 +0800 Subject: [PATCH 041/101] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20CRM-=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9D=83=E9=99=90=20service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/ErrorCodeConstants.java | 3 + .../permission/CrmPermissionConvert.java | 23 +++++++ .../permission/CrmPermissionDO.java | 57 ++++++++++++++++ .../mysql/permission/CrmPermissionMapper.java | 14 ++++ .../dal/mysql/permission/package-info.java | 1 + .../permission/CrmPermissionService.java | 47 +++++++++++++ .../permission/CrmPermissionServiceImpl.java | 66 +++++++++++++++++++ .../permission/bo/CrmPermissionCreateBO.java | 40 +++++++++++ .../permission/bo/CrmPermissionUpdateBO.java | 47 +++++++++++++ 9 files changed, 298 insertions(+) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/package-info.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateBO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateBO.java diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index b4f909a8b..bde7a3df5 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -41,4 +41,7 @@ public interface ErrorCodeConstants { // ========== 客户管理 1_020_006_000 ========== ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_020_006_000, "客户不存在"); + // ========== 客户管理 1_020_007_000 ========== + ErrorCode CRM_PERMISSION_NOT_EXISTS = new ErrorCode(1_020_007_000, "数据权限不存在"); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java new file mode 100644 index 000000000..0fc6f61cc --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.module.crm.convert.permission; + +import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; +import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateBO; +import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionUpdateBO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +/** + * Crm 数据权限 Convert + * + * @author Wanwan + */ +@Mapper +public interface CrmPermissionConvert { + + CrmPermissionConvert INSTANCE = Mappers.getMapper(CrmPermissionConvert.class); + + CrmPermissionDO convert(CrmPermissionCreateBO createBO); + + CrmPermissionDO convert(CrmPermissionUpdateBO updateBO); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java new file mode 100644 index 000000000..44a44fa6d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java @@ -0,0 +1,57 @@ +package cn.iocoder.yudao.module.crm.dal.dataobject.permission; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; +import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +import java.util.Set; + +/** + * crm 数据权限 DO + * + * @author HUIHUI + */ +@TableName("crm_receivable") +@KeySequence("crm_receivable_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class CrmPermissionDO extends BaseDO { + + /** + * ID + */ + @TableId + private Long id; + /** + * 数据类型 关联 {@link CrmEnum} + */ + private Integer crmType; + /** + * 数据编号 关联 {@link CrmEnum} 对应模块 DO#id + */ + private Integer crmDataId; + /** + * 负责人的用户编号 关联 AdminUser#id + */ + private Long ownerUserId; + /** + * 只读权限的用户编号数组 + */ + @TableField(typeHandler = JsonLongSetTypeHandler.class) + private Set roUserIds; + /** + * 读写权限的用户编号数组 + */ + @TableField(typeHandler = JsonLongSetTypeHandler.class) + private Set rwUserIds; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java new file mode 100644 index 000000000..44b7b270b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.permission; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * crm 数据权限 mapper + * + * @author HUIHUI + */ +@Mapper +public interface CrmPermissionMapper extends BaseMapperX { +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/package-info.java new file mode 100644 index 000000000..ff0e16b90 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/package-info.java @@ -0,0 +1 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.permission; \ No newline at end of file diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java new file mode 100644 index 000000000..ef064fd87 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java @@ -0,0 +1,47 @@ +package cn.iocoder.yudao.module.crm.service.permission; + + +import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; +import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateBO; +import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionUpdateBO; + +import javax.validation.Valid; + +/** + * crm 数据权限 Service 接口 + * + * @author HUIHUI + */ +public interface CrmPermissionService { + + /** + * 创建数据权限 + * + * @param createBO 创建信息 + * @return 编号 + */ + Long createCrmPermission(@Valid CrmPermissionCreateBO createBO); + + /** + * 更新数据权限 + * + * @param updateBO 更新信息 + */ + void updateCrmPermission(@Valid CrmPermissionUpdateBO updateBO); + + /** + * 删除数据权限 + * + * @param id 编号 + */ + void deleteCrmPermission(Long id); + + /** + * 获得数据权限 + * + * @param id 编号 + * @return 数据权限 + */ + CrmPermissionDO getCrmPermission(Long id); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java new file mode 100644 index 000000000..d0df3eee7 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java @@ -0,0 +1,66 @@ +package cn.iocoder.yudao.module.crm.service.permission; + +import cn.iocoder.yudao.module.crm.convert.permission.CrmPermissionConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; +import cn.iocoder.yudao.module.crm.dal.mysql.permission.CrmPermissionMapper; +import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateBO; +import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionUpdateBO; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_PERMISSION_NOT_EXISTS; + +/** + * crm 数据权限 Service 接口实现类 + * + * @author HUIHUI + */ +@Service +@Validated +public class CrmPermissionServiceImpl implements CrmPermissionService { + + @Resource + private CrmPermissionMapper crmPermissionMapper; + + + @Override + @Transactional(rollbackFor = Exception.class) + public Long createCrmPermission(CrmPermissionCreateBO createBO) { + CrmPermissionDO createDO = CrmPermissionConvert.INSTANCE.convert(createBO); + crmPermissionMapper.insert(createDO); + return createDO.getId(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateCrmPermission(CrmPermissionUpdateBO updateBO) { + validateCrmPermissionExists(updateBO.getId()); + + CrmPermissionDO updateDO = CrmPermissionConvert.INSTANCE.convert(updateBO); + crmPermissionMapper.updateById(updateDO); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteCrmPermission(Long id) { + validateCrmPermissionExists(id); + + crmPermissionMapper.deleteById(id); + } + + private void validateCrmPermissionExists(Long id) { + if (crmPermissionMapper.selectById(id) == null) { + throw exception(CRM_PERMISSION_NOT_EXISTS); + } + } + + @Override + public CrmPermissionDO getCrmPermission(Long id) { + return crmPermissionMapper.selectById(id); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateBO.java new file mode 100644 index 000000000..8c9b16376 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateBO.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.crm.service.permission.bo; + +import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.Set; + +/** + * crm 数据权限 Create BO + * + * @author HUIHUI + */ +@Data +public class CrmPermissionCreateBO { + + /** + * Crm 类型 关联 {@link CrmEnum} + */ + @NotNull(message = "Crm 类型不能为空") + private Integer crmType; + /** + * 数据编号 关联 {@link CrmEnum} 对应模块 DO#getId() + */ + @NotNull(message = "Crm 数据编号不能为空") + private Integer crmDataId; + /** + * 负责人的用户编号 关联 AdminUser#id, null 则为公海数据 + */ + private Long ownerUserId; + /** + * 只读权限的用户编号数组 + */ + private Set roUserIds; + /** + * 读写权限的用户编号数组 + */ + private Set rwUserIds; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateBO.java new file mode 100644 index 000000000..3b00eb644 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateBO.java @@ -0,0 +1,47 @@ +package cn.iocoder.yudao.module.crm.service.permission.bo; + +import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; +import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.util.Set; + +/** + * crm 数据权限 Update BO + * + * @author HUIHUI + */ +@Data +public class CrmPermissionUpdateBO { + + /** + * 数据权限编号 {@link CrmPermissionDO#getId()} + */ + @NotNull(message = "Crm 数据权限编号不能为空") + private Long id; + + /** + * Crm 类型 关联 {@link CrmEnum} + */ + @NotNull(message = "Crm 类型不能为空") + private Integer crmType; + /** + * 数据编号 关联 {@link CrmEnum} 对应模块 DO#getId() + */ + @NotNull(message = "Crm 数据编号不能为空") + private Integer crmDataId; + /** + * 负责人的用户编号 关联 AdminUser#id, null 则为公海数据 + */ + private Long ownerUserId; + /** + * 只读权限的用户编号数组 + */ + private Set roUserIds; + /** + * 读写权限的用户编号数组 + */ + private Set rwUserIds; + +} From e6eaa3a24af92e5a96d2b3169c7896d3b2cdda3c Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 30 Oct 2023 16:29:24 +0800 Subject: [PATCH 042/101] =?UTF-8?q?=E5=AE=8C=E5=96=84=20CRM-=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/ErrorCodeConstants.java | 11 +- .../crm/enums/common/PermissionTypeEnum.java | 31 ++++ .../crm/enums/common/TransferTypeEnum.java | 36 +++++ .../admin/business/CrmBusinessController.java | 6 +- .../business/vo/CrmTransferBusinessReqVO.java | 27 +++- .../admin/clue/vo/CrmClueBaseVO.java | 4 - .../admin/contact/ContactController.java | 2 +- .../admin/contact/vo/ContactCreateReqVO.java | 8 - .../contact/vo/CrmContactTransferReqVO.java | 8 + .../admin/contract/ContractController.java | 2 +- .../convert/business/CrmBusinessConvert.java | 17 +- .../crm/convert/contact/ContactConvert.java | 18 +-- .../crm/convert/contract/ContractConvert.java | 18 +-- .../dataobject/business/CrmBusinessDO.java | 4 +- .../crm/dal/dataobject/clue/CrmClueDO.java | 6 - .../crm/dal/dataobject/contact/ContactDO.java | 4 +- .../dal/dataobject/contract/ContractDO.java | 4 +- .../dataobject/customer/CrmCustomerDO.java | 4 +- .../permission/CrmPermissionDO.java | 4 +- .../dal/mysql/business/CrmBusinessMapper.java | 3 - .../mysql/permission/CrmPermissionMapper.java | 7 + .../core/aop/CrmPermissionAspect.java | 146 +++++------------- .../dataobject/CrmPermissionBaseDO.java | 37 ----- .../module/crm/framework/enums/CrmEnum.java | 16 +- .../framework/enums/OperationTypeEnum.java | 5 +- .../framework/utils/CrmPermissionUtils.java | 49 ------ .../crm/framework/vo/CrmTransferBaseVO.java | 32 ---- .../service/business/CrmBusinessService.java | 5 +- .../business/CrmBusinessServiceImpl.java | 43 +++--- .../crm/service/contact/ContactService.java | 5 +- .../service/contact/ContactServiceImpl.java | 47 +++--- .../crm/service/contract/ContractService.java | 3 +- .../service/contract/ContractServiceImpl.java | 46 +++--- .../permission/CrmPermissionService.java | 14 +- .../permission/CrmPermissionServiceImpl.java | 61 +++++++- .../permission/bo/CrmPermissionCreateBO.java | 2 +- .../permission/bo/CrmPermissionUpdateBO.java | 2 +- .../bo/TransferCrmPermissionBO.java | 48 ++++++ .../business/CrmBusinessServiceImplTest.java | 3 +- .../contract/ContractServiceImplTest.java | 3 +- 40 files changed, 399 insertions(+), 392 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/PermissionTypeEnum.java create mode 100644 yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/TransferTypeEnum.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/dataobject/CrmPermissionBaseDO.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/CrmPermissionUtils.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/vo/CrmTransferBaseVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/TransferCrmPermissionBO.java diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index bde7a3df5..aba62797d 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -11,17 +11,12 @@ public interface ErrorCodeConstants { // ========== 合同管理 1-020-000-000 ========== ErrorCode CONTRACT_NOT_EXISTS = new ErrorCode(1_020_000_000, "合同不存在"); - ErrorCode CONTRACT_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_000_001, "合同转移失败,原因:没有转移权限"); // TODO @puhui999:这个搞成 “合同操作失败,原因:没有权限” - ErrorCode CONTRACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_000_002, "合同转移失败,原因:负责人不存在"); // ========== 线索管理 1-020-001-000 ========== ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在"); // ========== 商机管理 1-020-002-000 ========== ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在"); - ErrorCode BUSINESS_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_002_001, "商机操作失败,原因:没有权限"); - ErrorCode BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_002_002, "商机操作失败,原因:负责人不存在"); - ErrorCode BUSINESS_TRANSFER_FAIL_OWNER_USER_EXISTS = new ErrorCode(1_020_002_003, "商机操作失败,原因:转移对象已经是该负责人"); // TODO @lilleo:商机状态、商机类型,都单独错误码段 @@ -30,8 +25,6 @@ public interface ErrorCodeConstants { // ========== 联系人管理 1-020-003-000 ========== ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); - ErrorCode CONTACT_TRANSFER_FAIL_PERMISSION_DENIED = new ErrorCode(1_020_003_001, "联系人转移失败,原因:没有转移权限"); // TODO @puhui999:这个搞成 “联系人操作失败,原因:没有权限” - ErrorCode CONTACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_003_002, "联系人转移失败,原因:负责人不存在"); // TODO @liuhongfeng:错误码分段; ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_030_000_001, "回款管理不存在"); @@ -43,5 +36,9 @@ public interface ErrorCodeConstants { // ========== 客户管理 1_020_007_000 ========== ErrorCode CRM_PERMISSION_NOT_EXISTS = new ErrorCode(1_020_007_000, "数据权限不存在"); + ErrorCode CRM_PERMISSION_DENIED = new ErrorCode(1_020_007_001, "{}操作失败,原因:没有权限"); + ErrorCode CRM_PERMISSION_MODEL_NOT_EXISTS = new ErrorCode(1_020_007_002, "{}不存在"); + ErrorCode CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS = new ErrorCode(1_020_007_003, "{}操作失败,原因:负责人不存在"); + ErrorCode CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS = new ErrorCode(1_020_007_004, "{}操作失败,原因:转移对象已经是该负责人"); } diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/PermissionTypeEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/PermissionTypeEnum.java new file mode 100644 index 000000000..1f94ce3fd --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/PermissionTypeEnum.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.crm.enums.common; + +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +@Getter +@AllArgsConstructor +public enum PermissionTypeEnum implements IntArrayValuable { + + READONLY(1, "只读"), + READ_AND_WRITE(2, "读写"); + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PermissionTypeEnum::getType).toArray(); + + /** + * 类型 + */ + private final Integer type; + /** + * 类型名 + */ + private final String name; + + @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/TransferTypeEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/TransferTypeEnum.java new file mode 100644 index 000000000..d12ce71db --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/TransferTypeEnum.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.crm.enums.common; + +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * Crm 负责人转移后原负责人的处理方式 + * + * @author HUIHUI + */ +@Getter +@AllArgsConstructor +public enum TransferTypeEnum implements IntArrayValuable { + + REMOVE(1, "移除"), + TEAM(2, "转为团队成员"); + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TransferTypeEnum::getType).toArray(); + + /** + * 类型 + */ + private final Integer type; + /** + * 类型名 + */ + private final String name; + + @Override + public int[] array() { + return ARRAYS; + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java index 2082e80d3..754bcd7cf 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.crm.controller.admin.business; -import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; @@ -8,7 +7,6 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.framework.utils.CrmPermissionUtils; import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -40,7 +38,7 @@ public class CrmBusinessController { @Operation(summary = "创建商机") @PreAuthorize("@ss.hasPermission('crm:business:create')") public CommonResult createBusiness(@Valid @RequestBody CrmBusinessCreateReqVO createReqVO) { - return success(businessService.createBusiness(createReqVO)); + return success(businessService.createBusiness(createReqVO, getLoginUserId())); } @PutMapping("/update") @@ -65,7 +63,6 @@ public class CrmBusinessController { @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('crm:business:query')") public CommonResult getBusiness(@RequestParam("id") Long id) { - CrmPermissionUtils.setCrmTransferInfo(getLoginUserId(), UserTypeEnum.ADMIN.getValue()); CrmBusinessDO business = businessService.getBusiness(id); return success(CrmBusinessConvert.INSTANCE.convert(business)); } @@ -95,7 +92,6 @@ public class CrmBusinessController { @Operation(summary = "商机转移") @PreAuthorize("@ss.hasPermission('crm:business:update')") public CommonResult transfer(@Valid @RequestBody CrmTransferBusinessReqVO reqVO) { - CrmPermissionUtils.setCrmTransferInfo(getLoginUserId(), UserTypeEnum.ADMIN.getValue(), reqVO); businessService.businessTransfer(reqVO, getLoginUserId()); return success(true); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmTransferBusinessReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmTransferBusinessReqVO.java index 0ba2142db..075cfb764 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmTransferBusinessReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/vo/CrmTransferBusinessReqVO.java @@ -1,11 +1,34 @@ package cn.iocoder.yudao.module.crm.controller.admin.business.vo; -import cn.iocoder.yudao.module.crm.framework.vo.CrmTransferBaseVO; +import cn.iocoder.yudao.framework.common.validation.InEnum; +import cn.iocoder.yudao.module.crm.enums.common.PermissionTypeEnum; +import cn.iocoder.yudao.module.crm.enums.common.TransferTypeEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import javax.validation.constraints.NotNull; + @Schema(description = "管理后台 - 商机转移 Request VO") @Data -public class CrmTransferBusinessReqVO extends CrmTransferBaseVO { +public class CrmTransferBusinessReqVO { + + @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "联系人编号不能为空") + private Long id; + + @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "新负责人的用户编号不能为空") + private Long ownerUserId; + + @Schema(description = "原负责人移除方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @InEnum(TransferTypeEnum.class) + @NotNull(message = "原负责人移除方式不能为空") + private Integer transferType; + + @Schema(description = "权限类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @InEnum(PermissionTypeEnum.class) + @NotNull(message = "权限类型不能为空") + private Integer permissionType; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java index a0efb99d6..f8ca48444 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/vo/CrmClueBaseVO.java @@ -42,10 +42,6 @@ public class CrmClueBaseVO { @Schema(description = "地址", example = "北京市海淀区") private String address; - @Schema(description = "负责人的用户编号", example = "27199") - @NotNull(message = "负责人不能为空") - private Long ownerUserId; - @Schema(description = "最后跟进时间") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime contactLastTime; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java index f28d27ef8..98ee287ad 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java @@ -39,7 +39,7 @@ public class ContactController { @Operation(summary = "创建crm联系人") @PreAuthorize("@ss.hasPermission('crm:contact:create')") public CommonResult createContact(@Valid @RequestBody ContactCreateReqVO createReqVO) { - return success(contactService.createContact(createReqVO)); + return success(contactService.createContact(createReqVO, getLoginUserId())); } @PutMapping("/update") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java index 64ea71084..9f4d8ec2c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java @@ -5,18 +5,10 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -import java.util.Set; - @Schema(description = "管理后台 - crm联系人创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class ContactCreateReqVO extends ContactBaseVO { - @Schema(description = "只读权限的用户编号数组") - private Set roUserIds; - - @Schema(description = "读写权限的用户编号数组") - private Set rwUserIds; - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java index de4c1cbb6..db4926e8c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java @@ -17,4 +17,12 @@ public class CrmContactTransferReqVO { @NotNull(message = "新负责人的用户编号不能为空") private Long ownerUserId; + @Schema(description = "原负责人移除方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "原负责人移除方式不能为空") + private Integer transferType; + + @Schema(description = "权限类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "权限类型不能为空") + private Integer permissionType; + } 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/ContractController.java index 7a7326cde..3372eb6a3 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/ContractController.java @@ -38,7 +38,7 @@ public class ContractController { @Operation(summary = "创建合同") @PreAuthorize("@ss.hasPermission('crm:contract:create')") public CommonResult createContract(@Valid @RequestBody ContractCreateReqVO createReqVO) { - return success(contractService.createContract(createReqVO)); + return success(contractService.createContract(createReqVO, getLoginUserId())); } @PutMapping("/update") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java index 16ef0433b..b9ddf8496 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/business/CrmBusinessConvert.java @@ -3,11 +3,13 @@ package cn.iocoder.yudao.module.crm.convert.business; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; +import cn.iocoder.yudao.module.crm.service.permission.bo.TransferCrmPermissionBO; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; import java.util.List; -import java.util.Set; /** * 商机 Convert @@ -29,13 +31,10 @@ public interface CrmBusinessConvert { List convertList02(List list); - default CrmBusinessDO convert(CrmBusinessDO business, CrmTransferBusinessReqVO reqVO, Long userId) { - Set rwUserIds = business.getRwUserIds(); - rwUserIds.remove(userId); - rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负责人 - // TODO @puhui999:对原负责人,加个类似的处理:移除、转化为团队成员(只读、读写) - return new CrmBusinessDO().setId(business.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 - .setRwUserIds(rwUserIds); - } + @Mappings({ + @Mapping(target = "userId", source = "userId"), + @Mapping(target = "crmDataId", source = "reqVO.id") + }) + TransferCrmPermissionBO convert(CrmTransferBusinessReqVO reqVO, Long userId); } 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 c14ea7586..48ebb7d02 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 @@ -1,14 +1,15 @@ package cn.iocoder.yudao.module.crm.convert.contact; -import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; +import cn.iocoder.yudao.module.crm.service.permission.bo.TransferCrmPermissionBO; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; import java.util.List; -import java.util.Set; /** * crm联系人 Convert @@ -32,13 +33,10 @@ public interface ContactConvert { List convertList02(List list); - // TODO @puhui999:参考 CrmBusinessConvert 的修改建议 - default ContactDO convert(ContactDO contact, CrmContactTransferReqVO reqVO, Long userId) { - Set rwUserIds = contact.getRwUserIds(); - rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 - rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 - return new ContactDO().setId(contact.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 - .setRwUserIds(rwUserIds); - } + @Mappings({ + @Mapping(target = "userId", source = "userId"), + @Mapping(target = "crmDataId", source = "reqVO.id") + }) + TransferCrmPermissionBO convert(CrmContactTransferReqVO reqVO, Long userId); } 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 55df1d87b..c962fcd55 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 @@ -1,14 +1,15 @@ package cn.iocoder.yudao.module.crm.convert.contract; -import cn.hutool.core.util.ObjUtil; 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.service.permission.bo.TransferCrmPermissionBO; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; import java.util.List; -import java.util.Set; /** * 合同 Convert @@ -32,13 +33,10 @@ public interface ContractConvert { List convertList02(List list); - // TODO @puhui999:参考 CrmBusinessConvert 的修改建议 - default ContractDO convert(ContractDO contract, CrmContractTransferReqVO reqVO, Long userId) { - Set rwUserIds = contract.getRwUserIds(); - rwUserIds.removeIf(item -> ObjUtil.equal(item, userId)); // 移除老负责人 - rwUserIds.add(reqVO.getOwnerUserId()); // 读写权限加入新的负人 - return (ContractDO) new ContractDO().setId(contract.getId()).setOwnerUserId(reqVO.getOwnerUserId()) // 设置新负责人 - .setRwUserIds(rwUserIds); - } + @Mappings({ + @Mapping(target = "userId", source = "userId"), + @Mapping(target = "crmDataId", source = "reqVO.id") + }) + TransferCrmPermissionBO convert(CrmContractTransferReqVO reqVO, Long userId); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java index a9e599b7c..435bf1995 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/business/CrmBusinessDO.java @@ -1,8 +1,8 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.business; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatus.CrmBusinessStatusDO; import cn.iocoder.yudao.module.crm.dal.dataobject.businessstatustype.CrmBusinessStatusTypeDO; -import cn.iocoder.yudao.module.crm.framework.dataobject.CrmPermissionBaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -23,7 +23,7 @@ import java.time.LocalDateTime; @Builder @NoArgsConstructor @AllArgsConstructor -public class CrmBusinessDO extends CrmPermissionBaseDO { +public class CrmBusinessDO extends BaseDO { /** * 主键 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java index 1c6ccd608..592301b44 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/clue/CrmClueDO.java @@ -64,12 +64,6 @@ public class CrmClueDO extends BaseDO { * 地址 */ private String address; - /** - * 负责人的用户编号 - * - * 关联 AdminUserDO 的 id 字段 - */ - private Long ownerUserId; /** * 最后跟进时间 TODO 添加跟进记录时更新该值 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java index 4e5dab7cf..f958fcd64 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/contact/ContactDO.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.contact; -import cn.iocoder.yudao.module.crm.framework.dataobject.CrmPermissionBaseDO; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -21,7 +21,7 @@ import java.time.LocalDateTime; @Builder @NoArgsConstructor @AllArgsConstructor -public class ContactDO extends CrmPermissionBaseDO { +public class ContactDO extends BaseDO { /** * 主键 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/ContractDO.java index 0ddce4c8b..f32786791 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/ContractDO.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.contract; -import cn.iocoder.yudao.module.crm.framework.dataobject.CrmPermissionBaseDO; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -21,7 +21,7 @@ import java.time.LocalDateTime; @Builder @NoArgsConstructor @AllArgsConstructor -public class ContractDO extends CrmPermissionBaseDO { +public class ContractDO extends BaseDO { /** * 合同编号 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java index e66c42172..9de87ee5b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/customer/CrmCustomerDO.java @@ -1,6 +1,6 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.customer; -import cn.iocoder.yudao.module.crm.framework.dataobject.CrmPermissionBaseDO; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -23,7 +23,7 @@ import java.time.LocalDateTime; @Builder @NoArgsConstructor @AllArgsConstructor -public class CrmCustomerDO extends CrmPermissionBaseDO { +public class CrmCustomerDO extends BaseDO { /** * 编号 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java index 44a44fa6d..028d41c95 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/permission/CrmPermissionDO.java @@ -36,9 +36,9 @@ public class CrmPermissionDO extends BaseDO { */ private Integer crmType; /** - * 数据编号 关联 {@link CrmEnum} 对应模块 DO#id + * 数据编号 关联 {@link CrmEnum} 对应模块 DO#getId() */ - private Integer crmDataId; + private Long crmDataId; /** * 负责人的用户编号 关联 AdminUser#id */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java index 1429c0794..5df94c0fa 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/business/CrmBusinessMapper.java @@ -36,10 +36,7 @@ public interface CrmBusinessMapper extends BaseMapperX { .eqIfPresent(CrmBusinessDO::getDiscountPercent, reqVO.getDiscountPercent()) .eqIfPresent(CrmBusinessDO::getProductPrice, reqVO.getProductPrice()) .eqIfPresent(CrmBusinessDO::getRemark, reqVO.getRemark()) - .eqIfPresent(CrmBusinessDO::getOwnerUserId, reqVO.getOwnerUserId()) .betweenIfPresent(CrmBusinessDO::getCreateTime, reqVO.getCreateTime()) - .eqIfPresent(CrmBusinessDO::getRoUserIds, reqVO.getRoUserIds()) - .eqIfPresent(CrmBusinessDO::getRwUserIds, reqVO.getRwUserIds()) .eqIfPresent(CrmBusinessDO::getEndStatus, reqVO.getEndStatus()) .eqIfPresent(CrmBusinessDO::getEndRemark, reqVO.getEndRemark()) .betweenIfPresent(CrmBusinessDO::getContactLastTime, reqVO.getContactLastTime()) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java index 44b7b270b..53809f3eb 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/permission/CrmPermissionMapper.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.crm.dal.mysql.permission; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; import org.apache.ibatis.annotations.Mapper; @@ -11,4 +12,10 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface CrmPermissionMapper extends BaseMapperX { + + default CrmPermissionDO selectByCrmTypeAndCrmDataId(Integer crmType, Long crmDataId) { + return selectOne(new LambdaQueryWrapperX() + .eq(CrmPermissionDO::getCrmType, crmType).eq(CrmPermissionDO::getCrmDataId, crmDataId)); + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java index b0692185b..dd25703e0 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java @@ -2,19 +2,11 @@ package cn.iocoder.yudao.module.crm.framework.core.aop; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.framework.common.core.KeyValue; -import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; +import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; +import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; -import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; import cn.iocoder.yudao.module.crm.framework.enums.OperationTypeEnum; -import cn.iocoder.yudao.module.crm.framework.vo.CrmTransferBaseVO; -import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService; -import cn.iocoder.yudao.module.crm.service.contact.ContactService; -import cn.iocoder.yudao.module.crm.service.contract.ContractService; -import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; +import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; @@ -22,11 +14,11 @@ import org.aspectj.lang.annotation.Before; import org.springframework.stereotype.Component; import javax.annotation.Resource; -import java.util.Collection; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_PERMISSION_DENIED; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_PERMISSION_MODEL_NOT_EXISTS; /** * Crm 数据权限校验 AOP 切面 @@ -38,48 +30,16 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; @Slf4j public class CrmPermissionAspect { - /** - * 用户编号 - */ - private static final ThreadLocal USER_ID = new ThreadLocal<>(); - /** - * 用户类型 - */ - private static final ThreadLocal USER_TYPE = new ThreadLocal<>(); - /** - * 操作数据编号 - */ - private static final ThreadLocal DATA_ID = new ThreadLocal<>(); - /** - * Crm 转换数据 VO 数据 - */ - private static final ThreadLocal CRM_TRANSFER_VO = new ThreadLocal<>(); - @Resource - private CrmBusinessService crmBusinessService; - @Resource - private ContactService contactService; - @Resource - private ContractService contractService; - @Resource - private CrmCustomerService crmCustomerService; + private CrmPermissionService crmPermissionService; - public static void setCrmTransferInfo(Long userId, Integer userType, Object crmTransferBaseVO) { - USER_ID.set(userId); - USER_TYPE.set(userType); - CRM_TRANSFER_VO.set((CrmTransferBaseVO) crmTransferBaseVO); - } - - public static void setCrmTransferInfo(Long userId, Integer userType) { - USER_ID.set(userId); - USER_TYPE.set(userType); - } - - private static void clear() { - USER_ID.remove(); - USER_TYPE.remove(); - DATA_ID.remove(); - CRM_TRANSFER_VO.remove(); + /** + * 获得用户编号 + * + * @return 用户编号 + */ + private static Long getUserId() { + return WebFrameworkUtils.getLoginUserId(); } @Before("@annotation(crmPermission)") @@ -87,78 +47,46 @@ public class CrmPermissionAspect { try { Integer crmType = crmPermission.crmType().getType(); Integer operationType = crmPermission.operationType().getType(); - Long id = DATA_ID.get();// 获取操作数据的编号 - KeyValue, Collection> keyValue = new KeyValue<>(); // 数据权限 key 只读,value 读写 - // 客户 - if (ObjUtil.equal(crmType, CrmEnum.CRM_CUSTOMER.getType())) { - CrmCustomerDO customer = crmCustomerService.getCustomer(id); - if (customer == null) { - throw exception(CUSTOMER_NOT_EXISTS); - } - // 如果是自己则直接过 - if (ObjUtil.equal(customer.getOwnerUserId(), USER_ID.get())) { - return; - } - new KeyValue<>(customer.getRoUserIds(), customer.getRwUserIds()); + Long id = (Long) joinPoint.getArgs()[0];// 获取操作数据的编号 + + // 1. 获取数据权限 + CrmPermissionDO permission = crmPermissionService.getCrmPermissionByCrmTypeAndCrmDataId(crmType, id); + if (permission == null) { + // 不存在说明数据也不存在 + throw exception(CRM_PERMISSION_MODEL_NOT_EXISTS, crmPermission.crmType().getName()); } - // 联系人 - if (ObjUtil.equal(crmType, CrmEnum.CRM_CONTACTS.getType())) { - ContactDO contact = contactService.getContact(id); - if (contact == null) { - throw exception(CONTACT_NOT_EXISTS); - } - // 如果是自己则直接过 - if (ObjUtil.equal(contact.getOwnerUserId(), USER_ID.get())) { - return; - } - new KeyValue<>(contact.getRoUserIds(), contact.getRwUserIds()); + // 1.2. 校验是否为公海数据 + if (permission.getOwnerUserId() == null) { + return; } - // 商机 - if (ObjUtil.equal(crmType, CrmEnum.CRM_BUSINESS.getType())) { - CrmBusinessDO business = crmBusinessService.getBusiness(id); - if (business == null) { - throw exception(BUSINESS_NOT_EXISTS); - } - // 如果是自己则直接过 - if (ObjUtil.equal(business.getOwnerUserId(), USER_ID.get())) { - return; - } - new KeyValue<>(business.getRoUserIds(), business.getRwUserIds()); + // 1.3. 校验当前负责人是不是自己 + if (ObjUtil.equal(permission.getOwnerUserId(), getUserId())) { + return; } - // 合同 - if (ObjUtil.equal(crmType, CrmEnum.CRM_CONTRACT.getType())) { - ContractDO contract = contractService.getContract(id); - if (contract == null) { - throw exception(CONTRACT_NOT_EXISTS); - } - // 如果是自己则直接过 - if (ObjUtil.equal(contract.getOwnerUserId(), USER_ID.get())) { - return; - } - new KeyValue<>(contract.getRoUserIds(), contract.getRwUserIds()); - } - // 1. 校验是否有读权限 + // 1.4 TODO 校验是否为超级管理员 + + // 2. 校验是否有读权限 if (OperationTypeEnum.isRead(operationType)) { // 校验该数据当前用户是否可读 - boolean isRead = CollUtil.contains(keyValue.getKey(), item -> ObjUtil.equal(id, USER_ID.get())) - || CollUtil.contains(keyValue.getValue(), item -> ObjUtil.equal(id, USER_ID.get())); + boolean isRead = CollUtil.contains(permission.getRoUserIds(), item -> ObjUtil.equal(item, getUserId())) + || CollUtil.contains(permission.getRwUserIds(), item -> ObjUtil.equal(item, getUserId())); if (isRead) { return; } - throw exception(CONTRACT_NOT_EXISTS); } - // 2. 校验是否有编辑权限 + + // 3. 校验是否有编辑权限 if (OperationTypeEnum.isEdit(operationType)) { // 校验该数据当前用户是否可读写 - if (CollUtil.contains(keyValue.getValue(), item -> ObjUtil.equal(id, USER_ID.get()))) { + if (CollUtil.contains(permission.getRwUserIds(), item -> ObjUtil.equal(item, getUserId()))) { return; } - throw exception(CONTRACT_NOT_EXISTS); } + + // 4. 没通过结束,报错 {}操作失败,原因:没有权限 + throw exception(CRM_PERMISSION_DENIED, crmPermission.crmType().getName()); } catch (Exception ex) { log.error("[doBefore][crmPermission({}) 数据校验错误]", toJsonString(crmPermission), ex); - } finally { - clear(); } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/dataobject/CrmPermissionBaseDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/dataobject/CrmPermissionBaseDO.java deleted file mode 100644 index e7262165b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/dataobject/CrmPermissionBaseDO.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.dataobject; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; -import com.baomidou.mybatisplus.annotation.TableField; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; - -import java.util.Set; - -/** - * crm 数据权限基础实体对象 - * - * @author HUIHUI - */ -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmPermissionBaseDO extends BaseDO { - - /** - * 负责人的用户编号 关联 AdminUser#id - */ - private Long ownerUserId; - /** - * 只读权限的用户编号数组 - */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) - private Set roUserIds; - /** - * 读写权限的用户编号数组 - */ - @TableField(typeHandler = JsonLongSetTypeHandler.class) - private Set rwUserIds; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/CrmEnum.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/CrmEnum.java index 1fbaea575..62fd4d007 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/CrmEnum.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/CrmEnum.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.crm.framework.enums; +import cn.hutool.core.util.ObjUtil; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -15,12 +16,8 @@ public enum CrmEnum { CRM_LEADS(1, "线索"), CRM_CUSTOMER(2, "客户"), CRM_CONTACTS(3, "联系人"), - CRM_PRODUCT(4, "产品"), CRM_BUSINESS(5, "商机"), - CRM_CONTRACT(6, "合同"), - CRM_RECEIVABLES(7, "回款"), - CRM_RECEIVABLES_PLAN(8, "回款计划"), - CRM_CUSTOMER_POOL(9, "客户公海"); + CRM_CONTRACT(6, "合同"); /** * 类型 @@ -31,4 +28,13 @@ public enum CrmEnum { */ private final String name; + public static String getNameByType(Integer type) { + for (CrmEnum crmEnum : CrmEnum.values()) { + if (ObjUtil.equal(crmEnum.type, type)) { + return crmEnum.name; + } + } + return ""; + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/OperationTypeEnum.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/OperationTypeEnum.java index beee6c93a..3cc2e8b6e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/OperationTypeEnum.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/OperationTypeEnum.java @@ -15,8 +15,7 @@ public enum OperationTypeEnum { DELETE(1, "删除"), UPDATE(2, "修改"), - READ(3, "查询"), - TRANSFER(4, "转移"); + READ(3, "查询"); /** * 类型 @@ -33,7 +32,7 @@ public enum OperationTypeEnum { } public static boolean isEdit(Integer type) { - return ObjUtil.equal(type, UPDATE.getType()) || ObjUtil.equal(type, DELETE.getType()) || ObjUtil.equal(type, TRANSFER.getType()); + return ObjUtil.equal(type, UPDATE.getType()) || ObjUtil.equal(type, DELETE.getType()); } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/CrmPermissionUtils.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/CrmPermissionUtils.java deleted file mode 100644 index 226c0e57b..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/utils/CrmPermissionUtils.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.utils; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjUtil; -import cn.iocoder.yudao.module.crm.framework.core.aop.CrmPermissionAspect; - -import java.util.Collection; - -/** - * 数据读写权限校验工具类 - * - * @author HUIHUI - */ -public class CrmPermissionUtils { - - // TODO @puhui999:负责人是单独的字段哈; - // TODO @puhui999:额外校验,如果是管理员,可以查看所有;看着要做成有状态的了,可能要搞个 CrmPermissionService 咧; - - /** - * 判断当前数据对用户来说是否是只读的 - * - * @param roUserIds 当前操作数据的只读权限的用户编号数组 - * @param userId 当前操作数据的用户编号 - * @return boolean 是/否 - */ - public static boolean isReadOnly(Collection roUserIds, Long userId) { - return CollUtil.contains(roUserIds, id -> ObjUtil.equal(id, userId)); - } - - /** - * 判断当前数据对用户来说是否是可读写的 - * - * @param rwUserIds 当前操作数据的读写权限的用户编号数组 - * @param userId 当前操作数据的用户编号 - * @return boolean 是/否 - */ - public static boolean isReadAndWrite(Collection rwUserIds, Long userId) { - return CollUtil.contains(rwUserIds, id -> ObjUtil.equal(id, userId)); - } - - public static void setCrmTransferInfo(Long userId, Integer userType, Object crmTransferBaseVO) { - CrmPermissionAspect.setCrmTransferInfo(userId, userType, crmTransferBaseVO); - } - - public static void setCrmTransferInfo(Long userId, Integer userType) { - CrmPermissionAspect.setCrmTransferInfo(userId, userType); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/vo/CrmTransferBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/vo/CrmTransferBaseVO.java deleted file mode 100644 index 97cc6d167..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/vo/CrmTransferBaseVO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.yudao.module.crm.framework.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -import javax.validation.constraints.NotNull; - -/** - * Crm 数据转移 Base VO,提供给转移的子 VO 使用 - * - * @author HUIHUI - */ -@Data -public class CrmTransferBaseVO { - - @Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "联系人编号不能为空") - private Long id; - - @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "新负责人的用户编号不能为空") - private Long ownerUserId; - - @Schema(description = "原负责人移除方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "原负责人移除方式不能为空") - private Integer transferType; - - @Schema(description = "权限类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") - @NotNull(message = "权限类型不能为空") - private Integer permissionType; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java index 12689d49c..233b6603a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java @@ -19,9 +19,10 @@ public interface CrmBusinessService { * 创建商机 * * @param createReqVO 创建信息 + * @param userId 用户编号 * @return 编号 */ - Long createBusiness(@Valid CrmBusinessCreateReqVO createReqVO); + Long createBusiness(@Valid CrmBusinessCreateReqVO createReqVO, Long userId); /** * 更新商机 @@ -76,5 +77,5 @@ public interface CrmBusinessService { * @param userId 用户编号 */ void businessTransfer(CrmTransferBusinessReqVO reqVO, Long userId); - + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java index c1adf4c9c..250f01492 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.service.business; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; -import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.crm.controller.admin.business.vo.*; import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert; @@ -11,9 +10,11 @@ import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; import cn.iocoder.yudao.module.crm.framework.enums.OperationTypeEnum; +import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; +import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateBO; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; @@ -21,7 +22,7 @@ import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; /** * 商机 Service 实现类 @@ -37,17 +38,27 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { @Resource private AdminUserApi adminUserApi; + @Resource + private CrmPermissionService crmPermissionService; @Override - public Long createBusiness(CrmBusinessCreateReqVO createReqVO) { + @Transactional(rollbackFor = Exception.class) + public Long createBusiness(CrmBusinessCreateReqVO createReqVO, Long userId) { // 插入 CrmBusinessDO business = CrmBusinessConvert.INSTANCE.convert(createReqVO); businessMapper.insert(business); + + // 创建数据权限 + crmPermissionService.createCrmPermission(new CrmPermissionCreateBO().setCrmType(CrmEnum.CRM_BUSINESS.getType()) + .setCrmDataId(business.getId()).setOwnerUserId(userId)); // 设置当前操作的人为负责人 + // 返回 return business.getId(); } @Override + @Transactional(rollbackFor = Exception.class) + @CrmPermission(crmType = CrmEnum.CRM_BUSINESS, operationType = OperationTypeEnum.UPDATE) public void updateBusiness(CrmBusinessUpdateReqVO updateReqVO) { // 校验存在 validateBusinessExists(updateReqVO.getId()); @@ -57,6 +68,8 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { } @Override + @Transactional(rollbackFor = Exception.class) + @CrmPermission(crmType = CrmEnum.CRM_BUSINESS, operationType = OperationTypeEnum.DELETE) public void deleteBusiness(Long id) { // 校验存在 validateBusinessExists(id); @@ -97,25 +110,15 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { } @Override - @CrmPermission(crmType = CrmEnum.CRM_BUSINESS, operationType = OperationTypeEnum.TRANSFER) + @Transactional(rollbackFor = Exception.class) public void businessTransfer(CrmTransferBusinessReqVO reqVO, Long userId) { - // 1.1 校验商机是否存在 - CrmBusinessDO business = getBusiness(reqVO.getId()); - // 1.3 校验转移对象是否已经是该负责人 - if (ObjUtil.equal(business.getOwnerUserId(), reqVO.getOwnerUserId())) { - throw exception(BUSINESS_TRANSFER_FAIL_OWNER_USER_EXISTS); - } - // 1.4 校验新负责人是否存在 - AdminUserRespDTO user = adminUserApi.getUser(reqVO.getOwnerUserId()); - if (user == null) { - throw exception(BUSINESS_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS); - } + // 1 校验商机是否存在 + validateBusinessExists(reqVO.getId()); - // 2. 更新新的负责人 - CrmBusinessDO updateBusiness = CrmBusinessConvert.INSTANCE.convert(business, reqVO, userId); - businessMapper.updateById(updateBusiness); + // 2. 数据权限转移 + crmPermissionService.transferCrmPermission( + CrmBusinessConvert.INSTANCE.convert(reqVO, userId).setCrmType(CrmEnum.CRM_BUSINESS.getType())); - // 3. TODO 记录商机转移日志 } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java index 63b3449f2..a66edc650 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java @@ -19,9 +19,10 @@ public interface ContactService { * 创建crm联系人 * * @param createReqVO 创建信息 + * @param userId 用户编号 * @return 编号 */ - Long createContact(@Valid ContactCreateReqVO createReqVO); + Long createContact(@Valid ContactCreateReqVO createReqVO, Long userId); /** * 更新crm联系人 @@ -76,5 +77,5 @@ public interface ContactService { * @param userId 用户编号 */ void contactTransfer(CrmContactTransferReqVO reqVO, Long userId); - + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java index f8fe72c12..d39ada967 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java @@ -7,9 +7,13 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert; import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; import cn.iocoder.yudao.module.crm.dal.mysql.contact.ContactMapper; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; +import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; +import cn.iocoder.yudao.module.crm.framework.enums.OperationTypeEnum; +import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; +import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateBO; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; @@ -17,8 +21,7 @@ import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.framework.utils.CrmPermissionUtils.isReadAndWrite; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_NOT_EXISTS; /** * crm联系人 Service 实现类 @@ -33,19 +36,26 @@ public class ContactServiceImpl implements ContactService { private ContactMapper contactMapper; @Resource - private AdminUserApi adminUserApi; + private CrmPermissionService crmPermissionService; @Override - public Long createContact(ContactCreateReqVO createReqVO) { + public Long createContact(ContactCreateReqVO createReqVO, Long userId) { // TODO @customerId:需要校验存在 // 插入 ContactDO contact = ContactConvert.INSTANCE.convert(createReqVO); contactMapper.insert(contact); + + // 创建数据权限 + crmPermissionService.createCrmPermission(new CrmPermissionCreateBO().setCrmType(CrmEnum.CRM_BUSINESS.getType()) + .setCrmDataId(contact.getId()).setOwnerUserId(userId)); // 设置当前操作的人为负责人 + // 返回 return contact.getId(); } @Override + @Transactional(rollbackFor = Exception.class) + @CrmPermission(crmType = CrmEnum.CRM_CONTACTS, operationType = OperationTypeEnum.UPDATE) public void updateContact(ContactUpdateReqVO updateReqVO) { // 校验存在 validateContactExists(updateReqVO.getId()); @@ -57,6 +67,8 @@ public class ContactServiceImpl implements ContactService { } @Override + @Transactional(rollbackFor = Exception.class) + @CrmPermission(crmType = CrmEnum.CRM_CONTACTS, operationType = OperationTypeEnum.DELETE) public void deleteContact(Long id) { // 校验存在 validateContactExists(id); @@ -73,6 +85,7 @@ public class ContactServiceImpl implements ContactService { } @Override + @CrmPermission(crmType = CrmEnum.CRM_CONTACTS, operationType = OperationTypeEnum.READ) public ContactDO getContact(Long id) { return contactMapper.selectById(id); } @@ -95,26 +108,14 @@ public class ContactServiceImpl implements ContactService { return contactMapper.selectList(exportReqVO); } - // TODO @puhui999:参考 CrmBusinessServiceImpl 修改建议 @Override public void contactTransfer(CrmContactTransferReqVO reqVO, Long userId) { - // 1. 校验联系人是否存在 - ContactDO contact = validateContactExists(reqVO.getId()); - // 1.2. 校验用户是否拥有读写权限 - if (!isReadAndWrite(contact.getRwUserIds(), userId)) { - throw exception(CONTACT_TRANSFER_FAIL_PERMISSION_DENIED); - } - // 2. 校验新负责人是否存在 - AdminUserRespDTO user = adminUserApi.getUser(reqVO.getOwnerUserId()); - if (user == null) { - throw exception(CONTACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS); - } + // 1 校验联系人是否存在 + validateContactExists(reqVO.getId()); - // 3. 更新新的负责人 - ContactDO updateContact = ContactConvert.INSTANCE.convert(contact, reqVO, userId); - contactMapper.updateById(updateContact); - - // 4. TODO 记录联系人转移日志 + // 2. 数据权限转移 + crmPermissionService.transferCrmPermission( + ContactConvert.INSTANCE.convert(reqVO, userId).setCrmType(CrmEnum.CRM_CONTACTS.getType())); } 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 index af8bda185..969f77851 100644 --- 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 @@ -19,9 +19,10 @@ public interface ContractService { * 创建合同 * * @param createReqVO 创建信息 + * @param userId 用户编号 * @return 编号 */ - Long createContract(@Valid ContractCreateReqVO createReqVO); + Long createContract(@Valid ContractCreateReqVO createReqVO, 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/ContractServiceImpl.java index 8bf6a356e..f07911455 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/ContractServiceImpl.java @@ -10,9 +10,10 @@ 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.framework.enums.CrmEnum; import cn.iocoder.yudao.module.crm.framework.enums.OperationTypeEnum; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; -import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; +import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateBO; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; @@ -20,8 +21,7 @@ import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.framework.utils.CrmPermissionUtils.isReadAndWrite; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS; /** * 合同 Service 实现类 @@ -36,18 +36,25 @@ public class ContractServiceImpl implements ContractService { private ContractMapper contractMapper; @Resource - private AdminUserApi adminUserApi; + private CrmPermissionService crmPermissionService; @Override - public Long createContract(ContractCreateReqVO createReqVO) { + public Long createContract(ContractCreateReqVO createReqVO, Long userId) { // 插入 ContractDO contract = ContractConvert.INSTANCE.convert(createReqVO); contractMapper.insert(contract); + + // 创建数据权限 + crmPermissionService.createCrmPermission(new CrmPermissionCreateBO().setCrmType(CrmEnum.CRM_CONTRACT.getType()) + .setCrmDataId(contract.getId()).setOwnerUserId(userId)); // 设置当前操作的人为负责人 + // 返回 return contract.getId(); } @Override + @Transactional(rollbackFor = Exception.class) + @CrmPermission(crmType = CrmEnum.CRM_CONTRACT, operationType = OperationTypeEnum.DELETE) public void updateContract(ContractUpdateReqVO updateReqVO) { // 校验存在 validateContractExists(updateReqVO.getId()); @@ -57,6 +64,8 @@ public class ContractServiceImpl implements ContractService { } @Override + @Transactional(rollbackFor = Exception.class) + @CrmPermission(crmType = CrmEnum.CRM_CONTRACT, operationType = OperationTypeEnum.DELETE) public void deleteContract(Long id) { // 校验存在 validateContractExists(id); @@ -73,6 +82,7 @@ public class ContractServiceImpl implements ContractService { } @Override + @CrmPermission(crmType = CrmEnum.CRM_CONTRACT, operationType = OperationTypeEnum.READ) public ContractDO getContract(Long id) { return contractMapper.selectById(id); } @@ -95,27 +105,15 @@ public class ContractServiceImpl implements ContractService { return contractMapper.selectList(exportReqVO); } - // TODO @puhui999:参考 CrmBusinessServiceImpl 修改建议 @Override - @CrmPermission(crmType = CrmEnum.CRM_CONTRACT, operationType = OperationTypeEnum.TRANSFER) + @Transactional(rollbackFor = Exception.class) public void contractTransfer(CrmContractTransferReqVO reqVO, Long userId) { - // 1. 校验合同是否存在 - ContractDO contract = validateContractExists(reqVO.getId()); - // 1.2. 校验用户是否拥有读写权限 - if (!isReadAndWrite(contract.getRwUserIds(), userId)) { - throw exception(CONTRACT_TRANSFER_FAIL_PERMISSION_DENIED); - } - // 2. 校验新负责人是否存在 - AdminUserRespDTO user = adminUserApi.getUser(reqVO.getOwnerUserId()); - if (user == null) { - throw exception(CONTRACT_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS); - } + // 1 校验合同是否存在 + validateContractExists(reqVO.getId()); - // 3. 更新新的负责人 - ContractDO updateContract = ContractConvert.INSTANCE.convert(contract, reqVO, userId); - contractMapper.updateById(updateContract); - - // 4. TODO 记录合同转移日志 + // 2. 数据权限转移 + crmPermissionService.transferCrmPermission( + ContractConvert.INSTANCE.convert(reqVO, userId).setCrmType(CrmEnum.CRM_CONTRACT.getType())); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java index ef064fd87..91321b709 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java @@ -2,8 +2,10 @@ package cn.iocoder.yudao.module.crm.service.permission; import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; +import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateBO; import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionUpdateBO; +import cn.iocoder.yudao.module.crm.service.permission.bo.TransferCrmPermissionBO; import javax.validation.Valid; @@ -39,9 +41,17 @@ public interface CrmPermissionService { /** * 获得数据权限 * - * @param id 编号 + * @param crmType 数据类型 关联 {@link CrmEnum} + * @param crmDataId 数据编号 关联 {@link CrmEnum} 对应模块 DO#getId() * @return 数据权限 */ - CrmPermissionDO getCrmPermission(Long id); + CrmPermissionDO getCrmPermissionByCrmTypeAndCrmDataId(Integer crmType, Long crmDataId); + + /** + * 数据权限转移 + * + * @param transferCrmPermissionBO 数据权限转移请求 + */ + void transferCrmPermission(@Valid TransferCrmPermissionBO transferCrmPermissionBO); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java index d0df3eee7..2647976bc 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java @@ -1,18 +1,27 @@ package cn.iocoder.yudao.module.crm.service.permission; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjUtil; import cn.iocoder.yudao.module.crm.convert.permission.CrmPermissionConvert; import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO; import cn.iocoder.yudao.module.crm.dal.mysql.permission.CrmPermissionMapper; +import cn.iocoder.yudao.module.crm.enums.common.PermissionTypeEnum; +import cn.iocoder.yudao.module.crm.enums.common.TransferTypeEnum; +import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateBO; import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionUpdateBO; +import cn.iocoder.yudao.module.crm.service.permission.bo.TransferCrmPermissionBO; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.Set; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_PERMISSION_NOT_EXISTS; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; /** * crm 数据权限 Service 接口实现类 @@ -26,6 +35,8 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { @Resource private CrmPermissionMapper crmPermissionMapper; + @Resource + private AdminUserApi adminUserApi; @Override @Transactional(rollbackFor = Exception.class) @@ -59,8 +70,52 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { } @Override - public CrmPermissionDO getCrmPermission(Long id) { - return crmPermissionMapper.selectById(id); + public CrmPermissionDO getCrmPermissionByCrmTypeAndCrmDataId(Integer crmType, Long crmDataId) { + return crmPermissionMapper.selectByCrmTypeAndCrmDataId(crmType, crmDataId); + } + + @Override + public void transferCrmPermission(TransferCrmPermissionBO transferCrmPermissionBO) { + // 1 校验商机是否存在 + CrmPermissionDO permission = getCrmPermissionByCrmTypeAndCrmDataId(transferCrmPermissionBO.getCrmType(), + transferCrmPermissionBO.getCrmDataId()); + String crmName = CrmEnum.getNameByType(transferCrmPermissionBO.getCrmType()); + if (permission == null) { + throw exception(CRM_PERMISSION_MODEL_NOT_EXISTS, crmName); + } + // 1.2 校验转移对象是否已经是该负责人 + if (ObjUtil.equal(permission.getOwnerUserId(), permission.getOwnerUserId())) { + throw exception(CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS, crmName); + } + // 1.3 校验新负责人是否存在 + AdminUserRespDTO user = adminUserApi.getUser(permission.getOwnerUserId()); + if (user == null) { + throw exception(CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_EXISTS, crmName); + } + // TODO 校验是否为超级管理员 || 1.4 + // 1.4 校验是否有写权限 + if (!CollUtil.contains(permission.getRwUserIds(), id -> ObjUtil.equal(id, transferCrmPermissionBO.getUserId()))) { + throw exception(CRM_PERMISSION_DENIED, crmName); + } + + // 2 权限转移 + CrmPermissionDO updateCrmPermission = new CrmPermissionDO().setId(permission.getId()) + .setOwnerUserId(transferCrmPermissionBO.getOwnerUserId()); + if (ObjUtil.equal(TransferTypeEnum.TEAM.getType(), transferCrmPermissionBO.getTransferType())) { + if (ObjUtil.equal(PermissionTypeEnum.READONLY.getType(), transferCrmPermissionBO.getPermissionType())) { + Set roUserIds = permission.getRoUserIds(); + roUserIds.add(permission.getOwnerUserId()); // 老负责人加入团队有只读权限 + updateCrmPermission.setRoUserIds(roUserIds); + } + if (ObjUtil.equal(PermissionTypeEnum.READ_AND_WRITE.getType(), transferCrmPermissionBO.getPermissionType())) { + Set rwUserIds = permission.getRwUserIds(); + rwUserIds.add(permission.getOwnerUserId()); // 老负责人加入团队有读写权限 + updateCrmPermission.setRoUserIds(rwUserIds); + } + } + crmPermissionMapper.updateById(updateCrmPermission); + + // 3. TODO 记录机转移日志 } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateBO.java index 8c9b16376..b7d693a18 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateBO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateBO.java @@ -23,7 +23,7 @@ public class CrmPermissionCreateBO { * 数据编号 关联 {@link CrmEnum} 对应模块 DO#getId() */ @NotNull(message = "Crm 数据编号不能为空") - private Integer crmDataId; + private Long crmDataId; /** * 负责人的用户编号 关联 AdminUser#id, null 则为公海数据 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateBO.java index 3b00eb644..6cad08e75 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateBO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateBO.java @@ -30,7 +30,7 @@ public class CrmPermissionUpdateBO { * 数据编号 关联 {@link CrmEnum} 对应模块 DO#getId() */ @NotNull(message = "Crm 数据编号不能为空") - private Integer crmDataId; + private Long crmDataId; /** * 负责人的用户编号 关联 AdminUser#id, null 则为公海数据 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/TransferCrmPermissionBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/TransferCrmPermissionBO.java new file mode 100644 index 000000000..2f3e94f38 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/TransferCrmPermissionBO.java @@ -0,0 +1,48 @@ +package cn.iocoder.yudao.module.crm.service.permission.bo; + +import cn.iocoder.yudao.module.crm.enums.common.PermissionTypeEnum; +import cn.iocoder.yudao.module.crm.enums.common.TransferTypeEnum; +import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +/** + * 数据权限转移 BO + * + * @author HUIHUI + */ +@Data +public class TransferCrmPermissionBO { + + @NotNull(message = "用户编号不能为空") + private Long userId; + + /** + * Crm 类型 关联 {@link CrmEnum} + */ + @NotNull(message = "Crm 类型不能为空") + private Integer crmType; + + /** + * 数据编号 关联 {@link CrmEnum} 对应模块 DO#getId() + */ + @NotNull(message = "Crm 数据编号不能为空") + private Long crmDataId; + + @NotNull(message = "新负责人的用户编号不能为空") + private Long ownerUserId; + + /** + * 原负责人移除方式, 关联 {@link TransferTypeEnum} + */ + @NotNull(message = "原负责人移除方式不能为空") + private Integer transferType; + + /** + * 权限类型, 关联 {@link PermissionTypeEnum} + */ + @NotNull(message = "权限类型不能为空") + private Integer permissionType; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java index 40fb404d3..b37563ada 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java @@ -15,6 +15,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; @@ -42,7 +43,7 @@ public class CrmBusinessServiceImplTest extends BaseDbUnitTest { CrmBusinessCreateReqVO reqVO = randomPojo(CrmBusinessCreateReqVO.class); // 调用 - Long businessId = businessService.createBusiness(reqVO); + Long businessId = businessService.createBusiness(reqVO, getLoginUserId()); // 断言 assertNotNull(businessId); // 校验记录的属性是否正确 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 f9cbe3a38..1406b5916 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 @@ -17,6 +17,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; @@ -44,7 +45,7 @@ public class ContractServiceImplTest extends BaseDbUnitTest { ContractCreateReqVO reqVO = randomPojo(ContractCreateReqVO.class); // 调用 - Long contractId = contractService.createContract(reqVO); + Long contractId = contractService.createContract(reqVO, getLoginUserId()); // 断言 assertNotNull(contractId); // 校验记录的属性是否正确 From c2fd8179891a061e2b9080ec1198871d145571f5 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 30 Oct 2023 16:52:01 +0800 Subject: [PATCH 043/101] =?UTF-8?q?=E5=AE=8C=E5=96=84=20CRM-=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=20=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/business/CrmBusinessController.java | 2 +- .../admin/contact/ContactController.java | 4 +-- ...eqVO.java => CrmTransferContactReqVO.java} | 2 +- .../admin/contract/ContractController.java | 4 +-- ...qVO.java => CrmTransferContractReqVO.java} | 10 +++++- .../admin/customer/CrmCustomerController.java | 11 +++++- .../customer/vo/CrmTransferCustomerReqVO.java | 28 +++++++++++++++ .../crm/convert/contact/ContactConvert.java | 2 +- .../crm/convert/contract/ContractConvert.java | 2 +- .../convert/customer/CrmCustomerConvert.java | 18 +++++++--- .../crm/dal/mysql/clue/CrmClueMapper.java | 10 +++--- .../crm/dal/mysql/contact/ContactMapper.java | 11 +++--- .../service/business/CrmBusinessService.java | 2 +- .../business/CrmBusinessServiceImpl.java | 5 +-- .../crm/service/contact/ContactService.java | 2 +- .../service/contact/ContactServiceImpl.java | 2 +- .../crm/service/contract/ContractService.java | 2 +- .../service/contract/ContractServiceImpl.java | 2 +- .../service/customer/CrmCustomerService.java | 16 ++++++--- .../customer/CrmCustomerServiceImpl.java | 36 ++++++++++++++++--- .../business/CrmBusinessServiceImplTest.java | 18 ---------- .../service/clue/CrmClueServiceImplTest.java | 6 ---- .../customer/CrmCustomerServiceImplTest.java | 4 ++- 23 files changed, 129 insertions(+), 70 deletions(-) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/{CrmContactTransferReqVO.java => CrmTransferContactReqVO.java} (96%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/{CrmContractTransferReqVO.java => CrmTransferContractReqVO.java} (59%) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmTransferCustomerReqVO.java diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java index 754bcd7cf..efff25372 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/business/CrmBusinessController.java @@ -92,7 +92,7 @@ public class CrmBusinessController { @Operation(summary = "商机转移") @PreAuthorize("@ss.hasPermission('crm:business:update')") public CommonResult transfer(@Valid @RequestBody CrmTransferBusinessReqVO reqVO) { - businessService.businessTransfer(reqVO, getLoginUserId()); + businessService.transferBusiness(reqVO, getLoginUserId()); return success(true); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java index 98ee287ad..a1872a57a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java @@ -100,8 +100,8 @@ public class ContactController { @PutMapping("/transfer") @Operation(summary = "联系人转移") @PreAuthorize("@ss.hasPermission('crm:contact:update')") - public CommonResult transfer(@Valid @RequestBody CrmContactTransferReqVO reqVO) { - contactService.contactTransfer(reqVO, getLoginUserId()); + public CommonResult transfer(@Valid @RequestBody CrmTransferContactReqVO reqVO) { + contactService.transferContact(reqVO, getLoginUserId()); return success(true); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmTransferContactReqVO.java similarity index 96% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmTransferContactReqVO.java index db4926e8c..bf58080b3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmContactTransferReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmTransferContactReqVO.java @@ -7,7 +7,7 @@ import javax.validation.constraints.NotNull; @Schema(description = "管理后台 - 联系人转移 Request VO") @Data -public class CrmContactTransferReqVO { +public class CrmTransferContactReqVO { @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/contract/ContractController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/ContractController.java index 3372eb6a3..ae2f0eb61 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/ContractController.java @@ -90,8 +90,8 @@ public class ContractController { @PutMapping("/transfer") @Operation(summary = "合同转移") @PreAuthorize("@ss.hasPermission('crm:contract:update')") - public CommonResult transfer(@Valid @RequestBody CrmContractTransferReqVO reqVO) { - contractService.contractTransfer(reqVO, getLoginUserId()); + public CommonResult transfer(@Valid @RequestBody CrmTransferContractReqVO reqVO) { + contractService.transferContract(reqVO, getLoginUserId()); return success(true); } 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/CrmTransferContractReqVO.java similarity index 59% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmContractTransferReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmTransferContractReqVO.java index b02834932..67a81ca8d 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/CrmTransferContractReqVO.java @@ -7,7 +7,7 @@ import javax.validation.constraints.NotNull; @Schema(description = "管理后台 - 合同转移 Request VO") @Data -public class CrmContractTransferReqVO { +public class CrmTransferContractReqVO { @Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") @NotNull(message = "合同编号不能为空") @@ -17,4 +17,12 @@ public class CrmContractTransferReqVO { @NotNull(message = "新负责人的用户编号不能为空") private Long ownerUserId; + @Schema(description = "原负责人移除方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "原负责人移除方式不能为空") + private Integer transferType; + + @Schema(description = "权限类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "权限类型不能为空") + private Integer permissionType; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java index 78ae1a20d..4977ef10f 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java @@ -23,6 +23,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; @Tag(name = "管理后台 - 客户") @RestController @@ -37,7 +38,7 @@ public class CrmCustomerController { @Operation(summary = "创建客户") @PreAuthorize("@ss.hasPermission('crm:customer:create')") public CommonResult createCustomer(@Valid @RequestBody CrmCustomerCreateReqVO createReqVO) { - return success(customerService.createCustomer(createReqVO)); + return success(customerService.createCustomer(createReqVO, getLoginUserId())); } @PutMapping("/update") @@ -86,4 +87,12 @@ public class CrmCustomerController { ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerExcelVO.class, datas); } + @PutMapping("/transfer") + @Operation(summary = "客户转移") + @PreAuthorize("@ss.hasPermission('crm:customer:update')") + public CommonResult transfer(@Valid @RequestBody CrmTransferCustomerReqVO reqVO) { + customerService.transferCustomer(reqVO, getLoginUserId()); + return success(true); + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmTransferCustomerReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmTransferCustomerReqVO.java new file mode 100644 index 000000000..b452c50e9 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmTransferCustomerReqVO.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Schema(description = "管理后台 - 客户转移 Request VO") +@Data +public class CrmTransferCustomerReqVO { + + @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "客户编号不能为空") + private Long id; + + @Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "新负责人的用户编号不能为空") + private Long ownerUserId; + + @Schema(description = "原负责人移除方式", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "原负责人移除方式不能为空") + private Integer transferType; + + @Schema(description = "权限类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430") + @NotNull(message = "权限类型不能为空") + private Integer permissionType; + +} 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 48ebb7d02..9f0e3da36 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 @@ -37,6 +37,6 @@ public interface ContactConvert { @Mapping(target = "userId", source = "userId"), @Mapping(target = "crmDataId", source = "reqVO.id") }) - TransferCrmPermissionBO convert(CrmContactTransferReqVO reqVO, Long userId); + TransferCrmPermissionBO convert(CrmTransferContactReqVO reqVO, Long userId); } 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 c962fcd55..bad9fa573 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 @@ -37,6 +37,6 @@ public interface ContractConvert { @Mapping(target = "userId", source = "userId"), @Mapping(target = "crmDataId", source = "reqVO.id") }) - TransferCrmPermissionBO convert(CrmContractTransferReqVO reqVO, Long userId); + TransferCrmPermissionBO convert(CrmTransferContractReqVO reqVO, Long userId); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java index 937705d99..7072536f5 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java @@ -1,13 +1,15 @@ package cn.iocoder.yudao.module.crm.convert.customer; -import java.util.*; - import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; +import cn.iocoder.yudao.module.crm.service.permission.bo.TransferCrmPermissionBO; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; /** * 客户 Convert @@ -29,4 +31,10 @@ public interface CrmCustomerConvert { List convertList02(List list); + @Mappings({ + @Mapping(target = "userId", source = "userId"), + @Mapping(target = "crmDataId", source = "reqVO.id") + }) + TransferCrmPermissionBO convert(CrmTransferCustomerReqVO reqVO, Long userId); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java index 8437337f4..8f9fea6c3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/clue/CrmClueMapper.java @@ -1,13 +1,14 @@ package cn.iocoder.yudao.module.crm.dal.mysql.clue; -import java.util.*; - import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 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.clue.vo.CrmClueExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO; import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*; + +import java.util.List; /** * 线索 Mapper @@ -35,7 +36,6 @@ public interface CrmClueMapper extends BaseMapperX { .likeIfPresent(CrmClueDO::getTelephone, reqVO.getTelephone()) .likeIfPresent(CrmClueDO::getMobile, reqVO.getMobile()) .likeIfPresent(CrmClueDO::getAddress, reqVO.getAddress()) - .eqIfPresent(CrmClueDO::getOwnerUserId, reqVO.getOwnerUserId()) .betweenIfPresent(CrmClueDO::getContactLastTime, reqVO.getContactLastTime()) .betweenIfPresent(CrmClueDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(CrmClueDO::getId)); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java index dfefeba5d..7643e4d4c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contact/ContactMapper.java @@ -1,13 +1,14 @@ package cn.iocoder.yudao.module.crm.dal.mysql.contact; -import java.util.*; - import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 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.contact.vo.ContactExportReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.ContactPageReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.contact.ContactDO; import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*; + +import java.util.List; /** * crm联系人 Mapper @@ -28,7 +29,6 @@ public interface ContactMapper extends BaseMapperX { .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId()) .eqIfPresent(ContactDO::getAddress, reqVO.getAddress()) .eqIfPresent(ContactDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId()) .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime()) .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime()) .orderByDesc(ContactDO::getId)); @@ -45,7 +45,6 @@ public interface ContactMapper extends BaseMapperX { .eqIfPresent(ContactDO::getCustomerId, reqVO.getCustomerId()) .eqIfPresent(ContactDO::getAddress, reqVO.getAddress()) .eqIfPresent(ContactDO::getRemark, reqVO.getRemark()) - .eqIfPresent(ContactDO::getOwnerUserId, reqVO.getOwnerUserId()) .betweenIfPresent(ContactDO::getCreateTime, reqVO.getCreateTime()) .betweenIfPresent(ContactDO::getLastTime, reqVO.getLastTime()) .orderByDesc(ContactDO::getId)); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java index 233b6603a..63baad383 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessService.java @@ -76,6 +76,6 @@ public interface CrmBusinessService { * @param reqVO 请求 * @param userId 用户编号 */ - void businessTransfer(CrmTransferBusinessReqVO reqVO, Long userId); + void transferBusiness(CrmTransferBusinessReqVO reqVO, Long userId); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java index 250f01492..2885e862d 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java @@ -12,7 +12,6 @@ import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; import cn.iocoder.yudao.module.crm.framework.enums.OperationTypeEnum; import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateBO; -import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; @@ -36,8 +35,6 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { @Resource private CrmBusinessMapper businessMapper; - @Resource - private AdminUserApi adminUserApi; @Resource private CrmPermissionService crmPermissionService; @@ -111,7 +108,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { @Override @Transactional(rollbackFor = Exception.class) - public void businessTransfer(CrmTransferBusinessReqVO reqVO, Long userId) { + public void transferBusiness(CrmTransferBusinessReqVO reqVO, Long userId) { // 1 校验商机是否存在 validateBusinessExists(reqVO.getId()); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java index a66edc650..6da77138e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactService.java @@ -76,6 +76,6 @@ public interface ContactService { * @param reqVO 请求 * @param userId 用户编号 */ - void contactTransfer(CrmContactTransferReqVO reqVO, Long userId); + void transferContact(CrmTransferContactReqVO reqVO, Long userId); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java index d39ada967..aea47ecb4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/ContactServiceImpl.java @@ -109,7 +109,7 @@ public class ContactServiceImpl implements ContactService { } @Override - public void contactTransfer(CrmContactTransferReqVO reqVO, Long userId) { + public void transferContact(CrmTransferContactReqVO reqVO, Long userId) { // 1 校验联系人是否存在 validateContactExists(reqVO.getId()); 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 index 969f77851..8cf41c152 100644 --- 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 @@ -76,6 +76,6 @@ public interface ContractService { * @param reqVO 请求 * @param userId 用户编号 */ - void contractTransfer(CrmContractTransferReqVO reqVO, Long userId); + void transferContract(CrmTransferContractReqVO 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/ContractServiceImpl.java index f07911455..fa3940f6a 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/ContractServiceImpl.java @@ -107,7 +107,7 @@ public class ContractServiceImpl implements ContractService { @Override @Transactional(rollbackFor = Exception.class) - public void contractTransfer(CrmContractTransferReqVO reqVO, Long userId) { + public void transferContract(CrmTransferContractReqVO reqVO, Long userId) { // 1 校验合同是否存在 validateContractExists(reqVO.getId()); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java index 73c6af2b6..576a9bcbc 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerService.java @@ -1,10 +1,7 @@ package cn.iocoder.yudao.module.crm.service.customer; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; import javax.validation.Valid; @@ -22,9 +19,10 @@ public interface CrmCustomerService { * 创建客户 * * @param createReqVO 创建信息 + * @param userId 用户编号 * @return 编号 */ - Long createCustomer(@Valid CrmCustomerCreateReqVO createReqVO); + Long createCustomer(@Valid CrmCustomerCreateReqVO createReqVO, Long userId); /** * 更新客户 @@ -80,4 +78,12 @@ public interface CrmCustomerService { */ CrmCustomerDO validateCustomer(Long customerId); + /** + * 客户转移 + * + * @param reqVO 请求 + * @param userId 用户编号 + */ + void transferCustomer(CrmTransferCustomerReqVO reqVO, Long userId); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java index 15535f681..879425a1c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java @@ -3,15 +3,18 @@ package cn.iocoder.yudao.module.crm.service.customer; 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.customer.vo.CrmCustomerCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*; import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper; +import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; +import cn.iocoder.yudao.module.crm.framework.enums.CrmEnum; +import cn.iocoder.yudao.module.crm.framework.enums.OperationTypeEnum; +import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; +import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateBO; import cn.iocoder.yudao.module.system.api.dept.DeptApi; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; @@ -35,17 +38,26 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { private CrmCustomerMapper customerMapper; @Resource private DeptApi deptApi; // TODO @wanwan:拼接数据,可以放到 controller;所以这里的引入,可以考虑放到 controller 哈; + @Resource + private CrmPermissionService crmPermissionService; @Override - public Long createCustomer(CrmCustomerCreateReqVO createReqVO) { + public Long createCustomer(CrmCustomerCreateReqVO createReqVO, Long userId) { // 插入 CrmCustomerDO customer = CrmCustomerConvert.INSTANCE.convert(createReqVO); customerMapper.insert(customer); + + // 创建数据权限 + crmPermissionService.createCrmPermission(new CrmPermissionCreateBO().setCrmType(CrmEnum.CRM_CUSTOMER.getType()) + .setCrmDataId(customer.getId()).setOwnerUserId(userId)); // 设置当前操作的人为负责人 + // 返回 return customer.getId(); } @Override + @Transactional(rollbackFor = Exception.class) + @CrmPermission(crmType = CrmEnum.CRM_CUSTOMER, operationType = OperationTypeEnum.UPDATE) public void updateCustomer(CrmCustomerUpdateReqVO updateReqVO) { // 校验存在 validateCustomerExists(updateReqVO.getId()); @@ -57,6 +69,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { } @Override + @Transactional(rollbackFor = Exception.class) + @CrmPermission(crmType = CrmEnum.CRM_CUSTOMER, operationType = OperationTypeEnum.DELETE) public void deleteCustomer(Long id) { // 校验存在 validateCustomerExists(id); @@ -73,6 +87,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { } @Override + @CrmPermission(crmType = CrmEnum.CRM_CUSTOMER, operationType = OperationTypeEnum.READ) public CrmCustomerDO getCustomer(Long id) { return customerMapper.selectById(id); } @@ -112,4 +127,15 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { return customer; } + @Override + @Transactional(rollbackFor = Exception.class) + public void transferCustomer(CrmTransferCustomerReqVO reqVO, Long userId) { + // 1 校验合同是否存在 + validateCustomer(reqVO.getId()); + + // 2. 数据权限转移 + crmPermissionService.transferCrmPermission( + CrmCustomerConvert.INSTANCE.convert(reqVO, userId).setCrmType(CrmEnum.CRM_CUSTOMER.getType())); + } + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java index b37563ada..9f199954e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java @@ -115,10 +115,7 @@ public class CrmBusinessServiceImplTest extends BaseDbUnitTest { o.setDiscountPercent(null); o.setProductPrice(null); o.setRemark(null); - o.setOwnerUserId(null); o.setCreateTime(null); - o.setRoUserIds(null); - o.setRwUserIds(null); o.setEndStatus(null); o.setEndRemark(null); o.setContactLastTime(null); @@ -145,14 +142,8 @@ public class CrmBusinessServiceImplTest extends BaseDbUnitTest { businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setProductPrice(null))); // 测试 remark 不匹配 businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRemark(null))); - // 测试 ownerUserId 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setOwnerUserId(null))); // 测试 createTime 不匹配 businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCreateTime(null))); - // 测试 roUserIds 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRoUserIds(null))); - // 测试 rwUserIds 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRwUserIds(null))); // 测试 endStatus 不匹配 businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndStatus(null))); // 测试 endRemark 不匹配 @@ -205,10 +196,7 @@ public class CrmBusinessServiceImplTest extends BaseDbUnitTest { o.setDiscountPercent(null); o.setProductPrice(null); o.setRemark(null); - o.setOwnerUserId(null); o.setCreateTime(null); - o.setRoUserIds(null); - o.setRwUserIds(null); o.setEndStatus(null); o.setEndRemark(null); o.setContactLastTime(null); @@ -235,14 +223,8 @@ public class CrmBusinessServiceImplTest extends BaseDbUnitTest { businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setProductPrice(null))); // 测试 remark 不匹配 businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRemark(null))); - // 测试 ownerUserId 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setOwnerUserId(null))); // 测试 createTime 不匹配 businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCreateTime(null))); - // 测试 roUserIds 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRoUserIds(null))); - // 测试 rwUserIds 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRwUserIds(null))); // 测试 endStatus 不匹配 businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndStatus(null))); // 测试 endRemark 不匹配 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java index 63a838164..4757e921d 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/clue/CrmClueServiceImplTest.java @@ -115,7 +115,6 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { o.setTelephone(null); o.setMobile(null); o.setAddress(null); - o.setOwnerUserId(null); o.setContactLastTime(null); o.setCreateTime(null); }); @@ -136,8 +135,6 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null))); // 测试 address 不匹配 clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null))); - // 测试 ownerUserId 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setOwnerUserId(null))); // 测试 contactLastTime 不匹配 clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null))); // 测试 createTime 不匹配 @@ -169,7 +166,6 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { o.setTelephone(null); o.setMobile(null); o.setAddress(null); - o.setOwnerUserId(null); o.setContactLastTime(null); o.setCreateTime(null); }); @@ -190,8 +186,6 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest { clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setMobile(null))); // 测试 address 不匹配 clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setAddress(null))); - // 测试 ownerUserId 不匹配 - clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setOwnerUserId(null))); // 测试 contactLastTime 不匹配 clueMapper.insert(cloneIgnoreId(dbClue, o -> o.setContactLastTime(null))); // 测试 createTime 不匹配 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java index aa188f06a..41dd14f92 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java @@ -16,6 +16,7 @@ import javax.annotation.Resource; import java.util.List; import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; @@ -24,6 +25,7 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_ import static org.junit.jupiter.api.Assertions.*; // TODO 芋艿:单测后续补 + /** * {@link CrmCustomerServiceImpl} 的单元测试类 * @@ -44,7 +46,7 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest { CrmCustomerCreateReqVO reqVO = randomPojo(CrmCustomerCreateReqVO.class); // 调用 - Long customerId = customerService.createCustomer(reqVO); + Long customerId = customerService.createCustomer(reqVO, getLoginUserId()); // 断言 assertNotNull(customerId); // 校验记录的属性是否正确 From 4dab376ca968941b99ca75029193698ae36f00fb Mon Sep 17 00:00:00 2001 From: "zhijiantianya@gmail.com" Date: Mon, 30 Oct 2023 19:28:33 +0800 Subject: [PATCH 044/101] =?UTF-8?q?code=20review=EF=BC=9A=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=9D=83=E9=99=90=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao/module/crm/enums/ErrorCodeConstants.java | 1 + .../module/crm/enums/common/TransferTypeEnum.java | 2 ++ .../admin/contact/ContactController.java | 2 +- .../admin/contact/vo/ContactCreateReqVO.java | 2 +- .../admin/contact/vo/ContactExportReqVO.java | 2 +- .../admin/contact/vo/ContactPageReqVO.java | 2 +- .../controller/admin/contact/vo/ContactRespVO.java | 2 +- .../admin/contact/vo/ContactUpdateReqVO.java | 2 +- .../admin/contact/vo/CrmTransferContactReqVO.java | 2 +- .../admin/contract/ContractController.java | 2 +- .../controller/admin/contract/package-info.java | 4 ---- .../admin/contract/vo/ContractCreateReqVO.java | 2 +- .../admin/contract/vo/ContractExcelVO.java | 2 +- .../admin/contract/vo/ContractExportReqVO.java | 2 +- .../admin/contract/vo/ContractPageReqVO.java | 2 +- .../admin/contract/vo/ContractRespVO.java | 2 +- .../admin/contract/vo/ContractUpdateReqVO.java | 2 +- .../contract/vo/CrmTransferContractReqVO.java | 3 ++- .../admin/customer/CrmCustomerController.java | 2 +- .../admin/customer/vo/CrmCustomerCreateReqVO.java | 2 +- .../admin/customer/vo/CrmCustomerExcelVO.java | 2 +- .../admin/customer/vo/CrmCustomerExportReqVO.java | 2 +- .../admin/customer/vo/CrmCustomerPageReqVO.java | 2 +- .../admin/customer/vo/CrmCustomerRespVO.java | 2 +- .../admin/customer/vo/CrmCustomerUpdateReqVO.java | 2 +- .../customer/vo/CrmTransferCustomerReqVO.java | 2 +- .../admin/receivable/ReceivableController.java | 5 +---- .../admin/receivable/ReceivablePlanController.java | 5 +---- .../admin/receivable/vo/ReceivableCreateReqVO.java | 2 +- .../admin/receivable/vo/ReceivableExcelVO.java | 2 +- .../admin/receivable/vo/ReceivableExportReqVO.java | 2 +- .../admin/receivable/vo/ReceivablePageReqVO.java | 2 +- .../receivable/vo/ReceivablePlanCreateReqVO.java | 2 +- .../admin/receivable/vo/ReceivablePlanExcelVO.java | 8 ++------ .../receivable/vo/ReceivablePlanExportReqVO.java | 2 +- .../receivable/vo/ReceivablePlanPageReqVO.java | 2 +- .../admin/receivable/vo/ReceivablePlanRespVO.java | 2 +- .../receivable/vo/ReceivablePlanUpdateReqVO.java | 2 +- .../admin/receivable/vo/ReceivableRespVO.java | 2 +- .../admin/receivable/vo/ReceivableUpdateReqVO.java | 2 +- .../module/crm/convert/contact/ContactConvert.java | 2 +- .../framework/core/aop/CrmPermissionAspect.java | 9 ++++++--- .../yudao/module/crm/framework/enums/CrmEnum.java | 1 + .../crm/framework/enums/OperationTypeEnum.java | 2 ++ .../service/customer/CrmCustomerServiceImpl.java | 6 +++--- .../service/permission/CrmPermissionService.java | 1 + .../permission/CrmPermissionServiceImpl.java | 14 ++++++++++---- .../permission/bo/CrmPermissionCreateBO.java | 4 ++++ .../permission/bo/CrmPermissionUpdateBO.java | 2 ++ .../permission/bo/TransferCrmPermissionBO.java | 11 ++++++++--- 50 files changed, 80 insertions(+), 66 deletions(-) delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/package-info.java diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index aba62797d..0977faa70 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -34,6 +34,7 @@ public interface ErrorCodeConstants { // ========== 客户管理 1_020_006_000 ========== ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(1_020_006_000, "客户不存在"); + // TODO @puhui999:权限管理??? // ========== 客户管理 1_020_007_000 ========== ErrorCode CRM_PERMISSION_NOT_EXISTS = new ErrorCode(1_020_007_000, "数据权限不存在"); ErrorCode CRM_PERMISSION_DENIED = new ErrorCode(1_020_007_001, "{}操作失败,原因:没有权限"); diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/TransferTypeEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/TransferTypeEnum.java index d12ce71db..7a4396265 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/TransferTypeEnum.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/common/TransferTypeEnum.java @@ -6,6 +6,7 @@ import lombok.Getter; import java.util.Arrays; +// TODO @puhui999:这个可以不用哈 /** * Crm 负责人转移后原负责人的处理方式 * @@ -17,6 +18,7 @@ public enum TransferTypeEnum implements IntArrayValuable { REMOVE(1, "移除"), TEAM(2, "转为团队成员"); + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(TransferTypeEnum::getType).toArray(); /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java index a1872a57a..cda6b29b9 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/ContactController.java @@ -26,7 +26,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -@Tag(name = "管理后台 - crm联系人") +@Tag(name = "管理后台 - CRM 联系人") @RestController @RequestMapping("/crm/contact") @Validated diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java index 9f4d8ec2c..5eccfea74 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactCreateReqVO.java @@ -5,7 +5,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Schema(description = "管理后台 - crm联系人创建 Request VO") +@Schema(description = "管理后台 - CRM 联系人创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExportReqVO.java index df4bd59e1..961cebd0c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExportReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactExportReqVO.java @@ -9,7 +9,7 @@ import org.springframework.format.annotation.DateTimeFormat; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -@Schema(description = "管理后台 - crm联系人 Excel 导出 Request VO,参数和 ContactPageReqVO 是一致的") +@Schema(description = "管理后台 - CRM 联系人 Excel 导出 Request VO,参数和 ContactPageReqVO 是一致的") @Data public class ContactExportReqVO { diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java index 31ad2a1fb..64d8a04b9 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactPageReqVO.java @@ -11,7 +11,7 @@ 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") +@Schema(description = "管理后台 - CRM 联系人分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactRespVO.java index acb6a737d..6a02c69d2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactRespVO.java @@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.time.LocalDateTime; -@Schema(description = "管理后台 - crm联系人 Response VO") +@Schema(description = "管理后台 - CRM 联系人 Response VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java index f319b52f0..d2621fa5e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/ContactUpdateReqVO.java @@ -5,7 +5,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Schema(description = "管理后台 - crm联系人更新 Request VO") +@Schema(description = "管理后台 - CRM 联系人更新 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmTransferContactReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmTransferContactReqVO.java index bf58080b3..1e16d2d20 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmTransferContactReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/vo/CrmTransferContactReqVO.java @@ -5,7 +5,7 @@ import lombok.Data; import javax.validation.constraints.NotNull; -@Schema(description = "管理后台 - 联系人转移 Request VO") +@Schema(description = "管理后台 - CRM 联系人转移 Request VO") @Data public class CrmTransferContactReqVO { 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/ContractController.java index ae2f0eb61..d875b21e3 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/ContractController.java @@ -25,7 +25,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -@Tag(name = "管理后台 - 合同") +@Tag(name = "管理后台 - CRM 合同") @RestController @RequestMapping("/crm/contract") @Validated diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/package-info.java deleted file mode 100644 index b2f4b7b4a..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 合同 - */ -package cn.iocoder.yudao.module.crm.controller.admin.contract; 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/ContractCreateReqVO.java index b21007f47..7793d7737 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/ContractCreateReqVO.java @@ -5,7 +5,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Schema(description = "管理后台 - 合同创建 Request VO") +@Schema(description = "管理后台 - CRM 合同创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) 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/ContractExcelVO.java index 895ac821a..2fb521321 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/ContractExcelVO.java @@ -6,7 +6,7 @@ import lombok.Data; import java.time.LocalDateTime; /** - * 合同 Excel VO + * CRM 合同 Excel VO * * @author dhb52 */ 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 index 8de3b4c1b..003e1f57c 100644 --- 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 @@ -8,7 +8,7 @@ import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -@Schema(description = "管理后台 - 合同 Excel 导出 Request VO,参数和 ContractPageReqVO 是一致的") +@Schema(description = "管理后台 - CRM 合同 Excel 导出 Request VO,参数和 ContractPageReqVO 是一致的") @Data public class ContractExportReqVO { 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/ContractPageReqVO.java index 01562be1b..36c7e14be 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/ContractPageReqVO.java @@ -11,7 +11,7 @@ import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -@Schema(description = "管理后台 - 合同分页 Request VO") +@Schema(description = "管理后台 - CRM 合同分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) 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 a0ab1d248..4a22251b0 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 @@ -7,7 +7,7 @@ import lombok.ToString; import java.time.LocalDateTime; -@Schema(description = "管理后台 - 合同 Response VO") +@Schema(description = "管理后台 - CRM 合同 Response VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) 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/ContractUpdateReqVO.java index ba38ca383..34a9797f4 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/ContractUpdateReqVO.java @@ -7,7 +7,7 @@ import lombok.ToString; import javax.validation.constraints.NotNull; -@Schema(description = "管理后台 - 合同更新 Request VO") +@Schema(description = "管理后台 - CRM 合同更新 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmTransferContractReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmTransferContractReqVO.java index 67a81ca8d..a987c9f89 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmTransferContractReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/vo/CrmTransferContractReqVO.java @@ -5,7 +5,8 @@ import lombok.Data; import javax.validation.constraints.NotNull; -@Schema(description = "管理后台 - 合同转移 Request VO") +// TODO @puhui999:CrmContractTransferReqVO,模块名字要放前面;看看还有没其它类似的 +@Schema(description = "管理后台 - CRM 合同转移 Request VO") @Data public class CrmTransferContractReqVO { diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java index 4977ef10f..ff144ffbf 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java @@ -25,7 +25,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -@Tag(name = "管理后台 - 客户") +@Tag(name = "管理后台 - CRM 客户") @RestController @RequestMapping("/crm/customer") @Validated diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java index 84462ddfa..38108776a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerCreateReqVO.java @@ -5,7 +5,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Schema(description = "管理后台 - 客户创建 Request VO") +@Schema(description = "管理后台 - CRM 客户创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java index 0fee3df4c..6f8156175 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExcelVO.java @@ -11,7 +11,7 @@ import java.time.LocalDateTime; // TODO 芋艿:导出最后做,等基本确认的差不多之后; /** - * 客户 Excel VO + * CRM 客户 Excel VO * * @author Wanwan */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java index 03a3f2d4d..3a37c2834 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerExportReqVO.java @@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; // TODO 芋艿:导出最后做,等基本确认的差不多之后; -@Schema(description = "管理后台 - 客户 Excel 导出 Request VO,参数和 CrmCustomerPageReqVO 是一致的") +@Schema(description = "管理后台 - CRM 客户 Excel 导出 Request VO,参数和 CrmCustomerPageReqVO 是一致的") @Data public class CrmCustomerExportReqVO { diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java index 8bf2018f1..e8a0b9e71 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerPageReqVO.java @@ -6,7 +6,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -@Schema(description = "管理后台 - 客户分页 Request VO") +@Schema(description = "管理后台 - CRM 客户分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java index bdcf28f2c..505221dfd 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerRespVO.java @@ -10,7 +10,7 @@ import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -@Schema(description = "管理后台 - 客户 Response VO") +@Schema(description = "管理后台 - CRM 客户 Response VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java index 545643fd9..6ed1566b3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerUpdateReqVO.java @@ -7,7 +7,7 @@ import lombok.ToString; import javax.validation.constraints.NotNull; -@Schema(description = "管理后台 - 客户更新 Request VO") +@Schema(description = "管理后台 - CRM 客户更新 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmTransferCustomerReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmTransferCustomerReqVO.java index b452c50e9..78ca15aca 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmTransferCustomerReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmTransferCustomerReqVO.java @@ -5,7 +5,7 @@ import lombok.Data; import javax.validation.constraints.NotNull; -@Schema(description = "管理后台 - 客户转移 Request VO") +@Schema(description = "管理后台 - CRM 客户转移 Request VO") @Data public class CrmTransferCustomerReqVO { diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java index 564e06bdb..c88f31f6d 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java @@ -24,10 +24,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -/** - * @author 赤焰 - */ -@Tag(name = "管理后台 - 回款管理") +@Tag(name = "管理后台 - CRM 回款管理") @RestController @RequestMapping("/crm/receivable") @Validated diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java index 9bf8d916a..0c33eb25a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java @@ -24,10 +24,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -/** - * @author 赤焰 - */ -@Tag(name = "管理后台 - 回款计划") +@Tag(name = "管理后台 - CRM 回款计划") @RestController @RequestMapping("/crm/receivable-plan") @Validated diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java index 5bbb4fce2..d38d0bd5f 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java @@ -5,7 +5,7 @@ import java.util.*; import io.swagger.v3.oas.annotations.media.Schema; import javax.validation.constraints.*; -@Schema(description = "管理后台 - 回款管理创建 Request VO") +@Schema(description = "管理后台 - CRM 回款创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java index f60330c53..b525341d3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java @@ -14,7 +14,7 @@ import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; /** - * 回款管理 Excel VO + * CRM 回款管理 Excel VO * * @author 赤焰 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java index 7ea31a0fb..4a9a033f3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java @@ -12,7 +12,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ /** * @author 赤焰 */ -@Schema(description = "管理后台 - 回款管理 Excel 导出 Request VO,参数和 ReceivablePageReqVO 是一致的") +@Schema(description = "管理后台 - CRM 回款 Excel 导出 Request VO,参数和 ReceivablePageReqVO 是一致的") @Data public class ReceivableExportReqVO { diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java index 7abd7cb39..ba4775535 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java @@ -12,7 +12,7 @@ import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -@Schema(description = "管理后台 - 回款管理分页 Request VO") +@Schema(description = "管理后台 - CRM 回款分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanCreateReqVO.java index 0d4fce3c8..d03e76eb0 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanCreateReqVO.java @@ -5,7 +5,7 @@ import java.util.*; import io.swagger.v3.oas.annotations.media.Schema; import javax.validation.constraints.*; -@Schema(description = "管理后台 - 回款计划创建 Request VO") +@Schema(description = "管理后台 - CRM 回款计划创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java index e12d5a1df..f0b822115 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java @@ -1,13 +1,9 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; -import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; -import java.util.*; + import java.math.BigDecimal; import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; import com.alibaba.excel.annotation.ExcelProperty; import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; @@ -15,7 +11,7 @@ import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; /** - * 回款计划 Excel VO + * CRM 回款计划 Excel VO * * @author 芋道源码 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java index ca5d3f553..506ffa1ed 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java @@ -9,7 +9,7 @@ import org.springframework.format.annotation.DateTimeFormat; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -@Schema(description = "管理后台 - 回款计划 Excel 导出 Request VO,参数和 ReceivablePlanPageReqVO 是一致的") +@Schema(description = "管理后台 - CRM 回款计划 Excel 导出 Request VO,参数和 ReceivablePlanPageReqVO 是一致的") @Data public class ReceivablePlanExportReqVO { diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java index 2d0e7d5ae..16ad6353d 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java @@ -11,7 +11,7 @@ import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -@Schema(description = "管理后台 - 回款计划分页 Request VO") +@Schema(description = "管理后台 - CRM 回款计划分页 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanRespVO.java index d96f631de..ce49d5977 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanRespVO.java @@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.time.LocalDateTime; -@Schema(description = "管理后台 - 回款计划 Response VO") +@Schema(description = "管理后台 - CRM 回款计划 Response VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanUpdateReqVO.java index 75f4ecca0..1f539537d 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanUpdateReqVO.java @@ -5,7 +5,7 @@ import lombok.*; import java.util.*; import javax.validation.constraints.*; -@Schema(description = "管理后台 - 回款计划更新 Request VO") +@Schema(description = "管理后台 - CRM 回款计划更新 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java index fd26e312e..1646cd5a8 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java @@ -4,7 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.time.LocalDateTime; -@Schema(description = "管理后台 - 回款管理 Response VO") +@Schema(description = "管理后台 - CRM 回款 Response VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java index 600b09943..008c06b63 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java @@ -5,7 +5,7 @@ import lombok.*; import java.util.*; import javax.validation.constraints.*; -@Schema(description = "管理后台 - 回款管理更新 Request VO") +@Schema(description = "管理后台 - CRM 回款更新 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) 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 9f0e3da36..11b549062 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 @@ -12,7 +12,7 @@ import org.mapstruct.factory.Mappers; import java.util.List; /** - * crm联系人 Convert + * crm 联系人 Convert * * @author 芋道源码 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java index dd25703e0..48d29c6c4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/core/aop/CrmPermissionAspect.java @@ -47,19 +47,21 @@ public class CrmPermissionAspect { try { Integer crmType = crmPermission.crmType().getType(); Integer operationType = crmPermission.operationType().getType(); + // TODO @puhui999:不一定是 id 参数噢;例如说,ContactServiceImpl 的 updateContact Long id = (Long) joinPoint.getArgs()[0];// 获取操作数据的编号 - // 1. 获取数据权限 + // 1.1 获取数据权限 CrmPermissionDO permission = crmPermissionService.getCrmPermissionByCrmTypeAndCrmDataId(crmType, id); if (permission == null) { // 不存在说明数据也不存在 throw exception(CRM_PERMISSION_MODEL_NOT_EXISTS, crmPermission.crmType().getName()); } - // 1.2. 校验是否为公海数据 + // 1.2 校验是否为公海数据 + // TODO @puhui999:这个判断去掉比较合适哈。这里更多是业务逻辑,不算权限判断。例如说,公海的客户,只要没负责人,就可以领取了; if (permission.getOwnerUserId() == null) { return; } - // 1.3. 校验当前负责人是不是自己 + // 1.3 校验当前负责人是不是自己 if (ObjUtil.equal(permission.getOwnerUserId(), getUserId())) { return; } @@ -68,6 +70,7 @@ public class CrmPermissionAspect { // 2. 校验是否有读权限 if (OperationTypeEnum.isRead(operationType)) { // 校验该数据当前用户是否可读 + // TODO @puhui999:直接 CollUtil.contains 就好,因为就是有某个 userId 呀 boolean isRead = CollUtil.contains(permission.getRoUserIds(), item -> ObjUtil.equal(item, getUserId())) || CollUtil.contains(permission.getRwUserIds(), item -> ObjUtil.equal(item, getUserId())); if (isRead) { diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/CrmEnum.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/CrmEnum.java index 62fd4d007..eb6110ec0 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/CrmEnum.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/CrmEnum.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjUtil; import lombok.Getter; import lombok.RequiredArgsConstructor; +// TODO @puhui999:可以改成 CrmBizTypeEnum,CRM 业务类型枚举 /** * Crm 类型枚举 * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/OperationTypeEnum.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/OperationTypeEnum.java index 3cc2e8b6e..893717154 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/OperationTypeEnum.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/enums/OperationTypeEnum.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjUtil; import lombok.Getter; import lombok.RequiredArgsConstructor; +// TODO @puhui999:是不是可以和 PermissionTypeEnum 合并,就是 CrmPermissionEnum,负责人、读取、读写;目前阶段,不用做的特别细致;类似 linux 的 acl; /** * Crm 数据操作类型枚举 * @@ -13,6 +14,7 @@ import lombok.RequiredArgsConstructor; @Getter public enum OperationTypeEnum { + // TODO @puhui999:抽象上,就分三种,会更合理。一个 OWNER 负责人,一个 READ 读,一个 WRITE 写; DELETE(1, "删除"), UPDATE(2, "修改"), READ(3, "查询"); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java index 879425a1c..e78717b2c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java @@ -115,8 +115,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { /** * 校验客户是否存在 * - * @param customerId 客户id - * @return + * @param customerId 客户 id + * @return 客户 */ @Override public CrmCustomerDO validateCustomer(Long customerId) { @@ -130,7 +130,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @Override @Transactional(rollbackFor = Exception.class) public void transferCustomer(CrmTransferCustomerReqVO reqVO, Long userId) { - // 1 校验合同是否存在 + // 1. 校验合同是否存在 validateCustomer(reqVO.getId()); // 2. 数据权限转移 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java index 91321b709..3203c06bc 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionService.java @@ -16,6 +16,7 @@ import javax.validation.Valid; */ public interface CrmPermissionService { + // TODO @puhui999:方法名上,不用 Crm /** * 创建数据权限 * diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java index 2647976bc..687de63ca 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/CrmPermissionServiceImpl.java @@ -41,6 +41,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { @Override @Transactional(rollbackFor = Exception.class) public Long createCrmPermission(CrmPermissionCreateBO createBO) { + // TODO @puhui999:createDO 改成 permission,保持统一哈; CrmPermissionDO createDO = CrmPermissionConvert.INSTANCE.convert(createBO); crmPermissionMapper.insert(createDO); return createDO.getId(); @@ -50,7 +51,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { @Transactional(rollbackFor = Exception.class) public void updateCrmPermission(CrmPermissionUpdateBO updateBO) { validateCrmPermissionExists(updateBO.getId()); - + // 更新操作 CrmPermissionDO updateDO = CrmPermissionConvert.INSTANCE.convert(updateBO); crmPermissionMapper.updateById(updateDO); } @@ -59,7 +60,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { @Transactional(rollbackFor = Exception.class) public void deleteCrmPermission(Long id) { validateCrmPermissionExists(id); - + // 删除 crmPermissionMapper.deleteById(id); } @@ -74,9 +75,11 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { return crmPermissionMapper.selectByCrmTypeAndCrmDataId(crmType, crmDataId); } + // TODO @puhui999:参数名,是不是 transferReqBO @Override public void transferCrmPermission(TransferCrmPermissionBO transferCrmPermissionBO) { - // 1 校验商机是否存在 + // 1.1 校验商机是否存在 + // TODO puhui999:这里直接调用 crmPermissionMapper 的 selectByCrmTypeAndCrmDataId 方法,会更简洁一点; CrmPermissionDO permission = getCrmPermissionByCrmTypeAndCrmDataId(transferCrmPermissionBO.getCrmType(), transferCrmPermissionBO.getCrmDataId()); String crmName = CrmEnum.getNameByType(transferCrmPermissionBO.getCrmType()); @@ -85,6 +88,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { } // 1.2 校验转移对象是否已经是该负责人 if (ObjUtil.equal(permission.getOwnerUserId(), permission.getOwnerUserId())) { + // TODO @puhui999:是不是这个错误码不太对。。。 throw exception(CRM_PERMISSION_MODEL_TRANSFER_FAIL_OWNER_USER_NOT_EXISTS, crmName); } // 1.3 校验新负责人是否存在 @@ -94,11 +98,12 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { } // TODO 校验是否为超级管理员 || 1.4 // 1.4 校验是否有写权限 + // TODO puhui999:CollUtil.contains 就够了,不用后面写个表达式; if (!CollUtil.contains(permission.getRwUserIds(), id -> ObjUtil.equal(id, transferCrmPermissionBO.getUserId()))) { throw exception(CRM_PERMISSION_DENIED, crmName); } - // 2 权限转移 + // 2. 权限转移 CrmPermissionDO updateCrmPermission = new CrmPermissionDO().setId(permission.getId()) .setOwnerUserId(transferCrmPermissionBO.getOwnerUserId()); if (ObjUtil.equal(TransferTypeEnum.TEAM.getType(), transferCrmPermissionBO.getTransferType())) { @@ -116,6 +121,7 @@ public class CrmPermissionServiceImpl implements CrmPermissionService { crmPermissionMapper.updateById(updateCrmPermission); // 3. TODO 记录机转移日志 + // TODO @puhui999:是不是交给业务记录哈; } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateBO.java index b7d693a18..e5dd5d6e9 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateBO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionCreateBO.java @@ -6,6 +6,7 @@ import lombok.Data; import javax.validation.constraints.NotNull; import java.util.Set; +// TODO @puhui999:,一个是 Crm 前缀,一个 Req 表示入参 /** * crm 数据权限 Create BO * @@ -14,6 +15,8 @@ import java.util.Set; @Data public class CrmPermissionCreateBO { + // TODO @puhui999:如果是关联字段,换一行写它的注释;不然看着略乱哈 + /** * Crm 类型 关联 {@link CrmEnum} */ @@ -24,6 +27,7 @@ public class CrmPermissionCreateBO { */ @NotNull(message = "Crm 数据编号不能为空") private Long crmDataId; + /** * 负责人的用户编号 关联 AdminUser#id, null 则为公海数据 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateBO.java index 6cad08e75..e8544a611 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateBO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/CrmPermissionUpdateBO.java @@ -7,6 +7,7 @@ import lombok.Data; import javax.validation.constraints.NotNull; import java.util.Set; +// TODO @puhui999:,一个是 Crm 前缀,一个 Req 表示入参 /** * crm 数据权限 Update BO * @@ -15,6 +16,7 @@ import java.util.Set; @Data public class CrmPermissionUpdateBO { + // TODO @puhui999:id 和 crmType + crmDataId 是不是重叠了; /** * 数据权限编号 {@link CrmPermissionDO#getId()} */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/TransferCrmPermissionBO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/TransferCrmPermissionBO.java index 2f3e94f38..246439bcb 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/TransferCrmPermissionBO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/permission/bo/TransferCrmPermissionBO.java @@ -7,6 +7,7 @@ import lombok.Data; import javax.validation.constraints.NotNull; +// TODO @puhui999:CrmTransferPermissionReqBO,一个是 Crm 前缀,一个 Req 表示入参 /** * 数据权限转移 BO * @@ -15,26 +16,30 @@ import javax.validation.constraints.NotNull; @Data public class TransferCrmPermissionBO { + // TODO @puhui999:参数的注释 @NotNull(message = "用户编号不能为空") private Long userId; + // TODO @puhui999:bizType /** - * Crm 类型 关联 {@link CrmEnum} + * Crm 类型 关联 {@link CrmEnum} TODO 这种不用再写关联了,直接 @InEnum 参数校验 */ @NotNull(message = "Crm 类型不能为空") private Integer crmType; + // TODO @puhui999:bizId /** - * 数据编号 关联 {@link CrmEnum} 对应模块 DO#getId() + * 数据编号 */ @NotNull(message = "Crm 数据编号不能为空") private Long crmDataId; + // TODO @puhui999:要不这里改成 newOwnerUserId;然后,transferType 和 permissionType,合并成 oldOwnerPermission(空就是移除) @NotNull(message = "新负责人的用户编号不能为空") private Long ownerUserId; /** - * 原负责人移除方式, 关联 {@link TransferTypeEnum} + * 原负责人移除方式, 关联 {@link TransferTypeEnum} TODO 这种不用再写关联了,直接 @InEnum 参数校验 */ @NotNull(message = "原负责人移除方式不能为空") private Integer transferType; From 921c2ab7571b3dc84cb1dff808a1f469d35178b4 Mon Sep 17 00:00:00 2001 From: liuhongfeng <291117974@qq.com> Date: Mon, 30 Oct 2023 21:33:28 +0800 Subject: [PATCH 045/101] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91?= =?UTF-8?q?=E8=B4=9F=E8=B4=A3=E4=BA=BA=20=E3=80=90=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E3=80=91=E8=A7=84=E8=8C=83=E5=91=BD=E5=90=8D=EF=BC=9A=E6=9C=9F?= =?UTF-8?q?=E6=95=B0=EF=BC=9AindexNo-=E3=80=8Bperiod?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 2 +- .../receivable/vo/ReceivablePlanBaseVO.java | 2 +- .../receivable/vo/ReceivablePlanExcelVO.java | 8 ++------ .../receivable/vo/ReceivablePlanExportReqVO.java | 5 ++--- .../receivable/vo/ReceivablePlanPageReqVO.java | 2 +- .../dataobject/receivable/ReceivablePlanDO.java | 8 +++----- .../mysql/receivable/ReceivablePlanMapper.java | 4 ++-- .../ReceivablePlanServiceImplTest.java | 16 ++++++++-------- 8 files changed, 20 insertions(+), 27 deletions(-) diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index de7922d24..8c662c238 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -41,7 +41,7 @@ CREATE TABLE `crm_receivable` ( DROP TABLE IF EXISTS `crm_receivable_plan`; CREATE TABLE `crm_receivable_plan` ( `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', - `index_no` bigint(20) NULL DEFAULT NULL COMMENT '期数', + `period` tinyint(4) DEFAULT NULL COMMENT '期数', `receivable_id` bigint(20) NULL DEFAULT NULL COMMENT '回款ID', `status` tinyint(4) NOT NULL COMMENT '完成状态', `check_status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '审批状态', diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java index 53572e2c4..b5ba20296 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java @@ -18,7 +18,7 @@ public class ReceivablePlanBaseVO { // TODO 芋艿:这个字段,在想想命名; @Schema(description = "期数") - private Long indexNo; + private Integer period; // TODO @liuhongfeng:中英文之间,有个空格,这样更干净; @Schema(description = "回款ID", example = "19852") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java index d08cfc6a7..0a3b2b7f8 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java @@ -1,13 +1,9 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; -import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; -import java.util.*; + import java.math.BigDecimal; import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; import com.alibaba.excel.annotation.ExcelProperty; import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; @@ -26,7 +22,7 @@ public class ReceivablePlanExcelVO { private Long id; @ExcelProperty("期数") - private Long indexNo; + private Integer period; @ExcelProperty("回款ID") private Long receivableId; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java index e68427d29..a9b505fe2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java @@ -1,9 +1,8 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; import lombok.*; -import java.util.*; import io.swagger.v3.oas.annotations.media.Schema; -import cn.iocoder.yudao.framework.common.pojo.PageParam; + import java.time.LocalDateTime; import org.springframework.format.annotation.DateTimeFormat; @@ -14,7 +13,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ public class ReceivablePlanExportReqVO { @Schema(description = "期数") - private Long indexNo; + private Integer period; @Schema(description = "完成状态", example = "2") private Integer status; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java index acd4d5aa4..37c0446c3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java @@ -20,7 +20,7 @@ public class ReceivablePlanPageReqVO extends PageParam { // TODO 芋艿:筛选字段,需要去掉几个,在想想; @Schema(description = "期数") - private Long indexNo; + private Integer period; @Schema(description = "完成状态", example = "2") private Integer status; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java index 0c6f6e033..56ef67962 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java @@ -1,12 +1,10 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; import lombok.*; -import java.util.*; + import java.math.BigDecimal; import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; -import java.time.LocalDateTime; + import com.baomidou.mybatisplus.annotation.*; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; @@ -33,7 +31,7 @@ public class ReceivablePlanDO extends BaseDO { /** * 期数 */ - private Long indexNo; + private Integer period; /** * 回款ID */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java index ac35133a7..3251c6787 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java @@ -19,7 +19,7 @@ public interface ReceivablePlanMapper extends BaseMapperX { default PageResult selectPage(ReceivablePlanPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ReceivablePlanDO::getIndexNo, reqVO.getIndexNo()) + .eqIfPresent(ReceivablePlanDO::getPeriod, reqVO.getPeriod()) .eqIfPresent(ReceivablePlanDO::getStatus, reqVO.getStatus()) .eqIfPresent(ReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus()) .betweenIfPresent(ReceivablePlanDO::getReturnTime, reqVO.getReturnTime()) @@ -35,7 +35,7 @@ public interface ReceivablePlanMapper extends BaseMapperX { default List selectList(ReceivablePlanExportReqVO reqVO) { return selectList(new LambdaQueryWrapperX() - .eqIfPresent(ReceivablePlanDO::getIndexNo, reqVO.getIndexNo()) + .eqIfPresent(ReceivablePlanDO::getPeriod, reqVO.getPeriod()) .eqIfPresent(ReceivablePlanDO::getStatus, reqVO.getStatus()) .eqIfPresent(ReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus()) .betweenIfPresent(ReceivablePlanDO::getReturnTime, reqVO.getReturnTime()) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java index 3739481c0..4f9fb8d26 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java @@ -107,7 +107,7 @@ public class ReceivablePlanServiceImplTest extends BaseDbUnitTest { public void testGetReceivablePlanPage() { // mock 数据 ReceivablePlanDO dbReceivablePlan = randomPojo(ReceivablePlanDO.class, o -> { // 等会查询到 - o.setIndexNo(null); + o.setPeriod(null); o.setStatus(null); o.setCheckStatus(null); o.setReturnTime(null); @@ -120,8 +120,8 @@ public class ReceivablePlanServiceImplTest extends BaseDbUnitTest { o.setCreateTime(null); }); receivablePlanMapper.insert(dbReceivablePlan); - // 测试 indexNo 不匹配 - receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setIndexNo(null))); + // 测试 Period 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setPeriod(null))); // 测试 status 不匹配 receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setStatus(null))); // 测试 checkStatus 不匹配 @@ -144,7 +144,7 @@ public class ReceivablePlanServiceImplTest extends BaseDbUnitTest { receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCreateTime(null))); // 准备参数 ReceivablePlanPageReqVO reqVO = new ReceivablePlanPageReqVO(); - reqVO.setIndexNo(null); + reqVO.setPeriod(null); reqVO.setStatus(null); reqVO.setCheckStatus(null); reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); @@ -169,7 +169,7 @@ public class ReceivablePlanServiceImplTest extends BaseDbUnitTest { public void testGetReceivablePlanList() { // mock 数据 ReceivablePlanDO dbReceivablePlan = randomPojo(ReceivablePlanDO.class, o -> { // 等会查询到 - o.setIndexNo(null); + o.setPeriod(null); o.setStatus(null); o.setCheckStatus(null); o.setReturnTime(null); @@ -182,8 +182,8 @@ public class ReceivablePlanServiceImplTest extends BaseDbUnitTest { o.setCreateTime(null); }); receivablePlanMapper.insert(dbReceivablePlan); - // 测试 indexNo 不匹配 - receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setIndexNo(null))); + // 测试 Period 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setPeriod(null))); // 测试 status 不匹配 receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setStatus(null))); // 测试 checkStatus 不匹配 @@ -206,7 +206,7 @@ public class ReceivablePlanServiceImplTest extends BaseDbUnitTest { receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCreateTime(null))); // 准备参数 ReceivablePlanExportReqVO reqVO = new ReceivablePlanExportReqVO(); - reqVO.setIndexNo(null); + reqVO.setPeriod(null); reqVO.setStatus(null); reqVO.setCheckStatus(null); reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); From f1f180ff77963f837acac390e94690cefcd05f95 Mon Sep 17 00:00:00 2001 From: liuhongfeng <291117974@qq.com> Date: Tue, 31 Oct 2023 00:35:41 +0800 Subject: [PATCH 046/101] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91?= =?UTF-8?q?=E5=AD=97=E5=85=B8=E5=BD=92=E7=B1=BB=20=E3=80=90=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E3=80=91=E8=A7=84=E8=8C=83=E5=AE=9E=E4=BD=93=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E5=92=8C=E5=AD=97=E6=AE=B5=E7=B1=BB=E5=9E=8B=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/DictTypeConstants.java | 1 + .../admin/receivable/vo/ReceivableBaseVO.java | 33 ++++--------------- .../receivable/vo/ReceivableExcelVO.java | 20 ++++------- .../receivable/vo/ReceivableExportReqVO.java | 21 +++--------- .../receivable/vo/ReceivablePageReqVO.java | 24 ++------------ .../receivable/vo/ReceivablePlanBaseVO.java | 30 ++++++----------- .../receivable/vo/ReceivablePlanExcelVO.java | 13 ++++---- .../vo/ReceivablePlanExportReqVO.java | 6 ++-- .../vo/ReceivablePlanPageReqVO.java | 15 ++------- .../dataobject/receivable/ReceivableDO.java | 17 +++++----- .../receivable/ReceivablePlanDO.java | 12 +++---- .../mysql/receivable/ReceivableMapper.java | 10 ------ .../receivable/ReceivablePlanMapper.java | 3 -- .../receivable/ReceivableServiceImpl.java | 9 ++++- .../ReceivablePlanServiceImplTest.java | 3 -- .../receivable/ReceivableServiceImplTest.java | 10 ------ 16 files changed, 64 insertions(+), 163 deletions(-) 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 0e412ee9b..71f550775 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,5 +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 审批状态 } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java index 8aa43e50b..1e7e7bd68 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java @@ -19,30 +19,22 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class ReceivableBaseVO { - // TODO @liuhongfeng:部分缺少 example 的字段,要补充下; - // TODO @liuhongfeng:部分字段,需要必传,要写 requiredMode = Schema.RequiredMode.REQUIRED,以及对应的 validator 非空校验 - - @Schema(description = "回款编号") + @Schema(description = "回款编号",requiredMode = Schema.RequiredMode.REQUIRED, example = "31177") private String no; - // TODO @liuhongfeng:中英文之间,有个空格,这样更干净; - @Schema(description = "回款计划ID", example = "31177") + @Schema(description = "回款计划", example = "31177") private Long planId; - @Schema(description = "客户ID", example = "4963") + @Schema(description = "客户名称", example = "4963") private Long customerId; - @Schema(description = "合同ID", example = "30305") + @Schema(description = "合同名称", example = "30305") private Long contractId; @Schema(description = "审批状态", example = "1") @InEnum(AuditStatusEnum.class) private Integer checkStatus; - // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; - @Schema(description = "工作流编号", example = "16568") - private Long processInstanceId; - @Schema(description = "回款日期") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime returnTime; @@ -50,9 +42,8 @@ public class ReceivableBaseVO { @Schema(description = "回款方式", example = "2") private String returnType; - // TODO @liuhongfeng:使用 Int 哈,分; @Schema(description = "回款金额", example = "31859") - private BigDecimal price; + private Integer price; @Schema(description = "负责人", example = "22202") private Long ownerUserId; @@ -63,19 +54,7 @@ public class ReceivableBaseVO { @Schema(description = "显示顺序") private Integer sort; - // TODO @芋艿:这个字段在看看;dataScope、dataScopeDeptIds - @Schema(description = "数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") - private Integer dataScope; - - @Schema(description = "数据范围(指定部门数组)") - private String dataScopeDeptIds; - - // TODO @liuhongfeng:这个字段,这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; - @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @NotNull(message = "状态不能为空") - private Integer status; - - @Schema(description = "备注", example = "随便") + @Schema(description = "备注", example = "备注") private String remark; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java index b525341d3..a88fa9fd9 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; +import cn.iocoder.yudao.module.system.enums.DictTypeConstants; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; @@ -30,14 +31,14 @@ public class ReceivableExcelVO { @ExcelProperty("回款计划ID") private Long planId; - @ExcelProperty("客户ID") + @ExcelProperty("客户名称") private Long customerId; - @ExcelProperty("合同ID") + @ExcelProperty("合同名称") private Long contractId; @ExcelProperty(value = "审批状态", converter = DictConvert.class) - @DictFormat("crm_receivable_check_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_RECEIVABLE_CHECK_STATUS) private Integer checkStatus; @ExcelProperty("工作流编号") @@ -50,7 +51,7 @@ public class ReceivableExcelVO { private String returnType; @ExcelProperty("回款金额") - private BigDecimal price; + private Integer price; @ExcelProperty("负责人") private Long ownerUserId; @@ -58,17 +59,8 @@ public class ReceivableExcelVO { @ExcelProperty("批次") private Long batchId; - //@ExcelProperty("显示顺序") - //private Integer sort; - - //@ExcelProperty("数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") - //private Integer dataScope; - - //@ExcelProperty("数据范围(指定部门数组)") - //private String dataScopeDeptIds; - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + @DictFormat(DictTypeConstants.COMMON_STATUS) private Integer status; @ExcelProperty("备注") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java index 4a9a033f3..f07e4ddf8 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java @@ -4,7 +4,6 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; -import java.math.BigDecimal; import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -19,21 +18,18 @@ public class ReceivableExportReqVO { @Schema(description = "回款编号") private String no; - @Schema(description = "回款计划ID", example = "31177") + @Schema(description = "回款计划", example = "31177") private Long planId; - @Schema(description = "客户ID", example = "4963") + @Schema(description = "客户名称", example = "4963") private Long customerId; - @Schema(description = "合同ID", example = "30305") + @Schema(description = "合同名称", example = "30305") private Long contractId; @Schema(description = "审批状态", example = "1") private Integer checkStatus; - @Schema(description = "工作流编号", example = "16568") - private Long processInstanceId; - @Schema(description = "回款日期") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] returnTime; @@ -42,7 +38,7 @@ public class ReceivableExportReqVO { private String returnType; @Schema(description = "回款金额", example = "31859") - private BigDecimal price; + private Integer price; @Schema(description = "负责人", example = "22202") private Long ownerUserId; @@ -50,15 +46,6 @@ public class ReceivableExportReqVO { @Schema(description = "批次", example = "2539") private Long batchId; - @Schema(description = "显示顺序") - private Integer sort; - - @Schema(description = "数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") - private Integer dataScope; - - @Schema(description = "数据范围(指定部门数组)") - private String dataScopeDeptIds; - @Schema(description = "状态", example = "1") private Integer status; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java index ba4775535..53cdc4949 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java @@ -18,25 +18,21 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class ReceivablePageReqVO extends PageParam { - // TODO @liuhongfeng:目前就使用 no 检索即可; @Schema(description = "回款编号") private String no; @Schema(description = "回款计划ID", example = "31177") private Long planId; - @Schema(description = "客户ID", example = "4963") + @Schema(description = "客户名称", example = "4963") private Long customerId; - @Schema(description = "合同ID", example = "30305") + @Schema(description = "合同名称", example = "30305") private Long contractId; @Schema(description = "审批状态", example = "1") private Integer checkStatus; - @Schema(description = "工作流编号", example = "16568") - private Long processInstanceId; - @Schema(description = "回款日期") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] returnTime; @@ -45,29 +41,15 @@ public class ReceivablePageReqVO extends PageParam { private String returnType; @Schema(description = "回款金额", example = "31859") - private BigDecimal price; + private Integer price; @Schema(description = "负责人", example = "22202") private Long ownerUserId; - @Schema(description = "批次", example = "2539") - private Long batchId; - - @Schema(description = "显示顺序") - private Integer sort; - - @Schema(description = "数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") - private Integer dataScope; - - @Schema(description = "数据范围(指定部门数组)") - private String dataScopeDeptIds; @Schema(description = "状态", example = "1") private Integer status; - @Schema(description = "备注", example = "随便") - private String remark; - @Schema(description = "创建时间") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] createTime; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java index b5ba20296..2bd05a64a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java @@ -1,10 +1,11 @@ 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 io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; -import java.math.BigDecimal; import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -16,57 +17,46 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class ReceivablePlanBaseVO { - // TODO 芋艿:这个字段,在想想命名; - @Schema(description = "期数") + @Schema(description = "期数", example = "1") private Integer period; - // TODO @liuhongfeng:中英文之间,有个空格,这样更干净; - @Schema(description = "回款ID", example = "19852") + @Schema(description = "回款计划", example = "19852") private Long receivableId; @Schema(description = "完成状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - //@NotNull(message = "完成状态不能为空") private Integer status; - // TODO @liuhongfeng:这个字段,可以写个枚举,然后 InEnum 去校验下; - // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的 @Schema(description = "审批状态", example = "1") + @InEnum(AuditStatusEnum.class) private Integer checkStatus; - // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; - @Schema(description = "工作流编号", example = "8909") - private Long processInstanceId; - - // TODO @liuhongfeng:使用 Int 哈,分; @Schema(description = "计划回款金额", example = "29675") - private BigDecimal price; + private Integer price; @Schema(description = "计划回款日期") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime returnTime; - // TODO @liuhongfeng:这个字段,Integer @Schema(description = "提前几天提醒") - private Long remindDays; + private Integer remindDays; @Schema(description = "提醒日期") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime remindTime; - @Schema(description = "客户ID", example = "18026") + @Schema(description = "客户名称", example = "18026") private Long customerId; - @Schema(description = "合同ID", example = "3473") + @Schema(description = "合同名称", example = "3473") private Long contractId; - // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; @Schema(description = "负责人", example = "17828") private Long ownerUserId; @Schema(description = "显示顺序") private Integer sort; - @Schema(description = "备注", example = "随便") + @Schema(description = "备注", example = "备注") private String remark; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java index e6646aa2d..2ff3fd0d3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; +import cn.iocoder.yudao.module.system.enums.DictTypeConstants; import lombok.*; import java.math.BigDecimal; @@ -27,25 +28,25 @@ public class ReceivablePlanExcelVO { @ExcelProperty("回款ID") private Long receivableId; - @ExcelProperty(value = "完成状态", converter = DictConvert.class) - @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + @ExcelProperty(value = "状态", converter = DictConvert.class) + @DictFormat(DictTypeConstants.COMMON_STATUS) private Integer status; @ExcelProperty(value = "审批状态", converter = DictConvert.class) - @DictFormat("crm_receivable_check_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_RECEIVABLE_CHECK_STATUS) private Integer checkStatus; //@ExcelProperty("工作流编号") //private Long processInstanceId; @ExcelProperty("计划回款金额") - private BigDecimal price; + private Integer price; @ExcelProperty("计划回款日期") private LocalDateTime returnTime; @ExcelProperty("提前几天提醒") - private Long remindDays; + private Integer remindDays; @ExcelProperty("提醒日期") private LocalDateTime remindTime; @@ -53,7 +54,7 @@ public class ReceivablePlanExcelVO { @ExcelProperty("客户ID") private Long customerId; - @ExcelProperty("合同ID") + @ExcelProperty("合同名称") private Long contractId; @ExcelProperty("负责人") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java index 694deb8fc..803e1ed03 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java @@ -26,16 +26,16 @@ public class ReceivablePlanExportReqVO { private LocalDateTime[] returnTime; @Schema(description = "提前几天提醒") - private Long remindDays; + private Integer remindDays; @Schema(description = "提醒日期") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] remindTime; - @Schema(description = "客户ID", example = "18026") + @Schema(description = "客户名称", example = "18026") private Long customerId; - @Schema(description = "合同ID", example = "3473") + @Schema(description = "合同名称", example = "3473") private Long contractId; @Schema(description = "负责人", example = "17828") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java index c445bee50..c92b4e891 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java @@ -17,11 +17,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @ToString(callSuper = true) public class ReceivablePlanPageReqVO extends PageParam { - // TODO 芋艿:筛选字段,需要去掉几个,在想想; - - @Schema(description = "期数") - private Integer period; - @Schema(description = "完成状态", example = "2") private Integer status; @@ -32,25 +27,19 @@ public class ReceivablePlanPageReqVO extends PageParam { @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] returnTime; - @Schema(description = "提前几天提醒") - private Long remindDays; - @Schema(description = "提醒日期") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] remindTime; - @Schema(description = "客户ID", example = "18026") + @Schema(description = "客户名称", example = "18026") private Long customerId; - @Schema(description = "合同ID", example = "3473") + @Schema(description = "合同名称", example = "3473") private Long contractId; @Schema(description = "负责人", example = "17828") private Long ownerUserId; - @Schema(description = "备注", example = "随便") - private String remark; - @Schema(description = "创建时间") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] createTime; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java index d80f76a91..0cf2423de 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java @@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; -import java.math.BigDecimal; import java.time.LocalDateTime; /** @@ -34,27 +33,26 @@ public class ReceivableDO extends BaseDO { */ private String no; /** - * 回款计划ID + * 回款计划 * - * TODO @liuhongfeng:这个字段,后续要写下关联的实体哈 + * 对应实体 {@link cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO} */ private Long planId; /** * 客户ID * - * TODO @liuhongfeng:这个字段,后续要写下关联的实体哈 + * 对应实体 {@link cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO} */ private Long customerId; /** * 合同ID * - * TODO @liuhongfeng:这个字段,后续要写下关联的实体哈 + * 对应实体 {@link cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO} */ private Long contractId; /** * 审批状态 - * - * 枚举 {@link TODO crm_receivable_check_status 对应的类} + * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_RECEIVABLE_CHECK_STATUS} */ private Integer checkStatus; /** @@ -74,7 +72,7 @@ public class ReceivableDO extends BaseDO { /** * 回款金额 */ - private BigDecimal price; + private Integer price; /** * 负责人 */ @@ -99,7 +97,8 @@ public class ReceivableDO extends BaseDO { /** * 状态 * - * 枚举 {@link TODO common_status 对应的类} + * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} + * */ private Integer status; /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java index 56ef67962..caaee7211 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java @@ -37,15 +37,15 @@ public class ReceivablePlanDO extends BaseDO { */ private Long receivableId; /** - * 完成状态 + * 状态 + * + * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} * - * 枚举 {@link TODO common_status 对应的类} */ private Integer status; /** * 审批状态 - * - * 枚举 {@link TODO crm_receivable_check_status 对应的类} + * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_RECEIVABLE_CHECK_STATUS} */ private Integer checkStatus; /** @@ -55,7 +55,7 @@ public class ReceivablePlanDO extends BaseDO { /** * 计划回款金额 */ - private BigDecimal price; + private Integer price; /** * 计划回款日期 */ @@ -63,7 +63,7 @@ public class ReceivablePlanDO extends BaseDO { /** * 提前几天提醒 */ - private Long remindDays; + private Integer remindDays; /** * 提醒日期 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java index 08031772c..0ef7165f4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java @@ -24,17 +24,11 @@ public interface ReceivableMapper extends BaseMapperX { .eqIfPresent(ReceivableDO::getCustomerId, reqVO.getCustomerId()) .eqIfPresent(ReceivableDO::getContractId, reqVO.getContractId()) .eqIfPresent(ReceivableDO::getCheckStatus, reqVO.getCheckStatus()) - .eqIfPresent(ReceivableDO::getProcessInstanceId, reqVO.getProcessInstanceId()) .betweenIfPresent(ReceivableDO::getReturnTime, reqVO.getReturnTime()) .eqIfPresent(ReceivableDO::getReturnType, reqVO.getReturnType()) .eqIfPresent(ReceivableDO::getPrice, reqVO.getPrice()) .eqIfPresent(ReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) - .eqIfPresent(ReceivableDO::getBatchId, reqVO.getBatchId()) - .eqIfPresent(ReceivableDO::getSort, reqVO.getSort()) - .eqIfPresent(ReceivableDO::getDataScope, reqVO.getDataScope()) - .eqIfPresent(ReceivableDO::getDataScopeDeptIds, reqVO.getDataScopeDeptIds()) .eqIfPresent(ReceivableDO::getStatus, reqVO.getStatus()) - .eqIfPresent(ReceivableDO::getRemark, reqVO.getRemark()) .betweenIfPresent(ReceivableDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(ReceivableDO::getId)); } @@ -46,15 +40,11 @@ public interface ReceivableMapper extends BaseMapperX { .eqIfPresent(ReceivableDO::getCustomerId, reqVO.getCustomerId()) .eqIfPresent(ReceivableDO::getContractId, reqVO.getContractId()) .eqIfPresent(ReceivableDO::getCheckStatus, reqVO.getCheckStatus()) - .eqIfPresent(ReceivableDO::getProcessInstanceId, reqVO.getProcessInstanceId()) .betweenIfPresent(ReceivableDO::getReturnTime, reqVO.getReturnTime()) .eqIfPresent(ReceivableDO::getReturnType, reqVO.getReturnType()) .eqIfPresent(ReceivableDO::getPrice, reqVO.getPrice()) .eqIfPresent(ReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) .eqIfPresent(ReceivableDO::getBatchId, reqVO.getBatchId()) - .eqIfPresent(ReceivableDO::getSort, reqVO.getSort()) - .eqIfPresent(ReceivableDO::getDataScope, reqVO.getDataScope()) - .eqIfPresent(ReceivableDO::getDataScopeDeptIds, reqVO.getDataScopeDeptIds()) .eqIfPresent(ReceivableDO::getStatus, reqVO.getStatus()) .eqIfPresent(ReceivableDO::getRemark, reqVO.getRemark()) .betweenIfPresent(ReceivableDO::getCreateTime, reqVO.getCreateTime()) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java index 3251c6787..516f20c0c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java @@ -19,16 +19,13 @@ public interface ReceivablePlanMapper extends BaseMapperX { default PageResult selectPage(ReceivablePlanPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ReceivablePlanDO::getPeriod, reqVO.getPeriod()) .eqIfPresent(ReceivablePlanDO::getStatus, reqVO.getStatus()) .eqIfPresent(ReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus()) .betweenIfPresent(ReceivablePlanDO::getReturnTime, reqVO.getReturnTime()) - .eqIfPresent(ReceivablePlanDO::getRemindDays, reqVO.getRemindDays()) .betweenIfPresent(ReceivablePlanDO::getRemindTime, reqVO.getRemindTime()) .eqIfPresent(ReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) .eqIfPresent(ReceivablePlanDO::getContractId, reqVO.getContractId()) .eqIfPresent(ReceivablePlanDO::getOwnerUserId, reqVO.getOwnerUserId()) - .eqIfPresent(ReceivablePlanDO::getRemark, reqVO.getRemark()) .betweenIfPresent(ReceivablePlanDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(ReceivablePlanDO::getId)); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java index cf216d4d2..d3c7a16ef 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java @@ -14,6 +14,7 @@ import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; import cn.iocoder.yudao.module.crm.service.contract.ContractService; @@ -43,10 +44,11 @@ public class ReceivableServiceImpl implements ReceivableService { private ContractService contractService; @Resource private CrmCustomerService crmCustomerService; + @Resource + private ReceivablePlanService receivablePlanService; @Override public Long createReceivable(ReceivableCreateReqVO createReqVO) { - // TODO @liuhongfeng:planId 是否存在,是否合法,需要去校验; // 插入 ReceivableDO receivable = ReceivableConvert.INSTANCE.convert(createReqVO); if (ObjectUtil.isNull(receivable.getStatus())){ @@ -80,6 +82,11 @@ public class ReceivableServiceImpl implements ReceivableService { throw exception(CUSTOMER_NOT_EXISTS); } + ReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(receivable.getPlanId()); + if(ObjectUtil.isNull(receivablePlan)){ + throw exception(RECEIVABLE_PLAN_NOT_EXISTS); + } + } @Override diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java index 4f9fb8d26..952514ecb 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java @@ -144,16 +144,13 @@ public class ReceivablePlanServiceImplTest extends BaseDbUnitTest { receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCreateTime(null))); // 准备参数 ReceivablePlanPageReqVO reqVO = new ReceivablePlanPageReqVO(); - reqVO.setPeriod(null); reqVO.setStatus(null); reqVO.setCheckStatus(null); reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setRemindDays(null); reqVO.setRemindTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); reqVO.setCustomerId(null); reqVO.setContractId(null); reqVO.setOwnerUserId(null); - reqVO.setRemark(null); reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); // 调用 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java index b8d4018b4..906fdb436 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java @@ -167,17 +167,11 @@ public class ReceivableServiceImplTest extends BaseDbUnitTest { reqVO.setCustomerId(null); reqVO.setContractId(null); reqVO.setCheckStatus(null); - reqVO.setProcessInstanceId(null); reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); reqVO.setReturnType(null); reqVO.setPrice(null); reqVO.setOwnerUserId(null); - reqVO.setBatchId(null); - reqVO.setSort(null); - reqVO.setDataScope(null); - reqVO.setDataScopeDeptIds(null); reqVO.setStatus(null); - reqVO.setRemark(null); reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); // 调用 @@ -253,15 +247,11 @@ public class ReceivableServiceImplTest extends BaseDbUnitTest { reqVO.setCustomerId(null); reqVO.setContractId(null); reqVO.setCheckStatus(null); - reqVO.setProcessInstanceId(null); reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); reqVO.setReturnType(null); reqVO.setPrice(null); reqVO.setOwnerUserId(null); reqVO.setBatchId(null); - reqVO.setSort(null); - reqVO.setDataScope(null); - reqVO.setDataScopeDeptIds(null); reqVO.setStatus(null); reqVO.setRemark(null); reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); From 95e9dc81c9c397078a8684dfbddc6599436f76fa Mon Sep 17 00:00:00 2001 From: liuhongfeng <291117974@qq.com> Date: Tue, 31 Oct 2023 01:09:40 +0800 Subject: [PATCH 047/101] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91?= =?UTF-8?q?=E5=9B=9E=E6=AC=BE=E8=AE=A1=E5=88=92=E5=92=8C=E5=9B=9E=E6=AC=BE?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=BB=9F=E4=B8=80=E5=B8=A6=E4=B8=8ACrm?= =?UTF-8?q?=E5=89=8D=E7=BC=80=EF=BC=8C=E9=98=B2=E6=AD=A2=E5=92=8C=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E6=A8=A1=E5=9D=97=E5=86=B2=E7=AA=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ller.java => CrmReceivableController.java} | 40 +++--- ....java => CrmReceivablePlanController.java} | 40 +++--- ...leBaseVO.java => CrmReceivableBaseVO.java} | 7 +- ...qVO.java => CrmReceivableCreateReqVO.java} | 4 +- ...ExcelVO.java => CrmReceivableExcelVO.java} | 8 +- ...qVO.java => CrmReceivableExportReqVO.java} | 4 +- ...ReqVO.java => CrmReceivablePageReqVO.java} | 3 +- ...seVO.java => CrmReceivablePlanBaseVO.java} | 2 +- ...java => CrmReceivablePlanCreateReqVO.java} | 4 +- ...lVO.java => CrmReceivablePlanExcelVO.java} | 3 +- ...java => CrmReceivablePlanExportReqVO.java} | 4 +- ...O.java => CrmReceivablePlanPageReqVO.java} | 2 +- ...spVO.java => CrmReceivablePlanRespVO.java} | 2 +- ...java => CrmReceivablePlanUpdateReqVO.java} | 4 +- ...leRespVO.java => CrmReceivableRespVO.java} | 2 +- ...qVO.java => CrmReceivableUpdateReqVO.java} | 4 +- .../receivable/CrmReceivableConvert.java | 34 +++++ .../receivable/CrmReceivablePlanConvert.java | 34 +++++ .../convert/receivable/ReceivableConvert.java | 34 ----- .../receivable/ReceivablePlanConvert.java | 34 ----- ...ReceivableDO.java => CrmReceivableDO.java} | 4 +- ...lePlanDO.java => CrmReceivablePlanDO.java} | 3 +- .../mysql/receivable/CrmReceivableMapper.java | 54 ++++++++ .../receivable/CrmReceivablePlanMapper.java | 49 +++++++ .../mysql/receivable/ReceivableMapper.java | 54 -------- .../receivable/ReceivablePlanMapper.java | 49 ------- ...ice.java => CrmReceivablePlanService.java} | 16 +-- ...java => CrmReceivablePlanServiceImpl.java} | 53 ++++---- ...Service.java => CrmReceivableService.java} | 16 +-- ...mpl.java => CrmReceivableServiceImpl.java} | 59 ++++---- ...ableMapper.xml => CrmReceivableMapper.xml} | 2 +- ...Mapper.xml => CrmReceivablePlanMapper.xml} | 2 +- ... CrmCrmReceivablePlanServiceImplTest.java} | 102 +++++++------- ...a => CrmCrmReceivableServiceImplTest.java} | 126 +++++++++--------- 34 files changed, 423 insertions(+), 435 deletions(-) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/{ReceivableController.java => CrmReceivableController.java} (64%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/{ReceivablePlanController.java => CrmReceivablePlanController.java} (62%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ReceivableBaseVO.java => CrmReceivableBaseVO.java} (91%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ReceivableCreateReqVO.java => CrmReceivableCreateReqVO.java} (69%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ReceivableExcelVO.java => CrmReceivableExcelVO.java} (89%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ReceivableExportReqVO.java => CrmReceivableExportReqVO.java} (94%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ReceivablePageReqVO.java => CrmReceivablePageReqVO.java} (95%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ReceivablePlanBaseVO.java => CrmReceivablePlanBaseVO.java} (98%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ReceivablePlanCreateReqVO.java => CrmReceivablePlanCreateReqVO.java} (68%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ReceivablePlanExcelVO.java => CrmReceivablePlanExcelVO.java} (96%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ReceivablePlanExportReqVO.java => CrmReceivablePlanExportReqVO.java} (93%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ReceivablePlanPageReqVO.java => CrmReceivablePlanPageReqVO.java} (96%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ReceivablePlanRespVO.java => CrmReceivablePlanRespVO.java} (88%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ReceivablePlanUpdateReqVO.java => CrmReceivablePlanUpdateReqVO.java} (84%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ReceivableRespVO.java => CrmReceivableRespVO.java} (89%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ReceivableUpdateReqVO.java => CrmReceivableUpdateReqVO.java} (85%) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivableConvert.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivablePlanConvert.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivableConvert.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivablePlanConvert.java rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/{ReceivableDO.java => CrmReceivableDO.java} (94%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/{ReceivablePlanDO.java => CrmReceivablePlanDO.java} (95%) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/{ReceivablePlanService.java => CrmReceivablePlanService.java} (64%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/{ReceivablePlanServiceImpl.java => CrmReceivablePlanServiceImpl.java} (63%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/{ReceivableService.java => CrmReceivableService.java} (67%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/{ReceivableServiceImpl.java => CrmReceivableServiceImpl.java} (62%) rename yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/{ReceivableMapper.xml => CrmReceivableMapper.xml} (95%) rename yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/{ReceivablePlanMapper.xml => CrmReceivablePlanMapper.xml} (95%) rename yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/{ReceivablePlanServiceImplTest.java => CrmCrmReceivablePlanServiceImplTest.java} (58%) rename yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/{ReceivableServiceImplTest.java => CrmCrmReceivableServiceImplTest.java} (57%) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java similarity index 64% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java index c88f31f6d..4f7d9e674 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java @@ -5,9 +5,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; 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.receivable.vo.*; -import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; -import cn.iocoder.yudao.module.crm.service.receivable.ReceivableService; +import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivableConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; +import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -28,23 +28,23 @@ import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.E @RestController @RequestMapping("/crm/receivable") @Validated -public class ReceivableController { +public class CrmReceivableController { @Resource - private ReceivableService receivableService; + private CrmReceivableService crmReceivableService; @PostMapping("/create") @Operation(summary = "创建回款管理") @PreAuthorize("@ss.hasPermission('crm:receivable:create')") - public CommonResult createReceivable(@Valid @RequestBody ReceivableCreateReqVO createReqVO) { - return success(receivableService.createReceivable(createReqVO)); + public CommonResult createReceivable(@Valid @RequestBody CrmReceivableCreateReqVO createReqVO) { + return success(crmReceivableService.createReceivable(createReqVO)); } @PutMapping("/update") @Operation(summary = "更新回款管理") @PreAuthorize("@ss.hasPermission('crm:receivable:update')") - public CommonResult updateReceivable(@Valid @RequestBody ReceivableUpdateReqVO updateReqVO) { - receivableService.updateReceivable(updateReqVO); + public CommonResult updateReceivable(@Valid @RequestBody CrmReceivableUpdateReqVO updateReqVO) { + crmReceivableService.updateReceivable(updateReqVO); return success(true); } @@ -53,7 +53,7 @@ public class ReceivableController { @Parameter(name = "id", description = "编号", required = true) @PreAuthorize("@ss.hasPermission('crm:receivable:delete')") public CommonResult deleteReceivable(@RequestParam("id") Long id) { - receivableService.deleteReceivable(id); + crmReceivableService.deleteReceivable(id); return success(true); } @@ -61,29 +61,29 @@ public class ReceivableController { @Operation(summary = "获得回款管理") @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('crm:receivable:query')") - public CommonResult getReceivable(@RequestParam("id") Long id) { - ReceivableDO receivable = receivableService.getReceivable(id); - return success(ReceivableConvert.INSTANCE.convert(receivable)); + public CommonResult getReceivable(@RequestParam("id") Long id) { + CrmReceivableDO receivable = crmReceivableService.getReceivable(id); + return success(CrmReceivableConvert.INSTANCE.convert(receivable)); } @GetMapping("/page") @Operation(summary = "获得回款管理分页") @PreAuthorize("@ss.hasPermission('crm:receivable:query')") - public CommonResult> getReceivablePage(@Valid ReceivablePageReqVO pageVO) { - PageResult pageResult = receivableService.getReceivablePage(pageVO); - return success(ReceivableConvert.INSTANCE.convertPage(pageResult)); + public CommonResult> getReceivablePage(@Valid CrmReceivablePageReqVO pageVO) { + PageResult pageResult = crmReceivableService.getReceivablePage(pageVO); + return success(CrmReceivableConvert.INSTANCE.convertPage(pageResult)); } @GetMapping("/export-excel") @Operation(summary = "导出回款管理 Excel") @PreAuthorize("@ss.hasPermission('crm:receivable:export')") @OperateLog(type = EXPORT) - public void exportReceivableExcel(@Valid ReceivableExportReqVO exportReqVO, + public void exportReceivableExcel(@Valid CrmReceivableExportReqVO exportReqVO, HttpServletResponse response) throws IOException { - List list = receivableService.getReceivableList(exportReqVO); + List list = crmReceivableService.getReceivableList(exportReqVO); // 导出 Excel - List datas = ReceivableConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "回款管理.xls", "数据", ReceivableExcelVO.class, datas); + List datas = CrmReceivableConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "回款管理.xls", "数据", CrmReceivableExcelVO.class, datas); } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java similarity index 62% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java index 0c33eb25a..afba2b721 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java @@ -5,9 +5,9 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; 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.receivable.vo.*; -import cn.iocoder.yudao.module.crm.convert.receivable.ReceivablePlanConvert; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; -import cn.iocoder.yudao.module.crm.service.receivable.ReceivablePlanService; +import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivablePlanConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; +import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivablePlanService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -28,23 +28,23 @@ import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.E @RestController @RequestMapping("/crm/receivable-plan") @Validated -public class ReceivablePlanController { +public class CrmReceivablePlanController { @Resource - private ReceivablePlanService receivablePlanService; + private CrmReceivablePlanService crmReceivablePlanService; @PostMapping("/create") @Operation(summary = "创建回款计划") @PreAuthorize("@ss.hasPermission('crm:receivable-plan:create')") - public CommonResult createReceivablePlan(@Valid @RequestBody ReceivablePlanCreateReqVO createReqVO) { - return success(receivablePlanService.createReceivablePlan(createReqVO)); + public CommonResult createReceivablePlan(@Valid @RequestBody CrmReceivablePlanCreateReqVO createReqVO) { + return success(crmReceivablePlanService.createReceivablePlan(createReqVO)); } @PutMapping("/update") @Operation(summary = "更新回款计划") @PreAuthorize("@ss.hasPermission('crm:receivable-plan:update')") - public CommonResult updateReceivablePlan(@Valid @RequestBody ReceivablePlanUpdateReqVO updateReqVO) { - receivablePlanService.updateReceivablePlan(updateReqVO); + public CommonResult updateReceivablePlan(@Valid @RequestBody CrmReceivablePlanUpdateReqVO updateReqVO) { + crmReceivablePlanService.updateReceivablePlan(updateReqVO); return success(true); } @@ -53,7 +53,7 @@ public class ReceivablePlanController { @Parameter(name = "id", description = "编号", required = true) @PreAuthorize("@ss.hasPermission('crm:receivable-plan:delete')") public CommonResult deleteReceivablePlan(@RequestParam("id") Long id) { - receivablePlanService.deleteReceivablePlan(id); + crmReceivablePlanService.deleteReceivablePlan(id); return success(true); } @@ -61,29 +61,29 @@ public class ReceivablePlanController { @Operation(summary = "获得回款计划") @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") - public CommonResult getReceivablePlan(@RequestParam("id") Long id) { - ReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(id); - return success(ReceivablePlanConvert.INSTANCE.convert(receivablePlan)); + public CommonResult getReceivablePlan(@RequestParam("id") Long id) { + CrmReceivablePlanDO receivablePlan = crmReceivablePlanService.getReceivablePlan(id); + return success(CrmReceivablePlanConvert.INSTANCE.convert(receivablePlan)); } @GetMapping("/page") @Operation(summary = "获得回款计划分页") @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") - public CommonResult> getReceivablePlanPage(@Valid ReceivablePlanPageReqVO pageVO) { - PageResult pageResult = receivablePlanService.getReceivablePlanPage(pageVO); - return success(ReceivablePlanConvert.INSTANCE.convertPage(pageResult)); + public CommonResult> getReceivablePlanPage(@Valid CrmReceivablePlanPageReqVO pageVO) { + PageResult pageResult = crmReceivablePlanService.getReceivablePlanPage(pageVO); + return success(CrmReceivablePlanConvert.INSTANCE.convertPage(pageResult)); } @GetMapping("/export-excel") @Operation(summary = "导出回款计划 Excel") @PreAuthorize("@ss.hasPermission('crm:receivable-plan:export')") @OperateLog(type = EXPORT) - public void exportReceivablePlanExcel(@Valid ReceivablePlanExportReqVO exportReqVO, + public void exportReceivablePlanExcel(@Valid CrmReceivablePlanExportReqVO exportReqVO, HttpServletResponse response) throws IOException { - List list = receivablePlanService.getReceivablePlanList(exportReqVO); + List list = crmReceivablePlanService.getReceivablePlanList(exportReqVO); // 导出 Excel - List datas = ReceivablePlanConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "回款计划.xls", "数据", ReceivablePlanExcelVO.class, datas); + List datas = CrmReceivablePlanConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "回款计划.xls", "数据", CrmReceivablePlanExcelVO.class, datas); } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableBaseVO.java similarity index 91% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableBaseVO.java index 1e7e7bd68..24b1d57e4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableBaseVO.java @@ -6,8 +6,6 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; -import javax.validation.constraints.NotNull; -import java.math.BigDecimal; import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -17,7 +15,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 */ @Data -public class ReceivableBaseVO { +public class CrmReceivableBaseVO { @Schema(description = "回款编号",requiredMode = Schema.RequiredMode.REQUIRED, example = "31177") private String no; @@ -57,4 +55,7 @@ public class ReceivableBaseVO { @Schema(description = "备注", example = "备注") private String remark; + @Schema(description = "完成状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + private Integer status; + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableCreateReqVO.java similarity index 69% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableCreateReqVO.java index d38d0bd5f..a2d43d8c1 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableCreateReqVO.java @@ -1,14 +1,12 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; import lombok.*; -import java.util.*; import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.*; @Schema(description = "管理后台 - CRM 回款创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ReceivableCreateReqVO extends ReceivableBaseVO { +public class CrmReceivableCreateReqVO extends CrmReceivableBaseVO { } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExcelVO.java similarity index 89% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExcelVO.java index a88fa9fd9..1bd461499 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExcelVO.java @@ -1,12 +1,8 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; -import java.util.*; -import java.time.LocalDateTime; -import java.math.BigDecimal; -import java.time.LocalDateTime; + import java.time.LocalDateTime; import com.alibaba.excel.annotation.ExcelProperty; @@ -20,7 +16,7 @@ import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; * @author 赤焰 */ @Data -public class ReceivableExcelVO { +public class CrmReceivableExcelVO { @ExcelProperty("ID") private Long id; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExportReqVO.java similarity index 94% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExportReqVO.java index f07e4ddf8..b674bbc2b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExportReqVO.java @@ -11,9 +11,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ /** * @author 赤焰 */ -@Schema(description = "管理后台 - CRM 回款 Excel 导出 Request VO,参数和 ReceivablePageReqVO 是一致的") +@Schema(description = "管理后台 - CRM 回款 Excel 导出 Request VO,参数和 CrmReceivablePageReqVO 是一致的") @Data -public class ReceivableExportReqVO { +public class CrmReceivableExportReqVO { @Schema(description = "回款编号") private String no; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePageReqVO.java similarity index 95% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePageReqVO.java index 53cdc4949..3a90ed809 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePageReqVO.java @@ -7,7 +7,6 @@ import lombok.EqualsAndHashCode; import lombok.ToString; import org.springframework.format.annotation.DateTimeFormat; -import java.math.BigDecimal; import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -16,7 +15,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ReceivablePageReqVO extends PageParam { +public class CrmReceivablePageReqVO extends PageParam { @Schema(description = "回款编号") private String no; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanBaseVO.java similarity index 98% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanBaseVO.java index 2bd05a64a..49d00892e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanBaseVO.java @@ -15,7 +15,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 */ @Data -public class ReceivablePlanBaseVO { +public class CrmReceivablePlanBaseVO { @Schema(description = "期数", example = "1") private Integer period; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanCreateReqVO.java similarity index 68% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanCreateReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanCreateReqVO.java index d03e76eb0..cebfd28cb 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanCreateReqVO.java @@ -1,14 +1,12 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; import lombok.*; -import java.util.*; import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.*; @Schema(description = "管理后台 - CRM 回款计划创建 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ReceivablePlanCreateReqVO extends ReceivablePlanBaseVO { +public class CrmReceivablePlanCreateReqVO extends CrmReceivablePlanBaseVO { } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExcelVO.java similarity index 96% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExcelVO.java index 2ff3fd0d3..a7246e252 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExcelVO.java @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; import cn.iocoder.yudao.module.system.enums.DictTypeConstants; import lombok.*; -import java.math.BigDecimal; import java.time.LocalDateTime; import com.alibaba.excel.annotation.ExcelProperty; @@ -17,7 +16,7 @@ import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; * @author 芋道源码 */ @Data -public class ReceivablePlanExcelVO { +public class CrmReceivablePlanExcelVO { @ExcelProperty("ID") private Long id; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExportReqVO.java similarity index 93% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExportReqVO.java index 803e1ed03..8002d41af 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExportReqVO.java @@ -8,9 +8,9 @@ import org.springframework.format.annotation.DateTimeFormat; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -@Schema(description = "管理后台 - CRM 回款计划 Excel 导出 Request VO,参数和 ReceivablePlanPageReqVO 是一致的") +@Schema(description = "管理后台 - CRM 回款计划 Excel 导出 Request VO,参数和 CrmReceivablePlanPageReqVO 是一致的") @Data -public class ReceivablePlanExportReqVO { +public class CrmReceivablePlanExportReqVO { @Schema(description = "期数") private Integer period; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanPageReqVO.java similarity index 96% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanPageReqVO.java index c92b4e891..10e26207a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanPageReqVO.java @@ -15,7 +15,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ReceivablePlanPageReqVO extends PageParam { +public class CrmReceivablePlanPageReqVO extends PageParam { @Schema(description = "完成状态", example = "2") private Integer status; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanRespVO.java similarity index 88% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanRespVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanRespVO.java index ce49d5977..243e7f782 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanRespVO.java @@ -8,7 +8,7 @@ import java.time.LocalDateTime; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ReceivablePlanRespVO extends ReceivablePlanBaseVO { +public class CrmReceivablePlanRespVO extends CrmReceivablePlanBaseVO { @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25153") private Long id; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanUpdateReqVO.java similarity index 84% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanUpdateReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanUpdateReqVO.java index 1f539537d..5471cfba3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanUpdateReqVO.java @@ -2,14 +2,14 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; -import java.util.*; + import javax.validation.constraints.*; @Schema(description = "管理后台 - CRM 回款计划更新 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ReceivablePlanUpdateReqVO extends ReceivablePlanBaseVO { +public class CrmReceivablePlanUpdateReqVO extends CrmReceivablePlanBaseVO { @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25153") @NotNull(message = "ID不能为空") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableRespVO.java similarity index 89% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableRespVO.java index 1646cd5a8..00d984da5 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableRespVO.java @@ -8,7 +8,7 @@ import java.time.LocalDateTime; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ReceivableRespVO extends ReceivableBaseVO { +public class CrmReceivableRespVO extends CrmReceivableBaseVO { @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25787") private Long id; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableUpdateReqVO.java similarity index 85% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableUpdateReqVO.java index 008c06b63..d6241f258 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableUpdateReqVO.java @@ -2,14 +2,14 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; -import java.util.*; + import javax.validation.constraints.*; @Schema(description = "管理后台 - CRM 回款更新 Request VO") @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class ReceivableUpdateReqVO extends ReceivableBaseVO { +public class CrmReceivableUpdateReqVO extends CrmReceivableBaseVO { @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25787") @NotNull(message = "ID不能为空") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivableConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivableConvert.java new file mode 100644 index 000000000..23345fbe6 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivableConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.convert.receivable; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; + +/** + * 回款管理 Convert + * + * @author 赤焰 + */ +@Mapper +public interface CrmReceivableConvert { + + CrmReceivableConvert INSTANCE = Mappers.getMapper(CrmReceivableConvert.class); + + CrmReceivableDO convert(CrmReceivableCreateReqVO bean); + + CrmReceivableDO convert(CrmReceivableUpdateReqVO bean); + + CrmReceivableRespVO convert(CrmReceivableDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivablePlanConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivablePlanConvert.java new file mode 100644 index 000000000..4b2d65c60 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivablePlanConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.convert.receivable; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; + +/** + * 回款计划 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface CrmReceivablePlanConvert { + + CrmReceivablePlanConvert INSTANCE = Mappers.getMapper(CrmReceivablePlanConvert.class); + + CrmReceivablePlanDO convert(CrmReceivablePlanCreateReqVO bean); + + CrmReceivablePlanDO convert(CrmReceivablePlanUpdateReqVO bean); + + CrmReceivablePlanRespVO convert(CrmReceivablePlanDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivableConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivableConvert.java deleted file mode 100644 index 7f14aaddd..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivableConvert.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.crm.convert.receivable; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; - -/** - * 回款管理 Convert - * - * @author 赤焰 - */ -@Mapper -public interface ReceivableConvert { - - ReceivableConvert INSTANCE = Mappers.getMapper(ReceivableConvert.class); - - ReceivableDO convert(ReceivableCreateReqVO bean); - - ReceivableDO convert(ReceivableUpdateReqVO bean); - - ReceivableRespVO convert(ReceivableDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivablePlanConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivablePlanConvert.java deleted file mode 100644 index 81ec646f3..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivablePlanConvert.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.yudao.module.crm.convert.receivable; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; - -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; - -/** - * 回款计划 Convert - * - * @author 芋道源码 - */ -@Mapper -public interface ReceivablePlanConvert { - - ReceivablePlanConvert INSTANCE = Mappers.getMapper(ReceivablePlanConvert.class); - - ReceivablePlanDO convert(ReceivablePlanCreateReqVO bean); - - ReceivablePlanDO convert(ReceivablePlanUpdateReqVO bean); - - ReceivablePlanRespVO convert(ReceivablePlanDO bean); - - List convertList(List list); - - PageResult convertPage(PageResult page); - - List convertList02(List list); - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java similarity index 94% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java index 0cf2423de..b74507dd1 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java @@ -21,7 +21,7 @@ import java.time.LocalDateTime; @Builder @NoArgsConstructor @AllArgsConstructor -public class ReceivableDO extends BaseDO { +public class CrmReceivableDO extends BaseDO { /** * ID @@ -35,7 +35,7 @@ public class ReceivableDO extends BaseDO { /** * 回款计划 * - * 对应实体 {@link cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO} + * 对应实体 {@link CrmReceivablePlanDO} */ private Long planId; /** diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java similarity index 95% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java index caaee7211..4274250e8 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; import lombok.*; -import java.math.BigDecimal; import java.time.LocalDateTime; import com.baomidou.mybatisplus.annotation.*; @@ -21,7 +20,7 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; @Builder @NoArgsConstructor @AllArgsConstructor -public class ReceivablePlanDO extends BaseDO { +public class CrmReceivablePlanDO extends BaseDO { /** * ID diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java new file mode 100644 index 000000000..716704fb8 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.receivable; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; + +/** + * 回款管理 Mapper + * + * @author 赤焰 + */ +@Mapper +public interface CrmReceivableMapper extends BaseMapperX { + + default PageResult selectPage(CrmReceivablePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(CrmReceivableDO::getNo, reqVO.getNo()) + .eqIfPresent(CrmReceivableDO::getPlanId, reqVO.getPlanId()) + .eqIfPresent(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(CrmReceivableDO::getContractId, reqVO.getContractId()) + .eqIfPresent(CrmReceivableDO::getCheckStatus, reqVO.getCheckStatus()) + .betweenIfPresent(CrmReceivableDO::getReturnTime, reqVO.getReturnTime()) + .eqIfPresent(CrmReceivableDO::getReturnType, reqVO.getReturnType()) + .eqIfPresent(CrmReceivableDO::getPrice, reqVO.getPrice()) + .eqIfPresent(CrmReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) + .eqIfPresent(CrmReceivableDO::getStatus, reqVO.getStatus()) + .betweenIfPresent(CrmReceivableDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(CrmReceivableDO::getId)); + } + + default List selectList(CrmReceivableExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(CrmReceivableDO::getNo, reqVO.getNo()) + .eqIfPresent(CrmReceivableDO::getPlanId, reqVO.getPlanId()) + .eqIfPresent(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(CrmReceivableDO::getContractId, reqVO.getContractId()) + .eqIfPresent(CrmReceivableDO::getCheckStatus, reqVO.getCheckStatus()) + .betweenIfPresent(CrmReceivableDO::getReturnTime, reqVO.getReturnTime()) + .eqIfPresent(CrmReceivableDO::getReturnType, reqVO.getReturnType()) + .eqIfPresent(CrmReceivableDO::getPrice, reqVO.getPrice()) + .eqIfPresent(CrmReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) + .eqIfPresent(CrmReceivableDO::getBatchId, reqVO.getBatchId()) + .eqIfPresent(CrmReceivableDO::getStatus, reqVO.getStatus()) + .eqIfPresent(CrmReceivableDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(CrmReceivableDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(CrmReceivableDO::getId)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java new file mode 100644 index 000000000..62b2c0c54 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java @@ -0,0 +1,49 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.receivable; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; + +/** + * 回款计划 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface CrmReceivablePlanMapper extends BaseMapperX { + + default PageResult selectPage(CrmReceivablePlanPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(CrmReceivablePlanDO::getStatus, reqVO.getStatus()) + .eqIfPresent(CrmReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus()) + .betweenIfPresent(CrmReceivablePlanDO::getReturnTime, reqVO.getReturnTime()) + .betweenIfPresent(CrmReceivablePlanDO::getRemindTime, reqVO.getRemindTime()) + .eqIfPresent(CrmReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(CrmReceivablePlanDO::getContractId, reqVO.getContractId()) + .eqIfPresent(CrmReceivablePlanDO::getOwnerUserId, reqVO.getOwnerUserId()) + .betweenIfPresent(CrmReceivablePlanDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(CrmReceivablePlanDO::getId)); + } + + default List selectList(CrmReceivablePlanExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(CrmReceivablePlanDO::getPeriod, reqVO.getPeriod()) + .eqIfPresent(CrmReceivablePlanDO::getStatus, reqVO.getStatus()) + .eqIfPresent(CrmReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus()) + .betweenIfPresent(CrmReceivablePlanDO::getReturnTime, reqVO.getReturnTime()) + .eqIfPresent(CrmReceivablePlanDO::getRemindDays, reqVO.getRemindDays()) + .betweenIfPresent(CrmReceivablePlanDO::getRemindTime, reqVO.getRemindTime()) + .eqIfPresent(CrmReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(CrmReceivablePlanDO::getContractId, reqVO.getContractId()) + .eqIfPresent(CrmReceivablePlanDO::getOwnerUserId, reqVO.getOwnerUserId()) + .eqIfPresent(CrmReceivablePlanDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(CrmReceivablePlanDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(CrmReceivablePlanDO::getId)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java deleted file mode 100644 index 0ef7165f4..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.receivable; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; - -/** - * 回款管理 Mapper - * - * @author 赤焰 - */ -@Mapper -public interface ReceivableMapper extends BaseMapperX { - - default PageResult selectPage(ReceivablePageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ReceivableDO::getNo, reqVO.getNo()) - .eqIfPresent(ReceivableDO::getPlanId, reqVO.getPlanId()) - .eqIfPresent(ReceivableDO::getCustomerId, reqVO.getCustomerId()) - .eqIfPresent(ReceivableDO::getContractId, reqVO.getContractId()) - .eqIfPresent(ReceivableDO::getCheckStatus, reqVO.getCheckStatus()) - .betweenIfPresent(ReceivableDO::getReturnTime, reqVO.getReturnTime()) - .eqIfPresent(ReceivableDO::getReturnType, reqVO.getReturnType()) - .eqIfPresent(ReceivableDO::getPrice, reqVO.getPrice()) - .eqIfPresent(ReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) - .eqIfPresent(ReceivableDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(ReceivableDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ReceivableDO::getId)); - } - - default List selectList(ReceivableExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(ReceivableDO::getNo, reqVO.getNo()) - .eqIfPresent(ReceivableDO::getPlanId, reqVO.getPlanId()) - .eqIfPresent(ReceivableDO::getCustomerId, reqVO.getCustomerId()) - .eqIfPresent(ReceivableDO::getContractId, reqVO.getContractId()) - .eqIfPresent(ReceivableDO::getCheckStatus, reqVO.getCheckStatus()) - .betweenIfPresent(ReceivableDO::getReturnTime, reqVO.getReturnTime()) - .eqIfPresent(ReceivableDO::getReturnType, reqVO.getReturnType()) - .eqIfPresent(ReceivableDO::getPrice, reqVO.getPrice()) - .eqIfPresent(ReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) - .eqIfPresent(ReceivableDO::getBatchId, reqVO.getBatchId()) - .eqIfPresent(ReceivableDO::getStatus, reqVO.getStatus()) - .eqIfPresent(ReceivableDO::getRemark, reqVO.getRemark()) - .betweenIfPresent(ReceivableDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ReceivableDO::getId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java deleted file mode 100644 index 516f20c0c..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.receivable; - -import java.util.*; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; -import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; - -/** - * 回款计划 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface ReceivablePlanMapper extends BaseMapperX { - - default PageResult selectPage(ReceivablePlanPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(ReceivablePlanDO::getStatus, reqVO.getStatus()) - .eqIfPresent(ReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus()) - .betweenIfPresent(ReceivablePlanDO::getReturnTime, reqVO.getReturnTime()) - .betweenIfPresent(ReceivablePlanDO::getRemindTime, reqVO.getRemindTime()) - .eqIfPresent(ReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) - .eqIfPresent(ReceivablePlanDO::getContractId, reqVO.getContractId()) - .eqIfPresent(ReceivablePlanDO::getOwnerUserId, reqVO.getOwnerUserId()) - .betweenIfPresent(ReceivablePlanDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ReceivablePlanDO::getId)); - } - - default List selectList(ReceivablePlanExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(ReceivablePlanDO::getPeriod, reqVO.getPeriod()) - .eqIfPresent(ReceivablePlanDO::getStatus, reqVO.getStatus()) - .eqIfPresent(ReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus()) - .betweenIfPresent(ReceivablePlanDO::getReturnTime, reqVO.getReturnTime()) - .eqIfPresent(ReceivablePlanDO::getRemindDays, reqVO.getRemindDays()) - .betweenIfPresent(ReceivablePlanDO::getRemindTime, reqVO.getRemindTime()) - .eqIfPresent(ReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) - .eqIfPresent(ReceivablePlanDO::getContractId, reqVO.getContractId()) - .eqIfPresent(ReceivablePlanDO::getOwnerUserId, reqVO.getOwnerUserId()) - .eqIfPresent(ReceivablePlanDO::getRemark, reqVO.getRemark()) - .betweenIfPresent(ReceivablePlanDO::getCreateTime, reqVO.getCreateTime()) - .orderByDesc(ReceivablePlanDO::getId)); - } - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java similarity index 64% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanService.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java index 163ebc26a..b8c472fa3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.crm.service.receivable; import java.util.*; import javax.validation.*; import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; /** @@ -11,7 +11,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; * * @author 芋道源码 */ -public interface ReceivablePlanService { +public interface CrmReceivablePlanService { /** * 创建回款计划 @@ -19,14 +19,14 @@ public interface ReceivablePlanService { * @param createReqVO 创建信息 * @return 编号 */ - Long createReceivablePlan(@Valid ReceivablePlanCreateReqVO createReqVO); + Long createReceivablePlan(@Valid CrmReceivablePlanCreateReqVO createReqVO); /** * 更新回款计划 * * @param updateReqVO 更新信息 */ - void updateReceivablePlan(@Valid ReceivablePlanUpdateReqVO updateReqVO); + void updateReceivablePlan(@Valid CrmReceivablePlanUpdateReqVO updateReqVO); /** * 删除回款计划 @@ -41,7 +41,7 @@ public interface ReceivablePlanService { * @param id 编号 * @return 回款计划 */ - ReceivablePlanDO getReceivablePlan(Long id); + CrmReceivablePlanDO getReceivablePlan(Long id); /** * 获得回款计划列表 @@ -49,7 +49,7 @@ public interface ReceivablePlanService { * @param ids 编号 * @return 回款计划列表 */ - List getReceivablePlanList(Collection ids); + List getReceivablePlanList(Collection ids); /** * 获得回款计划分页 @@ -57,7 +57,7 @@ public interface ReceivablePlanService { * @param pageReqVO 分页查询 * @return 回款计划分页 */ - PageResult getReceivablePlanPage(ReceivablePlanPageReqVO pageReqVO); + PageResult getReceivablePlanPage(CrmReceivablePlanPageReqVO pageReqVO); /** * 获得回款计划列表, 用于 Excel 导出 @@ -65,6 +65,6 @@ public interface ReceivablePlanService { * @param exportReqVO 查询条件 * @return 回款计划列表 */ - List getReceivablePlanList(ReceivablePlanExportReqVO exportReqVO); + List getReceivablePlanList(CrmReceivablePlanExportReqVO exportReqVO); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java similarity index 63% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java index f8493a1ec..b3497b686 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java @@ -5,16 +5,15 @@ import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanUpdateReqVO; -import cn.iocoder.yudao.module.crm.convert.receivable.ReceivablePlanConvert; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanExportReqVO; +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.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; -import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivablePlanMapper; +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.service.customer.CrmCustomerService; @@ -35,19 +34,19 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; */ @Service @Validated -public class ReceivablePlanServiceImpl implements ReceivablePlanService { +public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { @Resource - private ReceivablePlanMapper receivablePlanMapper; + private CrmReceivablePlanMapper crmReceivablePlanMapper; @Resource private ContractService contractService; @Resource private CrmCustomerService crmCustomerService; @Override - public Long createReceivablePlan(ReceivablePlanCreateReqVO createReqVO) { + public Long createReceivablePlan(CrmReceivablePlanCreateReqVO createReqVO) { // 插入 - ReceivablePlanDO receivablePlan = ReceivablePlanConvert.INSTANCE.convert(createReqVO); + CrmReceivablePlanDO receivablePlan = CrmReceivablePlanConvert.INSTANCE.convert(createReqVO); if (ObjectUtil.isNull(receivablePlan.getStatus())){ receivablePlan.setStatus(CommonStatusEnum.ENABLE.getStatus()); } @@ -57,12 +56,12 @@ public class ReceivablePlanServiceImpl implements ReceivablePlanService { checkReceivablePlan(receivablePlan); - receivablePlanMapper.insert(receivablePlan); + crmReceivablePlanMapper.insert(receivablePlan); // 返回 return receivablePlan.getId(); } - private void checkReceivablePlan(ReceivablePlanDO receivablePlan) { + private void checkReceivablePlan(CrmReceivablePlanDO receivablePlan) { if(ObjectUtil.isNull(receivablePlan.getContractId())){ throw exception(CONTRACT_NOT_EXISTS); @@ -81,13 +80,13 @@ public class ReceivablePlanServiceImpl implements ReceivablePlanService { } @Override - public void updateReceivablePlan(ReceivablePlanUpdateReqVO updateReqVO) { + public void updateReceivablePlan(CrmReceivablePlanUpdateReqVO updateReqVO) { // 校验存在 validateReceivablePlanExists(updateReqVO.getId()); // 更新 - ReceivablePlanDO updateObj = ReceivablePlanConvert.INSTANCE.convert(updateReqVO); - receivablePlanMapper.updateById(updateObj); + CrmReceivablePlanDO updateObj = CrmReceivablePlanConvert.INSTANCE.convert(updateReqVO); + crmReceivablePlanMapper.updateById(updateObj); } @Override @@ -95,36 +94,36 @@ public class ReceivablePlanServiceImpl implements ReceivablePlanService { // 校验存在 validateReceivablePlanExists(id); // 删除 - receivablePlanMapper.deleteById(id); + crmReceivablePlanMapper.deleteById(id); } private void validateReceivablePlanExists(Long id) { - if (receivablePlanMapper.selectById(id) == null) { + if (crmReceivablePlanMapper.selectById(id) == null) { throw exception(RECEIVABLE_PLAN_NOT_EXISTS); } } @Override - public ReceivablePlanDO getReceivablePlan(Long id) { - return receivablePlanMapper.selectById(id); + public CrmReceivablePlanDO getReceivablePlan(Long id) { + return crmReceivablePlanMapper.selectById(id); } @Override - public List getReceivablePlanList(Collection ids) { + public List getReceivablePlanList(Collection ids) { if (CollUtil.isEmpty(ids)) { return ListUtil.empty(); } - return receivablePlanMapper.selectBatchIds(ids); + return crmReceivablePlanMapper.selectBatchIds(ids); } @Override - public PageResult getReceivablePlanPage(ReceivablePlanPageReqVO pageReqVO) { - return receivablePlanMapper.selectPage(pageReqVO); + public PageResult getReceivablePlanPage(CrmReceivablePlanPageReqVO pageReqVO) { + return crmReceivablePlanMapper.selectPage(pageReqVO); } @Override - public List getReceivablePlanList(ReceivablePlanExportReqVO exportReqVO) { - return receivablePlanMapper.selectList(exportReqVO); + public List getReceivablePlanList(CrmReceivablePlanExportReqVO exportReqVO) { + return crmReceivablePlanMapper.selectList(exportReqVO); } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java similarity index 67% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableService.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java index a673ec99e..8875faaa9 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java @@ -4,7 +4,7 @@ import java.util.*; import javax.validation.*; import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; /** @@ -12,7 +12,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; * * @author 赤焰 */ -public interface ReceivableService { +public interface CrmReceivableService { /** * 创建回款管理 @@ -20,14 +20,14 @@ public interface ReceivableService { * @param createReqVO 创建信息 * @return 编号 */ - Long createReceivable(@Valid ReceivableCreateReqVO createReqVO); + Long createReceivable(@Valid CrmReceivableCreateReqVO createReqVO); /** * 更新回款管理 * * @param updateReqVO 更新信息 */ - void updateReceivable(@Valid ReceivableUpdateReqVO updateReqVO); + void updateReceivable(@Valid CrmReceivableUpdateReqVO updateReqVO); /** * 删除回款管理 @@ -42,7 +42,7 @@ public interface ReceivableService { * @param id 编号 * @return 回款管理 */ - ReceivableDO getReceivable(Long id); + CrmReceivableDO getReceivable(Long id); /** * 获得回款管理列表 @@ -50,7 +50,7 @@ public interface ReceivableService { * @param ids 编号 * @return 回款管理列表 */ - List getReceivableList(Collection ids); + List getReceivableList(Collection ids); /** * 获得回款管理分页 @@ -58,7 +58,7 @@ public interface ReceivableService { * @param pageReqVO 分页查询 * @return 回款管理分页 */ - PageResult getReceivablePage(ReceivablePageReqVO pageReqVO); + PageResult getReceivablePage(CrmReceivablePageReqVO pageReqVO); /** * 获得回款管理列表, 用于 Excel 导出 @@ -66,6 +66,6 @@ public interface ReceivableService { * @param exportReqVO 查询条件 * @return 回款管理列表 */ - List getReceivableList(ReceivableExportReqVO exportReqVO); + List getReceivableList(CrmReceivableExportReqVO exportReqVO); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java similarity index 62% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java index d3c7a16ef..ff751bc51 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java @@ -3,19 +3,18 @@ package cn.iocoder.yudao.module.crm.service.receivable; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableUpdateReqVO; -import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableExportReqVO; +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.customer.CrmCustomerDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; -import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; -import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; +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.service.customer.CrmCustomerService; @@ -36,21 +35,21 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; */ @Service @Validated -public class ReceivableServiceImpl implements ReceivableService { +public class CrmReceivableServiceImpl implements CrmReceivableService { @Resource - private ReceivableMapper receivableMapper; + private CrmReceivableMapper crmReceivableMapper; @Resource private ContractService contractService; @Resource private CrmCustomerService crmCustomerService; @Resource - private ReceivablePlanService receivablePlanService; + private CrmReceivablePlanService crmReceivablePlanService; @Override - public Long createReceivable(ReceivableCreateReqVO createReqVO) { + public Long createReceivable(CrmReceivableCreateReqVO createReqVO) { // 插入 - ReceivableDO receivable = ReceivableConvert.INSTANCE.convert(createReqVO); + CrmReceivableDO receivable = CrmReceivableConvert.INSTANCE.convert(createReqVO); if (ObjectUtil.isNull(receivable.getStatus())){ receivable.setStatus(CommonStatusEnum.ENABLE.getStatus()); } @@ -61,12 +60,12 @@ public class ReceivableServiceImpl implements ReceivableService { //校验 checkReceivable(receivable); - receivableMapper.insert(receivable); + crmReceivableMapper.insert(receivable); // 返回 return receivable.getId(); } - private void checkReceivable(ReceivableDO receivable) { + private void checkReceivable(CrmReceivableDO receivable) { if(ObjectUtil.isNull(receivable.getContractId())){ throw exception(CONTRACT_NOT_EXISTS); @@ -82,7 +81,7 @@ public class ReceivableServiceImpl implements ReceivableService { throw exception(CUSTOMER_NOT_EXISTS); } - ReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(receivable.getPlanId()); + CrmReceivablePlanDO receivablePlan = crmReceivablePlanService.getReceivablePlan(receivable.getPlanId()); if(ObjectUtil.isNull(receivablePlan)){ throw exception(RECEIVABLE_PLAN_NOT_EXISTS); } @@ -90,13 +89,13 @@ public class ReceivableServiceImpl implements ReceivableService { } @Override - public void updateReceivable(ReceivableUpdateReqVO updateReqVO) { + public void updateReceivable(CrmReceivableUpdateReqVO updateReqVO) { // 校验存在 validateReceivableExists(updateReqVO.getId()); // 更新 - ReceivableDO updateObj = ReceivableConvert.INSTANCE.convert(updateReqVO); - receivableMapper.updateById(updateObj); + CrmReceivableDO updateObj = CrmReceivableConvert.INSTANCE.convert(updateReqVO); + crmReceivableMapper.updateById(updateObj); } @Override @@ -104,36 +103,36 @@ public class ReceivableServiceImpl implements ReceivableService { // 校验存在 validateReceivableExists(id); // 删除 - receivableMapper.deleteById(id); + crmReceivableMapper.deleteById(id); } private void validateReceivableExists(Long id) { - if (receivableMapper.selectById(id) == null) { + if (crmReceivableMapper.selectById(id) == null) { throw exception(RECEIVABLE_NOT_EXISTS); } } @Override - public ReceivableDO getReceivable(Long id) { - return receivableMapper.selectById(id); + public CrmReceivableDO getReceivable(Long id) { + return crmReceivableMapper.selectById(id); } @Override - public List getReceivableList(Collection ids) { + public List getReceivableList(Collection ids) { if (CollUtil.isEmpty(ids)) { return ListUtil.empty(); } - return receivableMapper.selectBatchIds(ids); + return crmReceivableMapper.selectBatchIds(ids); } @Override - public PageResult getReceivablePage(ReceivablePageReqVO pageReqVO) { - return receivableMapper.selectPage(pageReqVO); + public PageResult getReceivablePage(CrmReceivablePageReqVO pageReqVO) { + return crmReceivableMapper.selectPage(pageReqVO); } @Override - public List getReceivableList(ReceivableExportReqVO exportReqVO) { - return receivableMapper.selectList(exportReqVO); + public List getReceivableList(CrmReceivableExportReqVO exportReqVO) { + return crmReceivableMapper.selectList(exportReqVO); } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivableMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/CrmReceivableMapper.xml similarity index 95% rename from yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivableMapper.xml rename to yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/CrmReceivableMapper.xml index b87beb08f..b2ab2042e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivableMapper.xml +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/CrmReceivableMapper.xml @@ -1,6 +1,6 @@ - + @@ -479,6 +476,8 @@ export default { // 打开表单,并设置初始化 this.open = true; this.title = "添加用户"; + // 为部门增加默认值 + this.form.deptId = this.queryParams.deptId; this.form.password = this.initPassword; }, /** 修改按钮操作 */ From a0c142f8863b6e5297fc648a85b7ea2782bb673c Mon Sep 17 00:00:00 2001 From: wgs7909 <87356667@qq.com> Date: Tue, 31 Oct 2023 06:42:12 +0800 Subject: [PATCH 049/101] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E7=BB=99=E9=83=A8=E9=97=A8=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC=E3=80=82=20=E5=AF=B9=E5=BA=94Issue,?= =?UTF-8?q?Cloud=E7=89=88=E6=9C=AC=E5=BA=93=E3=80=82=20https://gitee.com/z?= =?UTF-8?q?hijiantianya/yudao-cloud/issues/I8C4B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-ui-admin/src/views/system/user/index.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yudao-ui-admin/src/views/system/user/index.vue b/yudao-ui-admin/src/views/system/user/index.vue index 87cb1355f..c4f1b5297 100644 --- a/yudao-ui-admin/src/views/system/user/index.vue +++ b/yudao-ui-admin/src/views/system/user/index.vue @@ -1,5 +1,8 @@