|
|
@@ -328,7 +328,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
List<InsPlyIncomeOrder> res = page.getRecords().stream()
|
|
|
.map(action -> new InsPlyIncomeOrder(action.getId(), action.getOrderNo())).toList();
|
|
|
BigDecimal totalAmount = page.getRecords().stream()
|
|
|
- .map(action -> new BigDecimal(Objects.toString(action.getJyReceivablePremium(), "0"))).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ .map(action -> new BigDecimal(Objects.toString(action.getReceivableAmount(), "0"))).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
InsPlyIncomeVO vo = new InsPlyIncomeVO(null, res,Objects.toString(totalAmount,"0"));
|
|
|
log.info("获取私有/平台协议手续费应收列表的id集合。receivableQueryVo=[{}]. ids.size=[{}]", JSONUtil.toJsonStr(receivableQueryVo), CollUtil.size(res));
|
|
|
@@ -1482,7 +1482,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
default -> null;
|
|
|
};
|
|
|
// 四舍五入
|
|
|
- return result.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+// return result.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -4445,7 +4446,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
BigDecimal receivableSupervisePremium = action.getReceivableSupervisePremium() != null ? action.getReceivableSupervisePremium(): BigDecimal.ZERO;
|
|
|
// BigDecimal overinflatedAmount = action.getOverinflatedAmount() != null? action.getOverinflatedAmount(): BigDecimal.ZERO;
|
|
|
// 待结算金额 = 开票金额 - 已收金额
|
|
|
- BigDecimal remainSettlementAmount = receivableSupervisePremium.subtract(settlementAmount);
|
|
|
+ BigDecimal remainSettlementAmount = receivableSupervisePremium.subtract(BigDecimalUtil.add(settlementAmount, settlementPaymentDifference));
|
|
|
// 设置已结算的金额
|
|
|
action.setSettlementAmount(settlementAmount);
|
|
|
// 设置待结算金额
|
|
|
@@ -5389,7 +5390,11 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
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"));
|
|
|
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()) {
|
|
|
@@ -5406,16 +5411,17 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
|
|
|
CompanySuperviseSettlementReportDto dto;
|
|
|
dto = companyMap.get(companyId);
|
|
|
- companySuperviseSettlementReportDto.setSxfUnInvoicedAmount(BigDecimalUtil.subtract(new BigDecimal(dto.getSuperviseFee()),sxf).toString());
|
|
|
- companySuperviseSettlementReportDto.setGdfUnInvoicedAmount(BigDecimalUtil.subtract(new BigDecimal(dto.getFollowFee()),gdf).toString());
|
|
|
+ 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,sxfS).toString());
|
|
|
+ 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());
|
|
|
@@ -5574,6 +5580,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
tree.putExtra("gdfSettledAmount",dto.getGdfSettledAmount());
|
|
|
tree.putExtra("gdfUnSettledAmount",dto.getGdfUnSettledAmount());
|
|
|
tree.putExtra("totalOverinflatedAmount",dto.getTotalOverinflatedAmount());
|
|
|
+ tree.putExtra("settlementPaymentDifference",dto.getSettlementPaymentDifference());
|
|
|
});
|
|
|
log.info("树形结构构建:一级数据[{}]个", CollUtil.size(build));
|
|
|
return build;
|
|
|
@@ -5971,6 +5978,19 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
String userName = baseController.getUserName();
|
|
|
String systemCode = baseController.getSystemCode();
|
|
|
log.info("租户[{}]下的用户[{}]标识发票[{}]为结算完成", systemCode, userName, invoiceId);
|
|
|
+
|
|
|
+ List<InsPlyIncomeInvoiceSettlement> insPlyIncomeInvoiceSettlements = insPlyIncomeInvoiceSettlementMapper.querySettlementRecent(invoiceId);
|
|
|
+ InsPlyIncomeInvoice insPlyIncomeInvoice = insPlyIncomeInvoiceMapper.selectById(invoiceId);
|
|
|
+
|
|
|
+ // 标记结算完成的时候,将未结算金额汇总 到最后一次结算的回款差额里面 lipf 2026年7月7日10:53:47
|
|
|
+ BigDecimal settlementAmount = insPlyIncomeInvoiceSettlements.stream().map(action-> BigDecimalUtil.add(action.getSettlementPaymentDifference(), action.getActualReceivedAmount()))
|
|
|
+ .reduce(BigDecimal.ZERO,BigDecimal::add);
|
|
|
+ BigDecimal subtract = BigDecimalUtil.subtract(insPlyIncomeInvoice.getReceivableSupervisePremium(), settlementAmount);
|
|
|
+ if(subtract.compareTo(BigDecimal.ZERO) != 0){
|
|
|
+ InsPlyIncomeInvoiceSettlement insPlyIncomeInvoiceSettlement = insPlyIncomeInvoiceSettlements.get(0);
|
|
|
+ insPlyIncomeInvoiceSettlement.setSettlementPaymentDifference(BigDecimalUtil.add(subtract,insPlyIncomeInvoiceSettlement.getSettlementPaymentDifference()));
|
|
|
+ insPlyIncomeInvoiceSettlementMapper.updateById(insPlyIncomeInvoiceSettlement);
|
|
|
+ }
|
|
|
return insPlyIncomeInvoiceMapper.update(null, new LambdaUpdateWrapper<InsPlyIncomeInvoice>()
|
|
|
.set(InsPlyIncomeInvoice::getStatus,"1")
|
|
|
.set(InsPlyIncomeInvoice::getUpdateBy,userName)
|