Commit b7900c2035d23df2581d37de1d7f0d8845de8a26

Authored by YunaiV
1 parent 71ce831d

code review:回款逻辑

Showing 15 changed files with 75 additions and 43 deletions
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/AuditStatusEnum.java
... ... @@ -4,12 +4,16 @@ import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
4 4  
5 5 import java.util.Arrays;
6 6  
  7 +// TODO @liuhongfeng:这个状态,还是搞成专属 CrmReceivableDO 专属的 status;
7 8 /**
8 9 * 流程审批状态枚举类
9   - * 0 未审核 1 审核通过 2 审核拒绝 3 审核中 4 已撤回
  10 + * 0 未审核 1 审核通过 2 审核拒绝 3 审核中 4 已撤回 TODO @liuhongfeng:这一行可以删除,因为已经有枚举属性了哈;
10 11 * @author 赤焰
11 12 */
  13 +// TODO @liuhongfeng:可以使用 @Getter、@AllArgsConstructor 简化 get、构造方法
12 14 public enum AuditStatusEnum implements IntArrayValuable {
  15 +
  16 + // TODO @liuhongfeng:草稿 0;10 审核中;20 审核通过;30 审核拒绝;40 已撤回;主要是留好间隙,万一每个地方要做点拓展; 然后,枚举字段的顺序调整下,审批中,一定要放两个审批通过、拒绝前面哈;
13 17 /**
14 18 * 未审批
15 19 */
... ... @@ -31,16 +35,12 @@ public enum AuditStatusEnum implements IntArrayValuable {
31 35 */
32 36 AUDIT_RETURN(4, "已撤回");
33 37  
  38 + // TODO liuhongfeng:value 改成 status;desc 改成 name;
34 39 private final Integer value;
35 40 private final String desc;
36 41  
37 42 public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AuditStatusEnum::getValue).toArray();
38 43  
39   - /**
40   - *
41   - * @param value
42   - * @param desc
43   - */
44 44 AuditStatusEnum(Integer value, String desc) {
45 45 this.value = value;
46 46 this.desc = desc;
... ...
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/ReturnTypeEnum.java
1 1 package cn.iocoder.yudao.module.crm.enums;
2 2  
  3 +// TODO @liuhongfeng:这个的作用是?
3 4 /**
4 5 * @author 赤焰
5 6 */
6   -
7 7 public enum ReturnTypeEnum {
8 8 }
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/CrmReceivableController.java
... ... @@ -30,6 +30,7 @@ import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.E
30 30 @Validated
31 31 public class CrmReceivableController {
32 32  
  33 + // TODO @liuhongfeng:crmReceivableService 可以使用 receivableService ;在自己模块里,相对简洁一点;
33 34 @Resource
34 35 private CrmReceivableService crmReceivableService;
35 36  
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableBaseVO.java
... ... @@ -20,15 +20,19 @@ public class CrmReceivableBaseVO {
20 20 @Schema(description = "回款编号",requiredMode = Schema.RequiredMode.REQUIRED, example = "31177")
21 21 private String no;
22 22  
  23 + // TODO @liuhongfeng:回款计划编号
23 24 @Schema(description = "回款计划", example = "31177")
24 25 private Long planId;
25 26  
  27 + // TODO @liuhongfeng:客户编号
26 28 @Schema(description = "客户名称", example = "4963")
27 29 private Long customerId;
28 30  
  31 + // TODO @liuhongfeng:客户编号
29 32 @Schema(description = "合同名称", example = "30305")
30 33 private Long contractId;
31 34  
  35 + // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的
32 36 @Schema(description = "审批状态", example = "1")
33 37 @InEnum(AuditStatusEnum.class)
34 38 private Integer checkStatus;
... ... @@ -40,9 +44,10 @@ public class CrmReceivableBaseVO {
40 44 @Schema(description = "回款方式", example = "2")
41 45 private String returnType;
42 46  
43   - @Schema(description = "回款金额", example = "31859")
  47 + @Schema(description = "回款金额,单位:分", example = "31859")
44 48 private Integer price;
45 49  
  50 + // TODO @liuhongfeng:负责人编号
46 51 @Schema(description = "负责人", example = "22202")
47 52 private Long ownerUserId;
48 53  
... ... @@ -55,6 +60,7 @@ public class CrmReceivableBaseVO {
55 60 @Schema(description = "备注", example = "备注")
56 61 private String remark;
57 62  
  63 + // TODO @liuhongfeng:这个字段,这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面;
58 64 @Schema(description = "完成状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
59 65 private Integer status;
60 66  
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExcelVO.java
1 1 package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
2 2  
3   -import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
4   -import lombok.*;
5   -
6   -import java.time.LocalDateTime;
7   -
8   -import com.alibaba.excel.annotation.ExcelProperty;
9 3 import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
10 4 import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
  5 +import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
  6 +import com.alibaba.excel.annotation.ExcelProperty;
  7 +import lombok.Data;
11 8  
  9 +import java.time.LocalDateTime;
12 10  
13   -/**
14   - * CRM 回款管理 Excel VO
15   - *
16   - * @author 赤焰
17   - */
  11 +// TODO liuhongfeng:导出可以等其它功能做完,统一在搞;
18 12 @Data
19 13 public class CrmReceivableExcelVO {
20 14  
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivableExportReqVO.java
... ... @@ -8,9 +8,7 @@ import java.time.LocalDateTime;
8 8  
9 9 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
10 10  
11   -/**
12   - * @author 赤焰
13   - */
  11 +// TODO liuhongfeng:导出可以等其它功能做完,统一在搞;
14 12 @Schema(description = "管理后台 - CRM 回款 Excel 导出 Request VO,参数和 CrmReceivablePageReqVO 是一致的")
15 13 @Data
16 14 public class CrmReceivableExportReqVO {
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePageReqVO.java
... ... @@ -17,6 +17,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
17 17 @ToString(callSuper = true)
18 18 public class CrmReceivablePageReqVO extends PageParam {
19 19  
  20 + // TODO @liuhongfeng:可以根据需求,去除掉一些不要的过滤条件;另外,planId、customerId、contractId、ownerUserId 注释不正确,应该都是对应的编号
  21 +
20 22 @Schema(description = "回款编号")
21 23 private String no;
22 24  
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanBaseVO.java
... ... @@ -20,6 +20,7 @@ public class CrmReceivablePlanBaseVO {
20 20 @Schema(description = "期数", example = "1")
21 21 private Integer period;
22 22  
  23 + // TODO @liuhongfeng:回款计划编号
23 24 @Schema(description = "回款计划", example = "19852")
24 25 private Long receivableId;
25 26  
... ... @@ -44,12 +45,15 @@ public class CrmReceivablePlanBaseVO {
44 45 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
45 46 private LocalDateTime remindTime;
46 47  
  48 + // TODO @liuhongfeng:客户编号
47 49 @Schema(description = "客户名称", example = "18026")
48 50 private Long customerId;
49 51  
  52 + // TODO @liuhongfeng:合同编号
50 53 @Schema(description = "合同名称", example = "3473")
51 54 private Long contractId;
52 55  
  56 + // TODO @liuhongfeng:负责人编号
53 57 @Schema(description = "负责人", example = "17828")
54 58 private Long ownerUserId;
55 59  
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExcelVO.java
1 1 package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
2 2  
3   -import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
4   -import lombok.*;
5   -
6   -import java.time.LocalDateTime;
7   -
8   -import com.alibaba.excel.annotation.ExcelProperty;
9 3 import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
10 4 import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
  5 +import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
  6 +import com.alibaba.excel.annotation.ExcelProperty;
  7 +import lombok.Data;
11 8  
  9 +import java.time.LocalDateTime;
12 10  
  11 +// TODO liuhongfeng:导出可以等其它功能做完,统一在搞;
13 12 /**
14 13 * CRM 回款计划 Excel VO
15 14 *
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanExportReqVO.java
1 1 package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
2 2  
3   -import lombok.*;
4 3 import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +import org.springframework.format.annotation.DateTimeFormat;
5 6  
6 7 import java.time.LocalDateTime;
7   -import org.springframework.format.annotation.DateTimeFormat;
8 8  
9 9 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
10 10  
  11 +// TODO liuhongfeng:导出可以等其它功能做完,统一在搞;
11 12 @Schema(description = "管理后台 - CRM 回款计划 Excel 导出 Request VO,参数和 CrmReceivablePlanPageReqVO 是一致的")
12 13 @Data
13 14 public class CrmReceivablePlanExportReqVO {
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/receivable/vo/CrmReceivablePlanPageReqVO.java
... ... @@ -17,6 +17,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
17 17 @ToString(callSuper = true)
18 18 public class CrmReceivablePlanPageReqVO extends PageParam {
19 19  
  20 + // TODO @liuhongfeng:可以根据需求,去除掉一些不要的过滤条件;另外,customerId、contractId、ownerUserId 注释不正确,应该都是对应的编号
  21 +
20 22 @Schema(description = "完成状态", example = "2")
21 23 private Integer status;
22 24  
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivableDO.java
... ... @@ -32,24 +32,28 @@ public class CrmReceivableDO extends BaseDO {
32 32 * 回款编号
33 33 */
34 34 private String no;
  35 + // TODO @liuhongfeng:“对应实体”,参考别的模块,关联 {@link TableField.MetaInfo#getJdbcType()}
35 36 /**
36 37 * 回款计划
37 38 *
  39 + * TODO @liuhongfeng:这个字段什么时候更新,也可以写下
  40 + *
38 41 * 对应实体 {@link CrmReceivablePlanDO}
39 42 */
40 43 private Long planId;
41 44 /**
42   - * 客户ID
  45 + * 客户 ID
43 46 *
44 47 * 对应实体 {@link cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO}
45 48 */
46 49 private Long customerId;
47 50 /**
48   - * 合同ID
  51 + * 合同 ID
49 52 *
50 53 * 对应实体 {@link cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO}
51 54 */
52 55 private Long contractId;
  56 + // TODO @liuhongfeng:“对应字典”,参考别的模块,枚举 {@link XXXX};另外,这个字段就叫 status,整体状态,不只审批
53 57 /**
54 58 * 审批状态
55 59 * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_RECEIVABLE_CHECK_STATUS}
... ... @@ -65,6 +69,7 @@ public class CrmReceivableDO extends BaseDO {
65 69 * 回款日期
66 70 */
67 71 private LocalDateTime returnTime;
  72 + // TODO @liuhongfeng:少个枚举
68 73 /**
69 74 * 回款方式
70 75 */
... ... @@ -73,10 +78,12 @@ public class CrmReceivableDO extends BaseDO {
73 78 * 回款金额
74 79 */
75 80 private Integer price;
  81 + // TODO @liuhongfeng:少关联实体;
76 82 /**
77 83 * 负责人
78 84 */
79 85 private Long ownerUserId;
  86 + // TODO @liuhongfeng:应该不需要 batchId 字段
80 87 /**
81 88 * 批次
82 89 */
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/dal/dataobject/receivable/CrmReceivablePlanDO.java
1 1 package cn.iocoder.yudao.module.crm.dal.dataobject.receivable;
2 2  
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import com.baomidou.mybatisplus.annotation.KeySequence;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
3 7 import lombok.*;
4 8  
5 9 import java.time.LocalDateTime;
6 10  
7   -import com.baomidou.mybatisplus.annotation.*;
8   -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
9   -
10 11 /**
11 12 * 回款计划 DO
12 13 *
... ... @@ -33,26 +34,32 @@ public class CrmReceivablePlanDO extends BaseDO {
33 34 private Integer period;
34 35 /**
35 36 * 回款ID
  37 + *
  38 + * TODO @liuhongfeng:少关联实体;
36 39 */
37 40 private Long receivableId;
  41 + // TODO @liuhongfeng:还款计划,没有 status 和 checkStatus,改成 finishStatus Boolean;是否完成
38 42 /**
39 43 * 状态
40 44 *
41 45 * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum}
42   - *
43 46 */
44 47 private Integer status;
45 48 /**
46 49 * 审批状态
  50 + *
47 51 * 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_RECEIVABLE_CHECK_STATUS}
  52 + * // TODO @liuhongfeng:关联的枚举
48 53 */
49 54 private Integer checkStatus;
50 55 /**
51 56 * 工作流编号
  57 + *
  58 + * TODO @liuhongfeng:少关联实体;
52 59 */
53 60 private Long processInstanceId;
54 61 /**
55   - * 计划回款金额
  62 + * 计划回款金额,单位:分
56 63 */
57 64 private Integer price;
58 65 /**
... ... @@ -68,15 +75,21 @@ public class CrmReceivablePlanDO extends BaseDO {
68 75 */
69 76 private LocalDateTime remindTime;
70 77 /**
71   - * 客户ID
  78 + * 客户 ID
  79 + *
  80 + * TODO @liuhongfeng:少关联实体;
72 81 */
73 82 private Long customerId;
74 83 /**
75   - * 合同ID
  84 + * 合同 ID
  85 + *
  86 + * TODO @liuhongfeng:少关联实体;
76 87 */
77 88 private Long contractId;
78 89 /**
79   - * 负责人
  90 + * 负责人 ID
  91 + *
  92 + * TODO @liuhongfeng:少关联实体;
80 93 */
81 94 private Long ownerUserId;
82 95 /**
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivablePlanServiceImpl.java
... ... @@ -27,6 +27,7 @@ import java.util.List;
27 27 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
28 28 import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
29 29  
  30 +// TODO @liuhongfeng:参考 CrmReceivableServiceImpl 写的 todo 哈;
30 31 /**
31 32 * 回款计划 Service 实现类
32 33 *
... ...
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/receivable/CrmReceivableServiceImpl.java
... ... @@ -37,6 +37,7 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
37 37 @Validated
38 38 public class CrmReceivableServiceImpl implements CrmReceivableService {
39 39  
  40 + // TODO @liuhongfeng:crm 前缀,变量可以不带哈;
40 41 @Resource
41 42 private CrmReceivableMapper crmReceivableMapper;
42 43 @Resource
... ... @@ -46,10 +47,12 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
46 47 @Resource
47 48 private CrmReceivablePlanService crmReceivablePlanService;
48 49  
  50 + // TODO @liuhongfeng:创建还款后,是不是什么时候,要更新 plan?
49 51 @Override
50 52 public Long createReceivable(CrmReceivableCreateReqVO createReqVO) {
51 53 // 插入
52 54 CrmReceivableDO receivable = CrmReceivableConvert.INSTANCE.convert(createReqVO);
  55 + // TODO @liuhongfeng:这里的括号要注意排版;
53 56 if (ObjectUtil.isNull(receivable.getStatus())){
54 57 receivable.setStatus(CommonStatusEnum.ENABLE.getStatus());
55 58 }
... ... @@ -57,16 +60,17 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
57 60 receivable.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue());
58 61 }
59 62  
60   - //校验
  63 + // TODO @liuhongfeng:一般来说,逻辑的写法,是要先检查,后操作 db;所以,你这个 check 应该放到 CrmReceivableDO receivable 之前;
  64 + // 校验
61 65 checkReceivable(receivable);
62 66  
63 67 crmReceivableMapper.insert(receivable);
64   - // 返回
65 68 return receivable.getId();
66 69 }
67 70  
  71 + // TODO @liuhongfeng:这里的括号要注意排版;
68 72 private void checkReceivable(CrmReceivableDO receivable) {
69   -
  73 + // TODO @liuhongfeng:这个放在参数校验合适
70 74 if(ObjectUtil.isNull(receivable.getContractId())){
71 75 throw exception(CONTRACT_NOT_EXISTS);
72 76 }
... ...