Commit 34a5785768d6f14c0f05ab64c10ef095badfc3c3

Authored by liuhongfeng
1 parent 73f4fc8c

【新增】回款计划 功能

Showing 20 changed files with 1116 additions and 0 deletions
sql/mysql/crm.sql
@@ -93,3 +93,38 @@ CREATE TABLE `crm_receivable` ( @@ -93,3 +93,38 @@ CREATE TABLE `crm_receivable` (
93 `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号', 93 `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号',
94 PRIMARY KEY (`id`) USING BTREE 94 PRIMARY KEY (`id`) USING BTREE
95 ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '回款管理' ROW_FORMAT = DYNAMIC; 95 ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '回款管理' ROW_FORMAT = DYNAMIC;
  96 +
  97 +
  98 +-- ----------------------------
  99 +-- 回款计划表
  100 +-- ----------------------------
  101 +DROP TABLE IF EXISTS `crm_receivable_plan`;
  102 +CREATE TABLE `crm_receivable_plan` (
  103 + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  104 + `index_no` bigint(20) NULL DEFAULT NULL COMMENT '期数',
  105 + `receivable_id` bigint(20) NULL DEFAULT NULL COMMENT '回款ID',
  106 + `status` tinyint(4) NOT NULL COMMENT '完成状态',
  107 + `check_status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '审批状态',
  108 + `process_instance_id` bigint(20) NULL DEFAULT NULL COMMENT '工作流编号',
  109 + `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '计划回款金额',
  110 + `return_time` datetime NULL DEFAULT NULL COMMENT '计划回款日期',
  111 + `remind_days` bigint(20) NULL DEFAULT NULL COMMENT '提前几天提醒',
  112 + `remind_time` datetime NULL DEFAULT NULL COMMENT '提醒日期',
  113 + `customer_id` bigint(20) NULL DEFAULT NULL COMMENT '客户ID',
  114 + `contract_id` bigint(20) NULL DEFAULT NULL COMMENT '合同ID',
  115 + `owner_user_id` bigint(20) NULL DEFAULT NULL COMMENT '负责人',
  116 + `sort` int(11) NULL DEFAULT NULL COMMENT '显示顺序',
  117 + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
  118 + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  119 + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  120 + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  121 + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  122 + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  123 + `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号',
  124 + PRIMARY KEY (`id`) USING BTREE
  125 +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '回款计划' ROW_FORMAT = DYNAMIC;
  126 +
  127 +
  128 +
  129 +
  130 +
sql/mysql/crm_menu.sql
@@ -184,3 +184,64 @@ VALUES ( @@ -184,3 +184,64 @@ VALUES (
184 '回款管理导出', 'crm:receivable:export', 3, 5, @parentId, 184 '回款管理导出', 'crm:receivable:export', 3, 5, @parentId,
185 '', '', '', 0 185 '', '', '', 0
186 ); 186 );
  187 +
  188 +
  189 +-- ----------------------------
  190 +-- 回款计划菜单
  191 +-- ----------------------------
  192 +
  193 +-- 菜单 SQL
  194 +INSERT INTO system_menu(
  195 + name, permission, type, sort, parent_id,
  196 + path, icon, component, status, component_name
  197 +)
  198 +VALUES (
  199 + '回款计划管理', '', 2, 0, 2375,
  200 + 'receivable-plan', '', 'crm/receivablePlan/index', 0, 'ReceivablePlan'
  201 + );
  202 +
  203 +-- 按钮父菜单ID
  204 +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码
  205 +SELECT @parentId := LAST_INSERT_ID();
  206 +
  207 +-- 按钮 SQL
  208 +INSERT INTO system_menu(
  209 + name, permission, type, sort, parent_id,
  210 + path, icon, component, status
  211 +)
  212 +VALUES (
  213 + '回款计划查询', 'crm:receivable-plan:query', 3, 1, @parentId,
  214 + '', '', '', 0
  215 + );
  216 +INSERT INTO system_menu(
  217 + name, permission, type, sort, parent_id,
  218 + path, icon, component, status
  219 +)
  220 +VALUES (
  221 + '回款计划创建', 'crm:receivable-plan:create', 3, 2, @parentId,
  222 + '', '', '', 0
  223 + );
  224 +INSERT INTO system_menu(
  225 + name, permission, type, sort, parent_id,
  226 + path, icon, component, status
  227 +)
  228 +VALUES (
  229 + '回款计划更新', 'crm:receivable-plan:update', 3, 3, @parentId,
  230 + '', '', '', 0
  231 + );
  232 +INSERT INTO system_menu(
  233 + name, permission, type, sort, parent_id,
  234 + path, icon, component, status
  235 +)
  236 +VALUES (
  237 + '回款计划删除', 'crm:receivable-plan:delete', 3, 4, @parentId,
  238 + '', '', '', 0
  239 + );
  240 +INSERT INTO system_menu(
  241 + name, permission, type, sort, parent_id,
  242 + path, icon, component, status
  243 +)
  244 +VALUES (
  245 + '回款计划导出', 'crm:receivable-plan:export', 3, 5, @parentId,
  246 + '', '', '', 0
  247 + );
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 { @@ -17,4 +17,6 @@ public interface ErrorCodeConstants {
17 17
18 ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_030_000_001, "回款管理不存在"); 18 ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_030_000_001, "回款管理不存在");
19 19
  20 + ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_040_000_001, "回款计划不存在");
  21 +
20 } 22 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.receivable;
  2 +
  3 +import org.springframework.web.bind.annotation.*;
  4 +import javax.annotation.Resource;
  5 +import org.springframework.validation.annotation.Validated;
  6 +import org.springframework.security.access.prepost.PreAuthorize;
  7 +import io.swagger.v3.oas.annotations.tags.Tag;
  8 +import io.swagger.v3.oas.annotations.Parameter;
  9 +import io.swagger.v3.oas.annotations.Operation;
  10 +
  11 +import javax.validation.constraints.*;
  12 +import javax.validation.*;
  13 +import javax.servlet.http.*;
  14 +import java.util.*;
  15 +import java.io.IOException;
  16 +
  17 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  18 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  19 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  20 +
  21 +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
  22 +
  23 +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
  24 +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
  25 +
  26 +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*;
  27 +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO;
  28 +import cn.iocoder.yudao.module.crm.convert.receivable.ReceivablePlanConvert;
  29 +import cn.iocoder.yudao.module.crm.service.receivable.ReceivablePlanService;
  30 +
  31 +/**
  32 + * @author 赤焰
  33 + */
  34 +@Tag(name = "管理后台 - 回款计划")
  35 +@RestController
  36 +@RequestMapping("/crm/receivable-plan")
  37 +@Validated
  38 +public class ReceivablePlanController {
  39 +
  40 + @Resource
  41 + private ReceivablePlanService receivablePlanService;
  42 +
  43 + @PostMapping("/create")
  44 + @Operation(summary = "创建回款计划")
  45 + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:create')")
  46 + public CommonResult<Long> createReceivablePlan(@Valid @RequestBody ReceivablePlanCreateReqVO createReqVO) {
  47 + return success(receivablePlanService.createReceivablePlan(createReqVO));
  48 + }
  49 +
  50 + @PutMapping("/update")
  51 + @Operation(summary = "更新回款计划")
  52 + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:update')")
  53 + public CommonResult<Boolean> updateReceivablePlan(@Valid @RequestBody ReceivablePlanUpdateReqVO updateReqVO) {
  54 + receivablePlanService.updateReceivablePlan(updateReqVO);
  55 + return success(true);
  56 + }
  57 +
  58 + @DeleteMapping("/delete")
  59 + @Operation(summary = "删除回款计划")
  60 + @Parameter(name = "id", description = "编号", required = true)
  61 + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:delete')")
  62 + public CommonResult<Boolean> deleteReceivablePlan(@RequestParam("id") Long id) {
  63 + receivablePlanService.deleteReceivablePlan(id);
  64 + return success(true);
  65 + }
  66 +
  67 + @GetMapping("/get")
  68 + @Operation(summary = "获得回款计划")
  69 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  70 + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')")
  71 + public CommonResult<ReceivablePlanRespVO> getReceivablePlan(@RequestParam("id") Long id) {
  72 + ReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(id);
  73 + return success(ReceivablePlanConvert.INSTANCE.convert(receivablePlan));
  74 + }
  75 +
  76 + @GetMapping("/list")
  77 + @Operation(summary = "获得回款计划列表")
  78 + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
  79 + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')")
  80 + public CommonResult<List<ReceivablePlanRespVO>> getReceivablePlanList(@RequestParam("ids") Collection<Long> ids) {
  81 + List<ReceivablePlanDO> list = receivablePlanService.getReceivablePlanList(ids);
  82 + return success(ReceivablePlanConvert.INSTANCE.convertList(list));
  83 + }
  84 +
  85 + @GetMapping("/page")
  86 + @Operation(summary = "获得回款计划分页")
  87 + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')")
  88 + public CommonResult<PageResult<ReceivablePlanRespVO>> getReceivablePlanPage(@Valid ReceivablePlanPageReqVO pageVO) {
  89 + PageResult<ReceivablePlanDO> pageResult = receivablePlanService.getReceivablePlanPage(pageVO);
  90 + return success(ReceivablePlanConvert.INSTANCE.convertPage(pageResult));
  91 + }
  92 +
  93 + @GetMapping("/export-excel")
  94 + @Operation(summary = "导出回款计划 Excel")
  95 + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:export')")
  96 + @OperateLog(type = EXPORT)
  97 + public void exportReceivablePlanExcel(@Valid ReceivablePlanExportReqVO exportReqVO,
  98 + HttpServletResponse response) throws IOException {
  99 + List<ReceivablePlanDO> list = receivablePlanService.getReceivablePlanList(exportReqVO);
  100 + // 导出 Excel
  101 + List<ReceivablePlanExcelVO> datas = ReceivablePlanConvert.INSTANCE.convertList02(list);
  102 + ExcelUtils.write(response, "回款计划.xls", "数据", ReceivablePlanExcelVO.class, datas);
  103 + }
  104 +
  105 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.util.*;
  6 +import java.math.BigDecimal;
  7 +import java.time.LocalDateTime;
  8 +import java.time.LocalDateTime;
  9 +import java.time.LocalDateTime;
  10 +import java.time.LocalDateTime;
  11 +import javax.validation.constraints.*;
  12 +import org.springframework.format.annotation.DateTimeFormat;
  13 +
  14 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  15 +
  16 +/**
  17 + * 回款计划 Base VO,提供给添加、修改、详细的子 VO 使用
  18 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
  19 + */
  20 +@Data
  21 +public class ReceivablePlanBaseVO {
  22 +
  23 + @Schema(description = "期数")
  24 + private Long indexNo;
  25 +
  26 + @Schema(description = "回款ID", example = "19852")
  27 + private Long receivableId;
  28 +
  29 + @Schema(description = "完成状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
  30 + //@NotNull(message = "完成状态不能为空")
  31 + private Integer status;
  32 +
  33 + @Schema(description = "审批状态", example = "1")
  34 + private String checkStatus;
  35 +
  36 + @Schema(description = "工作流编号", example = "8909")
  37 + private Long processInstanceId;
  38 +
  39 + @Schema(description = "计划回款金额", example = "29675")
  40 + private BigDecimal price;
  41 +
  42 + @Schema(description = "计划回款日期")
  43 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  44 + private LocalDateTime returnTime;
  45 +
  46 + @Schema(description = "提前几天提醒")
  47 + private Long remindDays;
  48 +
  49 + @Schema(description = "提醒日期")
  50 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  51 + private LocalDateTime remindTime;
  52 +
  53 + @Schema(description = "客户ID", example = "18026")
  54 + private Long customerId;
  55 +
  56 + @Schema(description = "合同ID", example = "3473")
  57 + private Long contractId;
  58 +
  59 + @Schema(description = "负责人", example = "17828")
  60 + private Long ownerUserId;
  61 +
  62 + @Schema(description = "显示顺序")
  63 + private Integer sort;
  64 +
  65 + @Schema(description = "备注", example = "随便")
  66 + private String remark;
  67 +
  68 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanCreateReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
  6 +import javax.validation.constraints.*;
  7 +
  8 +@Schema(description = "管理后台 - 回款计划创建 Request VO")
  9 +@Data
  10 +@EqualsAndHashCode(callSuper = true)
  11 +@ToString(callSuper = true)
  12 +public class ReceivablePlanCreateReqVO extends ReceivablePlanBaseVO {
  13 +
  14 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.util.*;
  6 +import java.math.BigDecimal;
  7 +import java.time.LocalDateTime;
  8 +import java.time.LocalDateTime;
  9 +import java.time.LocalDateTime;
  10 +import java.time.LocalDateTime;
  11 +
  12 +import com.alibaba.excel.annotation.ExcelProperty;
  13 +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
  14 +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
  15 +
  16 +
  17 +/**
  18 + * 回款计划 Excel VO
  19 + *
  20 + * @author 芋道源码
  21 + */
  22 +@Data
  23 +public class ReceivablePlanExcelVO {
  24 +
  25 + @ExcelProperty("ID")
  26 + private Long id;
  27 +
  28 + @ExcelProperty("期数")
  29 + private Long indexNo;
  30 +
  31 + @ExcelProperty("回款ID")
  32 + private Long receivableId;
  33 +
  34 + @ExcelProperty(value = "完成状态", converter = DictConvert.class)
  35 + @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
  36 + private Integer status;
  37 +
  38 + @ExcelProperty(value = "审批状态", converter = DictConvert.class)
  39 + @DictFormat("crm_receivable_check_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
  40 + private String checkStatus;
  41 +
  42 + //@ExcelProperty("工作流编号")
  43 + //private Long processInstanceId;
  44 +
  45 + @ExcelProperty("计划回款金额")
  46 + private BigDecimal price;
  47 +
  48 + @ExcelProperty("计划回款日期")
  49 + private LocalDateTime returnTime;
  50 +
  51 + @ExcelProperty("提前几天提醒")
  52 + private Long remindDays;
  53 +
  54 + @ExcelProperty("提醒日期")
  55 + private LocalDateTime remindTime;
  56 +
  57 + @ExcelProperty("客户ID")
  58 + private Long customerId;
  59 +
  60 + @ExcelProperty("合同ID")
  61 + private Long contractId;
  62 +
  63 + @ExcelProperty("负责人")
  64 + private Long ownerUserId;
  65 +
  66 + //@ExcelProperty("显示顺序")
  67 + //private Integer sort;
  68 +
  69 + @ExcelProperty("备注")
  70 + private String remark;
  71 +
  72 + @ExcelProperty("创建时间")
  73 + private LocalDateTime createTime;
  74 +
  75 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
  6 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  7 +import java.time.LocalDateTime;
  8 +import org.springframework.format.annotation.DateTimeFormat;
  9 +
  10 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  11 +
  12 +@Schema(description = "管理后台 - 回款计划 Excel 导出 Request VO,参数和 ReceivablePlanPageReqVO 是一致的")
  13 +@Data
  14 +public class ReceivablePlanExportReqVO {
  15 +
  16 + @Schema(description = "期数")
  17 + private Long indexNo;
  18 +
  19 + @Schema(description = "完成状态", example = "2")
  20 + private Integer status;
  21 +
  22 + @Schema(description = "审批状态", example = "1")
  23 + private String checkStatus;
  24 +
  25 + @Schema(description = "计划回款日期")
  26 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  27 + private LocalDateTime[] returnTime;
  28 +
  29 + @Schema(description = "提前几天提醒")
  30 + private Long remindDays;
  31 +
  32 + @Schema(description = "提醒日期")
  33 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  34 + private LocalDateTime[] remindTime;
  35 +
  36 + @Schema(description = "客户ID", example = "18026")
  37 + private Long customerId;
  38 +
  39 + @Schema(description = "合同ID", example = "3473")
  40 + private Long contractId;
  41 +
  42 + @Schema(description = "负责人", example = "17828")
  43 + private Long ownerUserId;
  44 +
  45 + @Schema(description = "备注", example = "随便")
  46 + private String remark;
  47 +
  48 + @Schema(description = "创建时间")
  49 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  50 + private LocalDateTime[] createTime;
  51 +
  52 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
  6 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  7 +import org.springframework.format.annotation.DateTimeFormat;
  8 +import java.time.LocalDateTime;
  9 +
  10 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  11 +
  12 +@Schema(description = "管理后台 - 回款计划分页 Request VO")
  13 +@Data
  14 +@EqualsAndHashCode(callSuper = true)
  15 +@ToString(callSuper = true)
  16 +public class ReceivablePlanPageReqVO extends PageParam {
  17 +
  18 + @Schema(description = "期数")
  19 + private Long indexNo;
  20 +
  21 + @Schema(description = "完成状态", example = "2")
  22 + private Integer status;
  23 +
  24 + @Schema(description = "审批状态", example = "1")
  25 + private String checkStatus;
  26 +
  27 + @Schema(description = "计划回款日期")
  28 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  29 + private LocalDateTime[] returnTime;
  30 +
  31 + @Schema(description = "提前几天提醒")
  32 + private Long remindDays;
  33 +
  34 + @Schema(description = "提醒日期")
  35 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  36 + private LocalDateTime[] remindTime;
  37 +
  38 + @Schema(description = "客户ID", example = "18026")
  39 + private Long customerId;
  40 +
  41 + @Schema(description = "合同ID", example = "3473")
  42 + private Long contractId;
  43 +
  44 + @Schema(description = "负责人", example = "17828")
  45 + private Long ownerUserId;
  46 +
  47 + @Schema(description = "备注", example = "随便")
  48 + private String remark;
  49 +
  50 + @Schema(description = "创建时间")
  51 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  52 + private LocalDateTime[] createTime;
  53 +
  54 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.time.LocalDateTime;
  6 +
  7 +@Schema(description = "管理后台 - 回款计划 Response VO")
  8 +@Data
  9 +@EqualsAndHashCode(callSuper = true)
  10 +@ToString(callSuper = true)
  11 +public class ReceivablePlanRespVO extends ReceivablePlanBaseVO {
  12 +
  13 + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25153")
  14 + private Long id;
  15 +
  16 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  17 + private LocalDateTime createTime;
  18 +
  19 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanUpdateReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.*;
  5 +import java.util.*;
  6 +import javax.validation.constraints.*;
  7 +
  8 +@Schema(description = "管理后台 - 回款计划更新 Request VO")
  9 +@Data
  10 +@EqualsAndHashCode(callSuper = true)
  11 +@ToString(callSuper = true)
  12 +public class ReceivablePlanUpdateReqVO extends ReceivablePlanBaseVO {
  13 +
  14 + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25153")
  15 + @NotNull(message = "ID不能为空")
  16 + private Long id;
  17 +
  18 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivablePlanConvert.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.convert.receivable;
  2 +
  3 +import java.util.*;
  4 +
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +
  7 +import org.mapstruct.Mapper;
  8 +import org.mapstruct.factory.Mappers;
  9 +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*;
  10 +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO;
  11 +
  12 +/**
  13 + * 回款计划 Convert
  14 + *
  15 + * @author 芋道源码
  16 + */
  17 +@Mapper
  18 +public interface ReceivablePlanConvert {
  19 +
  20 + ReceivablePlanConvert INSTANCE = Mappers.getMapper(ReceivablePlanConvert.class);
  21 +
  22 + ReceivablePlanDO convert(ReceivablePlanCreateReqVO bean);
  23 +
  24 + ReceivablePlanDO convert(ReceivablePlanUpdateReqVO bean);
  25 +
  26 + ReceivablePlanRespVO convert(ReceivablePlanDO bean);
  27 +
  28 + List<ReceivablePlanRespVO> convertList(List<ReceivablePlanDO> list);
  29 +
  30 + PageResult<ReceivablePlanRespVO> convertPage(PageResult<ReceivablePlanDO> page);
  31 +
  32 + List<ReceivablePlanExcelVO> convertList02(List<ReceivablePlanDO> list);
  33 +
  34 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.dal.dataobject.receivable;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import java.math.BigDecimal;
  6 +import java.time.LocalDateTime;
  7 +import java.time.LocalDateTime;
  8 +import java.time.LocalDateTime;
  9 +import java.time.LocalDateTime;
  10 +import com.baomidou.mybatisplus.annotation.*;
  11 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  12 +
  13 +/**
  14 + * 回款计划 DO
  15 + *
  16 + * @author 芋道源码
  17 + */
  18 +@TableName("crm_receivable_plan")
  19 +@KeySequence("crm_receivable_plan_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  20 +@Data
  21 +@EqualsAndHashCode(callSuper = true)
  22 +@ToString(callSuper = true)
  23 +@Builder
  24 +@NoArgsConstructor
  25 +@AllArgsConstructor
  26 +public class ReceivablePlanDO extends BaseDO {
  27 +
  28 + /**
  29 + * ID
  30 + */
  31 + @TableId
  32 + private Long id;
  33 + /**
  34 + * 期数
  35 + */
  36 + private Long indexNo;
  37 + /**
  38 + * 回款ID
  39 + */
  40 + private Long receivableId;
  41 + /**
  42 + * 完成状态
  43 + *
  44 + * 枚举 {@link TODO common_status 对应的类}
  45 + */
  46 + private Integer status;
  47 + /**
  48 + * 审批状态
  49 + *
  50 + * 枚举 {@link TODO crm_receivable_check_status 对应的类}
  51 + */
  52 + private String checkStatus;
  53 + /**
  54 + * 工作流编号
  55 + */
  56 + private Long processInstanceId;
  57 + /**
  58 + * 计划回款金额
  59 + */
  60 + private BigDecimal price;
  61 + /**
  62 + * 计划回款日期
  63 + */
  64 + private LocalDateTime returnTime;
  65 + /**
  66 + * 提前几天提醒
  67 + */
  68 + private Long remindDays;
  69 + /**
  70 + * 提醒日期
  71 + */
  72 + private LocalDateTime remindTime;
  73 + /**
  74 + * 客户ID
  75 + */
  76 + private Long customerId;
  77 + /**
  78 + * 合同ID
  79 + */
  80 + private Long contractId;
  81 + /**
  82 + * 负责人
  83 + */
  84 + private Long ownerUserId;
  85 + /**
  86 + * 显示顺序
  87 + */
  88 + private Integer sort;
  89 + /**
  90 + * 备注
  91 + */
  92 + private String remark;
  93 +
  94 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.dal.mysql.receivable;
  2 +
  3 +import java.util.*;
  4 +
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  7 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  8 +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO;
  9 +import org.apache.ibatis.annotations.Mapper;
  10 +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*;
  11 +
  12 +/**
  13 + * 回款计划 Mapper
  14 + *
  15 + * @author 芋道源码
  16 + */
  17 +@Mapper
  18 +public interface ReceivablePlanMapper extends BaseMapperX<ReceivablePlanDO> {
  19 +
  20 + default PageResult<ReceivablePlanDO> selectPage(ReceivablePlanPageReqVO reqVO) {
  21 + return selectPage(reqVO, new LambdaQueryWrapperX<ReceivablePlanDO>()
  22 + .eqIfPresent(ReceivablePlanDO::getIndexNo, reqVO.getIndexNo())
  23 + .eqIfPresent(ReceivablePlanDO::getStatus, reqVO.getStatus())
  24 + .eqIfPresent(ReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus())
  25 + .betweenIfPresent(ReceivablePlanDO::getReturnTime, reqVO.getReturnTime())
  26 + .eqIfPresent(ReceivablePlanDO::getRemindDays, reqVO.getRemindDays())
  27 + .betweenIfPresent(ReceivablePlanDO::getRemindTime, reqVO.getRemindTime())
  28 + .eqIfPresent(ReceivablePlanDO::getCustomerId, reqVO.getCustomerId())
  29 + .eqIfPresent(ReceivablePlanDO::getContractId, reqVO.getContractId())
  30 + .eqIfPresent(ReceivablePlanDO::getOwnerUserId, reqVO.getOwnerUserId())
  31 + .eqIfPresent(ReceivablePlanDO::getRemark, reqVO.getRemark())
  32 + .betweenIfPresent(ReceivablePlanDO::getCreateTime, reqVO.getCreateTime())
  33 + .orderByDesc(ReceivablePlanDO::getId));
  34 + }
  35 +
  36 + default List<ReceivablePlanDO> selectList(ReceivablePlanExportReqVO reqVO) {
  37 + return selectList(new LambdaQueryWrapperX<ReceivablePlanDO>()
  38 + .eqIfPresent(ReceivablePlanDO::getIndexNo, reqVO.getIndexNo())
  39 + .eqIfPresent(ReceivablePlanDO::getStatus, reqVO.getStatus())
  40 + .eqIfPresent(ReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus())
  41 + .betweenIfPresent(ReceivablePlanDO::getReturnTime, reqVO.getReturnTime())
  42 + .eqIfPresent(ReceivablePlanDO::getRemindDays, reqVO.getRemindDays())
  43 + .betweenIfPresent(ReceivablePlanDO::getRemindTime, reqVO.getRemindTime())
  44 + .eqIfPresent(ReceivablePlanDO::getCustomerId, reqVO.getCustomerId())
  45 + .eqIfPresent(ReceivablePlanDO::getContractId, reqVO.getContractId())
  46 + .eqIfPresent(ReceivablePlanDO::getOwnerUserId, reqVO.getOwnerUserId())
  47 + .eqIfPresent(ReceivablePlanDO::getRemark, reqVO.getRemark())
  48 + .betweenIfPresent(ReceivablePlanDO::getCreateTime, reqVO.getCreateTime())
  49 + .orderByDesc(ReceivablePlanDO::getId));
  50 + }
  51 +
  52 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.service.receivable;
  2 +
  3 +import java.util.*;
  4 +import javax.validation.*;
  5 +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*;
  6 +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO;
  7 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  8 +
  9 +/**
  10 + * 回款计划 Service 接口
  11 + *
  12 + * @author 芋道源码
  13 + */
  14 +public interface ReceivablePlanService {
  15 +
  16 + /**
  17 + * 创建回款计划
  18 + *
  19 + * @param createReqVO 创建信息
  20 + * @return 编号
  21 + */
  22 + Long createReceivablePlan(@Valid ReceivablePlanCreateReqVO createReqVO);
  23 +
  24 + /**
  25 + * 更新回款计划
  26 + *
  27 + * @param updateReqVO 更新信息
  28 + */
  29 + void updateReceivablePlan(@Valid ReceivablePlanUpdateReqVO updateReqVO);
  30 +
  31 + /**
  32 + * 删除回款计划
  33 + *
  34 + * @param id 编号
  35 + */
  36 + void deleteReceivablePlan(Long id);
  37 +
  38 + /**
  39 + * 获得回款计划
  40 + *
  41 + * @param id 编号
  42 + * @return 回款计划
  43 + */
  44 + ReceivablePlanDO getReceivablePlan(Long id);
  45 +
  46 + /**
  47 + * 获得回款计划列表
  48 + *
  49 + * @param ids 编号
  50 + * @return 回款计划列表
  51 + */
  52 + List<ReceivablePlanDO> getReceivablePlanList(Collection<Long> ids);
  53 +
  54 + /**
  55 + * 获得回款计划分页
  56 + *
  57 + * @param pageReqVO 分页查询
  58 + * @return 回款计划分页
  59 + */
  60 + PageResult<ReceivablePlanDO> getReceivablePlanPage(ReceivablePlanPageReqVO pageReqVO);
  61 +
  62 + /**
  63 + * 获得回款计划列表, 用于 Excel 导出
  64 + *
  65 + * @param exportReqVO 查询条件
  66 + * @return 回款计划列表
  67 + */
  68 + List<ReceivablePlanDO> getReceivablePlanList(ReceivablePlanExportReqVO exportReqVO);
  69 +
  70 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.service.receivable;
  2 +
  3 +import cn.hutool.core.util.ObjectUtil;
  4 +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
  5 +import org.springframework.stereotype.Service;
  6 +import javax.annotation.Resource;
  7 +import org.springframework.validation.annotation.Validated;
  8 +
  9 +import java.util.*;
  10 +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*;
  11 +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO;
  12 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  13 +
  14 +import cn.iocoder.yudao.module.crm.convert.receivable.ReceivablePlanConvert;
  15 +import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivablePlanMapper;
  16 +
  17 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  18 +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
  19 +
  20 +import cn.hutool.core.collection.CollUtil;
  21 +import cn.hutool.core.collection.ListUtil;
  22 +
  23 +/**
  24 + * 回款计划 Service 实现类
  25 + *
  26 + * @author 芋道源码
  27 + */
  28 +@Service
  29 +@Validated
  30 +public class ReceivablePlanServiceImpl implements ReceivablePlanService {
  31 +
  32 + @Resource
  33 + private ReceivablePlanMapper receivablePlanMapper;
  34 +
  35 + @Override
  36 + public Long createReceivablePlan(ReceivablePlanCreateReqVO createReqVO) {
  37 + // 插入
  38 + ReceivablePlanDO receivablePlan = ReceivablePlanConvert.INSTANCE.convert(createReqVO);
  39 + if(ObjectUtil.isNull(receivablePlan.getStatus())){
  40 + receivablePlan.setStatus(CommonStatusEnum.ENABLE.getStatus());
  41 + }
  42 + receivablePlanMapper.insert(receivablePlan);
  43 + // 返回
  44 + return receivablePlan.getId();
  45 + }
  46 +
  47 + @Override
  48 + public void updateReceivablePlan(ReceivablePlanUpdateReqVO updateReqVO) {
  49 + // 校验存在
  50 + validateReceivablePlanExists(updateReqVO.getId());
  51 + // 更新
  52 + ReceivablePlanDO updateObj = ReceivablePlanConvert.INSTANCE.convert(updateReqVO);
  53 + receivablePlanMapper.updateById(updateObj);
  54 + }
  55 +
  56 + @Override
  57 + public void deleteReceivablePlan(Long id) {
  58 + // 校验存在
  59 + validateReceivablePlanExists(id);
  60 + // 删除
  61 + receivablePlanMapper.deleteById(id);
  62 + }
  63 +
  64 + private void validateReceivablePlanExists(Long id) {
  65 + if (receivablePlanMapper.selectById(id) == null) {
  66 + throw exception(RECEIVABLE_PLAN_NOT_EXISTS);
  67 + }
  68 + }
  69 +
  70 + @Override
  71 + public ReceivablePlanDO getReceivablePlan(Long id) {
  72 + return receivablePlanMapper.selectById(id);
  73 + }
  74 +
  75 + @Override
  76 + public List<ReceivablePlanDO> getReceivablePlanList(Collection<Long> ids) {
  77 + if (CollUtil.isEmpty(ids)) {
  78 + return ListUtil.empty();
  79 + }
  80 + return receivablePlanMapper.selectBatchIds(ids);
  81 + }
  82 +
  83 + @Override
  84 + public PageResult<ReceivablePlanDO> getReceivablePlanPage(ReceivablePlanPageReqVO pageReqVO) {
  85 + return receivablePlanMapper.selectPage(pageReqVO);
  86 + }
  87 +
  88 + @Override
  89 + public List<ReceivablePlanDO> getReceivablePlanList(ReceivablePlanExportReqVO exportReqVO) {
  90 + return receivablePlanMapper.selectList(exportReqVO);
  91 + }
  92 +
  93 +}
yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivablePlanMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3 +<mapper namespace="cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivablePlanMapper">
  4 +
  5 + <!--
  6 + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
  7 + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
  8 + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
  9 + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
  10 + -->
  11 +
  12 +</mapper>
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.service.receivable;
  2 +
  3 +import org.junit.jupiter.api.Disabled;
  4 +import org.junit.jupiter.api.Test;
  5 +import org.springframework.boot.test.mock.mockito.MockBean;
  6 +
  7 +import javax.annotation.Resource;
  8 +
  9 +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
  10 +
  11 +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*;
  12 +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO;
  13 +import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivablePlanMapper;
  14 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  15 +
  16 +import javax.annotation.Resource;
  17 +import org.springframework.context.annotation.Import;
  18 +import java.util.*;
  19 +import java.time.LocalDateTime;
  20 +
  21 +import static cn.hutool.core.util.RandomUtil.*;
  22 +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
  23 +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*;
  24 +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
  25 +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*;
  26 +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*;
  27 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*;
  28 +import static org.junit.jupiter.api.Assertions.*;
  29 +import static org.mockito.Mockito.*;
  30 +
  31 +/**
  32 + * {@link ReceivablePlanServiceImpl} 的单元测试类
  33 + *
  34 + * @author 芋道源码
  35 + */
  36 +@Import(ReceivablePlanServiceImpl.class)
  37 +public class ReceivablePlanServiceImplTest extends BaseDbUnitTest {
  38 +
  39 + @Resource
  40 + private ReceivablePlanServiceImpl receivablePlanService;
  41 +
  42 + @Resource
  43 + private ReceivablePlanMapper receivablePlanMapper;
  44 +
  45 + @Test
  46 + public void testCreateReceivablePlan_success() {
  47 + // 准备参数
  48 + ReceivablePlanCreateReqVO reqVO = randomPojo(ReceivablePlanCreateReqVO.class);
  49 +
  50 + // 调用
  51 + Long receivablePlanId = receivablePlanService.createReceivablePlan(reqVO);
  52 + // 断言
  53 + assertNotNull(receivablePlanId);
  54 + // 校验记录的属性是否正确
  55 + ReceivablePlanDO receivablePlan = receivablePlanMapper.selectById(receivablePlanId);
  56 + assertPojoEquals(reqVO, receivablePlan);
  57 + }
  58 +
  59 + @Test
  60 + public void testUpdateReceivablePlan_success() {
  61 + // mock 数据
  62 + ReceivablePlanDO dbReceivablePlan = randomPojo(ReceivablePlanDO.class);
  63 + receivablePlanMapper.insert(dbReceivablePlan);// @Sql: 先插入出一条存在的数据
  64 + // 准备参数
  65 + ReceivablePlanUpdateReqVO reqVO = randomPojo(ReceivablePlanUpdateReqVO.class, o -> {
  66 + o.setId(dbReceivablePlan.getId()); // 设置更新的 ID
  67 + });
  68 +
  69 + // 调用
  70 + receivablePlanService.updateReceivablePlan(reqVO);
  71 + // 校验是否更新正确
  72 + ReceivablePlanDO receivablePlan = receivablePlanMapper.selectById(reqVO.getId()); // 获取最新的
  73 + assertPojoEquals(reqVO, receivablePlan);
  74 + }
  75 +
  76 + @Test
  77 + public void testUpdateReceivablePlan_notExists() {
  78 + // 准备参数
  79 + ReceivablePlanUpdateReqVO reqVO = randomPojo(ReceivablePlanUpdateReqVO.class);
  80 +
  81 + // 调用, 并断言异常
  82 + assertServiceException(() -> receivablePlanService.updateReceivablePlan(reqVO), RECEIVABLE_PLAN_NOT_EXISTS);
  83 + }
  84 +
  85 + @Test
  86 + public void testDeleteReceivablePlan_success() {
  87 + // mock 数据
  88 + ReceivablePlanDO dbReceivablePlan = randomPojo(ReceivablePlanDO.class);
  89 + receivablePlanMapper.insert(dbReceivablePlan);// @Sql: 先插入出一条存在的数据
  90 + // 准备参数
  91 + Long id = dbReceivablePlan.getId();
  92 +
  93 + // 调用
  94 + receivablePlanService.deleteReceivablePlan(id);
  95 + // 校验数据不存在了
  96 + assertNull(receivablePlanMapper.selectById(id));
  97 + }
  98 +
  99 + @Test
  100 + public void testDeleteReceivablePlan_notExists() {
  101 + // 准备参数
  102 + Long id = randomLongId();
  103 +
  104 + // 调用, 并断言异常
  105 + assertServiceException(() -> receivablePlanService.deleteReceivablePlan(id), RECEIVABLE_PLAN_NOT_EXISTS);
  106 + }
  107 +
  108 + @Test
  109 + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
  110 + public void testGetReceivablePlanPage() {
  111 + // mock 数据
  112 + ReceivablePlanDO dbReceivablePlan = randomPojo(ReceivablePlanDO.class, o -> { // 等会查询到
  113 + o.setIndexNo(null);
  114 + o.setStatus(null);
  115 + o.setCheckStatus(null);
  116 + o.setReturnTime(null);
  117 + o.setRemindDays(null);
  118 + o.setRemindTime(null);
  119 + o.setCustomerId(null);
  120 + o.setContractId(null);
  121 + o.setOwnerUserId(null);
  122 + o.setRemark(null);
  123 + o.setCreateTime(null);
  124 + });
  125 + receivablePlanMapper.insert(dbReceivablePlan);
  126 + // 测试 indexNo 不匹配
  127 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setIndexNo(null)));
  128 + // 测试 status 不匹配
  129 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setStatus(null)));
  130 + // 测试 checkStatus 不匹配
  131 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCheckStatus(null)));
  132 + // 测试 returnTime 不匹配
  133 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setReturnTime(null)));
  134 + // 测试 remindDays 不匹配
  135 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindDays(null)));
  136 + // 测试 remindTime 不匹配
  137 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindTime(null)));
  138 + // 测试 customerId 不匹配
  139 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCustomerId(null)));
  140 + // 测试 contractId 不匹配
  141 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setContractId(null)));
  142 + // 测试 ownerUserId 不匹配
  143 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setOwnerUserId(null)));
  144 + // 测试 remark 不匹配
  145 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemark(null)));
  146 + // 测试 createTime 不匹配
  147 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCreateTime(null)));
  148 + // 准备参数
  149 + ReceivablePlanPageReqVO reqVO = new ReceivablePlanPageReqVO();
  150 + reqVO.setIndexNo(null);
  151 + reqVO.setStatus(null);
  152 + reqVO.setCheckStatus(null);
  153 + reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
  154 + reqVO.setRemindDays(null);
  155 + reqVO.setRemindTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
  156 + reqVO.setCustomerId(null);
  157 + reqVO.setContractId(null);
  158 + reqVO.setOwnerUserId(null);
  159 + reqVO.setRemark(null);
  160 + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
  161 +
  162 + // 调用
  163 + PageResult<ReceivablePlanDO> pageResult = receivablePlanService.getReceivablePlanPage(reqVO);
  164 + // 断言
  165 + assertEquals(1, pageResult.getTotal());
  166 + assertEquals(1, pageResult.getList().size());
  167 + assertPojoEquals(dbReceivablePlan, pageResult.getList().get(0));
  168 + }
  169 +
  170 + @Test
  171 + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
  172 + public void testGetReceivablePlanList() {
  173 + // mock 数据
  174 + ReceivablePlanDO dbReceivablePlan = randomPojo(ReceivablePlanDO.class, o -> { // 等会查询到
  175 + o.setIndexNo(null);
  176 + o.setStatus(null);
  177 + o.setCheckStatus(null);
  178 + o.setReturnTime(null);
  179 + o.setRemindDays(null);
  180 + o.setRemindTime(null);
  181 + o.setCustomerId(null);
  182 + o.setContractId(null);
  183 + o.setOwnerUserId(null);
  184 + o.setRemark(null);
  185 + o.setCreateTime(null);
  186 + });
  187 + receivablePlanMapper.insert(dbReceivablePlan);
  188 + // 测试 indexNo 不匹配
  189 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setIndexNo(null)));
  190 + // 测试 status 不匹配
  191 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setStatus(null)));
  192 + // 测试 checkStatus 不匹配
  193 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCheckStatus(null)));
  194 + // 测试 returnTime 不匹配
  195 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setReturnTime(null)));
  196 + // 测试 remindDays 不匹配
  197 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindDays(null)));
  198 + // 测试 remindTime 不匹配
  199 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindTime(null)));
  200 + // 测试 customerId 不匹配
  201 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCustomerId(null)));
  202 + // 测试 contractId 不匹配
  203 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setContractId(null)));
  204 + // 测试 ownerUserId 不匹配
  205 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setOwnerUserId(null)));
  206 + // 测试 remark 不匹配
  207 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemark(null)));
  208 + // 测试 createTime 不匹配
  209 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCreateTime(null)));
  210 + // 准备参数
  211 + ReceivablePlanExportReqVO reqVO = new ReceivablePlanExportReqVO();
  212 + reqVO.setIndexNo(null);
  213 + reqVO.setStatus(null);
  214 + reqVO.setCheckStatus(null);
  215 + reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
  216 + reqVO.setRemindDays(null);
  217 + reqVO.setRemindTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
  218 + reqVO.setCustomerId(null);
  219 + reqVO.setContractId(null);
  220 + reqVO.setOwnerUserId(null);
  221 + reqVO.setRemark(null);
  222 + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
  223 +
  224 + // 调用
  225 + List<ReceivablePlanDO> list = receivablePlanService.getReceivablePlanList(reqVO);
  226 + // 断言
  227 + assertEquals(1, list.size());
  228 + assertPojoEquals(dbReceivablePlan, list.get(0));
  229 + }
  230 +
  231 +}
yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql
@@ -3,3 +3,5 @@ DELETE FROM &quot;crm_contract&quot;; @@ -3,3 +3,5 @@ DELETE FROM &quot;crm_contract&quot;;
3 DELETE FROM "crm_clue"; 3 DELETE FROM "crm_clue";
4 4
5 DELETE FROM "crm_receivable"; 5 DELETE FROM "crm_receivable";
  6 +
  7 +DELETE FROM "crm_receivable_plan";
yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql
@@ -73,3 +73,28 @@ CREATE TABLE IF NOT EXISTS &quot;crm_receivable&quot; ( @@ -73,3 +73,28 @@ CREATE TABLE IF NOT EXISTS &quot;crm_receivable&quot; (
73 "deleted" bit NOT NULL DEFAULT FALSE, 73 "deleted" bit NOT NULL DEFAULT FALSE,
74 PRIMARY KEY ("id") 74 PRIMARY KEY ("id")
75 ) COMMENT '回款管理'; 75 ) COMMENT '回款管理';
  76 +
  77 +CREATE TABLE IF NOT EXISTS "crm_receivable_plan" (
  78 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  79 + "index_no" bigint,
  80 + "receivable_id" bigint,
  81 + "status" int NOT NULL,
  82 + "check_status" varchar,
  83 + "process_instance_id" bigint,
  84 + "price" varchar,
  85 + "return_time" varchar,
  86 + "remind_days" bigint,
  87 + "remind_time" varchar,
  88 + "customer_id" bigint,
  89 + "contract_id" bigint,
  90 + "owner_user_id" bigint,
  91 + "sort" int,
  92 + "remark" varchar,
  93 + "creator" varchar DEFAULT '',
  94 + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  95 + "updater" varchar DEFAULT '',
  96 + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  97 + "deleted" bit NOT NULL DEFAULT FALSE,
  98 + PRIMARY KEY ("id")
  99 +) COMMENT '回款计划';
  100 +