|
@@ -1,5 +1,6 @@
|
|
|
package com.jzg.organization.service.impl;
|
|
package com.jzg.organization.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.collection.ListUtil;
|
|
import cn.hutool.core.collection.ListUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
@@ -29,7 +30,10 @@ import com.jzg.commons.entity.finance.po.*;
|
|
|
import com.jzg.commons.entity.finance.vo.*;
|
|
import com.jzg.commons.entity.finance.vo.*;
|
|
|
import com.jzg.commons.entity.finance.vo.importimcome.*;
|
|
import com.jzg.commons.entity.finance.vo.importimcome.*;
|
|
|
import com.jzg.commons.entity.orders.po.InsOrderAdjust;
|
|
import com.jzg.commons.entity.orders.po.InsOrderAdjust;
|
|
|
-import com.jzg.commons.entity.po.*;
|
|
|
|
|
|
|
+import com.jzg.commons.entity.po.EsmInsCompany;
|
|
|
|
|
+import com.jzg.commons.entity.po.InsFeeOrders;
|
|
|
|
|
+import com.jzg.commons.entity.po.PtlAgreement;
|
|
|
|
|
+import com.jzg.commons.entity.po.SysUploadFiles;
|
|
|
import com.jzg.commons.entity.quote.vo.orders.InsOrdersVo;
|
|
import com.jzg.commons.entity.quote.vo.orders.InsOrdersVo;
|
|
|
import com.jzg.commons.entity.vo.AgreementVo;
|
|
import com.jzg.commons.entity.vo.AgreementVo;
|
|
|
import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
|
|
import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
|
|
@@ -41,7 +45,10 @@ import com.jzg.organization.client.EsmInsCompanyClient;
|
|
|
import com.jzg.organization.client.InsFeeOrdersClient;
|
|
import com.jzg.organization.client.InsFeeOrdersClient;
|
|
|
import com.jzg.organization.client.InsOrdersClient;
|
|
import com.jzg.organization.client.InsOrdersClient;
|
|
|
import com.jzg.organization.entity.dto.CalRes;
|
|
import com.jzg.organization.entity.dto.CalRes;
|
|
|
-import com.jzg.organization.excel.listener.*;
|
|
|
|
|
|
|
+import com.jzg.organization.excel.listener.JyExcelListener;
|
|
|
|
|
+import com.jzg.organization.excel.listener.OtherExcelListener;
|
|
|
|
|
+import com.jzg.organization.excel.listener.ReceivbleExcelListener;
|
|
|
|
|
+import com.jzg.organization.excel.listener.SuperviseExcelListener;
|
|
|
import com.jzg.organization.mapper.*;
|
|
import com.jzg.organization.mapper.*;
|
|
|
import com.jzg.organization.service.ReceivableService;
|
|
import com.jzg.organization.service.ReceivableService;
|
|
|
import com.jzg.organization.service.SysUserJzgInfoSalesmanService;
|
|
import com.jzg.organization.service.SysUserJzgInfoSalesmanService;
|
|
@@ -873,12 +880,31 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 4. 根据筛选条件过滤收入数据(发票、结算时间/状态过滤)
|
|
|
|
|
- List<InsPlyIncomeDto> filterIncomeList = filterIncomeByInvoiceAndSettleCondition(incomeDtoList, settlementReportQueryVo);
|
|
|
|
|
- if (CollUtil.isEmpty(filterIncomeList)) {
|
|
|
|
|
|
|
+ List<InsPlyIncome> insPlyIncomes = BeanUtil.copyToList(incomeDtoList, InsPlyIncome.class);
|
|
|
|
|
+ // 设置disableFlag:根据签单时间的年月、companyId、partnerCompanyId查询是否存在对账数据
|
|
|
|
|
+ if (CollUtil.isNotEmpty(incomeDtoList)) {
|
|
|
|
|
+ String systemCode = baseController.getSystemCode();
|
|
|
|
|
+ setDisableFlagForOtherReceivable(insPlyIncomes, systemCode);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 根据结算状态过滤数据
|
|
|
|
|
+ String status = settlementReportQueryVo.getStatus();
|
|
|
|
|
+ String invoiceStartTime = settlementReportQueryVo.getInvoiceStartTime();
|
|
|
|
|
+ String invoiceEndTime = settlementReportQueryVo.getInvoiceEndTime();
|
|
|
|
|
+ String settleStartTime = settlementReportQueryVo.getSettlementStartTime();
|
|
|
|
|
+ String settleEndTime = settlementReportQueryVo.getSettlementEndTime();
|
|
|
|
|
+ if (StrUtil.isNotBlank(invoiceStartTime) || StrUtil.isNotBlank(invoiceEndTime)
|
|
|
|
|
+ || StrUtil.isNotBlank(settleStartTime) || StrUtil.isNotBlank(settleEndTime)
|
|
|
|
|
+ || (StrUtil.equals("0", status) || StrUtil.equals("1", status))) {
|
|
|
return resultList;
|
|
return resultList;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 如果status = 0或1,则直接返回空的filterIncomeList,如果status = 2,则查询所有ins_ply_follow_invoice_link表,过滤掉disableFlag为1 的,保留为0 的数据
|
|
|
|
|
+ List<InsPlyIncomeDto> filterIncomeList = insPlyIncomes.stream()
|
|
|
|
|
+ .filter(income -> "0".equals(income.getDisableFlag()))
|
|
|
|
|
+ .map(income -> BeanUtil.copyProperties(income, InsPlyIncomeDto.class))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
// 5. 将其他费用收入合并进结果集合
|
|
// 5. 将其他费用收入合并进结果集合
|
|
|
mergeOtherCostIncomeToResult(filterIncomeList, resultList, companyMap);
|
|
mergeOtherCostIncomeToResult(filterIncomeList, resultList, companyMap);
|
|
|
|
|
|
|
@@ -1349,7 +1375,6 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
/**
|
|
/**
|
|
|
* 为私有协议跟单费列表设置disableFlag
|
|
* 为私有协议跟单费列表设置disableFlag
|
|
|
* 根据签单时间的年月、companyId、partnerCompanyId查询ins_fee_follow_order表,有数据则disableFlag为1
|
|
* 根据签单时间的年月、companyId、partnerCompanyId查询ins_fee_follow_order表,有数据则disableFlag为1
|
|
|
- * 如果没有数据再根据年月、partnerCompanyId查询ins_fee_follow_order_reconciliation表,有数据则disableFlag为1
|
|
|
|
|
* 否则disableFlag为0
|
|
* 否则disableFlag为0
|
|
|
* @param records 应收数据列表
|
|
* @param records 应收数据列表
|
|
|
* @param systemCode 租户代码
|
|
* @param systemCode 租户代码
|
|
@@ -2453,7 +2478,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
/**
|
|
/**
|
|
|
* 导出应收开票模板
|
|
* 导出应收开票模板
|
|
|
*
|
|
*
|
|
|
- * @param type 10 表示私有协议 20 表示平台协议
|
|
|
|
|
|
|
+ * @param type 20 表示平台协议 11表示车险手续费 12 表示非车险手续费 13 表示车险跟单费 14 表示非车险跟单费
|
|
|
* @return String 导出时的提示信息
|
|
* @return String 导出时的提示信息
|
|
|
* @author lipf
|
|
* @author lipf
|
|
|
* @date 2026/8/3 10:23
|
|
* @date 2026/8/3 10:23
|
|
@@ -2463,10 +2488,34 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
log.info("导出模板: type=[{}]",type);
|
|
log.info("导出模板: type=[{}]",type);
|
|
|
// List<InvoiceReceivableExportExcelVo4Private> emptyList = ListUtil.empty();
|
|
// List<InvoiceReceivableExportExcelVo4Private> emptyList = ListUtil.empty();
|
|
|
|
|
|
|
|
- if("10".equals(type)){
|
|
|
|
|
|
|
+ if("11".equals(type)){
|
|
|
|
|
+ // 调用动态导出
|
|
|
|
|
+ return exportBaseService.upLoadFile(
|
|
|
|
|
+ ExcelContent4PrivateSuperviseCar.class,
|
|
|
|
|
+ ListUtil.empty(),
|
|
|
|
|
+ "应收开票-导出模板(私有车险手续费)-" + Instant.now()
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ if("12".equals(type)){
|
|
|
|
|
+ // 调用动态导出
|
|
|
|
|
+ return exportBaseService.upLoadFile(
|
|
|
|
|
+ ExcelContent4PrivateSuperviseNoCar.class,
|
|
|
|
|
+ ListUtil.empty(),
|
|
|
|
|
+ "应收开票-导出模板(私有非车险手续费)-" + Instant.now()
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ if("13".equals(type)){
|
|
|
|
|
+ // 调用动态导出
|
|
|
|
|
+ return exportBaseService.upLoadFile(
|
|
|
|
|
+ ExcelContent4PrivateFollow.class,
|
|
|
|
|
+ ListUtil.empty(),
|
|
|
|
|
+ "应收开票-导出模板(私有)-" + Instant.now()
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ if("14".equals(type)){
|
|
|
// 调用动态导出
|
|
// 调用动态导出
|
|
|
return exportBaseService.upLoadFile(
|
|
return exportBaseService.upLoadFile(
|
|
|
- ExcelContent4Private.class,
|
|
|
|
|
|
|
+ ExcelContent4PrivateFollow.class,
|
|
|
ListUtil.empty(),
|
|
ListUtil.empty(),
|
|
|
"应收开票-导出模板(私有)-" + Instant.now()
|
|
"应收开票-导出模板(私有)-" + Instant.now()
|
|
|
);
|
|
);
|
|
@@ -2519,7 +2568,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
String userName = baseController.getUserName();
|
|
String userName = baseController.getUserName();
|
|
|
log.info("用户[{}]导入私有应设有文件",userName);
|
|
log.info("用户[{}]导入私有应设有文件",userName);
|
|
|
|
|
|
|
|
- List<ExcelContent4Private> excelContents = importIncomeService.parseImportExcel4Private(file);
|
|
|
|
|
|
|
+ List<ExcelContent4PrivateSuperviseNoCar> excelContents = importIncomeService.parseImportExcel4Private(file);
|
|
|
if (CollUtil.isEmpty(excelContents)){
|
|
if (CollUtil.isEmpty(excelContents)){
|
|
|
throw new SystemException("数据不能为空,导入失败");
|
|
throw new SystemException("数据不能为空,导入失败");
|
|
|
}
|
|
}
|
|
@@ -3858,6 +3907,27 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
List<InsPlyIncome> updateList = new ArrayList<>();
|
|
List<InsPlyIncome> updateList = new ArrayList<>();
|
|
|
batchModifyVo.divide100();
|
|
batchModifyVo.divide100();
|
|
|
|
|
|
|
|
|
|
+ // ===================== 新增:updateAgreementId不为空时,根据新协议的withTax重新计算税率因子 =====================
|
|
|
|
|
+ String updateAgreementId = batchModifyVo.getUpdateAgreementId();
|
|
|
|
|
+ // 提前声明 agreementVo,供后面的保司信息修改逻辑复用
|
|
|
|
|
+ AgreementVo agreementVo = null;
|
|
|
|
|
+ if (StrUtil.isNotBlank(updateAgreementId)) {
|
|
|
|
|
+ agreementVo = ptlAgreementMapper.queryById(updateAgreementId);
|
|
|
|
|
+ if (null == agreementVo) {
|
|
|
|
|
+ throw new ServiceException("未找到对应协议,请检查协议配置");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 根据新协议的withTax重新计算税率因子,覆盖taxRateMap
|
|
|
|
|
+ // withTax=0(不含税)→ 税率=1.06;withTax=1(含税)→ 税率=1
|
|
|
|
|
+ String withTaxStr = agreementVo.getWithTax();
|
|
|
|
|
+ BigDecimal newTaxRate = ("0".equals(withTaxStr)) ? new BigDecimal("1.06") : BigDecimal.ONE;
|
|
|
|
|
+ for (String orderNo : orderNos) {
|
|
|
|
|
+ taxRateMap.put(orderNo, newTaxRate);
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("切换协议后,根据新协议withTax=[{}]重新设置税率因子=[{}]", withTaxStr, newTaxRate);
|
|
|
|
|
+ }
|
|
|
|
|
+ // ==============================================================================================================
|
|
|
|
|
+
|
|
|
for (InsPlyIncome income : incomeList) {
|
|
for (InsPlyIncome income : incomeList) {
|
|
|
BigDecimal taxRate = taxRateMap.getOrDefault(income.getOrderNo(), BigDecimal.ONE);
|
|
BigDecimal taxRate = taxRateMap.getOrDefault(income.getOrderNo(), BigDecimal.ONE);
|
|
|
InsPlyIncome updateIncome = new InsPlyIncome();
|
|
InsPlyIncome updateIncome = new InsPlyIncome();
|
|
@@ -3867,7 +3937,20 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
updateIncome.setJyPremium(income.getJyPremium());
|
|
updateIncome.setJyPremium(income.getJyPremium());
|
|
|
// 因为 实体对象的settlementStatus设置了初始默认值0, 为了避免已经结算的数据被调整未未结算, 这里将settlementStatus设置为null 2026-6-24 14:33:47
|
|
// 因为 实体对象的settlementStatus设置了初始默认值0, 为了避免已经结算的数据被调整未未结算, 这里将settlementStatus设置为null 2026-6-24 14:33:47
|
|
|
updateIncome.setSettlementStatus(null);
|
|
updateIncome.setSettlementStatus(null);
|
|
|
- // 根据income的order_no查询inss_fee_order
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // updateAgreementId不为空时,从ins_ply_income(income)查询比例覆盖batchModifyVo,用于后续calRatio和calPremium计算
|
|
|
|
|
+ // ins_ply_income中的比例是字符串形式的小数值(如"0.20000"),转为BigDecimal后与batchModifyVo.divide100()后的格式一致
|
|
|
|
|
+ if (StrUtil.isNotBlank(updateAgreementId)) {
|
|
|
|
|
+ batchModifyVo.setJqSuperviseCostsProportion(StrUtil.isNotBlank(income.getJqSuperviseCostsProportion()) ? new BigDecimal(income.getJqSuperviseCostsProportion()) : BigDecimal.ZERO);
|
|
|
|
|
+ batchModifyVo.setJqOtherCostsProportion(StrUtil.isNotBlank(income.getJqOtherCostsProportion()) ? new BigDecimal(income.getJqOtherCostsProportion()) : BigDecimal.ZERO);
|
|
|
|
|
+ batchModifyVo.setSySuperviseCostsProportion(StrUtil.isNotBlank(income.getSySuperviseCostsProportion()) ? new BigDecimal(income.getSySuperviseCostsProportion()) : BigDecimal.ZERO);
|
|
|
|
|
+ batchModifyVo.setSyOtherCostsProportion(StrUtil.isNotBlank(income.getSyOtherCostsProportion()) ? new BigDecimal(income.getSyOtherCostsProportion()) : BigDecimal.ZERO);
|
|
|
|
|
+ batchModifyVo.setJySuperviseCostsProportion(StrUtil.isNotBlank(income.getJySuperviseCostsProportion()) ? new BigDecimal(income.getJySuperviseCostsProportion()) : BigDecimal.ZERO);
|
|
|
|
|
+ batchModifyVo.setJyOtherCostsProportion(StrUtil.isNotBlank(income.getJyOtherCostsProportion()) ? new BigDecimal(income.getJyOtherCostsProportion()) : BigDecimal.ZERO);
|
|
|
|
|
+ log.info("切换协议后,从ins_ply_income查询比例覆盖batchModifyVo。orderNo=[{}], batchModifyVo=[{}]", income.getOrderNo(), JSONUtil.toJsonStr(batchModifyVo));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 根据income的order_no查询ins_fee_order(后续adjustmentCostAndSave需要从ins_fee_orders取完整比例)
|
|
|
List<InsFeeOrders> insFeeOrderByOrderNo = insFeeOrdersClient.getInsFeeOrderByOrderNo(income.getOrderNo());
|
|
List<InsFeeOrders> insFeeOrderByOrderNo = insFeeOrdersClient.getInsFeeOrderByOrderNo(income.getOrderNo());
|
|
|
if (CollUtil.isNotEmpty(insFeeOrderByOrderNo)){
|
|
if (CollUtil.isNotEmpty(insFeeOrderByOrderNo)){
|
|
|
InsFeeOrders insFeeOrders = CollUtil.getFirst(insFeeOrderByOrderNo);
|
|
InsFeeOrders insFeeOrders = CollUtil.getFirst(insFeeOrderByOrderNo);
|
|
@@ -3933,13 +4016,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
|
|
|
|
|
// 如果updateAgreementId不为空,则执行保司信息修改逻辑
|
|
// 如果updateAgreementId不为空,则执行保司信息修改逻辑
|
|
|
// 涉及表:ins_ply_income(未对账的才改)、ins_orders、ins_order_adjust
|
|
// 涉及表:ins_ply_income(未对账的才改)、ins_orders、ins_order_adjust
|
|
|
- String updateAgreementId = batchModifyVo.getUpdateAgreementId();
|
|
|
|
|
- if (StrUtil.isNotBlank(updateAgreementId)) {
|
|
|
|
|
- // 根据协议查询公司和子公司
|
|
|
|
|
- AgreementVo agreementVo = ptlAgreementMapper.queryById(updateAgreementId);
|
|
|
|
|
- if (null == agreementVo){
|
|
|
|
|
- throw new ServiceException("未找到对应协议,请检查协议配置");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (StrUtil.isNotBlank(updateAgreementId) && agreementVo != null) {
|
|
|
|
|
|
|
|
// 获取新的保司ID(companyIds第一个元素)和合作保险公司ID(companyIds第二个元素,若不存在则使用保司ID)
|
|
// 获取新的保司ID(companyIds第一个元素)和合作保险公司ID(companyIds第二个元素,若不存在则使用保司ID)
|
|
|
String newCompanyId = agreementVo.getCompanyId();
|
|
String newCompanyId = agreementVo.getCompanyId();
|
|
@@ -4006,6 +4083,19 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
UpdateCompanyBatchVo updateCompanyBatchVo = UpdateCompanyBatchVo.builder().batchModifyVo(batchModifyVo).agreementVo(agreementVo).build();
|
|
UpdateCompanyBatchVo updateCompanyBatchVo = UpdateCompanyBatchVo.builder().batchModifyVo(batchModifyVo).agreementVo(agreementVo).build();
|
|
|
HttpResult<String> updateCompanyRes = insOrdersClient.updateCompanyBatch(updateCompanyBatchVo);
|
|
HttpResult<String> updateCompanyRes = insOrdersClient.updateCompanyBatch(updateCompanyBatchVo);
|
|
|
log.info("修改ins_orders和ins_order_adjust保司信息的结果:updateCompanyRes=[{}]", JSONUtil.toJsonStr(updateCompanyRes));
|
|
log.info("修改ins_orders和ins_order_adjust保司信息的结果:updateCompanyRes=[{}]", JSONUtil.toJsonStr(updateCompanyRes));
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 从ins_fee_orders查询比例数据,调用adjustmentCostAndSave完整更新ins_fee_orders的所有比例和对应金额
|
|
|
|
|
+ // 此时ins_orders和ins_fee_orders的agreement_id已更新为新协议,calcCosts内部会查询到新协议的withTax
|
|
|
|
|
+ for (String orderNo : orderNos) {
|
|
|
|
|
+ List<InsFeeOrders> feeOrdersList = insFeeOrdersClient.getInsFeeOrderByOrderNo(orderNo);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(feeOrdersList)) {
|
|
|
|
|
+ InsFeeOrders feeOrders = CollUtil.getFirst(feeOrdersList);
|
|
|
|
|
+ // 使用PtlAgreementCostRatioVo的构造函数,从ins_fee_orders提取所有比例(转为百分比形式)
|
|
|
|
|
+ PtlAgreementCostRatioVo ratioVo = new PtlAgreementCostRatioVo(feeOrders);
|
|
|
|
|
+ HttpResult<InsFeeOrders> adjustResult = insFeeOrdersClient.adjustmentCostAndSave(ratioVo);
|
|
|
|
|
+ log.info("根据ins_fee_orders比例完整更新ins_fee_orders。orderNo=[{}], result=[{}]", orderNo, JSONUtil.toJsonStr(adjustResult));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|