|
|
@@ -16,6 +16,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.jzg.commons.constants.InvoiceTypeEnum;
|
|
|
import com.jzg.commons.constants.ProductsType;
|
|
|
import com.jzg.commons.constants.dict.InsOrderStatusEnum;
|
|
|
import com.jzg.commons.core.base.BaseController;
|
|
|
@@ -327,8 +328,23 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
Page<InsPlyIncome> page = baseMapper.getReceivablePage(page1, receivableQueryVo);
|
|
|
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.getReceivableAmount(), "0"))).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal totalAmount = BigDecimal.ZERO;
|
|
|
+ if (InvoiceTypeEnum.FEE_3.getCode().equals(receivableQueryVo.getInvoiceType())){
|
|
|
+ totalAmount = page.getRecords().stream()
|
|
|
+ .map(action -> new BigDecimal(Objects.toString(action.getNonCarInsuranceSuperviseCostsPremiums(), "0"))).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ } else if (InvoiceTypeEnum.FEE_4.getCode().equals(receivableQueryVo.getInvoiceType())){
|
|
|
+ totalAmount = page.getRecords().stream()
|
|
|
+ .map(action -> new BigDecimal(Objects.toString(action.getNonCarInsuranceOtherCostsPremiums(), "0"))).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ }else if (InvoiceTypeEnum.FEE_1.getCode().equals(receivableQueryVo.getInvoiceType())){
|
|
|
+ totalAmount = page.getRecords().stream()
|
|
|
+ .map(action -> new BigDecimal(Objects.toString(action.getCarInsuranceSuperviseCostsPremiums(), "0"))).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ }else if (InvoiceTypeEnum.FEE_2.getCode().equals(receivableQueryVo.getInvoiceType())){
|
|
|
+ totalAmount = page.getRecords().stream()
|
|
|
+ .map(action -> new BigDecimal(Objects.toString(action.getCarInsuranceOtherCostsPremiums(), "0"))).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ }else{
|
|
|
+ totalAmount = page.getRecords().stream()
|
|
|
+ .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));
|
|
|
@@ -4065,7 +4081,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
for (int month = 1; month <= 12; month++) {
|
|
|
InsFeeFollowOrderVo vo = buildFollowOrderVo(
|
|
|
year, month, firstItem, partnerCompanyId,
|
|
|
- monthReceivableMap, invoicedMap
|
|
|
+ monthReceivableMap, invoicedMap, followInvoicePageListVo
|
|
|
);
|
|
|
result.add(vo);
|
|
|
}
|
|
|
@@ -4195,7 +4211,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
private InsFeeFollowOrderVo buildFollowOrderVo(Integer year, int month, InsPlyIncomeDto firstItem,
|
|
|
String partnerCompanyId,
|
|
|
Map<Integer, BigDecimal> monthReceivableMap,
|
|
|
- Map<String, BigDecimal> invoicedMap) {
|
|
|
+ Map<String, BigDecimal> invoicedMap, FollowInvoicePageListVo followInvoicePageListVo) {
|
|
|
|
|
|
String systemCode = baseController.getSystemCode();
|
|
|
// 获取当月应收保费,默认为0
|
|
|
@@ -4221,6 +4237,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
.eq("month", month)
|
|
|
.eq("partner_company_id", partnerCompanyId)
|
|
|
.eq("system_code", systemCode)
|
|
|
+ .eq("invoice_type", followInvoicePageListVo.getInvoiceType())
|
|
|
.last("LIMIT 1"); // 取一条即可,或者根据业务取最新的
|
|
|
InsFeeFollowOrder dbOrder = insFeeFollowOrderMapper.selectOne(queryWrapper);
|
|
|
if (dbOrder != null) {
|
|
|
@@ -4237,6 +4254,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
.eq("month", month)
|
|
|
.eq("partner_company_id", partnerCompanyId)
|
|
|
.eq("system_code", systemCode)
|
|
|
+ .eq("invoice_type", followInvoicePageListVo.getInvoiceType())
|
|
|
.last("LIMIT 1"); // 取一条即可,或者根据业务取最新的
|
|
|
InsFeeFollowOrderReconciliation insFeeFollowOrderReconciliation = insFeeFollowOrderReconciliationMapper.selectOne(insFeeFollowOrderReconciliationQueryWrapper);
|
|
|
if (null != insFeeFollowOrderReconciliation){
|
|
|
@@ -5408,18 +5426,18 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
calRes = baseMapper.queryInvoicedAmount(systemCode, List.of(1, 3), 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));
|
|
|
+// 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> 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> 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<>();
|
|
|
+ //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()) {
|
|
|
@@ -5429,37 +5447,37 @@ 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+""));
|
|
|
+// 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.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 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());
|
|
|
+ //companySuperviseSettlementReportDto.setGdfSettledAmount(Objects.toString(gdfS, BigDecimal.ZERO+""));
|
|
|
+ //companySuperviseSettlementReportDto.setGdfUnSettledAmount(BigDecimalUtil.subtract(gdf,gdfS).toString());
|
|
|
|
|
|
// 当起始日期有值的时候,计算的没有意义
|
|
|
if(StrUtil.isNotEmpty(queryVo.getInvoiceStartTime())){
|
|
|
companySuperviseSettlementReportDto.setSxfUnInvoicedAmount("-");
|
|
|
- companySuperviseSettlementReportDto.setGdfUnInvoicedAmount("-");
|
|
|
+ //companySuperviseSettlementReportDto.setGdfUnInvoicedAmount("-");
|
|
|
companySuperviseSettlementReportDto.setPtUnInvoicedAmount("-");
|
|
|
}
|
|
|
if(StrUtil.isNotEmpty(queryVo.getSettlementStartTime())){
|
|
|
companySuperviseSettlementReportDto.setSxfUnSettledAmount("-");
|
|
|
- companySuperviseSettlementReportDto.setGdfUnSettledAmount("-");
|
|
|
+ // companySuperviseSettlementReportDto.setGdfUnSettledAmount("-");
|
|
|
}
|
|
|
}
|
|
|
return new ArrayList<>(companyMap.values().stream().toList());
|
|
|
@@ -5709,7 +5727,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
InsPlyIncomeInvoiceSettlementVo insPlyIncomeInvoiceSettlementVo = baseMapper.querySettledAmountByInvoiceIds(invoiceIdList);
|
|
|
action.setSettledAmount(Objects.toString(insPlyIncomeInvoiceSettlementVo.getActualReceivedAmount(),"0"));
|
|
|
action.setTotalPaymentDifference(insPlyIncomeInvoiceSettlementVo.getSettlementPaymentDifference());
|
|
|
- action.setUnSettledAmount(BigDecimalUtil.subtract(new BigDecimal(action.getTotalReceivable()),insPlyIncomeInvoiceSettlementVo.getActualReceivedAmount()).toString());
|
|
|
+ action.setUnSettledAmount(BigDecimalUtil.subtract(new BigDecimal(action.getTotalReceivable()),BigDecimalUtil.subtract(insPlyIncomeInvoiceSettlementVo.getActualReceivedAmount(),insPlyIncomeInvoiceSettlementVo.getSettlementPaymentDifference())).toString());
|
|
|
}else{
|
|
|
action.setSettledAmount("0");
|
|
|
action.setUnSettledAmount(BigDecimalUtil.subtract(new BigDecimal(action.getTotalReceivable()),BigDecimal.ZERO).toString());
|