diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 24cc3c623..e8c9cb31a 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -90,3 +90,71 @@ CREATE TABLE `crm_business` ( `tenant_id` bigint DEFAULT '0' COMMENT '租户ID', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='商机表'; + + + +-- ---------------------------- +-- 回款表 +-- ---------------------------- +DROP TABLE IF EXISTS `crm_receivable`; +CREATE TABLE `crm_receivable` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '回款编号', + `plan_id` bigint(20) NULL DEFAULT NULL COMMENT '回款计划ID', + `customer_id` bigint(20) NULL DEFAULT NULL COMMENT '客户ID', + `contract_id` bigint(20) NULL DEFAULT NULL COMMENT '合同ID', + `check_status` tinyint(4) NULL DEFAULT NULL COMMENT '审批状态', + `process_instance_id` bigint(20) NULL DEFAULT NULL COMMENT '工作流编号', + `return_time` datetime NULL DEFAULT NULL COMMENT '回款日期', + `return_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '回款方式', + `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '回款金额', + `owner_user_id` bigint(20) NULL DEFAULT NULL COMMENT '负责人的用户编号', + `batch_id` bigint(20) NULL DEFAULT NULL COMMENT '批次', + `sort` int(11) NULL DEFAULT NULL COMMENT '显示顺序', + `data_scope` tinyint(4) NULL DEFAULT 1 COMMENT '数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)', + `data_scope_dept_ids` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '数据范围(指定部门数组)', + `status` tinyint(4) NOT NULL COMMENT '状态(0正常 1停用)', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '回款管理' ROW_FORMAT = DYNAMIC; + + +-- ---------------------------- +-- 回款计划表 +-- ---------------------------- +DROP TABLE IF EXISTS `crm_receivable_plan`; +CREATE TABLE `crm_receivable_plan` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `index_no` bigint(20) NULL DEFAULT NULL COMMENT '期数', + `receivable_id` bigint(20) NULL DEFAULT NULL COMMENT '回款ID', + `status` tinyint(4) NOT NULL COMMENT '完成状态', + `check_status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '审批状态', + `process_instance_id` bigint(20) NULL DEFAULT NULL COMMENT '工作流编号', + `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '计划回款金额', + `return_time` datetime NULL DEFAULT NULL COMMENT '计划回款日期', + `remind_days` bigint(20) NULL DEFAULT NULL COMMENT '提前几天提醒', + `remind_time` datetime NULL DEFAULT NULL COMMENT '提醒日期', + `customer_id` bigint(20) NULL DEFAULT NULL COMMENT '客户ID', + `contract_id` bigint(20) NULL DEFAULT NULL COMMENT '合同ID', + `owner_user_id` bigint(20) NULL DEFAULT NULL COMMENT '负责人', + `sort` int(11) NULL DEFAULT NULL COMMENT '显示顺序', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '回款计划' ROW_FORMAT = DYNAMIC; + + + + + diff --git a/sql/mysql/crm_data.sql b/sql/mysql/crm_data.sql new file mode 100644 index 000000000..dfc1135f9 --- /dev/null +++ b/sql/mysql/crm_data.sql @@ -0,0 +1,19 @@ + +INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (184, '回款管理审批状态', 'crm_receivable_check_status', 0, '回款管理审批状态(0 未审核 1 审核通过 2 审核拒绝 3 审核中 4 已撤回)', '1', '2023-10-18 21:44:24', '1', '2023-10-18 21:44:24', b'0', '1970-01-01 00:00:00'); +INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (185, '回款管理-回款方式', 'crm_return_type', 0, '回款管理-回款方式', '1', '2023-10-18 21:54:10', '1', '2023-10-18 21:54:10', b'0', '1970-01-01 00:00:00'); + + +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1389, 0, '未审核', '0', 'crm_receivable_check_status', 0, 'default', '', '0 未审核 ', '1', '2023-10-18 21:46:00', '1', '2023-10-18 21:47:16', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1390, 1, '审核通过', '1', 'crm_receivable_check_status', 0, 'default', '', '1 审核通过', '1', '2023-10-18 21:46:18', '1', '2023-10-18 21:47:08', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1391, 2, '审核拒绝', '2', 'crm_receivable_check_status', 0, 'default', '', ' 2 审核拒绝', '1', '2023-10-18 21:46:58', '1', '2023-10-18 21:47:21', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1392, 3, '审核中', '3', 'crm_receivable_check_status', 0, 'default', '', ' 3 审核中', '1', '2023-10-18 21:47:35', '1', '2023-10-18 21:47:35', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1393, 4, '已撤回', '4', 'crm_receivable_check_status', 0, 'default', '', ' 4 已撤回', '1', '2023-10-18 21:47:46', '1', '2023-10-18 21:47:46', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1394, 1, '支票', '1', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:54:29', '1', '2023-10-18 21:54:29', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1395, 2, '现金', '2', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:54:41', '1', '2023-10-18 21:54:41', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1396, 3, '邮政汇款', '3', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:54:53', '1', '2023-10-18 21:54:53', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1397, 4, '电汇', '4', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:07', '1', '2023-10-18 21:55:07', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1398, 5, '网上转账', '5', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:24', '1', '2023-10-18 21:55:24', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1399, 6, '支付宝', '6', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:38', '1', '2023-10-18 21:55:38', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1400, 7, '微信支付', '7', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:53', '1', '2023-10-18 21:55:53', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1401, 8, '其他', '8', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:56:06', '1', '2023-10-18 21:56:06', b'0'); + diff --git a/sql/mysql/crm_menu.sql b/sql/mysql/crm_menu.sql index 58c2fd194..d85c9496b 100644 --- a/sql/mysql/crm_menu.sql +++ b/sql/mysql/crm_menu.sql @@ -8,7 +8,7 @@ INSERT INTO system_menu( path, icon, component, status, component_name ) VALUES ( - '合同管理', '', 2, 0, 1254, + '合同管理', '', 2, 0, 2375, 'contract', '', 'crm/contract/index', 0, 'Contract' ); @@ -177,3 +177,131 @@ VALUES ( '商机导出', 'crm:business:export', 3, 5, @parentId, '', '', '', 0 ); + + +-- ---------------------------- +-- 客户管理菜单 +-- ---------------------------- +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2375, '客户管理', '', 1, 0, 0, '/crm', 'ep:avatar', '', '', 0, b'1', b'1', b'1', '1', '2023-10-20 00:36:13', '1', '2023-10-19 16:37:24', b'0'); + + +-- ---------------------------- +-- 回款菜单 +-- ---------------------------- + +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '回款管理', '', 2, 0, 2375, + 'receivable', '', 'crm/receivable/index', 0, 'Receivable' + ); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款管理查询', 'crm:receivable:query', 3, 1, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款管理创建', 'crm:receivable:create', 3, 2, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款管理更新', 'crm:receivable:update', 3, 3, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款管理删除', 'crm:receivable:delete', 3, 4, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款管理导出', 'crm:receivable:export', 3, 5, @parentId, + '', '', '', 0 + ); + + +-- ---------------------------- +-- 回款计划菜单 +-- ---------------------------- + +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '回款计划管理', '', 2, 0, 2375, + 'receivable-plan', '', 'crm/receivablePlan/index', 0, 'ReceivablePlan' + ); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款计划查询', 'crm:receivable-plan:query', 3, 1, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款计划创建', 'crm:receivable-plan:create', 3, 2, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款计划更新', 'crm:receivable-plan:update', 3, 3, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款计划删除', 'crm:receivable-plan:delete', 3, 4, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款计划导出', 'crm:receivable-plan:export', 3, 5, @parentId, + '', '', '', 0 + ); diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 66f2abc1f..33c87bf19 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 @@ -18,4 +18,9 @@ public interface ErrorCodeConstants { // ========== 商机管理 1-020-001-000 ========== ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_001_000, "商机不存在"); + // TODO @liuhongfeng:错误码分段; + ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_030_000_001, "回款管理不存在"); + + ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_040_000_001, "回款计划不存在"); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java new file mode 100644 index 000000000..94c3a1c70 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java @@ -0,0 +1,101 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; +import cn.iocoder.yudao.module.crm.service.receivable.ReceivableService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.Collection; +import java.util.List; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; + +/** + * @author 赤焰 + */ +@Tag(name = "管理后台 - 回款管理") +@RestController +@RequestMapping("/crm/receivable") +@Validated +public class ReceivableController { + + @Resource + private ReceivableService receivableService; + + @PostMapping("/create") + @Operation(summary = "创建回款管理") + @PreAuthorize("@ss.hasPermission('crm:receivable:create')") + public CommonResult createReceivable(@Valid @RequestBody ReceivableCreateReqVO createReqVO) { + return success(receivableService.createReceivable(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新回款管理") + @PreAuthorize("@ss.hasPermission('crm:receivable:update')") + public CommonResult updateReceivable(@Valid @RequestBody ReceivableUpdateReqVO updateReqVO) { + receivableService.updateReceivable(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除回款管理") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('crm:receivable:delete')") + public CommonResult deleteReceivable(@RequestParam("id") Long id) { + receivableService.deleteReceivable(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得回款管理") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('crm:receivable:query')") + public CommonResult getReceivable(@RequestParam("id") Long id) { + ReceivableDO receivable = receivableService.getReceivable(id); + return success(ReceivableConvert.INSTANCE.convert(receivable)); + } + + @GetMapping("/list") + @Operation(summary = "获得回款管理列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('crm:receivable:query')") + public CommonResult> getReceivableList(@RequestParam("ids") Collection ids) { + List list = receivableService.getReceivableList(ids); + return success(ReceivableConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得回款管理分页") + @PreAuthorize("@ss.hasPermission('crm:receivable:query')") + public CommonResult> getReceivablePage(@Valid ReceivablePageReqVO pageVO) { + PageResult pageResult = receivableService.getReceivablePage(pageVO); + return success(ReceivableConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出回款管理 Excel") + @PreAuthorize("@ss.hasPermission('crm:receivable:export')") + @OperateLog(type = EXPORT) + public void exportReceivableExcel(@Valid ReceivableExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = receivableService.getReceivableList(exportReqVO); + // 导出 Excel + List datas = ReceivableConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "回款管理.xls", "数据", ReceivableExcelVO.class, datas); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java new file mode 100644 index 000000000..ae21a952d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivablePlanController.java @@ -0,0 +1,105 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; +import cn.iocoder.yudao.module.crm.convert.receivable.ReceivablePlanConvert; +import cn.iocoder.yudao.module.crm.service.receivable.ReceivablePlanService; + +/** + * @author 赤焰 + */ +@Tag(name = "管理后台 - 回款计划") +@RestController +@RequestMapping("/crm/receivable-plan") +@Validated +public class ReceivablePlanController { + + @Resource + private ReceivablePlanService receivablePlanService; + + @PostMapping("/create") + @Operation(summary = "创建回款计划") + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:create')") + public CommonResult createReceivablePlan(@Valid @RequestBody ReceivablePlanCreateReqVO createReqVO) { + return success(receivablePlanService.createReceivablePlan(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新回款计划") + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:update')") + public CommonResult updateReceivablePlan(@Valid @RequestBody ReceivablePlanUpdateReqVO updateReqVO) { + receivablePlanService.updateReceivablePlan(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除回款计划") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:delete')") + public CommonResult deleteReceivablePlan(@RequestParam("id") Long id) { + receivablePlanService.deleteReceivablePlan(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得回款计划") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") + public CommonResult getReceivablePlan(@RequestParam("id") Long id) { + ReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(id); + return success(ReceivablePlanConvert.INSTANCE.convert(receivablePlan)); + } + + @GetMapping("/list") + @Operation(summary = "获得回款计划列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") + public CommonResult> getReceivablePlanList(@RequestParam("ids") Collection ids) { + List list = receivablePlanService.getReceivablePlanList(ids); + return success(ReceivablePlanConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得回款计划分页") + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") + public CommonResult> getReceivablePlanPage(@Valid ReceivablePlanPageReqVO pageVO) { + PageResult pageResult = receivablePlanService.getReceivablePlanPage(pageVO); + return success(ReceivablePlanConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出回款计划 Excel") + @PreAuthorize("@ss.hasPermission('crm:receivable-plan:export')") + @OperateLog(type = EXPORT) + public void exportReceivablePlanExcel(@Valid ReceivablePlanExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = receivablePlanService.getReceivablePlanList(exportReqVO); + // 导出 Excel + List datas = ReceivablePlanConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "回款计划.xls", "数据", ReceivablePlanExcelVO.class, datas); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java new file mode 100644 index 000000000..4b63f1466 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java @@ -0,0 +1,72 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * 回款管理 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class ReceivableBaseVO { + + @Schema(description = "回款编号") + private String no; + + @Schema(description = "回款计划ID", example = "31177") + private Long planId; + + @Schema(description = "客户ID", example = "4963") + private Long customerId; + + @Schema(description = "合同ID", example = "30305") + private Long contractId; + + @Schema(description = "审批状态", example = "1") + private Integer checkStatus; + + @Schema(description = "工作流编号", example = "16568") + private Long processInstanceId; + + @Schema(description = "回款日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime returnTime; + + @Schema(description = "回款方式", example = "2") + private String returnType; + + @Schema(description = "回款金额", example = "31859") + private BigDecimal price; + + @Schema(description = "负责人", example = "22202") + private Long ownerUserId; + + @Schema(description = "批次", example = "2539") + private Long batchId; + + @Schema(description = "显示顺序") + private Integer sort; + + @Schema(description = "数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") + private Integer dataScope; + + @Schema(description = "数据范围(指定部门数组)") + private String dataScopeDeptIds; + + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "状态不能为空") + private Integer status; + + @Schema(description = "备注", example = "随便") + private String remark; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java new file mode 100644 index 000000000..5bbb4fce2 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 回款管理创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivableCreateReqVO extends ReceivableBaseVO { + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java new file mode 100644 index 000000000..f60330c53 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java @@ -0,0 +1,80 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + + +/** + * 回款管理 Excel VO + * + * @author 赤焰 + */ +@Data +public class ReceivableExcelVO { + + @ExcelProperty("ID") + private Long id; + + @ExcelProperty("回款编号") + private String no; + + @ExcelProperty("回款计划ID") + private Long planId; + + @ExcelProperty("客户ID") + private Long customerId; + + @ExcelProperty("合同ID") + private Long contractId; + + @ExcelProperty(value = "审批状态", converter = DictConvert.class) + @DictFormat("crm_receivable_check_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private Integer checkStatus; + + @ExcelProperty("工作流编号") + private Long processInstanceId; + + @ExcelProperty("回款日期") + private LocalDateTime returnTime; + + @ExcelProperty("回款方式") + private String returnType; + + @ExcelProperty("回款金额") + private BigDecimal price; + + @ExcelProperty("负责人") + private Long ownerUserId; + + @ExcelProperty("批次") + private Long batchId; + + //@ExcelProperty("显示顺序") + //private Integer sort; + + //@ExcelProperty("数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") + //private Integer dataScope; + + //@ExcelProperty("数据范围(指定部门数组)") + //private String dataScopeDeptIds; + + @ExcelProperty(value = "状态", converter = DictConvert.class) + @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private Integer status; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java new file mode 100644 index 000000000..7ea31a0fb --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java @@ -0,0 +1,72 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * @author 赤焰 + */ +@Schema(description = "管理后台 - 回款管理 Excel 导出 Request VO,参数和 ReceivablePageReqVO 是一致的") +@Data +public class ReceivableExportReqVO { + + @Schema(description = "回款编号") + private String no; + + @Schema(description = "回款计划ID", example = "31177") + private Long planId; + + @Schema(description = "客户ID", example = "4963") + private Long customerId; + + @Schema(description = "合同ID", example = "30305") + private Long contractId; + + @Schema(description = "审批状态", example = "1") + private Integer checkStatus; + + @Schema(description = "工作流编号", example = "16568") + private Long processInstanceId; + + @Schema(description = "回款日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] returnTime; + + @Schema(description = "回款方式", example = "2") + private String returnType; + + @Schema(description = "回款金额", example = "31859") + private BigDecimal price; + + @Schema(description = "负责人", example = "22202") + private Long ownerUserId; + + @Schema(description = "批次", example = "2539") + private Long batchId; + + @Schema(description = "显示顺序") + private Integer sort; + + @Schema(description = "数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") + private Integer dataScope; + + @Schema(description = "数据范围(指定部门数组)") + private String dataScopeDeptIds; + + @Schema(description = "状态", example = "1") + private Integer status; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java new file mode 100644 index 000000000..7b9e9df6d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java @@ -0,0 +1,73 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import lombok.*; + +import java.math.BigDecimal; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 回款管理分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivablePageReqVO extends PageParam { + + @Schema(description = "回款编号") + private String no; + + @Schema(description = "回款计划ID", example = "31177") + private Long planId; + + @Schema(description = "客户ID", example = "4963") + private Long customerId; + + @Schema(description = "合同ID", example = "30305") + private Long contractId; + + @Schema(description = "审批状态", example = "1") + private Integer checkStatus; + + @Schema(description = "工作流编号", example = "16568") + private Long processInstanceId; + + @Schema(description = "回款日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] returnTime; + + @Schema(description = "回款方式", example = "2") + private String returnType; + + @Schema(description = "回款金额", example = "31859") + private BigDecimal price; + + @Schema(description = "负责人", example = "22202") + private Long ownerUserId; + + @Schema(description = "批次", example = "2539") + private Long batchId; + + @Schema(description = "显示顺序") + private Integer sort; + + @Schema(description = "数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") + private Integer dataScope; + + @Schema(description = "数据范围(指定部门数组)") + private String dataScopeDeptIds; + + @Schema(description = "状态", example = "1") + private Integer status; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java new file mode 100644 index 000000000..638934a8e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java @@ -0,0 +1,68 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * 回款计划 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class ReceivablePlanBaseVO { + + @Schema(description = "期数") + private Long indexNo; + + @Schema(description = "回款ID", example = "19852") + private Long receivableId; + + @Schema(description = "完成状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + //@NotNull(message = "完成状态不能为空") + private Integer status; + + @Schema(description = "审批状态", example = "1") + private String checkStatus; + + @Schema(description = "工作流编号", example = "8909") + private Long processInstanceId; + + @Schema(description = "计划回款金额", example = "29675") + private BigDecimal price; + + @Schema(description = "计划回款日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime returnTime; + + @Schema(description = "提前几天提醒") + private Long remindDays; + + @Schema(description = "提醒日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime remindTime; + + @Schema(description = "客户ID", example = "18026") + private Long customerId; + + @Schema(description = "合同ID", example = "3473") + private Long contractId; + + @Schema(description = "负责人", example = "17828") + private Long ownerUserId; + + @Schema(description = "显示顺序") + private Integer sort; + + @Schema(description = "备注", example = "随便") + private String remark; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanCreateReqVO.java new file mode 100644 index 000000000..0d4fce3c8 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 回款计划创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivablePlanCreateReqVO extends ReceivablePlanBaseVO { + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java new file mode 100644 index 000000000..e12d5a1df --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java @@ -0,0 +1,75 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + + +/** + * 回款计划 Excel VO + * + * @author 芋道源码 + */ +@Data +public class ReceivablePlanExcelVO { + + @ExcelProperty("ID") + private Long id; + + @ExcelProperty("期数") + private Long indexNo; + + @ExcelProperty("回款ID") + private Long receivableId; + + @ExcelProperty(value = "完成状态", converter = DictConvert.class) + @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private Integer status; + + @ExcelProperty(value = "审批状态", converter = DictConvert.class) + @DictFormat("crm_receivable_check_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private String checkStatus; + + //@ExcelProperty("工作流编号") + //private Long processInstanceId; + + @ExcelProperty("计划回款金额") + private BigDecimal price; + + @ExcelProperty("计划回款日期") + private LocalDateTime returnTime; + + @ExcelProperty("提前几天提醒") + private Long remindDays; + + @ExcelProperty("提醒日期") + private LocalDateTime remindTime; + + @ExcelProperty("客户ID") + private Long customerId; + + @ExcelProperty("合同ID") + private Long contractId; + + @ExcelProperty("负责人") + private Long ownerUserId; + + //@ExcelProperty("显示顺序") + //private Integer sort; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java new file mode 100644 index 000000000..ca5d3f553 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java @@ -0,0 +1,52 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import java.time.LocalDateTime; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 回款计划 Excel 导出 Request VO,参数和 ReceivablePlanPageReqVO 是一致的") +@Data +public class ReceivablePlanExportReqVO { + + @Schema(description = "期数") + private Long indexNo; + + @Schema(description = "完成状态", example = "2") + private Integer status; + + @Schema(description = "审批状态", example = "1") + private String checkStatus; + + @Schema(description = "计划回款日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] returnTime; + + @Schema(description = "提前几天提醒") + private Long remindDays; + + @Schema(description = "提醒日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] remindTime; + + @Schema(description = "客户ID", example = "18026") + private Long customerId; + + @Schema(description = "合同ID", example = "3473") + private Long contractId; + + @Schema(description = "负责人", example = "17828") + private Long ownerUserId; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java new file mode 100644 index 000000000..2c1166d1c --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 回款计划分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivablePlanPageReqVO extends PageParam { + + @Schema(description = "期数") + private Long indexNo; + + @Schema(description = "完成状态", example = "2") + private Integer status; + + @Schema(description = "审批状态", example = "1") + private String checkStatus; + + @Schema(description = "计划回款日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] returnTime; + + @Schema(description = "提前几天提醒") + private Long remindDays; + + @Schema(description = "提醒日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] remindTime; + + @Schema(description = "客户ID", example = "18026") + private Long customerId; + + @Schema(description = "合同ID", example = "3473") + private Long contractId; + + @Schema(description = "负责人", example = "17828") + private Long ownerUserId; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanRespVO.java new file mode 100644 index 000000000..d96f631de --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 回款计划 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivablePlanRespVO extends ReceivablePlanBaseVO { + + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25153") + private Long id; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanUpdateReqVO.java new file mode 100644 index 000000000..75f4ecca0 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 回款计划更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivablePlanUpdateReqVO extends ReceivablePlanBaseVO { + + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25153") + @NotNull(message = "ID不能为空") + private Long id; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java new file mode 100644 index 000000000..fd26e312e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 回款管理 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivableRespVO extends ReceivableBaseVO { + + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25787") + private Long id; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java new file mode 100644 index 000000000..600b09943 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 回款管理更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivableUpdateReqVO extends ReceivableBaseVO { + + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25787") + @NotNull(message = "ID不能为空") + private Long id; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivableConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivableConvert.java new file mode 100644 index 000000000..7f14aaddd --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivableConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.convert.receivable; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; + +/** + * 回款管理 Convert + * + * @author 赤焰 + */ +@Mapper +public interface ReceivableConvert { + + ReceivableConvert INSTANCE = Mappers.getMapper(ReceivableConvert.class); + + ReceivableDO convert(ReceivableCreateReqVO bean); + + ReceivableDO convert(ReceivableUpdateReqVO bean); + + ReceivableRespVO convert(ReceivableDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivablePlanConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivablePlanConvert.java new file mode 100644 index 000000000..81ec646f3 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivablePlanConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.convert.receivable; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; + +/** + * 回款计划 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface ReceivablePlanConvert { + + ReceivablePlanConvert INSTANCE = Mappers.getMapper(ReceivablePlanConvert.class); + + ReceivablePlanDO convert(ReceivablePlanCreateReqVO bean); + + ReceivablePlanDO convert(ReceivablePlanUpdateReqVO bean); + + ReceivablePlanRespVO convert(ReceivablePlanDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java new file mode 100644 index 000000000..561765b09 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java @@ -0,0 +1,101 @@ +package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 回款管理 DO + * + * @author 赤焰 + */ +@TableName("crm_receivable") +@KeySequence("crm_receivable_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ReceivableDO extends BaseDO { + + /** + * ID + */ + @TableId + private Long id; + /** + * 回款编号 + */ + private String no; + /** + * 回款计划ID + */ + private Long planId; + /** + * 客户ID + */ + private Long customerId; + /** + * 合同ID + */ + private Long contractId; + /** + * 审批状态 + * + * 枚举 {@link TODO crm_receivable_check_status 对应的类} + */ + private Integer checkStatus; + /** + * 工作流编号 + */ + private Long processInstanceId; + /** + * 回款日期 + */ + private LocalDateTime returnTime; + /** + * 回款方式 + */ + private String returnType; + /** + * 回款金额 + */ + private BigDecimal price; + /** + * 负责人 + */ + private Long ownerUserId; + /** + * 批次 + */ + private Long batchId; + /** + * 显示顺序 + */ + private Integer sort; + /** + * 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限) + */ + private Integer dataScope; + /** + * 数据范围(指定部门数组) + */ + private String dataScopeDeptIds; + /** + * 状态 + * + * 枚举 {@link TODO common_status 对应的类} + */ + private Integer status; + /** + * 备注 + */ + private String remark; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java new file mode 100644 index 000000000..4447df053 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java @@ -0,0 +1,94 @@ +package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; + +import lombok.*; +import java.util.*; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 回款计划 DO + * + * @author 芋道源码 + */ +@TableName("crm_receivable_plan") +@KeySequence("crm_receivable_plan_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ReceivablePlanDO extends BaseDO { + + /** + * ID + */ + @TableId + private Long id; + /** + * 期数 + */ + private Long indexNo; + /** + * 回款ID + */ + private Long receivableId; + /** + * 完成状态 + * + * 枚举 {@link TODO common_status 对应的类} + */ + private Integer status; + /** + * 审批状态 + * + * 枚举 {@link TODO crm_receivable_check_status 对应的类} + */ + private String checkStatus; + /** + * 工作流编号 + */ + private Long processInstanceId; + /** + * 计划回款金额 + */ + private BigDecimal price; + /** + * 计划回款日期 + */ + private LocalDateTime returnTime; + /** + * 提前几天提醒 + */ + private Long remindDays; + /** + * 提醒日期 + */ + private LocalDateTime remindTime; + /** + * 客户ID + */ + private Long customerId; + /** + * 合同ID + */ + private Long contractId; + /** + * 负责人 + */ + private Long ownerUserId; + /** + * 显示顺序 + */ + private Integer sort; + /** + * 备注 + */ + private String remark; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java new file mode 100644 index 000000000..08031772c --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java @@ -0,0 +1,64 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.receivable; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; + +/** + * 回款管理 Mapper + * + * @author 赤焰 + */ +@Mapper +public interface ReceivableMapper extends BaseMapperX { + + default PageResult selectPage(ReceivablePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(ReceivableDO::getNo, reqVO.getNo()) + .eqIfPresent(ReceivableDO::getPlanId, reqVO.getPlanId()) + .eqIfPresent(ReceivableDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(ReceivableDO::getContractId, reqVO.getContractId()) + .eqIfPresent(ReceivableDO::getCheckStatus, reqVO.getCheckStatus()) + .eqIfPresent(ReceivableDO::getProcessInstanceId, reqVO.getProcessInstanceId()) + .betweenIfPresent(ReceivableDO::getReturnTime, reqVO.getReturnTime()) + .eqIfPresent(ReceivableDO::getReturnType, reqVO.getReturnType()) + .eqIfPresent(ReceivableDO::getPrice, reqVO.getPrice()) + .eqIfPresent(ReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) + .eqIfPresent(ReceivableDO::getBatchId, reqVO.getBatchId()) + .eqIfPresent(ReceivableDO::getSort, reqVO.getSort()) + .eqIfPresent(ReceivableDO::getDataScope, reqVO.getDataScope()) + .eqIfPresent(ReceivableDO::getDataScopeDeptIds, reqVO.getDataScopeDeptIds()) + .eqIfPresent(ReceivableDO::getStatus, reqVO.getStatus()) + .eqIfPresent(ReceivableDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(ReceivableDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(ReceivableDO::getId)); + } + + default List selectList(ReceivableExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(ReceivableDO::getNo, reqVO.getNo()) + .eqIfPresent(ReceivableDO::getPlanId, reqVO.getPlanId()) + .eqIfPresent(ReceivableDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(ReceivableDO::getContractId, reqVO.getContractId()) + .eqIfPresent(ReceivableDO::getCheckStatus, reqVO.getCheckStatus()) + .eqIfPresent(ReceivableDO::getProcessInstanceId, reqVO.getProcessInstanceId()) + .betweenIfPresent(ReceivableDO::getReturnTime, reqVO.getReturnTime()) + .eqIfPresent(ReceivableDO::getReturnType, reqVO.getReturnType()) + .eqIfPresent(ReceivableDO::getPrice, reqVO.getPrice()) + .eqIfPresent(ReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) + .eqIfPresent(ReceivableDO::getBatchId, reqVO.getBatchId()) + .eqIfPresent(ReceivableDO::getSort, reqVO.getSort()) + .eqIfPresent(ReceivableDO::getDataScope, reqVO.getDataScope()) + .eqIfPresent(ReceivableDO::getDataScopeDeptIds, reqVO.getDataScopeDeptIds()) + .eqIfPresent(ReceivableDO::getStatus, reqVO.getStatus()) + .eqIfPresent(ReceivableDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(ReceivableDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(ReceivableDO::getId)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java new file mode 100644 index 000000000..ac35133a7 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivablePlanMapper.java @@ -0,0 +1,52 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.receivable; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; + +/** + * 回款计划 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface ReceivablePlanMapper extends BaseMapperX { + + default PageResult selectPage(ReceivablePlanPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(ReceivablePlanDO::getIndexNo, reqVO.getIndexNo()) + .eqIfPresent(ReceivablePlanDO::getStatus, reqVO.getStatus()) + .eqIfPresent(ReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus()) + .betweenIfPresent(ReceivablePlanDO::getReturnTime, reqVO.getReturnTime()) + .eqIfPresent(ReceivablePlanDO::getRemindDays, reqVO.getRemindDays()) + .betweenIfPresent(ReceivablePlanDO::getRemindTime, reqVO.getRemindTime()) + .eqIfPresent(ReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(ReceivablePlanDO::getContractId, reqVO.getContractId()) + .eqIfPresent(ReceivablePlanDO::getOwnerUserId, reqVO.getOwnerUserId()) + .eqIfPresent(ReceivablePlanDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(ReceivablePlanDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(ReceivablePlanDO::getId)); + } + + default List selectList(ReceivablePlanExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(ReceivablePlanDO::getIndexNo, reqVO.getIndexNo()) + .eqIfPresent(ReceivablePlanDO::getStatus, reqVO.getStatus()) + .eqIfPresent(ReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus()) + .betweenIfPresent(ReceivablePlanDO::getReturnTime, reqVO.getReturnTime()) + .eqIfPresent(ReceivablePlanDO::getRemindDays, reqVO.getRemindDays()) + .betweenIfPresent(ReceivablePlanDO::getRemindTime, reqVO.getRemindTime()) + .eqIfPresent(ReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(ReceivablePlanDO::getContractId, reqVO.getContractId()) + .eqIfPresent(ReceivablePlanDO::getOwnerUserId, reqVO.getOwnerUserId()) + .eqIfPresent(ReceivablePlanDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(ReceivablePlanDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(ReceivablePlanDO::getId)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanService.java new file mode 100644 index 000000000..163ebc26a --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanService.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.crm.service.receivable; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * 回款计划 Service 接口 + * + * @author 芋道源码 + */ +public interface ReceivablePlanService { + + /** + * 创建回款计划 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createReceivablePlan(@Valid ReceivablePlanCreateReqVO createReqVO); + + /** + * 更新回款计划 + * + * @param updateReqVO 更新信息 + */ + void updateReceivablePlan(@Valid ReceivablePlanUpdateReqVO updateReqVO); + + /** + * 删除回款计划 + * + * @param id 编号 + */ + void deleteReceivablePlan(Long id); + + /** + * 获得回款计划 + * + * @param id 编号 + * @return 回款计划 + */ + ReceivablePlanDO getReceivablePlan(Long id); + + /** + * 获得回款计划列表 + * + * @param ids 编号 + * @return 回款计划列表 + */ + List getReceivablePlanList(Collection ids); + + /** + * 获得回款计划分页 + * + * @param pageReqVO 分页查询 + * @return 回款计划分页 + */ + PageResult getReceivablePlanPage(ReceivablePlanPageReqVO pageReqVO); + + /** + * 获得回款计划列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 回款计划列表 + */ + List getReceivablePlanList(ReceivablePlanExportReqVO exportReqVO); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java new file mode 100644 index 000000000..1a1462388 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java @@ -0,0 +1,93 @@ +package cn.iocoder.yudao.module.crm.service.receivable; + +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.crm.convert.receivable.ReceivablePlanConvert; +import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivablePlanMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; + +/** + * 回款计划 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class ReceivablePlanServiceImpl implements ReceivablePlanService { + + @Resource + private ReceivablePlanMapper receivablePlanMapper; + + @Override + public Long createReceivablePlan(ReceivablePlanCreateReqVO createReqVO) { + // 插入 + ReceivablePlanDO receivablePlan = ReceivablePlanConvert.INSTANCE.convert(createReqVO); + if(ObjectUtil.isNull(receivablePlan.getStatus())){ + receivablePlan.setStatus(CommonStatusEnum.ENABLE.getStatus()); + } + receivablePlanMapper.insert(receivablePlan); + // 返回 + return receivablePlan.getId(); + } + + @Override + public void updateReceivablePlan(ReceivablePlanUpdateReqVO updateReqVO) { + // 校验存在 + validateReceivablePlanExists(updateReqVO.getId()); + // 更新 + ReceivablePlanDO updateObj = ReceivablePlanConvert.INSTANCE.convert(updateReqVO); + receivablePlanMapper.updateById(updateObj); + } + + @Override + public void deleteReceivablePlan(Long id) { + // 校验存在 + validateReceivablePlanExists(id); + // 删除 + receivablePlanMapper.deleteById(id); + } + + private void validateReceivablePlanExists(Long id) { + if (receivablePlanMapper.selectById(id) == null) { + throw exception(RECEIVABLE_PLAN_NOT_EXISTS); + } + } + + @Override + public ReceivablePlanDO getReceivablePlan(Long id) { + return receivablePlanMapper.selectById(id); + } + + @Override + public List getReceivablePlanList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return receivablePlanMapper.selectBatchIds(ids); + } + + @Override + public PageResult getReceivablePlanPage(ReceivablePlanPageReqVO pageReqVO) { + return receivablePlanMapper.selectPage(pageReqVO); + } + + @Override + public List getReceivablePlanList(ReceivablePlanExportReqVO exportReqVO) { + return receivablePlanMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableService.java new file mode 100644 index 000000000..a673ec99e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableService.java @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.crm.service.receivable; + +import java.util.*; +import javax.validation.*; + +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * 回款管理 Service 接口 + * + * @author 赤焰 + */ +public interface ReceivableService { + + /** + * 创建回款管理 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createReceivable(@Valid ReceivableCreateReqVO createReqVO); + + /** + * 更新回款管理 + * + * @param updateReqVO 更新信息 + */ + void updateReceivable(@Valid ReceivableUpdateReqVO updateReqVO); + + /** + * 删除回款管理 + * + * @param id 编号 + */ + void deleteReceivable(Long id); + + /** + * 获得回款管理 + * + * @param id 编号 + * @return 回款管理 + */ + ReceivableDO getReceivable(Long id); + + /** + * 获得回款管理列表 + * + * @param ids 编号 + * @return 回款管理列表 + */ + List getReceivableList(Collection ids); + + /** + * 获得回款管理分页 + * + * @param pageReqVO 分页查询 + * @return 回款管理分页 + */ + PageResult getReceivablePage(ReceivablePageReqVO pageReqVO); + + /** + * 获得回款管理列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 回款管理列表 + */ + List getReceivableList(ReceivableExportReqVO exportReqVO); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java new file mode 100644 index 000000000..2f5abe1fc --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java @@ -0,0 +1,87 @@ +package cn.iocoder.yudao.module.crm.service.receivable; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import java.util.*; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; + +import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; +import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; + +/** + * 回款管理 Service 实现类 + * + * @author 赤焰 + */ +@Service +@Validated +public class ReceivableServiceImpl implements ReceivableService { + + @Resource + private ReceivableMapper receivableMapper; + + @Override + public Long createReceivable(ReceivableCreateReqVO createReqVO) { + // 插入 + ReceivableDO receivable = ReceivableConvert.INSTANCE.convert(createReqVO); + receivableMapper.insert(receivable); + // 返回 + return receivable.getId(); + } + + @Override + public void updateReceivable(ReceivableUpdateReqVO updateReqVO) { + // 校验存在 + validateReceivableExists(updateReqVO.getId()); + // 更新 + ReceivableDO updateObj = ReceivableConvert.INSTANCE.convert(updateReqVO); + receivableMapper.updateById(updateObj); + } + + @Override + public void deleteReceivable(Long id) { + // 校验存在 + validateReceivableExists(id); + // 删除 + receivableMapper.deleteById(id); + } + + private void validateReceivableExists(Long id) { + if (receivableMapper.selectById(id) == null) { + throw exception(RECEIVABLE_NOT_EXISTS); + } + } + + @Override + public ReceivableDO getReceivable(Long id) { + return receivableMapper.selectById(id); + } + + @Override + public List getReceivableList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return receivableMapper.selectBatchIds(ids); + } + + @Override + public PageResult getReceivablePage(ReceivablePageReqVO pageReqVO) { + return receivableMapper.selectPage(pageReqVO); + } + + @Override + public List getReceivableList(ReceivableExportReqVO exportReqVO) { + return receivableMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivableMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivableMapper.xml new file mode 100644 index 000000000..b87beb08f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivableMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivablePlanMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivablePlanMapper.xml new file mode 100644 index 000000000..f0e4c2e84 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivablePlanMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java new file mode 100644 index 000000000..0d90fd1aa --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImplTest.java @@ -0,0 +1,231 @@ +package cn.iocoder.yudao.module.crm.service.receivable; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; +import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivablePlanMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link ReceivablePlanServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(ReceivablePlanServiceImpl.class) +public class ReceivablePlanServiceImplTest extends BaseDbUnitTest { + + @Resource + private ReceivablePlanServiceImpl receivablePlanService; + + @Resource + private ReceivablePlanMapper receivablePlanMapper; + + @Test + public void testCreateReceivablePlan_success() { + // 准备参数 + ReceivablePlanCreateReqVO reqVO = randomPojo(ReceivablePlanCreateReqVO.class); + + // 调用 + Long receivablePlanId = receivablePlanService.createReceivablePlan(reqVO); + // 断言 + assertNotNull(receivablePlanId); + // 校验记录的属性是否正确 + ReceivablePlanDO receivablePlan = receivablePlanMapper.selectById(receivablePlanId); + assertPojoEquals(reqVO, receivablePlan); + } + + @Test + public void testUpdateReceivablePlan_success() { + // mock 数据 + ReceivablePlanDO dbReceivablePlan = randomPojo(ReceivablePlanDO.class); + receivablePlanMapper.insert(dbReceivablePlan);// @Sql: 先插入出一条存在的数据 + // 准备参数 + ReceivablePlanUpdateReqVO reqVO = randomPojo(ReceivablePlanUpdateReqVO.class, o -> { + o.setId(dbReceivablePlan.getId()); // 设置更新的 ID + }); + + // 调用 + receivablePlanService.updateReceivablePlan(reqVO); + // 校验是否更新正确 + ReceivablePlanDO receivablePlan = receivablePlanMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, receivablePlan); + } + + @Test + public void testUpdateReceivablePlan_notExists() { + // 准备参数 + ReceivablePlanUpdateReqVO reqVO = randomPojo(ReceivablePlanUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> receivablePlanService.updateReceivablePlan(reqVO), RECEIVABLE_PLAN_NOT_EXISTS); + } + + @Test + public void testDeleteReceivablePlan_success() { + // mock 数据 + ReceivablePlanDO dbReceivablePlan = randomPojo(ReceivablePlanDO.class); + receivablePlanMapper.insert(dbReceivablePlan);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbReceivablePlan.getId(); + + // 调用 + receivablePlanService.deleteReceivablePlan(id); + // 校验数据不存在了 + assertNull(receivablePlanMapper.selectById(id)); + } + + @Test + public void testDeleteReceivablePlan_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> receivablePlanService.deleteReceivablePlan(id), RECEIVABLE_PLAN_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetReceivablePlanPage() { + // mock 数据 + ReceivablePlanDO dbReceivablePlan = randomPojo(ReceivablePlanDO.class, o -> { // 等会查询到 + o.setIndexNo(null); + o.setStatus(null); + o.setCheckStatus(null); + o.setReturnTime(null); + o.setRemindDays(null); + o.setRemindTime(null); + o.setCustomerId(null); + o.setContractId(null); + o.setOwnerUserId(null); + o.setRemark(null); + o.setCreateTime(null); + }); + receivablePlanMapper.insert(dbReceivablePlan); + // 测试 indexNo 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setIndexNo(null))); + // 测试 status 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setStatus(null))); + // 测试 checkStatus 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCheckStatus(null))); + // 测试 returnTime 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setReturnTime(null))); + // 测试 remindDays 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindDays(null))); + // 测试 remindTime 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindTime(null))); + // 测试 customerId 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCustomerId(null))); + // 测试 contractId 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setContractId(null))); + // 测试 ownerUserId 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setOwnerUserId(null))); + // 测试 remark 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemark(null))); + // 测试 createTime 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCreateTime(null))); + // 准备参数 + ReceivablePlanPageReqVO reqVO = new ReceivablePlanPageReqVO(); + reqVO.setIndexNo(null); + reqVO.setStatus(null); + reqVO.setCheckStatus(null); + reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setRemindDays(null); + reqVO.setRemindTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setCustomerId(null); + reqVO.setContractId(null); + reqVO.setOwnerUserId(null); + reqVO.setRemark(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = receivablePlanService.getReceivablePlanPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbReceivablePlan, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetReceivablePlanList() { + // mock 数据 + ReceivablePlanDO dbReceivablePlan = randomPojo(ReceivablePlanDO.class, o -> { // 等会查询到 + o.setIndexNo(null); + o.setStatus(null); + o.setCheckStatus(null); + o.setReturnTime(null); + o.setRemindDays(null); + o.setRemindTime(null); + o.setCustomerId(null); + o.setContractId(null); + o.setOwnerUserId(null); + o.setRemark(null); + o.setCreateTime(null); + }); + receivablePlanMapper.insert(dbReceivablePlan); + // 测试 indexNo 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setIndexNo(null))); + // 测试 status 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setStatus(null))); + // 测试 checkStatus 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCheckStatus(null))); + // 测试 returnTime 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setReturnTime(null))); + // 测试 remindDays 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindDays(null))); + // 测试 remindTime 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindTime(null))); + // 测试 customerId 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCustomerId(null))); + // 测试 contractId 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setContractId(null))); + // 测试 ownerUserId 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setOwnerUserId(null))); + // 测试 remark 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemark(null))); + // 测试 createTime 不匹配 + receivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCreateTime(null))); + // 准备参数 + ReceivablePlanExportReqVO reqVO = new ReceivablePlanExportReqVO(); + reqVO.setIndexNo(null); + reqVO.setStatus(null); + reqVO.setCheckStatus(null); + reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setRemindDays(null); + reqVO.setRemindTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setCustomerId(null); + reqVO.setContractId(null); + reqVO.setOwnerUserId(null); + reqVO.setRemark(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + List list = receivablePlanService.getReceivablePlanList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbReceivablePlan, list.get(0)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java new file mode 100644 index 000000000..3d1b47403 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java @@ -0,0 +1,279 @@ +package cn.iocoder.yudao.module.crm.service.receivable; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; +import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link ReceivableServiceImpl} 的单元测试类 + * + * @author 赤焰 + */ +@Import(ReceivableServiceImpl.class) +public class ReceivableServiceImplTest extends BaseDbUnitTest { + + @Resource + private ReceivableServiceImpl receivableService; + + @Resource + private ReceivableMapper receivableMapper; + + @Test + public void testCreateReceivable_success() { + // 准备参数 + ReceivableCreateReqVO reqVO = randomPojo(ReceivableCreateReqVO.class); + + // 调用 + Long receivableId = receivableService.createReceivable(reqVO); + // 断言 + assertNotNull(receivableId); + // 校验记录的属性是否正确 + ReceivableDO receivable = receivableMapper.selectById(receivableId); + assertPojoEquals(reqVO, receivable); + } + + @Test + public void testUpdateReceivable_success() { + // mock 数据 + ReceivableDO dbReceivable = randomPojo(ReceivableDO.class); + receivableMapper.insert(dbReceivable);// @Sql: 先插入出一条存在的数据 + // 准备参数 + ReceivableUpdateReqVO reqVO = randomPojo(ReceivableUpdateReqVO.class, o -> { + o.setId(dbReceivable.getId()); // 设置更新的 ID + }); + + // 调用 + receivableService.updateReceivable(reqVO); + // 校验是否更新正确 + ReceivableDO receivable = receivableMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, receivable); + } + + @Test + public void testUpdateReceivable_notExists() { + // 准备参数 + ReceivableUpdateReqVO reqVO = randomPojo(ReceivableUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> receivableService.updateReceivable(reqVO), RECEIVABLE_NOT_EXISTS); + } + + @Test + public void testDeleteReceivable_success() { + // mock 数据 + ReceivableDO dbReceivable = randomPojo(ReceivableDO.class); + receivableMapper.insert(dbReceivable);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbReceivable.getId(); + + // 调用 + receivableService.deleteReceivable(id); + // 校验数据不存在了 + assertNull(receivableMapper.selectById(id)); + } + + @Test + public void testDeleteReceivable_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> receivableService.deleteReceivable(id), RECEIVABLE_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetReceivablePage() { + // mock 数据 + ReceivableDO dbReceivable = randomPojo(ReceivableDO.class, o -> { // 等会查询到 + o.setNo(null); + o.setPlanId(null); + o.setCustomerId(null); + o.setContractId(null); + o.setCheckStatus(null); + o.setProcessInstanceId(null); + o.setReturnTime(null); + o.setReturnType(null); + o.setPrice(null); + o.setOwnerUserId(null); + o.setBatchId(null); + o.setSort(null); + o.setDataScope(null); + o.setDataScopeDeptIds(null); + o.setStatus(null); + o.setRemark(null); + o.setCreateTime(null); + }); + receivableMapper.insert(dbReceivable); + // 测试 no 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setNo(null))); + // 测试 planId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPlanId(null))); + // 测试 customerId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCustomerId(null))); + // 测试 contractId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setContractId(null))); + // 测试 checkStatus 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCheckStatus(null))); + // 测试 processInstanceId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setProcessInstanceId(null))); + // 测试 returnTime 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnTime(null))); + // 测试 returnType 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnType(null))); + // 测试 price 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPrice(null))); + // 测试 ownerUserId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setOwnerUserId(null))); + // 测试 batchId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setBatchId(null))); + // 测试 sort 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setSort(null))); + // 测试 dataScope 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScope(null))); + // 测试 dataScopeDeptIds 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScopeDeptIds(null))); + // 测试 status 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setStatus(null))); + // 测试 remark 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setRemark(null))); + // 测试 createTime 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCreateTime(null))); + // 准备参数 + ReceivablePageReqVO reqVO = new ReceivablePageReqVO(); + reqVO.setNo(null); + reqVO.setPlanId(null); + reqVO.setCustomerId(null); + reqVO.setContractId(null); + reqVO.setCheckStatus(null); + reqVO.setProcessInstanceId(null); + reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setReturnType(null); + reqVO.setPrice(null); + reqVO.setOwnerUserId(null); + reqVO.setBatchId(null); + reqVO.setSort(null); + reqVO.setDataScope(null); + reqVO.setDataScopeDeptIds(null); + reqVO.setStatus(null); + reqVO.setRemark(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = receivableService.getReceivablePage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbReceivable, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetReceivableList() { + // mock 数据 + ReceivableDO dbReceivable = randomPojo(ReceivableDO.class, o -> { // 等会查询到 + o.setNo(null); + o.setPlanId(null); + o.setCustomerId(null); + o.setContractId(null); + o.setCheckStatus(null); + o.setProcessInstanceId(null); + o.setReturnTime(null); + o.setReturnType(null); + o.setPrice(null); + o.setOwnerUserId(null); + o.setBatchId(null); + o.setSort(null); + o.setDataScope(null); + o.setDataScopeDeptIds(null); + o.setStatus(null); + o.setRemark(null); + o.setCreateTime(null); + }); + receivableMapper.insert(dbReceivable); + // 测试 no 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setNo(null))); + // 测试 planId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPlanId(null))); + // 测试 customerId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCustomerId(null))); + // 测试 contractId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setContractId(null))); + // 测试 checkStatus 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCheckStatus(null))); + // 测试 processInstanceId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setProcessInstanceId(null))); + // 测试 returnTime 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnTime(null))); + // 测试 returnType 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnType(null))); + // 测试 price 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPrice(null))); + // 测试 ownerUserId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setOwnerUserId(null))); + // 测试 batchId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setBatchId(null))); + // 测试 sort 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setSort(null))); + // 测试 dataScope 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScope(null))); + // 测试 dataScopeDeptIds 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScopeDeptIds(null))); + // 测试 status 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setStatus(null))); + // 测试 remark 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setRemark(null))); + // 测试 createTime 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCreateTime(null))); + // 准备参数 + ReceivableExportReqVO reqVO = new ReceivableExportReqVO(); + reqVO.setNo(null); + reqVO.setPlanId(null); + reqVO.setCustomerId(null); + reqVO.setContractId(null); + reqVO.setCheckStatus(null); + reqVO.setProcessInstanceId(null); + reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setReturnType(null); + reqVO.setPrice(null); + reqVO.setOwnerUserId(null); + reqVO.setBatchId(null); + reqVO.setSort(null); + reqVO.setDataScope(null); + reqVO.setDataScopeDeptIds(null); + reqVO.setStatus(null); + reqVO.setRemark(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + List list = receivableService.getReceivableList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbReceivable, list.get(0)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql index 983e53ab3..525391b33 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql @@ -1,3 +1,7 @@ DELETE FROM "crm_contract"; -DELETE FROM "crm_clue"; \ No newline at end of file +DELETE FROM "crm_clue"; + +DELETE FROM "crm_receivable"; + +DELETE FROM "crm_receivable_plan"; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql index 816264e66..8d98883b4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql @@ -46,4 +46,55 @@ CREATE TABLE IF NOT EXISTS "crm_clue" ( "deleted" bit NOT NULL DEFAULT FALSE, "tenant_id" bigint NOT NULL, PRIMARY KEY ("id") -) COMMENT '线索表'; \ No newline at end of file +) COMMENT '线索表'; + +CREATE TABLE IF NOT EXISTS "crm_receivable" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "no" varchar, + "plan_id" bigint, + "customer_id" bigint, + "contract_id" bigint, + "check_status" int, + "process_instance_id" bigint, + "return_time" varchar, + "return_type" varchar, + "price" varchar, + "owner_user_id" bigint, + "batch_id" bigint, + "sort" int, + "data_scope" int, + "data_scope_dept_ids" varchar, + "status" int NOT NULL, + "remark" varchar, + "creator" varchar DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT '回款管理'; + +CREATE TABLE IF NOT EXISTS "crm_receivable_plan" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "index_no" bigint, + "receivable_id" bigint, + "status" int NOT NULL, + "check_status" varchar, + "process_instance_id" bigint, + "price" varchar, + "return_time" varchar, + "remind_days" bigint, + "remind_time" varchar, + "customer_id" bigint, + "contract_id" bigint, + "owner_user_id" bigint, + "sort" int, + "remark" varchar, + "creator" varchar DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT '回款计划'; +