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] =?UTF-8?q?feat:=20CRM=20=E7=BA=BF=E7=B4=A2=E8=A1=A8=20cru?=
 =?UTF-8?q?d?=
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<Long> createClue(@Valid @RequestBody CrmClueCreateReqVO createReqVO) {
+        return success(clueService.createClue(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新线索")
+    @PreAuthorize("@ss.hasPermission('crm:clue:update')")
+    public CommonResult<Boolean> 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<Boolean> 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<CrmClueRespVO> 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<List<CrmClueRespVO>> getClueList(@RequestParam("ids") Collection<Long> ids) {
+        List<CrmClueDO> list = clueService.getClueList(ids);
+        return success(CrmClueConvert.INSTANCE.convertList(list));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得线索分页")
+    @PreAuthorize("@ss.hasPermission('crm:clue:query')")
+    public CommonResult<PageResult<CrmClueRespVO>> getCluePage(@Valid CrmCluePageReqVO pageVO) {
+        PageResult<CrmClueDO> 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<CrmClueDO> list = clueService.getClueList(exportReqVO);
+        // 导出 Excel
+        List<CrmClueExcelVO> 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<CrmClueRespVO> convertList(List<CrmClueDO> list);
+
+    PageResult<CrmClueRespVO> convertPage(PageResult<CrmClueDO> page);
+
+    List<CrmClueExcelVO> convertList02(List<CrmClueDO> 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<CrmClueDO> {
+
+    default PageResult<CrmClueDO> selectPage(CrmCluePageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<CrmClueDO>()
+                .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<CrmClueDO> selectList(CrmClueExportReqVO reqVO) {
+        return selectList(new LambdaQueryWrapperX<CrmClueDO>()
+                .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<CrmClueDO> getClueList(Collection<Long> ids);
+
+    /**
+     * 获得线索分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 线索分页
+     */
+    PageResult<CrmClueDO> getCluePage(CrmCluePageReqVO pageReqVO);
+
+    /**
+     * 获得线索列表, 用于 Excel 导出
+     *
+     * @param exportReqVO 查询条件
+     * @return 线索列表
+     */
+    List<CrmClueDO> 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<CrmClueDO> getClueList(Collection<Long> ids) {
+        if (CollUtil.isEmpty(ids)) {
+            return ListUtil.empty();
+        }
+        return clueMapper.selectBatchIds(ids);
+    }
+
+    @Override
+    public PageResult<CrmClueDO> getCluePage(CrmCluePageReqVO pageReqVO) {
+        return clueMapper.selectPage(pageReqVO);
+    }
+
+    @Override
+    public List<CrmClueDO> 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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper">
+
+    <!--
+        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
+        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
+        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
+        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
+     -->
+
+</mapper>
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<CrmClueDO> 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<CrmClueDO> 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