From 72969e921ecc2e0317592b8cf6e5f3c0cd16f56f Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 1 Dec 2023 22:46:13 +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=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql/crm.sql | 3 - sql/mysql/crm_data.sql | 20 ---- .../controller/admin/clue/package-info.java | 4 - .../admin/product/package-info.java | 4 - .../receivable/CrmReceivableController.java | 12 +-- .../CrmReceivablePlanController.java | 88 ++++++++++++++--- .../vo/CrmReceivablePlanExcelVO.java | 70 -------------- .../vo/CrmReceivablePlanExportReqVO.java | 52 ---------- .../vo/CrmReceivablePlanPageReqVO.java | 49 ---------- .../vo/CrmReceivablePlanRespVO.java | 19 ---- .../{ => plan}/CrmReceivablePlanBaseVO.java | 20 +--- .../CrmReceivablePlanCreateReqVO.java | 2 +- .../vo/plan/CrmReceivablePlanPageReqVO.java | 22 +++++ .../vo/plan/CrmReceivablePlanRespVO.java | 40 ++++++++ .../CrmReceivablePlanUpdateReqVO.java | 2 +- .../vo/receivable/CrmReceivableBaseVO.java | 5 +- .../receivable/CrmReceivablePlanConvert.java | 44 +++++++-- .../receivable/CrmReceivableDO.java | 2 +- .../receivable/CrmReceivablePlanDO.java | 20 +--- .../receivable/CrmReceivablePlanMapper.java | 27 +----- .../receivable/CrmReceivablePlanService.java | 27 ++++-- .../CrmReceivablePlanServiceImpl.java | 46 +++++---- .../business/CrmBusinessServiceImplTest.java | 86 +---------------- .../contract/ContractServiceImplTest.java | 59 ------------ .../CrmCrmReceivablePlanServiceImplTest.java | 96 +------------------ 25 files changed, 241 insertions(+), 578 deletions(-) delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/package-info.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/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/CrmReceivablePlanExcelVO.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExportReqVO.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanPageReqVO.java delete mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanRespVO.java rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ => plan}/CrmReceivablePlanBaseVO.java (68%) rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ => plan}/CrmReceivablePlanCreateReqVO.java (97%) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanPageReqVO.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanRespVO.java rename yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/{ => plan}/CrmReceivablePlanUpdateReqVO.java (98%) diff --git a/sql/mysql/crm.sql b/sql/mysql/crm.sql index 135826585d..e69de29bb2 100644 --- a/sql/mysql/crm.sql +++ b/sql/mysql/crm.sql @@ -1,3 +0,0 @@ -SET NAMES utf8mb4; --- `ruoyi-vue-pro`.crm_contact definition - diff --git a/sql/mysql/crm_data.sql b/sql/mysql/crm_data.sql index e73f3bfd39..e69de29bb2 100644 --- a/sql/mysql/crm_data.sql +++ b/sql/mysql/crm_data.sql @@ -1,20 +0,0 @@ - -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/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/package-info.java deleted file mode 100644 index 0dc1108449..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/clue/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 线索 - */ -package cn.iocoder.yudao.module.crm.controller.admin.clue; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/package-info.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/package-info.java deleted file mode 100644 index 6500da0b86..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 产品表 - */ -package cn.iocoder.yudao.module.crm.controller.admin.product; 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 5ad1df7d19..531782654d 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 @@ -99,7 +99,7 @@ public class CrmReceivableController { @GetMapping("/page-by-customer") @Operation(summary = "获得回款分页,基于指定客户") - public CommonResult> getContractPageByCustomer(@Valid CrmReceivablePageReqVO pageReqVO) { + public CommonResult> getReceivablePageByCustomer(@Valid CrmReceivablePageReqVO pageReqVO) { Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); PageResult pageResult = receivableService.getReceivablePageByCustomer(pageReqVO); return success(convertDetailReceivablePage(pageResult)); @@ -125,19 +125,19 @@ public class CrmReceivableController { * @return 详细的回款分页 */ private PageResult convertDetailReceivablePage(PageResult pageResult) { - List contactList = pageResult.getList(); - if (CollUtil.isEmpty(contactList)) { + List receivableList = pageResult.getList(); + if (CollUtil.isEmpty(receivableList)) { return PageResult.empty(pageResult.getTotal()); } // 1. 获取客户列表 List customerList = customerService.getCustomerList( - convertSet(contactList, CrmReceivableDO::getCustomerId)); + convertSet(receivableList, CrmReceivableDO::getCustomerId)); // 2. 获取创建人、负责人列表 - Map userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList, + Map userMap = adminUserApi.getUserMap(convertListByFlatMap(receivableList, contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); // 3. 获得合同列表 List contractList = contractService.getContractList( - convertSet(contactList, CrmReceivableDO::getContractId)); + convertSet(receivableList, 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/CrmReceivablePlanController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java index afba2b721d..71ad2b9851 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivablePlanController.java @@ -1,13 +1,27 @@ 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.plan.CrmReceivablePlanCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO; import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivablePlanConvert; +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.dal.dataobject.receivable.CrmReceivablePlanDO; +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.CrmReceivablePlanService; +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,8 +34,12 @@ 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 回款计划") @@ -31,20 +49,29 @@ import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.E public class CrmReceivablePlanController { @Resource - private CrmReceivablePlanService crmReceivablePlanService; + private CrmReceivablePlanService receivablePlanService; + @Resource + private CrmReceivableService receivableService; + @Resource + private CrmContractService contractService; + @Resource + private CrmCustomerService customerService; + + @Resource + private AdminUserApi adminUserApi; @PostMapping("/create") @Operation(summary = "创建回款计划") @PreAuthorize("@ss.hasPermission('crm:receivable-plan:create')") public CommonResult createReceivablePlan(@Valid @RequestBody CrmReceivablePlanCreateReqVO createReqVO) { - return success(crmReceivablePlanService.createReceivablePlan(createReqVO)); + return success(receivablePlanService.createReceivablePlan(createReqVO)); } @PutMapping("/update") @Operation(summary = "更新回款计划") @PreAuthorize("@ss.hasPermission('crm:receivable-plan:update')") public CommonResult updateReceivablePlan(@Valid @RequestBody CrmReceivablePlanUpdateReqVO updateReqVO) { - crmReceivablePlanService.updateReceivablePlan(updateReqVO); + receivablePlanService.updateReceivablePlan(updateReqVO); return success(true); } @@ -53,7 +80,7 @@ public class CrmReceivablePlanController { @Parameter(name = "id", description = "编号", required = true) @PreAuthorize("@ss.hasPermission('crm:receivable-plan:delete')") public CommonResult deleteReceivablePlan(@RequestParam("id") Long id) { - crmReceivablePlanService.deleteReceivablePlan(id); + receivablePlanService.deleteReceivablePlan(id); return success(true); } @@ -62,28 +89,63 @@ public class CrmReceivablePlanController { @Parameter(name = "id", description = "编号", required = true, example = "1024") @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") public CommonResult getReceivablePlan(@RequestParam("id") Long id) { - CrmReceivablePlanDO receivablePlan = crmReceivablePlanService.getReceivablePlan(id); + CrmReceivablePlanDO receivablePlan = receivablePlanService.getReceivablePlan(id); return success(CrmReceivablePlanConvert.INSTANCE.convert(receivablePlan)); } @GetMapping("/page") @Operation(summary = "获得回款计划分页") @PreAuthorize("@ss.hasPermission('crm:receivable-plan:query')") - public CommonResult> getReceivablePlanPage(@Valid CrmReceivablePlanPageReqVO pageVO) { - PageResult pageResult = crmReceivablePlanService.getReceivablePlanPage(pageVO); - return success(CrmReceivablePlanConvert.INSTANCE.convertPage(pageResult)); + public CommonResult> getReceivablePlanPage(@Valid CrmReceivablePlanPageReqVO pageReqVO) { + PageResult pageResult = receivablePlanService.getReceivablePlanPage(pageReqVO); + return success(convertDetailReceivablePlanPage(pageResult)); } + @GetMapping("/page-by-customer") + @Operation(summary = "获得回款计划分页,基于指定客户") + public CommonResult> getReceivablePlanPageByCustomer(@Valid CrmReceivablePlanPageReqVO pageReqVO) { + Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空"); + PageResult pageResult = receivablePlanService.getReceivablePlanPageByCustomer(pageReqVO); + return success(convertDetailReceivablePlanPage(pageResult)); + } + + // TODO 芋艿:后面在优化导出 @GetMapping("/export-excel") @Operation(summary = "导出回款计划 Excel") @PreAuthorize("@ss.hasPermission('crm:receivable-plan:export')") @OperateLog(type = EXPORT) - public void exportReceivablePlanExcel(@Valid CrmReceivablePlanExportReqVO exportReqVO, + public void exportReceivablePlanExcel(@Valid CrmReceivablePlanPageReqVO exportReqVO, HttpServletResponse response) throws IOException { - List list = crmReceivablePlanService.getReceivablePlanList(exportReqVO); + PageResult pageResult = receivablePlanService.getReceivablePlanPage(exportReqVO); // 导出 Excel - List datas = CrmReceivablePlanConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "回款计划.xls", "数据", CrmReceivablePlanExcelVO.class, datas); + ExcelUtils.write(response, "回款计划.xls", "数据", CrmReceivablePlanRespVO.class, + convertDetailReceivablePlanPage(pageResult).getList()); + } + + /** + * 转换成详细的回款计划分页,即读取关联信息 + * + * @param pageResult 回款计划分页 + * @return 详细的回款计划分页 + */ + private PageResult convertDetailReceivablePlanPage(PageResult pageResult) { + List receivablePlanList = pageResult.getList(); + if (CollUtil.isEmpty(receivablePlanList)) { + return PageResult.empty(pageResult.getTotal()); + } + // 1. 获取客户列表 + List customerList = customerService.getCustomerList( + convertSet(receivablePlanList, CrmReceivablePlanDO::getCustomerId)); + // 2. 获取创建人、负责人列表 + Map userMap = adminUserApi.getUserMap(convertListByFlatMap(receivablePlanList, + contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId()))); + // 3. 获得合同列表 + List contractList = contractService.getContractList( + convertSet(receivablePlanList, CrmReceivablePlanDO::getContractId)); + // 4. 获得还款列表 + List receivableList = receivableService.getReceivableList( + convertSet(receivablePlanList, CrmReceivablePlanDO::getReceivableId)); + return CrmReceivablePlanConvert.INSTANCE.convertPage(pageResult, userMap, customerList, contractList, receivableList); } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExcelVO.java deleted file mode 100644 index 7c25bf18ef..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExcelVO.java +++ /dev/null @@ -1,70 +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:导出可以等其它功能做完,统一在搞; -/** - * CRM 回款计划 Excel VO - * - * @author 芋道源码 - */ -@Data -public class CrmReceivablePlanExcelVO { - - @ExcelProperty("ID") - private Long id; - - @ExcelProperty("期数") - private Integer period; - - @ExcelProperty("回款ID") - private Long receivableId; - - @ExcelProperty(value = "状态", converter = DictConvert.class) - @DictFormat(DictTypeConstants.COMMON_STATUS) - private Integer status; - - @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 Integer price; - - @ExcelProperty("计划回款日期") - private LocalDateTime returnTime; - - @ExcelProperty("提前几天提醒") - private Integer remindDays; - - @ExcelProperty("提醒日期") - private LocalDateTime remindTime; - - @ExcelProperty("客户ID") - private Long customerId; - - @ExcelProperty("合同名称") - private Long contractId; - - @ExcelProperty("负责人") - private Long ownerUserId; - - //@ExcelProperty("显示顺序") - //private Integer sort; - - @ExcelProperty("备注") - private String remark; - - @ExcelProperty("创建时间") - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExportReqVO.java deleted file mode 100644 index cbe86bd051..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExportReqVO.java +++ /dev/null @@ -1,52 +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,参数和 CrmReceivablePlanPageReqVO 是一致的") -@Data -public class CrmReceivablePlanExportReqVO { - - @Schema(description = "期数") - private Integer period; - - @Schema(description = "完成状态", example = "2") - private Integer status; - - @Schema(description = "审批状态", example = "1") - private Integer checkStatus; - - @Schema(description = "计划回款日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] returnTime; - - @Schema(description = "提前几天提醒") - private Integer remindDays; - - @Schema(description = "提醒日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] remindTime; - - @Schema(description = "客户名称", example = "18026") - private Long customerId; - - @Schema(description = "合同名称", example = "3473") - private Long contractId; - - @Schema(description = "负责人", example = "17828") - private Long ownerUserId; - - @Schema(description = "备注", example = "随便") - private String remark; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanPageReqVO.java deleted file mode 100644 index a510753dd0..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanPageReqVO.java +++ /dev/null @@ -1,49 +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 CrmReceivablePlanPageReqVO extends PageParam { - - // TODO @liuhongfeng:可以根据需求,去除掉一些不要的过滤条件;另外,customerId、contractId、ownerUserId 注释不正确,应该都是对应的编号 - - @Schema(description = "完成状态", example = "2") - private Integer status; - - @Schema(description = "审批状态", example = "1") - private Integer checkStatus; - - @Schema(description = "计划回款日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] returnTime; - - @Schema(description = "提醒日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) - private LocalDateTime[] remindTime; - - @Schema(description = "客户名称", example = "18026") - private Long customerId; - - @Schema(description = "合同名称", example = "3473") - private Long contractId; - - @Schema(description = "负责人", example = "17828") - private Long ownerUserId; - - @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/CrmReceivablePlanRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanRespVO.java deleted file mode 100644 index 243e7f7824..0000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanRespVO.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 CrmReceivablePlanRespVO extends CrmReceivablePlanBaseVO { - - @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25153") - private Long id; - - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) - private LocalDateTime createTime; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanBaseVO.java similarity index 68% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanBaseVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanBaseVO.java index 517ac98110..70272b8e8e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanBaseVO.java @@ -1,7 +1,5 @@ -package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; -import cn.iocoder.yudao.framework.common.validation.InEnum; -import cn.iocoder.yudao.module.crm.enums.common.CrmAuditStatusEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; @@ -20,17 +18,9 @@ public class CrmReceivablePlanBaseVO { @Schema(description = "期数", example = "1") private Integer period; - // TODO @liuhongfeng:回款计划编号 - @Schema(description = "回款计划", example = "19852") + @Schema(description = "回款计划编号", example = "19852") private Long receivableId; - @Schema(description = "完成状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - private Integer status; - - @Schema(description = "审批状态", example = "1") - @InEnum(CrmAuditStatusEnum.class) - private Integer checkStatus; - @Schema(description = "计划回款金额", example = "29675") private Integer price; @@ -45,16 +35,14 @@ public class CrmReceivablePlanBaseVO { @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime remindTime; - // TODO @liuhongfeng:客户编号 @Schema(description = "客户名称", example = "18026") private Long customerId; - // TODO @liuhongfeng:合同编号 - @Schema(description = "合同名称", example = "3473") + @Schema(description = "合同编号", example = "3473") private Long contractId; // TODO @liuhongfeng:负责人编号 - @Schema(description = "负责人", example = "17828") + @Schema(description = "负责人编号", example = "17828") private Long ownerUserId; @Schema(description = "显示顺序") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanCreateReqVO.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/CrmReceivablePlanCreateReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanCreateReqVO.java index cebfd28cb6..193a44bf4c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanCreateReqVO.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.plan; 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/plan/CrmReceivablePlanPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanPageReqVO.java new file mode 100644 index 0000000000..b9249c2f2b --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanPageReqVO.java @@ -0,0 +1,22 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; + +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 CrmReceivablePlanPageReqVO extends PageParam { + + @Schema(description = "客户编号", example = "18026") + private Long customerId; + + // TODO @芋艿:这个搜的应该是合同编号 no + @Schema(description = "合同名称", example = "3473") + private Long contractId; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanRespVO.java new file mode 100644 index 0000000000..d5e9de187a --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanRespVO.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan; + +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 CrmReceivablePlanRespVO extends CrmReceivablePlanBaseVO { + + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25153") + 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 = "合同编号", 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; + + @Schema(description = "完成状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + private Boolean finishStatus; + + @Schema(description = "回款方式", example = "1") // 来自 Receivable 的 returnType 字段 + private Integer returnType; + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanUpdateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanUpdateReqVO.java similarity index 98% rename from yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanUpdateReqVO.java rename to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanUpdateReqVO.java index 5471cfba38..c0072defcb 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanUpdateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/plan/CrmReceivablePlanUpdateReqVO.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.plan; 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/controller/admin/receivable/vo/receivable/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 index 9ff4083138..c32bc9ad52 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/receivable/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 @@ -42,7 +42,7 @@ public class CrmReceivableBaseVO { private LocalDateTime returnTime; @Schema(description = "回款方式", example = "2") - private String returnType; + private Integer returnType; @Schema(description = "回款金额,单位:分", example = "31859") private Integer price; @@ -51,9 +51,6 @@ public class CrmReceivableBaseVO { @Schema(description = "负责人", example = "22202") private Long ownerUserId; - @Schema(description = "批次", example = "2539") - private Long batchId; - @Schema(description = "显示顺序") private Integer sort; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivablePlanConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivablePlanConvert.java index 4b2d65c60f..a89140d07c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivablePlanConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/receivable/CrmReceivablePlanConvert.java @@ -1,13 +1,22 @@ 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.plan.CrmReceivablePlanCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanRespVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO; +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.dal.dataobject.receivable.CrmReceivablePlanDO; +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 @@ -27,8 +36,31 @@ public interface CrmReceivablePlanConvert { List convertList(List list); - PageResult convertPage(PageResult page); + default PageResult convertPage(PageResult pageResult, Map userMap, + List customerList, List contractList, + List receivableList) { + return new PageResult<>(converList(pageResult.getList(), userMap, customerList, contractList, receivableList), pageResult.getTotal()); + } - List convertList02(List list); + default List converList(List receivablePlanList, Map userMap, + List customerList, List contractList, + List receivableList) { + List result = convertList(receivablePlanList); + Map customerMap = convertMap(customerList, CrmCustomerDO::getId); + Map contractMap = convertMap(contractList, CrmContractDO::getId); + Map receivableMap = convertMap(receivableList, CrmReceivableDO::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())); + findAndThen(receivableMap, item.getReceivableId(), receivable -> item.setReturnType(receivable.getReturnType())); + }); + return result; + } + + static void setUserInfo(CrmReceivablePlanRespVO receivablePlan, Map userMap) { + findAndThen(userMap, receivablePlan.getOwnerUserId(), user -> receivablePlan.setOwnerUserName(user.getNickname())); + findAndThen(userMap, Long.parseLong(receivablePlan.getCreator()), user -> receivablePlan.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 8a19bdf53e..842fc96b4f 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 @@ -68,7 +68,7 @@ public class CrmReceivableDO extends BaseDO { /** * 回款方式 */ - private String returnType; + private Integer returnType; /** * 回款金额 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java index bec57cc9ed..78658e609a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java @@ -38,26 +38,10 @@ public class CrmReceivablePlanDO extends BaseDO { * TODO @liuhongfeng:少关联实体; */ private Long receivableId; - // TODO @liuhongfeng:还款计划,没有 status 和 checkStatus,改成 finishStatus Boolean;是否完成 /** - * 状态 - * - * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} + * 完成状态 */ - private Integer status; - /** - * 审批状态 - * - * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_AUDIT_STATUS} - * // TODO @liuhongfeng:关联的枚举 - */ - private Integer checkStatus; - /** - * 工作流编号 - * - * TODO @liuhongfeng:少关联实体; - */ - private Long processInstanceId; + private Boolean finishStatus; /** * 计划回款金额,单位:分 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java index 62b2c0c54c..52d16f0e1b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/mysql/receivable/CrmReceivablePlanMapper.java @@ -1,13 +1,11 @@ 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.plan.CrmReceivablePlanPageReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; import org.apache.ibatis.annotations.Mapper; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.*; /** * 回款计划 Mapper @@ -19,30 +17,15 @@ public interface CrmReceivablePlanMapper extends BaseMapperX selectPage(CrmReceivablePlanPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(CrmReceivablePlanDO::getStatus, reqVO.getStatus()) - .eqIfPresent(CrmReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus()) - .betweenIfPresent(CrmReceivablePlanDO::getReturnTime, reqVO.getReturnTime()) - .betweenIfPresent(CrmReceivablePlanDO::getRemindTime, reqVO.getRemindTime()) .eqIfPresent(CrmReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) .eqIfPresent(CrmReceivablePlanDO::getContractId, reqVO.getContractId()) - .eqIfPresent(CrmReceivablePlanDO::getOwnerUserId, reqVO.getOwnerUserId()) - .betweenIfPresent(CrmReceivablePlanDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(CrmReceivablePlanDO::getId)); } - default List selectList(CrmReceivablePlanExportReqVO reqVO) { - return selectList(new LambdaQueryWrapperX() - .eqIfPresent(CrmReceivablePlanDO::getPeriod, reqVO.getPeriod()) - .eqIfPresent(CrmReceivablePlanDO::getStatus, reqVO.getStatus()) - .eqIfPresent(CrmReceivablePlanDO::getCheckStatus, reqVO.getCheckStatus()) - .betweenIfPresent(CrmReceivablePlanDO::getReturnTime, reqVO.getReturnTime()) - .eqIfPresent(CrmReceivablePlanDO::getRemindDays, reqVO.getRemindDays()) - .betweenIfPresent(CrmReceivablePlanDO::getRemindTime, reqVO.getRemindTime()) - .eqIfPresent(CrmReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) + default PageResult selectPageByCustomer(CrmReceivablePlanPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eq(CrmReceivablePlanDO::getCustomerId, reqVO.getCustomerId()) // 必须传递 .eqIfPresent(CrmReceivablePlanDO::getContractId, reqVO.getContractId()) - .eqIfPresent(CrmReceivablePlanDO::getOwnerUserId, reqVO.getOwnerUserId()) - .eqIfPresent(CrmReceivablePlanDO::getRemark, reqVO.getRemark()) - .betweenIfPresent(CrmReceivablePlanDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(CrmReceivablePlanDO::getId)); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java index b8c472fa33..c044ad5441 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanService.java @@ -1,13 +1,18 @@ 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.CrmReceivablePlanDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; + +import javax.validation.Valid; +import java.util.Collection; +import java.util.List; /** - * 回款计划 Service 接口 + * CRM 回款计划 Service 接口 * * @author 芋道源码 */ @@ -54,17 +59,21 @@ public interface CrmReceivablePlanService { /** * 获得回款计划分页 * + * 数据权限:基于 {@link CrmReceivablePlanDO} 读取 + * * @param pageReqVO 分页查询 * @return 回款计划分页 */ PageResult getReceivablePlanPage(CrmReceivablePlanPageReqVO pageReqVO); /** - * 获得回款计划列表, 用于 Excel 导出 + * 获得回款计划分页,基于指定客户 * - * @param exportReqVO 查询条件 - * @return 回款计划列表 + * 数据权限:基于 {@link CrmCustomerDO} 读取 + * + * @param pageReqVO 分页查询 + * @return 回款计划分页 */ - List getReceivablePlanList(CrmReceivablePlanExportReqVO exportReqVO); + PageResult getReceivablePlanPageByCustomer(CrmReceivablePlanPageReqVO pageReqVO); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java index 1946c7eceb..e6760040a4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java @@ -3,18 +3,18 @@ package cn.iocoder.yudao.module.crm.service.receivable; import cn.hutool.core.collection.CollUtil; 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.CrmReceivablePlanCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanUpdateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO; import cn.iocoder.yudao.module.crm.convert.receivable.CrmReceivablePlanConvert; 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.CrmReceivablePlanDO; import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivablePlanMapper; -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; @@ -28,6 +28,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; // TODO @liuhongfeng:参考 CrmReceivableServiceImpl 写的 todo 哈; +// TODO @puhui999:数据权限 /** * 回款计划 Service 实现类 * @@ -38,26 +39,22 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { @Resource - private CrmReceivablePlanMapper crmReceivablePlanMapper; + private CrmReceivablePlanMapper receivablePlanMapper; + @Resource private CrmContractService contractService; @Resource - private CrmCustomerService crmCustomerService; + private CrmCustomerService customerService; @Override public Long createReceivablePlan(CrmReceivablePlanCreateReqVO createReqVO) { // 插入 CrmReceivablePlanDO receivablePlan = CrmReceivablePlanConvert.INSTANCE.convert(createReqVO); - if (ObjectUtil.isNull(receivablePlan.getStatus())){ - receivablePlan.setStatus(CommonStatusEnum.ENABLE.getStatus()); - } - if (ObjectUtil.isNull(receivablePlan.getCheckStatus())){ - receivablePlan.setCheckStatus(CrmAuditStatusEnum.DRAFT.getStatus()); - } + receivablePlan.setFinishStatus(false); checkReceivablePlan(receivablePlan); - crmReceivablePlanMapper.insert(receivablePlan); + receivablePlanMapper.insert(receivablePlan); // 返回 return receivablePlan.getId(); } @@ -73,7 +70,7 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { throw exception(CONTRACT_NOT_EXISTS); } - CrmCustomerDO customer = crmCustomerService.getCustomer(receivablePlan.getCustomerId()); + CrmCustomerDO customer = customerService.getCustomer(receivablePlan.getCustomerId()); if(ObjectUtil.isNull(customer)){ throw exception(CUSTOMER_NOT_EXISTS); } @@ -87,7 +84,7 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { // 更新 CrmReceivablePlanDO updateObj = CrmReceivablePlanConvert.INSTANCE.convert(updateReqVO); - crmReceivablePlanMapper.updateById(updateObj); + receivablePlanMapper.updateById(updateObj); } @Override @@ -95,18 +92,18 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { // 校验存在 validateReceivablePlanExists(id); // 删除 - crmReceivablePlanMapper.deleteById(id); + receivablePlanMapper.deleteById(id); } private void validateReceivablePlanExists(Long id) { - if (crmReceivablePlanMapper.selectById(id) == null) { + if (receivablePlanMapper.selectById(id) == null) { throw exception(RECEIVABLE_PLAN_NOT_EXISTS); } } @Override public CrmReceivablePlanDO getReceivablePlan(Long id) { - return crmReceivablePlanMapper.selectById(id); + return receivablePlanMapper.selectById(id); } @Override @@ -114,17 +111,18 @@ public class CrmReceivablePlanServiceImpl implements CrmReceivablePlanService { if (CollUtil.isEmpty(ids)) { return ListUtil.empty(); } - return crmReceivablePlanMapper.selectBatchIds(ids); + return receivablePlanMapper.selectBatchIds(ids); } @Override public PageResult getReceivablePlanPage(CrmReceivablePlanPageReqVO pageReqVO) { - return crmReceivablePlanMapper.selectPage(pageReqVO); + return receivablePlanMapper.selectPage(pageReqVO); } @Override - public List getReceivablePlanList(CrmReceivablePlanExportReqVO exportReqVO) { - return crmReceivablePlanMapper.selectList(exportReqVO); + @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#pageReqVO.customerId", level = CrmPermissionLevelEnum.READ) + public PageResult getReceivablePlanPageByCustomer(CrmReceivablePlanPageReqVO pageReqVO) { + return receivablePlanMapper.selectPageByCustomer(pageReqVO); } } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java index 78b51e94a0..626c4363fe 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImplTest.java @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.service.business; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessExportReqVO; import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessUpdateReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; @@ -11,9 +10,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.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; @@ -21,7 +18,8 @@ import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServic import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; /** * {@link CrmBusinessServiceImpl} 的单元测试类 @@ -181,84 +179,4 @@ public class CrmBusinessServiceImplTest extends BaseDbUnitTest { //assertPojoEquals(dbBusiness, pageResult.getList().get(0)); } - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetBusinessList() { - // mock 数据 - CrmBusinessDO dbBusiness = randomPojo(CrmBusinessDO.class, o -> { // 等会查询到 - o.setName(null); - o.setStatusTypeId(null); - o.setStatusId(null); - o.setContactNextTime(null); - o.setCustomerId(null); - o.setDealTime(null); - o.setPrice(null); - o.setDiscountPercent(null); - o.setProductPrice(null); - o.setRemark(null); - o.setCreateTime(null); - o.setEndStatus(null); - o.setEndRemark(null); - o.setContactLastTime(null); - o.setFollowUpStatus(null); - }); - businessMapper.insert(dbBusiness); - // 测试 name 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setName(null))); - // 测试 statusTypeId 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusTypeId(null))); - // 测试 statusId 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setStatusId(null))); - // 测试 contactNextTime 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactNextTime(null))); - // 测试 customerId 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCustomerId(null))); - // 测试 dealTime 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDealTime(null))); - // 测试 price 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setPrice(null))); - // 测试 discountPercent 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setDiscountPercent(null))); - // 测试 productPrice 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setProductPrice(null))); - // 测试 remark 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setRemark(null))); - // 测试 createTime 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setCreateTime(null))); - // 测试 endStatus 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndStatus(null))); - // 测试 endRemark 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setEndRemark(null))); - // 测试 contactLastTime 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setContactLastTime(null))); - // 测试 followUpStatus 不匹配 - businessMapper.insert(cloneIgnoreId(dbBusiness, o -> o.setFollowUpStatus(null))); - // 准备参数 - CrmBusinessExportReqVO reqVO = new CrmBusinessExportReqVO(); - reqVO.setName(null); - reqVO.setStatusTypeId(null); - reqVO.setStatusId(null); - reqVO.setContactNextTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setCustomerId(null); - reqVO.setDealTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setPrice(null); - reqVO.setDiscountPercent(null); - reqVO.setProductPrice(null); - reqVO.setRemark(null); - reqVO.setOwnerUserId(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setRoUserIds(null); - reqVO.setRwUserIds(null); - reqVO.setEndStatus(null); - reqVO.setEndRemark(null); - reqVO.setContactLastTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setFollowUpStatus(null); - - // 调用 - List list = businessService.getBusinessList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbBusiness, list.get(0)); - } - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java index 2e80a6955b..b57d749b3d 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/contract/ContractServiceImplTest.java @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.crm.service.contract; 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.contract.vo.CrmContractCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.ContractExportReqVO; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractUpdateReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO; @@ -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.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; @@ -120,25 +117,14 @@ public class ContractServiceImplTest extends BaseDbUnitTest { contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setName(null))); // 测试 customerId 不匹配 contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setCustomerId(null))); - // 测试 businessId 不匹配 - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setBusinessId(null))); - // 测试 orderDate 不匹配 - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setOrderDate(null))); // 测试 no 不匹配 contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setNo(null))); - // 测试 discountPercent 不匹配 - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setDiscountPercent(null))); - // 测试 productPrice 不匹配 - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setProductPrice(null))); // 准备参数 CrmContractPageReqVO reqVO = new CrmContractPageReqVO(); reqVO.setName(null); reqVO.setCustomerId(null); reqVO.setBusinessId(null); - reqVO.setOrderDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); reqVO.setNo(null); - reqVO.setDiscountPercent(null); - reqVO.setProductPrice(null); // 调用 PageResult pageResult = contractService.getContractPage(reqVO); @@ -148,49 +134,4 @@ public class ContractServiceImplTest extends BaseDbUnitTest { assertPojoEquals(dbContract, pageResult.getList().get(0)); } - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetContractList() { - // mock 数据 - CrmContractDO dbContract = randomPojo(CrmContractDO.class, o -> { // 等会查询到 - o.setName("合同名称"); - o.setCustomerId(null); - o.setBusinessId(null); - o.setOrderDate(null); - o.setNo(null); - o.setDiscountPercent(null); - o.setProductPrice(null); - }); - contractMapper.insert(dbContract); - // 测试 name 不匹配 - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setName(null))); - // 测试 customerId 不匹配 - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setCustomerId(null))); - // 测试 businessId 不匹配 - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setBusinessId(null))); - // 测试 orderDate 不匹配 - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setOrderDate(null))); - // 测试 no 不匹配 - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setNo(null))); - // 测试 discountPercent 不匹配 - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setDiscountPercent(null))); - // 测试 productPrice 不匹配 - contractMapper.insert(cloneIgnoreId(dbContract, o -> o.setProductPrice(null))); - // 准备参数 - ContractExportReqVO reqVO = new ContractExportReqVO(); - reqVO.setName(null); - reqVO.setCustomerId(null); - reqVO.setBusinessId(null); - reqVO.setOrderDate(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setNo(null); - reqVO.setDiscountPercent(null); - reqVO.setProductPrice(null); - - // 调用 - List list = contractService.getContractList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbContract, list.get(0)); - } - } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivablePlanServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivablePlanServiceImplTest.java index 09993f8992..f546e9f15b 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivablePlanServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/receivable/CrmCrmReceivablePlanServiceImplTest.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.CrmReceivablePlanCreateReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanExportReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanPageReqVO; -import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.CrmReceivablePlanUpdateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanCreateReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanPageReqVO; +import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.plan.CrmReceivablePlanUpdateReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.CrmReceivablePlanDO; import cn.iocoder.yudao.module.crm.dal.mysql.receivable.CrmReceivablePlanMapper; 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; @@ -108,8 +105,6 @@ public class CrmCrmReceivablePlanServiceImplTest extends BaseDbUnitTest { // mock 数据 CrmReceivablePlanDO dbReceivablePlan = randomPojo(CrmReceivablePlanDO.class, o -> { // 等会查询到 o.setPeriod(null); - o.setStatus(null); - o.setCheckStatus(null); o.setReturnTime(null); o.setRemindDays(null); o.setRemindTime(null); @@ -120,38 +115,14 @@ public class CrmCrmReceivablePlanServiceImplTest extends BaseDbUnitTest { o.setCreateTime(null); }); crmReceivablePlanMapper.insert(dbReceivablePlan); - // 测试 Period 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setPeriod(null))); - // 测试 status 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setStatus(null))); - // 测试 checkStatus 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCheckStatus(null))); - // 测试 returnTime 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setReturnTime(null))); - // 测试 remindDays 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindDays(null))); - // 测试 remindTime 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindTime(null))); // 测试 customerId 不匹配 crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCustomerId(null))); // 测试 contractId 不匹配 crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setContractId(null))); - // 测试 ownerUserId 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setOwnerUserId(null))); - // 测试 remark 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemark(null))); - // 测试 createTime 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCreateTime(null))); // 准备参数 CrmReceivablePlanPageReqVO reqVO = new CrmReceivablePlanPageReqVO(); - reqVO.setStatus(null); - reqVO.setCheckStatus(null); - reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setRemindTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); reqVO.setCustomerId(null); reqVO.setContractId(null); - reqVO.setOwnerUserId(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); // 调用 PageResult pageResult = receivablePlanService.getReceivablePlanPage(reqVO); @@ -161,65 +132,4 @@ public class CrmCrmReceivablePlanServiceImplTest extends BaseDbUnitTest { assertPojoEquals(dbReceivablePlan, pageResult.getList().get(0)); } - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetReceivablePlanList() { - // mock 数据 - CrmReceivablePlanDO dbReceivablePlan = randomPojo(CrmReceivablePlanDO.class, o -> { // 等会查询到 - o.setPeriod(null); - o.setStatus(null); - o.setCheckStatus(null); - o.setReturnTime(null); - o.setRemindDays(null); - o.setRemindTime(null); - o.setCustomerId(null); - o.setContractId(null); - o.setOwnerUserId(null); - o.setRemark(null); - o.setCreateTime(null); - }); - crmReceivablePlanMapper.insert(dbReceivablePlan); - // 测试 Period 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setPeriod(null))); - // 测试 status 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setStatus(null))); - // 测试 checkStatus 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCheckStatus(null))); - // 测试 returnTime 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setReturnTime(null))); - // 测试 remindDays 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindDays(null))); - // 测试 remindTime 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemindTime(null))); - // 测试 customerId 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCustomerId(null))); - // 测试 contractId 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setContractId(null))); - // 测试 ownerUserId 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setOwnerUserId(null))); - // 测试 remark 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setRemark(null))); - // 测试 createTime 不匹配 - crmReceivablePlanMapper.insert(cloneIgnoreId(dbReceivablePlan, o -> o.setCreateTime(null))); - // 准备参数 - CrmReceivablePlanExportReqVO reqVO = new CrmReceivablePlanExportReqVO(); - reqVO.setPeriod(null); - reqVO.setStatus(null); - reqVO.setCheckStatus(null); - reqVO.setReturnTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setRemindDays(null); - reqVO.setRemindTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - reqVO.setCustomerId(null); - reqVO.setContractId(null); - reqVO.setOwnerUserId(null); - reqVO.setRemark(null); - reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); - - // 调用 - List list = receivablePlanService.getReceivablePlanList(reqVO); - // 断言 - assertEquals(1, list.size()); - assertPojoEquals(dbReceivablePlan, list.get(0)); - } - }