Commit 4a58ae34 by zhangxingmin

push

parent 16cb097b
...@@ -198,6 +198,7 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia ...@@ -198,6 +198,7 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia
// 改为使用列表保存转换信息,按顺序匹配 // 改为使用列表保存转换信息,按顺序匹配
List<ConvertInfo> convertInfoList = new ArrayList<>(); List<ConvertInfo> convertInfoList = new ArrayList<>();
// 调试:记录每个对账记录的详细信息
for (Map.Entry<String, List<ApiPremiumRemittanceDto>> entry : reconciliationRemittanceMap.entrySet()) { for (Map.Entry<String, List<ApiPremiumRemittanceDto>> entry : reconciliationRemittanceMap.entrySet()) {
String reconciliationBizId = entry.getKey(); String reconciliationBizId = entry.getKey();
List<ApiPremiumRemittanceDto> remittanceDtos = entry.getValue(); List<ApiPremiumRemittanceDto> remittanceDtos = entry.getValue();
...@@ -214,9 +215,17 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia ...@@ -214,9 +215,17 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia
continue; continue;
} }
log.info("开始处理对账记录: {}, 保单: {}, 保单币种: {}, 汇款记录数: {}", log.info("处理对账记录: {}, 保单: {}, 保单币种: {}, 汇款记录数: {}",
reconciliationBizId, policyNo, policyCurrency, remittanceDtos.size()); reconciliationBizId, policyNo, policyCurrency, remittanceDtos.size());
// 打印所有汇款记录详情
for (int i = 0; i < remittanceDtos.size(); i++) {
ApiPremiumRemittanceDto dto = remittanceDtos.get(i);
log.info("汇款记录 {}: ID={}, 金额={}, 币种={}, 日期={}",
i, dto.getPremiumRemittanceBizId(), dto.getPaymentAmount(),
dto.getPaymentCurrency(), dto.getPaymentDate());
}
// 初始化总金额 // 初始化总金额
BigDecimal totalAmount = BigDecimal.ZERO; BigDecimal totalAmount = BigDecimal.ZERO;
String paymentCurrency = policyCurrency; String paymentCurrency = policyCurrency;
...@@ -230,11 +239,11 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia ...@@ -230,11 +239,11 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia
if (policyCurrency.equalsIgnoreCase(remittanceCurrency)) { if (policyCurrency.equalsIgnoreCase(remittanceCurrency)) {
totalAmount = totalAmount.add(amount); totalAmount = totalAmount.add(amount);
sameCurrencyCount++; sameCurrencyCount++;
log.debug("相同币种汇款记录: {} {}", amount, remittanceCurrency); log.info("相同币种汇款记录: {} {}", amount, remittanceCurrency);
} }
} }
log.debug("相同币种汇款记录数: {}, 累计金额: {}", sameCurrencyCount, totalAmount); log.info("相同币种汇款记录数: {}, 累计金额: {}", sameCurrencyCount, totalAmount);
// 然后处理需要转换的汇款记录 // 然后处理需要转换的汇款记录
int convertCount = 0; int convertCount = 0;
...@@ -248,7 +257,8 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia ...@@ -248,7 +257,8 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia
} }
convertCount++; convertCount++;
log.debug("需要转换的汇款记录: {} {} -> {}", amount, remittanceCurrency, policyCurrency); log.info("需要转换的汇款记录: ID={}, 金额={} {}, 目标币种={}",
remittanceDto.getPremiumRemittanceBizId(), amount, remittanceCurrency, policyCurrency);
// 构建转换请求 // 构建转换请求
ApiExchangeRateConvertRequest convertRequest = new ApiExchangeRateConvertRequest(); ApiExchangeRateConvertRequest convertRequest = new ApiExchangeRateConvertRequest();
...@@ -283,9 +293,12 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia ...@@ -283,9 +293,12 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia
info.targetCurrency = policyCurrency; info.targetCurrency = policyCurrency;
info.requestId = requestId; // 保存requestId,如果汇率服务返回则使用 info.requestId = requestId; // 保存requestId,如果汇率服务返回则使用
convertInfoList.add(info); convertInfoList.add(info);
log.debug("添加转换请求: requestId={}, {} {} -> {}",
requestId, amount, remittanceCurrency, policyCurrency);
} }
log.debug("需要转换的汇款记录数: {}", convertCount); log.info("需要转换的汇款记录数: {}", convertCount);
// 先保存相同币种的累计金额 // 先保存相同币种的累计金额
totalAmount = totalAmount.setScale(2, RoundingMode.HALF_EVEN); totalAmount = totalAmount.setScale(2, RoundingMode.HALF_EVEN);
...@@ -309,9 +322,20 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia ...@@ -309,9 +322,20 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia
log.info("发送第 {} 批汇率转换请求,共 {} 条", i/batchSize + 1, batch.size()); log.info("发送第 {} 批汇率转换请求,共 {} 条", i/batchSize + 1, batch.size());
// 记录每个请求的详细信息
for (ApiExchangeRateConvertRequest req : batch) {
log.info("转换请求: requestId={}, 金额={}, 从{}到{}",
req.getRequestId(), req.getAmount(), req.getFromCurrency(), req.getToCurrency());
}
Result<List<ApiExchangeRateConvertResponse>> batchResult = Result<List<ApiExchangeRateConvertResponse>> batchResult =
apiExchangeRateFeignClient.batchConvert(batch); apiExchangeRateFeignClient.batchConvert(batch);
log.info("汇率转换服务返回: code={}, message={}, 数据量={}",
batchResult != null ? batchResult.getCode() : "null",
batchResult != null ? batchResult.getMsg() : "null",
batchResult != null && batchResult.getData() != null ? batchResult.getData().size() : 0);
if (batchResult != null && batchResult.getCode() == 200 && if (batchResult != null && batchResult.getCode() == 200 &&
!CollectionUtils.isEmpty(batchResult.getData())) { !CollectionUtils.isEmpty(batchResult.getData())) {
...@@ -320,6 +344,13 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia ...@@ -320,6 +344,13 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia
// 处理转换结果 - 使用顺序匹配 // 处理转换结果 - 使用顺序匹配
List<ApiExchangeRateConvertResponse> responses = batchResult.getData(); List<ApiExchangeRateConvertResponse> responses = batchResult.getData();
// 记录每个响应的详细信息
for (ApiExchangeRateConvertResponse resp : responses) {
log.info("转换响应: requestId={}, 原金额={} {}, 转换金额={} {}",
resp.getRequestId(), resp.getOriginalAmount(), resp.getOriginalCurrency(),
resp.getConvertedAmount(), resp.getTargetCurrency());
}
// 确保响应数量与请求数量一致 // 确保响应数量与请求数量一致
if (responses.size() != batch.size()) { if (responses.size() != batch.size()) {
log.warn("汇率转换响应数量({})与请求数量({})不一致,可能无法正确匹配", log.warn("汇率转换响应数量({})与请求数量({})不一致,可能无法正确匹配",
...@@ -337,6 +368,8 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia ...@@ -337,6 +368,8 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia
for (ConvertInfo ci : convertInfoList) { for (ConvertInfo ci : convertInfoList) {
if (convertResponse.getRequestId().equals(ci.requestId)) { if (convertResponse.getRequestId().equals(ci.requestId)) {
info = ci; info = ci;
log.info("通过requestId匹配成功: requestId={}, 对账记录ID={}",
convertResponse.getRequestId(), info.reconciliationBizId);
break; break;
} }
} }
...@@ -345,13 +378,14 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia ...@@ -345,13 +378,14 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia
// 如果通过requestId没有找到,则使用顺序匹配 // 如果通过requestId没有找到,则使用顺序匹配
if (info == null && j < batchConvertInfos.size()) { if (info == null && j < batchConvertInfos.size()) {
info = batchConvertInfos.get(j); info = batchConvertInfos.get(j);
log.info("尝试顺序匹配: 批次索引={}, 对账记录ID={}", j, info.reconciliationBizId);
} }
if (info != null && convertResponse.getConvertedAmount() != null) { if (info != null && convertResponse.getConvertedAmount() != null) {
BigDecimal currentTotal = totalPaymentAmounts.getOrDefault(info.reconciliationBizId, BigDecimal.ZERO); BigDecimal currentTotal = totalPaymentAmounts.getOrDefault(info.reconciliationBizId, BigDecimal.ZERO);
BigDecimal convertedAmount = convertResponse.getConvertedAmount(); BigDecimal convertedAmount = convertResponse.getConvertedAmount();
log.debug("汇率转换结果: {} {} -> {} {}, 汇率={}", log.info("汇率转换结果: {} {} -> {} {}, 汇率={}",
convertResponse.getOriginalAmount(), convertResponse.getOriginalCurrency(), convertResponse.getOriginalAmount(), convertResponse.getOriginalCurrency(),
convertedAmount, convertResponse.getTargetCurrency(), convertResponse.getExchangeRate()); convertedAmount, convertResponse.getTargetCurrency(), convertResponse.getExchangeRate());
...@@ -360,7 +394,7 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia ...@@ -360,7 +394,7 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia
BigDecimal newTotal = currentTotal.add(convertedAmount); BigDecimal newTotal = currentTotal.add(convertedAmount);
totalPaymentAmounts.put(info.reconciliationBizId, newTotal); totalPaymentAmounts.put(info.reconciliationBizId, newTotal);
log.debug("对账记录 {} 累加后总金额: {} (之前: {} + 转换: {})", log.info("对账记录 {} 累加后总金额: {} (之前: {} + 转换: {})",
info.reconciliationBizId, newTotal, currentTotal, convertedAmount); info.reconciliationBizId, newTotal, currentTotal, convertedAmount);
} else { } else {
log.warn("转换结果缺少必要信息或无法匹配: requestId={}, info={}, convertedAmount={}", log.warn("转换结果缺少必要信息或无法匹配: requestId={}, info={}, convertedAmount={}",
...@@ -402,6 +436,11 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia ...@@ -402,6 +436,11 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia
} }
} }
// 调试:打印所有对账记录的总付款金额
for (Map.Entry<String, BigDecimal> entry : totalPaymentAmounts.entrySet()) {
log.info("对账记录 {} 最终总付款金额: {}", entry.getKey(), entry.getValue());
}
// 更新分页响应 // 更新分页响应
int updatedCount = 0; int updatedCount = 0;
for (ApiPremiumReconciliationPageResponse item : iPage.getRecords()) { for (ApiPremiumReconciliationPageResponse item : iPage.getRecords()) {
...@@ -422,7 +461,7 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia ...@@ -422,7 +461,7 @@ public class ApiPremiumReconciliationServiceImpl implements ApiPremiumReconcilia
} }
updatedCount++; updatedCount++;
} else { } else {
log.debug("对账记录 {} 没有找到付款金额汇总", reconciliationBizId); log.info("对账记录 {} 没有找到付款金额汇总", reconciliationBizId);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment