|
|
@@ -29,7 +29,10 @@ import com.jzg.commons.entity.finance.po.*;
|
|
|
import com.jzg.commons.entity.finance.vo.*;
|
|
|
import com.jzg.commons.entity.finance.vo.importimcome.*;
|
|
|
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.vo.AgreementVo;
|
|
|
import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
|
|
|
@@ -41,7 +44,10 @@ import com.jzg.organization.client.EsmInsCompanyClient;
|
|
|
import com.jzg.organization.client.InsFeeOrdersClient;
|
|
|
import com.jzg.organization.client.InsOrdersClient;
|
|
|
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.service.ReceivableService;
|
|
|
import com.jzg.organization.service.SysUserJzgInfoSalesmanService;
|
|
|
@@ -3882,6 +3888,27 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
List<InsPlyIncome> updateList = new ArrayList<>();
|
|
|
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) {
|
|
|
BigDecimal taxRate = taxRateMap.getOrDefault(income.getOrderNo(), BigDecimal.ONE);
|
|
|
InsPlyIncome updateIncome = new InsPlyIncome();
|
|
|
@@ -3891,7 +3918,20 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
updateIncome.setJyPremium(income.getJyPremium());
|
|
|
// 因为 实体对象的settlementStatus设置了初始默认值0, 为了避免已经结算的数据被调整未未结算, 这里将settlementStatus设置为null 2026-6-24 14:33:47
|
|
|
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());
|
|
|
if (CollUtil.isNotEmpty(insFeeOrderByOrderNo)){
|
|
|
InsFeeOrders insFeeOrders = CollUtil.getFirst(insFeeOrderByOrderNo);
|
|
|
@@ -3957,13 +3997,7 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
|
|
|
// 如果updateAgreementId不为空,则执行保司信息修改逻辑
|
|
|
// 涉及表: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)
|
|
|
String newCompanyId = agreementVo.getCompanyId();
|
|
|
@@ -4030,6 +4064,19 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
|
|
|
UpdateCompanyBatchVo updateCompanyBatchVo = UpdateCompanyBatchVo.builder().batchModifyVo(batchModifyVo).agreementVo(agreementVo).build();
|
|
|
HttpResult<String> updateCompanyRes = insOrdersClient.updateCompanyBatch(updateCompanyBatchVo);
|
|
|
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;
|