调整征信维护为征信对象直接入库
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
package com.ruoyi.info.collection.service;
|
||||
|
||||
import com.ruoyi.info.collection.domain.CcdiBaseStaff;
|
||||
import com.ruoyi.info.collection.domain.CcdiCreditNegativeInfo;
|
||||
import com.ruoyi.info.collection.domain.CcdiDebtsInfo;
|
||||
import com.ruoyi.info.collection.domain.vo.CreditInfoUploadResultVO;
|
||||
import com.ruoyi.info.collection.mapper.CcdiBaseStaffMapper;
|
||||
import com.ruoyi.info.collection.mapper.CcdiCreditInfoQueryMapper;
|
||||
import com.ruoyi.info.collection.mapper.CcdiCreditNegativeInfoMapper;
|
||||
import com.ruoyi.info.collection.mapper.CcdiDebtsInfoMapper;
|
||||
@@ -24,7 +22,6 @@ import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -47,9 +44,6 @@ class CcdiCreditInfoServiceImplTest {
|
||||
@Mock
|
||||
private CreditInfoPayloadAssembler assembler;
|
||||
|
||||
@Mock
|
||||
private CcdiBaseStaffMapper baseStaffMapper;
|
||||
|
||||
@Mock
|
||||
private CcdiDebtsInfoMapper debtsInfoMapper;
|
||||
|
||||
@@ -60,28 +54,23 @@ class CcdiCreditInfoServiceImplTest {
|
||||
private CcdiCreditInfoQueryMapper queryMapper;
|
||||
|
||||
@Test
|
||||
void uploadHtmlFiles_shouldIsolateFailuresPerEmployee() {
|
||||
MockMultipartFile successFile = new MockMultipartFile("files", "a.html", "text/html", "<html>a</html>".getBytes(StandardCharsets.UTF_8));
|
||||
MockMultipartFile failFile = new MockMultipartFile("files", "b.html", "text/html", "<html>b</html>".getBytes(StandardCharsets.UTF_8));
|
||||
void uploadHtmlFiles_shouldStoreCreditObjectWithoutStaffBinding() {
|
||||
MockMultipartFile file = new MockMultipartFile(
|
||||
"files", "family.html", "text/html", "<html>ok</html>".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
when(creditParseClient.parse(anyString(), anyString(), any(File.class)))
|
||||
.thenReturn(successResponse("330101199001010011", "张三", "2026-03-03"))
|
||||
.thenThrow(new RuntimeException("征信解析失败"));
|
||||
when(baseStaffMapper.selectOne(any())).thenReturn(baseStaff("330101199001010011", "张三"));
|
||||
.thenReturn(successResponse("330101199202020022", "李四", "2026-03-24"));
|
||||
when(assembler.buildDebts(anyString(), anyString(), any(LocalDate.class), any(CreditParsePayload.class)))
|
||||
.thenReturn(List.of(buildDebt()));
|
||||
.thenReturn(List.of(buildDebt("330101199202020022")));
|
||||
when(assembler.buildNegative(anyString(), anyString(), any(LocalDate.class), any(CreditParsePayload.class)))
|
||||
.thenReturn(buildNegative());
|
||||
.thenReturn(buildNegative("330101199202020022"));
|
||||
|
||||
CreditInfoUploadResultVO result = service.upload(Arrays.asList(successFile, failFile));
|
||||
CreditInfoUploadResultVO result = service.upload(List.of(file));
|
||||
|
||||
assertEquals(1, result.getSuccessCount());
|
||||
assertEquals(1, result.getFailureCount());
|
||||
assertEquals("征信解析失败", result.getFailures().get(0).getReason());
|
||||
verify(debtsInfoMapper).deleteByPersonId("330101199001010011");
|
||||
verify(negativeInfoMapper).deleteByPersonId("330101199001010011");
|
||||
verify(debtsInfoMapper).insertBatch(any());
|
||||
verify(negativeInfoMapper).insert(any(CcdiCreditNegativeInfo.class));
|
||||
assertEquals(0, result.getFailureCount());
|
||||
verify(debtsInfoMapper).deleteByPersonId("330101199202020022");
|
||||
verify(negativeInfoMapper).deleteByPersonId("330101199202020022");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,7 +79,6 @@ class CcdiCreditInfoServiceImplTest {
|
||||
|
||||
when(creditParseClient.parse(anyString(), anyString(), any(File.class)))
|
||||
.thenReturn(successResponse("330101199001010011", "张三", "2026-03-03"));
|
||||
when(baseStaffMapper.selectOne(any())).thenReturn(baseStaff("330101199001010011", "张三"));
|
||||
when(queryMapper.selectLatestQueryDate("330101199001010011"))
|
||||
.thenReturn(LocalDate.parse("2026-03-05"));
|
||||
|
||||
@@ -116,23 +104,16 @@ class CcdiCreditInfoServiceImplTest {
|
||||
return response;
|
||||
}
|
||||
|
||||
private CcdiBaseStaff baseStaff(String idCard, String name) {
|
||||
CcdiBaseStaff staff = new CcdiBaseStaff();
|
||||
staff.setIdCard(idCard);
|
||||
staff.setName(name);
|
||||
return staff;
|
||||
}
|
||||
|
||||
private CcdiDebtsInfo buildDebt() {
|
||||
private CcdiDebtsInfo buildDebt(String personId) {
|
||||
CcdiDebtsInfo debt = new CcdiDebtsInfo();
|
||||
debt.setPersonId("330101199001010011");
|
||||
debt.setPersonId(personId);
|
||||
debt.setDebtTotalAmount(new BigDecimal("100"));
|
||||
return debt;
|
||||
}
|
||||
|
||||
private CcdiCreditNegativeInfo buildNegative() {
|
||||
private CcdiCreditNegativeInfo buildNegative(String personId) {
|
||||
CcdiCreditNegativeInfo info = new CcdiCreditNegativeInfo();
|
||||
info.setPersonId("330101199001010011");
|
||||
info.setPersonId(personId);
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user