Commit 677e8ab2fc0c50185425ba24b90d0049099ab027
1 parent
b0ddd522
【修改】回款计划-修改字段类型
【修改】修改回款计划-创建逻辑,添加客户的数据校验
Showing
8 changed files
with
59 additions
and
13 deletions
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 { | @@ -17,7 +17,7 @@ public enum AuditStatusEnum implements IntArrayValuable { | ||
| 17 | /** | 17 | /** |
| 18 | * 审核通过 | 18 | * 审核通过 |
| 19 | */ | 19 | */ |
| 20 | - AUDIT_FINISH(0, "审核通过"), | 20 | + AUDIT_FINISH(1, "审核通过"), |
| 21 | /** | 21 | /** |
| 22 | * 审核拒绝 | 22 | * 审核拒绝 |
| 23 | */ | 23 | */ |
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 { | @@ -31,7 +31,7 @@ public class ReceivablePlanBaseVO { | ||
| 31 | // TODO @liuhongfeng:这个字段,可以写个枚举,然后 InEnum 去校验下; | 31 | // TODO @liuhongfeng:这个字段,可以写个枚举,然后 InEnum 去校验下; |
| 32 | // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的 | 32 | // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的 |
| 33 | @Schema(description = "审批状态", example = "1") | 33 | @Schema(description = "审批状态", example = "1") |
| 34 | - private String checkStatus; | 34 | + private Integer checkStatus; |
| 35 | 35 | ||
| 36 | // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; | 36 | // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; |
| 37 | @Schema(description = "工作流编号", example = "8909") | 37 | @Schema(description = "工作流编号", example = "8909") |
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 { | @@ -37,7 +37,7 @@ public class ReceivablePlanExcelVO { | ||
| 37 | 37 | ||
| 38 | @ExcelProperty(value = "审批状态", converter = DictConvert.class) | 38 | @ExcelProperty(value = "审批状态", converter = DictConvert.class) |
| 39 | @DictFormat("crm_receivable_check_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 | 39 | @DictFormat("crm_receivable_check_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 |
| 40 | - private String checkStatus; | 40 | + private Integer checkStatus; |
| 41 | 41 | ||
| 42 | //@ExcelProperty("工作流编号") | 42 | //@ExcelProperty("工作流编号") |
| 43 | //private Long processInstanceId; | 43 | //private Long processInstanceId; |
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 { | @@ -20,7 +20,7 @@ public class ReceivablePlanExportReqVO { | ||
| 20 | private Integer status; | 20 | private Integer status; |
| 21 | 21 | ||
| 22 | @Schema(description = "审批状态", example = "1") | 22 | @Schema(description = "审批状态", example = "1") |
| 23 | - private String checkStatus; | 23 | + private Integer checkStatus; |
| 24 | 24 | ||
| 25 | @Schema(description = "计划回款日期") | 25 | @Schema(description = "计划回款日期") |
| 26 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | 26 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
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 { | @@ -26,7 +26,7 @@ public class ReceivablePlanPageReqVO extends PageParam { | ||
| 26 | private Integer status; | 26 | private Integer status; |
| 27 | 27 | ||
| 28 | @Schema(description = "审批状态", example = "1") | 28 | @Schema(description = "审批状态", example = "1") |
| 29 | - private String checkStatus; | 29 | + private Integer checkStatus; |
| 30 | 30 | ||
| 31 | @Schema(description = "计划回款日期") | 31 | @Schema(description = "计划回款日期") |
| 32 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | 32 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
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 { | @@ -49,7 +49,7 @@ public class ReceivablePlanDO extends BaseDO { | ||
| 49 | * | 49 | * |
| 50 | * 枚举 {@link TODO crm_receivable_check_status 对应的类} | 50 | * 枚举 {@link TODO crm_receivable_check_status 对应的类} |
| 51 | */ | 51 | */ |
| 52 | - private String checkStatus; | 52 | + private Integer checkStatus; |
| 53 | /** | 53 | /** |
| 54 | * 工作流编号 | 54 | * 工作流编号 |
| 55 | */ | 55 | */ |
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 | @@ -10,8 +10,14 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlan | ||
| 10 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanPageReqVO; | 10 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanPageReqVO; |
| 11 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanUpdateReqVO; | 11 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanUpdateReqVO; |
| 12 | import cn.iocoder.yudao.module.crm.convert.receivable.ReceivablePlanConvert; | 12 | import cn.iocoder.yudao.module.crm.convert.receivable.ReceivablePlanConvert; |
| 13 | +import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; | ||
| 14 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||
| 15 | +import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; | ||
| 13 | import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; | 16 | import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO; |
| 14 | import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivablePlanMapper; | 17 | import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivablePlanMapper; |
| 18 | +import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; | ||
| 19 | +import cn.iocoder.yudao.module.crm.service.contract.ContractService; | ||
| 20 | +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; | ||
| 15 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
| 16 | import org.springframework.validation.annotation.Validated; | 22 | import org.springframework.validation.annotation.Validated; |
| 17 | 23 | ||
| @@ -20,7 +26,7 @@ import java.util.Collection; | @@ -20,7 +26,7 @@ import java.util.Collection; | ||
| 20 | import java.util.List; | 26 | import java.util.List; |
| 21 | 27 | ||
| 22 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 28 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 23 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_PLAN_NOT_EXISTS; | 29 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; |
| 24 | 30 | ||
| 25 | /** | 31 | /** |
| 26 | * 回款计划 Service 实现类 | 32 | * 回款计划 Service 实现类 |
| @@ -33,20 +39,47 @@ public class ReceivablePlanServiceImpl implements ReceivablePlanService { | @@ -33,20 +39,47 @@ public class ReceivablePlanServiceImpl implements ReceivablePlanService { | ||
| 33 | 39 | ||
| 34 | @Resource | 40 | @Resource |
| 35 | private ReceivablePlanMapper receivablePlanMapper; | 41 | private ReceivablePlanMapper receivablePlanMapper; |
| 42 | + @Resource | ||
| 43 | + private ContractService contractService; | ||
| 44 | + @Resource | ||
| 45 | + private CrmCustomerService crmCustomerService; | ||
| 36 | 46 | ||
| 37 | @Override | 47 | @Override |
| 38 | public Long createReceivablePlan(ReceivablePlanCreateReqVO createReqVO) { | 48 | public Long createReceivablePlan(ReceivablePlanCreateReqVO createReqVO) { |
| 39 | // 插入 | 49 | // 插入 |
| 40 | ReceivablePlanDO receivablePlan = ReceivablePlanConvert.INSTANCE.convert(createReqVO); | 50 | ReceivablePlanDO receivablePlan = ReceivablePlanConvert.INSTANCE.convert(createReqVO); |
| 41 | - // TODO @liuhongfeng:空格要注释;if (ObjectUtil.isNull(receivablePlan.getStatus())) { | ||
| 42 | - if(ObjectUtil.isNull(receivablePlan.getStatus())){ | 51 | + if (ObjectUtil.isNull(receivablePlan.getStatus())){ |
| 43 | receivablePlan.setStatus(CommonStatusEnum.ENABLE.getStatus()); | 52 | receivablePlan.setStatus(CommonStatusEnum.ENABLE.getStatus()); |
| 44 | } | 53 | } |
| 54 | + if (ObjectUtil.isNull(receivablePlan.getCheckStatus())){ | ||
| 55 | + receivablePlan.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue()); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + checkReceivablePlan(receivablePlan); | ||
| 59 | + | ||
| 45 | receivablePlanMapper.insert(receivablePlan); | 60 | receivablePlanMapper.insert(receivablePlan); |
| 46 | // 返回 | 61 | // 返回 |
| 47 | return receivablePlan.getId(); | 62 | return receivablePlan.getId(); |
| 48 | } | 63 | } |
| 49 | 64 | ||
| 65 | + private void checkReceivablePlan(ReceivablePlanDO receivablePlan) { | ||
| 66 | + | ||
| 67 | + if(ObjectUtil.isNull(receivablePlan.getContractId())){ | ||
| 68 | + throw exception(CONTRACT_NOT_EXISTS); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + ContractDO contract = contractService.getContract(receivablePlan.getContractId()); | ||
| 72 | + if(ObjectUtil.isNull(contract)){ | ||
| 73 | + throw exception(CONTRACT_NOT_EXISTS); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + CrmCustomerDO customer = crmCustomerService.getCustomer(receivablePlan.getCustomerId()); | ||
| 77 | + if(ObjectUtil.isNull(customer)){ | ||
| 78 | + throw exception(CUSTOMER_NOT_EXISTS); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + } | ||
| 82 | + | ||
| 50 | @Override | 83 | @Override |
| 51 | public void updateReceivablePlan(ReceivablePlanUpdateReqVO updateReqVO) { | 84 | public void updateReceivablePlan(ReceivablePlanUpdateReqVO updateReqVO) { |
| 52 | // 校验存在 | 85 | // 校验存在 |
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; | @@ -4,6 +4,7 @@ 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; | 5 | import cn.hutool.core.util.ObjectUtil; |
| 6 | import cn.hutool.core.util.StrUtil; | 6 | import cn.hutool.core.util.StrUtil; |
| 7 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 8 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableCreateReqVO; | 9 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableCreateReqVO; |
| 9 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableExportReqVO; | 10 | 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 | @@ -11,10 +12,12 @@ import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePage | ||
| 11 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableUpdateReqVO; | 12 | import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableUpdateReqVO; |
| 12 | import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; | 13 | import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert; |
| 13 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; | 14 | import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO; |
| 15 | +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO; | ||
| 14 | import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; | 16 | import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO; |
| 15 | import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; | 17 | import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper; |
| 16 | import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; | 18 | import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; |
| 17 | import cn.iocoder.yudao.module.crm.service.contract.ContractService; | 19 | import cn.iocoder.yudao.module.crm.service.contract.ContractService; |
| 20 | +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService; | ||
| 18 | import org.springframework.stereotype.Service; | 21 | import org.springframework.stereotype.Service; |
| 19 | import org.springframework.validation.annotation.Validated; | 22 | import org.springframework.validation.annotation.Validated; |
| 20 | 23 | ||
| @@ -23,8 +26,7 @@ import java.util.Collection; | @@ -23,8 +26,7 @@ import java.util.Collection; | ||
| 23 | import java.util.List; | 26 | import java.util.List; |
| 24 | 27 | ||
| 25 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 28 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 26 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTRACT_NOT_EXISTS; | ||
| 27 | -import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.RECEIVABLE_NOT_EXISTS; | 29 | +import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; |
| 28 | 30 | ||
| 29 | /** | 31 | /** |
| 30 | * 回款管理 Service 实现类 | 32 | * 回款管理 Service 实现类 |
| @@ -39,15 +41,21 @@ public class ReceivableServiceImpl implements ReceivableService { | @@ -39,15 +41,21 @@ public class ReceivableServiceImpl implements ReceivableService { | ||
| 39 | private ReceivableMapper receivableMapper; | 41 | private ReceivableMapper receivableMapper; |
| 40 | @Resource | 42 | @Resource |
| 41 | private ContractService contractService; | 43 | private ContractService contractService; |
| 44 | + @Resource | ||
| 45 | + private CrmCustomerService crmCustomerService; | ||
| 42 | 46 | ||
| 43 | @Override | 47 | @Override |
| 44 | public Long createReceivable(ReceivableCreateReqVO createReqVO) { | 48 | public Long createReceivable(ReceivableCreateReqVO createReqVO) { |
| 45 | // TODO @liuhongfeng:planId 是否存在,是否合法,需要去校验; | 49 | // TODO @liuhongfeng:planId 是否存在,是否合法,需要去校验; |
| 46 | - // TODO @liuhongfeng:其它类似 customerId、contractId 也需要去校验; | ||
| 47 | // 插入 | 50 | // 插入 |
| 48 | ReceivableDO receivable = ReceivableConvert.INSTANCE.convert(createReqVO); | 51 | ReceivableDO receivable = ReceivableConvert.INSTANCE.convert(createReqVO); |
| 52 | + if (ObjectUtil.isNull(receivable.getStatus())){ | ||
| 53 | + receivable.setStatus(CommonStatusEnum.ENABLE.getStatus()); | ||
| 54 | + } | ||
| 55 | + if (ObjectUtil.isNull(receivable.getCheckStatus())){ | ||
| 56 | + receivable.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue()); | ||
| 57 | + } | ||
| 49 | 58 | ||
| 50 | - receivable.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue()); | ||
| 51 | //校验 | 59 | //校验 |
| 52 | checkReceivable(receivable); | 60 | checkReceivable(receivable); |
| 53 | 61 | ||
| @@ -67,6 +75,11 @@ public class ReceivableServiceImpl implements ReceivableService { | @@ -67,6 +75,11 @@ public class ReceivableServiceImpl implements ReceivableService { | ||
| 67 | throw exception(CONTRACT_NOT_EXISTS); | 75 | throw exception(CONTRACT_NOT_EXISTS); |
| 68 | } | 76 | } |
| 69 | 77 | ||
| 78 | + CrmCustomerDO customer = crmCustomerService.getCustomer(receivable.getCustomerId()); | ||
| 79 | + if(ObjectUtil.isNull(customer)){ | ||
| 80 | + throw exception(CUSTOMER_NOT_EXISTS); | ||
| 81 | + } | ||
| 82 | + | ||
| 70 | } | 83 | } |
| 71 | 84 | ||
| 72 | @Override | 85 | @Override |