账户库中介风险等级固定为高
This commit is contained in:
@@ -49,6 +49,10 @@ public class CcdiAccountInfoServiceImpl implements ICcdiAccountInfoService {
|
||||
private static final Set<String> ACCOUNT_TYPES = Set.of("BANK", "SECURITIES", "PAYMENT", "OTHER");
|
||||
private static final Set<String> BANK_SCOPES = Set.of("INTERNAL", "EXTERNAL");
|
||||
private static final Set<String> LEVELS = Set.of("LOW", "MEDIUM", "HIGH");
|
||||
private static final String OWNER_TYPE_INTERMEDIARY = "INTERMEDIARY";
|
||||
private static final String BANK_SCOPE_EXTERNAL = "EXTERNAL";
|
||||
private static final String RISK_LEVEL_LOW = "LOW";
|
||||
private static final String RISK_LEVEL_HIGH = "HIGH";
|
||||
private final List<AccountInfoImportFailureVO> latestImportFailures = new CopyOnWriteArrayList<>();
|
||||
|
||||
@Resource
|
||||
@@ -195,12 +199,12 @@ public class CcdiAccountInfoServiceImpl implements ICcdiAccountInfoService {
|
||||
|
||||
private void validateOwner(String ownerType, String ownerId) {
|
||||
if (StringUtils.isEmpty(ownerId)) {
|
||||
if ("EXTERNAL".equals(ownerType) || "INTERMEDIARY".equals(ownerType)) {
|
||||
if ("EXTERNAL".equals(ownerType) || OWNER_TYPE_INTERMEDIARY.equals(ownerType)) {
|
||||
throw new RuntimeException("证件号不能为空");
|
||||
}
|
||||
throw new RuntimeException("所属人不能为空");
|
||||
}
|
||||
if ("EXTERNAL".equals(ownerType) || "INTERMEDIARY".equals(ownerType)) {
|
||||
if ("EXTERNAL".equals(ownerType) || OWNER_TYPE_INTERMEDIARY.equals(ownerType)) {
|
||||
return;
|
||||
}
|
||||
if ("EMPLOYEE".equals(ownerType)) {
|
||||
@@ -232,8 +236,9 @@ public class CcdiAccountInfoServiceImpl implements ICcdiAccountInfoService {
|
||||
}
|
||||
|
||||
private void prepareAnalysisFields(CcdiAccountInfo accountInfo) {
|
||||
if (!"EXTERNAL".equals(accountInfo.getBankScope())) {
|
||||
if (!BANK_SCOPE_EXTERNAL.equals(accountInfo.getBankScope())) {
|
||||
clearAnalysisFields(accountInfo);
|
||||
applyIntermediaryRiskLevel(accountInfo);
|
||||
return;
|
||||
}
|
||||
if (accountInfo.getIsActualControl() == null) {
|
||||
@@ -249,8 +254,9 @@ public class CcdiAccountInfoServiceImpl implements ICcdiAccountInfoService {
|
||||
accountInfo.setTxnFrequencyLevel("MEDIUM");
|
||||
}
|
||||
if (StringUtils.isEmpty(accountInfo.getTxnRiskLevel())) {
|
||||
accountInfo.setTxnRiskLevel("LOW");
|
||||
accountInfo.setTxnRiskLevel(RISK_LEVEL_LOW);
|
||||
}
|
||||
applyIntermediaryRiskLevel(accountInfo);
|
||||
}
|
||||
|
||||
private void clearAnalysisFields(CcdiAccountInfo accountInfo) {
|
||||
@@ -265,6 +271,12 @@ public class CcdiAccountInfoServiceImpl implements ICcdiAccountInfoService {
|
||||
accountInfo.setTxnRiskLevel(null);
|
||||
}
|
||||
|
||||
private void applyIntermediaryRiskLevel(CcdiAccountInfo accountInfo) {
|
||||
if (OWNER_TYPE_INTERMEDIARY.equals(accountInfo.getOwnerType())) {
|
||||
accountInfo.setTxnRiskLevel(RISK_LEVEL_HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateAmount(BigDecimal amount, String fieldLabel) {
|
||||
if (amount == null) {
|
||||
return;
|
||||
@@ -285,6 +297,7 @@ public class CcdiAccountInfoServiceImpl implements ICcdiAccountInfoService {
|
||||
addDTO.setTxnFrequencyLevel(toUpper(addDTO.getTxnFrequencyLevel()));
|
||||
addDTO.setTxnRiskLevel(toUpper(addDTO.getTxnRiskLevel()));
|
||||
addDTO.setOwnerId(normalizeOwnerId(addDTO.getOwnerId()));
|
||||
applyIntermediaryRiskLevel(addDTO);
|
||||
}
|
||||
|
||||
private void normalizeEditDto(CcdiAccountInfoEditDTO editDTO) {
|
||||
@@ -295,6 +308,19 @@ public class CcdiAccountInfoServiceImpl implements ICcdiAccountInfoService {
|
||||
editDTO.setTxnFrequencyLevel(toUpper(editDTO.getTxnFrequencyLevel()));
|
||||
editDTO.setTxnRiskLevel(toUpper(editDTO.getTxnRiskLevel()));
|
||||
editDTO.setOwnerId(normalizeOwnerId(editDTO.getOwnerId()));
|
||||
applyIntermediaryRiskLevel(editDTO);
|
||||
}
|
||||
|
||||
private void applyIntermediaryRiskLevel(CcdiAccountInfoAddDTO addDTO) {
|
||||
if (OWNER_TYPE_INTERMEDIARY.equals(addDTO.getOwnerType())) {
|
||||
addDTO.setTxnRiskLevel(RISK_LEVEL_HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
private void applyIntermediaryRiskLevel(CcdiAccountInfoEditDTO editDTO) {
|
||||
if (OWNER_TYPE_INTERMEDIARY.equals(editDTO.getOwnerType())) {
|
||||
editDTO.setTxnRiskLevel(RISK_LEVEL_HIGH);
|
||||
}
|
||||
}
|
||||
|
||||
private String normalizeCurrency(String currency) {
|
||||
@@ -362,7 +388,8 @@ public class CcdiAccountInfoServiceImpl implements ICcdiAccountInfoService {
|
||||
|
||||
private CcdiAccountInfoAddDTO toAddDto(CcdiAccountInfoExcel excel) {
|
||||
CcdiAccountInfoAddDTO dto = new CcdiAccountInfoAddDTO();
|
||||
dto.setOwnerType(parseOwnerType(excel.getOwnerType()));
|
||||
String ownerType = parseOwnerType(excel.getOwnerType());
|
||||
dto.setOwnerType(ownerType);
|
||||
dto.setOwnerId(normalizeOwnerId(excel.getOwnerId()));
|
||||
dto.setAccountName(trimToNull(excel.getAccountName()));
|
||||
dto.setAccountNo(trimToNull(excel.getAccountNo()));
|
||||
@@ -382,7 +409,9 @@ public class CcdiAccountInfoServiceImpl implements ICcdiAccountInfoService {
|
||||
dto.setCreditSingleMaxAmount(parseDecimal(excel.getCreditSingleMaxAmount()));
|
||||
dto.setDebitDailyMaxAmount(parseDecimal(excel.getDebitDailyMaxAmount()));
|
||||
dto.setCreditDailyMaxAmount(parseDecimal(excel.getCreditDailyMaxAmount()));
|
||||
dto.setTxnRiskLevel(parseLevel(excel.getTxnRiskLevel(), "风险等级"));
|
||||
dto.setTxnRiskLevel(OWNER_TYPE_INTERMEDIARY.equals(ownerType)
|
||||
? RISK_LEVEL_HIGH
|
||||
: parseLevel(excel.getTxnRiskLevel(), "风险等级"));
|
||||
return dto;
|
||||
}
|
||||
|
||||
@@ -418,7 +447,7 @@ public class CcdiAccountInfoServiceImpl implements ICcdiAccountInfoService {
|
||||
return "RELATION";
|
||||
}
|
||||
if ("中介".equals(value)) {
|
||||
return "INTERMEDIARY";
|
||||
return OWNER_TYPE_INTERMEDIARY;
|
||||
}
|
||||
if ("外部人员".equals(value)) {
|
||||
return "EXTERNAL";
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ruoyi.info.collection.service;
|
||||
import com.ruoyi.info.collection.domain.CcdiAccountInfo;
|
||||
import com.ruoyi.info.collection.domain.CcdiBaseStaff;
|
||||
import com.ruoyi.info.collection.domain.dto.CcdiAccountInfoAddDTO;
|
||||
import com.ruoyi.info.collection.domain.excel.CcdiAccountInfoExcel;
|
||||
import com.ruoyi.info.collection.mapper.CcdiAccountInfoMapper;
|
||||
import com.ruoyi.info.collection.mapper.CcdiBaseStaffMapper;
|
||||
import com.ruoyi.info.collection.mapper.CcdiStaffFmyRelationMapper;
|
||||
@@ -16,6 +17,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.beans.BeanWrapperImpl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
@@ -109,6 +111,64 @@ class CcdiAccountInfoServiceImplTest {
|
||||
assertNull(wrapper.getPropertyValue("txnRiskLevel"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void insertInternalIntermediaryAccount_shouldForceHighRiskLevelOnAccountInfo() {
|
||||
CcdiAccountInfoAddDTO dto = buildBaseAddDto();
|
||||
dto.setOwnerType("INTERMEDIARY");
|
||||
dto.setOwnerId("91330100MA00000001");
|
||||
dto.setBankScope("INTERNAL");
|
||||
dto.setIsActualControl(1);
|
||||
dto.setAvgMonthTxnCount(8);
|
||||
dto.setAvgMonthTxnAmount(new BigDecimal("9988.66"));
|
||||
dto.setTxnFrequencyLevel("HIGH");
|
||||
dto.setDebitSingleMaxAmount(new BigDecimal("111.11"));
|
||||
dto.setCreditSingleMaxAmount(new BigDecimal("222.22"));
|
||||
dto.setDebitDailyMaxAmount(new BigDecimal("333.33"));
|
||||
dto.setCreditDailyMaxAmount(new BigDecimal("444.44"));
|
||||
dto.setTxnRiskLevel("LOW");
|
||||
|
||||
when(accountInfoMapper.selectCount(any())).thenReturn(0L);
|
||||
when(accountInfoMapper.insert(any(CcdiAccountInfo.class))).thenReturn(1);
|
||||
|
||||
service.insertAccountInfo(dto);
|
||||
|
||||
ArgumentCaptor<CcdiAccountInfo> captor = ArgumentCaptor.forClass(CcdiAccountInfo.class);
|
||||
verify(accountInfoMapper).insert(captor.capture());
|
||||
BeanWrapperImpl wrapper = new BeanWrapperImpl(captor.getValue());
|
||||
assertNull(wrapper.getPropertyValue("isActualControl"));
|
||||
assertNull(wrapper.getPropertyValue("avgMonthTxnCount"));
|
||||
assertNull(wrapper.getPropertyValue("avgMonthTxnAmount"));
|
||||
assertNull(wrapper.getPropertyValue("txnFrequencyLevel"));
|
||||
assertEquals("HIGH", wrapper.getPropertyValue("txnRiskLevel"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void importExternalIntermediaryAccount_shouldForceHighRiskLevelOnAccountInfo() {
|
||||
CcdiAccountInfoExcel excel = new CcdiAccountInfoExcel();
|
||||
excel.setOwnerType("中介");
|
||||
excel.setOwnerId("91330100MA00000002");
|
||||
excel.setAccountName("测试中介");
|
||||
excel.setAccountNo("6222024000000099");
|
||||
excel.setAccountType("银行账户");
|
||||
excel.setBankScope("行外");
|
||||
excel.setOpenBank("中国银行");
|
||||
excel.setBankCode("BOC");
|
||||
excel.setCurrency("CNY");
|
||||
excel.setStatus("正常");
|
||||
excel.setEffectiveDate("2026-07-10");
|
||||
excel.setTxnRiskLevel("LOW");
|
||||
|
||||
when(accountInfoMapper.selectOne(any())).thenReturn(null);
|
||||
when(accountInfoMapper.selectCount(any())).thenReturn(0L);
|
||||
when(accountInfoMapper.insert(any(CcdiAccountInfo.class))).thenReturn(1);
|
||||
|
||||
service.importAccountInfo(List.of(excel), false);
|
||||
|
||||
ArgumentCaptor<CcdiAccountInfo> captor = ArgumentCaptor.forClass(CcdiAccountInfo.class);
|
||||
verify(accountInfoMapper).insert(captor.capture());
|
||||
assertEquals("HIGH", captor.getValue().getTxnRiskLevel());
|
||||
}
|
||||
|
||||
private CcdiAccountInfoAddDTO buildBaseAddDto() {
|
||||
CcdiAccountInfoAddDTO dto = new CcdiAccountInfoAddDTO();
|
||||
dto.setAccountNo("6222024000000001");
|
||||
|
||||
Reference in New Issue
Block a user