Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

wks 1 год назад
Родитель
Сommit
1fea638cf8
14 измененных файлов с 653 добавлено и 195 удалено
  1. 9 191
      commons/src/main/java/com/jzg/commons/entity/po/InsFeeOrders.java
  2. 2 2
      commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCostType.java
  3. 8 1
      commons/src/main/java/com/jzg/commons/entity/quote/vo/aggregated/QuoteEchoVo.java
  4. 116 0
      commons/src/main/java/com/jzg/commons/entity/vo/InsFeeOrdersVo.java
  5. 99 0
      commons/src/main/java/com/jzg/commons/entity/vo/PtlAgreementCostRatioVo.java
  6. 3 0
      commons/src/main/java/com/jzg/commons/entity/vo/PtlAgreementCostTypeVo.java
  7. 3 0
      tenant/insurance/quotation-commons/src/main/java/com/jzg/quotation/commons/client/OrgClient.java
  8. 193 1
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/aop/aspect/QuoteVerificationAspect.java
  9. 12 0
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/controller/InsOrdersController.java
  10. 4 0
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/InsFeeOrdersService.java
  11. 187 0
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsFeeOrdersServiceImpl.java
  12. 10 0
      tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/impl/InsOrdersServiceImpl.java
  13. 6 0
      tenant/organization/src/main/java/com/jzg/organization/controller/AgreementController.java
  14. 1 0
      tenant/organization/src/main/resources/application.yml

+ 9 - 191
commons/src/main/java/com/jzg/commons/entity/po/InsFeeOrders.java

@@ -91,195 +91,13 @@ public class InsFeeOrders {
 
     @Schema(description = "驾意险加投费费费用")
     private BigDecimal jyAdditionalPremium;
-//    // 获取协议录入的 手续费比例 保留百分比
-//    BigDecimal jqEntranceFeeRatio = agreementInfoVo.getAgreement().getJqEntranceFeeRatio().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//    BigDecimal syEntranceFeeRatio = agreementInfoVo.getAgreement().getSyEntranceFeeRatio().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//    BigDecimal jyEntranceFeeRatio = agreementInfoVo.getAgreement().getJyEntranceFeeRatio().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//    // 开始计算费用
-//    // 通过费用id查询入口出口比例
-//    List<PtlAgreementCostTypeVo> costTypeList = orgClient.queryByCostId(costId);
-//    PtlAgreementCostTypeVo jqCostType = costTypeList.stream().filter(c -> "交强险".equals(c.getCostType())).findFirst().orElse(null);
-//    PtlAgreementCostTypeVo syCostType = costTypeList.stream().filter(c -> "商业险".equals(c.getCostType())).findFirst().orElse(null);
-//    PtlAgreementCostTypeVo jyCostType = costTypeList.stream().filter(c -> "驾意险".equals(c.getCostType())).findFirst().orElse(null);
-//    // 计算跟单费比例 入口比例 - 手续费比例 = 跟单比例 (保留百分比)
-//    BigDecimal jqFollowRatio = (jqCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN).subtract(jqEntranceFeeRatio));
-//    BigDecimal syFollowRatio = (syCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN).subtract(syEntranceFeeRatio));
-//    BigDecimal jyFollowRatio = (jyCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN).subtract(jyEntranceFeeRatio));
-//    // 当协议是平台协议时
-//        if (agreementType.equals("1")) {
-//        // 初始化交强应收 应付金额
-//        BigDecimal jqReceivablePremium = BigDecimal.ZERO;
-//        BigDecimal jqPayablePremium = BigDecimal.ZERO;
-//        // 交强险保费 * 入口手续费比例 + 交强险保费 * 跟单费比例 + 交强险保费 * 加投比例 = 交强应收(不含车船税);
-//        // 交强险保费 * 出口比例 = 交强应付;
-//        if (jqCostType != null) {
-//            // 转换百分比
-//            BigDecimal inletPercent = jqCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal addThrowPercent = jqCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal exportPercent = jqCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            // 交强应收
-//            jqReceivablePremium = insOrdersCosts.getJqPremium().multiply(inletPercent)
-//                    .add(insOrdersCosts.getJqPremium().multiply(addThrowPercent))
-//                    .add(insOrdersCosts.getJqPremium().multiply(jqFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
-//            // 交强应付
-//            jqPayablePremium = insOrdersCosts.getJqPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
-//            // 交强手续费费用
-//            insFeeOrders.setJqCommissionPremium(insOrdersCosts.getJqPremium().multiply(jqEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 交强跟单费费用
-//            insFeeOrders.setJqFollowPremium(insOrdersCosts.getJqPremium().multiply(jqFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 交强加投费费用
-//            insFeeOrders.setJqAdditionalPremium(insOrdersCosts.getJqPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
-//        }
-//        insFeeOrders.setJqReceivablePremium(jqReceivablePremium);
-//        insFeeOrders.setJqPayablePremium(jqPayablePremium);
-//
-//        // 初始化商业应收 应付金额
-//        BigDecimal syReceivablePremium = BigDecimal.ZERO;
-//        BigDecimal syPayablePremium = BigDecimal.ZERO;
-//        // 商业险保费 * 入口手续费比例 + 商业险保费 * 跟单费比例 + 商业险保费 * 加投比例 = 商业应收
-//        // 商业险保费 * 出口比例 = 商业应付;
-//        if (syCostType != null) {
-//            // 转换百分比
-//            BigDecimal inletPercent = syCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal addThrowPercent = syCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal exportPercent = syCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            // 商业应收
-//            syReceivablePremium = insOrdersCosts.getSyPremium().multiply(inletPercent)
-//                    .add(insOrdersCosts.getSyPremium().multiply(addThrowPercent))
-//                    .add(insOrdersCosts.getSyPremium().multiply(syFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
-//            // 商业应付
-//            syPayablePremium = insOrdersCosts.getSyPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
-//            // 商业手续费费用
-//            insFeeOrders.setSyCommissionPremium(insOrdersCosts.getSyPremium().multiply(syEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 商业跟单费费用
-//            insFeeOrders.setSyFollowPremium(insOrdersCosts.getSyPremium().multiply(syFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 商业加投费费用
-//            insFeeOrders.setSyAdditionalPremium(insOrdersCosts.getSyPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
-//        }
-//        insFeeOrders.setSyReceivablePremium(syReceivablePremium);
-//        insFeeOrders.setSyPayablePremium(syPayablePremium);
-//
-//        // 初始化驾意应收 应付金额
-//        BigDecimal jyReceivablePremium = BigDecimal.ZERO;
-//        BigDecimal jyPayablePremium = BigDecimal.ZERO;
-//        // 驾意险保费 * 入口手续费比例 + 驾意险保费 * 跟单费比例 + 驾意险保费 * 加投比例 = 商业应收
-//        // 驾意险保费 * 出口比例 = 驾意险应付;
-//        if (jyCostType != null) {
-//            // 转换百分比
-//            BigDecimal inletPercent = jyCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal addThrowPercent = jyCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal exportPercent = jyCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            // 驾意应收
-//            jyReceivablePremium = insOrdersCosts.getJyPremium().multiply(inletPercent)
-//                    .add(insOrdersCosts.getJyPremium().multiply(addThrowPercent))
-//                    .add(insOrdersCosts.getJyPremium().multiply(jyFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
-//            // 驾意应付
-//            jyPayablePremium = insOrdersCosts.getJyPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
-//            // 驾意手续费费用
-//            insFeeOrders.setJyCommissionPremium(insOrdersCosts.getJyPremium().multiply(jyEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 驾意跟单费费用
-//            insFeeOrders.setJyFollowPremium(insOrdersCosts.getJyPremium().multiply(jyFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 驾意加投费费用
-//            insFeeOrders.setJyAdditionalPremium(insOrdersCosts.getJyPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
-//        }
-//        insFeeOrders.setJyReceivablePremium(jyReceivablePremium);
-//        insFeeOrders.setJyPayablePremium(jyPayablePremium);
-//        // 应收总金额
-//        BigDecimal totalReceivablePremium = jqReceivablePremium.add(syReceivablePremium).add(jyReceivablePremium).setScale(5, RoundingMode.HALF_EVEN);
-//        insFeeOrders.setTotalReceivablePremium(totalReceivablePremium);
-//        // 应付总金额
-//        BigDecimal totalPayablePremium = jqPayablePremium.add(syPayablePremium).add(jyPayablePremium).setScale(2, RoundingMode.DOWN);
-//        insFeeOrders.setTotalPayablePremium(totalPayablePremium);
-//        insFeeOrdersService.save(insFeeOrders);
-//    }
-//    // 当协议类型是私有协议时
-//        if (!agreementType.equals("1")) {
-//        // 固定税收 1.06
-//        BigDecimal fixedTax = new BigDecimal("1.06");
-//        // 初始化交强应收 应付金额
-//        BigDecimal jqReceivablePremium = BigDecimal.ZERO;
-//        BigDecimal jqPayablePremium = BigDecimal.ZERO;
-//        // 交强险保费 * 入口手续费比例 + 交强险保费 * 跟单费比例 + 交强险保费 * 加投比例 = 交强应收(不含车船税);
-//        // 交强险保费 * 出口比例 = 交强应付;
-//        if (jqCostType != null) {
-//            // 转换百分比
-//            BigDecimal inletPercent = jqCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal addThrowPercent = jqCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal exportPercent = jqCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            // 交强应收
-//            jqReceivablePremium = (insOrdersCosts.getJqPremium().divide(fixedTax)).multiply(inletPercent)
-//                    .add((insOrdersCosts.getJqPremium().divide(fixedTax)).multiply(addThrowPercent))
-//                    .add((insOrdersCosts.getJqPremium().divide(fixedTax)).multiply(jqFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
-//            // 交强应付
-//            jqPayablePremium = insOrdersCosts.getJqPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
-//            // 交强手续费费用
-//            insFeeOrders.setJqCommissionPremium(insOrdersCosts.getJqPremium().multiply(jqEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 交强跟单费费用
-//            insFeeOrders.setJqFollowPremium(insOrdersCosts.getJqPremium().multiply(jqFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 交强加投费费用
-//            insFeeOrders.setJqAdditionalPremium(insOrdersCosts.getJqPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
-//        }
-//        insFeeOrders.setJqReceivablePremium(jqReceivablePremium);
-//        insFeeOrders.setJqPayablePremium(jqPayablePremium);
-//
-//        // 初始化商业应收 应付金额
-//        BigDecimal syReceivablePremium = BigDecimal.ZERO;
-//        BigDecimal syPayablePremium = BigDecimal.ZERO;
-//        // 商业险保费 * 入口手续费比例 + 商业险保费 * 跟单费比例 + 商业险保费 * 加投比例 = 商业应收
-//        // 商业险保费 * 出口比例 = 商业应付;
-//        if (syCostType != null) {
-//            // 转换百分比
-//            BigDecimal inletPercent = syCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal addThrowPercent = syCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal exportPercent = syCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            // 商业应收
-//            syReceivablePremium = (insOrdersCosts.getSyPremium().divide(fixedTax)).multiply(inletPercent)
-//                    .add((insOrdersCosts.getSyPremium().divide(fixedTax)).multiply(addThrowPercent))
-//                    .add((insOrdersCosts.getSyPremium().divide(fixedTax)).multiply(syFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
-//            // 商业应付
-//            syPayablePremium = insOrdersCosts.getSyPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
-//            // 商业手续费费用
-//            insFeeOrders.setSyCommissionPremium(insOrdersCosts.getSyPremium().multiply(syEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 商业跟单费费用
-//            insFeeOrders.setSyFollowPremium(insOrdersCosts.getSyPremium().multiply(syFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 商业加投费费用
-//            insFeeOrders.setSyAdditionalPremium(insOrdersCosts.getSyPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
-//        }
-//        insFeeOrders.setSyReceivablePremium(syReceivablePremium);
-//        insFeeOrders.setSyPayablePremium(syPayablePremium);
-//
-//        // 初始化驾意应收 应付金额
-//        BigDecimal jyReceivablePremium = BigDecimal.ZERO;
-//        BigDecimal jyPayablePremium = BigDecimal.ZERO;
-//        // 驾意险保费 * 入口手续费比例 + 驾意险保费 * 跟单费比例 + 驾意险保费 * 加投比例 = 商业应收
-//        // 驾意险保费 * 出口比例 = 驾意险应付;
-//        if (jyCostType != null) {
-//            // 转换百分比
-//            BigDecimal inletPercent = jyCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal addThrowPercent = jyCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            BigDecimal exportPercent = jyCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
-//            // 驾意应收
-//            jyReceivablePremium = (insOrdersCosts.getJyPremium().divide(fixedTax)).multiply(inletPercent)
-//                    .add((insOrdersCosts.getJyPremium().divide(fixedTax)).multiply(addThrowPercent))
-//                    .add((insOrdersCosts.getJyPremium().divide(fixedTax)).multiply(jyFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
-//            // 驾意应付
-//            jyPayablePremium = insOrdersCosts.getJyPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
-//            // 驾意手续费费用
-//            insFeeOrders.setJyCommissionPremium(insOrdersCosts.getJyPremium().multiply(jyEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 驾意跟单费费用
-//            insFeeOrders.setJyFollowPremium(insOrdersCosts.getJyPremium().multiply(jyFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
-//            // 驾意加投费费用
-//            insFeeOrders.setJyAdditionalPremium(insOrdersCosts.getJyPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
-//        }
-//        insFeeOrders.setJyReceivablePremium(jyReceivablePremium);
-//        insFeeOrders.setJyPayablePremium(jyPayablePremium);
-//        // 应收总金额
-//        BigDecimal totalReceivablePremium = jqReceivablePremium.add(syReceivablePremium).add(jyReceivablePremium).setScale(5, RoundingMode.HALF_EVEN);
-//        insFeeOrders.setTotalReceivablePremium(totalReceivablePremium);
-//        // 应付总金额
-//        BigDecimal totalPayablePremium = jqPayablePremium.add(syPayablePremium).add(jyPayablePremium).setScale(2, RoundingMode.DOWN);
-//        insFeeOrders.setTotalPayablePremium(totalPayablePremium);
-//        insFeeOrdersService.save(insFeeOrders);
-//
-//    }
+
+    @Schema(description = "交强险留点费用")
+    private BigDecimal jqKeepPointPremium;
+
+    @Schema(description = "商业险留点费用")
+    private BigDecimal syKeepPointPremium;
+
+    @Schema(description = "驾意险留点费用")
+    private BigDecimal jyKeepPointPremium;
 }

+ 2 - 2
commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCostType.java

@@ -24,10 +24,10 @@ public class PtlAgreementCostType extends BaseModel {
 
     private BigDecimal export;
 
-    private BigDecimal commission;
-
     private BigDecimal addThrow;
 
+    private BigDecimal keepPointRatio;
+
 
 
 }

+ 8 - 1
commons/src/main/java/com/jzg/commons/entity/quote/vo/aggregated/QuoteEchoVo.java

@@ -13,6 +13,8 @@ import com.jzg.commons.entity.scheme.vo.PtlAgreementInsCompanyVo;
 import com.jzg.commons.constants.quote.enums.quote.RiskCode;
 import com.jzg.commons.entity.quote.vo.base.OrderBase;
 import com.jzg.commons.entity.vo.ImagesVo;
+import com.jzg.commons.entity.vo.InsFeeOrdersVo;
+import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
 import lombok.Data;
@@ -173,13 +175,18 @@ public class QuoteEchoVo extends QuoteVo {
     /**
      * 费用信息
      */
-    private InsFeeOrders insFeeOrders;
+    private InsFeeOrdersVo insFeeOrders;
 
     /**
      * 支付码
      */
     private InsOrdersQrcode qrcode;
 
+    /**
+     * 费用比例信息
+     */
+    private PtlAgreementCostRatioVo costRatio;
+
 
     /**
      * 订单数据库查询数据转 QuoteVo对象

+ 116 - 0
commons/src/main/java/com/jzg/commons/entity/vo/InsFeeOrdersVo.java

@@ -0,0 +1,116 @@
+package com.jzg.commons.entity.vo;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.jzg.commons.entity.po.InsFeeOrders;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author quchen
+ * @date 2025/7/9 14:55
+ */
+
+@Data
+public class InsFeeOrdersVo {
+    @Schema(description = "订单号")
+    @TableId
+    private String orderNo;
+
+    @Schema(description = "协议id")
+    private String agreementId;
+
+    @Schema(description = "费用id")
+    private String costId;
+
+    @Schema(description = "交强险保费")
+    private String jqPremium;
+
+    @Schema(description = "商业险保费")
+    private String syPremium;
+
+    @Schema(description = "驾意险保费")
+    private String jyPremium;
+
+    @Schema(description = "总保费")
+    private String totalPremium;
+
+    @Schema(description = "交强险应收保费")
+    private String jqReceivablePremium;
+
+    @Schema(description = "商业险应收保费")
+    private String syReceivablePremium;
+
+    @Schema(description = "驾意险应收保费")
+    private String jyReceivablePremium;
+
+    @Schema(description = "总应收保费")
+    private String totalReceivablePremium;
+
+    @Schema(description = "交强险应付保费")
+    private String jqPayablePremium;
+
+    @Schema(description = "商业险应付保费")
+    private String syPayablePremium;
+
+    @Schema(description = "驾意险应付保费")
+    private String jyPayablePremium;
+
+    @Schema(description = "总应付保费")
+    private String totalPayablePremium;
+
+    @Schema(description = "交强险手续费费用")
+    private String jqCommissionPremium;
+
+    @Schema(description = "商业险手续费费用")
+    private String syCommissionPremium;
+
+    @Schema(description = "驾意险手续费费用")
+    private String jyCommissionPremium;
+
+    @Schema(description = "交强险跟单费费用")
+    private String jqFollowPremium;
+
+    @Schema(description = "商业险跟单费费用")
+    private String syFollowPremium;
+
+    @Schema(description = "驾意险跟单费费用")
+    private String jyFollowPremium;
+
+    @Schema(description = "交强险加投费费费用")
+    private String jqAdditionalPremium;
+
+    @Schema(description = "商业险加投费费费用")
+    private String syAdditionalPremium;
+
+    @Schema(description = "驾意险加投费费费用")
+    private String jyAdditionalPremium;
+
+    public InsFeeOrdersVo(InsFeeOrders insFeeOrders) {
+        this.orderNo = insFeeOrders.getOrderNo();
+        this.agreementId = insFeeOrders.getAgreementId();
+        this.costId = insFeeOrders.getCostId();
+        this.jqPremium = insFeeOrders.getJqPremium().toString();
+        this.syPremium = insFeeOrders.getSyPremium().toString();
+        this.jyPremium = insFeeOrders.getJyPremium().toString();
+        this.totalPremium = insFeeOrders.getTotalPremium().toString();
+        this.jqReceivablePremium = insFeeOrders.getJqReceivablePremium().toString();
+        this.syReceivablePremium = insFeeOrders.getSyReceivablePremium().toString();
+        this.jyReceivablePremium = insFeeOrders.getJyReceivablePremium().toString();
+        this.totalReceivablePremium = insFeeOrders.getTotalReceivablePremium().toString();
+        this.jqPayablePremium = insFeeOrders.getJqPayablePremium().toString();
+        this.syPayablePremium = insFeeOrders.getSyPayablePremium().toString();
+        this.jyPayablePremium = insFeeOrders.getJyPayablePremium().toString();
+        this.totalPayablePremium = insFeeOrders.getTotalPayablePremium().toString();
+        this.jqCommissionPremium = insFeeOrders.getJqCommissionPremium().toString();
+        this.syCommissionPremium = insFeeOrders.getSyCommissionPremium().toString();
+        this.jyCommissionPremium = insFeeOrders.getJyCommissionPremium().toString();
+        this.jqFollowPremium = insFeeOrders.getJqFollowPremium().toString();
+        this.syFollowPremium = insFeeOrders.getSyFollowPremium().toString();
+        this.jyFollowPremium = insFeeOrders.getJyFollowPremium().toString();
+        this.jqAdditionalPremium = insFeeOrders.getJqAdditionalPremium().toString();
+        this.syAdditionalPremium = insFeeOrders.getSyAdditionalPremium().toString();
+        this.jyAdditionalPremium = insFeeOrders.getJyAdditionalPremium().toString();
+    }
+}

+ 99 - 0
commons/src/main/java/com/jzg/commons/entity/vo/PtlAgreementCostRatioVo.java

@@ -0,0 +1,99 @@
+package com.jzg.commons.entity.vo;
+
+import com.jzg.commons.entity.po.PtlAgreement;
+import com.jzg.commons.entity.po.PtlAgreementCostType;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * @author quchen
+ * @date 2025/7/9 11:03
+ */
+
+@Data
+public class PtlAgreementCostRatioVo {
+    @Schema(description = "订单号")
+    private String orderNo;
+
+    @Schema(description = "交强险手续费比例")
+    private BigDecimal jqCommissionRatio;
+
+    @Schema(description = "商业险手续费比例")
+    private BigDecimal syCommissionRatio;
+
+    @Schema(description = "驾意险手续费比例")
+    private BigDecimal jyCommissionRatio;
+
+    @Schema(description = "交强险跟单费比例")
+    private BigDecimal jqFollowRatio;
+
+    @Schema(description = "商业险跟单费比例")
+    private BigDecimal syFollowRatio;
+
+    @Schema(description = "驾意险跟单费比例")
+    private BigDecimal jyFollowRatio;
+
+    @Schema(description = "交强险加投费比例")
+    private BigDecimal jqAdditionalRatio;
+
+    @Schema(description = "商业险加投费比例")
+    private BigDecimal syAdditionalRatio;
+
+    @Schema(description = "驾意险加投费比例")
+    private BigDecimal jyAdditionalRatio;
+
+    @Schema(description = "交强险出口比例")
+    private BigDecimal jqExportRatio;
+
+    @Schema(description = "商业险出口比例")
+    private BigDecimal syExportRatio;
+
+    @Schema(description = "驾意险出口比例")
+    private BigDecimal jyExportRatio;
+
+    @Schema(description = "交强险入口比例")
+    private BigDecimal jqInletRatio;
+
+    @Schema(description = "商业险入口比例")
+    private BigDecimal syInletRatio;
+
+    @Schema(description = "驾意险入口比例")
+    private BigDecimal jyInletRatio;
+
+    @Schema(description = "交强险留点比例")
+    private BigDecimal jqKeepPointRatio;
+
+    @Schema(description = "商业险留点比例")
+    private BigDecimal syKeepPointRatio;
+
+    @Schema(description = "非车险留点比例")
+    private BigDecimal jyKeepPointRatio;
+
+    public PtlAgreementCostRatioVo(List<PtlAgreementCostTypeVo> ptlAgreementCostTypeList, PtlAgreement ptlAgreement) {
+        ptlAgreementCostTypeList.forEach(ptlAgreementCostType -> {
+            switch (ptlAgreementCostType.getCostType()) {
+                case "交强险":
+                    this.jqCommissionRatio = ptlAgreement.getJqEntranceFeeRatio();
+                    this.jqInletRatio = ptlAgreementCostType.getInlet();
+                    this.jqExportRatio = ptlAgreementCostType.getExport();
+                    this.jqFollowRatio = ptlAgreementCostType.getInlet().subtract(ptlAgreement.getJqEntranceFeeRatio());
+                    this.jqAdditionalRatio = ptlAgreementCostType.getAddThrow();
+                case "商业险":
+                    this.syCommissionRatio = ptlAgreement.getSyEntranceFeeRatio();
+                    this.syInletRatio = ptlAgreementCostType.getInlet();
+                    this.syExportRatio = ptlAgreementCostType.getExport();
+                    this.syFollowRatio = ptlAgreementCostType.getInlet().subtract(ptlAgreement.getSyEntranceFeeRatio());
+                    this.syAdditionalRatio = ptlAgreementCostType.getAddThrow();
+                case "驾意险":
+                    this.jyCommissionRatio = ptlAgreement.getJyEntranceFeeRatio();
+                    this.jyInletRatio = ptlAgreementCostType.getInlet();
+                    this.jyExportRatio = ptlAgreementCostType.getExport();
+                    this.jyFollowRatio = ptlAgreementCostType.getInlet().subtract(ptlAgreement.getJyEntranceFeeRatio());
+                    this.jyAdditionalRatio = ptlAgreementCostType.getAddThrow();
+            }
+        });
+    }
+}

+ 3 - 0
commons/src/main/java/com/jzg/commons/entity/vo/PtlAgreementCostTypeVo.java

@@ -26,4 +26,7 @@ public class PtlAgreementCostTypeVo{
     @Schema(description = "加投比例")
     private BigDecimal addThrow;
 
+    @Schema(description = "留点比例")
+    private BigDecimal keepPointRatio;
+
 }

+ 3 - 0
tenant/insurance/quotation-commons/src/main/java/com/jzg/quotation/commons/client/OrgClient.java

@@ -31,6 +31,9 @@ public interface OrgClient {
     public HttpResult<List<PtlAgreement>> getByCompanyId(@RequestParam("companyId") String companyId,
                                                          @RequestHeader("Authorization") String authToken,
                                                          @RequestHeader("system_code")String systemCode);
+    @GetMapping(value = "/agreement/getByAgreementId")
+    public PtlAgreement getByAgreementId(@RequestParam String agreementId,
+                                         @RequestHeader("Authorization") String authToken);
 
     @GetMapping(value = "/messageTemplate/templateGet")
     public HttpResult<SysMessageTemplate> templateGet(@RequestParam MessageCodeEnum messageCodeEnum,

+ 193 - 1
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/aop/aspect/QuoteVerificationAspect.java

@@ -724,7 +724,7 @@ public class QuoteVerificationAspect {
     }
 
     /**
-     * 转换百分比为小数(如:50 -> 0.5)
+     * 转换百分比为小数
      */
     private BigDecimal convertPercent(BigDecimal percent) {
         return percent.divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
@@ -828,4 +828,196 @@ public class QuoteVerificationAspect {
         insFeeOrders.setTotalReceivablePremium(totalReceivable);
         insFeeOrders.setTotalPayablePremium(totalPayable);
     }
+
+    //    // 获取协议录入的 手续费比例 保留百分比
+//    BigDecimal jqEntranceFeeRatio = agreementInfoVo.getAgreement().getJqEntranceFeeRatio().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//    BigDecimal syEntranceFeeRatio = agreementInfoVo.getAgreement().getSyEntranceFeeRatio().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//    BigDecimal jyEntranceFeeRatio = agreementInfoVo.getAgreement().getJyEntranceFeeRatio().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//    // 开始计算费用
+//    // 通过费用id查询入口出口比例
+//    List<PtlAgreementCostTypeVo> costTypeList = orgClient.queryByCostId(costId);
+//    PtlAgreementCostTypeVo jqCostType = costTypeList.stream().filter(c -> "交强险".equals(c.getCostType())).findFirst().orElse(null);
+//    PtlAgreementCostTypeVo syCostType = costTypeList.stream().filter(c -> "商业险".equals(c.getCostType())).findFirst().orElse(null);
+//    PtlAgreementCostTypeVo jyCostType = costTypeList.stream().filter(c -> "驾意险".equals(c.getCostType())).findFirst().orElse(null);
+//    // 计算跟单费比例 入口比例 - 手续费比例 = 跟单比例 (保留百分比)
+//    BigDecimal jqFollowRatio = (jqCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN).subtract(jqEntranceFeeRatio));
+//    BigDecimal syFollowRatio = (syCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN).subtract(syEntranceFeeRatio));
+//    BigDecimal jyFollowRatio = (jyCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN).subtract(jyEntranceFeeRatio));
+//    // 当协议是平台协议时
+//        if (agreementType.equals("1")) {
+//        // 初始化交强应收 应付金额
+//        BigDecimal jqReceivablePremium = BigDecimal.ZERO;
+//        BigDecimal jqPayablePremium = BigDecimal.ZERO;
+//        // 交强险保费 * 入口手续费比例 + 交强险保费 * 跟单费比例 + 交强险保费 * 加投比例 = 交强应收(不含车船税);
+//        // 交强险保费 * 出口比例 = 交强应付;
+//        if (jqCostType != null) {
+//            // 转换百分比
+//            BigDecimal inletPercent = jqCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            BigDecimal addThrowPercent = jqCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            BigDecimal exportPercent = jqCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            // 交强应收
+//            jqReceivablePremium = insOrdersCosts.getJqPremium().multiply(inletPercent)
+//                    .add(insOrdersCosts.getJqPremium().multiply(addThrowPercent))
+//                    .add(insOrdersCosts.getJqPremium().multiply(jqFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
+//            // 交强应付
+//            jqPayablePremium = insOrdersCosts.getJqPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
+//            // 交强手续费费用
+//            insFeeOrders.setJqCommissionPremium(insOrdersCosts.getJqPremium().multiply(jqEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
+//            // 交强跟单费费用
+//            insFeeOrders.setJqFollowPremium(insOrdersCosts.getJqPremium().multiply(jqFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
+//            // 交强加投费费用
+//            insFeeOrders.setJqAdditionalPremium(insOrdersCosts.getJqPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
+//        }
+//        insFeeOrders.setJqReceivablePremium(jqReceivablePremium);
+//        insFeeOrders.setJqPayablePremium(jqPayablePremium);
+//
+//        // 初始化商业应收 应付金额
+//        BigDecimal syReceivablePremium = BigDecimal.ZERO;
+//        BigDecimal syPayablePremium = BigDecimal.ZERO;
+//        // 商业险保费 * 入口手续费比例 + 商业险保费 * 跟单费比例 + 商业险保费 * 加投比例 = 商业应收
+//        // 商业险保费 * 出口比例 = 商业应付;
+//        if (syCostType != null) {
+//            // 转换百分比
+//            BigDecimal inletPercent = syCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            BigDecimal addThrowPercent = syCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            BigDecimal exportPercent = syCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            // 商业应收
+//            syReceivablePremium = insOrdersCosts.getSyPremium().multiply(inletPercent)
+//                    .add(insOrdersCosts.getSyPremium().multiply(addThrowPercent))
+//                    .add(insOrdersCosts.getSyPremium().multiply(syFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
+//            // 商业应付
+//            syPayablePremium = insOrdersCosts.getSyPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
+//            // 商业手续费费用
+//            insFeeOrders.setSyCommissionPremium(insOrdersCosts.getSyPremium().multiply(syEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
+//            // 商业跟单费费用
+//            insFeeOrders.setSyFollowPremium(insOrdersCosts.getSyPremium().multiply(syFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
+//            // 商业加投费费用
+//            insFeeOrders.setSyAdditionalPremium(insOrdersCosts.getSyPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
+//        }
+//        insFeeOrders.setSyReceivablePremium(syReceivablePremium);
+//        insFeeOrders.setSyPayablePremium(syPayablePremium);
+//
+//        // 初始化驾意应收 应付金额
+//        BigDecimal jyReceivablePremium = BigDecimal.ZERO;
+//        BigDecimal jyPayablePremium = BigDecimal.ZERO;
+//        // 驾意险保费 * 入口手续费比例 + 驾意险保费 * 跟单费比例 + 驾意险保费 * 加投比例 = 商业应收
+//        // 驾意险保费 * 出口比例 = 驾意险应付;
+//        if (jyCostType != null) {
+//            // 转换百分比
+//            BigDecimal inletPercent = jyCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            BigDecimal addThrowPercent = jyCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            BigDecimal exportPercent = jyCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            // 驾意应收
+//            jyReceivablePremium = insOrdersCosts.getJyPremium().multiply(inletPercent)
+//                    .add(insOrdersCosts.getJyPremium().multiply(addThrowPercent))
+//                    .add(insOrdersCosts.getJyPremium().multiply(jyFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
+//            // 驾意应付
+//            jyPayablePremium = insOrdersCosts.getJyPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
+//            // 驾意手续费费用
+//            insFeeOrders.setJyCommissionPremium(insOrdersCosts.getJyPremium().multiply(jyEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
+//            // 驾意跟单费费用
+//            insFeeOrders.setJyFollowPremium(insOrdersCosts.getJyPremium().multiply(jyFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
+//            // 驾意加投费费用
+//            insFeeOrders.setJyAdditionalPremium(insOrdersCosts.getJyPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
+//        }
+//        insFeeOrders.setJyReceivablePremium(jyReceivablePremium);
+//        insFeeOrders.setJyPayablePremium(jyPayablePremium);
+//        // 应收总金额
+//        BigDecimal totalReceivablePremium = jqReceivablePremium.add(syReceivablePremium).add(jyReceivablePremium).setScale(5, RoundingMode.HALF_EVEN);
+//        insFeeOrders.setTotalReceivablePremium(totalReceivablePremium);
+//        // 应付总金额
+//        BigDecimal totalPayablePremium = jqPayablePremium.add(syPayablePremium).add(jyPayablePremium).setScale(2, RoundingMode.DOWN);
+//        insFeeOrders.setTotalPayablePremium(totalPayablePremium);
+//        insFeeOrdersService.save(insFeeOrders);
+//    }
+//    // 当协议类型是私有协议时
+//        if (!agreementType.equals("1")) {
+//        // 固定税收 1.06
+//        BigDecimal fixedTax = new BigDecimal("1.06");
+//        // 初始化交强应收 应付金额
+//        BigDecimal jqReceivablePremium = BigDecimal.ZERO;
+//        BigDecimal jqPayablePremium = BigDecimal.ZERO;
+//        // 交强险保费 * 入口手续费比例 + 交强险保费 * 跟单费比例 + 交强险保费 * 加投比例 = 交强应收(不含车船税);
+//        // 交强险保费 * 出口比例 = 交强应付;
+//        if (jqCostType != null) {
+//            // 转换百分比
+//            BigDecimal inletPercent = jqCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            BigDecimal addThrowPercent = jqCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            BigDecimal exportPercent = jqCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            // 交强应收
+//            jqReceivablePremium = (insOrdersCosts.getJqPremium().divide(fixedTax)).multiply(inletPercent)
+//                    .add((insOrdersCosts.getJqPremium().divide(fixedTax)).multiply(addThrowPercent))
+//                    .add((insOrdersCosts.getJqPremium().divide(fixedTax)).multiply(jqFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
+//            // 交强应付
+//            jqPayablePremium = insOrdersCosts.getJqPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
+//            // 交强手续费费用
+//            insFeeOrders.setJqCommissionPremium(insOrdersCosts.getJqPremium().multiply(jqEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
+//            // 交强跟单费费用
+//            insFeeOrders.setJqFollowPremium(insOrdersCosts.getJqPremium().multiply(jqFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
+//            // 交强加投费费用
+//            insFeeOrders.setJqAdditionalPremium(insOrdersCosts.getJqPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
+//        }
+//        insFeeOrders.setJqReceivablePremium(jqReceivablePremium);
+//        insFeeOrders.setJqPayablePremium(jqPayablePremium);
+//
+//        // 初始化商业应收 应付金额
+//        BigDecimal syReceivablePremium = BigDecimal.ZERO;
+//        BigDecimal syPayablePremium = BigDecimal.ZERO;
+//        // 商业险保费 * 入口手续费比例 + 商业险保费 * 跟单费比例 + 商业险保费 * 加投比例 = 商业应收
+//        // 商业险保费 * 出口比例 = 商业应付;
+//        if (syCostType != null) {
+//            // 转换百分比
+//            BigDecimal inletPercent = syCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            BigDecimal addThrowPercent = syCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            BigDecimal exportPercent = syCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            // 商业应收
+//            syReceivablePremium = (insOrdersCosts.getSyPremium().divide(fixedTax)).multiply(inletPercent)
+//                    .add((insOrdersCosts.getSyPremium().divide(fixedTax)).multiply(addThrowPercent))
+//                    .add((insOrdersCosts.getSyPremium().divide(fixedTax)).multiply(syFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
+//            // 商业应付
+//            syPayablePremium = insOrdersCosts.getSyPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
+//            // 商业手续费费用
+//            insFeeOrders.setSyCommissionPremium(insOrdersCosts.getSyPremium().multiply(syEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
+//            // 商业跟单费费用
+//            insFeeOrders.setSyFollowPremium(insOrdersCosts.getSyPremium().multiply(syFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
+//            // 商业加投费费用
+//            insFeeOrders.setSyAdditionalPremium(insOrdersCosts.getSyPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
+//        }
+//        insFeeOrders.setSyReceivablePremium(syReceivablePremium);
+//        insFeeOrders.setSyPayablePremium(syPayablePremium);
+//
+//        // 初始化驾意应收 应付金额
+//        BigDecimal jyReceivablePremium = BigDecimal.ZERO;
+//        BigDecimal jyPayablePremium = BigDecimal.ZERO;
+//        // 驾意险保费 * 入口手续费比例 + 驾意险保费 * 跟单费比例 + 驾意险保费 * 加投比例 = 商业应收
+//        // 驾意险保费 * 出口比例 = 驾意险应付;
+//        if (jyCostType != null) {
+//            // 转换百分比
+//            BigDecimal inletPercent = jyCostType.getInlet().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            BigDecimal addThrowPercent = jyCostType.getAddThrow().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            BigDecimal exportPercent = jyCostType.getExport().divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+//            // 驾意应收
+//            jyReceivablePremium = (insOrdersCosts.getJyPremium().divide(fixedTax)).multiply(inletPercent)
+//                    .add((insOrdersCosts.getJyPremium().divide(fixedTax)).multiply(addThrowPercent))
+//                    .add((insOrdersCosts.getJyPremium().divide(fixedTax)).multiply(jyFollowRatio)).setScale(5, RoundingMode.HALF_EVEN);
+//            // 驾意应付
+//            jyPayablePremium = insOrdersCosts.getJyPremium().multiply(exportPercent.setScale(2, RoundingMode.DOWN));
+//            // 驾意手续费费用
+//            insFeeOrders.setJyCommissionPremium(insOrdersCosts.getJyPremium().multiply(jyEntranceFeeRatio).setScale(5, RoundingMode.HALF_EVEN));
+//            // 驾意跟单费费用
+//            insFeeOrders.setJyFollowPremium(insOrdersCosts.getJyPremium().multiply(jyFollowRatio).setScale(5, RoundingMode.HALF_EVEN));
+//            // 驾意加投费费用
+//            insFeeOrders.setJyAdditionalPremium(insOrdersCosts.getJyPremium().multiply(addThrowPercent).setScale(5, RoundingMode.HALF_EVEN));
+//        }
+//        insFeeOrders.setJyReceivablePremium(jyReceivablePremium);
+//        insFeeOrders.setJyPayablePremium(jyPayablePremium);
+//        // 应收总金额
+//        BigDecimal totalReceivablePremium = jqReceivablePremium.add(syReceivablePremium).add(jyReceivablePremium).setScale(5, RoundingMode.HALF_EVEN);
+//        insFeeOrders.setTotalReceivablePremium(totalReceivablePremium);
+//        // 应付总金额
+//        BigDecimal totalPayablePremium = jqPayablePremium.add(syPayablePremium).add(jyPayablePremium).setScale(2, RoundingMode.DOWN);
+//        insFeeOrders.setTotalPayablePremium(totalPayablePremium);
+//        insFeeOrdersService.save(insFeeOrders);
+//
+//    }
 }

+ 12 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/controller/InsOrdersController.java

@@ -4,10 +4,13 @@ package com.jzg.quotation.summary.controller;
 import com.jzg.commons.aop.OperatorTrajectory;
 import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.dto.InsOrdersParam;
+import com.jzg.commons.entity.po.InsFeeOrders;
 import com.jzg.commons.entity.quote.vo.QuoteVo;
 import com.jzg.commons.entity.quote.vo.orders.InsOrdersAdd;
 import com.jzg.commons.entity.quote.vo.orders.InsOrdersEnd;
+import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
 import com.jzg.quotation.summary.mapper.InsOrdersMapper;
+import com.jzg.quotation.summary.service.InsFeeOrdersService;
 import com.jzg.quotation.summary.service.InsOrdersCarInfoService;
 import com.jzg.quotation.summary.service.InsOrdersService;
 import com.jzg.quotation.summary.service.InsTaskImagesService;
@@ -37,6 +40,9 @@ public class InsOrdersController {
     @Autowired
     private InsOrdersCarInfoService insOrdersCarInfoService;
 
+    @Resource
+    private InsFeeOrdersService insFeeOrdersService;
+
 
     @OperatorTrajectory(moduleName = "车险订单/补录订单)",mapperClass = InsOrdersMapper.class,entityClass = InsOrdersAdd.class,isRecorded = "insOrders.isTemporarily")
     @Operation(summary = "录入订单新增")
@@ -109,4 +115,10 @@ public class InsOrdersController {
         return HttpResult.ok(insOrdersService.getExistCompany());
     }
 
+    @Operation(summary = "费用调整并计算保存")
+    @PostMapping("/adjustmentCostAndSave")
+    public HttpResult<InsFeeOrders> adjustmentCostAndSave(@RequestBody PtlAgreementCostRatioVo ptlAgreementCostRatioVo) throws ReflectiveOperationException {
+        return HttpResult.ok(insFeeOrdersService.calcCosts(ptlAgreementCostRatioVo));
+    }
+
 }

+ 4 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/InsFeeOrdersService.java

@@ -2,6 +2,10 @@ package com.jzg.quotation.summary.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.jzg.commons.entity.po.InsFeeOrders;
+import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
 
 public interface InsFeeOrdersService extends IService<InsFeeOrders> {
+    InsFeeOrders calcCosts(PtlAgreementCostRatioVo ptlAgreementCostRatioVo) throws ReflectiveOperationException;
+
+
 }

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

@@ -1,11 +1,26 @@
 package com.jzg.quotation.summary.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jzg.commons.core.base.BaseController;
+import com.jzg.commons.entity.orders.po.InsOrders;
+import com.jzg.commons.entity.orders.po.InsOrdersCosts;
 import com.jzg.commons.entity.po.InsFeeOrders;
+import com.jzg.commons.entity.po.PtlAgreement;
+import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
+import com.jzg.quotation.commons.client.OrgClient;
 import com.jzg.quotation.summary.mapper.InsFeeOrdersMapper;
 import com.jzg.quotation.summary.service.InsFeeOrdersService;
+import com.jzg.quotation.summary.service.InsOrdersCostsService;
+import com.jzg.quotation.summary.service.InsOrdersService;
+import jakarta.annotation.Resource;
 import org.springframework.stereotype.Service;
 
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.Arrays;
+import java.util.List;
+
 /**
  * @author quchen
  * @date 2025/7/3 8:48
@@ -13,4 +28,176 @@ import org.springframework.stereotype.Service;
 
 @Service
 public class InsFeeOrdersServiceImpl extends ServiceImpl<InsFeeOrdersMapper, InsFeeOrders> implements InsFeeOrdersService {
+    @Resource
+    private InsOrdersService insOrdersService;
+
+    @Resource
+    private InsOrdersCostsService insOrdersCostsService;
+
+    @Resource
+    private OrgClient orgClient;
+
+    @Resource
+    private BaseController baseController;
+
+    @Resource
+    private InsFeeOrdersService insFeeOrdersService;
+
+    @Override
+    public InsFeeOrders calcCosts(PtlAgreementCostRatioVo ptlAgreementCostRatioVo) throws ReflectiveOperationException {
+        // 常量定义 保留小数5位
+        final int SCALE = 5;
+        final RoundingMode ROUNDING_MODE = RoundingMode.HALF_EVEN;
+        final BigDecimal TAX_FACTOR = new BigDecimal("1").divide(new BigDecimal("1.06"), 10, ROUNDING_MODE);
+
+        // 获取订单信息
+        InsOrders insOrders = insOrdersService.getById(ptlAgreementCostRatioVo.getOrderNo());
+        // 获取订单费用信息
+        InsOrdersCosts insOrdersCosts = insOrdersCostsService.getById(insOrders.getId());
+        // 获取协议信息
+        PtlAgreement ptlAgreement = orgClient.getByAgreementId(insOrders.getAgreementId(), baseController.getToken());
+        // 获取费用信息
+        InsFeeOrders insFeeOrders = insFeeOrdersService.getById(insOrders.getId());
+        // 保费
+        BigDecimal jqPremium = insOrdersCosts.getJqPremium();
+        BigDecimal syPremium = insOrdersCosts.getSyPremium();
+        BigDecimal jyPremium = insOrdersCosts.getJyPremium();
+        // 手续费比例
+        BigDecimal jqCommissionRatio = covertPercent(ptlAgreementCostRatioVo.getJqCommissionRatio());
+        BigDecimal syCommissionRatio = covertPercent(ptlAgreementCostRatioVo.getSyCommissionRatio());
+        BigDecimal jyCommissionRatio = covertPercent(ptlAgreementCostRatioVo.getJyCommissionRatio());
+        // 跟单费比例
+        BigDecimal jqFollowRatio = covertPercent(ptlAgreementCostRatioVo.getJqFollowRatio());
+        BigDecimal syFollowRatio = covertPercent(ptlAgreementCostRatioVo.getSyFollowRatio());
+        BigDecimal jyFollowRatio = covertPercent(ptlAgreementCostRatioVo.getJyFollowRatio());
+        // 加投费比例
+        BigDecimal jqAddThrowRatio = covertPercent(ptlAgreementCostRatioVo.getJqAdditionalRatio());
+        BigDecimal syAddThrowRatio = covertPercent(ptlAgreementCostRatioVo.getSyAdditionalRatio());
+        BigDecimal jyAddThrowRatio = covertPercent(ptlAgreementCostRatioVo.getJyAdditionalRatio());
+        // 留点比例
+        BigDecimal jqKeepPointRatio = covertPercent(ptlAgreementCostRatioVo.getJqKeepPointRatio());
+        BigDecimal syKeepPointRatio = covertPercent(ptlAgreementCostRatioVo.getSyKeepPointRatio());
+        BigDecimal jyKeepPointRatio = covertPercent(ptlAgreementCostRatioVo.getJyKeepPointRatio());
+        // 入口比例
+        BigDecimal jqInletRatio = covertPercent(ptlAgreementCostRatioVo.getJqInletRatio());
+        BigDecimal syInletRatio = covertPercent(ptlAgreementCostRatioVo.getSyInletRatio());
+        BigDecimal jyInletRatio = covertPercent(ptlAgreementCostRatioVo.getJyInletRatio());
+        // 出口比例
+        BigDecimal jqExportRatio = covertPercent(ptlAgreementCostRatioVo.getJqExportRatio());
+        BigDecimal syExportRatio = covertPercent(ptlAgreementCostRatioVo.getSyExportRatio());
+        BigDecimal jyExportRatio = covertPercent(ptlAgreementCostRatioVo.getJyExportRatio());
+
+        List<CostTypeParam> typeParams = Arrays.asList(
+                new CostTypeParam("jq", jqPremium, jqCommissionRatio, jqFollowRatio, jqAddThrowRatio,
+                        jqKeepPointRatio, jqInletRatio, jqExportRatio),
+                new CostTypeParam("sy", syPremium, syCommissionRatio, syFollowRatio, syAddThrowRatio,
+                        syKeepPointRatio, syInletRatio, syExportRatio),
+                new CostTypeParam("jy", jyPremium, jyCommissionRatio, jyFollowRatio, jyAddThrowRatio,
+                        jyKeepPointRatio, jyInletRatio, jyExportRatio)
+        );
+        // 5. 根据协议类型计算费用
+        boolean isPlatformAgreement = ptlAgreement.getAgreementType() == 1;
+        BigDecimal totalReceivable = BigDecimal.ZERO;
+        BigDecimal totalPayable = BigDecimal.ZERO;
+
+        for (CostTypeParam param : typeParams) {
+            // 5.1 计算基础保费(平台协议直接用原始保费,私有协议扣税)
+            BigDecimal basePremium = isPlatformAgreement ?
+                    param.premium : divideTaxFactor(param.premium, TAX_FACTOR, SCALE);
+
+            // 5.2 计算各类费用
+            BigDecimal commission = calculateFee(basePremium, param.commissionRatio, SCALE);
+            BigDecimal follow = calculateFee(basePremium, param.followRatio, SCALE);
+            BigDecimal addThrow = calculateFee(basePremium, param.addThrowRatio, SCALE);
+            BigDecimal keepPoint = calculateFee(basePremium, param.keepPointRatio, SCALE);
+            BigDecimal inlet = calculateFee(basePremium, param.inletRatio, SCALE);
+            BigDecimal export = calculateFee(basePremium, param.exportRatio, SCALE);
+
+            // 5.3 设置费用到对象(通过反射或方法引用简化setter调用)
+            setFeeToOrder(insFeeOrders, param.typePrefix, commission, follow, addThrow, keepPoint, inlet, export);
+
+            // 5.4 累加总应收/应付款
+            totalReceivable = totalReceivable.add(inlet);
+            totalPayable = totalPayable.add(export);
+        }
+
+        // 6. 设置总费用并更新
+        insFeeOrders.setTotalReceivablePremium(scale(totalReceivable, SCALE));
+        insFeeOrders.setTotalPayablePremium(scale(totalPayable, SCALE));
+        insFeeOrdersService.updateById(insFeeOrders);
+        return insFeeOrders;
+    }
+
+    // 转换百分比
+    public BigDecimal covertPercent(BigDecimal ratio) {
+        if (ratio == null) {
+            return BigDecimal.ZERO;
+        }
+       return ratio.divide(BigDecimal.valueOf(100), 10, RoundingMode.HALF_EVEN);
+    }
+
+    // 计算单种费用(保费 * 比例)
+    private BigDecimal calculateFee(BigDecimal basePremium, BigDecimal ratio, int scale) {
+        if (basePremium == null || ratio == null) {
+            return BigDecimal.ZERO;
+        }
+        return scale(basePremium.multiply(ratio), scale);
+    }
+
+    // 统一保留小数
+    private BigDecimal scale(BigDecimal value, int scale) {
+        return value.setScale(scale, RoundingMode.HALF_EVEN);
+    }
+
+    // 扣税计算(抽取为方法)
+    private BigDecimal divideTaxFactor(BigDecimal premium, BigDecimal taxFactor, int scale) {
+        if (premium == null) {
+            return BigDecimal.ZERO;
+        }
+        return scale(premium.multiply(taxFactor), scale);
+    }
+
+    private static class CostTypeParam {
+        String typePrefix; // 类型前缀(jq/sy/jy)
+        BigDecimal premium; // 保费
+        BigDecimal commissionRatio; // 手续费比例
+        BigDecimal followRatio; // 跟单费比例
+        BigDecimal addThrowRatio; // 加投费比例
+        BigDecimal keepPointRatio; // 留点比例
+        BigDecimal inletRatio; // 入口比例
+        BigDecimal exportRatio; // 出口比例
+
+        public CostTypeParam(String typePrefix, BigDecimal premium, BigDecimal commissionRatio,
+                             BigDecimal followRatio, BigDecimal addThrowRatio, BigDecimal keepPointRatio,
+                             BigDecimal inletRatio, BigDecimal exportRatio) {
+            this.typePrefix = typePrefix;
+            this.premium = premium;
+            this.commissionRatio = commissionRatio;
+            this.followRatio = followRatio;
+            this.addThrowRatio = addThrowRatio;
+            this.keepPointRatio = keepPointRatio;
+            this.inletRatio = inletRatio;
+            this.exportRatio = exportRatio;
+        }
+    }
+    // 设置费用到订单对象(通过反射简化重复setter)
+    private void setFeeToOrder(InsFeeOrders feeOrders, String prefix,
+                               BigDecimal commission, BigDecimal follow, BigDecimal addThrow,
+                               BigDecimal keepPoint, BigDecimal inlet, BigDecimal export) throws ReflectiveOperationException {
+        Class<?> clazz = InsFeeOrders.class;
+        // 利用反射调用setter方法(如setJqCommissionPremium)
+        setField(feeOrders, clazz, prefix + "CommissionPremium", commission);
+        setField(feeOrders, clazz, prefix + "FollowPremium", follow);
+        setField(feeOrders, clazz, prefix + "AdditionalPremium", addThrow);
+        setField(feeOrders, clazz, prefix + "KeepPointPremium", keepPoint);
+        setField(feeOrders, clazz, prefix + "ReceivablePremium", inlet);
+        setField(feeOrders, clazz, prefix + "PayablePremium", export);
+    }
+
+    // 反射设置字段值
+    private void setField(InsFeeOrders obj, Class<?> clazz, String fieldName, BigDecimal value) throws ReflectiveOperationException {
+        String setterName = "set" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
+        Method setter = clazz.getMethod(setterName, BigDecimal.class);
+        setter.invoke(obj, value);
+    }
 }

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

@@ -951,6 +951,16 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
         InsOrdersQrcode qrcode = insOrdersQrcodeMapper.selectOne(new LambdaQueryWrapper<InsOrdersQrcode>()
                 .eq(InsOrdersQrcode::getOrderno, ordersNo));
         resultVo.setQrcode(qrcode);
+        // 费用信息
+        InsFeeOrders insFeeOrders = insFeeOrdersService.getOne(new LambdaQueryWrapper<InsFeeOrders>()
+                .eq(InsFeeOrders::getOrderNo, ordersNo));
+        resultVo.setInsFeeOrders(new InsFeeOrdersVo(insFeeOrders));
+        // 比例信息
+        if (insFeeOrders != null) {
+            List<PtlAgreementCostTypeVo> ptlAgreementCostTypeList = orgClient.queryByCostId(insFeeOrders.getCostId());
+            PtlAgreement ptlAgreement = orgClient.getByAgreementId(insOrdersVo.getInsOrders().getAgreementId(),baseController.getToken());
+            resultVo.setCostRatio(new PtlAgreementCostRatioVo(ptlAgreementCostTypeList,ptlAgreement));
+        }
         return resultVo;
     }
 

+ 6 - 0
tenant/organization/src/main/java/com/jzg/organization/controller/AgreementController.java

@@ -236,4 +236,10 @@ public class AgreementController extends BaseController {
     public HttpResult getByCompanyCode(String companyId) {
         return HttpResult.ok(agreementService.getByCompanyId(companyId));
     }
+
+    @Operation(summary = "根据协议id查找协议")
+    @GetMapping("/getByAgreementId")
+    public PtlAgreement getByAgreementId(String agreementId) {
+        return agreementService.getById(agreementId);
+    }
 }

+ 1 - 0
tenant/organization/src/main/resources/application.yml

@@ -65,6 +65,7 @@ tenant:
     - dept_tree
     - dept_path
     - ptl_agreement_cost_type
+    - ptl_agreement
 
   ignoreLoginNames: