From f02b9464bdbbd9f13a54dd0d56583a23fce088b3 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 1 Dec 2023 19:37:44 +0800 Subject: [PATCH] =?UTF-8?q?crm:=20=E5=A2=9E=E5=8A=A0=E5=9F=BA=E4=BA=8E?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E6=9F=A5=E8=AF=A2=E5=9B=9E=E6=AC=BE=E5=88=86?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm_data.sql | 4 +- sql/mysql/ruoyi-vue-pro.sql | 12 +- .../module/crm/enums/ErrorCodeConstants.java | 4 +- .../admin/contract/CrmContractController.java | 6 +- .../receivable/CrmReceivableController.java | 96 ++++++++++--- .../admin/receivable/package-info.java | 4 - .../receivable/vo/CrmReceivableExcelVO.java | 62 --------- .../vo/CrmReceivableExportReqVO.java | 57 -------- .../receivable/vo/CrmReceivablePageReqVO.java | 58 -------- .../receivable/vo/CrmReceivableRespVO.java | 19 --- .../{ => receivable}/CrmReceivableBaseVO.java | 7 +- .../CrmReceivableCreateReqVO.java | 2 +- .../vo/receivable/CrmReceivablePageReqVO.java | 24 ++++ .../vo/receivable/CrmReceivableRespVO.java | 38 ++++++ .../CrmReceivableUpdateReqVO.java | 2 +- .../receivable/CrmReceivableConvert.java | 41 +++++- .../receivable/CrmReceivableDO.java | 29 +--- .../crm/dal/mysql/contract/package-info.java | 4 - .../CrmCustomerLimitConfigMapper.java | 2 +- .../crm/dal/mysql/customer/package-info.java | 4 - .../mysql/receivable/CrmReceivableMapper.java | 32 +---- .../dal/mysql/receivable/package-info.java | 4 - .../CrmCustomerLimitConfigServiceImpl.java | 2 +- .../receivable/CrmReceivableService.java | 46 ++++--- .../receivable/CrmReceivableServiceImpl.java | 54 ++++---- ...CrmCustomerLimitConfigServiceImplTest.java | 2 +- .../CrmCrmReceivableServiceImplTest.java | 128 +----------------- .../src/test/resources/sql/create_tables.sql | 2 +- 28 files changed, 261 insertions(+), 484 deletions(-) delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/package-info.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExcelVO.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExportReqVO.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePageReqVO.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableRespVO.java rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ => receivable}/CrmReceivableBaseVO.java (85%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ => receivable}/CrmReceivableCreateReqVO.java (95%) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivablePageReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableRespVO.java rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ => receivable}/CrmReceivableUpdateReqVO.java (97%) delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/package-info.java rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/{customerlimitconfig => customer}/CrmCustomerLimitConfigMapper.java (93%) delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/package-info.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/package-info.java diff --git a/sql/mysql/crm_data.sql b/sql/mysql/crm_data.sql index b5be1e6910..e73f3bfd39 100644 --- a/sql/mysql/crm_data.sql +++ b/sql/mysql/crm_data.sql @@ -1,7 +1,7 @@ -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 (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_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'); diff --git a/sql/mysql/ruoyi-vue-pro.sql b/sql/mysql/ruoyi-vue-pro.sql index a9cca3ba8c..025045872c 100644 --- a/sql/mysql/ruoyi-vue-pro.sql +++ b/sql/mysql/ruoyi-vue-pro.sql @@ -2405,12 +2405,12 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2419, '联系人更新', 'crm:contact:update', 3, 3, 2416, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:14:56', '', '2023-10-29 11:14:56', b'0'); INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2420, '联系人删除', 'crm:contact:delete', 3, 4, 2416, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:14:56', '', '2023-10-29 11:14:56', b'0'); INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2421, '联系人导出', 'crm:contact:export', 3, 5, 2416, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:14:56', '', '2023-10-29 11:14:56', b'0'); -INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2422, '回款管理', '', 2, 0, 2397, 'receivable', 'ep:money', 'crm/receivable/index', 'CrmReceivable', 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '1', '2023-10-29 19:18:52', b'0'); -INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2423, '回款管理查询', 'crm:receivable:query', 3, 1, 2422, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); -INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2424, '回款管理创建', 'crm:receivable:create', 3, 2, 2422, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); -INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2425, '回款管理更新', 'crm:receivable:update', 3, 3, 2422, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); -INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2426, '回款管理删除', 'crm:receivable:delete', 3, 4, 2422, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); -INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2427, '回款管理导出', 'crm:receivable:export', 3, 5, 2422, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2422, '回款', '', 2, 0, 2397, 'receivable', 'ep:money', 'crm/receivable/index', 'CrmReceivable', 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '1', '2023-10-29 19:18:52', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2423, '回款查询', 'crm:receivable:query', 3, 1, 2422, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2424, '回款创建', 'crm:receivable:create', 3, 2, 2422, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2425, '回款更新', 'crm:receivable:update', 3, 3, 2422, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2426, '回款删除', 'crm:receivable:delete', 3, 4, 2422, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2427, '回款导出', 'crm:receivable:export', 3, 5, 2422, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2428, '回款计划管理', '', 2, 0, 2397, 'receivable-plan', 'fa:money', 'crm/receivablePlan/index', 'CrmReceivablePlan', 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '1', '2023-10-29 19:19:08', b'0'); INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2429, '回款计划查询', 'crm:receivable-plan:query', 3, 1, 2428, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2430, '回款计划创建', 'crm:receivable-plan:create', 3, 2, 2428, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-29 11:18:09', '', '2023-10-29 11:18:09', b'0'); 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 60f08a1eb3..ea5b7aaa01 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 @@ -24,8 +24,8 @@ public interface ErrorCodeConstants { // ========== 联系人管理 1-020-003-000 ========== ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); - // ========== 回款管理 1-020-004-000 ========== - ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款管理不存在"); + // ========== 回款 1-020-004-000 ========== + ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在"); // ========== 合同管理 1-020-005-000 ========== ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_020_005_000, "回款计划不存在"); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java index 70b124196d..395db98797 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contract/CrmContractController.java @@ -112,10 +112,10 @@ public class CrmContractController { } /** - * 转换成详细的联系人分页,即读取关联信息 + * 转换成详细的合同分页,即读取关联信息 * - * @param pageResult 联系人分页 - * @return 详细的联系人分页 + * @param pageResult 合同分页 + * @return 详细的合同分页 */ private PageResult convertDetailContractPage(PageResult pageResult) { List contactList = pageResult.getList(); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java index 4900719008..5ad1df7d19 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java @@ -1,13 +1,25 @@ package cn.iocoder.yudao.module.crm.controller.admin.receivable; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Assert; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.number.NumberUtils; 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.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivableConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; +import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; import cn.iocoder.yudao.module.crm.service.receivable.CrmReceivableService; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -20,71 +32,113 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; import java.util.List; +import java.util.Map; +import java.util.stream.Stream; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -@Tag(name = "管理后台 - CRM 回款管理") +@Tag(name = "管理后台 - CRM 回款") @RestController @RequestMapping("/crm/receivable") @Validated public class CrmReceivableController { - // TODO @liuhongfeng:crmReceivableService 可以使用 receivableService ;在自己模块里,相对简洁一点; @Resource - private CrmReceivableService crmReceivableService; + private CrmReceivableService receivableService; + @Resource + private CrmContractService contractService; + @Resource + private CrmCustomerService customerService; + + @Resource + private AdminUserApi adminUserApi; @PostMapping("/create") - @Operation(summary = "创建回款管理") + @Operation(summary = "创建回款") @PreAuthorize("@ss.hasPermission('crm:receivable:create')") public CommonResult createReceivable(@Valid @RequestBody CrmReceivableCreateReqVO createReqVO) { - return success(crmReceivableService.createReceivable(createReqVO)); + return success(receivableService.createReceivable(createReqVO)); } @PutMapping("/update") - @Operation(summary = "更新回款管理") + @Operation(summary = "更新回款") @PreAuthorize("@ss.hasPermission('crm:receivable:update')") public CommonResult updateReceivable(@Valid @RequestBody CrmReceivableUpdateReqVO updateReqVO) { - crmReceivableService.updateReceivable(updateReqVO); + receivableService.updateReceivable(updateReqVO); return success(true); } @DeleteMapping("/delete") - @Operation(summary = "删除回款管理") + @Operation(summary = "删除回款") @Parameter(name = "id", description = "编号", required = true) @PreAuthorize("@ss.hasPermission('crm:receivable:delete')") public CommonResult deleteReceivable(@RequestParam("id") Long id) { - crmReceivableService.deleteReceivable(id); + receivableService.deleteReceivable(id); return success(true); } @GetMapping("/get") - @Operation(summary = "获得回款管理") + @Operation(summary = "获得回款") @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('crm:receivable:query')") public CommonResult getReceivable(@RequestParam("id") Long id) { - CrmReceivableDO receivable = crmReceivableService.getReceivable(id); + CrmReceivableDO receivable = receivableService.getReceivable(id); return success(CrmReceivableConvert.INSTANCE.convert(receivable)); } @GetMapping("/page") - @Operation(summary = "获得回款管理分页") + @Operation(summary = "获得回款分页") @PreAuthorize("@ss.hasPermission('crm:receivable:query')") - public CommonResult> getReceivablePage(@Valid CrmReceivablePageReqVO pageVO) { - PageResult pageResult = crmReceivableService.getReceivablePage(pageVO); - return success(CrmReceivableConvert.INSTANCE.convertPage(pageResult)); + public CommonResult> getReceivablePage(@Valid CrmReceivablePageReqVO pageReqVO) { + PageResult pageResult = receivableService.getReceivablePage(pageReqVO); + return success(convertDetailReceivablePage(pageResult)); } + @GetMapping("/page-by-customer") + @Operation(summary = "获得回款分页,基于指定客户") + public CommonResult> getContractPageByCustomer(@Valid CrmReceivablePageReqVO pageReqVO) { + Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); + PageResult pageResult = receivableService.getReceivablePageByCustomer(pageReqVO); + return success(convertDetailReceivablePage(pageResult)); + } + + // TODO 芋艿:后面在优化导出 @GetMapping("/export-excel") - @Operation(summary = "导出回款管理 Excel") + @Operation(summary = "导出回款 Excel") @PreAuthorize("@ss.hasPermission('crm:receivable:export')") @OperateLog(type = EXPORT) - public void exportReceivableExcel(@Valid CrmReceivableExportReqVO exportReqVO, + public void exportReceivableExcel(@Valid CrmReceivablePageReqVO exportReqVO, HttpServletResponse response) throws IOException { - List list = crmReceivableService.getReceivableList(exportReqVO); + PageResult pageResult = receivableService.getReceivablePage(exportReqVO); // 导出 Excel - List datas = CrmReceivableConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "回款管理.xls", "数据", CrmReceivableExcelVO.class, datas); + ExcelUtils.write(response, "回款.xls", "数据", CrmReceivableRespVO.class, + convertDetailReceivablePage(pageResult).getList()); + } + + /** + * 转换成详细的回款分页,即读取关联信息 + * + * @param pageResult 回款分页 + * @return 详细的回款分页 + */ + private PageResult convertDetailReceivablePage(PageResult pageResult) { + List contactList = pageResult.getList(); + if (CollUtil.isEmpty(contactList)) { + return PageResult.empty(pageResult.getTotal()); + } + // 1. 获取客户列表 + List customerList = customerService.getCustomerList( + convertSet(contactList, CrmReceivableDO::getCustomerId)); + // 2. 获取创建人、负责人列表 + Map userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, + contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); + // 3. 获得合同列表 + List contractList = contractService.getContractList( + convertSet(contactList, CrmReceivableDO::getContractId)); + return CrmReceivableConvert.INSTANCE.convertPage(pageResult, userMap, customerList, contractList); } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/package-info.java deleted file mode 100644 index 1993982876..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 回款 - */ -package cn.iocoder.yudao.module.crm.controller.admin.receivable; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExcelVO.java deleted file mode 100644 index 3d81378a89..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExcelVO.java +++ /dev/null @@ -1,62 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; - -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; -import cn.iocoder.yudao.module.system.enums.DictTypeConstants; -import com.alibaba.excel.annotation.ExcelProperty; -import lombok.Data; - -import java.time.LocalDateTime; - -// TODO liuhongfeng:导出可以等其它功能做完,统一在搞; -@Data -public class CrmReceivableExcelVO { - - @ExcelProperty("ID") - private Long id; - - @ExcelProperty("回款编号") - private String no; - - @ExcelProperty("回款计划ID") - private Long planId; - - @ExcelProperty("客户名称") - private Long customerId; - - @ExcelProperty("合同名称") - private Long contractId; - - @ExcelProperty(value = "审批状态", converter = DictConvert.class) - @DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_AUDIT_STATUS) - private Integer checkStatus; - - @ExcelProperty("工作流编号") - private Long processInstanceId; - - @ExcelProperty("回款日期") - private LocalDateTime returnTime; - - @ExcelProperty("回款方式") - private String returnType; - - @ExcelProperty("回款金额") - private Integer price; - - @ExcelProperty("负责人") - private Long ownerUserId; - - @ExcelProperty("批次") - private Long batchId; - - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.COMMON_STATUS) - 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/CrmReceivableExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExportReqVO.java deleted file mode 100644 index c8bdb16e70..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExportReqVO.java +++ /dev/null @@ -1,57 +0,0 @@ -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.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -// TODO liuhongfeng:导出可以等其它功能做完,统一在搞; -@Schema(description = "管理后台 - CRM 回款 Excel 导出 Request VO,参数和 CrmReceivablePageReqVO 是一致的") -@Data -public class CrmReceivableExportReqVO { - - @Schema(description = "回款编号") - private String no; - - @Schema(description = "回款计划", example = "31177") - private Long planId; - - @Schema(description = "客户名称", example = "4963") - private Long customerId; - - @Schema(description = "合同名称", example = "30305") - private Long contractId; - - @Schema(description = "审批状态", example = "1") - private Integer checkStatus; - - @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 Integer price; - - @Schema(description = "负责人", example = "22202") - private Long ownerUserId; - - @Schema(description = "批次", example = "2539") - private Long batchId; - - @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/CrmReceivablePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePageReqVO.java deleted file mode 100644 index 61bd6f9a5d..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePageReqVO.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; - -import cn.iocoder.yudao.framework.common.pojo.PageParam; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; -import org.springframework.format.annotation.DateTimeFormat; - -import java.time.LocalDateTime; - -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; - -@Schema(description = "管理后台 - CRM 回款分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmReceivablePageReqVO extends PageParam { - - // TODO @liuhongfeng:可以根据需求,去除掉一些不要的过滤条件;另外,planId、customerId、contractId、ownerUserId 注释不正确,应该都是对应的编号 - - @Schema(description = "回款编号") - private String no; - - @Schema(description = "回款计划ID", example = "31177") - private Long planId; - - @Schema(description = "客户名称", example = "4963") - private Long customerId; - - @Schema(description = "合同名称", example = "30305") - private Long contractId; - - @Schema(description = "审批状态", example = "1") - private Integer checkStatus; - - @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 Integer price; - - @Schema(description = "负责人", example = "22202") - private Long ownerUserId; - - - @Schema(description = "状态", example = "1") - private Integer status; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableRespVO.java deleted file mode 100644 index 00d984da54..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableRespVO.java +++ /dev/null @@ -1,19 +0,0 @@ -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 = "管理后台 - CRM 回款 Response VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class CrmReceivableRespVO extends CrmReceivableBaseVO { - - @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/CrmReceivableBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableBaseVO.java similarity index 85% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableBaseVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableBaseVO.java index aeefd94cce..9ff4083138 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableBaseVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; import cn.iocoder.yudao.framework.common.validation.InEnum; import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; @@ -11,7 +11,7 @@ import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; /** - * 回款管理 Base VO,提供给添加、修改、详细的子 VO 使用 + * 回款 Base VO,提供给添加、修改、详细的子 VO 使用 * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 */ @Data @@ -60,8 +60,5 @@ public class CrmReceivableBaseVO { @Schema(description = "备注", example = "备注") private String remark; - // TODO @liuhongfeng:这个字段,这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; - @Schema(description = "完成状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer status; } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableCreateReqVO.java similarity index 95% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableCreateReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableCreateReqVO.java index a2d43d8c17..4471b780a8 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableCreateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; import lombok.*; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivablePageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivablePageReqVO.java new file mode 100644 index 0000000000..9d0d4eb212 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivablePageReqVO.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - CRM 回款分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmReceivablePageReqVO extends PageParam { + + @Schema(description = "回款编号") + private String no; + + @Schema(description = "回款计划编号", example = "31177") + private Long planId; + + @Schema(description = "客户编号", example = "4963") + private Long customerId; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableRespVO.java new file mode 100644 index 0000000000..7c536bd512 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableRespVO.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +// TODO 芋艿:导出的 VO,可以考虑使用 @Excel 注解,实现导出功能 +@Schema(description = "管理后台 - CRM 回款 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CrmReceivableRespVO extends CrmReceivableBaseVO { + + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25787") + private Long id; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + private LocalDateTime createTime; + + @Schema(description = "客户名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "test") + private String customerName; + + @Schema(description = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") + private Integer auditStatus; + + @Schema(description = "合同编号", example = "Q110") + private String contractNo; + + @Schema(description = "负责人", example = "test") + private String ownerUserName; + + @Schema(description = "创建人", example = "25682") + private String creator; + + @Schema(description = "创建人名字", example = "test") + private String creatorName; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableUpdateReqVO.java similarity index 97% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableUpdateReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableUpdateReqVO.java index d6241f258e..a3156eb993 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/CrmReceivableUpdateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivableConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivableConvert.java index 23345fbe61..27502103d2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivableConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivableConvert.java @@ -1,16 +1,24 @@ package cn.iocoder.yudao.module.crm.convert.receivable; -import java.util.*; - import cn.iocoder.yudao.framework.common.pojo.PageResult; - +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; + +import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; /** - * 回款管理 Convert + * 回款 Convert * * @author 赤焰 */ @@ -27,8 +35,27 @@ public interface CrmReceivableConvert { List convertList(List list); - PageResult convertPage(PageResult page); + default PageResult convertPage(PageResult pageResult, Map userMap, + List customerList, List contractList) { + return new PageResult<>(converList(pageResult.getList(), userMap, customerList, contractList), pageResult.getTotal()); + } - List convertList02(List list); + default List converList(List receivableList, Map userMap, + List customerList, List contractList) { + List result = convertList(receivableList); + Map customerMap = convertMap(customerList, CrmCustomerDO::getId); + Map contractMap = convertMap(contractList, CrmContractDO::getId); + result.forEach(item -> { + setUserInfo(item, userMap); + findAndThen(customerMap, item.getCustomerId(), customer -> item.setCustomerName(customer.getName())); + findAndThen(contractMap, item.getContractId(), contract -> item.setContractNo(contract.getNo())); + }); + return result; + } + + static void setUserInfo(CrmReceivableRespVO receivable, Map userMap) { + findAndThen(userMap, receivable.getOwnerUserId(), user -> receivable.setOwnerUserName(user.getNickname())); + findAndThen(userMap, Long.parseLong(receivable.getCreator()), user -> receivable.setCreatorName(user.getNickname())); + } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java index 16cbebe56d..8a19bdf53e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java @@ -10,7 +10,7 @@ import lombok.*; import java.time.LocalDateTime; /** - * 回款管理 DO + * 回款 DO * * @author 赤焰 */ @@ -54,12 +54,6 @@ public class CrmReceivableDO extends BaseDO { * 对应实体 {@link CrmContractDO} */ private Long contractId; - // TODO @liuhongfeng:“对应字典”,参考别的模块,枚举 {@link XXXX};另外,这个字段就叫 status,整体状态,不只审批 - /** - * 审批状态 - * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_AUDIT_STATUS} - */ - private Integer checkStatus; /** * 工作流编号 * @@ -84,31 +78,16 @@ public class CrmReceivableDO extends BaseDO { * 负责人 */ private Long ownerUserId; - // TODO @liuhongfeng:应该不需要 batchId 字段 - /** - * 批次 - */ - private Long batchId; /** * 显示顺序 */ private Integer sort; - // TODO 芋艿:dataScope、dataScopeDeptIds 在想下; /** - * 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限) - */ - private Integer dataScope; - /** - * 数据范围(指定部门数组) - */ - private String dataScopeDeptIds; - /** - * 状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} + * 审核状态 * + * 枚举 {@link cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum} */ - private Integer status; + private Integer auditStatus; /** * 备注 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/package-info.java deleted file mode 100644 index fb8045878d..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/contract/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 合同 - */ -package cn.iocoder.yudao.module.crm.dal.mysql.contract; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customerlimitconfig/CrmCustomerLimitConfigMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerLimitConfigMapper.java similarity index 93% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customerlimitconfig/CrmCustomerLimitConfigMapper.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerLimitConfigMapper.java index 143d000863..f5fb31b61c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customerlimitconfig/CrmCustomerLimitConfigMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/CrmCustomerLimitConfigMapper.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig; +package cn.iocoder.yudao.module.crm.dal.mysql.customer; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/package-info.java deleted file mode 100644 index 4173c01809..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/customer/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 客户 - */ -package cn.iocoder.yudao.module.crm.dal.mysql.customer; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java index 716704fb89..9da1300228 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivableMapper.java @@ -1,16 +1,14 @@ 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.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; /** - * 回款管理 Mapper + * 回款 Mapper * * @author 赤焰 */ @@ -22,32 +20,14 @@ public interface CrmReceivableMapper extends BaseMapperX { .eqIfPresent(CrmReceivableDO::getNo, reqVO.getNo()) .eqIfPresent(CrmReceivableDO::getPlanId, reqVO.getPlanId()) .eqIfPresent(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) - .eqIfPresent(CrmReceivableDO::getContractId, reqVO.getContractId()) - .eqIfPresent(CrmReceivableDO::getCheckStatus, reqVO.getCheckStatus()) - .betweenIfPresent(CrmReceivableDO::getReturnTime, reqVO.getReturnTime()) - .eqIfPresent(CrmReceivableDO::getReturnType, reqVO.getReturnType()) - .eqIfPresent(CrmReceivableDO::getPrice, reqVO.getPrice()) - .eqIfPresent(CrmReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) - .eqIfPresent(CrmReceivableDO::getStatus, reqVO.getStatus()) - .betweenIfPresent(CrmReceivableDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(CrmReceivableDO::getId)); } - default List selectList(CrmReceivableExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() + default PageResult selectPageByCustomer(CrmReceivablePageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eq(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) // 必须传递 .eqIfPresent(CrmReceivableDO::getNo, reqVO.getNo()) .eqIfPresent(CrmReceivableDO::getPlanId, reqVO.getPlanId()) - .eqIfPresent(CrmReceivableDO::getCustomerId, reqVO.getCustomerId()) - .eqIfPresent(CrmReceivableDO::getContractId, reqVO.getContractId()) - .eqIfPresent(CrmReceivableDO::getCheckStatus, reqVO.getCheckStatus()) - .betweenIfPresent(CrmReceivableDO::getReturnTime, reqVO.getReturnTime()) - .eqIfPresent(CrmReceivableDO::getReturnType, reqVO.getReturnType()) - .eqIfPresent(CrmReceivableDO::getPrice, reqVO.getPrice()) - .eqIfPresent(CrmReceivableDO::getOwnerUserId, reqVO.getOwnerUserId()) - .eqIfPresent(CrmReceivableDO::getBatchId, reqVO.getBatchId()) - .eqIfPresent(CrmReceivableDO::getStatus, reqVO.getStatus()) - .eqIfPresent(CrmReceivableDO::getRemark, reqVO.getRemark()) - .betweenIfPresent(CrmReceivableDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(CrmReceivableDO::getId)); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/package-info.java deleted file mode 100644 index 65b30aa922..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 回款 - */ -package cn.iocoder.yudao.module.crm.dal.mysql.receivable; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java index 0e3eed3094..f0a9496088 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java @@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmC import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO; import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert; import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig.CrmCustomerLimitConfigMapper; +import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper; import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import org.springframework.stereotype.Service; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java index 8875faaa92..08c5898815 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableService.java @@ -1,21 +1,25 @@ 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.CrmReceivableDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; /** - * 回款管理 Service 接口 + * CRM 回款 Service 接口 * * @author 赤焰 */ public interface CrmReceivableService { /** - * 创建回款管理 + * 创建回款 * * @param createReqVO 创建信息 * @return 编号 @@ -23,49 +27,53 @@ public interface CrmReceivableService { Long createReceivable(@Valid CrmReceivableCreateReqVO createReqVO); /** - * 更新回款管理 + * 更新回款 * * @param updateReqVO 更新信息 */ void updateReceivable(@Valid CrmReceivableUpdateReqVO updateReqVO); /** - * 删除回款管理 + * 删除回款 * * @param id 编号 */ void deleteReceivable(Long id); /** - * 获得回款管理 + * 获得回款 * * @param id 编号 - * @return 回款管理 + * @return 回款 */ CrmReceivableDO getReceivable(Long id); /** - * 获得回款管理列表 + * 获得回款列表 * * @param ids 编号 - * @return 回款管理列表 + * @return 回款列表 */ List getReceivableList(Collection ids); /** - * 获得回款管理分页 + * 获得回款分页 + * + * 数据权限:基于 {@link CrmReceivableDO} 读取 * * @param pageReqVO 分页查询 - * @return 回款管理分页 + * @return 回款分页 */ PageResult getReceivablePage(CrmReceivablePageReqVO pageReqVO); /** - * 获得回款管理列表, 用于 Excel 导出 + * 获得回款分页,基于指定客户 * - * @param exportReqVO 查询条件 - * @return 回款管理列表 + * 数据权限:基于 {@link CrmCustomerDO} 读取 + * + * @param pageReqVO 分页查询 + * @return 回款分页 */ - List getReceivableList(CrmReceivableExportReqVO exportReqVO); + PageResult getReceivablePageByCustomer(CrmReceivablePageReqVO pageReqVO); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java index b1b9d3ede6..c6994a4733 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java @@ -5,10 +5,9 @@ import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableUpdateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivableConvert; import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; @@ -16,6 +15,9 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivableMapper; import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; +import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; +import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; +import cn.iocoder.yudao.module.crm.framework.core.annotations.CrmPermission; import cn.iocoder.yudao.module.crm.service.contract.CrmContractService; import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; import org.springframework.stereotype.Service; @@ -29,7 +31,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; /** - * 回款管理 Service 实现类 + * CRM 回款 Service 实现类 * * @author 赤焰 */ @@ -37,34 +39,31 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; @Validated public class CrmReceivableServiceImpl implements CrmReceivableService { - // TODO @liuhongfeng:crm 前缀,变量可以不带哈; @Resource - private CrmReceivableMapper crmReceivableMapper; + private CrmReceivableMapper receivableMapper; + @Resource private CrmContractService contractService; @Resource - private CrmCustomerService crmCustomerService; + private CrmCustomerService customerService; @Resource - private CrmReceivablePlanService crmReceivablePlanService; + private CrmReceivablePlanService receivablePlanService; // TODO @liuhongfeng:创建还款后,是不是什么时候,要更新 plan? @Override public Long createReceivable(CrmReceivableCreateReqVO createReqVO) { // 插入 CrmReceivableDO receivable = CrmReceivableConvert.INSTANCE.convert(createReqVO); - // TODO @liuhongfeng:这里的括号要注意排版; - if (ObjectUtil.isNull(receivable.getStatus())){ - receivable.setStatus(CommonStatusEnum.ENABLE.getStatus()); - } - if (ObjectUtil.isNull(receivable.getCheckStatus())){ - receivable.setCheckStatus(CrmAuditStatusEnum.DRAFT.getStatus()); + if (ObjectUtil.isNull(receivable.getAuditStatus())) { + receivable.setAuditStatus(CommonStatusEnum.ENABLE.getStatus()); } + receivable.setAuditStatus(CrmAuditStatusEnum.DRAFT.getStatus()); // TODO @liuhongfeng:一般来说,逻辑的写法,是要先检查,后操作 db;所以,你这个 check 应该放到 CrmReceivableDO receivable 之前; // 校验 checkReceivable(receivable); - crmReceivableMapper.insert(receivable); + receivableMapper.insert(receivable); return receivable.getId(); } @@ -80,12 +79,12 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { throw exception(CONTRACT_NOT_EXISTS); } - CrmCustomerDO customer = crmCustomerService.getCustomer(receivable.getCustomerId()); + CrmCustomerDO customer = customerService.getCustomer(receivable.getCustomerId()); if(ObjectUtil.isNull(customer)){ throw exception(CUSTOMER_NOT_EXISTS); } - CrmReceivablePlanDO receivablePlan = crmReceivablePlanService.getReceivablePlan(receivable.getPlanId()); + CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(receivable.getPlanId()); if(ObjectUtil.isNull(receivablePlan)){ throw exception(RECEIVABLE_PLAN_NOT_EXISTS); } @@ -99,7 +98,7 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { // 更新 CrmReceivableDO updateObj = CrmReceivableConvert.INSTANCE.convert(updateReqVO); - crmReceivableMapper.updateById(updateObj); + receivableMapper.updateById(updateObj); } @Override @@ -107,18 +106,19 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { // 校验存在 validateReceivableExists(id); // 删除 - crmReceivableMapper.deleteById(id); + receivableMapper.deleteById(id); } private void validateReceivableExists(Long id) { - if (crmReceivableMapper.selectById(id) == null) { + if (receivableMapper.selectById(id) == null) { throw exception(RECEIVABLE_NOT_EXISTS); } } + // TODO @芋艿:数据权限 @Override public CrmReceivableDO getReceivable(Long id) { - return crmReceivableMapper.selectById(id); + return receivableMapper.selectById(id); } @Override @@ -126,17 +126,19 @@ public class CrmReceivableServiceImpl implements CrmReceivableService { if (CollUtil.isEmpty(ids)) { return ListUtil.empty(); } - return crmReceivableMapper.selectBatchIds(ids); + return receivableMapper.selectBatchIds(ids); } + // TODO @芋艿:数据权限 @Override public PageResult getReceivablePage(CrmReceivablePageReqVO pageReqVO) { - return crmReceivableMapper.selectPage(pageReqVO); + return receivableMapper.selectPage(pageReqVO); } @Override - public List getReceivableList(CrmReceivableExportReqVO exportReqVO) { - return crmReceivableMapper.selectList(exportReqVO); + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) + public PageResult getReceivablePageByCustomer(CrmReceivablePageReqVO pageReqVO) { + return receivableMapper.selectPageByCustomer(pageReqVO); } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigServiceImplTest.java index 0b61af6c50..f293b35dbb 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigServiceImplTest.java @@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmC import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; -import cn.iocoder.yudao.module.crm.dal.mysql.customerlimitconfig.CrmCustomerLimitConfigMapper; +import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper; import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigServiceImpl; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivableServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivableServiceImplTest.java index 6d65231b1d..b3db63c078 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivableServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivableServiceImplTest.java @@ -2,10 +2,9 @@ package cn.iocoder.yudao.module.crm.service.receivable; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivableUpdateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivablePageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.receivable.CrmReceivableUpdateReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivableDO; import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivableMapper; import org.junit.jupiter.api.Disabled; @@ -13,9 +12,7 @@ import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Import; import javax.annotation.Resource; -import java.util.List; -import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; @@ -121,7 +118,7 @@ public class CrmCrmReceivableServiceImplTest extends BaseDbUnitTest { o.setSort(null); o.setDataScope(null); o.setDataScopeDeptIds(null); - o.setStatus(null); + o.setAuditStatus(null); o.setRemark(null); o.setCreateTime(null); }); @@ -132,47 +129,11 @@ public class CrmCrmReceivableServiceImplTest extends BaseDbUnitTest { crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPlanId(null))); // 测试 customerId 不匹配 crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCustomerId(null))); - // 测试 contractId 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setContractId(null))); - // 测试 checkStatus 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCheckStatus(null))); - // 测试 processInstanceId 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setProcessInstanceId(null))); - // 测试 returnTime 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnTime(null))); - // 测试 returnType 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnType(null))); - // 测试 price 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPrice(null))); - // 测试 ownerUserId 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setOwnerUserId(null))); - // 测试 batchId 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setBatchId(null))); - // 测试 sort 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setSort(null))); - // 测试 dataScope 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScope(null))); - // 测试 dataScopeDeptIds 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScopeDeptIds(null))); - // 测试 status 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setStatus(null))); - // 测试 remark 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setRemark(null))); - // 测试 createTime 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCreateTime(null))); // 准备参数 CrmReceivablePageReqVO reqVO = new CrmReceivablePageReqVO(); reqVO.setNo(null); reqVO.setPlanId(null); reqVO.setCustomerId(null); - reqVO.setContractId(null); - reqVO.setCheckStatus(null); - reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setReturnType(null); - reqVO.setPrice(null); - reqVO.setOwnerUserId(null); - reqVO.setStatus(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); // 调用 PageResult pageResult = receivableService.getReceivablePage(reqVO); @@ -182,85 +143,4 @@ public class CrmCrmReceivableServiceImplTest extends BaseDbUnitTest { assertPojoEquals(dbReceivable, pageResult.getList().get(0)); } - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetReceivableList() { - // mock 数据 - CrmReceivableDO dbReceivable = randomPojo(CrmReceivableDO.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); - }); - crmReceivableMapper.insert(dbReceivable); - // 测试 no 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setNo(null))); - // 测试 planId 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPlanId(null))); - // 测试 customerId 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCustomerId(null))); - // 测试 contractId 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setContractId(null))); - // 测试 checkStatus 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCheckStatus(null))); - // 测试 processInstanceId 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setProcessInstanceId(null))); - // 测试 returnTime 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnTime(null))); - // 测试 returnType 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setReturnType(null))); - // 测试 price 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setPrice(null))); - // 测试 ownerUserId 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setOwnerUserId(null))); - // 测试 batchId 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setBatchId(null))); - // 测试 sort 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setSort(null))); - // 测试 dataScope 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScope(null))); - // 测试 dataScopeDeptIds 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setDataScopeDeptIds(null))); - // 测试 status 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setStatus(null))); - // 测试 remark 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setRemark(null))); - // 测试 createTime 不匹配 - crmReceivableMapper.insert(cloneIgnoreId(dbReceivable, o -> o.setCreateTime(null))); - // 准备参数 - CrmReceivableExportReqVO reqVO = new CrmReceivableExportReqVO(); - reqVO.setNo(null); - reqVO.setPlanId(null); - reqVO.setCustomerId(null); - reqVO.setContractId(null); - reqVO.setCheckStatus(null); - reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setReturnType(null); - reqVO.setPrice(null); - reqVO.setOwnerUserId(null); - reqVO.setBatchId(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/create_tables.sql b/yudao-module-crm/yudao-module-crm-biz/src/test/resources/sql/create_tables.sql index 9ba943234f..9528f3dde3 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 @@ -72,7 +72,7 @@ CREATE TABLE IF NOT EXISTS "crm_receivable" ( "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, "deleted" bit NOT NULL DEFAULT FALSE, PRIMARY KEY ("id") -) COMMENT '回款管理'; +) COMMENT '回款'; CREATE TABLE IF NOT EXISTS "crm_receivable_plan" ( "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,