修改抵押物类型自动判断逻辑

This commit is contained in:
wkc
2026-08-10 15:53:41 +08:00
parent 739a73c6ee
commit 3667a3cf78
7 changed files with 335 additions and 37 deletions

View File

@@ -65,8 +65,8 @@ public class CorporateLoanPricingCreateDTO implements Serializable {
@Schema(description = "贸易和建筑业企业标识", example = "0")
private String isTradeBuildEnt;
@Schema(description = "抵质押类型", example = "一类", allowableValues = {"一类", "二类", "三类", "四类", "排污权抵押", "设备等其他不动产抵押", "存单质押", "股权质押", "其他质押"})
@Pattern(regexp = "^(一类|二类|三类|四类|排污权抵押|设备等其他不动产抵押|存单质押|股权质押|其他质押)$", message = "抵质押类型必须是:一类、二类、三类、四类、排污权抵押、设备等其他不动产抵押、存单质押、股权质押、其他质押之一")
@Schema(description = "抵质押类型", example = "一类", allowableValues = {"一类", "二类", "三类", "排污权抵押", "其他不动产抵押", "存单质押", "股权质押", "其他质押"})
@Pattern(regexp = "^(一类|二类|三类|排污权抵押|其他不动产抵押|存单质押|股权质押|其他质押)$", message = "抵质押类型必须是:一类、二类、三类、排污权抵押、其他不动产抵押、存单质押、股权质押、其他质押之一")
private String collType;
@Schema(description = "抵质押物是否三方所有", example = "0")

View File

@@ -56,7 +56,7 @@ public class PersonalLoanPricingCreateDTO implements Serializable {
@Schema(description = "循环功能", example = "0")
private String loanLoop;
@Schema(description = "抵质押类型", example = "一类", allowableValues = {"线", "", "二类", "三类", "存单质押", "其他质押"})
@Schema(description = "抵质押类型", example = "一类", allowableValues = {"一类", "二类", "三类", "四类", "存单质押", "其他质押"})
private String collType;
@Schema(description = "抵质押物是否三方所有", example = "0")

View File

@@ -139,8 +139,8 @@ public class LoanPricingWorkflowServiceImpl implements ILoanPricingWorkflowServi
private void validatePersonalCollateralType(LoanPricingWorkflow workflow) {
if ("抵押".equals(workflow.getGuarType())
&& !isOneOf(workflow.getCollType(), "线", "", "二类", "三类")) {
throw new ServiceException("个人抵押抵质押类型必须是:一线、一类、二类、三类之一");
&& !isOneOf(workflow.getCollType(), "一类", "二类", "三类", "四类")) {
throw new ServiceException("个人抵押抵质押类型必须是:一类、二类、三类、四类之一");
}
if ("质押".equals(workflow.getGuarType())
&& !isOneOf(workflow.getCollType(), "存单质押", "其他质押")) {
@@ -150,8 +150,8 @@ public class LoanPricingWorkflowServiceImpl implements ILoanPricingWorkflowServi
private void validateCorporateCollateralType(LoanPricingWorkflow workflow) {
if ("抵押".equals(workflow.getGuarType())
&& !isOneOf(workflow.getCollType(), "一类", "二类", "三类", "四类", "排污权抵押", "设备等其他不动产抵押")) {
throw new ServiceException("企业抵押抵质押类型必须是:一类、二类、三类、四类、排污权抵押、设备等其他不动产抵押之一");
&& !isOneOf(workflow.getCollType(), "一类", "二类", "三类", "排污权抵押", "其他不动产抵押")) {
throw new ServiceException("企业抵押抵质押类型必须是:一类、二类、三类、排污权抵押、其他不动产抵押之一");
}
if ("质押".equals(workflow.getGuarType())
&& !isOneOf(workflow.getCollType(), "存单质押", "股权质押", "其他质押")) {

View File

@@ -290,36 +290,67 @@ class LoanPricingWorkflowServiceImplTest
}
@Test
void shouldAllowPersonalMortgageOneLineAndRejectOldOther()
void shouldAllowPersonalMortgageFourthCategoryAndRejectOldFirstLine()
{
LoanPricingWorkflow allowedWorkflow = validWorkflow();
allowedWorkflow.setCustType("个人");
allowedWorkflow.setGuarType("抵押");
allowedWorkflow.setCollType("一线");
allowedWorkflow.setCollType("四类");
loanPricingWorkflowService.createLoanPricing(allowedWorkflow);
LoanPricingWorkflow rejectedWorkflow = validWorkflow();
rejectedWorkflow.setCustType("个人");
rejectedWorkflow.setGuarType("抵押");
rejectedWorkflow.setCollType("其他");
rejectedWorkflow.setCollType("一线");
ServiceException exception = assertThrows(ServiceException.class,
() -> loanPricingWorkflowService.createLoanPricing(rejectedWorkflow));
assertEquals("个人抵押抵质押类型必须是:一线、一类、二类、三类之一", exception.getMessage());
assertEquals("个人抵押抵质押类型必须是:一类、二类、三类、四类之一", exception.getMessage());
}
@Test
void shouldAllowCorporateMortgagePollutionRightAndPledgeEquity()
void shouldAllowCorporateNewMortgageTypesAndRejectOldMortgageTypes()
{
LoanPricingWorkflow mortgageWorkflow = validWorkflow();
mortgageWorkflow.setCustType("企业");
mortgageWorkflow.setGuarType("抵押");
mortgageWorkflow.setCollType("排污权抵押");
LoanPricingWorkflow pollutionRightWorkflow = validWorkflow();
pollutionRightWorkflow.setCustType("企业");
pollutionRightWorkflow.setGuarType("抵押");
pollutionRightWorkflow.setCollType("排污权抵押");
loanPricingWorkflowService.createLoanPricing(mortgageWorkflow);
loanPricingWorkflowService.createLoanPricing(pollutionRightWorkflow);
LoanPricingWorkflow otherRealEstateWorkflow = validWorkflow();
otherRealEstateWorkflow.setCustType("企业");
otherRealEstateWorkflow.setGuarType("抵押");
otherRealEstateWorkflow.setCollType("其他不动产抵押");
loanPricingWorkflowService.createLoanPricing(otherRealEstateWorkflow);
LoanPricingWorkflow oldFourthCategoryWorkflow = validWorkflow();
oldFourthCategoryWorkflow.setCustType("企业");
oldFourthCategoryWorkflow.setGuarType("抵押");
oldFourthCategoryWorkflow.setCollType("四类");
ServiceException fourthCategoryException = assertThrows(ServiceException.class,
() -> loanPricingWorkflowService.createLoanPricing(oldFourthCategoryWorkflow));
LoanPricingWorkflow oldOtherRealEstateWorkflow = validWorkflow();
oldOtherRealEstateWorkflow.setCustType("企业");
oldOtherRealEstateWorkflow.setGuarType("抵押");
oldOtherRealEstateWorkflow.setCollType("设备等其他不动产抵押");
ServiceException otherRealEstateException = assertThrows(ServiceException.class,
() -> loanPricingWorkflowService.createLoanPricing(oldOtherRealEstateWorkflow));
String expectedMessage = "企业抵押抵质押类型必须是:一类、二类、三类、排污权抵押、其他不动产抵押之一";
assertEquals(expectedMessage, fourthCategoryException.getMessage());
assertEquals(expectedMessage, otherRealEstateException.getMessage());
}
@Test
void shouldKeepCorporatePledgeTypesUnchanged()
{
LoanPricingWorkflow pledgeWorkflow = validWorkflow();
pledgeWorkflow.setCustType("企业");
pledgeWorkflow.setGuarType("质押");