code review:回款逻辑

This commit is contained in:
YunaiV 2023-11-03 23:02:01 +08:00
parent 71ce831d59
commit b7900c2035
15 changed files with 75 additions and 43 deletions

View File

@ -4,12 +4,16 @@ import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import java.util.Arrays;
// TODO @liuhongfeng这个状态还是搞成专属 CrmReceivableDO 专属的 status
/**
* 流程审批状态枚举类
* 0 未审核 1 审核通过 2 审核拒绝 3 审核中 4 已撤回
* 0 未审核 1 审核通过 2 审核拒绝 3 审核中 4 已撤回 TODO @liuhongfeng这一行可以删除因为已经有枚举属性了哈
* @author 赤焰
*/
// TODO @liuhongfeng可以使用 @Getter@AllArgsConstructor 简化 get构造方法
public enum AuditStatusEnum implements IntArrayValuable {
// TODO @liuhongfeng草稿 010 审核中20 审核通过30 审核拒绝40 已撤回主要是留好间隙万一每个地方要做点拓展 然后枚举字段的顺序调整下审批中一定要放两个审批通过拒绝前面哈
/**
* 未审批
*/
@ -31,16 +35,12 @@ public enum AuditStatusEnum implements IntArrayValuable {
*/
AUDIT_RETURN(4, "已撤回");
// TODO liuhongfengvalue 改成 statusdesc 改成 name
private final Integer value;
private final String desc;
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AuditStatusEnum::getValue).toArray();
/**
*
* @param value
* @param desc
*/
AuditStatusEnum(Integer value, String desc) {
this.value = value;
this.desc = desc;

View File

@ -1,8 +1,8 @@
package cn.iocoder.yudao.module.crm.enums;
// TODO @liuhongfeng这个的作用是
/**
* @author 赤焰
*/
public enum ReturnTypeEnum {
}

View File

@ -30,6 +30,7 @@ import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.E
@Validated
public class CrmReceivableController {
// TODO @liuhongfengcrmReceivableService 可以使用 receivableService 在自己模块里相对简洁一点
@Resource
private CrmReceivableService crmReceivableService;

View File

@ -20,15 +20,19 @@ public class CrmReceivableBaseVO {
@Schema(description = "回款编号",requiredMode = Schema.RequiredMode.REQUIRED, example = "31177")
private String no;
// TODO @liuhongfeng回款计划编号
@Schema(description = "回款计划", example = "31177")
private Long planId;
// TODO @liuhongfeng客户编号
@Schema(description = "客户名称", example = "4963")
private Long customerId;
// TODO @liuhongfeng客户编号
@Schema(description = "合同名称", example = "30305")
private Long contractId;
// TODO @liuhongfeng这个字段应该不是前端传递的噢而是后端自己生成的
@Schema(description = "审批状态", example = "1")
@InEnum(AuditStatusEnum.class)
private Integer checkStatus;
@ -40,9 +44,10 @@ public class CrmReceivableBaseVO {
@Schema(description = "回款方式", example = "2")
private String returnType;
@Schema(description = "回款金额", example = "31859")
@Schema(description = "回款金额,单位:分", example = "31859")
private Integer price;
// TODO @liuhongfeng负责人编号
@Schema(description = "负责人", example = "22202")
private Long ownerUserId;
@ -55,6 +60,7 @@ public class CrmReceivableBaseVO {
@Schema(description = "备注", example = "备注")
private String remark;
// TODO @liuhongfeng这个字段这个字段应该不是前端传递的噢而是后端自己生成的所以不适合放在 base 里面
@Schema(description = "完成状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
private Integer status;

View File

@ -1,20 +1,14 @@
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 lombok.*;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.ExcelProperty;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
/**
* CRM 回款管理 Excel VO
*
* @author 赤焰
*/
// TODO liuhongfeng导出可以等其它功能做完统一在搞
@Data
public class CrmReceivableExcelVO {

View File

@ -8,9 +8,7 @@ import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
* @author 赤焰
*/
// TODO liuhongfeng导出可以等其它功能做完统一在搞
@Schema(description = "管理后台 - CRM 回款 Excel 导出 Request VO参数和 CrmReceivablePageReqVO 是一致的")
@Data
public class CrmReceivableExportReqVO {

View File

@ -17,6 +17,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true)
public class CrmReceivablePageReqVO extends PageParam {
// TODO @liuhongfeng可以根据需求去除掉一些不要的过滤条件另外planIdcustomerIdcontractIdownerUserId 注释不正确应该都是对应的编号
@Schema(description = "回款编号")
private String no;

View File

@ -20,6 +20,7 @@ public class CrmReceivablePlanBaseVO {
@Schema(description = "期数", example = "1")
private Integer period;
// TODO @liuhongfeng回款计划编号
@Schema(description = "回款计划", example = "19852")
private Long receivableId;
@ -44,12 +45,15 @@ 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")
private Long contractId;
// TODO @liuhongfeng负责人编号
@Schema(description = "负责人", example = "17828")
private Long ownerUserId;

View File

@ -1,15 +1,14 @@
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 lombok.*;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.ExcelProperty;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
// TODO liuhongfeng导出可以等其它功能做完统一在搞
/**
* CRM 回款计划 Excel VO
*

View File

@ -1,13 +1,14 @@
package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import org.springframework.format.annotation.DateTimeFormat;
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 {

View File

@ -17,6 +17,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true)
public class CrmReceivablePlanPageReqVO extends PageParam {
// TODO @liuhongfeng可以根据需求去除掉一些不要的过滤条件另外customerIdcontractIdownerUserId 注释不正确应该都是对应的编号
@Schema(description = "完成状态", example = "2")
private Integer status;

View File

@ -32,9 +32,12 @@ public class CrmReceivableDO extends BaseDO {
* 回款编号
*/
private String no;
// TODO @liuhongfeng对应实体参考别的模块关联 {@link TableField.MetaInfo#getJdbcType()}
/**
* 回款计划
*
* TODO @liuhongfeng这个字段什么时候更新也可以写下
*
* 对应实体 {@link CrmReceivablePlanDO}
*/
private Long planId;
@ -50,6 +53,7 @@ public class CrmReceivableDO extends BaseDO {
* 对应实体 {@link cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO}
*/
private Long contractId;
// TODO @liuhongfeng对应字典参考别的模块枚举 {@link XXXX}另外这个字段就叫 status整体状态不只审批
/**
* 审批状态
* 对应字典 {@link cn.iocoder.yudao.module.crm.enums.DictTypeConstants#CRM_RECEIVABLE_CHECK_STATUS}
@ -65,6 +69,7 @@ public class CrmReceivableDO extends BaseDO {
* 回款日期
*/
private LocalDateTime returnTime;
// TODO @liuhongfeng少个枚举
/**
* 回款方式
*/
@ -73,10 +78,12 @@ public class CrmReceivableDO extends BaseDO {
* 回款金额
*/
private Integer price;
// TODO @liuhongfeng少关联实体
/**
* 负责人
*/
private Long ownerUserId;
// TODO @liuhongfeng应该不需要 batchId 字段
/**
* 批次
*/

View File

@ -1,12 +1,13 @@
package cn.iocoder.yudao.module.crm.dal.dataobject.receivable;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 回款计划 DO
*
@ -33,26 +34,32 @@ public class CrmReceivablePlanDO extends BaseDO {
private Integer period;
/**
* 回款ID
*
* 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_RECEIVABLE_CHECK_STATUS}
* // TODO @liuhongfeng关联的枚举
*/
private Integer checkStatus;
/**
* 工作流编号
*
* TODO @liuhongfeng少关联实体
*/
private Long processInstanceId;
/**
* 计划回款金额
* 计划回款金额单位
*/
private Integer price;
/**
@ -69,14 +76,20 @@ public class CrmReceivablePlanDO extends BaseDO {
private LocalDateTime remindTime;
/**
* 客户 ID
*
* TODO @liuhongfeng少关联实体
*/
private Long customerId;
/**
* 合同 ID
*
* TODO @liuhongfeng少关联实体
*/
private Long contractId;
/**
* 负责人
* 负责人 ID
*
* TODO @liuhongfeng少关联实体
*/
private Long ownerUserId;
/**

View File

@ -27,6 +27,7 @@ import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
// TODO @liuhongfeng参考 CrmReceivableServiceImpl 写的 todo
/**
* 回款计划 Service 实现类
*

View File

@ -37,6 +37,7 @@ import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
@Validated
public class CrmReceivableServiceImpl implements CrmReceivableService {
// TODO @liuhongfengcrm 前缀变量可以不带哈
@Resource
private CrmReceivableMapper crmReceivableMapper;
@Resource
@ -46,10 +47,12 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
@Resource
private CrmReceivablePlanService crmReceivablePlanService;
// TODO @liuhongfeng创建还款后是不是什么时候要更新 plan
@Override
public Long createReceivable(CrmReceivableCreateReqVO createReqVO) {
// 插入
CrmReceivableDO receivable = CrmReceivableConvert.INSTANCE.convert(createReqVO);
// TODO @liuhongfeng这里的括号要注意排版
if (ObjectUtil.isNull(receivable.getStatus())){
receivable.setStatus(CommonStatusEnum.ENABLE.getStatus());
}
@ -57,16 +60,17 @@ public class CrmReceivableServiceImpl implements CrmReceivableService {
receivable.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue());
}
// TODO @liuhongfeng一般来说逻辑的写法是要先检查后操作 db所以你这个 check 应该放到 CrmReceivableDO receivable 之前
// 校验
checkReceivable(receivable);
crmReceivableMapper.insert(receivable);
// 返回
return receivable.getId();
}
// TODO @liuhongfeng这里的括号要注意排版
private void checkReceivable(CrmReceivableDO receivable) {
// TODO @liuhongfeng这个放在参数校验合适
if(ObjectUtil.isNull(receivable.getContractId())){
throw exception(CONTRACT_NOT_EXISTS);
}