mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 02:08:43 +08:00 
			
		
		
		
	【新增】回款计划-审批枚举类
【新增】回款计划-回款方式枚举类 【新增】回款计划-枚举类校验 【修改】回款计划-错误码调整 【修改】修改回款计划-创建逻辑,添加合同数据的校验
This commit is contained in:
		| @@ -0,0 +1,61 @@ | ||||
| package cn.iocoder.yudao.module.crm.enums; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||||
|  | ||||
| import java.util.Arrays; | ||||
|  | ||||
| /** | ||||
|  * 流程审批状态枚举类 | ||||
|  * 0 未审核 1 审核通过 2 审核拒绝 3 审核中 4 已撤回 | ||||
|  * @author 赤焰 | ||||
|  */ | ||||
| public enum AuditStatusEnum implements IntArrayValuable { | ||||
|     /** | ||||
|      * 未审批 | ||||
|      */ | ||||
|     AUDIT_NEW(0, "未审批"), | ||||
|     /** | ||||
|      * 审核通过 | ||||
|      */ | ||||
| 	AUDIT_FINISH(0, "审核通过"), | ||||
|     /** | ||||
|      * 审核拒绝 | ||||
|      */ | ||||
| 	AUDIT_REJECT(2, "审核拒绝"), | ||||
|     /** | ||||
|      * 审核中 | ||||
|      */ | ||||
|     AUDIT_DOING(3, "审核中"), | ||||
| 	/** | ||||
| 	 * 已撤回 | ||||
| 	 */ | ||||
| 	AUDIT_RETURN(4, "已撤回"); | ||||
|  | ||||
|     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; | ||||
|     } | ||||
|  | ||||
|     public Integer getValue() { | ||||
|         return value; | ||||
|     } | ||||
|  | ||||
|     public String getDesc() { | ||||
|         return desc; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int[] array() { | ||||
|         return ARRAYS; | ||||
|     } | ||||
| } | ||||
| @@ -21,9 +21,10 @@ public interface ErrorCodeConstants { | ||||
|     // ========== 联系人管理 1-020-003-000 ========== | ||||
|     ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); | ||||
|  | ||||
|     // TODO @liuhongfeng:错误码分段; | ||||
|     ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_030_000_001, "回款管理不存在"); | ||||
|     // ========== 回款管理 1-020-004-000 ========== | ||||
|     ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款管理不存在"); | ||||
|  | ||||
|     ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_040_000_001, "回款计划不存在"); | ||||
|     // ========== 合同管理 1-020-005-000 ========== | ||||
|     ErrorCode RECEIVABLE_PLAN_NOT_EXISTS = new ErrorCode(1_020_005_000, "回款计划不存在"); | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,8 @@ | ||||
| package cn.iocoder.yudao.module.crm.enums; | ||||
|  | ||||
| /** | ||||
|  * @author 赤焰 | ||||
|  */ | ||||
|  | ||||
| public enum ReturnTypeEnum { | ||||
| } | ||||
| @@ -1,5 +1,7 @@ | ||||
| package cn.iocoder.yudao.module.crm.controller.admin.receivable.vo; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.validation.InEnum; | ||||
| import cn.iocoder.yudao.module.crm.enums.AuditStatusEnum; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| @@ -33,9 +35,8 @@ public class ReceivableBaseVO { | ||||
|     @Schema(description = "合同ID", example = "30305") | ||||
|     private Long contractId; | ||||
|  | ||||
|     // TODO @liuhongfeng:这个字段,可以写个枚举,然后 InEnum 去校验下; | ||||
|     // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的 | ||||
|     @Schema(description = "审批状态", example = "1") | ||||
|     @InEnum(AuditStatusEnum.class) | ||||
|     private Integer checkStatus; | ||||
|  | ||||
|     // TODO @liuhongfeng:这个字段,应该不是前端传递的噢,而是后端自己生成的,所以不适合放在 base 里面; | ||||
|   | ||||
| @@ -2,14 +2,19 @@ package cn.iocoder.yudao.module.crm.service.receivable; | ||||
|  | ||||
| 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.pojo.PageResult; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableCreateReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivableExportReqVO; | ||||
| import cn.iocoder.yudao.module.crm.controller.admin.receivable.vo.ReceivablePageReqVO; | ||||
| 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.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 org.springframework.stereotype.Service; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
|  | ||||
| @@ -18,6 +23,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; | ||||
|  | ||||
| /** | ||||
| @@ -31,6 +37,8 @@ public class ReceivableServiceImpl implements ReceivableService { | ||||
|  | ||||
|     @Resource | ||||
|     private ReceivableMapper receivableMapper; | ||||
|     @Resource | ||||
|     private ContractService contractService; | ||||
|  | ||||
|     @Override | ||||
|     public Long createReceivable(ReceivableCreateReqVO createReqVO) { | ||||
| @@ -38,11 +46,29 @@ public class ReceivableServiceImpl implements ReceivableService { | ||||
|         // TODO @liuhongfeng:其它类似 customerId、contractId 也需要去校验; | ||||
|         // 插入 | ||||
|         ReceivableDO receivable = ReceivableConvert.INSTANCE.convert(createReqVO); | ||||
|  | ||||
|         receivable.setCheckStatus(AuditStatusEnum.AUDIT_NEW.getValue()); | ||||
|         //校验 | ||||
|         checkReceivable(receivable); | ||||
|  | ||||
|         receivableMapper.insert(receivable); | ||||
|         // 返回 | ||||
|         return receivable.getId(); | ||||
|     } | ||||
|  | ||||
|     private void checkReceivable(ReceivableDO receivable) { | ||||
|  | ||||
|         if(ObjectUtil.isNull(receivable.getContractId())){ | ||||
|             throw exception(CONTRACT_NOT_EXISTS); | ||||
|         } | ||||
|  | ||||
|         ContractDO contract = contractService.getContract(receivable.getContractId()); | ||||
|         if(ObjectUtil.isNull(contract)){ | ||||
|             throw exception(CONTRACT_NOT_EXISTS); | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateReceivable(ReceivableUpdateReqVO updateReqVO) { | ||||
|         // 校验存在 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 liuhongfeng
					liuhongfeng