From 73f4fc8ceb4adbca1a9b9c75f87f684b7a98aaa6 Mon Sep 17 00:00:00 2001 From: liuhongfeng <291117974@qq.com> Date: Fri, 20 Oct 2023 22:16:34 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91=E5=9B=9E?= =?UTF-8?q?=E6=AC=BE=E7=AE=A1=E7=90=86=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 34 ++- sql/mysql/crm_data.sql | 19 ++ sql/mysql/crm_menu.sql | 69 ++++- .../module/crm/enums/ErrorCodeConstants.java | 2 + .../receivable/ReceivableController.java | 101 +++++++ .../admin/receivable/vo/ReceivableBaseVO.java | 72 +++++ .../receivable/vo/ReceivableCreateReqVO.java | 14 + .../receivable/vo/ReceivableExcelVO.java | 80 +++++ .../receivable/vo/ReceivableExportReqVO.java | 72 +++++ .../receivable/vo/ReceivablePageReqVO.java | 73 +++++ .../admin/receivable/vo/ReceivableRespVO.java | 19 ++ .../receivable/vo/ReceivableUpdateReqVO.java | 18 ++ .../convert/receivable/ReceivableConvert.java | 34 +++ .../dataobject/receivable/ReceivableDO.java | 101 +++++++ .../mysql/receivable/ReceivableMapper.java | 64 ++++ .../service/receivable/ReceivableService.java | 71 +++++ .../receivable/ReceivableServiceImpl.java | 87 ++++++ .../mapper/receivable/ReceivableMapper.xml | 12 + .../receivable/ReceivableServiceImplTest.java | 279 ++++++++++++++++++ .../src/test/resources/sql/clean.sql | 4 +- .../src/test/resources/sql/create_tables.sql | 28 +- 21 files changed, 1249 insertions(+), 4 deletions(-) create mode 100644 sql/mysql/crm_data.sql create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivableConvert.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableService.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivableMapper.xml create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 6c5594068..699f69307 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -60,4 +60,36 @@ CREATE TABLE `crm_clue` ( `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线索表' ROW_FORMAT = Dynamic; \ No newline at end of file +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '线索表' ROW_FORMAT = Dynamic; + + +-- ---------------------------- +-- 回款表 +-- ---------------------------- +DROP TABLE IF EXISTS `crm_receivable`; +CREATE TABLE `crm_receivable` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', + `no` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '回款编号', + `plan_id` bigint(20) NULL DEFAULT NULL COMMENT '回款计划ID', + `customer_id` bigint(20) NULL DEFAULT NULL COMMENT '客户ID', + `contract_id` bigint(20) NULL DEFAULT NULL COMMENT '合同ID', + `check_status` tinyint(4) NULL DEFAULT NULL COMMENT '审批状态', + `process_instance_id` bigint(20) NULL DEFAULT NULL COMMENT '工作流编号', + `return_time` datetime NULL DEFAULT NULL COMMENT '回款日期', + `return_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '回款方式', + `price` decimal(10, 2) NULL DEFAULT NULL COMMENT '回款金额', + `owner_user_id` bigint(20) NULL DEFAULT NULL COMMENT '负责人的用户编号', + `batch_id` bigint(20) NULL DEFAULT NULL COMMENT '批次', + `sort` int(11) NULL DEFAULT NULL COMMENT '显示顺序', + `data_scope` tinyint(4) NULL DEFAULT 1 COMMENT '数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)', + `data_scope_dept_ids` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '数据范围(指定部门数组)', + `status` tinyint(4) NOT NULL COMMENT '状态(0正常 1停用)', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` bigint(20) NOT NULL DEFAULT 0 COMMENT '租户编号', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '回款管理' ROW_FORMAT = DYNAMIC; diff --git a/sql/mysql/crm_data.sql b/sql/mysql/crm_data.sql new file mode 100644 index 000000000..dfc1135f9 --- /dev/null +++ b/sql/mysql/crm_data.sql @@ -0,0 +1,19 @@ + +INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (184, '回款管理审批状态', 'crm_receivable_check_status', 0, '回款管理审批状态(0 未审核 1 审核通过 2 审核拒绝 3 审核中 4 已撤回)', '1', '2023-10-18 21:44:24', '1', '2023-10-18 21:44:24', b'0', '1970-01-01 00:00:00'); +INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (185, '回款管理-回款方式', 'crm_return_type', 0, '回款管理-回款方式', '1', '2023-10-18 21:54:10', '1', '2023-10-18 21:54:10', b'0', '1970-01-01 00:00:00'); + + +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1389, 0, '未审核', '0', 'crm_receivable_check_status', 0, 'default', '', '0 未审核 ', '1', '2023-10-18 21:46:00', '1', '2023-10-18 21:47:16', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1390, 1, '审核通过', '1', 'crm_receivable_check_status', 0, 'default', '', '1 审核通过', '1', '2023-10-18 21:46:18', '1', '2023-10-18 21:47:08', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1391, 2, '审核拒绝', '2', 'crm_receivable_check_status', 0, 'default', '', ' 2 审核拒绝', '1', '2023-10-18 21:46:58', '1', '2023-10-18 21:47:21', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1392, 3, '审核中', '3', 'crm_receivable_check_status', 0, 'default', '', ' 3 审核中', '1', '2023-10-18 21:47:35', '1', '2023-10-18 21:47:35', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1393, 4, '已撤回', '4', 'crm_receivable_check_status', 0, 'default', '', ' 4 已撤回', '1', '2023-10-18 21:47:46', '1', '2023-10-18 21:47:46', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1394, 1, '支票', '1', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:54:29', '1', '2023-10-18 21:54:29', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1395, 2, '现金', '2', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:54:41', '1', '2023-10-18 21:54:41', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1396, 3, '邮政汇款', '3', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:54:53', '1', '2023-10-18 21:54:53', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1397, 4, '电汇', '4', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:07', '1', '2023-10-18 21:55:07', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1398, 5, '网上转账', '5', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:24', '1', '2023-10-18 21:55:24', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1399, 6, '支付宝', '6', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:38', '1', '2023-10-18 21:55:38', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1400, 7, '微信支付', '7', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:55:53', '1', '2023-10-18 21:55:53', b'0'); +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1401, 8, '其他', '8', 'crm_return_type', 0, 'default', '', '', '1', '2023-10-18 21:56:06', '1', '2023-10-18 21:56:06', b'0'); + diff --git a/sql/mysql/crm_menu.sql b/sql/mysql/crm_menu.sql index cf0fe00fd..25c07c6a8 100644 --- a/sql/mysql/crm_menu.sql +++ b/sql/mysql/crm_menu.sql @@ -8,7 +8,7 @@ INSERT INTO system_menu( path, icon, component, status, component_name ) VALUES ( - '合同管理', '', 2, 0, 1254, + '合同管理', '', 2, 0, 2375, 'contract', '', 'crm/contract/index', 0, 'Contract' ); @@ -117,3 +117,70 @@ VALUES ( '线索导出', 'crm:clue:export', 3, 5, @parentId, '', '', '', 0 ); + + +-- ---------------------------- +-- 客户管理菜单 +-- ---------------------------- +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2375, '客户管理', '', 1, 0, 0, '/crm', 'ep:avatar', '', '', 0, b'1', b'1', b'1', '1', '2023-10-20 00:36:13', '1', '2023-10-19 16:37:24', b'0'); + + +-- ---------------------------- +-- 回款菜单 +-- ---------------------------- + +-- 菜单 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status, component_name +) +VALUES ( + '回款管理', '', 2, 0, 2375, + 'receivable', '', 'crm/receivable/index', 0, 'Receivable' + ); + +-- 按钮父菜单ID +-- 暂时只支持 MySQL。如果你是 Oracle、PostgreSQL、SQLServer 的话,需要手动修改 @parentId 的部分的代码 +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款管理查询', 'crm:receivable:query', 3, 1, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款管理创建', 'crm:receivable:create', 3, 2, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款管理更新', 'crm:receivable:update', 3, 3, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款管理删除', 'crm:receivable:delete', 3, 4, @parentId, + '', '', '', 0 + ); +INSERT INTO system_menu( + name, permission, type, sort, parent_id, + path, icon, component, status +) +VALUES ( + '回款管理导出', 'crm:receivable:export', 3, 5, @parentId, + '', '', '', 0 + ); diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java index 3538b16ee..6c0d03d93 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java @@ -15,4 +15,6 @@ public interface ErrorCodeConstants { // TODO @wanwan:要单独一个分段噢 ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_000_001, "线索不存在"); + ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_030_000_001, "回款管理不存在"); + } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java new file mode 100644 index 000000000..94c3a1c70 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/ReceivableController.java @@ -0,0 +1,101 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; +import cn.iocoder.yudao.module.crm.service.receivable.ReceivableService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.io.IOException; +import java.util.Collection; +import java.util.List; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; + +/** + * @author 赤焰 + */ +@Tag(name = "管理后台 - 回款管理") +@RestController +@RequestMapping("/crm/receivable") +@Validated +public class ReceivableController { + + @Resource + private ReceivableService receivableService; + + @PostMapping("/create") + @Operation(summary = "创建回款管理") + @PreAuthorize("@ss.hasPermission('crm:receivable:create')") + public CommonResult createReceivable(@Valid @RequestBody ReceivableCreateReqVO createReqVO) { + return success(receivableService.createReceivable(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新回款管理") + @PreAuthorize("@ss.hasPermission('crm:receivable:update')") + public CommonResult updateReceivable(@Valid @RequestBody ReceivableUpdateReqVO updateReqVO) { + receivableService.updateReceivable(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除回款管理") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('crm:receivable:delete')") + public CommonResult deleteReceivable(@RequestParam("id") Long id) { + receivableService.deleteReceivable(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得回款管理") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('crm:receivable:query')") + public CommonResult getReceivable(@RequestParam("id") Long id) { + ReceivableDO receivable = receivableService.getReceivable(id); + return success(ReceivableConvert.INSTANCE.convert(receivable)); + } + + @GetMapping("/list") + @Operation(summary = "获得回款管理列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('crm:receivable:query')") + public CommonResult> getReceivableList(@RequestParam("ids") Collection ids) { + List list = receivableService.getReceivableList(ids); + return success(ReceivableConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得回款管理分页") + @PreAuthorize("@ss.hasPermission('crm:receivable:query')") + public CommonResult> getReceivablePage(@Valid ReceivablePageReqVO pageVO) { + PageResult pageResult = receivableService.getReceivablePage(pageVO); + return success(ReceivableConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出回款管理 Excel") + @PreAuthorize("@ss.hasPermission('crm:receivable:export')") + @OperateLog(type = EXPORT) + public void exportReceivableExcel(@Valid ReceivableExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = receivableService.getReceivableList(exportReqVO); + // 导出 Excel + List datas = ReceivableConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "回款管理.xls", "数据", ReceivableExcelVO.class, datas); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java new file mode 100644 index 000000000..4b63f1466 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java @@ -0,0 +1,72 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; +import org.springframework.format.annotation.DateTimeFormat; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * 回款管理 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class ReceivableBaseVO { + + @Schema(description = "回款编号") + private String no; + + @Schema(description = "回款计划ID", example = "31177") + private Long planId; + + @Schema(description = "客户ID", example = "4963") + private Long customerId; + + @Schema(description = "合同ID", example = "30305") + private Long contractId; + + @Schema(description = "审批状态", example = "1") + private Integer checkStatus; + + @Schema(description = "工作流编号", example = "16568") + private Long processInstanceId; + + @Schema(description = "回款日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime returnTime; + + @Schema(description = "回款方式", example = "2") + private String returnType; + + @Schema(description = "回款金额", example = "31859") + private BigDecimal price; + + @Schema(description = "负责人", example = "22202") + private Long ownerUserId; + + @Schema(description = "批次", example = "2539") + private Long batchId; + + @Schema(description = "显示顺序") + private Integer sort; + + @Schema(description = "数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") + private Integer dataScope; + + @Schema(description = "数据范围(指定部门数组)") + private String dataScopeDeptIds; + + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "状态不能为空") + private Integer status; + + @Schema(description = "备注", example = "随便") + private String remark; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java new file mode 100644 index 000000000..5bbb4fce2 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 回款管理创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivableCreateReqVO extends ReceivableBaseVO { + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java new file mode 100644 index 000000000..f60330c53 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExcelVO.java @@ -0,0 +1,80 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; + + +/** + * 回款管理 Excel VO + * + * @author 赤焰 + */ +@Data +public class ReceivableExcelVO { + + @ExcelProperty("ID") + private Long id; + + @ExcelProperty("回款编号") + private String no; + + @ExcelProperty("回款计划ID") + private Long planId; + + @ExcelProperty("客户ID") + private Long customerId; + + @ExcelProperty("合同ID") + private Long contractId; + + @ExcelProperty(value = "审批状态", converter = DictConvert.class) + @DictFormat("crm_receivable_check_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private Integer checkStatus; + + @ExcelProperty("工作流编号") + private Long processInstanceId; + + @ExcelProperty("回款日期") + private LocalDateTime returnTime; + + @ExcelProperty("回款方式") + private String returnType; + + @ExcelProperty("回款金额") + private BigDecimal price; + + @ExcelProperty("负责人") + private Long ownerUserId; + + @ExcelProperty("批次") + private Long batchId; + + //@ExcelProperty("显示顺序") + //private Integer sort; + + //@ExcelProperty("数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") + //private Integer dataScope; + + //@ExcelProperty("数据范围(指定部门数组)") + //private String dataScopeDeptIds; + + @ExcelProperty(value = "状态", converter = DictConvert.class) + @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private Integer status; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java new file mode 100644 index 000000000..7ea31a0fb --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableExportReqVO.java @@ -0,0 +1,72 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +/** + * @author 赤焰 + */ +@Schema(description = "管理后台 - 回款管理 Excel 导出 Request VO,参数和 ReceivablePageReqVO 是一致的") +@Data +public class ReceivableExportReqVO { + + @Schema(description = "回款编号") + private String no; + + @Schema(description = "回款计划ID", example = "31177") + private Long planId; + + @Schema(description = "客户ID", example = "4963") + private Long customerId; + + @Schema(description = "合同ID", example = "30305") + private Long contractId; + + @Schema(description = "审批状态", example = "1") + private Integer checkStatus; + + @Schema(description = "工作流编号", example = "16568") + private Long processInstanceId; + + @Schema(description = "回款日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] returnTime; + + @Schema(description = "回款方式", example = "2") + private String returnType; + + @Schema(description = "回款金额", example = "31859") + private BigDecimal price; + + @Schema(description = "负责人", example = "22202") + private Long ownerUserId; + + @Schema(description = "批次", example = "2539") + private Long batchId; + + @Schema(description = "显示顺序") + private Integer sort; + + @Schema(description = "数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") + private Integer dataScope; + + @Schema(description = "数据范围(指定部门数组)") + private String dataScopeDeptIds; + + @Schema(description = "状态", example = "1") + private Integer status; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java new file mode 100644 index 000000000..7b9e9df6d --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePageReqVO.java @@ -0,0 +1,73 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import lombok.*; + +import java.math.BigDecimal; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 回款管理分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivablePageReqVO extends PageParam { + + @Schema(description = "回款编号") + private String no; + + @Schema(description = "回款计划ID", example = "31177") + private Long planId; + + @Schema(description = "客户ID", example = "4963") + private Long customerId; + + @Schema(description = "合同ID", example = "30305") + private Long contractId; + + @Schema(description = "审批状态", example = "1") + private Integer checkStatus; + + @Schema(description = "工作流编号", example = "16568") + private Long processInstanceId; + + @Schema(description = "回款日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] returnTime; + + @Schema(description = "回款方式", example = "2") + private String returnType; + + @Schema(description = "回款金额", example = "31859") + private BigDecimal price; + + @Schema(description = "负责人", example = "22202") + private Long ownerUserId; + + @Schema(description = "批次", example = "2539") + private Long batchId; + + @Schema(description = "显示顺序") + private Integer sort; + + @Schema(description = "数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限)") + private Integer dataScope; + + @Schema(description = "数据范围(指定部门数组)") + private String dataScopeDeptIds; + + @Schema(description = "状态", example = "1") + private Integer status; + + @Schema(description = "备注", example = "随便") + private String remark; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java new file mode 100644 index 000000000..fd26e312e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 回款管理 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivableRespVO extends ReceivableBaseVO { + + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25787") + private Long id; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java new file mode 100644 index 000000000..600b09943 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 回款管理更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ReceivableUpdateReqVO extends ReceivableBaseVO { + + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25787") + @NotNull(message = "ID不能为空") + private Long id; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivableConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivableConvert.java new file mode 100644 index 000000000..7f14aaddd --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/ReceivableConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.crm.convert.receivable; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; + +/** + * 回款管理 Convert + * + * @author 赤焰 + */ +@Mapper +public interface ReceivableConvert { + + ReceivableConvert INSTANCE = Mappers.getMapper(ReceivableConvert.class); + + ReceivableDO convert(ReceivableCreateReqVO bean); + + ReceivableDO convert(ReceivableUpdateReqVO bean); + + ReceivableRespVO convert(ReceivableDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java new file mode 100644 index 000000000..561765b09 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivableDO.java @@ -0,0 +1,101 @@ +package cn.iocoder.yudao.module.crm.dal.dataobject.receivable; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 回款管理 DO + * + * @author 赤焰 + */ +@TableName("crm_receivable") +@KeySequence("crm_receivable_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ReceivableDO extends BaseDO { + + /** + * ID + */ + @TableId + private Long id; + /** + * 回款编号 + */ + private String no; + /** + * 回款计划ID + */ + private Long planId; + /** + * 客户ID + */ + private Long customerId; + /** + * 合同ID + */ + private Long contractId; + /** + * 审批状态 + * + * 枚举 {@link TODO crm_receivable_check_status 对应的类} + */ + private Integer checkStatus; + /** + * 工作流编号 + */ + private Long processInstanceId; + /** + * 回款日期 + */ + private LocalDateTime returnTime; + /** + * 回款方式 + */ + private String returnType; + /** + * 回款金额 + */ + private BigDecimal price; + /** + * 负责人 + */ + private Long ownerUserId; + /** + * 批次 + */ + private Long batchId; + /** + * 显示顺序 + */ + private Integer sort; + /** + * 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限) + */ + private Integer dataScope; + /** + * 数据范围(指定部门数组) + */ + private String dataScopeDeptIds; + /** + * 状态 + * + * 枚举 {@link TODO common_status 对应的类} + */ + private Integer status; + /** + * 备注 + */ + private String remark; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java new file mode 100644 index 000000000..08031772c --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/ReceivableMapper.java @@ -0,0 +1,64 @@ +package cn.iocoder.yudao.module.crm.dal.mysql.receivable; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; + +/** + * 回款管理 Mapper + * + * @author 赤焰 + */ +@Mapper +public interface ReceivableMapper extends BaseMapperX { + + default PageResult selectPage(ReceivablePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(ReceivableDO::getNo, reqVO.getNo()) + .eqIfPresent(ReceivableDO::getPlanId, reqVO.getPlanId()) + .eqIfPresent(ReceivableDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(ReceivableDO::getContractId, reqVO.getContractId()) + .eqIfPresent(ReceivableDO::getCheckStatus, reqVO.getCheckStatus()) + .eqIfPresent(ReceivableDO::getProcessInstanceId, reqVO.getProcessInstanceId()) + .betweenIfPresent(ReceivableDO::getReturnTime, reqVO.getReturnTime()) + .eqIfPresent(ReceivableDO::getReturnType, reqVO.getReturnType()) + .eqIfPresent(ReceivableDO::getPrice, reqVO.getPrice()) + .eqIfPresent(ReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) + .eqIfPresent(ReceivableDO::getBatchId, reqVO.getBatchId()) + .eqIfPresent(ReceivableDO::getSort, reqVO.getSort()) + .eqIfPresent(ReceivableDO::getDataScope, reqVO.getDataScope()) + .eqIfPresent(ReceivableDO::getDataScopeDeptIds, reqVO.getDataScopeDeptIds()) + .eqIfPresent(ReceivableDO::getStatus, reqVO.getStatus()) + .eqIfPresent(ReceivableDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(ReceivableDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(ReceivableDO::getId)); + } + + default List selectList(ReceivableExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(ReceivableDO::getNo, reqVO.getNo()) + .eqIfPresent(ReceivableDO::getPlanId, reqVO.getPlanId()) + .eqIfPresent(ReceivableDO::getCustomerId, reqVO.getCustomerId()) + .eqIfPresent(ReceivableDO::getContractId, reqVO.getContractId()) + .eqIfPresent(ReceivableDO::getCheckStatus, reqVO.getCheckStatus()) + .eqIfPresent(ReceivableDO::getProcessInstanceId, reqVO.getProcessInstanceId()) + .betweenIfPresent(ReceivableDO::getReturnTime, reqVO.getReturnTime()) + .eqIfPresent(ReceivableDO::getReturnType, reqVO.getReturnType()) + .eqIfPresent(ReceivableDO::getPrice, reqVO.getPrice()) + .eqIfPresent(ReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) + .eqIfPresent(ReceivableDO::getBatchId, reqVO.getBatchId()) + .eqIfPresent(ReceivableDO::getSort, reqVO.getSort()) + .eqIfPresent(ReceivableDO::getDataScope, reqVO.getDataScope()) + .eqIfPresent(ReceivableDO::getDataScopeDeptIds, reqVO.getDataScopeDeptIds()) + .eqIfPresent(ReceivableDO::getStatus, reqVO.getStatus()) + .eqIfPresent(ReceivableDO::getRemark, reqVO.getRemark()) + .betweenIfPresent(ReceivableDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(ReceivableDO::getId)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableService.java new file mode 100644 index 000000000..a673ec99e --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableService.java @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.crm.service.receivable; + +import java.util.*; +import javax.validation.*; + +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * 回款管理 Service 接口 + * + * @author 赤焰 + */ +public interface ReceivableService { + + /** + * 创建回款管理 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createReceivable(@Valid ReceivableCreateReqVO createReqVO); + + /** + * 更新回款管理 + * + * @param updateReqVO 更新信息 + */ + void updateReceivable(@Valid ReceivableUpdateReqVO updateReqVO); + + /** + * 删除回款管理 + * + * @param id 编号 + */ + void deleteReceivable(Long id); + + /** + * 获得回款管理 + * + * @param id 编号 + * @return 回款管理 + */ + ReceivableDO getReceivable(Long id); + + /** + * 获得回款管理列表 + * + * @param ids 编号 + * @return 回款管理列表 + */ + List getReceivableList(Collection ids); + + /** + * 获得回款管理分页 + * + * @param pageReqVO 分页查询 + * @return 回款管理分页 + */ + PageResult getReceivablePage(ReceivablePageReqVO pageReqVO); + + /** + * 获得回款管理列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 回款管理列表 + */ + List getReceivableList(ReceivableExportReqVO exportReqVO); + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java new file mode 100644 index 000000000..2f5abe1fc --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java @@ -0,0 +1,87 @@ +package cn.iocoder.yudao.module.crm.service.receivable; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import java.util.*; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; + +import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; +import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; + +/** + * 回款管理 Service 实现类 + * + * @author 赤焰 + */ +@Service +@Validated +public class ReceivableServiceImpl implements ReceivableService { + + @Resource + private ReceivableMapper receivableMapper; + + @Override + public Long createReceivable(ReceivableCreateReqVO createReqVO) { + // 插入 + ReceivableDO receivable = ReceivableConvert.INSTANCE.convert(createReqVO); + receivableMapper.insert(receivable); + // 返回 + return receivable.getId(); + } + + @Override + public void updateReceivable(ReceivableUpdateReqVO updateReqVO) { + // 校验存在 + validateReceivableExists(updateReqVO.getId()); + // 更新 + ReceivableDO updateObj = ReceivableConvert.INSTANCE.convert(updateReqVO); + receivableMapper.updateById(updateObj); + } + + @Override + public void deleteReceivable(Long id) { + // 校验存在 + validateReceivableExists(id); + // 删除 + receivableMapper.deleteById(id); + } + + private void validateReceivableExists(Long id) { + if (receivableMapper.selectById(id) == null) { + throw exception(RECEIVABLE_NOT_EXISTS); + } + } + + @Override + public ReceivableDO getReceivable(Long id) { + return receivableMapper.selectById(id); + } + + @Override + public List getReceivableList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return ListUtil.empty(); + } + return receivableMapper.selectBatchIds(ids); + } + + @Override + public PageResult getReceivablePage(ReceivablePageReqVO pageReqVO) { + return receivableMapper.selectPage(pageReqVO); + } + + @Override + public List getReceivableList(ReceivableExportReqVO exportReqVO) { + return receivableMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivableMapper.xml b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivableMapper.xml new file mode 100644 index 000000000..b87beb08f --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/resources/mapper/receivable/ReceivableMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java new file mode 100644 index 000000000..3d1b47403 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImplTest.java @@ -0,0 +1,279 @@ +package cn.iocoder.yudao.module.crm.service.receivable; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; +import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link ReceivableServiceImpl} 的单元测试类 + * + * @author 赤焰 + */ +@Import(ReceivableServiceImpl.class) +public class ReceivableServiceImplTest extends BaseDbUnitTest { + + @Resource + private ReceivableServiceImpl receivableService; + + @Resource + private ReceivableMapper receivableMapper; + + @Test + public void testCreateReceivable_success() { + // 准备参数 + ReceivableCreateReqVO reqVO = randomPojo(ReceivableCreateReqVO.class); + + // 调用 + Long receivableId = receivableService.createReceivable(reqVO); + // 断言 + assertNotNull(receivableId); + // 校验记录的属性是否正确 + ReceivableDO receivable = receivableMapper.selectById(receivableId); + assertPojoEquals(reqVO, receivable); + } + + @Test + public void testUpdateReceivable_success() { + // mock 数据 + ReceivableDO dbReceivable = randomPojo(ReceivableDO.class); + receivableMapper.insert(dbReceivable);// @Sql: 先插入出一条存在的数据 + // 准备参数 + ReceivableUpdateReqVO reqVO = randomPojo(ReceivableUpdateReqVO.class, o -> { + o.setId(dbReceivable.getId()); // 设置更新的 ID + }); + + // 调用 + receivableService.updateReceivable(reqVO); + // 校验是否更新正确 + ReceivableDO receivable = receivableMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, receivable); + } + + @Test + public void testUpdateReceivable_notExists() { + // 准备参数 + ReceivableUpdateReqVO reqVO = randomPojo(ReceivableUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> receivableService.updateReceivable(reqVO), RECEIVABLE_NOT_EXISTS); + } + + @Test + public void testDeleteReceivable_success() { + // mock 数据 + ReceivableDO dbReceivable = randomPojo(ReceivableDO.class); + receivableMapper.insert(dbReceivable);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbReceivable.getId(); + + // 调用 + receivableService.deleteReceivable(id); + // 校验数据不存在了 + assertNull(receivableMapper.selectById(id)); + } + + @Test + public void testDeleteReceivable_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> receivableService.deleteReceivable(id), RECEIVABLE_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetReceivablePage() { + // mock 数据 + ReceivableDO dbReceivable = randomPojo(ReceivableDO.class, o -> { // 等会查询到 + o.setNo(null); + o.setPlanId(null); + o.setCustomerId(null); + o.setContractId(null); + o.setCheckStatus(null); + o.setProcessInstanceId(null); + o.setReturnTime(null); + o.setReturnType(null); + o.setPrice(null); + o.setOwnerUserId(null); + o.setBatchId(null); + o.setSort(null); + o.setDataScope(null); + o.setDataScopeDeptIds(null); + o.setStatus(null); + o.setRemark(null); + o.setCreateTime(null); + }); + receivableMapper.insert(dbReceivable); + // 测试 no 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setNo(null))); + // 测试 planId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPlanId(null))); + // 测试 customerId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCustomerId(null))); + // 测试 contractId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setContractId(null))); + // 测试 checkStatus 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCheckStatus(null))); + // 测试 processInstanceId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setProcessInstanceId(null))); + // 测试 returnTime 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnTime(null))); + // 测试 returnType 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnType(null))); + // 测试 price 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPrice(null))); + // 测试 ownerUserId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setOwnerUserId(null))); + // 测试 batchId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setBatchId(null))); + // 测试 sort 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setSort(null))); + // 测试 dataScope 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScope(null))); + // 测试 dataScopeDeptIds 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScopeDeptIds(null))); + // 测试 status 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setStatus(null))); + // 测试 remark 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setRemark(null))); + // 测试 createTime 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCreateTime(null))); + // 准备参数 + ReceivablePageReqVO reqVO = new ReceivablePageReqVO(); + reqVO.setNo(null); + reqVO.setPlanId(null); + reqVO.setCustomerId(null); + reqVO.setContractId(null); + reqVO.setCheckStatus(null); + reqVO.setProcessInstanceId(null); + reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setReturnType(null); + reqVO.setPrice(null); + reqVO.setOwnerUserId(null); + reqVO.setBatchId(null); + reqVO.setSort(null); + reqVO.setDataScope(null); + reqVO.setDataScopeDeptIds(null); + reqVO.setStatus(null); + reqVO.setRemark(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = receivableService.getReceivablePage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbReceivable, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetReceivableList() { + // mock 数据 + ReceivableDO dbReceivable = randomPojo(ReceivableDO.class, o -> { // 等会查询到 + o.setNo(null); + o.setPlanId(null); + o.setCustomerId(null); + o.setContractId(null); + o.setCheckStatus(null); + o.setProcessInstanceId(null); + o.setReturnTime(null); + o.setReturnType(null); + o.setPrice(null); + o.setOwnerUserId(null); + o.setBatchId(null); + o.setSort(null); + o.setDataScope(null); + o.setDataScopeDeptIds(null); + o.setStatus(null); + o.setRemark(null); + o.setCreateTime(null); + }); + receivableMapper.insert(dbReceivable); + // 测试 no 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setNo(null))); + // 测试 planId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPlanId(null))); + // 测试 customerId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCustomerId(null))); + // 测试 contractId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setContractId(null))); + // 测试 checkStatus 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCheckStatus(null))); + // 测试 processInstanceId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setProcessInstanceId(null))); + // 测试 returnTime 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnTime(null))); + // 测试 returnType 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnType(null))); + // 测试 price 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPrice(null))); + // 测试 ownerUserId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setOwnerUserId(null))); + // 测试 batchId 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setBatchId(null))); + // 测试 sort 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setSort(null))); + // 测试 dataScope 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScope(null))); + // 测试 dataScopeDeptIds 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScopeDeptIds(null))); + // 测试 status 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setStatus(null))); + // 测试 remark 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setRemark(null))); + // 测试 createTime 不匹配 + receivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCreateTime(null))); + // 准备参数 + ReceivableExportReqVO reqVO = new ReceivableExportReqVO(); + reqVO.setNo(null); + reqVO.setPlanId(null); + reqVO.setCustomerId(null); + reqVO.setContractId(null); + reqVO.setCheckStatus(null); + reqVO.setProcessInstanceId(null); + reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setReturnType(null); + reqVO.setPrice(null); + reqVO.setOwnerUserId(null); + reqVO.setBatchId(null); + reqVO.setSort(null); + reqVO.setDataScope(null); + reqVO.setDataScopeDeptIds(null); + reqVO.setStatus(null); + reqVO.setRemark(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + List list = receivableService.getReceivableList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbReceivable, list.get(0)); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql index 983e53ab3..97305a2e2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/clean.sql @@ -1,3 +1,5 @@ DELETE FROM "crm_contract"; -DELETE FROM "crm_clue"; \ No newline at end of file +DELETE FROM "crm_clue"; + +DELETE FROM "crm_receivable"; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql index 816264e66..cdea50a96 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql @@ -46,4 +46,30 @@ CREATE TABLE IF NOT EXISTS "crm_clue" ( "deleted" bit NOT NULL DEFAULT FALSE, "tenant_id" bigint NOT NULL, PRIMARY KEY ("id") -) COMMENT '线索表'; \ No newline at end of file +) COMMENT '线索表'; + +CREATE TABLE IF NOT EXISTS "crm_receivable" ( + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, + "no" varchar, + "plan_id" bigint, + "customer_id" bigint, + "contract_id" bigint, + "check_status" int, + "process_instance_id" bigint, + "return_time" varchar, + "return_type" varchar, + "price" varchar, + "owner_user_id" bigint, + "batch_id" bigint, + "sort" int, + "data_scope" int, + "data_scope_dept_ids" varchar, + "status" int NOT NULL, + "remark" varchar, + "creator" varchar DEFAULT '', + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updater" varchar DEFAULT '', + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + "deleted" bit NOT NULL DEFAULT FALSE, + PRIMARY KEY ("id") +) COMMENT '回款管理';