【修改】回款计划-修改字段类型

【修改】修改回款计划-创建逻辑,添加客户的数据校验
This commit is contained in:
liuhongfeng 2023-10-29 18:00:34 +08:00
parent b0ddd522fb
commit 677e8ab2fc
8 changed files with 59 additions and 13 deletions

View File

@ -17,7 +17,7 @@ public enum AuditStatusEnum implements IntArrayValuable {
/**
* 审核通过
*/
AUDIT_FINISH(0, "审核通过"),
AUDIT_FINISH(1, "审核通过"),
/**
* 审核拒绝
*/

View File

@ -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")

View File

@ -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;

View File

@ -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)

View File

@ -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)

View File

@ -49,7 +49,7 @@ public class ReceivablePlanDO extends BaseDO {
*
* 枚举 {@link TODO crm_receivable_check_status 对应的类}
*/
private String checkStatus;
private Integer checkStatus;
/**
* 工作流编号
*/

View File

@ -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) {
// 校验存在

View File

@ -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 @liuhongfengplanId 是否存在是否合法需要去校验
// TODO @liuhongfeng其它类似 customerIdcontractId 也需要去校验
// 插入
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