|
@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.lang.tree.Tree;
|
|
import cn.hutool.core.lang.tree.Tree;
|
|
|
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
|
import cn.hutool.core.lang.tree.TreeNodeConfig;
|
|
|
import cn.hutool.core.lang.tree.TreeUtil;
|
|
import cn.hutool.core.lang.tree.TreeUtil;
|
|
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
import com.alibaba.excel.EasyExcel;
|
|
@@ -601,6 +602,23 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
return followCompanyFeeVos;
|
|
return followCompanyFeeVos;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<FollowCompanyFeeVO> platformCompanySuperviseSettlementReport(SettlementReportQueryVo settlementReportQueryVo) {
|
|
|
|
|
+ log.info("平台协议-结算记录-结算报表: settlementReportQueryVo=[{}]", JSONUtil.toJsonStr(settlementReportQueryVo));
|
|
|
|
|
+
|
|
|
|
|
+ List<FollowCompanyFeeVO> platformCompanyFeeVos = baseMapper.selectPlatformCompanySettlementReport(settlementReportQueryVo);
|
|
|
|
|
+ // 过滤掉对接人和对接人手机号为空的数据
|
|
|
|
|
+ List<FollowCompanyFeeVO> list = platformCompanyFeeVos.stream().filter(plat -> StrUtil.isNotBlank(plat.getContactPerson()) && StrUtil.isNotBlank(plat.getContactPersonPhone())).toList();
|
|
|
|
|
+ // 查询所有保险公司,匹配保险公司的id和名称
|
|
|
|
|
+ HttpResult<Map<String, EsmInsCompany>> mapHttpResult = esmInsCompanyClient.queryAllCompanyMap();
|
|
|
|
|
+ Map<String, EsmInsCompany> data = mapHttpResult.getData();
|
|
|
|
|
+ for (FollowCompanyFeeVO platformCompanyFeeVo : list) {
|
|
|
|
|
+ platformCompanyFeeVo.setCompanyName(null != data.get(platformCompanyFeeVo.getCompanyId()) ? data.get(platformCompanyFeeVo.getCompanyId()).getName() : "");
|
|
|
|
|
+ platformCompanyFeeVo.setTotalUnSettlementAmount(BigDecimal.ZERO);
|
|
|
|
|
+ }
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* BigDecimal安全相加工具:null值转为0
|
|
* BigDecimal安全相加工具:null值转为0
|
|
|
*/
|
|
*/
|
|
@@ -1094,6 +1112,11 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
SettlementVo settlementVo = platformSettlementVo.getSettlementVo();
|
|
SettlementVo settlementVo = platformSettlementVo.getSettlementVo();
|
|
|
InvoicingVo invoicingVo = platformSettlementVo.getInvoicingVo();
|
|
InvoicingVo invoicingVo = platformSettlementVo.getInvoicingVo();
|
|
|
log.info("平台结算:platformSettlement=[{}]", JSONUtil.toJsonStr(platformSettlementVo));
|
|
log.info("平台结算:platformSettlement=[{}]", JSONUtil.toJsonStr(platformSettlementVo));
|
|
|
|
|
+
|
|
|
|
|
+ if (StrUtil.isBlank(platformSettlementVo.getInvoicingVo().getContactPerson())
|
|
|
|
|
+ || StrUtil.isBlank(platformSettlementVo.getInvoicingVo().getContactPersonPhone())){
|
|
|
|
|
+ throw new SystemException("对接人信息不能为空");
|
|
|
|
|
+ }
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
LocalDateTime settlementDateTime = LocalDateTime.parse(platformSettlementVo.getSettlementVo().getReceivePaymentDate(), formatter);
|
|
LocalDateTime settlementDateTime = LocalDateTime.parse(platformSettlementVo.getSettlementVo().getReceivePaymentDate(), formatter);
|
|
|
try {
|
|
try {
|
|
@@ -1117,6 +1140,8 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
invoice.setOverinflatedAmount(invoicingVo.getOverinflatedAmount());
|
|
invoice.setOverinflatedAmount(invoicingVo.getOverinflatedAmount());
|
|
|
invoice.setReceivableSupervisePremium(invoicingVo.getReceivablePremium());
|
|
invoice.setReceivableSupervisePremium(invoicingVo.getReceivablePremium());
|
|
|
invoice.setTaxPoint(invoicingVo.getTaxPoint());
|
|
invoice.setTaxPoint(invoicingVo.getTaxPoint());
|
|
|
|
|
+ invoice.setContactPerson(platformSettlementVo.getInvoicingVo().getContactPerson());
|
|
|
|
|
+ invoice.setContactPersonPhone(platformSettlementVo.getInvoicingVo().getContactPersonPhone());
|
|
|
|
|
|
|
|
List<InsPlyIncomeInvoiceLink> invoicingLinkList = new ArrayList<>();
|
|
List<InsPlyIncomeInvoiceLink> invoicingLinkList = new ArrayList<>();
|
|
|
|
|
|
|
@@ -2325,6 +2350,9 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
if(batchModifyVo.getJqSuperviseCostsProportion() != null && batchModifyVo.getJqOtherCostsProportion() == null){
|
|
if(batchModifyVo.getJqSuperviseCostsProportion() != null && batchModifyVo.getJqOtherCostsProportion() == null){
|
|
|
jqInletRatio = insFeeOrders .getJqInletRatio();
|
|
jqInletRatio = insFeeOrders .getJqInletRatio();
|
|
|
jqCommissionRatio = batchModifyVo.getJqSuperviseCostsProportion();
|
|
jqCommissionRatio = batchModifyVo.getJqSuperviseCostsProportion();
|
|
|
|
|
+ if (jqCommissionRatio.compareTo(jqInletRatio) > 0){
|
|
|
|
|
+ jqCommissionRatio = jqInletRatio;
|
|
|
|
|
+ }
|
|
|
jqFollowRatio = BigDecimalUtil.subtract(jqInletRatio,jqCommissionRatio);
|
|
jqFollowRatio = BigDecimalUtil.subtract(jqInletRatio,jqCommissionRatio);
|
|
|
}else if(batchModifyVo.getJqSuperviseCostsProportion() == null && batchModifyVo.getJqOtherCostsProportion() != null){
|
|
}else if(batchModifyVo.getJqSuperviseCostsProportion() == null && batchModifyVo.getJqOtherCostsProportion() != null){
|
|
|
jqCommissionRatio = BigDecimalUtil.null2Zero(insPlyIncome.getJqSuperviseCostsProportion());
|
|
jqCommissionRatio = BigDecimalUtil.null2Zero(insPlyIncome.getJqSuperviseCostsProportion());
|
|
@@ -2350,6 +2378,9 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
if(batchModifyVo.getSySuperviseCostsProportion() != null && batchModifyVo.getSyOtherCostsProportion() == null){
|
|
if(batchModifyVo.getSySuperviseCostsProportion() != null && batchModifyVo.getSyOtherCostsProportion() == null){
|
|
|
syInletRatio = insFeeOrders.getSyInletRatio();
|
|
syInletRatio = insFeeOrders.getSyInletRatio();
|
|
|
syCommissionRatio = batchModifyVo.getSySuperviseCostsProportion();
|
|
syCommissionRatio = batchModifyVo.getSySuperviseCostsProportion();
|
|
|
|
|
+ if (syCommissionRatio.compareTo(syInletRatio) > 0){
|
|
|
|
|
+ syCommissionRatio = syInletRatio;
|
|
|
|
|
+ }
|
|
|
syFollowRatio = BigDecimalUtil.subtract(syInletRatio,syCommissionRatio);
|
|
syFollowRatio = BigDecimalUtil.subtract(syInletRatio,syCommissionRatio);
|
|
|
}else if(batchModifyVo.getSySuperviseCostsProportion() == null && null != batchModifyVo.getSyOtherCostsProportion()){
|
|
}else if(batchModifyVo.getSySuperviseCostsProportion() == null && null != batchModifyVo.getSyOtherCostsProportion()){
|
|
|
syCommissionRatio = BigDecimalUtil.null2Zero(insPlyIncome.getSySuperviseCostsProportion());
|
|
syCommissionRatio = BigDecimalUtil.null2Zero(insPlyIncome.getSySuperviseCostsProportion());
|
|
@@ -2375,6 +2406,9 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
if(batchModifyVo.getJySuperviseCostsProportion() != null && batchModifyVo.getJyOtherCostsProportion() == null){
|
|
if(batchModifyVo.getJySuperviseCostsProportion() != null && batchModifyVo.getJyOtherCostsProportion() == null){
|
|
|
jyInletRatio = insFeeOrders.getJyInletRatio();
|
|
jyInletRatio = insFeeOrders.getJyInletRatio();
|
|
|
jyCommissionRatio = batchModifyVo.getJySuperviseCostsProportion();
|
|
jyCommissionRatio = batchModifyVo.getJySuperviseCostsProportion();
|
|
|
|
|
+ if (jyCommissionRatio.compareTo(jyInletRatio) > 0){
|
|
|
|
|
+ jyCommissionRatio = jyInletRatio;
|
|
|
|
|
+ }
|
|
|
jyFollowRatio = BigDecimalUtil.subtract(jyInletRatio,jyCommissionRatio);
|
|
jyFollowRatio = BigDecimalUtil.subtract(jyInletRatio,jyCommissionRatio);
|
|
|
}else if(batchModifyVo.getJySuperviseCostsProportion() == null && batchModifyVo.getJyOtherCostsProportion() != null){
|
|
}else if(batchModifyVo.getJySuperviseCostsProportion() == null && batchModifyVo.getJyOtherCostsProportion() != null){
|
|
|
jyCommissionRatio = BigDecimalUtil.null2Zero(insPlyIncome.getJySuperviseCostsProportion());
|
|
jyCommissionRatio = BigDecimalUtil.null2Zero(insPlyIncome.getJySuperviseCostsProportion());
|
|
@@ -3515,7 +3549,12 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
public Page<ExportSuperviseSettlementDetailExcelDto> superviseSettlementDetailExcel(Page page, SettlementQueryVo settlementQueryVo) {
|
|
public Page<ExportSuperviseSettlementDetailExcelDto> superviseSettlementDetailExcel(Page page, SettlementQueryVo settlementQueryVo) {
|
|
|
log.info("superviseSettlementDetailExcel:settlementQueryVo=[{}]", JSONUtil.toJsonStr(settlementQueryVo));
|
|
log.info("superviseSettlementDetailExcel:settlementQueryVo=[{}]", JSONUtil.toJsonStr(settlementQueryVo));
|
|
|
settlementQueryVo.setSystemCode(baseController.getSystemCode());
|
|
settlementQueryVo.setSystemCode(baseController.getSystemCode());
|
|
|
- Page<ExportSuperviseSettlementDetailExcelDto> exportSuperviseSettlementDetailExcelDtos = baseMapper.getSuperviseSettlementDetailExcelDtos(page, settlementQueryVo);
|
|
|
|
|
|
|
+ Page<ExportSuperviseSettlementDetailExcelDto> exportSuperviseSettlementDetailExcelDtos = null;
|
|
|
|
|
+ if (settlementQueryVo.getInvoiceTypes().contains("5") && settlementQueryVo.getInvoiceTypes().contains("6")) {
|
|
|
|
|
+ exportSuperviseSettlementDetailExcelDtos = baseMapper.getPlatFormSettlementDetailExcelDtos(page, settlementQueryVo);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ exportSuperviseSettlementDetailExcelDtos = baseMapper.getSuperviseSettlementDetailExcelDtos(page, settlementQueryVo);
|
|
|
|
|
+ }
|
|
|
exportSuperviseSettlementDetailExcelDtos.getRecords().forEach(dto -> {
|
|
exportSuperviseSettlementDetailExcelDtos.getRecords().forEach(dto -> {
|
|
|
if (dto.getInvoiceParty().equals("1")) {
|
|
if (dto.getInvoiceParty().equals("1")) {
|
|
|
dto.setInvoiceParty("我方开票");
|
|
dto.setInvoiceParty("我方开票");
|
|
@@ -3531,6 +3570,52 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
return exportSuperviseSettlementDetailExcelDtos;
|
|
return exportSuperviseSettlementDetailExcelDtos;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Page<InvoiceRecordResult> followSettlementDetailExcel(Page page, SettlementQueryVo settlementQueryVo) {
|
|
|
|
|
+ log.info("followSettlementDetailExcel:settlementQueryVo=[{}]", JSONUtil.toJsonStr(settlementQueryVo));
|
|
|
|
|
+ settlementQueryVo.setSystemCode(baseController.getSystemCode());
|
|
|
|
|
+ Page<InvoiceRecordResult> invoiceRecordResultPage = baseMapper.followSettlementDetailExcel(page, settlementQueryVo);
|
|
|
|
|
+ List<InvoiceRecordResult> records = invoiceRecordResultPage.getRecords();
|
|
|
|
|
+ if(CollUtil.isNotEmpty(records)){
|
|
|
|
|
+ Map<String, String> allCompanyHierarchyPaths = esmInsCompanyClient.getAllCompanyHierarchyPaths();
|
|
|
|
|
+ records.stream().peek(action->{
|
|
|
|
|
+ if (action.getInvoiceParty().equals("1")) {
|
|
|
|
|
+ action.setInvoiceParty("我方开票");
|
|
|
|
|
+ } else if (action.getInvoiceParty().equals("2")) {
|
|
|
|
|
+ action.setInvoiceParty("保司开票");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (action.getStatus().equals("1")) {
|
|
|
|
|
+ action.setStatus("已结算");
|
|
|
|
|
+ } else if (action.getStatus().equals("0")) {
|
|
|
|
|
+ action.setStatus("未结算");
|
|
|
|
|
+ }
|
|
|
|
|
+ String settlementStatusName = Constant.settlementStatusMap.get(Objects.toString(action.getStatus(),""));
|
|
|
|
|
+ action.setSettlementStatusName(settlementStatusName);
|
|
|
|
|
+ String invoiceRiskTypeName = Constant.invoiceRiskTypeMap.get(Objects.toString(action.getInvoiceRiskType(), ""));
|
|
|
|
|
+ action.setAccountsReceivable(invoiceRiskTypeName);
|
|
|
|
|
+ action.setInvoiceRiskTypeName(invoiceRiskTypeName);
|
|
|
|
|
+ List<InsPlyIncomeInvoiceSettlement> insPlyIncomeInvoiceSettlements = baseMapper.queryInvoiceSettlementByInvoiceId(action.getId());
|
|
|
|
|
+ BigDecimal settlementAmount = insPlyIncomeInvoiceSettlements.stream()
|
|
|
|
|
+ .map(InsPlyIncomeInvoiceSettlement::getActualReceivedAmount)
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
+ BigDecimal receivableSupervisePremium = action.getReceivableSupervisePremium() != null ? action.getReceivableSupervisePremium(): BigDecimal.ZERO;
|
|
|
|
|
+// BigDecimal overinflatedAmount = action.getOverinflatedAmount() != null? action.getOverinflatedAmount(): BigDecimal.ZERO;
|
|
|
|
|
+ // 待结算金额 = 开票金额 - 已收金额
|
|
|
|
|
+ BigDecimal remainSettlementAmount = receivableSupervisePremium.subtract(settlementAmount);
|
|
|
|
|
+ // 设置已结算的金额
|
|
|
|
|
+ action.setSettlementAmount(settlementAmount);
|
|
|
|
|
+ // 设置待结算金额
|
|
|
|
|
+ action.setRemainSettlementAmount(remainSettlementAmount);
|
|
|
|
|
+ action.setCompanyAllName(allCompanyHierarchyPaths.get(Objects.toString(action.getCompanyId(),"")));
|
|
|
|
|
+ action.setSettlementStatus(settlementStatusName);
|
|
|
|
|
+ // 开票金额
|
|
|
|
|
+ action.setReceivableAmount(action.getReceivableSupervisePremium().subtract(action.getOverinflatedAmount()).toString());
|
|
|
|
|
+ }).toList();
|
|
|
|
|
+ }
|
|
|
|
|
+ return invoiceRecordResultPage;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 导出应收手续费结算记录明细
|
|
* 导出应收手续费结算记录明细
|
|
|
*
|
|
*
|
|
@@ -4101,9 +4186,10 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
List<String> invoiceIdList = Arrays.asList(invoiceIds.split(","));
|
|
List<String> invoiceIdList = Arrays.asList(invoiceIds.split(","));
|
|
|
log.info("invoiceIdList.size=[{}]", CollUtil.size(invoiceIdList));
|
|
log.info("invoiceIdList.size=[{}]", CollUtil.size(invoiceIdList));
|
|
|
log.info("invoiceIdList=[{}]", JSONUtil.toJsonStr(invoiceIdList));
|
|
log.info("invoiceIdList=[{}]", JSONUtil.toJsonStr(invoiceIdList));
|
|
|
- BigDecimal amount = baseMapper.querySettledAmountByInvoiceIds(invoiceIdList);
|
|
|
|
|
- action.setSettledAmount(Objects.toString(amount,"0"));
|
|
|
|
|
- action.setUnSettledAmount(BigDecimalUtil.subtract(new BigDecimal(action.getTotalReceivable()),amount).toString());
|
|
|
|
|
|
|
+ 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());
|
|
|
}else{
|
|
}else{
|
|
|
action.setSettledAmount("0");
|
|
action.setSettledAmount("0");
|
|
|
action.setUnSettledAmount(BigDecimalUtil.subtract(new BigDecimal(action.getTotalReceivable()),BigDecimal.ZERO).toString());
|
|
action.setUnSettledAmount(BigDecimalUtil.subtract(new BigDecimal(action.getTotalReceivable()),BigDecimal.ZERO).toString());
|