Bladeren bron

电销填写出口费用计算

dongxin 1 jaar geleden
bovenliggende
commit
c077bdc3f4

+ 9 - 0
sql/Online.sql

@@ -0,0 +1,9 @@
+--  2024-10-15 BY dongxin statr
+ALTER TABLE `agent`.`ins_fee_telemarketing`
+ADD COLUMN `jq_total_proportion` decimal(10, 2) NULL DEFAULT NULL COMMENT '交强优惠比例' AFTER `create_time`,
+ADD COLUMN `sy_total_proportion` decimal(10, 2) NULL DEFAULT NULL COMMENT '商业优惠比例' AFTER `jq_total_proportion`,
+ADD COLUMN `no_total_proportion` decimal(10, 2) NULL DEFAULT NULL COMMENT '非车优惠比例' AFTER `sy_total_proportion`,
+ADD COLUMN `first_jq_total_proportion` decimal(10, 2) NULL DEFAULT NULL COMMENT '初始交强优惠比例' AFTER `no_total_proportion`,
+ADD COLUMN `first_sy_total_proportion` decimal(10, 2) NULL DEFAULT NULL COMMENT '初始商业优惠比例' AFTER `first_jq_total_proportion`,
+ADD COLUMN `first_no_total_proportion` decimal(10, 2) NULL DEFAULT NULL COMMENT '初始非车优惠比例' AFTER `first_sy_total_proportion`;
+--  2024-10-15 BY dongxin end

+ 3 - 3
src/main/java/com/ydtech/modules/fee/dao/InsFeeTelemarketingMapper.java

@@ -4,10 +4,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ydtech.modules.fee.entity.po.InsFeeTelemarketing;
 
 /**
-* @author Administrator
+* @author dongxin
 * @description 针对表【ins_fee_telemarketing(电销费用扣减比例)】的数据库操作Mapper
-* @createDate 2024-08-28 19:13:00
-* @Entity com.ydtech.modules.fee.entity.po.InsFeeTelemarketing
+* @createDate 2024-10-15 11:02:51
+* @Entity generator.domain.InsFeeTelemarketing
 */
 public interface InsFeeTelemarketingMapper extends BaseMapper<InsFeeTelemarketing> {
 

+ 73 - 23
src/main/java/com/ydtech/modules/fee/entity/po/InsFeeTelemarketing.java

@@ -4,74 +4,106 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.util.Date;
-
 import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.order.entity.vo.SubmitExportFeesVo;
 import lombok.Data;
 
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
 /**
  * 电销费用扣减比例
- *
  * @TableName ins_fee_telemarketing
  */
-@TableName(value = "ins_fee_telemarketing")
+@TableName(value ="ins_fee_telemarketing")
 @Data
 public class InsFeeTelemarketing implements Serializable {
     /**
      * 主键
      */
-    @TableId(value = "id", type = IdType.AUTO)
+    @TableId(type = IdType.AUTO)
     private Integer id;
 
     /**
      * 子订单id
      */
-    @TableField(value = "sub_order_no")
     private String subOrderNo;
 
     /**
      * 交强扣减比例
      */
-    @TableField(value = "jq_export_proportion")
     private BigDecimal jqExportProportion;
 
     /**
      * 商业扣减比例
      */
-    @TableField(value = "sy_export_proportion")
     private BigDecimal syExportProportion;
 
     /**
      * 非车扣减比例
      */
-    @TableField(value = "no_car_export_proportion")
     private BigDecimal noCarExportProportion;
 
     /**
      * 创建用户
      */
-    @TableField(value = "create_user")
     private String createUser;
 
     /**
      * 创建时间
      */
-    @TableField(value = "create_time")
-    private Date createTime;
+    private LocalDateTime createTime;
+
+    /**
+     * 交强优惠比例
+     */
+    private BigDecimal jqTotalProportion;
+
+    /**
+     * 商业优惠比例
+     */
+    private BigDecimal syTotalProportion;
+
+    /**
+     * 非车优惠比例
+     */
+    private BigDecimal noTotalProportion;
+
+    /**
+     * 初始交强优惠比例
+     */
+    private BigDecimal firstJqTotalProportion;
+
+    /**
+     * 初始商业优惠比例
+     */
+    private BigDecimal firstSyTotalProportion;
+
+    /**
+     * 初始非车优惠比例
+     */
+    private BigDecimal firstNoTotalProportion;
 
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
 
+    public InsFeeTelemarketing() {
+        super();
+    }
+
     public InsFeeTelemarketing(SubmitExportFeesVo submitExportFeesVo) {
         this.subOrderNo = submitExportFeesVo.getSubOrderNo();
         this.jqExportProportion = submitExportFeesVo.getJqExportProportion();
         this.syExportProportion = submitExportFeesVo.getSyExportProportion();
         this.noCarExportProportion = submitExportFeesVo.getNoCarExportProportion();
-        this.createTime = new Date();
+        this.jqTotalProportion = submitExportFeesVo.getJqdiscountrate();
+        this.syTotalProportion = submitExportFeesVo.getSydiscountrate();
+        this.noTotalProportion = submitExportFeesVo.getNodiscountrate();
+        this.firstJqTotalProportion = submitExportFeesVo.getFirstjqdiscountrate();
+        this.firstSyTotalProportion = submitExportFeesVo.getFirstsydiscountrate();
+        this.firstNoTotalProportion = submitExportFeesVo.getFirstnodiscountrate();
+        this.createTime = LocalDateTime.now();
         this.createUser = BaseController.getUserId();
     }
 
@@ -88,12 +120,18 @@ public class InsFeeTelemarketing implements Serializable {
         }
         InsFeeTelemarketing other = (InsFeeTelemarketing) that;
         return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
-                && (this.getSubOrderNo() == null ? other.getSubOrderNo() == null : this.getSubOrderNo().equals(other.getSubOrderNo()))
-                && (this.getJqExportProportion() == null ? other.getJqExportProportion() == null : this.getJqExportProportion().equals(other.getJqExportProportion()))
-                && (this.getSyExportProportion() == null ? other.getSyExportProportion() == null : this.getSyExportProportion().equals(other.getSyExportProportion()))
-                && (this.getNoCarExportProportion() == null ? other.getNoCarExportProportion() == null : this.getNoCarExportProportion().equals(other.getNoCarExportProportion()))
-                && (this.getCreateUser() == null ? other.getCreateUser() == null : this.getCreateUser().equals(other.getCreateUser()))
-                && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
+            && (this.getSubOrderNo() == null ? other.getSubOrderNo() == null : this.getSubOrderNo().equals(other.getSubOrderNo()))
+            && (this.getJqExportProportion() == null ? other.getJqExportProportion() == null : this.getJqExportProportion().equals(other.getJqExportProportion()))
+            && (this.getSyExportProportion() == null ? other.getSyExportProportion() == null : this.getSyExportProportion().equals(other.getSyExportProportion()))
+            && (this.getNoCarExportProportion() == null ? other.getNoCarExportProportion() == null : this.getNoCarExportProportion().equals(other.getNoCarExportProportion()))
+            && (this.getCreateUser() == null ? other.getCreateUser() == null : this.getCreateUser().equals(other.getCreateUser()))
+            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
+            && (this.getJqTotalProportion() == null ? other.getJqTotalProportion() == null : this.getJqTotalProportion().equals(other.getJqTotalProportion()))
+            && (this.getSyTotalProportion() == null ? other.getSyTotalProportion() == null : this.getSyTotalProportion().equals(other.getSyTotalProportion()))
+            && (this.getNoTotalProportion() == null ? other.getNoTotalProportion() == null : this.getNoTotalProportion().equals(other.getNoTotalProportion()))
+            && (this.getFirstJqTotalProportion() == null ? other.getFirstJqTotalProportion() == null : this.getFirstJqTotalProportion().equals(other.getFirstJqTotalProportion()))
+            && (this.getFirstSyTotalProportion() == null ? other.getFirstSyTotalProportion() == null : this.getFirstSyTotalProportion().equals(other.getFirstSyTotalProportion()))
+            && (this.getFirstNoTotalProportion() == null ? other.getFirstNoTotalProportion() == null : this.getFirstNoTotalProportion().equals(other.getFirstNoTotalProportion()));
     }
 
     @Override
@@ -107,6 +145,12 @@ public class InsFeeTelemarketing implements Serializable {
         result = prime * result + ((getNoCarExportProportion() == null) ? 0 : getNoCarExportProportion().hashCode());
         result = prime * result + ((getCreateUser() == null) ? 0 : getCreateUser().hashCode());
         result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
+        result = prime * result + ((getJqTotalProportion() == null) ? 0 : getJqTotalProportion().hashCode());
+        result = prime * result + ((getSyTotalProportion() == null) ? 0 : getSyTotalProportion().hashCode());
+        result = prime * result + ((getNoTotalProportion() == null) ? 0 : getNoTotalProportion().hashCode());
+        result = prime * result + ((getFirstJqTotalProportion() == null) ? 0 : getFirstJqTotalProportion().hashCode());
+        result = prime * result + ((getFirstSyTotalProportion() == null) ? 0 : getFirstSyTotalProportion().hashCode());
+        result = prime * result + ((getFirstNoTotalProportion() == null) ? 0 : getFirstNoTotalProportion().hashCode());
         return result;
     }
 
@@ -123,8 +167,14 @@ public class InsFeeTelemarketing implements Serializable {
         sb.append(", noCarExportProportion=").append(noCarExportProportion);
         sb.append(", createUser=").append(createUser);
         sb.append(", createTime=").append(createTime);
+        sb.append(", jqTotalProportion=").append(jqTotalProportion);
+        sb.append(", syTotalProportion=").append(syTotalProportion);
+        sb.append(", noTotalProportion=").append(noTotalProportion);
+        sb.append(", firstJqTotalProportion=").append(firstJqTotalProportion);
+        sb.append(", firstSyTotalProportion=").append(firstSyTotalProportion);
+        sb.append(", firstNoTotalProportion=").append(firstNoTotalProportion);
         sb.append(", serialVersionUID=").append(serialVersionUID);
         sb.append("]");
         return sb.toString();
     }
-}
+}

+ 12 - 2
src/main/java/com/ydtech/modules/fee/service/InsFeeTelemarketingService.java

@@ -1,13 +1,23 @@
 package com.ydtech.modules.fee.service;
 
+import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ydtech.modules.fee.entity.po.InsFeeTelemarketing;
 
+import java.util.List;
+
 /**
-* @author Administrator
+* @author dongxin
 * @description 针对表【ins_fee_telemarketing(电销费用扣减比例)】的数据库操作Service
-* @createDate 2024-08-28 19:13:00
+* @createDate 2024-10-15 11:02:51
 */
 public interface InsFeeTelemarketingService extends IService<InsFeeTelemarketing> {
 
+    default InsFeeTelemarketing getByInsOrderNo(String id){
+        List<InsFeeTelemarketing> insFeeTelemarketingList = lambdaQuery()
+                .eq(InsFeeTelemarketing::getSubOrderNo,id)
+                .list();
+
+        return CollUtil.isNotEmpty(insFeeTelemarketingList)? insFeeTelemarketingList.get(0):null;
+    }
 }

+ 2 - 2
src/main/java/com/ydtech/modules/fee/service/impl/InsFeeTelemarketingServiceImpl.java

@@ -7,9 +7,9 @@ import com.ydtech.modules.fee.service.InsFeeTelemarketingService;
 import org.springframework.stereotype.Service;
 
 /**
-* @author Administrator
+* @author dongxin
 * @description 针对表【ins_fee_telemarketing(电销费用扣减比例)】的数据库操作Service实现
-* @createDate 2024-08-28 19:13:00
+* @createDate 2024-10-15 11:02:51
 */
 @Service
 public class InsFeeTelemarketingServiceImpl extends ServiceImpl<InsFeeTelemarketingMapper, InsFeeTelemarketing>

+ 43 - 0
src/main/java/com/ydtech/modules/order/entity/vo/SubmitExportFeesVo.java

@@ -1,6 +1,7 @@
 package com.ydtech.modules.order.entity.vo;
 
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.ydtech.utils.ObjectUtil;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
@@ -27,6 +28,24 @@ public class SubmitExportFeesVo {
     @ApiModelProperty("非车出口比例")
     private BigDecimal noCarExportProportion;
 
+    @ApiModelProperty("交强优惠比例")
+    private BigDecimal jqdiscountrate;
+
+    @ApiModelProperty("商业优惠比例")
+    private BigDecimal sydiscountrate;
+
+    @ApiModelProperty("非车优惠比例")
+    private BigDecimal nodiscountrate;
+
+    @ApiModelProperty("初始交强优惠比例")
+    private BigDecimal firstjqdiscountrate;
+
+    @ApiModelProperty("初始商业优惠比例")
+    private BigDecimal firstsydiscountrate;
+
+    @ApiModelProperty("初始非车优惠比例")
+    private BigDecimal firstnodiscountrate;
+
     @ApiModelProperty("子订单号")
     private String subOrderNo;
 
@@ -44,4 +63,28 @@ public class SubmitExportFeesVo {
     public BigDecimal getNoCarExportProportion() {
         return ObjectUtils.isEmpty(noCarExportProportion)  ? BigDecimal.ZERO : noCarExportProportion;
     }
+
+    public BigDecimal getNodiscountrate() {
+        return ObjectUtils.isEmpty(nodiscountrate)  ? BigDecimal.ZERO : nodiscountrate;
+    }
+
+    public BigDecimal getSydiscountrate() {
+        return ObjectUtils.isEmpty(sydiscountrate)  ? BigDecimal.ZERO : sydiscountrate;
+    }
+
+    public BigDecimal getJqdiscountrate() {
+        return ObjectUtils.isEmpty(jqdiscountrate)  ? BigDecimal.ZERO : jqdiscountrate;
+    }
+
+    public BigDecimal getFirstjqdiscountrate() {
+        return ObjectUtils.isEmpty(firstjqdiscountrate)  ? BigDecimal.ZERO : firstjqdiscountrate;
+    }
+
+    public BigDecimal getFirstsydiscountrate() {
+        return ObjectUtils.isEmpty(firstsydiscountrate)  ? BigDecimal.ZERO : firstsydiscountrate;
+    }
+
+    public BigDecimal getFirstnodiscountrate() {
+        return ObjectUtils.isEmpty(firstnodiscountrate)  ? BigDecimal.ZERO : firstnodiscountrate;
+    }
 }

+ 94 - 18
src/main/java/com/ydtech/modules/order/entity/vo/telemarketing/TelemarketingAuditOrderEditVo.java

@@ -2,7 +2,7 @@ package com.ydtech.modules.order.entity.vo.telemarketing;
 
 
 import com.ydtech.modules.fee.entity.po.InsFeeOrderNewHistory;
-import com.ydtech.modules.order.entity.vo.FeeOrderNewVo;
+import com.ydtech.modules.fee.entity.po.InsFeeTelemarketing;
 import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
@@ -13,6 +13,7 @@ import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 @Data
 @AllArgsConstructor
@@ -24,23 +25,88 @@ public class TelemarketingAuditOrderEditVo implements Serializable {
     @ApiModelProperty("出口费用")
     private List<ExportFeeDTO> exportFee;
 
-    public TelemarketingAuditOrderEditVo(InsFeeOrderNew insFeeOrderNew) {
+    public TelemarketingAuditOrderEditVo(InsFeeOrderNew insFeeOrderNew, InsFeeOrderNewHistory insFeeOrderNewHistory, InsFeeTelemarketing insFeeTelemarketing) {
         List<ExportFeeDTO> exportFeeDTOS = new ArrayList<>();
-        ExportFeeDTO jqExportFee = new ExportFeeDTO("交强险", insFeeOrderNew.getJqPremium(), insFeeOrderNew.getJqCostsExportProportion(),
-                insFeeOrderNew.getJqExportOtherCostsProportion(),
-                insFeeOrderNew.getJqExportSuperviseCostsPremiums(), insFeeOrderNew.getJqExportOtherCostsPremiums());
-        exportFeeDTOS.add(jqExportFee);
-        ExportFeeDTO syExportFee = new ExportFeeDTO("商业险",
-                insFeeOrderNew.getSyPremium(), insFeeOrderNew.getSyCostsExportProportion(),
-                insFeeOrderNew.getSyExportOtherCostsProportion(),
-                insFeeOrderNew.getSyExportSuperviseCostsPremiums(), insFeeOrderNew.getSyExportOtherCostsPremiums()
-        );
-        exportFeeDTOS.add(syExportFee);
-        ExportFeeDTO noExportFee = new ExportFeeDTO("非车险",
-                insFeeOrderNew.getNoPremium(), insFeeOrderNew.getNoCostsExportProportion(),
-                insFeeOrderNew.getNoExportOtherCostsProportion(),
-                insFeeOrderNew.getNoExportSuperviseCostsPremiums(), insFeeOrderNew.getNoExportOtherCostsPremiums());
-        exportFeeDTOS.add(noExportFee);
+
+        if(!Objects.isNull(insFeeTelemarketing) && !Objects.isNull(insFeeTelemarketing.getFirstJqTotalProportion())){
+            ExportFeeDTO jqExportFee = new ExportFeeDTO("交强险", insFeeOrderNew.getJqPremium(), insFeeOrderNew.getJqCostsExportProportion(),
+                    insFeeOrderNew.getJqExportOtherCostsProportion(),
+                    insFeeOrderNew.getJqExportSuperviseCostsPremiums(),
+                    insFeeOrderNew.getJqExportOtherCostsPremiums(),
+                    insFeeTelemarketing.getFirstJqTotalProportion(),
+                    BigDecimal.ZERO
+            );
+            exportFeeDTOS.add(jqExportFee);
+            ExportFeeDTO syExportFee = new ExportFeeDTO("商业险",
+                    insFeeOrderNew.getSyPremium(), insFeeOrderNew.getSyCostsExportProportion(),
+                    insFeeOrderNew.getSyExportOtherCostsProportion(),
+                    insFeeOrderNew.getSyExportSuperviseCostsPremiums(), insFeeOrderNew.getSyExportOtherCostsPremiums(),
+                    insFeeTelemarketing.getFirstSyTotalProportion(),
+                    BigDecimal.ZERO
+            );
+            exportFeeDTOS.add(syExportFee);
+            ExportFeeDTO noExportFee = new ExportFeeDTO("非车险",
+                    insFeeOrderNew.getNoPremium(), insFeeOrderNew.getNoCostsExportProportion(),
+                    insFeeOrderNew.getNoExportOtherCostsProportion(),
+                    insFeeOrderNew.getNoExportSuperviseCostsPremiums(),
+                    insFeeOrderNew.getNoExportOtherCostsPremiums(),
+                    insFeeTelemarketing.getFirstNoTotalProportion(),
+                    BigDecimal.ZERO
+            );
+            exportFeeDTOS.add(noExportFee);
+        } else if (!Objects.isNull(insFeeOrderNewHistory)) {
+            ExportFeeDTO jqExportFee = new ExportFeeDTO("交强险", insFeeOrderNew.getJqPremium(), insFeeOrderNew.getJqCostsExportProportion(),
+                    insFeeOrderNew.getJqExportOtherCostsProportion(),
+                    insFeeOrderNew.getJqExportSuperviseCostsPremiums(),
+                    insFeeOrderNew.getJqExportOtherCostsPremiums(),
+                    insFeeOrderNewHistory.getJqCostsExportProportion(),
+                    insFeeOrderNewHistory.getJqExportOtherCostsProportion()
+            );
+            exportFeeDTOS.add(jqExportFee);
+            ExportFeeDTO syExportFee = new ExportFeeDTO("商业险",
+                    insFeeOrderNew.getSyPremium(), insFeeOrderNew.getSyCostsExportProportion(),
+                    insFeeOrderNew.getSyExportOtherCostsProportion(),
+                    insFeeOrderNew.getSyExportSuperviseCostsPremiums(), insFeeOrderNew.getSyExportOtherCostsPremiums(),
+                    insFeeOrderNewHistory.getSyCostsExportProportion(),
+                    insFeeOrderNewHistory.getSyExportOtherCostsProportion()
+            );
+            exportFeeDTOS.add(syExportFee);
+            ExportFeeDTO noExportFee = new ExportFeeDTO("非车险",
+                    insFeeOrderNew.getNoPremium(), insFeeOrderNew.getNoCostsExportProportion(),
+                    insFeeOrderNew.getNoExportOtherCostsProportion(),
+                    insFeeOrderNew.getNoExportSuperviseCostsPremiums(),
+                    insFeeOrderNew.getNoExportOtherCostsPremiums(),
+                    insFeeOrderNewHistory.getNoCostsExportProportion(),
+                    insFeeOrderNewHistory.getNoExportOtherCostsProportion()
+            );
+            exportFeeDTOS.add(noExportFee);
+        }else{
+            ExportFeeDTO jqExportFee = new ExportFeeDTO("交强险", insFeeOrderNew.getJqPremium(), insFeeOrderNew.getJqCostsExportProportion(),
+                    insFeeOrderNew.getJqExportOtherCostsProportion(),
+                    insFeeOrderNew.getJqExportSuperviseCostsPremiums(),
+                    insFeeOrderNew.getJqExportOtherCostsPremiums(),
+                    insFeeOrderNew.getJqCostsExportProportion(),
+                    insFeeOrderNew.getJqExportOtherCostsProportion()
+            );
+            exportFeeDTOS.add(jqExportFee);
+            ExportFeeDTO syExportFee = new ExportFeeDTO("商业险",
+                    insFeeOrderNew.getSyPremium(), insFeeOrderNew.getSyCostsExportProportion(),
+                    insFeeOrderNew.getSyExportOtherCostsProportion(),
+                    insFeeOrderNew.getSyExportSuperviseCostsPremiums(), insFeeOrderNew.getSyExportOtherCostsPremiums(),
+                    insFeeOrderNew.getSyCostsExportProportion(),
+                    insFeeOrderNew.getSyExportOtherCostsProportion()
+            );
+            exportFeeDTOS.add(syExportFee);
+            ExportFeeDTO noExportFee = new ExportFeeDTO("非车险",
+                    insFeeOrderNew.getNoPremium(), insFeeOrderNew.getNoCostsExportProportion(),
+                    insFeeOrderNew.getNoExportOtherCostsProportion(),
+                    insFeeOrderNew.getNoExportSuperviseCostsPremiums(),
+                    insFeeOrderNew.getNoExportOtherCostsPremiums(),
+                    insFeeOrderNew.getNoCostsExportProportion(),
+                    insFeeOrderNew.getNoExportOtherCostsProportion()
+            );
+            exportFeeDTOS.add(noExportFee);
+        }
         this.exportFee = exportFeeDTOS;
     }
 
@@ -55,23 +121,33 @@ public class TelemarketingAuditOrderEditVo implements Serializable {
         @ApiModelProperty("保费")
         private BigDecimal premium;
 
+        @ApiModelProperty("初始总比例")
+        private BigDecimal firstTotalProportion;
+
         @ApiModelProperty("总比例")
         private BigDecimal totalProportion;
 
         @ApiModelProperty("总费用")
         private BigDecimal totalAmount;
 
+        @ApiModelProperty("扣减比例")
+        private BigDecimal subProportion;
+
         public ExportFeeDTO(String title,
                             BigDecimal premium,
                             BigDecimal superviseCostsProportion,
                             BigDecimal otherCostsProportion,
                             BigDecimal superviseCostsPremiums,
-                            BigDecimal otherCostsPremiums) {
+                            BigDecimal otherCostsPremiums,
+                            BigDecimal firstSuperviseCostsProportion,
+                            BigDecimal firstOtherCostsProportion) {
 
             this.insuranceType = title;
             //保费
             this.premium = premium;
             //总比例
+            this.firstTotalProportion = firstSuperviseCostsProportion.add(firstOtherCostsProportion);
+            //总比例
             this.totalProportion = superviseCostsProportion.add(otherCostsProportion);
             //总费用
             this.totalAmount = superviseCostsPremiums.add(otherCostsPremiums);

+ 27 - 19
src/main/java/com/ydtech/modules/order/service/impl/InsTelemarketingOrderServiceImpl.java

@@ -1,6 +1,9 @@
 package com.ydtech.modules.order.service.impl;
 
 
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.ydtech.constants.enums.dict.FeeAuditAuditstatus;
 import com.ydtech.modules.fee.entity.po.InsFeeOrderNewHistory;
 import com.ydtech.modules.fee.entity.po.InsFeeTelemarketing;
@@ -10,7 +13,6 @@ import com.ydtech.modules.fee.service.InsFeeTelemarketingService;
 import com.ydtech.modules.fnc.service.InsFeeAuditService;
 import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.modules.order.entity.InsAreaCompany;
-import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.order.entity.dto.TelemarketingAuditOrderDTO;
 import com.ydtech.modules.order.entity.vo.SubmitExportFeesVo;
 import com.ydtech.modules.order.entity.vo.telemarketing.TelemarketingAuditOrderEditVo;
@@ -19,12 +21,11 @@ import com.ydtech.modules.order.entity.vo.telemarketing.TelemarketingQueryExpens
 import com.ydtech.modules.order.service.InsAreaCompanyService;
 import com.ydtech.modules.order.service.InsOrdersService;
 import com.ydtech.modules.order.service.InsTelemarketingOrderService;
+import com.ydtech.modules.protocol.utils.AssertionUtils;
 import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
 import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsExport;
-import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsNew;
 import com.ydtech.modules.protocols.service.InsFeeOrderNewService;
 import com.ydtech.modules.protocols.service.PtlAgreementProductCostsExportService;
-import com.ydtech.modules.protocols.service.PtlAgreementProductCostsNewService;
 import com.ydtech.utils.BigDecimalUtils;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.BeanUtils;
@@ -33,6 +34,8 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
 
 import java.math.BigDecimal;
+import java.util.List;
+import java.util.Objects;
 
 
 @Service
@@ -68,6 +71,23 @@ public class InsTelemarketingOrderServiceImpl implements InsTelemarketingOrderSe
         // 费用信息
         InsFeeOrderNew insFeeOrderNew = insFeeOrderNewService.getByInsOrderNo(insAreaCompany.getId());
 
+        // 校验不能大于之前的优惠比例
+        AssertionUtils.isFail(submitExportFeesVo.getJqdiscountrate().compareTo(submitExportFeesVo.getFirstjqdiscountrate()) == 1, "交强优惠比例不能大于初始比例");
+        AssertionUtils.isFail(submitExportFeesVo.getSydiscountrate().compareTo(submitExportFeesVo.getFirstsydiscountrate()) == 1, "商业优惠比例不能大于初始比例");
+        AssertionUtils.isFail(submitExportFeesVo.getNodiscountrate().compareTo(submitExportFeesVo.getFirstnodiscountrate()) == 1, "非车优惠比例不能大于初始比例");
+
+        // 获取未保存前的优惠比例
+        BigDecimal jqDiscount = insFeeOrderNew.getJqCostsExportProportion().add(insFeeOrderNew.getJqExportOtherCostsProportion());
+        BigDecimal syDiscount = insFeeOrderNew.getSyCostsExportProportion().add(insFeeOrderNew.getSyExportOtherCostsProportion());
+        BigDecimal noDiscount = insFeeOrderNew.getNoCostsExportProportion().add(insFeeOrderNew.getNoExportOtherCostsProportion());
+        // 计算扣减比例
+        BigDecimal jqSub = jqDiscount.subtract(submitExportFeesVo.getJqdiscountrate());
+        BigDecimal sySub = syDiscount.subtract(submitExportFeesVo.getSydiscountrate());
+        BigDecimal noSub = noDiscount.subtract(submitExportFeesVo.getNodiscountrate());
+        submitExportFeesVo.setJqExportProportion(jqSub);
+        submitExportFeesVo.setSyExportProportion(sySub);
+        submitExportFeesVo.setNoCarExportProportion(noSub);
+
         // 出口费用
         PtlAgreementProductCostsExport ptlAgreementProductCostsExport = ptlAgreementProductCostsExportService.lambdaQuery().eq(PtlAgreementProductCostsExport::getCostsId, insFeeOrderNew.getCostsId()).one();
 
@@ -115,22 +135,10 @@ public class InsTelemarketingOrderServiceImpl implements InsTelemarketingOrderSe
 
     @Override
     public TelemarketingAuditOrderEditVo queryExpenses(TelemarketingQueryExpensesVo telemarketingQueryExpensesVo) {
-        String state = telemarketingQueryExpensesVo.getState();
         InsAreaCompany insAreaCompany = insAreaCompanyService.getByIdIsExist(telemarketingQueryExpensesVo.getSubOrderId());
-        InsFeeOrderNew insFeeOrderNew = new InsFeeOrderNew();
-        if ("2".equals(state)) {
-            // 费用信息
-            insFeeOrderNew = insFeeOrderNewService.getByInsOrderNo(insAreaCompany.getId());
-            return new TelemarketingAuditOrderEditVo(insFeeOrderNew);
-        } else {
-            InsFeeOrderNewHistory insFeeOrderNewHistory = insFeeOrderNewHistoryService.getByInsOrderNo(insAreaCompany.getId());
-            if (ObjectUtils.isEmpty(insFeeOrderNewHistory)) {
-                insFeeOrderNew = insFeeOrderNewService.getByInsOrderNo(insAreaCompany.getId());
-            } else {
-                BeanUtils.copyProperties(insFeeOrderNewHistory, insFeeOrderNew);
-            }
-        }
-        return new TelemarketingAuditOrderEditVo(insFeeOrderNew);
+        InsFeeOrderNew insFeeOrderNew = insFeeOrderNewService.getByInsOrderNo(insAreaCompany.getId());
+        InsFeeOrderNewHistory insFeeOrderNewHistory = insFeeOrderNewHistoryService.getByInsOrderNo(insAreaCompany.getId());
+        InsFeeTelemarketing insFeeTelemarketing = insFeeTelemarketingService.getByInsOrderNo(insAreaCompany.getId());
+        return new TelemarketingAuditOrderEditVo(insFeeOrderNew,insFeeOrderNewHistory,insFeeTelemarketing);
     }
-
 }

+ 9 - 1
src/main/resources/mapper/modules/ins/InsFeeTelemarketingMapper.xml

@@ -12,11 +12,19 @@
             <result property="noCarExportProportion" column="no_car_export_proportion" jdbcType="DECIMAL"/>
             <result property="createUser" column="create_user" jdbcType="VARCHAR"/>
             <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+            <result property="jqTotalProportion" column="jq_total_proportion" jdbcType="DECIMAL"/>
+            <result property="syTotalProportion" column="sy_total_proportion" jdbcType="DECIMAL"/>
+            <result property="noTotalProportion" column="no_total_proportion" jdbcType="DECIMAL"/>
+            <result property="firstJqTotalProportion" column="first_jq_total_proportion" jdbcType="DECIMAL"/>
+            <result property="firstSyTotalProportion" column="first_sy_total_proportion" jdbcType="DECIMAL"/>
+            <result property="firstNoTotalProportion" column="first_no_total_proportion" jdbcType="DECIMAL"/>
     </resultMap>
 
     <sql id="Base_Column_List">
         id,sub_order_no,jq_export_proportion,
         sy_export_proportion,no_car_export_proportion,create_user,
-        create_time
+        create_time,jq_total_proportion,sy_total_proportion,
+        no_total_proportion,first_jq_total_proportion,first_sy_total_proportion,
+        first_no_total_proportion
     </sql>
 </mapper>