From 677e8ab2fc0c50185425ba24b90d0049099ab027 Mon Sep 17 00:00:00 2001 From: liuhongfeng <291117974@qq.com> Date: Sun, 29 Oct 2023 18:00:34 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E5=9B=9E?= =?UTF-8?q?=E6=AC=BE=E8=AE=A1=E5=88=92-=E4=BF=AE=E6=94=B9=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E7=B1=BB=E5=9E=8B=20=E3=80=90=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E3=80=91=E4=BF=AE=E6=94=B9=E5=9B=9E=E6=AC=BE=E8=AE=A1=E5=88=92?= =?UTF-8?q?-=E5=88=9B=E5=BB=BA=E9=80=BB=E8=BE=91=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=AE=A2=E6=88=B7=E7=9A=84=E6=95=B0=E6=8D=AE=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/AuditStatusEnum.java | 2 +- .../receivable/vo/ReceivablePlanBaseVO.java | 2 +- .../receivable/vo/ReceivablePlanExcelVO.java | 2 +- .../vo/ReceivablePlanExportReqVO.java | 2 +- .../vo/ReceivablePlanPageReqVO.java | 2 +- .../receivable/ReceivablePlanDO.java | 2 +- .../receivable/ReceivablePlanServiceImpl.java | 39 +++++++++++++++++-- .../receivable/ReceivableServiceImpl.java | 21 ++++++++-- 8 files changed, 59 insertions(+), 13 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/AuditStatusEnum.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/AuditStatusEnum.java index ce04c18a1..6cc1012b6 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/AuditStatusEnum.java +++ b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/AuditStatusEnum.java @@ -17,7 +17,7 @@ public enum AuditStatusEnum implements IntArrayValuable { /** * 审核通过 */ - AUDIT_FINISH(0, "审核通过"), + AUDIT_FINISH(1, "审核通过"), /** * 审核拒绝 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java index 59f333e4b..53572e2c4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanBaseVO.java @@ -31,7 +31,7 @@ public class ReceivablePlanBaseVO { // TODO @liuhongfeng:这个字段,可以写个枚举,然后 InEnum 去校验下; // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的 @Schema(description = "审批状态", example = "1") - private String checkStatus; + private Integer checkStatus; // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; @Schema(description = "工作流编号", example = "8909") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java index e12d5a1df..d08cfc6a7 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExcelVO.java @@ -37,7 +37,7 @@ public class ReceivablePlanExcelVO { @ExcelProperty(value = "审批状态", converter = DictConvert.class) @DictFormat("crm_receivable_check_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 - private String checkStatus; + private Integer checkStatus; //@ExcelProperty("工作流编号") //private Long processInstanceId; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java index ca5d3f553..e68427d29 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanExportReqVO.java @@ -20,7 +20,7 @@ public class ReceivablePlanExportReqVO { private Integer status; @Schema(description = "审批状态", example = "1") - private String checkStatus; + private Integer checkStatus; @Schema(description = "计划回款日期") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java index 2d0e7d5ae..acd4d5aa4 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivablePlanPageReqVO.java @@ -26,7 +26,7 @@ public class ReceivablePlanPageReqVO extends PageParam { private Integer status; @Schema(description = "审批状态", example = "1") - private String checkStatus; + private Integer checkStatus; @Schema(description = "计划回款日期") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java index 4447df053..0c6f6e033 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/ReceivablePlanDO.java @@ -49,7 +49,7 @@ public class ReceivablePlanDO extends BaseDO { * * 枚举 {@link TODO crm_receivable_check_status 对应的类} */ - private String checkStatus; + private Integer checkStatus; /** * 工作流编号 */ diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java index c0b236ac0..f8493a1ec 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivablePlanServiceImpl.java @@ -10,8 +10,14 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlan import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanPageReqVO; import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanUpdateReqVO; import cn.iocoder.yudao.module.crm.convert.receivable.ReceivablePlanConvert; +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivablePlanMapper; +import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; +import cn.iocoder.yudao.module.crm.service.contract.ContractService; +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -20,7 +26,7 @@ import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_PLAN_NOT_EXISTS; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; /** * 回款计划 Service 实现类 @@ -33,20 +39,47 @@ public class ReceivablePlanServiceImpl implements ReceivablePlanService { @Resource private ReceivablePlanMapper receivablePlanMapper; + @Resource + private ContractService contractService; + @Resource + private CrmCustomerService crmCustomerService; @Override public Long createReceivablePlan(ReceivablePlanCreateReqVO createReqVO) { // 插入 ReceivablePlanDO receivablePlan = ReceivablePlanConvert.INSTANCE.convert(createReqVO); - // TODO @liuhongfeng:空格要注释;if (ObjectUtil.isNull(receivablePlan.getStatus())) { - if(ObjectUtil.isNull(receivablePlan.getStatus())){ + if (ObjectUtil.isNull(receivablePlan.getStatus())){ receivablePlan.setStatus(CommonStatusEnum.ENABLE.getStatus()); } + if (ObjectUtil.isNull(receivablePlan.getCheckStatus())){ + receivablePlan.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue()); + } + + checkReceivablePlan(receivablePlan); + receivablePlanMapper.insert(receivablePlan); // 返回 return receivablePlan.getId(); } + private void checkReceivablePlan(ReceivablePlanDO receivablePlan) { + + if(ObjectUtil.isNull(receivablePlan.getContractId())){ + throw exception(CONTRACT_NOT_EXISTS); + } + + ContractDO contract = contractService.getContract(receivablePlan.getContractId()); + if(ObjectUtil.isNull(contract)){ + throw exception(CONTRACT_NOT_EXISTS); + } + + CrmCustomerDO customer = crmCustomerService.getCustomer(receivablePlan.getCustomerId()); + if(ObjectUtil.isNull(customer)){ + throw exception(CUSTOMER_NOT_EXISTS); + } + + } + @Override public void updateReceivablePlan(ReceivablePlanUpdateReqVO updateReqVO) { // 校验存在 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java index 39de05fe1..cf216d4d2 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +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.ReceivableCreateReqVO; import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableExportReqVO; @@ -11,10 +12,12 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePage import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableUpdateReqVO; import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; import cn.iocoder.yudao.module.crm.service.contract.ContractService; +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -23,8 +26,7 @@ import java.util.Collection; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS; -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_NOT_EXISTS; +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; /** * 回款管理 Service 实现类 @@ -39,15 +41,21 @@ public class ReceivableServiceImpl implements ReceivableService { private ReceivableMapper receivableMapper; @Resource private ContractService contractService; + @Resource + private CrmCustomerService crmCustomerService; @Override public Long createReceivable(ReceivableCreateReqVO createReqVO) { // TODO @liuhongfeng:planId 是否存在,是否合法,需要去校验; - // TODO @liuhongfeng:其它类似 customerId、contractId 也需要去校验; // 插入 ReceivableDO receivable = ReceivableConvert.INSTANCE.convert(createReqVO); + if (ObjectUtil.isNull(receivable.getStatus())){ + receivable.setStatus(CommonStatusEnum.ENABLE.getStatus()); + } + if (ObjectUtil.isNull(receivable.getCheckStatus())){ + receivable.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue()); + } - receivable.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue()); //校验 checkReceivable(receivable); @@ -67,6 +75,11 @@ public class ReceivableServiceImpl implements ReceivableService { throw exception(CONTRACT_NOT_EXISTS); } + CrmCustomerDO customer = crmCustomerService.getCustomer(receivable.getCustomerId()); + if(ObjectUtil.isNull(customer)){ + throw exception(CUSTOMER_NOT_EXISTS); + } + } @Override