فهرست منبع

Merge remote-tracking branch 'origin/dev_jzg_lipf_v20260622' into dev_jzg_lipf_v20260622

# Conflicts:
#	tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java
lipf 3 ماه پیش
والد
کامیت
67ec8b6df2

+ 14 - 11
commons/src/main/java/com/jzg/commons/entity/finance/vo/BatchModifyVo.java

@@ -28,17 +28,17 @@ public class BatchModifyVo {
     @Schema(description = "商业手续费比例")
     private BigDecimal sySuperviseCostsProportion;
 
-//    @Schema(description = "驾意手续费比例")
-//    private BigDecimal jySuperviseCostsProportion;
-//
-//    @Schema(description = "交强跟单费比例")
-//    private BigDecimal jqOtherCostsProportion;
-//
-//    @Schema(description = "商业跟单费比例")
-//    private BigDecimal syOtherCostsProportion;
-//
-//    @Schema(description = "驾意跟单费比例")
-//    private BigDecimal jyOtherCostsProportion;
+    @Schema(description = "驾意手续费比例")
+    private BigDecimal jySuperviseCostsProportion;
+
+    @Schema(description = "交强跟单费比例")
+    private BigDecimal jqOtherCostsProportion;
+
+    @Schema(description = "商业跟单费比例")
+    private BigDecimal syOtherCostsProportion;
+
+    @Schema(description = "驾意跟单费比例")
+    private BigDecimal jyOtherCostsProportion;
 
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     @Schema(description = "签单时间")
@@ -53,4 +53,7 @@ public class BatchModifyVo {
     @Schema(description = "对接人手机号")
     private String contractPhone;
 
+    @Schema(description = "修改标识 1-手续费 2-跟单费 3-驾意险 4-所有都改")
+    private String updateFlag;
+
 }

+ 7 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsFeeAuditServiceImpl.java

@@ -56,6 +56,7 @@ import org.springframework.stereotype.Service;
 
 import java.io.File;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.Instant;
 import java.time.LocalDateTime;
 import java.util.*;
@@ -882,6 +883,12 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
     @Override
     public String exportAuditList(FeeAuditParam param) {
         List<FeeAuditVo> result = queryList(param);
+        for (FeeAuditVo feeAuditVo : result) {
+            feeAuditVo.setTotalPayablePremium(feeAuditVo.getTotalPayablePremium().setScale(2, RoundingMode.HALF_UP));
+            feeAuditVo.setJyPayablePremium(feeAuditVo.getJyPayablePremium().setScale(2, RoundingMode.HALF_UP));
+            feeAuditVo.setSyPayablePremium(feeAuditVo.getSyPayablePremium().setScale(2, RoundingMode.HALF_UP));
+            feeAuditVo.setJqPayablePremium(feeAuditVo.getJqPayablePremium().setScale(2, RoundingMode.HALF_UP));
+        }
 
         // 调用动态导出
         return exportBaseService.upLoadFile(

+ 5 - 0
tenant/organization/src/main/java/com/jzg/organization/mapper/ReceivableMapper.java

@@ -204,6 +204,11 @@ public interface ReceivableMapper extends BaseMapper<InsPlyIncome> {
      */
     Map<String, Object> getJqSumReceivable(@Param("orderNos") List<String> orderNos);
 
+    /**
+     * 获取应收交强的总金额
+     */
+    Map<String, Object> getIncomeJqSumReceivable(@Param("orderNos") List<String> orderNos);
+
     /**
      * 获取开票记录
      */

+ 253 - 75
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -25,6 +25,7 @@ import com.jzg.commons.entity.finance.po.*;
 import com.jzg.commons.entity.finance.vo.*;
 import com.jzg.commons.entity.orders.po.InsOrderAdjust;
 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;
@@ -59,6 +60,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.math.RoundingMode;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -767,8 +769,11 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 .map(String::trim)
                 .distinct() // 可选,去重
                 .collect(Collectors.toList());
+        // 根据tz要求将从ins_fee_order查费用信息改为从income表查
+        Map<String, Object> map = baseMapper.getIncomeJqSumReceivable(orderNos);
+
         // 修改后(返回总手续费 = 交强险+商业险+驾意险 手续费之和)
-        Map<String, Object> map = baseMapper.getJqSumReceivable(orderNos);
+//        Map<String, Object> map = baseMapper.getJqSumReceivable(orderNos);
         if(map == null){
             // 订单不存在的时候,直接返回0
             log.info("订单不存在。 orderNos=[{}]", JSONUtil.toJsonStr(orderNos));
@@ -1542,25 +1547,26 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         linkQueryWrapper.eq(InsPlyIncomeInvoiceLink::getIsDelete, SETTLE_STATUS_RESET);
         List<InsPlyIncomeInvoiceLink> linkList = insPlyIncomeInvoiceLinkMapper.selectList(linkQueryWrapper);
 
-        // 提取incomeId列表
-        List<String> incomeIdList = linkList.stream()
-                .map(InsPlyIncomeInvoiceLink::getIncomeId)
-                .distinct()
-                .collect(Collectors.toList());
-
-        // 构造更新条件,增加主表逻辑删除过滤
         LambdaUpdateWrapper<InsPlyIncome> incomeUpdateWrapper = new LambdaUpdateWrapper<>();
-        incomeUpdateWrapper.set(InsPlyIncome::getSettlementStatus, SETTLE_STATUS_RESET)
-                .set(InsPlyIncome::getSuperviseSettlement, SETTLE_STATUS_RESET)
-                .set(InsPlyIncome::getOtherSettlement, SETTLE_STATUS_RESET)
-                .set(InsPlyIncome::getJySuperviseSettlement, SETTLE_STATUS_RESET)
-                .set(InsPlyIncome::getJyOtherSettlement, SETTLE_STATUS_RESET)
-                .eq(InsPlyIncome::getIsDelete, SETTLE_STATUS_RESET)
-                .in(InsPlyIncome::getId, incomeIdList);
+        if (CollUtil.isNotEmpty(linkList)){
+            // 提取incomeId列表
+            List<String> incomeIdList = linkList.stream()
+                    .map(InsPlyIncomeInvoiceLink::getIncomeId)
+                    .distinct()
+                    .collect(Collectors.toList());
 
-        // 执行更新
-        baseMapper.update(null, incomeUpdateWrapper);
-        return insPlyIncomeInvoiceSettlementMapper.deleteById(settlementId) > 0;
+            // 构造更新条件,增加主表逻辑删除过滤
+            incomeUpdateWrapper.set(InsPlyIncome::getSettlementStatus, SETTLE_STATUS_RESET)
+                    .set(InsPlyIncome::getSuperviseSettlement, SETTLE_STATUS_RESET)
+                    .set(InsPlyIncome::getOtherSettlement, SETTLE_STATUS_RESET)
+                    .set(InsPlyIncome::getJySuperviseSettlement, SETTLE_STATUS_RESET)
+                    .set(InsPlyIncome::getJyOtherSettlement, SETTLE_STATUS_RESET)
+                    .eq(InsPlyIncome::getIsDelete, SETTLE_STATUS_RESET)
+                    .in(InsPlyIncome::getId, incomeIdList);
+            // 执行更新
+            baseMapper.update(null, incomeUpdateWrapper);
+        }
+        return insPlyIncomeInvoiceSettlementMapper.deleteById(id) > 0;
     }
 
     /**
@@ -2224,68 +2230,243 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
      * @date 2026/5/27 20:25
      */
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public boolean batchModify(BatchModifyVo batchModifyVo) {
         log.info("批量修改应收订单: batchModifyVo=[{}]", JSONUtil.toJsonStr(batchModifyVo));
         List<String> incomeIds = batchModifyVo.getIncomeIds();
-        if(CollUtil.isEmpty(incomeIds)) {
+        if (CollUtil.isEmpty(incomeIds)) {
             throw new ServiceException("请勾选要批量修改的应收订单");
         }
-        List<String> insOrders = new ArrayList<>();
-        for (String incomeId : batchModifyVo.getIncomeIds()) {
-            InsPlyIncome insPlyIncomeSource = baseMapper.selectById(incomeId);
-            if(insPlyIncomeSource == null) {
-                log.info("批量修改应收订单。序号为[{}]的应收订单不存在", incomeId);
-                continue;
+
+        // 一次性查询所有需要修改的记录
+        List<InsPlyIncome> incomeList = baseMapper.selectBatchIds(incomeIds);
+        if (CollUtil.isEmpty(incomeList)) {
+            throw new ServiceException("未找到需要修改的应收订单");
+        }
+
+        // 收集订单号
+        List<String> orderNos = incomeList.stream()
+                .map(InsPlyIncome::getOrderNo)
+                .filter(Objects::nonNull)
+                .distinct()
+                .collect(Collectors.toList());
+
+        // 批量获取税率
+        Map<String, BigDecimal> taxRateMap = orderNos.stream()
+                .collect(Collectors.toMap(
+                        orderNo -> orderNo,
+                        this::obtainTaxRate,
+                        (v1, v2) -> v1 // 如果有重复,保留第一个
+                ));
+
+        // 准备批量更新的实体列表
+        List<InsPlyIncome> updateList = new ArrayList<>();
+
+        for (InsPlyIncome income : incomeList) {
+            BigDecimal taxRate = taxRateMap.getOrDefault(income.getOrderNo(), BigDecimal.ONE);
+            InsPlyIncome updateIncome = new InsPlyIncome();
+            updateIncome.setId(income.getId());
+
+            boolean hasUpdate = false;
+            String updateFlag = batchModifyVo.getUpdateFlag();
+
+            // 根据 updateFlag 处理不同的更新逻辑
+            if ("1".equals(updateFlag)) {
+                // 修改手续费
+                hasUpdate = handleSuperviseCosts(updateIncome, income, batchModifyVo, taxRate);
+            } else if ("2".equals(updateFlag)) {
+                // 修改跟单费
+                hasUpdate = handleOtherCosts(updateIncome, income, batchModifyVo, taxRate);
+            } else if ("3".equals(updateFlag)) {
+                // 修改驾意险费用
+                hasUpdate = handleJyCosts(updateIncome, income, batchModifyVo, taxRate);
+            } else if ("4".equals(updateFlag)) {
+                // 修改所有
+                boolean superviseUpdated = handleSuperviseCosts(updateIncome, income, batchModifyVo, taxRate);
+                boolean otherUpdated = handleOtherCosts(updateIncome, income, batchModifyVo, taxRate);
+                boolean jyUpdated = handleJyCosts(updateIncome, income, batchModifyVo, taxRate);
+                hasUpdate = superviseUpdated || otherUpdated || jyUpdated;
+            }
+
+            // 处理公共字段更新
+            if (batchModifyVo.getSigningTime() != null) {
+                updateIncome.setSigningTime(batchModifyVo.getSigningTime());
+                hasUpdate = true;
+            }
+            if (StrUtil.isNotEmpty(batchModifyVo.getContractUserName())) {
+                updateIncome.setContactPerson(batchModifyVo.getContractUserName());
+                hasUpdate = true;
             }
-            insOrders.add(insPlyIncomeSource.getOrderNo());
-            BigDecimal taxRate = this.obtainTaxRate(insPlyIncomeSource.getOrderNo());
-            if (Objects.nonNull(batchModifyVo.getJqSuperviseCostsProportion()) && batchModifyVo.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
-                // modify by lipf 2026年6月18日09:36:01 转换为百分比
-                BigDecimal jqSuperviseCostsProportion = BigDecimalUtil.divide(batchModifyVo.getJqSuperviseCostsProportion(), new BigDecimal(100)) ;
-                BigDecimal superviseReceivablePremium = BigDecimalUtil.divide(BigDecimalUtil.multiply(new BigDecimal(Objects.toString(insPlyIncomeSource.getJqPremium(),"0") ), jqSuperviseCostsProportion), taxRate) ;
-                BigDecimal jqReceivePremiun = BigDecimalUtil.add(superviseReceivablePremium, BigDecimalUtil.toZero(insPlyIncomeSource.getInsFeeOrders()  == null? null:  insPlyIncomeSource.getInsFeeOrders().getJqFollowPremium()));
-                baseMapper.update(null, new LambdaUpdateWrapper<InsPlyIncome>()
-                        .set(InsPlyIncome::getJqSuperviseCostsProportion, jqSuperviseCostsProportion)
-                        .set(InsPlyIncome::getJqSuperviseCostsPremiums, superviseReceivablePremium)
-                        .set(InsPlyIncome::getJqReceivablePremium,jqReceivePremiun)
-                        .in(InsPlyIncome::getId, batchModifyVo.getIncomeIds()));
-            }
-            if (Objects.nonNull(batchModifyVo.getSySuperviseCostsProportion()) && batchModifyVo.getSySuperviseCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
-                // modify by lipf 2026年6月18日09:36:01 转换为百分比
-                BigDecimal sySuperviseCostsProportion = BigDecimalUtil.divide(batchModifyVo.getSySuperviseCostsProportion(), new BigDecimal(100)) ;
-                BigDecimal sySuperviseReceivablePremium = BigDecimalUtil.divide(BigDecimalUtil.multiply(new BigDecimal(Objects.toString(insPlyIncomeSource.getSyPremium(),"0")), sySuperviseCostsProportion), taxRate) ;
-                BigDecimal syReceivePremiun = BigDecimalUtil.add(sySuperviseReceivablePremium, BigDecimalUtil.toZero(insPlyIncomeSource.getInsFeeOrders() != null? insPlyIncomeSource.getInsFeeOrders().getSyFollowPremium() : null));
-                baseMapper.update(null, new LambdaUpdateWrapper<InsPlyIncome>()
-                        .set(InsPlyIncome::getSySuperviseCostsProportion, sySuperviseCostsProportion)
-                        .set(InsPlyIncome::getSySuperviseCostsPremiums, sySuperviseReceivablePremium)
-                        .set(InsPlyIncome::getSyReceivablePremium,syReceivePremiun)
-                        .in(InsPlyIncome::getId, batchModifyVo.getIncomeIds()));
-            }
-            if (batchModifyVo.getSigningTime() != null){
-                baseMapper.update(null, new LambdaUpdateWrapper<InsPlyIncome>()
-                        .set(InsPlyIncome::getSigningTime, batchModifyVo.getSigningTime())
-                        .in(InsPlyIncome::getId, batchModifyVo.getIncomeIds()));
-
-            }
-            if(StrUtil.isNotEmpty(batchModifyVo.getContractUserName())){
-                baseMapper.update(null, new LambdaUpdateWrapper<InsPlyIncome>()
-                        .set(InsPlyIncome::getContactPerson, batchModifyVo.getContractUserName())
-                        .in(InsPlyIncome::getId, batchModifyVo.getIncomeIds()));
-
-            }
-            if(StrUtil.isNotEmpty(batchModifyVo.getContractPhone())){
-                baseMapper.update(null, new LambdaUpdateWrapper<InsPlyIncome>()
-                        .set(InsPlyIncome::getContactPersonPhone, batchModifyVo.getContractPhone())
-                        .in(InsPlyIncome::getId, batchModifyVo.getIncomeIds()));
-            }
-        }
-        batchModifyVo.setOrderNos(insOrders);
+            if (StrUtil.isNotEmpty(batchModifyVo.getContractPhone())) {
+                updateIncome.setContactPersonPhone(batchModifyVo.getContractPhone());
+                hasUpdate = true;
+            }
+
+            if (hasUpdate) {
+                updateList.add(updateIncome);
+            }
+        }
+
+        // 批量更新
+        if (CollUtil.isNotEmpty(updateList)) {
+            this.updateBatchById(updateList);
+        }
+
+        // 更新关联订单
+        batchModifyVo.setOrderNos(orderNos);
         HttpResult<String> updateOrdersRes = insFeeOrdersClient.updateOrdersBatch(batchModifyVo);
         log.info("更新车险订单的结果:updateOrdersRes=[{}]", JSONUtil.toJsonStr(updateOrdersRes));
         return true;
     }
 
+    /**
+     * 处理手续费更新
+     */
+    private boolean handleSuperviseCosts(InsPlyIncome updateIncome, InsPlyIncome sourceIncome,
+                                         BatchModifyVo batchModifyVo, BigDecimal taxRate) {
+        boolean hasUpdate = false;
+
+        if (Objects.nonNull(batchModifyVo.getJqSuperviseCostsProportion()) &&
+                batchModifyVo.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
+
+            BigDecimal proportion = batchModifyVo.getJqSuperviseCostsProportion().divide(new BigDecimal(100), 4, RoundingMode.HALF_UP);
+            BigDecimal premium = calculatePremium(sourceIncome.getJqPremium(), proportion, taxRate);
+            BigDecimal receivable = calculateReceivable(premium, sourceIncome.getInsFeeOrders(), "jqFollow");
+
+            updateIncome.setJqSuperviseCostsProportion(proportion.toString());
+            updateIncome.setJqSuperviseCostsPremiums(premium.toString());
+            updateIncome.setJqReceivablePremium(receivable.toString());
+            hasUpdate = true;
+        }
+
+        if (Objects.nonNull(batchModifyVo.getSySuperviseCostsProportion()) &&
+                batchModifyVo.getSySuperviseCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
+
+            BigDecimal proportion = batchModifyVo.getSySuperviseCostsProportion().divide(new BigDecimal(100), 4, RoundingMode.HALF_UP);
+            BigDecimal premium = calculatePremium(sourceIncome.getSyPremium(), proportion, taxRate);
+            BigDecimal receivable = calculateReceivable(premium, sourceIncome.getInsFeeOrders(), "syFollow");
+
+            updateIncome.setSySuperviseCostsProportion(proportion.toString());
+            updateIncome.setSySuperviseCostsPremiums(premium.toString());
+            updateIncome.setSyReceivablePremium(receivable.toString());
+            hasUpdate = true;
+        }
+
+        return hasUpdate;
+    }
+
+    /**
+     * 处理跟单费更新
+     */
+    private boolean handleOtherCosts(InsPlyIncome updateIncome, InsPlyIncome sourceIncome,
+                                     BatchModifyVo batchModifyVo, BigDecimal taxRate) {
+        boolean hasUpdate = false;
+
+        if (Objects.nonNull(batchModifyVo.getJqOtherCostsProportion()) &&
+                batchModifyVo.getJqOtherCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
+
+            BigDecimal proportion = batchModifyVo.getJqOtherCostsProportion().divide(new BigDecimal(100), 4, RoundingMode.HALF_UP);
+            BigDecimal premium = calculatePremium(sourceIncome.getJqPremium(), proportion, taxRate);
+            BigDecimal receivable = calculateReceivable(premium, sourceIncome.getInsFeeOrders(), "jqCommission");
+
+            updateIncome.setJqOtherCostsProportion(proportion.toString());
+            updateIncome.setJqOtherCostsPremiums(premium.toString());
+            updateIncome.setJqReceivablePremium(receivable.toString());
+            hasUpdate = true;
+        }
+
+        if (Objects.nonNull(batchModifyVo.getSyOtherCostsProportion()) &&
+                batchModifyVo.getSyOtherCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
+
+            BigDecimal proportion = batchModifyVo.getSyOtherCostsProportion().divide(new BigDecimal(100), 4, RoundingMode.HALF_UP);
+            BigDecimal premium = calculatePremium(sourceIncome.getSyPremium(), proportion, taxRate);
+            BigDecimal receivable = calculateReceivable(premium, sourceIncome.getInsFeeOrders(), "syCommission");
+
+            updateIncome.setSyOtherCostsProportion(proportion.toString());
+            updateIncome.setSyOtherCostsPremiums(premium.toString());
+            updateIncome.setSyReceivablePremium(receivable.toString());
+            hasUpdate = true;
+        }
+
+        return hasUpdate;
+    }
+
+    /**
+     * 处理驾意险费用更新
+     */
+    private boolean handleJyCosts(InsPlyIncome updateIncome, InsPlyIncome sourceIncome,
+                                  BatchModifyVo batchModifyVo, BigDecimal taxRate) {
+        boolean hasUpdate = false;
+
+        if (Objects.nonNull(batchModifyVo.getJySuperviseCostsProportion()) &&
+                batchModifyVo.getJySuperviseCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
+
+            BigDecimal proportion = batchModifyVo.getJySuperviseCostsProportion().divide(new BigDecimal(100));
+            BigDecimal premium = calculatePremium(sourceIncome.getJyPremium(), proportion, taxRate);
+            BigDecimal receivable = calculateReceivable(premium, sourceIncome.getInsFeeOrders(), "jyCommission");
+
+            updateIncome.setJySuperviseCostsProportion(proportion.toString());
+            updateIncome.setJySuperviseCostsPremiums(premium.toString());
+            updateIncome.setJyReceivablePremium(receivable.toString());
+            hasUpdate = true;
+        }
+
+        if (Objects.nonNull(batchModifyVo.getJyOtherCostsProportion()) &&
+                batchModifyVo.getJyOtherCostsProportion().compareTo(BigDecimal.ZERO) > 0) {
+
+            BigDecimal proportion = batchModifyVo.getJyOtherCostsProportion().divide(new BigDecimal(100));
+            BigDecimal premium = calculatePremium(sourceIncome.getJyPremium(), proportion, taxRate);
+            BigDecimal receivable = calculateReceivable(premium, sourceIncome.getInsFeeOrders(), "jyFollow");
+
+            updateIncome.setJyOtherCostsProportion(proportion.toString());
+            updateIncome.setJyOtherCostsPremiums(premium.toString());
+            updateIncome.setJyReceivablePremium(receivable.toString());
+            hasUpdate = true;
+        }
+
+        return hasUpdate;
+    }
+
+    /**
+     * 计算保费
+     */
+    private BigDecimal calculatePremium(String premiumStr, BigDecimal proportion, BigDecimal taxRate) {
+        BigDecimal premium = new BigDecimal(Objects.toString(premiumStr, "0"));
+        return premium.multiply(proportion).divide(taxRate, 2, RoundingMode.HALF_UP);
+    }
+
+    /**
+     * 计算应收金额
+     */
+    private BigDecimal calculateReceivable(BigDecimal premium, InsFeeOrders insFeeOrders, String type) {
+        BigDecimal followPremium = BigDecimal.ZERO;
+
+        if (insFeeOrders != null) {
+            switch (type) {
+                case "jqFollow":
+                    followPremium = BigDecimalUtil.toZero(insFeeOrders.getJqFollowPremium());
+                    break;
+                case "syFollow":
+                    followPremium = BigDecimalUtil.toZero(insFeeOrders.getSyFollowPremium());
+                    break;
+                case "jqCommission":
+                    followPremium = BigDecimalUtil.toZero(insFeeOrders.getJqCommissionPremium());
+                    break;
+                case "syCommission":
+                    followPremium = BigDecimalUtil.toZero(insFeeOrders.getSyCommissionPremium());
+                    break;
+                case "jyCommission":
+                    followPremium = BigDecimalUtil.toZero(insFeeOrders.getJyCommissionPremium());
+                    break;
+                case "jyFollow":
+                    followPremium = BigDecimalUtil.toZero(insFeeOrders.getJyFollowPremium());
+                    break;
+            }
+        }
+
+        return premium.add(followPremium);
+    }
+
     /**
      * 处理跟单费开票业务
      * 包含:创建发票主表记录、批量创建跟单订单明细、建立发票与明细的关联关系
@@ -3370,8 +3551,6 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
         Map<String, BigDecimal> sxfInvoicedAmountMap = 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));
-        calRes = baseMapper.queryInvoicedAmount(systemCode, List.of(4, 6), queryVo.getInvoiceStartTime(), queryVo.getInvoiceEndTime(), queryVo.getAgreementType());
-        Map<String, BigDecimal> ptInvoicedAmountMap =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"));
@@ -3387,13 +3566,14 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             companySuperviseSettlementReportDto.setSxfInvoicedAmount(Objects.toString(sxf,BigDecimal.ZERO+""));
             BigDecimal gdf = gdfInvoicedAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
             companySuperviseSettlementReportDto.setGdfInvoicedAmount(Objects.toString(gdf,BigDecimal.ZERO+""));
-            BigDecimal pt = ptInvoicedAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
-            companySuperviseSettlementReportDto.setPtInvoicedAmount(Objects.toString(pt,BigDecimal.ZERO+""));
+            // 平台就没有未结算的,只要结算就是已结算的
+            companySuperviseSettlementReportDto.setPtInvoicedAmount(companySuperviseSettlementReportDto.getTotalReceivable());
 
             CompanySuperviseSettlementReportDto dto;
             dto = companyMap.get(companyId);
             companySuperviseSettlementReportDto.setSxfUnInvoicedAmount(BigDecimalUtil.subtract(new BigDecimal(dto.getSuperviseFee()),sxf).toString());
             companySuperviseSettlementReportDto.setGdfUnInvoicedAmount(BigDecimalUtil.subtract(new BigDecimal(dto.getFollowFee()),gdf).toString());
+            companySuperviseSettlementReportDto.setPtUnInvoicedAmount(BigDecimal.ZERO.toString());
 
             BigDecimal sxfS = sxfSettledAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
             BigDecimal gdfS = gdfSettledAmountMap.getOrDefault(companyId, BigDecimal.ZERO);
@@ -3635,8 +3815,6 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
                 }
             }).toList();
             receiverSettlementReport.setRecords(records);
-
-
         }
         return receiverSettlementReport;
     }

+ 19 - 0
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -1270,6 +1270,25 @@
         </where>
     </select>
 
+    <select id="getIncomeJqSumReceivable" resultType="java.util.Map">
+        SELECT
+        sum( jq_supervise_costs_premiums ) AS jqCommissionPremium,
+        sum( sy_supervise_costs_premiums ) AS syCommissionPremium,
+        sum( jy_supervise_costs_premiums ) AS jyCommissionPremium,
+        sum( jq_other_costs_premiums ) AS jqFollowPremium,
+        sum( sy_other_costs_premiums ) AS syFollowPremium,
+        sum( jy_other_costs_premiums ) AS jyFollowPremium
+        FROM
+        ins_ply_income
+        <where>
+            is_delete = 0
+            AND order_no IN
+            <foreach collection="orderNos" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </where>
+    </select>
+
     <select id="getInvoiceRecordList" resultType="com.jzg.commons.entity.finance.vo.InvoiceRecordResult">
         SELECT
         ipii.id,