Commit 301f497527edcc8a594dbc8fe79a91ab8eeec079

Authored by liuhongfeng
1 parent 55f9e013

【新增】回款计划-审批枚举类

【新增】回款计划-回款方式枚举类
【新增】回款计划-枚举类校验
【修改】回款计划-错误码调整
【修改】修改回款计划-创建逻辑,添加合同数据的校验
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/AuditStatusEnum.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.enums;
  2 +
  3 +import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
  4 +
  5 +import java.util.Arrays;
  6 +
  7 +/**
  8 + * 流程审批状态枚举类
  9 + * 0 未审核 1 审核通过 2 审核拒绝 3 审核中 4 已撤回
  10 + * @author 赤焰
  11 + */
  12 +public enum AuditStatusEnum implements IntArrayValuable {
  13 + /**
  14 + * 未审批
  15 + */
  16 + AUDIT_NEW(0, "未审批"),
  17 + /**
  18 + * 审核通过
  19 + */
  20 + AUDIT_FINISH(0, "审核通过"),
  21 + /**
  22 + * 审核拒绝
  23 + */
  24 + AUDIT_REJECT(2, "审核拒绝"),
  25 + /**
  26 + * 审核中
  27 + */
  28 + AUDIT_DOING(3, "审核中"),
  29 + /**
  30 + * 已撤回
  31 + */
  32 + AUDIT_RETURN(4, "已撤回");
  33 +
  34 + private final Integer value;
  35 + private final String desc;
  36 +
  37 + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AuditStatusEnum::getValue).toArray();
  38 +
  39 + /**
  40 + *
  41 + * @param value
  42 + * @param desc
  43 + */
  44 + AuditStatusEnum(Integer value, String desc) {
  45 + this.value = value;
  46 + this.desc = desc;
  47 + }
  48 +
  49 + public Integer getValue() {
  50 + return value;
  51 + }
  52 +
  53 + public String getDesc() {
  54 + return desc;
  55 + }
  56 +
  57 + @Override
  58 + public int[] array() {
  59 + return ARRAYS;
  60 + }
  61 +}
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
@@ -21,9 +21,10 @@ public interface ErrorCodeConstants { @@ -21,9 +21,10 @@ public interface ErrorCodeConstants {
21 // ========== 联系人管理 1-020-003-000 ========== 21 // ========== 联系人管理 1-020-003-000 ==========
22 ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); 22 ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在");
23 23
24 - // TODO @liuhongfeng:错误码分段;  
25 - ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_030_000_001, "回款管理不存在"); 24 + // ========== 回款管理 1-020-004-000 ==========
  25 + ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款管理不存在");
26 26
27 - ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_040_000_001, "回款计划不存在"); 27 + // ========== 合同管理 1-020-005-000 ==========
  28 + ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_020_005_000, "回款计划不存在");
28 29
29 } 30 }
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ReturnTypeEnum.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.enums;
  2 +
  3 +/**
  4 + * @author 赤焰
  5 + */
  6 +
  7 +public enum ReturnTypeEnum {
  8 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/ReceivableBaseVO.java
1 package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; 1 package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
2 2
  3 +import cn.iocoder.yudao.framework.common.validation.InEnum;
  4 +import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum;
3 import io.swagger.v3.oas.annotations.media.Schema; 5 import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 6 import lombok.Data;
5 import org.springframework.format.annotation.DateTimeFormat; 7 import org.springframework.format.annotation.DateTimeFormat;
@@ -33,9 +35,8 @@ public class ReceivableBaseVO { @@ -33,9 +35,8 @@ public class ReceivableBaseVO {
33 @Schema(description = "合同ID", example = "30305") 35 @Schema(description = "合同ID", example = "30305")
34 private Long contractId; 36 private Long contractId;
35 37
36 - // TODO @liuhongfeng:这个字段,可以写个枚举,然后 InEnum 去校验下;  
37 - // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的  
38 @Schema(description = "审批状态", example = "1") 38 @Schema(description = "审批状态", example = "1")
  39 + @InEnum(AuditStatusEnum.class)
39 private Integer checkStatus; 40 private Integer checkStatus;
40 41
41 // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; 42 // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面;
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/ReceivableServiceImpl.java
@@ -2,14 +2,19 @@ package cn.iocoder.yudao.module.crm.service.receivable; @@ -2,14 +2,19 @@ package cn.iocoder.yudao.module.crm.service.receivable;
2 2
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 import cn.hutool.core.collection.ListUtil; 4 import cn.hutool.core.collection.ListUtil;
  5 +import cn.hutool.core.util.ObjectUtil;
  6 +import cn.hutool.core.util.StrUtil;
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 7 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableCreateReqVO; 8 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableCreateReqVO;
7 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableExportReqVO; 9 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableExportReqVO;
8 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePageReqVO; 10 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePageReqVO;
9 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableUpdateReqVO; 11 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableUpdateReqVO;
10 import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; 12 import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert;
  13 +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO;
11 import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; 14 import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO;
12 import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; 15 import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper;
  16 +import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum;
  17 +import cn.iocoder.yudao.module.crm.service.contract.ContractService;
13 import org.springframework.stereotype.Service; 18 import org.springframework.stereotype.Service;
14 import org.springframework.validation.annotation.Validated; 19 import org.springframework.validation.annotation.Validated;
15 20
@@ -18,6 +23,7 @@ import java.util.Collection; @@ -18,6 +23,7 @@ import java.util.Collection;
18 import java.util.List; 23 import java.util.List;
19 24
20 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 25 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  26 +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS;
21 import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_NOT_EXISTS; 27 import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_NOT_EXISTS;
22 28
23 /** 29 /**
@@ -31,6 +37,8 @@ public class ReceivableServiceImpl implements ReceivableService { @@ -31,6 +37,8 @@ public class ReceivableServiceImpl implements ReceivableService {
31 37
32 @Resource 38 @Resource
33 private ReceivableMapper receivableMapper; 39 private ReceivableMapper receivableMapper;
  40 + @Resource
  41 + private ContractService contractService;
34 42
35 @Override 43 @Override
36 public Long createReceivable(ReceivableCreateReqVO createReqVO) { 44 public Long createReceivable(ReceivableCreateReqVO createReqVO) {
@@ -38,11 +46,29 @@ public class ReceivableServiceImpl implements ReceivableService { @@ -38,11 +46,29 @@ public class ReceivableServiceImpl implements ReceivableService {
38 // TODO @liuhongfeng:其它类似 customerId、contractId 也需要去校验; 46 // TODO @liuhongfeng:其它类似 customerId、contractId 也需要去校验;
39 // 插入 47 // 插入
40 ReceivableDO receivable = ReceivableConvert.INSTANCE.convert(createReqVO); 48 ReceivableDO receivable = ReceivableConvert.INSTANCE.convert(createReqVO);
  49 +
  50 + receivable.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue());
  51 + //校验
  52 + checkReceivable(receivable);
  53 +
41 receivableMapper.insert(receivable); 54 receivableMapper.insert(receivable);
42 // 返回 55 // 返回
43 return receivable.getId(); 56 return receivable.getId();
44 } 57 }
45 58
  59 + private void checkReceivable(ReceivableDO receivable) {
  60 +
  61 + if(ObjectUtil.isNull(receivable.getContractId())){
  62 + throw exception(CONTRACT_NOT_EXISTS);
  63 + }
  64 +
  65 + ContractDO contract = contractService.getContract(receivable.getContractId());
  66 + if(ObjectUtil.isNull(contract)){
  67 + throw exception(CONTRACT_NOT_EXISTS);
  68 + }
  69 +
  70 + }
  71 +
46 @Override 72 @Override
47 public void updateReceivable(ReceivableUpdateReqVO updateReqVO) { 73 public void updateReceivable(ReceivableUpdateReqVO updateReqVO) {
48 // 校验存在 74 // 校验存在