浏览代码

缺失功能:
订单审核-我的审核,审核订单调整费用,修改留点比例后,出口不会跟着变

jiakai 4 月之前
父节点
当前提交
05a2074e41

+ 19 - 0
commons/src/main/java/com/jzg/commons/entity/dto/CostCalculateRespVO.java

@@ -0,0 +1,19 @@
+package com.jzg.commons.entity.dto;
+
+import com.jzg.commons.entity.po.InsFeeOrders;
+import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+@Schema(description = "纯费用计算-出参")
+public class CostCalculateRespVO {
+
+    @Schema(description = "费用订单信息")
+    private InsFeeOrders insFeeOrders;
+
+    @Schema(description = "费用比例信息")
+    private PtlAgreementCostRatioVo costRatio;
+}

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

@@ -5,6 +5,7 @@ import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.dto.CostCalculateRespVO;
 import com.jzg.commons.entity.dto.FeeAuditParam;
 import com.jzg.commons.entity.dto.VerifyOrderParam;
 import com.jzg.commons.entity.orders.vo.AuditCostInfoVo;
@@ -181,4 +182,15 @@ public class InsFeeAuditController {
         insFeeAuditService.saveCostInfo(param);
         return HttpResult.ok();
     }
+
+    /**
+     * 保存调整的费用
+     * @return
+     */
+    @PostMapping("/computedCostInfo")
+    @Operation(summary = "计算调整的费用")
+    public HttpResult<CostCalculateRespVO> computedCostInfo(@RequestBody PtlAgreementCostRatioVo param){
+        CostCalculateRespVO costCalculateRespVO = insFeeAuditService.computedCostInfo(param);
+        return HttpResult.ok(costCalculateRespVO);
+    }
 }

+ 3 - 0
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/InsFeeAuditService.java

@@ -2,6 +2,7 @@ package com.jzg.quotation.summary.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.jzg.commons.entity.dto.CostCalculateRespVO;
 import com.jzg.commons.entity.dto.FeeAuditParam;
 import com.jzg.commons.entity.dto.VerifyOrderParam;
 import com.jzg.commons.entity.orders.po.InsFeeAudit;
@@ -101,4 +102,6 @@ public interface InsFeeAuditService extends IService<InsFeeAudit> {
      * @return
      */
     String exportAuditList(FeeAuditParam param);
+
+    CostCalculateRespVO computedCostInfo(PtlAgreementCostRatioVo param);
 }

+ 2 - 1
tenant/insurance/quotation-summary/src/main/java/com/jzg/quotation/summary/service/InsFeeOrdersService.java

@@ -2,6 +2,7 @@ package com.jzg.quotation.summary.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.dto.CostCalculateRespVO;
 import com.jzg.commons.entity.dto.InsFeeOrdersParam;
 import com.jzg.commons.entity.po.InsFeeOrders;
 import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
@@ -24,5 +25,5 @@ public interface InsFeeOrdersService extends IService<InsFeeOrders> {
 
     HttpResult updateAvailableAmount(String orderNo,BigDecimal availableAmount);
 
-
+    CostCalculateRespVO computedCostInfo(PtlAgreementCostRatioVo param);
 }

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

@@ -11,6 +11,7 @@ import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.base.StateResult;
 import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.account.po.SysUserAccountIncomeLog;
+import com.jzg.commons.entity.dto.CostCalculateRespVO;
 import com.jzg.commons.entity.dto.FeeAuditParam;
 import com.jzg.commons.entity.dto.VerifyOrderParam;
 import com.jzg.commons.entity.orders.po.*;
@@ -724,6 +725,11 @@ public class InsFeeAuditServiceImpl extends ServiceImpl<InsFeeAuditMapper, InsFe
         recordService.updateById(record);
     }
 
+    @Override
+    public CostCalculateRespVO computedCostInfo(PtlAgreementCostRatioVo param) {
+        return feeOrdersService.computedCostInfo(param);
+    }
+
     /**
      * 导出订单审核列表
      * @param param

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

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.page.HttpResult;
+import com.jzg.commons.entity.dto.CostCalculateRespVO;
 import com.jzg.commons.entity.dto.InsFeeOrdersParam;
 import com.jzg.commons.entity.orders.po.InsOrders;
 import com.jzg.commons.entity.orders.po.InsOrdersCosts;
@@ -62,19 +63,15 @@ public class InsFeeOrdersServiceImpl extends ServiceImpl<InsFeeOrdersMapper, Ins
     }
 
     @Override
-    public InsFeeOrders calcCosts(PtlAgreementCostRatioVo ptlAgreementCostRatioVo) throws ReflectiveOperationException {
+    public CostCalculateRespVO computedCostInfo(PtlAgreementCostRatioVo ptlAgreementCostRatioVo) {
         // 常量定义 保留小数5位
         final int SCALE = 5;
-        final RoundingMode ROUNDING_MODE = RoundingMode.HALF_EVEN;
-        final BigDecimal ONE_HUNDRED = new BigDecimal("100");
         final BigDecimal TAX_RATE = new BigDecimal("1.06");
 
         // 获取订单信息
         InsOrders insOrders = insOrdersService.getById(ptlAgreementCostRatioVo.getOrderNo());
         // 获取订单费用信息
         InsOrdersCosts insOrdersCosts = insOrdersCostsService.getById(insOrders.getId());
-
-        String systemCode = getSystemCode();
         // 获取协议信息
         PtlAgreement ptlAgreement = orgClient.getByAgreementId(insOrders.getAgreementId());
         // 获取费用信息
@@ -89,7 +86,7 @@ public class InsFeeOrdersServiceImpl extends ServiceImpl<InsFeeOrdersMapper, Ins
         BigDecimal jyPremium = insOrdersCosts.getJyPremium() == null ? BigDecimal.ZERO : insOrdersCosts.getJyPremium();
 
         // 更新对象中的比例字段
-        saveRatio(ptlAgreementCostRatioVo, insFeeOrders);
+        copyRatio(ptlAgreementCostRatioVo, insFeeOrders);
 
         // 核心:规则重新计算所有费用
         // 1. 交强险
@@ -117,6 +114,67 @@ public class InsFeeOrdersServiceImpl extends ServiceImpl<InsFeeOrdersMapper, Ins
         insFeeOrders.setTotalPayablePremium(scale(totalPayable, SCALE));
         insFeeOrders.setTotalReceivablePremium(scale(totalReceivable, SCALE));
 
+        // 拼接返回值
+        CostCalculateRespVO costCalculateRespVO = new CostCalculateRespVO();
+        costCalculateRespVO.setInsFeeOrders(insFeeOrders);
+        costCalculateRespVO.setCostRatio(new PtlAgreementCostRatioVo(insFeeOrders));
+        return costCalculateRespVO;
+    }
+
+
+    @Override
+    public InsFeeOrders calcCosts(PtlAgreementCostRatioVo ptlAgreementCostRatioVo) {
+        // 常量定义 保留小数5位
+        final int SCALE = 5;
+        final BigDecimal TAX_RATE = new BigDecimal("1.06");
+
+        // 获取订单信息
+        InsOrders insOrders = insOrdersService.getById(ptlAgreementCostRatioVo.getOrderNo());
+        // 获取订单费用信息
+        InsOrdersCosts insOrdersCosts = insOrdersCostsService.getById(insOrders.getId());
+        // 获取协议信息
+        PtlAgreement ptlAgreement = orgClient.getByAgreementId(insOrders.getAgreementId());
+        // 获取费用信息
+        InsFeeOrders insFeeOrders = insFeeOrdersMapper.selectById(insOrders.getId());
+
+        // 关键:获取是否含税标识
+        Integer withTax = ptlAgreement.getWithTax(); // 0-否 1-是
+
+        // 保费
+        BigDecimal jqPremium = insOrdersCosts.getJqPremium() == null ? BigDecimal.ZERO : insOrdersCosts.getJqPremium();
+        BigDecimal syPremium = insOrdersCosts.getSyPremium() == null ? BigDecimal.ZERO : insOrdersCosts.getSyPremium();
+        BigDecimal jyPremium = insOrdersCosts.getJyPremium() == null ? BigDecimal.ZERO : insOrdersCosts.getJyPremium();
+
+        // 更新对象中的比例字段
+        copyRatio(ptlAgreementCostRatioVo, insFeeOrders);
+
+        // 核心:规则重新计算所有费用
+        // 1. 交强险
+        calculatePremiumByRule(insFeeOrders,
+                "jq", jqPremium,
+                insFeeOrders.getJqCommissionRatio(), insFeeOrders.getJqInletRatio(), insFeeOrders.getJqFollowRatio(),
+                insFeeOrders.getJqAdditionalRatio(), insFeeOrders.getJqKeepPointRatio(), insFeeOrders.getJqExportRatio(), insFeeOrders.getJqExportKeepPointRatio(),
+                withTax, TAX_RATE, SCALE);
+
+        // 2. 商业险
+        calculatePremiumByRule(insFeeOrders, "sy", syPremium,
+                insFeeOrders.getSyCommissionRatio(), insFeeOrders.getSyInletRatio(), insFeeOrders.getSyFollowRatio(),
+                insFeeOrders.getSyAdditionalRatio(), insFeeOrders.getSyKeepPointRatio(), insFeeOrders.getSyExportRatio(), insFeeOrders.getSyExportKeepPointRatio(),
+                withTax, TAX_RATE, SCALE);
+
+        // 3. 驾乘险
+        calculatePremiumByRule(insFeeOrders, "jy", jyPremium,
+                insFeeOrders.getJyCommissionRatio(), insFeeOrders.getJyInletRatio(), insFeeOrders.getJyFollowRatio(),
+                insFeeOrders.getJyAdditionalRatio(), insFeeOrders.getJyKeepPointRatio(), insFeeOrders.getJyExportRatio(), insFeeOrders.getJyExportKeepPointRatio(),
+                withTax, TAX_RATE, SCALE);
+
+        // 重新统计总应收、总应付
+        BigDecimal totalPayable = insFeeOrders.getJqPayablePremium().add(insFeeOrders.getSyPayablePremium()).add(insFeeOrders.getJyPayablePremium());
+        BigDecimal totalReceivable = insFeeOrders.getJqReceivablePremium().add(insFeeOrders.getSyReceivablePremium()).add(insFeeOrders.getJyReceivablePremium());
+
+        insFeeOrders.setTotalPayablePremium(scale(totalPayable, SCALE));
+        insFeeOrders.setTotalReceivablePremium(scale(totalReceivable, SCALE));
+
         // 保存比例
         this.updateById(insFeeOrders);
         return insFeeOrders;
@@ -267,31 +325,50 @@ public class InsFeeOrdersServiceImpl extends ServiceImpl<InsFeeOrdersMapper, Ins
     }
 
     // 保存比例
-    private void saveRatio(PtlAgreementCostRatioVo ptlAgreementCostRatioVo, InsFeeOrders insFeeOrders) {
+    private void copyRatio(PtlAgreementCostRatioVo ptlAgreementCostRatioVo, InsFeeOrders insFeeOrders) {
         // 手续费比例
-        insFeeOrders.setJqCommissionRatio(covertPercent(ptlAgreementCostRatioVo.getJqCommissionRatio()));
-        insFeeOrders.setSyCommissionRatio(covertPercent(ptlAgreementCostRatioVo.getSyCommissionRatio()));
-        insFeeOrders.setJyCommissionRatio(covertPercent(ptlAgreementCostRatioVo.getJyCommissionRatio()));
+        BigDecimal jqCommissionRatio = covertPercent(ptlAgreementCostRatioVo.getJqCommissionRatio());
+        BigDecimal syCommissionRatio = covertPercent(ptlAgreementCostRatioVo.getSyCommissionRatio());
+        BigDecimal jyCommissionRatio = covertPercent(ptlAgreementCostRatioVo.getJyCommissionRatio());
+        insFeeOrders.setJqCommissionRatio(jqCommissionRatio);
+        insFeeOrders.setSyCommissionRatio(syCommissionRatio);
+        insFeeOrders.setJyCommissionRatio(jyCommissionRatio);
         // 入口比例
-        insFeeOrders.setJqInletRatio(covertPercent(ptlAgreementCostRatioVo.getJqInletRatio()));
-        insFeeOrders.setSyInletRatio(covertPercent(ptlAgreementCostRatioVo.getSyInletRatio()));
-        insFeeOrders.setJyInletRatio(covertPercent(ptlAgreementCostRatioVo.getJyInletRatio()));
+        BigDecimal jqInletRatio = covertPercent(ptlAgreementCostRatioVo.getJqInletRatio());
+        BigDecimal syInletRatio = covertPercent(ptlAgreementCostRatioVo.getSyInletRatio());
+        BigDecimal jyInletRatio = covertPercent(ptlAgreementCostRatioVo.getJyInletRatio());
+        insFeeOrders.setJqInletRatio(jqInletRatio);
+        insFeeOrders.setSyInletRatio(syInletRatio);
+        insFeeOrders.setJyInletRatio(jyInletRatio);
         // 跟单比例
-        insFeeOrders.setJqFollowRatio(insFeeOrders.getJqInletRatio().subtract(insFeeOrders.getJqCommissionRatio()));
-        insFeeOrders.setSyFollowRatio(insFeeOrders.getSyInletRatio().subtract(insFeeOrders.getSyCommissionRatio()));
-        insFeeOrders.setJyFollowRatio(insFeeOrders.getJyInletRatio().subtract(insFeeOrders.getJyCommissionRatio()));
+        BigDecimal jqFollowRatio = jqInletRatio.subtract(jqCommissionRatio);
+        BigDecimal syFollowRatio = syInletRatio.subtract(syCommissionRatio);
+        BigDecimal jyFollowRatio = jyInletRatio.subtract(jyCommissionRatio);
+        insFeeOrders.setJqFollowRatio(jqFollowRatio);
+        insFeeOrders.setSyFollowRatio(syFollowRatio);
+        insFeeOrders.setJyFollowRatio(jyFollowRatio);
         // 加投比例
-        insFeeOrders.setJqAdditionalRatio(covertPercent(ptlAgreementCostRatioVo.getJqAdditionalRatio()));
-        insFeeOrders.setSyAdditionalRatio(covertPercent(ptlAgreementCostRatioVo.getSyAdditionalRatio()));
-        insFeeOrders.setJyAdditionalRatio(covertPercent(ptlAgreementCostRatioVo.getJyAdditionalRatio()));
-        // 留点比例
-        insFeeOrders.setJqKeepPointRatio(covertPercent(ptlAgreementCostRatioVo.getJqKeepPointRatio()));
-        insFeeOrders.setSyKeepPointRatio(covertPercent(ptlAgreementCostRatioVo.getSyKeepPointRatio()));
-        insFeeOrders.setJyKeepPointRatio(covertPercent(ptlAgreementCostRatioVo.getJyKeepPointRatio()));
+        BigDecimal jqAdditionalRatio = covertPercent(ptlAgreementCostRatioVo.getJqAdditionalRatio());
+        BigDecimal syAdditionalRatio = covertPercent(ptlAgreementCostRatioVo.getSyAdditionalRatio());
+        BigDecimal jyAdditionalRatio = covertPercent(ptlAgreementCostRatioVo.getJyAdditionalRatio());
+        insFeeOrders.setJqAdditionalRatio(jqAdditionalRatio);
+        insFeeOrders.setSyAdditionalRatio(syAdditionalRatio);
+        insFeeOrders.setJyAdditionalRatio(jyAdditionalRatio);
         // 出口比例
-        insFeeOrders.setJqExportRatio(covertPercent(ptlAgreementCostRatioVo.getJqExportRatio()));
-        insFeeOrders.setSyExportRatio(covertPercent(ptlAgreementCostRatioVo.getSyExportRatio()));
-        insFeeOrders.setJyExportRatio(covertPercent(ptlAgreementCostRatioVo.getJyExportRatio()));
+        BigDecimal jqExportRatio = covertPercent(ptlAgreementCostRatioVo.getJqExportRatio());
+        BigDecimal syExportRatio = covertPercent(ptlAgreementCostRatioVo.getSyExportRatio());
+        BigDecimal jyExportRatio = covertPercent(ptlAgreementCostRatioVo.getJyExportRatio());
+        insFeeOrders.setJqExportRatio(jqExportRatio);
+        insFeeOrders.setSyExportRatio(syExportRatio);
+        insFeeOrders.setJyExportRatio(jyExportRatio);
+        // 需求:入口 + 加投 - 出口 = 留点
+        BigDecimal jqKeepPointRatio = jqInletRatio.add(jqAdditionalRatio).subtract(jqExportRatio);
+        BigDecimal syKeepPointRatio = syInletRatio.add(syAdditionalRatio).subtract(syExportRatio);
+        BigDecimal jyKeepPointRatio = jyInletRatio.add(jyAdditionalRatio).subtract(jyExportRatio);
+        // 留点比例
+        insFeeOrders.setJqKeepPointRatio(jqKeepPointRatio);
+        insFeeOrders.setSyKeepPointRatio(syKeepPointRatio);
+        insFeeOrders.setJyKeepPointRatio(jyKeepPointRatio);
         // 出口留点比例
         insFeeOrders.setJqExportKeepPointRatio(covertPercent(ptlAgreementCostRatioVo.getJqExportKeepPointRatio()));
         insFeeOrders.setSyExportKeepPointRatio(covertPercent(ptlAgreementCostRatioVo.getSyExportKeepPointRatio()));