|
|
@@ -5273,8 +5273,26 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
String systemCode = baseController.getSystemCode();
|
|
|
log.info("保险公司结算报表查询-区分租户并且按照日期进行过滤:systemCode=[{}],queryVo=[{}]", systemCode, JSONUtil.toJsonStr(queryVo));
|
|
|
// 1. 先将有数据的保险公司进行汇总
|
|
|
- // 累计应收金额, 应收手续费(手续费), 应收手续费(手续费)
|
|
|
+ // 累计应收金额, 应收手续费(手续费)
|
|
|
List<CompanySuperviseSettlementReportDto> allCompaniesIncomeDatas = baseMapper.queryCumulativeAccountsReceivable(systemCode, queryVo);
|
|
|
+
|
|
|
+ // 车险
|
|
|
+ if("10".equals(queryVo.getAccountsReceivable())){
|
|
|
+ // 默认情况下,superviseFee 得到的就是车险的手续费
|
|
|
+ allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().toList();
|
|
|
+ }else if("20".equals(queryVo.getAccountsReceivable())){
|
|
|
+ allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().peek(action->{
|
|
|
+ // 统计非车的手续费
|
|
|
+ action.setSuperviseFee(action.getSuperviseFee4Other());
|
|
|
+ }).toList();
|
|
|
+ }else if(StrUtil.isEmpty(queryVo.getAccountsReceivable())){
|
|
|
+ // 统计总的手续费
|
|
|
+ allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().peek(action->{
|
|
|
+ // 统计非车的手续费
|
|
|
+ action.setSuperviseFee(action.getTotalReceivable());
|
|
|
+ }).toList();
|
|
|
+ }
|
|
|
+
|
|
|
// for test, 查看一家公司的数据,将不可变对象变成 可变对象
|
|
|
// allCompaniesIncomeDatas = allCompaniesIncomeDatas.stream().filter(action-> "1738811735599338932".equals(action.getCompanyId())).toList();
|
|
|
// allCompaniesIncomeDatas = new ArrayList<>(allCompaniesIncomeDatas);
|
|
|
@@ -5310,20 +5328,12 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
BigDecimal totalReceivable = groupList.stream()
|
|
|
.map(x -> new BigDecimal(x.getTotalReceivable()))
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal totalFollowFee = groupList.stream()
|
|
|
- .map(x -> new BigDecimal(x.getTotalFollowFee()))
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+
|
|
|
BigDecimal superviseFee = groupList.stream()
|
|
|
.map(x -> new BigDecimal(x.getSuperviseFee()))
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal followFee = groupList.stream()
|
|
|
- .map(x -> new BigDecimal(x.getFollowFee()))
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
-
|
|
|
sumDto.setTotalReceivable(totalReceivable.toString());
|
|
|
- sumDto.setTotalFollowFee(totalFollowFee.toString());
|
|
|
sumDto.setSuperviseFee(superviseFee.toString());
|
|
|
- sumDto.setFollowFee(followFee.toString());
|
|
|
sumDto.setParentId(first.getParentId());
|
|
|
resultList.add(sumDto);
|
|
|
}
|
|
|
@@ -5422,22 +5432,25 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
// 已开票(手续费)
|
|
|
// 已开票(跟单费)
|
|
|
|
|
|
+ List<String> invoiceTypes = List.of("1","3");
|
|
|
+
|
|
|
+
|
|
|
+ if("10".equals(queryVo.getAccountsReceivable())){
|
|
|
+ invoiceTypes = List.of("1");
|
|
|
+ }else if("20".equals(queryVo.getAccountsReceivable())){
|
|
|
+ invoiceTypes = List.of("3");
|
|
|
+ }
|
|
|
+
|
|
|
List<CalRes> calRes;
|
|
|
- calRes = baseMapper.queryInvoicedAmount(systemCode, List.of(1, 3), queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime(), queryVo.getAgreementType());
|
|
|
+ calRes = baseMapper.queryInvoicedAmount(systemCode, invoiceTypes, queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime(), queryVo.getAgreementType());
|
|
|
Map<String, BigDecimal> sxfInvoicedAmountMap = calRes.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getAmount, (o1,o2)->o1));
|
|
|
Map<String, BigDecimal> sxfOverinflatedAmountMap = calRes.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getOverinflatedAmount, (o1,o2)->o1));
|
|
|
-// calRes = baseMapper.queryInvoicedAmount(systemCode, List.of(2, 4), queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime(), queryVo.getAgreementType());
|
|
|
-// Map<String, BigDecimal> gdfInvoicedAmountMap = calRes.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getAmount, (o1,o2)->o1));
|
|
|
|
|
|
// 结算费用
|
|
|
- List<CalRes> sxfList = baseMapper.querySettledAmount(systemCode, queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime(), queryVo.getAgreementType(), CollUtil.newArrayList("1", "3"));
|
|
|
- // List<CalRes> gdfList = baseMapper.querySettledAmount(systemCode, queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime(), queryVo.getAgreementType(), CollUtil.newArrayList("2", "4"));
|
|
|
+ List<CalRes> sxfList = baseMapper.querySettledAmount(systemCode, queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime(), queryVo.getAgreementType(), invoiceTypes);
|
|
|
Map<String, BigDecimal> sxfSettledAmountMap = CollUtil.isNotEmpty(sxfList) ? sxfList.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getSettlement, (o1,o2)->o1)) : new HashMap<>();
|
|
|
// 手续费的回款差额汇总
|
|
|
Map<String, BigDecimal> sxfSettledDiffAmountMap = CollUtil.isNotEmpty(sxfList) ? sxfList.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getOverinflatedAmount, (o1,o2)->o1)) : new HashMap<>();
|
|
|
- //Map<String, BigDecimal> gdfSettledAmountMap = CollUtil.isNotEmpty(gdfList) ? gdfList.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getSettlement, (o1,o2)->o1)) : new HashMap<>();
|
|
|
- // 跟单费的回款差额汇总
|
|
|
- //Map<String, BigDecimal> gdfSettledDiffAmountMap = CollUtil.isNotEmpty(gdfList) ? gdfList.stream().collect(Collectors.toMap(CalRes::getCompanyId, CalRes::getOverinflatedAmount, (o1,o2)->o1)) : new HashMap<>();
|
|
|
|
|
|
// 计算已开票和未开票
|
|
|
for (String companyId : companyMap.keySet()) {
|
|
|
@@ -5447,37 +5460,27 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
companySuperviseSettlementReportDto.setSxfInvoicedAmount(Objects.toString(sxf,BigDecimal.ZERO+""));
|
|
|
BigDecimal sxfOverinflatedAmount = sxfOverinflatedAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
|
|
|
companySuperviseSettlementReportDto.setTotalOverinflatedAmount(Objects.toString(sxfOverinflatedAmount,BigDecimal.ZERO+""));
|
|
|
-// BigDecimal gdf = gdfInvoicedAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
|
|
|
- //companySuperviseSettlementReportDto.setGdfInvoicedAmount(Objects.toString(gdf,BigDecimal.ZERO+""));
|
|
|
// 平台就没有未结算的,只要结算就是已结算的
|
|
|
companySuperviseSettlementReportDto.setPtInvoicedAmount(companySuperviseSettlementReportDto.getTotalReceivable());
|
|
|
|
|
|
CompanySuperviseSettlementReportDto dto;
|
|
|
dto = companyMap.get(companyId);
|
|
|
companySuperviseSettlementReportDto.setSxfUnInvoicedAmount(BigDecimalUtil.subtract(new BigDecimal(dto.getSuperviseFee()),BigDecimalUtil.subtract(sxf, new BigDecimal(dto.getTotalOverinflatedAmount()))).toString());
|
|
|
- //companySuperviseSettlementReportDto.setGdfUnInvoicedAmount(BigDecimalUtil.subtract(new BigDecimal(dto.getFollowFee()),BigDecimalUtil.subtract(gdf,new BigDecimal(dto.getTotalOverinflatedAmount()))).toString());
|
|
|
companySuperviseSettlementReportDto.setPtUnInvoicedAmount(BigDecimal.ZERO.toString());
|
|
|
|
|
|
BigDecimal sxfS = sxfSettledAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
|
|
|
- //BigDecimal gdfS = gdfSettledAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
|
|
|
BigDecimal overinflatedAmount = sxfOverinflatedAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
|
|
|
companySuperviseSettlementReportDto.setSxfSettledAmount(Objects.toString(sxfS, BigDecimal.ZERO+""));
|
|
|
companySuperviseSettlementReportDto.setSxfUnSettledAmount(BigDecimalUtil.subtract(sxf,BigDecimalUtil.add(sxfS,sxfSettledDiffAmountMap.getOrDefault(companyId, BigDecimal.ZERO))).toString());
|
|
|
companySuperviseSettlementReportDto.setTotalOverinflatedAmount(Objects.toString(overinflatedAmount, BigDecimal.ZERO+""));
|
|
|
companySuperviseSettlementReportDto.setSettlementPaymentDifference(Objects.toString(sxfSettledDiffAmountMap.getOrDefault(companyId, BigDecimal.ZERO)) );
|
|
|
-
|
|
|
- //companySuperviseSettlementReportDto.setGdfSettledAmount(Objects.toString(gdfS, BigDecimal.ZERO+""));
|
|
|
- //companySuperviseSettlementReportDto.setGdfUnSettledAmount(BigDecimalUtil.subtract(gdf,gdfS).toString());
|
|
|
-
|
|
|
// 当起始日期有值的时候,计算的没有意义
|
|
|
if(StrUtil.isNotEmpty(queryVo.getInvoiceStartTime())){
|
|
|
companySuperviseSettlementReportDto.setSxfUnInvoicedAmount("-");
|
|
|
- //companySuperviseSettlementReportDto.setGdfUnInvoicedAmount("-");
|
|
|
companySuperviseSettlementReportDto.setPtUnInvoicedAmount("-");
|
|
|
}
|
|
|
if(StrUtil.isNotEmpty(queryVo.getSettlementStartTime())){
|
|
|
companySuperviseSettlementReportDto.setSxfUnSettledAmount("-");
|
|
|
- // companySuperviseSettlementReportDto.setGdfUnSettledAmount("-");
|
|
|
}
|
|
|
}
|
|
|
return new ArrayList<>(companyMap.values().stream().toList());
|
|
|
@@ -5608,6 +5611,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
tree.setParentId(dto.getParentId());
|
|
|
// 将原对象的其他属性放入扩展字段
|
|
|
tree.putExtra("companyName",dto.getCompanyName());
|
|
|
+ tree.putExtra("companyId",dto.getCompanyId());
|
|
|
tree.putExtra("totalReceivable",dto.getTotalReceivable());
|
|
|
tree.putExtra("totalFollowFee",dto.getTotalFollowFee());
|
|
|
tree.putExtra("superviseFee",dto.getSuperviseFee());
|
|
|
@@ -5624,6 +5628,9 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
tree.putExtra("gdfUnSettledAmount",dto.getGdfUnSettledAmount());
|
|
|
tree.putExtra("totalOverinflatedAmount",dto.getTotalOverinflatedAmount());
|
|
|
tree.putExtra("settlementPaymentDifference",dto.getSettlementPaymentDifference());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
});
|
|
|
log.info("树形结构构建:一级数据[{}]个", CollUtil.size(build));
|
|
|
return build;
|