Commit 677e8ab2fc0c50185425ba24b90d0049099ab027

Authored by liuhongfeng
1 parent b0ddd522

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

【修改】修改回款计划-创建逻辑,添加客户的数据校验
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 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 31 // TODO @liuhongfeng:这个字段,可以写个枚举,然后 InEnum 去校验下;
32 32 // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的
33 33 @Schema(description = "审批状态", example = "1")
34   - private String checkStatus;
  34 + private Integer checkStatus;
35 35  
36 36 // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面;
37 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 37  
38 38 @ExcelProperty(value = "审批状态", converter = DictConvert.class)
39 39 @DictFormat("crm_receivable_check_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
40   - private String checkStatus;
  40 + private Integer checkStatus;
41 41  
42 42 //@ExcelProperty("工作流编号")
43 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 20 private Integer status;
21 21  
22 22 @Schema(description = "审批状态", example = "1")
23   - private String checkStatus;
  23 + private Integer checkStatus;
24 24  
25 25 @Schema(description = "计划回款日期")
26 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 26 private Integer status;
27 27  
28 28 @Schema(description = "审批状态", example = "1")
29   - private String checkStatus;
  29 + private Integer checkStatus;
30 30  
31 31 @Schema(description = "计划回款日期")
32 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 49 *
50 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 10 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanPageReqVO;
11 11 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePlanUpdateReqVO;
12 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 16 import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivablePlanDO;
14 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 21 import org.springframework.stereotype.Service;
16 22 import org.springframework.validation.annotation.Validated;
17 23  
... ... @@ -20,7 +26,7 @@ import java.util.Collection;
20 26 import java.util.List;
21 27  
22 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 32 * 回款计划 Service 实现类
... ... @@ -33,20 +39,47 @@ public class ReceivablePlanServiceImpl implements ReceivablePlanService {
33 39  
34 40 @Resource
35 41 private ReceivablePlanMapper receivablePlanMapper;
  42 + @Resource
  43 + private ContractService contractService;
  44 + @Resource
  45 + private CrmCustomerService crmCustomerService;
36 46  
37 47 @Override
38 48 public Long createReceivablePlan(ReceivablePlanCreateReqVO createReqVO) {
39 49 // 插入
40 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 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 60 receivablePlanMapper.insert(receivablePlan);
46 61 // 返回
47 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 83 @Override
51 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 4 import cn.hutool.core.collection.ListUtil;
5 5 import cn.hutool.core.util.ObjectUtil;
6 6 import cn.hutool.core.util.StrUtil;
  7 +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
7 8 import cn.iocoder.yudao.framework.common.pojo.PageResult;
8 9 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableCreateReqVO;
9 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 12 import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableUpdateReqVO;
12 13 import cn.iocoder.yudao.module.crm.convert.receivable.ReceivableConvert;
13 14 import cn.iocoder.yudao.module.crm.dal.dataobject.contract.ContractDO;
  15 +import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
14 16 import cn.iocoder.yudao.module.crm.dal.dataobject.receivable.ReceivableDO;
15 17 import cn.iocoder.yudao.module.crm.dal.mysql.receivable.ReceivableMapper;
16 18 import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum;
17 19 import cn.iocoder.yudao.module.crm.service.contract.ContractService;
  20 +import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
18 21 import org.springframework.stereotype.Service;
19 22 import org.springframework.validation.annotation.Validated;
20 23  
... ... @@ -23,8 +26,7 @@ import java.util.Collection;
23 26 import java.util.List;
24 27  
25 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 32 * 回款管理 Service 实现类
... ... @@ -39,15 +41,21 @@ public class ReceivableServiceImpl implements ReceivableService {
39 41 private ReceivableMapper receivableMapper;
40 42 @Resource
41 43 private ContractService contractService;
  44 + @Resource
  45 + private CrmCustomerService crmCustomerService;
42 46  
43 47 @Override
44 48 public Long createReceivable(ReceivableCreateReqVO createReqVO) {
45 49 // TODO @liuhongfeng:planId 是否存在,是否合法,需要去校验;
46   - // TODO @liuhongfeng:其它类似 customerId、contractId 也需要去校验;
47 50 // 插入
48 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 60 checkReceivable(receivable);
53 61  
... ... @@ -67,6 +75,11 @@ public class ReceivableServiceImpl implements ReceivableService {
67 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 85 @Override
... ...