|
@@ -917,8 +917,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
|
|
|
|
|
// 批量查询跟单订单
|
|
// 批量查询跟单订单
|
|
|
Map<String, InsFeeFollowOrder> followOrderMap = batchQueryFollowOrder(allFollowIds);
|
|
Map<String, InsFeeFollowOrder> followOrderMap = batchQueryFollowOrder(allFollowIds);
|
|
|
- // 批量查询未结算的开票信息
|
|
|
|
|
- Map<String, InsPlyIncomeInvoice> invoiceMap = batchQueryInvoice(allInvoiceIds);
|
|
|
|
|
|
|
+ // 批量查询未结算的结算信息
|
|
|
|
|
+ Map<String, BigDecimal> invoiceNoSettlementDecimalMap = batchQueryInvoice(allInvoiceIds);
|
|
|
// 批量查询结算单
|
|
// 批量查询结算单
|
|
|
Map<String, InsPlyIncomeInvoiceSettlement> settlementMap = batchQuerySettlement(allSettlementIds);
|
|
Map<String, InsPlyIncomeInvoiceSettlement> settlementMap = batchQuerySettlement(allSettlementIds);
|
|
|
|
|
|
|
@@ -989,12 +989,11 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
vo.setTotalUnSettlementAmount(BigDecimal.ZERO);
|
|
vo.setTotalUnSettlementAmount(BigDecimal.ZERO);
|
|
|
}else{
|
|
}else{
|
|
|
// 和wwq讨论过了,这个就是统计已开票未结算的数据
|
|
// 和wwq讨论过了,这个就是统计已开票未结算的数据
|
|
|
- BigDecimal invoiceNoSettlement = invoiceIds.stream()
|
|
|
|
|
- .map(invoiceMap::get)
|
|
|
|
|
|
|
+ BigDecimal reduce = invoiceIds.stream()
|
|
|
|
|
+ .map(invoiceNoSettlementDecimalMap::get)
|
|
|
.filter(Objects::nonNull)
|
|
.filter(Objects::nonNull)
|
|
|
- .map(InsPlyIncomeInvoice::getReceivableSupervisePremium)
|
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- vo.setTotalUnSettlementAmount(invoiceNoSettlement);
|
|
|
|
|
|
|
+ vo.setTotalUnSettlementAmount(reduce);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
aggResult.add(vo);
|
|
aggResult.add(vo);
|
|
@@ -1017,18 +1016,56 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 批量查询未结算的开票信息
|
|
|
|
|
|
|
+ * 批量查询未结算的结算信息
|
|
|
*/
|
|
*/
|
|
|
- private Map<String, InsPlyIncomeInvoice> batchQueryInvoice(Set<String> invoiceIdSet) {
|
|
|
|
|
|
|
+ private Map<String, BigDecimal> batchQueryInvoice(Set<String> invoiceIdSet) {
|
|
|
|
|
+ Map<String, BigDecimal> resultMap = new HashMap<>(0);
|
|
|
if (CollUtil.isEmpty(invoiceIdSet)) {
|
|
if (CollUtil.isEmpty(invoiceIdSet)) {
|
|
|
- return new HashMap<>(0);
|
|
|
|
|
|
|
+ return resultMap;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 1、查询有效发票主记录 status = "0"
|
|
|
LambdaQueryWrapper<InsPlyIncomeInvoice> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<InsPlyIncomeInvoice> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.in(InsPlyIncomeInvoice::getId, invoiceIdSet);
|
|
wrapper.in(InsPlyIncomeInvoice::getId, invoiceIdSet);
|
|
|
wrapper.eq(InsPlyIncomeInvoice::getStatus, "0");
|
|
wrapper.eq(InsPlyIncomeInvoice::getStatus, "0");
|
|
|
- List<InsPlyIncomeInvoice> insPlyIncomeInvoices = insPlyIncomeInvoiceMapper.selectList(wrapper);
|
|
|
|
|
- return insPlyIncomeInvoices.stream()
|
|
|
|
|
- .collect(Collectors.toMap(InsPlyIncomeInvoice::getId, Function.identity(), (k1, k2) -> k1));
|
|
|
|
|
|
|
+ List<InsPlyIncomeInvoice> invoiceList = insPlyIncomeInvoiceMapper.selectList(wrapper);
|
|
|
|
|
+ if (CollUtil.isEmpty(invoiceList)) {
|
|
|
|
|
+ return resultMap;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 取出有效发票id集合
|
|
|
|
|
+ Set<String> validInvoiceIds = invoiceList.stream()
|
|
|
|
|
+ .map(InsPlyIncomeInvoice::getId)
|
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
|
+
|
|
|
|
|
+ // 2、批量查询所有对应的结算明细
|
|
|
|
|
+ LambdaQueryWrapper<InsPlyIncomeInvoiceSettlement> settleWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ settleWrapper.in(InsPlyIncomeInvoiceSettlement::getInvoiceId, validInvoiceIds);
|
|
|
|
|
+ List<InsPlyIncomeInvoiceSettlement> settlementList = insPlyIncomeInvoiceSettlementMapper.selectList(settleWrapper);
|
|
|
|
|
+
|
|
|
|
|
+ // 3、按invoiceId分组,累加 actualReceivedAmount
|
|
|
|
|
+ Map<String, BigDecimal> sumSettleMap = settlementList.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
|
|
+ InsPlyIncomeInvoiceSettlement::getInvoiceId,
|
|
|
|
|
+ Collectors.reducing(
|
|
|
|
|
+ BigDecimal.ZERO,
|
|
|
|
|
+ InsPlyIncomeInvoiceSettlement::getActualReceivedAmount,
|
|
|
|
|
+ BigDecimal::add
|
|
|
|
|
+ )
|
|
|
|
|
+ ));
|
|
|
|
|
+
|
|
|
|
|
+ // 4、应收监管保费 - 已实收总额
|
|
|
|
|
+ for (InsPlyIncomeInvoice invoice : invoiceList) {
|
|
|
|
|
+ String invoiceId = invoice.getId();
|
|
|
|
|
+ BigDecimal receivablePremium = invoice.getReceivableSupervisePremium() == null
|
|
|
|
|
+ ? BigDecimal.ZERO
|
|
|
|
|
+ : invoice.getReceivableSupervisePremium();
|
|
|
|
|
+ BigDecimal sumActual = sumSettleMap.getOrDefault(invoiceId, BigDecimal.ZERO);
|
|
|
|
|
+ BigDecimal surplus = receivablePremium.subtract(sumActual);
|
|
|
|
|
+ resultMap.put(invoiceId, surplus);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return resultMap;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1806,6 +1843,10 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public InvoiceingResult addInvoicing(InsPlyIncomeInvoiceVO invoicingVo) {
|
|
public InvoiceingResult addInvoicing(InsPlyIncomeInvoiceVO invoicingVo) {
|
|
|
log.info("开票:invoicingVo=[{}]", JSONUtil.toJsonStr(invoicingVo));
|
|
log.info("开票:invoicingVo=[{}]", JSONUtil.toJsonStr(invoicingVo));
|
|
|
|
|
+ // add by lipf, 如果是保司开票, 设置发票号为空
|
|
|
|
|
+ if("2".equals(invoicingVo.getInvoiceType())){
|
|
|
|
|
+ invoicingVo.setInvoiceNo(null);
|
|
|
|
|
+ }
|
|
|
try {
|
|
try {
|
|
|
this.valide4Invoicing(invoicingVo);
|
|
this.valide4Invoicing(invoicingVo);
|
|
|
InvoiceingResult result = new InvoiceingResult();
|
|
InvoiceingResult result = new InvoiceingResult();
|
|
@@ -5115,6 +5156,16 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
@Override
|
|
@Override
|
|
|
public Page<ExportSuperviseSettlementExcelDto> platformSettlementExcel(Page page, SettlementQueryVo settlementQueryVo) {
|
|
public Page<ExportSuperviseSettlementExcelDto> platformSettlementExcel(Page page, SettlementQueryVo settlementQueryVo) {
|
|
|
log.info("查询平台结算记录:settlementQueryVo=[{}]", JSONUtil.toJsonStr(settlementQueryVo));
|
|
log.info("查询平台结算记录:settlementQueryVo=[{}]", JSONUtil.toJsonStr(settlementQueryVo));
|
|
|
|
|
+
|
|
|
|
|
+ if(StrUtil.isEmpty(settlementQueryVo.getSettlementDateStart())
|
|
|
|
|
+ && StrUtil.isEmpty(settlementQueryVo.getSettlementDateEnd())
|
|
|
|
|
+ && settlementQueryVo.getSettlementTime() != null &&
|
|
|
|
|
+ settlementQueryVo.getSettlementTime().length ==2){
|
|
|
|
|
+ DateUtil.parse(settlementQueryVo.getSettlementDateStart());
|
|
|
|
|
+ settlementQueryVo.setSettlementDateStart(DateUtil.format(LocalDate.parse(settlementQueryVo.getSettlementTime()[0], DateTimeFormatter.ISO_DATE).atStartOfDay(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ settlementQueryVo.setSettlementDateEnd(DateUtil.format(LocalDate.parse(settlementQueryVo.getSettlementTime()[1], DateTimeFormatter.ISO_DATE).plusDays(1).atStartOfDay(), "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 设置空条件
|
|
// 设置空条件
|
|
|
setNoneCondition(settlementQueryVo);
|
|
setNoneCondition(settlementQueryVo);
|
|
|
settlementQueryVo.setSystemCode(baseController.getSystemCode());
|
|
settlementQueryVo.setSystemCode(baseController.getSystemCode());
|