ソースを参照

1.财务结算逻辑调整

wuhp 2 年 前
コミット
7102737e3c
21 ファイル変更1905 行追加192 行削除
  1. 56 0
      sql/Online.sql
  2. 92 6
      src/main/java/com/ydtech/modules/fnc/controller/InsPlyIncomeController.java
  3. 11 1
      src/main/java/com/ydtech/modules/fnc/dao/InsPlyIncomeMapper.java
  4. 205 3
      src/main/java/com/ydtech/modules/fnc/entity/InsPlyIncome.java
  5. 16 0
      src/main/java/com/ydtech/modules/fnc/entity/SettlementDocumentaryFeesEntity.java
  6. 10 0
      src/main/java/com/ydtech/modules/fnc/entity/SettlementDocumentaryLogEntity.java
  7. 28 0
      src/main/java/com/ydtech/modules/fnc/service/InsPlyIncomeService.java
  8. 461 143
      src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java
  9. 43 2
      src/main/java/com/ydtech/modules/fnc/vo/InsPlyIncomeVo.java
  10. 5 0
      src/main/java/com/ydtech/modules/fnc/vo/SettlementDocumentaryFeesVo.java
  11. 49 0
      src/main/java/com/ydtech/modules/ins/model/vo/res/BxOtherExcel.java
  12. 131 0
      src/main/java/com/ydtech/modules/ins/model/vo/res/BxSettlementFeesExcel.java
  13. 173 0
      src/main/java/com/ydtech/modules/ins/model/vo/res/SettlementFeesExcel.java
  14. 18 1
      src/main/java/com/ydtech/modules/inv/model/dto/InsPlyIncomeExcelDto.java
  15. 1 0
      src/main/java/com/ydtech/modules/protocol/dao/PtlAgreementMapper.java
  16. 2 0
      src/main/java/com/ydtech/modules/protocol/service/PtlAgreementService.java
  17. 6 0
      src/main/java/com/ydtech/modules/protocol/service/impl/PtlAgreementServiceImpl.java
  18. 579 36
      src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml
  19. 5 0
      src/main/resources/mapper/modules/fnc/SettlementDocumentaryFeesMapper.xml
  20. 3 0
      src/main/resources/mapper/modules/fnc/SettlementDocumentaryLogMapper.xml
  21. 11 0
      src/main/resources/mapper/modules/protocol/PtlAgreementMapper.xml

+ 56 - 0
sql/Online.sql

@@ -14,3 +14,59 @@ CREATE TABLE `sys_user_link_area`  (
                                        INDEX `user_id_index`(`user_id`) USING BTREE COMMENT '用户id索引',
                                        INDEX `area_code_index`(`area_code`) USING BTREE COMMENT '部门code索引'
 ) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '后线人员关联区域表' ROW_FORMAT = Dynamic;
+
+
+--    2024-04-25  wuhp
+ALTER TABLE `ins_ply_income`
+    MODIFY COLUMN `handling_fees_status` varchar (5) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '手续费结算状态  1 为已结算 2 已开票' AFTER `contract_file_id`,
+    MODIFY COLUMN `documentary_fees_status` varchar (5) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '跟单费结算状态  1 为已结算 2 已开票' AFTER `no_policyno`;
+
+
+ALTER TABLE `ins_ply_income` ADD COLUMN `invoic_amount` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '开票金额' AFTER `is_not_documentary`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `invoic_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '开票号' AFTER `invoic_amount`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `tax_premium` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '含税保费' AFTER `invoic_id`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `jq_supervise_costs_premiums` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '交强手续费' AFTER `tax_premium`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `jq_supervise_costs_proportion` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '交强手续费比例' AFTER `jq_supervise_costs_premiums`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `sy_supervise_costs_premiums` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '商业手续费' AFTER `jq_supervise_costs_proportion`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `sy_supervise_costs_proportion` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '商业手续费比例' AFTER `sy_supervise_costs_premiums`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `no_supervise_costs_premiums` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '非车手续费' AFTER `sy_supervise_costs_proportion`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `no_supervise_costs_proportion` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '非车手续费比例' AFTER `no_supervise_costs_premiums`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `jq_premium` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '交强险含税保费' AFTER `no_supervise_costs_proportion`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `sy_premium` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '商业险含保费' AFTER `jq_premium`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `no_premium` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '非车险含保费' AFTER `sy_premium`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `jq_no_tax_premium` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '交强险不含税保费' AFTER `no_premium`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `sy_no_tax_premium` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '商业险不含税保费' AFTER `jq_no_tax_premium`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `no_no_tax_premium` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '非车险不含税保费' AFTER `sy_no_tax_premium`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `jq_receivable_proportion` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '交强应收比例' AFTER `no_no_tax_premium`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `sy_receivable_proportion` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '商业应收比例' AFTER `jq_receivable_proportion`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `no_receivable_proportion` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '非车应收比例' AFTER `sy_receivable_proportion`;
+
+ALTER TABLE `ins_ply_income` ADD COLUMN `jq_other_costs_proportion` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '交强跟单比例' AFTER `no_receivable_proportion`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `sy_other_costs_proportion` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '商业跟单比例' AFTER `jq_other_costs_proportion`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `no_other_costs_proportion` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '非车跟单比例' AFTER `sy_other_costs_proportion`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `settlement_time` datetime NULL DEFAULT NULL COMMENT '结算日期' AFTER `no_other_costs_proportion`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `update_time` datetime NULL DEFAULT NULL COMMENT '修改日期' AFTER `settlement_time`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `settlement_user_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '结算人id' AFTER `update_time`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `update_user_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '修改用户id' AFTER `settlement_user_id`;
+
+ALTER TABLE `ins_ply_income` ADD COLUMN `jq_other_costs_premium` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '交强跟单金额' AFTER `update_user_id`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `sy_other_costs_premium` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '商业跟单金额' AFTER `jq_other_costs_premium`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `no_other_costs_premium` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '非车跟单金额' AFTER `sy_other_costs_premium`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `user_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '被保人' AFTER `no_other_costs_premium`;
+
+ALTER TABLE `ins_ply_income` ADD COLUMN `company_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '保险公司名称' AFTER `user_id`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `partner_companies_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '合作公司id' AFTER `company_name`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `partner_companies_name` varchar(10) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '合作公司名称' AFTER `partner_companies_id`;
+
+ALTER TABLE `settlement_documentary_log` ADD COLUMN `ids` text CHARACTER SET utf8 COLLATE utf8_bin NULL COMMENT '结算ids' AFTER `crud_status`;
+ALTER TABLE `settlement_documentary_log` ADD COLUMN `company_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '保险公司id' AFTER `ids`;
+ALTER TABLE `ins_ply_income` ADD COLUMN `receivable_amount` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '应收金额' AFTER `partner_companies_name`;
+
+ALTER TABLE `settlement_documentary_fees` ADD COLUMN `year` varchar(5) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '结算年度' AFTER `signing_time`;
+ALTER TABLE `settlement_documentary_fees` ADD COLUMN `month` varchar(5) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '结算月份' AFTER `signing_time`;
+ALTER TABLE `settlement_documentary_fees` ADD COLUMN `day` varchar(5) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '结算日期' AFTER `signing_time`;
+ALTER TABLE `settlement_documentary_fees` ADD COLUMN `agree_ment_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '协议di' AFTER `day`;
+
+ALTER TABLE `ins_ply_income` ADD COLUMN `invoic_time` datetime NULL DEFAULT NULL COMMENT '开票时间' AFTER `receivable_amount`;
+ALTER TABLE `settlement_documentary_fees` ADD COLUMN `settlement_status` varchar(5) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '状态  1 开票 2结算' AFTER `year`;
+ALTER TABLE `settlement_documentary_fees` ADD COLUMN `ids` text CHARACTER SET utf8 COLLATE utf8_bin NULL COMMENT '结算ids' AFTER `settlement_status`;

+ 92 - 6
src/main/java/com/ydtech/modules/fnc/controller/InsPlyIncomeController.java

@@ -1,5 +1,6 @@
 package com.ydtech.modules.fnc.controller;
 
+import com.ydtech.aop.exception.DescribeException;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.admin.model.vo.SysUserBankCardVO;
 import com.ydtech.modules.base.controller.BaseController;
@@ -17,9 +18,13 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
+import java.io.IOException;
 import java.time.LocalDate;
 import java.time.Period;
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -74,6 +79,18 @@ public class InsPlyIncomeController extends BaseController {
 
         return result;
     }
+    @PostMapping("/totalAmount")
+    @ApiModelProperty(value = "平台手续费合计金额")
+    public HttpResult<InsPlyIncome>totalAmount(@RequestBody @Valid InsPlyIncomeVo insPlyIncomeVo){
+        InsPlyIncome  result = insPlyIncomeService.totalAmount(insPlyIncomeVo);
+        return  HttpResult.ok(result);
+    }
+    @PostMapping("/totalPinAmount")
+    @ApiModelProperty(value = "平台结算未结算接口")
+    public HttpResult<List<InsPlyIncome>>totalPinAmount(@RequestBody @Valid InsPlyIncomeVo insPlyIncomeVo){
+        List<InsPlyIncome>  result = insPlyIncomeService.totalPinAmount(insPlyIncomeVo);
+        return  HttpResult.ok(result);
+    }
     @PutMapping("/balance")
     @ApiModelProperty(value = "结算手续费")
     public HttpResult<Object> balance(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
@@ -88,14 +105,23 @@ public class InsPlyIncomeController extends BaseController {
         return result;
     }
 
-        @PutMapping("/batchBalance")
-    @ApiModelProperty(value = "批量跟单费")
+    @PutMapping("/batchInvoic")
+    @ApiModelProperty(value = "批量开票跟单费")
+    public HttpResult<Object> batchInvoic(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+
+        return   insPlyIncomeService.batchInvoic(insPlyIncomeVo);
+    }
+    @PutMapping("/batchBalance")
+    @ApiModelProperty(value = "批量结算跟单费")
     public HttpResult<Object> batchBalance(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
 
         return   insPlyIncomeService.batchBalance(insPlyIncomeVo);
     }
-
-
+    @PutMapping("/batchPinBalance")
+    @ApiModelProperty(value = "平台批量结算")
+    public HttpResult<Object> batchPinBalance(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+        return   insPlyIncomeService.batchPinBalance(insPlyIncomeVo);
+    }
 
     @PostMapping("/NonSettlementQuery")
     @ApiOperation(value = "非跟单查询")
@@ -110,7 +136,7 @@ public class InsPlyIncomeController extends BaseController {
         return  insPlyIncomeService.nonSettldetail(insPlyIncomeVo);
     }
     @PostMapping("/importData")
-    @ApiOperation(value = "渠道数据导入(excel)")
+    @ApiOperation(value = "手续费导入(excel)")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "file", value = "excel文件", required = true, dataType = "__file")
     })
@@ -121,6 +147,8 @@ public class InsPlyIncomeController extends BaseController {
         return HttpResult.ok("导入成功");
     }
 
+
+
     @PutMapping("/update")
     @ApiModelProperty(value = "修改")
     public HttpResult<Object> updateByEntity(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
@@ -146,5 +174,63 @@ public class InsPlyIncomeController extends BaseController {
         return  HttpResult.ok(item) ;
     }
 
+    @PostMapping("/totalBxAmount")
+    @ApiModelProperty(value = "保险未开票金额")
+    public HttpResult<List<InsPlyIncome>>totalBxAmount(@RequestBody @Valid InsPlyIncomeVo insPlyIncomeVo){
+        List<InsPlyIncome>  result = insPlyIncomeService.totalBxAmount(insPlyIncomeVo);
+        return  HttpResult.ok(result);
+    }
+
+
+    @PutMapping("/batchInvoicing")
+    @ApiModelProperty(value = "保险手续费批量开票")
+    public HttpResult<Object> batchInvoicing(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+        return   insPlyIncomeService.batchInvoicing(insPlyIncomeVo);
+    }
+
+    @PostMapping("/queryInvoicing")
+    @ApiModelProperty(value = "查询开票金额")
+    public HttpResult<InsPlyIncome> queryInvoicing(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+        return   insPlyIncomeService.queryInvoicing(insPlyIncomeVo);
+    }
+    @PostMapping("/querySettInvoicing")
+    @ApiModelProperty(value = "查询已开票已结算")
+    public HttpResult<InsPlyIncome> querySettInvoicing(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+        return   insPlyIncomeService.querySettInvoicing(insPlyIncomeVo);
+    }
+
+    @PutMapping("/batchBxBalance")
+    @ApiModelProperty(value = "保险批量结算")
+    public HttpResult<Object> batchBxBalance(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+        return   insPlyIncomeService.batchBxBalance(insPlyIncomeVo);
+    }
+
+
+    @PostMapping("/allOtherAmount")
+    @ApiModelProperty(value = "保险跟单总表")
+    public HttpResult<List<InsPlyIncome>> allOtherAmount(@RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+        return   insPlyIncomeService.allOtherAmount(insPlyIncomeVo);
+    }
+
+
+    @ApiModelProperty("保险手续费导出")
+    @PostMapping("bxHandlingExcel")
+    public HttpResult bxHandlingexcel(@RequestBody @ApiParam(name = "insPlyIncomeVo") InsPlyIncomeVo  insPlyIncomeVo , HttpServletRequest request, HttpServletResponse response ) throws IOException {
+            return  insPlyIncomeService.bxHandlingexcel(insPlyIncomeVo, request, response);
+
+    }
+
+    @ApiModelProperty("平台手续费导出")
+    @PostMapping("pinHandlingExcel")
+    public HttpResult pinHandlingexcel(@RequestBody @ApiParam(name = "insPlyIncomeVo") InsPlyIncomeVo  insPlyIncomeVo , HttpServletRequest request, HttpServletResponse response ){
+
+            return insPlyIncomeService.pinHandlingexcel(insPlyIncomeVo, request, response);
+    }
+    @ApiModelProperty("保险跟单导出")
+    @PostMapping("bxOtherExcel")
+    public HttpResult bxOtherExcel(@RequestBody @ApiParam(name = "insPlyIncomeVo") InsPlyIncomeVo  insPlyIncomeVo , HttpServletRequest request, HttpServletResponse response ){
+            return insPlyIncomeService.bxOtherExcel(insPlyIncomeVo, request, response);
+        }
+    }
+
 
-}

+ 11 - 1
src/main/java/com/ydtech/modules/fnc/dao/InsPlyIncomeMapper.java

@@ -85,6 +85,16 @@ public interface InsPlyIncomeMapper extends BaseMapper<InsPlyIncome> {
 
     List<InsPlyIncome> NonSettlementQuery(HashMap<String, Object> params);
 
-    InsPlyIncome findByLicenseno(@Param("licenseno") String licenseno);
+    InsPlyIncome totalAmount(HashMap<String, Object> params);
 
+    List<InsPlyIncome> totalPinAmount(HashMap<String, Object> params);
+
+    List<InsPlyIncome> totalBxAmount(HashMap<String, Object> params);
+
+    InsPlyIncome queryInvoicing(HashMap<String, Object> params);
+
+    List<InsPlyIncome> allOtherAmount(HashMap<String, Object> params);
+
+
+    InsPlyIncome findByLicenseno(@Param ("licenseno")String licenseno, @Param ("policyno") String policyno, @Param ("syPolicyno") String syPolicyno,@Param ("noPolicyno")   String noPolicyno);
 }

+ 205 - 3
src/main/java/com/ydtech/modules/fnc/entity/InsPlyIncome.java

@@ -5,10 +5,12 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
+import lombok.NoArgsConstructor;
 import lombok.Setter;
 
 /**
@@ -23,6 +25,7 @@ import lombok.Setter;
 @Setter
 @TableName("ins_ply_income")
 @ApiModel(value = "InsPlyIncome对象", description = "保司结算手续费")
+@NoArgsConstructor
 public class InsPlyIncome implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -76,7 +79,7 @@ public class InsPlyIncome implements Serializable {
     private String companyId;
 
     @ApiModelProperty("保险公司名称")
-    @TableField(exist = false)
+    @TableField("company_name")
     private String companyName;
 
     @ApiModelProperty("协议号")
@@ -127,6 +130,30 @@ public class InsPlyIncome implements Serializable {
     @TableField("create_time")
     private LocalDateTime createTime;
 
+    @ApiModelProperty("开票时间")
+    @TableField("invoic_time")
+    private LocalDate invoicTime;
+
+    @ApiModelProperty("结算日期")
+    @TableField("settlement_time")
+    private LocalDateTime settlementTime;
+
+    @ApiModelProperty("修改日期")
+    @TableField("update_time")
+    private LocalDateTime updateTime;
+
+    @ApiModelProperty("结算人")
+    @TableField("settlement_user_id")
+    private String settlementUserId;
+
+    @ApiModelProperty("修改人")
+    @TableField("update_user_id")
+    private String updateUserId;
+
+    @ApiModelProperty("被保人")
+    @TableField("user_id")
+    private String userId;
+
     @ApiModelProperty("凭证号")
     @TableField("voucher_number")
     private String voucherNumber;
@@ -139,12 +166,12 @@ public class InsPlyIncome implements Serializable {
     @TableField("contract_file_id")
     private String contractFileId;
 
-    @ApiModelProperty("手续费结算状态  1 为已结算")
+    @ApiModelProperty("手续费结算状态  1 为已结算  2 已经结算")
     @TableField("handling_fees_status")
     private String handlingFeesStatus;
 
 
-    @ApiModelProperty("跟单费结算状态  1 为已结算")
+    @ApiModelProperty("跟单费结算状态  1 为已结算  2 已经结算")
     @TableField("documentary_fees_status")
     private String documentaryFeesStatus;
 
@@ -157,6 +184,117 @@ public class InsPlyIncome implements Serializable {
     @TableField("is_not_documentary")
     private String isNotDocumentary;
 
+    @ApiModelProperty("开票金额")
+    @TableField("invoic_amount")
+    private BigDecimal invoicAmount;
+
+    @ApiModelProperty("开票号")
+    @TableField("invoic_id")
+    private String invoicId;
+
+
+    @ApiModelProperty("含税保费")
+    @TableField("tax_premium")
+    private BigDecimal taxPremium;
+
+    @ApiModelProperty("交强手续费")
+    @TableField("jq_supervise_costs_premiums")
+    private BigDecimal jqSuperviseCostsPremiums;
+
+    @ApiModelProperty("交强手续费比例")
+    @TableField("jq_supervise_costs_proportion")
+    private BigDecimal jqSuperviseCostsProportion;
+
+    @ApiModelProperty("商业手续费")
+    @TableField("sy_supervise_costs_premiums")
+    private BigDecimal sySuperviseCostsPremiums;
+
+    @ApiModelProperty("商业手续费比例")
+    @TableField("sy_supervise_costs_proportion")
+    private BigDecimal sySuperviseCostsProportion;
+
+    @ApiModelProperty("非车手续费")
+    @TableField("no_supervise_costs_premiums")
+    private BigDecimal noSuperviseCostsPremiums;
+
+    @ApiModelProperty("非车手续费比例")
+    @TableField("no_supervise_costs_proportion")
+    private BigDecimal noSuperviseCostsProportion;
+
+    @ApiModelProperty("交强险含税保费")
+    @TableField("jq_premium")
+    private BigDecimal jqPremium;
+
+    @ApiModelProperty("商业险含保费")
+    @TableField("sy_premium")
+    private BigDecimal syPremium;
+
+    @ApiModelProperty("非车险含保费")
+    @TableField("no_premium")
+    private BigDecimal noPremium;
+
+    @ApiModelProperty("交强险不含税保费")
+    @TableField("jq_no_tax_premium")
+    private BigDecimal jqNoTaxPremium;
+
+
+    @ApiModelProperty("商业险不含税保费")
+    @TableField("sy_no_tax_premium")
+    private BigDecimal syNoTaxPremium;
+
+    @ApiModelProperty("非车险不含税保费")
+    @TableField("no_no_tax_premium")
+    private BigDecimal noNoTaxPremium;
+
+    @ApiModelProperty("交强应收比例")
+    @TableField("jq_receivable_proportion")
+    private BigDecimal jqReceivableProportion;
+
+    @ApiModelProperty("商业应收比例")
+    @TableField("sy_receivable_proportion")
+    private BigDecimal syReceivableProportion;
+
+
+    @ApiModelProperty("非车应收比例")
+    @TableField("no_receivable_proportion")
+    private BigDecimal noReceivableProportion;
+
+    @ApiModelProperty("应收金额")
+    @TableField("receivable_amount")
+    private BigDecimal receivableAmount;
+
+    @ApiModelProperty("交强跟单比例")
+    @TableField("jq_other_costs_proportion")
+    private BigDecimal jqOtherCostsProportion;
+
+    @ApiModelProperty("商业跟单比例")
+    @TableField("sy_other_costs_proportion")
+    private BigDecimal syOtherCostsProportion;
+
+    @ApiModelProperty("非车跟单比例")
+    @TableField("no_other_costs_proportion")
+    private BigDecimal noOtherCostsProportion;
+
+    @ApiModelProperty("交强跟单金额")
+    @TableField("jq_other_costs_premium")
+    private BigDecimal jqOtherCostsPremium;
+
+    @ApiModelProperty("商业跟单金额")
+    @TableField("sy_other_costs_premium")
+    private BigDecimal syOtherCostsPremium;
+
+    @ApiModelProperty("非车跟单金额")
+    @TableField("no_other_costs_premium")
+    private BigDecimal noOtherCostsPremium;
+
+    @ApiModelProperty("合作公司id")
+    @TableField("partner_companies_id")
+    private String partnerCompaniesId;
+
+    @ApiModelProperty("合作公司名称")
+    @TableField("partner_companies_name")
+    private String partnerCompaniesName;
+
 
     @ApiModelProperty("总单数")
     @TableField(exist = false)
@@ -176,6 +314,9 @@ public class InsPlyIncome implements Serializable {
     @ApiModelProperty("ids")
     @TableField(exist = false)
     private String ids;
+    @ApiModelProperty("ids")
+    @TableField(exist = false)
+    private String unSettledIds;
 
     @ApiModelProperty("时间范围")
     @TableField(exist = false)
@@ -198,14 +339,75 @@ public class InsPlyIncome implements Serializable {
     @TableField(exist = false)
     private BigDecimal sdfStartTime;
 
+    @ApiModelProperty("预收金额")
+    @TableField(exist = false)
+    private BigDecimal totalFeevalue;
+
 
     @ApiModelProperty("结束时间")
     @TableField(exist = false)
     private BigDecimal sdfEndTime;
+
     @ApiModelProperty("月数")
     @TableField(exist = false)
     private String monthSigdate;
 
 
+    @ApiModelProperty("未结算手续费")
+    @TableField(exist = false)
+    private BigDecimal readyCommissionFeevalue;
+    @ApiModelProperty("未结算跟单费")
+    @TableField(exist = false)
+    private BigDecimal readyOtherFeevalue;
+    @ApiModelProperty("未结算总额")
+    @TableField(exist = false)
+    private BigDecimal readyTotalFeevalue;
+    @ApiModelProperty("已开票金额")
+    @TableField(exist = false)
+    private BigDecimal invoicCommissionFeevalue;
 
+    @ApiModelProperty("未开票金额")
+    @TableField(exist = false)
+    private BigDecimal noInvoicCommissionFeevalue;
+    @ApiModelProperty("开票ids")
+    @TableField(exist = false)
+    private String incomeIds;
+
+
+    public InsPlyIncome(String orderno, String policyno, String syPolicyno, String noPolicyno, String settleno, String deptId, String deptName, String riskcode, LocalDateTime payDate, LocalDateTime signDate, String companyId, String companyName, String agreementId, String licenseno, BigDecimal taxamount, BigDecimal noTaxPremium, BigDecimal commissionFeerate, BigDecimal otherFeerate, BigDecimal commissionFeevalue, BigDecimal otherFeevalue, BigDecimal allFeeValue, BigDecimal finalFeeValue, BigDecimal doingFeeValue, LocalDateTime createTime, String voucherNumber, String contractId, String contractFileId, String handlingFeesStatus, String documentaryFeesStatus, String isNotCar, String isNotDocumentary) {
+        this.orderno = orderno;
+        this.policyno = policyno;
+        this.syPolicyno = syPolicyno;
+        this.noPolicyno = noPolicyno;
+        this.settleno = settleno;
+        this.deptId = deptId;
+        this.deptName = deptName;
+        this.riskcode = riskcode;
+        this.payDate = payDate;
+        this.signDate = signDate;
+        this.companyId = companyId;
+        this.companyName = companyName;
+        this.agreementId = agreementId;
+        this.licenseno = licenseno;
+        this.taxamount = taxamount;
+        this.noTaxPremium = noTaxPremium;
+        this.commissionFeerate = commissionFeerate;
+        this.otherFeerate = otherFeerate;
+        this.commissionFeevalue = commissionFeevalue;
+        this.otherFeevalue = otherFeevalue;
+        this.allFeeValue = allFeeValue;
+        this.finalFeeValue = finalFeeValue;
+        this.doingFeeValue = doingFeeValue;
+        this.createTime = createTime;
+        this.voucherNumber = voucherNumber;
+        this.contractId = contractId;
+        this.contractFileId = contractFileId;
+        this.handlingFeesStatus = handlingFeesStatus;
+        this.documentaryFeesStatus = documentaryFeesStatus;
+        this.isNotCar = isNotCar;
+        this.isNotDocumentary = isNotDocumentary;
+    }
+
+    public InsPlyIncome(String id, String jqpolicyno, String sypolicyno, Object o, Object o1, String deptId, Object o2, String productid, LocalDateTime payDate, LocalDateTime signingTime, String companyId, Object o3, String agreementId, String licenseno, BigDecimal taxamount, BigDecimal allNoTaxPremium, BigDecimal handlingProportion, Object o4, BigDecimal handlingAmount, BigDecimal handlingAmount1, Object o5, Object o6, LocalDateTime now, Object o7, Object o8, Object o9, String number, String number1, String number2, String number3) {
+    }
 }

+ 16 - 0
src/main/java/com/ydtech/modules/fnc/entity/SettlementDocumentaryFeesEntity.java

@@ -65,6 +65,22 @@ public class SettlementDocumentaryFeesEntity implements Serializable {
     @TableField("company_id")
     private String companyId;
 
+    @ApiModelProperty("结算年度")
+    @TableField("year")
+    private String year;
+
+    @ApiModelProperty("结算月份")
+    @TableField("month")
+    private String month;
+
+    @ApiModelProperty("结算日期")
+    @TableField("day")
+    private String day;
+
+    @ApiModelProperty("结算ids")
+    @TableField("ids")
+    private String ids;
+
 
 
 

+ 10 - 0
src/main/java/com/ydtech/modules/fnc/entity/SettlementDocumentaryLogEntity.java

@@ -47,4 +47,14 @@ public class SettlementDocumentaryLogEntity implements Serializable {
     @TableField("handing_amount")
     private BigDecimal handingAmount;
 
+    @ApiModelProperty("结算ids")
+    @TableField("ids")
+    private String ids;
+
+    @ApiModelProperty("结算保险公司")
+    @TableField("company_id")
+    private String companyId;
+    @ApiModelProperty("其他费用金额")
+    private BigDecimal otherFeevalue;
+
 }

+ 28 - 0
src/main/java/com/ydtech/modules/fnc/service/InsPlyIncomeService.java

@@ -10,6 +10,9 @@ import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -51,4 +54,29 @@ public interface InsPlyIncomeService extends IService<InsPlyIncome> {
 
     HttpResult<InsPlyIncome> insertByEntity(InsPlyIncomeVo insPlyIncomeVo);
 
+    InsPlyIncome totalAmount(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<Object> batchPinBalance(InsPlyIncomeVo insPlyIncomeVo);
+
+    List<InsPlyIncome> totalPinAmount(InsPlyIncomeVo insPlyIncomeVo);
+
+    List<InsPlyIncome> totalBxAmount(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<Object> batchInvoicing(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<InsPlyIncome> queryInvoicing(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<Object> batchBxBalance(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<InsPlyIncome> querySettInvoicing(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<List<InsPlyIncome>> allOtherAmount(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult<Object> batchInvoic(InsPlyIncomeVo insPlyIncomeVo);
+
+    HttpResult pinHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response);
+
+    HttpResult bxHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response);
+
+    HttpResult bxOtherExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response);
 }

+ 461 - 143
src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java

@@ -1,5 +1,7 @@
 package com.ydtech.modules.fnc.service.impl;
 
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
 import cn.hutool.core.bean.BeanUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -11,6 +13,7 @@ import com.github.pagehelper.PageInfo;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.esm.model.EsmInsCompany;
+import com.ydtech.modules.esm.service.EsmInsCompanyService;
 import com.ydtech.modules.fnc.entity.InsAreaCompany;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.ydtech.modules.fnc.dao.InsPlyIncomeMapper;
@@ -21,9 +24,15 @@ import com.ydtech.modules.fnc.service.SettlementDocumentaryFeesService;
 import com.ydtech.modules.fnc.service.SettlementDocumentaryLogService;
 import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
 import com.ydtech.modules.fnc.vo.SettlementDocumentaryFeesVo;
+import com.ydtech.modules.ins.model.vo.res.BxOtherExcel;
+import com.ydtech.modules.ins.model.vo.res.BxSettlementFeesExcel;
+import com.ydtech.modules.ins.model.vo.res.InsCmainNocarDetailResVo;
+import com.ydtech.modules.ins.model.vo.res.SettlementFeesExcel;
 import com.ydtech.modules.inv.model.InvChannelsExternalBillsDetails;
 import com.ydtech.modules.inv.model.dto.InsPlyIncomeExcelDto;
 import com.ydtech.modules.inv.model.dto.InvChannelExcelDto;
+import com.ydtech.modules.inv.model.excel.InvDisburseExcel;
+import com.ydtech.modules.inv.utils.EasyExcelUtils;
 import com.ydtech.modules.order.entity.BasePageResult;
 import com.ydtech.modules.order.entity.InsOrders;
 import com.ydtech.modules.order.service.InsAreaCompanyService;
@@ -35,10 +44,15 @@ import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
 import com.ydtech.modules.protocols.service.InsFeeOrderNewService;
 import com.ydtech.utils.SnowFlakeUtil;
 import com.ydtech.utils.excel.ExcelEasypoiUtils;
+import com.ydtech.utils.excel.ExcelStyleUtil;
+import com.ydtech.utils.excel.ExcelUtils2;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.formula.functions.Now;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -46,8 +60,15 @@ import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 import redis.clients.jedis.params.Params;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BandedSampleModel;
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -60,6 +81,8 @@ import java.util.stream.Collectors;
  * @author gws
  * @since 2024-01-05
  */
+
+@Slf4j
 @Service
 public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, InsPlyIncome> implements InsPlyIncomeService {
 
@@ -78,6 +101,13 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     private SettlementDocumentaryLogService settlementDocumentaryLogService;
     @Autowired
     private PtlAgreementService  ptlAgreementService;
+    @Autowired
+    private EsmInsCompanyService EsmInsCompanyService;
+
+    @Value("${upload.file.path}")
+    private String uploadPath;
+    @Value("${upload.file.url}")
+    private String uploadUrl;
 
 
     public HttpResult<BasePageResult<InsPlyIncome>> queryplyIncome(InsPlyIncomeVo insPlyIncomeVo){
@@ -109,14 +139,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         if (StringUtils.isNotEmpty(agreeType)) {
 //            判断协议类型 平台  保险
             if ("1".equals(agreeType)) {
-                // 平台逻辑处理   判断是否是 和手续费 非车
-                if (insFeeOrderNew.getJqSuperviseCostsPremiums() != null || insFeeOrderNew.getSySuperviseCostsPremiums() != null) { //平台车险
-//                    生成手续费  跟单费和手续费是一条单据
-                    this.savePinTai(order,insFeeOrderNew,insAreaCompany);
-                }
-                if(insFeeOrderNew.getNoSuperviseCostsPremiums() != null || insFeeOrderNew.getNoOtherCostsPremiums() != null){ // 平台非车
-                    this.saveNoPinTai(order,insFeeOrderNew,insAreaCompany);
-                }
+                this.savePinTai(order,insFeeOrderNew,insAreaCompany);  //手续费不分非车不非车 跟单也不分
             }else {  // 保险  逻辑: 手续费生成一条  跟单费生成一条   非车手续费一条  非车跟单费一条
                 if (insFeeOrderNew.getJqSuperviseCostsPremiums() != null || insFeeOrderNew.getSySuperviseCostsPremiums() != null) { //手续费
                     this.saveInsuranceProcedures(order,insFeeOrderNew,insAreaCompany);
@@ -154,9 +177,13 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         insPlyIncome.setCreateTime(LocalDateTime.now());
         insPlyIncome.setDocumentaryFeesStatus("0");
         insPlyIncome.setHandlingFeesStatus("0");
+        insPlyIncome.setNoNoTaxPremium(insPlyIncome.getNoNoTaxPremium());
+        insPlyIncome.setNoPremium(insPlyIncome.getNoPremium());
         insPlyIncome.setIsNotCar("1");
         insPlyIncome.setIsNotDocumentary("1");
         insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoOtherCostsPremiums());
+        this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
+        baseMapper.insert(insPlyIncome);
     }
 
     private void saveNoSupervise(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
@@ -182,88 +209,59 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         insPlyIncome.setIsNotCar("1");
         insPlyIncome.setIsNotDocumentary("0");
         insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoSuperviseCostsPremiums());
+        insPlyIncome.setUserId(insFeeOrderNew.getUserId());
+        insPlyIncome.setNoPremium(insFeeOrderNew.getNoPremium()); //非车保费
+        insPlyIncome.setNoNoTaxPremium(insFeeOrderNew.getNoNoTaxPremium());  //非车不含税保费
+        this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
+
         baseMapper.insert(insPlyIncome);
     }
 
     private void saveOtherAmount(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
-        InsPlyIncome insPlyIncome = new InsPlyIncome();
-        insPlyIncome.setOrderno(insFeeOrderNew.getId());  // 子订单号
-        insPlyIncome.setPolicyno(insAreaCompany.getJqpolicyno());  // 商业保单号
-        insPlyIncome.setSyPolicyno(insAreaCompany.getSypolicyno());  // 商业保单号
-        BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums());
-        insPlyIncome.setOtherFeevalue(otherAmount);//跟单费用
-        BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion());
-        insPlyIncome.setOtherFeerate(otherProportion); // 跟单非比例
-        insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
-        insPlyIncome.setRiskcode(order.getProductid());
-        insPlyIncome.setPayDate(insAreaCompany.getPayDate());
-        insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
-        insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
-        insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
-        insPlyIncome.setLicenseno(order.getLicenseno());
-        insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
-        insPlyIncome.setCreateTime(LocalDateTime.now());
-        insPlyIncome.setDocumentaryFeesStatus("0");
-        insPlyIncome.setHandlingFeesStatus("0");
-        insPlyIncome.setIsNotCar("0");
-        insPlyIncome.setIsNotDocumentary("1");
-        insPlyIncome.setAllFeeValue(otherAmount);
+        BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums(),null);
+        BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion(),null);
+        BigDecimal allNoTaxPremium = this.calculateTotal(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(), null);  //交强不含税保费
+        BigDecimal allPremium = this.calculateTotal(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), null);// 总保费
+
+
+        InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getId(),insAreaCompany.getJqpolicyno(),insAreaCompany.getSypolicyno(),null,null,insFeeOrderNew.getDeptId(),null,order.getProductid(),insAreaCompany.getPayDate(),insAreaCompany.getSigningTime(),insAreaCompany.getCompanyId(),null,insFeeOrderNew.getAgreementId(),order.getLicenseno(),insAreaCompany.getTaxamount(),
+                allNoTaxPremium,null,otherProportion,null,otherAmount,otherAmount,null,null,LocalDateTime.now(),null,null,null,"0","0","0","1");
+
+        insPlyIncome.setTaxPremium(allPremium);
+        insPlyIncome.setJqPremium(insFeeOrderNew.getJqPremium());
+        insPlyIncome.setSyPremium(insFeeOrderNew.getSyPremium());
+        insPlyIncome.setJqNoTaxPremium(insFeeOrderNew.getJqNoTaxPremium());
+        insPlyIncome.setSyNoTaxPremium(insFeeOrderNew.getSyNoTaxPremium());
+        insPlyIncome.setJqOtherCostsProportion(insFeeOrderNew.getJqOtherCostsProportion());   //交强跟单费比例
+        insPlyIncome.setSyOtherCostsProportion(insFeeOrderNew.getSyOtherCostsProportion());   //商业跟单费比例
+        insPlyIncome.setSyOtherCostsPremium(insFeeOrderNew.getSyOtherCostsPremiums());
+        insPlyIncome.setJqOtherCostsPremium(insFeeOrderNew.getJqOtherCostsPremiums());
+        insPlyIncome.setUserId(insFeeOrderNew.getUserId());
+        this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
+
         baseMapper.insert(insPlyIncome);
     }
 
     private void saveInsuranceProcedures(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
 //        保险手续费
-        InsPlyIncome insPlyIncome = new InsPlyIncome();
-        insPlyIncome.setOrderno(insFeeOrderNew.getId());  // 子订单号
-        insPlyIncome.setPolicyno(insAreaCompany.getJqpolicyno());   // 交强保单号
-        BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(), insFeeOrderNew.getSySuperviseCostsPremiums());
-        insPlyIncome.setCommissionFeevalue(handlingAmount);//手续费
-        BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getSySuperviseCostsProportion());
-        insPlyIncome.setCommissionFeerate(handlingProportion);// 手续费比例
-
-        insPlyIncome.setSyPolicyno(insAreaCompany.getSypolicyno()); //商业保单号
-        insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
-        insPlyIncome.setRiskcode(order.getProductid());
-        insPlyIncome.setPayDate(insAreaCompany.getPayDate());
-        insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
-        insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
-        insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
-        insPlyIncome.setLicenseno(order.getLicenseno());
-        insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
-        insPlyIncome.setCreateTime(LocalDateTime.now());
-        insPlyIncome.setDocumentaryFeesStatus("0");
-        insPlyIncome.setHandlingFeesStatus("0");
-        insPlyIncome.setIsNotCar("0");
-        insPlyIncome.setIsNotDocumentary("0");
-        insPlyIncome.setAllFeeValue(handlingAmount);
-        baseMapper.insert(insPlyIncome);
-    }
+        BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(), insFeeOrderNew.getSySuperviseCostsPremiums(),null);
+        BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getSySuperviseCostsProportion(),null);
+        BigDecimal allNoTaxPremium = this.calculateTotal(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(), null);//不含税保费
+        InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getId(),insAreaCompany.getJqpolicyno(),insAreaCompany.getSypolicyno(),null,null,insFeeOrderNew.getDeptId(),null,order.getProductid(),insAreaCompany.getPayDate(),insAreaCompany.getSigningTime(),insAreaCompany.getCompanyId(),null,insFeeOrderNew.getAgreementId(),order.getLicenseno(),insAreaCompany.getTaxamount()
+        ,allNoTaxPremium,handlingProportion,null,handlingAmount,null,handlingAmount,null,null,LocalDateTime.now(),null,null,null,"0","0","0","0");
+        BigDecimal allTaxPremium = this.calculateTotal(insFeeOrderNew.getJqPremium(), insFeeOrderNew.getSyPremium(), null);
+        insPlyIncome.setJqPremium(insFeeOrderNew.getJqPremium());
+        insPlyIncome.setSyPremium(insFeeOrderNew.getSyPremium());
+        insPlyIncome.setJqNoTaxPremium(insFeeOrderNew.getJqNoTaxPremium());
+        insPlyIncome.setSyNoTaxPremium(insFeeOrderNew.getSyNoTaxPremium());
+        insPlyIncome.setJqSuperviseCostsProportion(insFeeOrderNew.getJqSuperviseCostsProportion());
+        insPlyIncome.setJqSuperviseCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums());
+        insPlyIncome.setSySuperviseCostsProportion(insFeeOrderNew.getSySuperviseCostsProportion());
+        insPlyIncome.setSySuperviseCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums());
+        insPlyIncome.setTaxPremium(allTaxPremium);
+        insPlyIncome.setUserId(insFeeOrderNew.getUserId());
+        this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
 
-    private void saveNoPinTai(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
-        InsPlyIncome insPlyIncome = new InsPlyIncome();
-        insPlyIncome.setOrderno(insFeeOrderNew.getId());  // 子订单号
-        String noPolicyno  = this.setNoPolicyno(insAreaCompany);
-        if(StringUtils.isNotEmpty(noPolicyno)){
-            insPlyIncome.setNoPolicyno(noPolicyno); // 非车保单号
-        }
-        insPlyIncome.setCommissionFeevalue(insFeeOrderNew.getNoSuperviseCostsPremiums());// 非车手续费
-        insPlyIncome.setCommissionFeerate(insFeeOrderNew.getNoSuperviseCostsProportion()); // 非车手续费比例
-        insPlyIncome.setOtherFeevalue(insFeeOrderNew.getNoOtherCostsPremiums());  //非车跟单费
-        insPlyIncome.setOtherFeerate(insFeeOrderNew.getNoOtherCostsProportion()); //非车跟单费用比例
-        insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
-        insPlyIncome.setRiskcode(order.getProductid());
-        insPlyIncome.setPayDate(insAreaCompany.getPayDate());
-        insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
-        insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
-        insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
-        insPlyIncome.setLicenseno(order.getLicenseno());
-        insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
-        insPlyIncome.setCreateTime(LocalDateTime.now());
-        insPlyIncome.setDocumentaryFeesStatus("0");
-        insPlyIncome.setHandlingFeesStatus("0");
-        insPlyIncome.setIsNotCar("1");
-        insPlyIncome.setIsNotDocumentary("0");
-        insPlyIncome.setAllFeeValue(insFeeOrderNew.getNoSuperviseCostsPremiums().add(insFeeOrderNew.getNoOtherCostsPremiums()));
         baseMapper.insert(insPlyIncome);
     }
 
@@ -296,37 +294,62 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     }
 
     private void savePinTai(InsOrders order, InsFeeOrderNew insFeeOrderNew, InsAreaCompany insAreaCompany) {
-        InsPlyIncome insPlyIncome = new InsPlyIncome();
-        insPlyIncome.setOrderno(insFeeOrderNew.getId());  // 子订单号
-        BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(), insFeeOrderNew.getSySuperviseCostsPremiums());
-        insPlyIncome.setCommissionFeevalue(handlingAmount);//手续费
-        BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getSySuperviseCostsProportion());
-        insPlyIncome.setCommissionFeerate(handlingProportion);// 手续费比例
-        BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums());
-        insPlyIncome.setOtherFeevalue(otherAmount);//跟单费用
-        BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion());
-        insPlyIncome.setOtherFeerate(otherProportion); // 跟单非比例
-        //保单号
-        insPlyIncome.setPolicyno(insAreaCompany.getJqpolicyno());  // 交强保单号
-        insPlyIncome.setSyPolicyno(insAreaCompany.getSypolicyno()); //商业保单号
-        insPlyIncome.setDeptId(insFeeOrderNew.getDeptId());
-        insPlyIncome.setRiskcode(order.getProductid());
-        insPlyIncome.setPayDate(insAreaCompany.getPayDate());
-        insPlyIncome.setSignDate(insAreaCompany.getSigningTime());
-        insPlyIncome.setCompanyId(insAreaCompany.getCompanyId());
-        insPlyIncome.setAgreementId(insFeeOrderNew.getAgreementId());
-        insPlyIncome.setLicenseno(order.getLicenseno());
-        insPlyIncome.setTaxamount(insAreaCompany.getTaxamount());
-        insPlyIncome.setCreateTime(LocalDateTime.now());
-        insPlyIncome.setDocumentaryFeesStatus("0");
-        insPlyIncome.setHandlingFeesStatus("0");
-        insPlyIncome.setIsNotCar("0");
-        insPlyIncome.setIsNotDocumentary("0");
-        insPlyIncome.setAllFeeValue(otherAmount.add(handlingAmount));
+        BigDecimal handlingAmount = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsPremiums(), insFeeOrderNew.getSySuperviseCostsPremiums(),insFeeOrderNew.getNoSuperviseCostsPremiums());  //手续费
+        BigDecimal handlingProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getSySuperviseCostsProportion(),insFeeOrderNew.getNoSuperviseCostsProportion());//手续费比例
+        BigDecimal otherAmount = this.calculateTotal(insFeeOrderNew.getJqOtherCostsPremiums(), insFeeOrderNew.getSyOtherCostsPremiums(),insFeeOrderNew.getNoOtherCostsPremiums());//跟单费
+        BigDecimal otherProportion = this.calculateTotal(insFeeOrderNew.getSyOtherCostsProportion(), insFeeOrderNew.getJqOtherCostsProportion(),insFeeOrderNew.getNoOtherCostsProportion()); //跟单费比例
+//      不含税保费
+        BigDecimal allNoTaxPremium = this.calculateTotal(insFeeOrderNew.getJqNoTaxPremium(), insFeeOrderNew.getSyNoTaxPremium(), insFeeOrderNew.getNoNoTaxPremium());
+        BigDecimal allAmount = this.calculateTotal(otherAmount, handlingAmount, null);
+        BigDecimal jqReceivableProportion = this.calculateTotal(insFeeOrderNew.getJqSuperviseCostsProportion(), insFeeOrderNew.getNoSuperviseCostsProportion(), null);// 交强应收 比例
+        BigDecimal syReceivableProportion = this.calculateTotal(insFeeOrderNew.getSySuperviseCostsProportion(), insFeeOrderNew.getSyOtherCostsProportion(), null);//商业应收比例
+        BigDecimal noReceivableProportion = this.calculateTotal(insFeeOrderNew.getNoSuperviseCostsProportion(), insFeeOrderNew.getNoOtherCostsProportion(), null);
+
+        String noPolicyno  = this.setNoPolicyno(insAreaCompany);
+        InsPlyIncome insPlyIncome = new InsPlyIncome(insFeeOrderNew.getId(),insAreaCompany.getJqpolicyno(),insAreaCompany.getSypolicyno(),
+                noPolicyno,null,insFeeOrderNew.getDeptId(), null,order.getProductid(),insAreaCompany.getPayDate(),insAreaCompany.getSigningTime(),insAreaCompany.getCompanyId(),
+                null,insFeeOrderNew.getAgreementId(),order.getLicenseno(),insAreaCompany.getTaxamount(),allNoTaxPremium,handlingProportion,
+                otherProportion,handlingAmount,otherAmount,allAmount,null,null,LocalDateTime.now(),null,null,null,"0","0","0","0");
+        insPlyIncome.setJqReceivableProportion(jqReceivableProportion);
+        insPlyIncome.setSyReceivableProportion(syReceivableProportion);
+        insPlyIncome.setNoReceivableProportion(noReceivableProportion);
+//        应收金额 =  商业手续费+商业跟单  + 交强手续费  +交强跟单费 + 非车手续费 + 非车跟单费   = allAmount
+        insPlyIncome.setJqSuperviseCostsPremiums(insFeeOrderNew.getJqSuperviseCostsPremiums()); // 交强手续费
+        insPlyIncome.setSySuperviseCostsPremiums(insFeeOrderNew.getSySuperviseCostsPremiums()); // 商业手续费
+        insPlyIncome.setNoSuperviseCostsPremiums(insFeeOrderNew.getNoSuperviseCostsPremiums()); // 非车手续费
+        insPlyIncome.setJqSuperviseCostsProportion(insFeeOrderNew.getJqSuperviseCostsProportion()); //交强手续费 比例
+        insPlyIncome.setSySuperviseCostsProportion(insFeeOrderNew.getSySuperviseCostsProportion()); // 商业手续费 比例
+        insPlyIncome.setNoSuperviseCostsProportion(insFeeOrderNew.getNoSuperviseCostsProportion());// 非车手续费 比例
+        insPlyIncome.setJqOtherCostsProportion(insFeeOrderNew.getJqOtherCostsProportion());  //交强跟单费比例
+        insPlyIncome.setSyOtherCostsProportion(insFeeOrderNew.getSyOtherCostsProportion());  //商业跟单费比例
+        insPlyIncome.setNoOtherCostsProportion(insFeeOrderNew.getNoOtherCostsProportion());  //非车跟单费比例
+        insPlyIncome.setUserId(insFeeOrderNew.getUserId());
+        this.saveByCompanyId(insFeeOrderNew ,insAreaCompany.getCompanyId(),insPlyIncome);
         baseMapper.insert(insPlyIncome);
     }
 
-    private BigDecimal calculateTotal(BigDecimal value1, BigDecimal value2) {
+    private void saveByCompanyId(InsFeeOrderNew insFeeOrderNew,String companyId, InsPlyIncome insPlyIncome) {
+        PtlAgreement  ptlAgreementQueryVo  = this.ptlAgreementService.getByAgreementIdNew(insFeeOrderNew.getAgreementId());
+        if(ObjectUtils.isNotEmpty(ptlAgreementQueryVo)){
+            if(StringUtils.isNotEmpty(ptlAgreementQueryVo.getPartnerCompaniesId())){
+//                合作公司id
+                String partnerCompaniesId = ptlAgreementQueryVo.getPartnerCompaniesId();
+                insPlyIncome.setPartnerCompaniesId(partnerCompaniesId);
+                EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(partnerCompaniesId);
+                String name = esmInsCompany.getName();   //合作名称
+                insPlyIncome.setPartnerCompaniesName(name);
+                insPlyIncome.setPartnerCompaniesId(ptlAgreementQueryVo.getPartnerCompaniesId());
+            }
+            if(StringUtils.isNotEmpty(ptlAgreementQueryVo.getAssociationCompaniesId())){
+                String associationCompaniesId = ptlAgreementQueryVo.getAssociationCompaniesId();
+                EsmInsCompany esmInsCompany = EsmInsCompanyService.getById(associationCompaniesId);
+                String name = esmInsCompany.getName();   //保险公司名称
+                insPlyIncome.setCompanyName(name);
+            }
+        }
+    }
+
+    private BigDecimal calculateTotal(BigDecimal value1, BigDecimal value2, BigDecimal value3) {
         BigDecimal total = BigDecimal.ZERO;
 
         if (value1 != null) {
@@ -336,6 +359,9 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         if (value2 != null) {
             total = total.add(value2);
         }
+        if (value3 != null) {
+            total = total.add(value3);
+        }
 
         return total;
     }
@@ -364,29 +390,8 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             PageHelper.startPage(insPlyIncomeVo.getPageNum(),insPlyIncomeVo.getPageSize());
             params.put("pageNum",insPlyIncomeVo.getPageNum());
             params.put("pageSize",insPlyIncomeVo.getPageSize());
-            if(ObjectUtils.isNotEmpty(insPlyIncomeVo.getStartDate())){
-                params.put("startDate",insPlyIncomeVo.getStartDate().toString());
-
-            }
-            if(ObjectUtils.isNotEmpty(insPlyIncomeVo.getEndDate())){
-                params.put("endDate",insPlyIncomeVo.getEndDate().toString());
-            }
-            if(StringUtils.isNotEmpty(insPlyIncomeVo.getOrderno())){
-                params.put("orderno",insPlyIncomeVo.getOrderno());
-            }
-            if(StringUtils.isNotEmpty(insPlyIncomeVo.getPolicyno())){
-                params.put("policyno",insPlyIncomeVo.getPolicyno());
-            }
-            if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())){
-                params.put("isOther",insPlyIncomeVo.getIsNotDocumentary());
-            }
+            params =this.saveParams(insPlyIncomeVo,params);
 
-            if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
-                params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
-            }
-            if(StringUtils.isNotEmpty(insPlyIncomeVo.getAgreementType())){
-                params.put("agreementType",insPlyIncomeVo.getAgreementType());
-            }
 
             List<InsPlyIncome> list= this.baseMapper.queryNew(params);
             pageHelper=new PageInfo(list);
@@ -397,6 +402,119 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             return HttpResult.error("查询异常");
         }
     }
+    @Override
+    public InsPlyIncome totalAmount(InsPlyIncomeVo insPlyIncomeVo) {
+        HashMap<String, Object> params = new HashMap<>();
+        params = this.saveParams(insPlyIncomeVo, params);
+        InsPlyIncome totalledAmount =baseMapper.totalAmount(params);  //总金额
+        params.put("handlingFeesStatus","0");
+        InsPlyIncome noTotalAmount =baseMapper.totalAmount(params);
+        if(ObjectUtils.isNotEmpty(totalledAmount) && ObjectUtils.isNotEmpty(noTotalAmount)){
+            totalledAmount.setReadyTotalFeevalue(noTotalAmount.getTotalFeevalue());
+            totalledAmount.setReadyCommissionFeevalue(noTotalAmount.getReadyCommissionFeevalue());
+            totalledAmount.setReadyOtherFeevalue(noTotalAmount.getOtherFeevalue());
+            return totalledAmount;
+        }
+        return totalledAmount;
+    }
+
+    @Override
+    @Transactional
+    public HttpResult<Object> batchPinBalance(InsPlyIncomeVo insPlyIncomeVo) {
+
+            HashMap<String, Object> params = new HashMap<>();
+            List<InsPlyIncome> list= this.baseMapper.queryNew(params);
+            for (InsPlyIncome item : list) {
+                item.setHandlingFeesStatus("1");
+                item.setSettlementTime(LocalDateTime.now());
+                baseMapper.updateById(item);
+            }
+            SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
+            settlementDocumentaryLogEntity.setIds(insPlyIncomeVo.getIds());
+            settlementDocumentaryLogEntity.setCompanyId(insPlyIncomeVo.getCompanyId());
+            settlementDocumentaryLogEntity.setAmount(insPlyIncomeVo.getOtherFeevalue());  //跟单费金额
+            settlementDocumentaryLogEntity.setHandingAmount(insPlyIncomeVo.getCommissionFeevalue());  //手续费金额
+            settlementDocumentaryLogEntity.setCreateTime(new Date());
+            settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
+            return HttpResult.ok();
+    }
+
+    @Override
+    public List<InsPlyIncome> totalPinAmount(InsPlyIncomeVo insPlyIncomeVo) {
+        HashMap<String, Object> params = new HashMap<>();
+        params = this.saveParams(insPlyIncomeVo,params);
+        List<InsPlyIncome>   result=baseMapper.totalPinAmount(params);
+        return result;
+    }
+
+
+    private HashMap<String, Object> saveParams(InsPlyIncomeVo insPlyIncomeVo, HashMap<String, Object> params) {
+        if(ObjectUtils.isNotEmpty(insPlyIncomeVo.getStartDate())){
+            params.put("startDate",insPlyIncomeVo.getStartDate().toString());
+        }
+        if(ObjectUtils.isNotEmpty(insPlyIncomeVo.getEndDate())){
+            params.put("endDate",insPlyIncomeVo.getEndDate().toString());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getOrderno())){
+            params.put("orderno",insPlyIncomeVo.getOrderno());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotDocumentary())){
+            params.put("isOther",insPlyIncomeVo.getIsNotDocumentary());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getIsNotCar())){
+            params.put("isNotCar",insPlyIncomeVo.getIsNotCar());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getAgreementType())){
+            params.put("agreementType",insPlyIncomeVo.getAgreementType());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getLicenseno())){
+            params.put("licenseno", insPlyIncomeVo.getLicenseno().split(","));
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getUserId())){
+            params.put("userId",insPlyIncomeVo.getUserId());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompanyId())){
+            params.put("companyId",insPlyIncomeVo.getCompanyId());
+        }
+
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getRiskcode())){
+            params.put("riskcode",insPlyIncomeVo.getRiskcode());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getPolicyno())){
+            params.put("policyno",insPlyIncomeVo.getPolicyno().split(","));
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getSyPolicyno())){
+            params.put("syPolicyno",insPlyIncomeVo.getSyPolicyno().split(","));
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getNoPolicyno())){
+            params.put("noPolicyno",insPlyIncomeVo.getNoPolicyno().split(","));
+        }
+        if(insPlyIncomeVo.getSigndate()!=null){
+            params.put("signdate",insPlyIncomeVo.getSigndate());
+        }
+        if(insPlyIncomeVo.getCreateTime()!=null){
+            params.put("createTime",insPlyIncomeVo.getCreateTime());
+        }
+        if(insPlyIncomeVo.getSettlementTime()!=null){
+            params.put("settlementTime",insPlyIncomeVo.getSettlementTime());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getHandlingFeesStatus())){
+            params.put("handlingFeesStatus",insPlyIncomeVo.getHandlingFeesStatus());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getPartnerCompaniesId())){
+            params.put("partnerCompaniesId",insPlyIncomeVo.getHandlingFeesStatus());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
+            params.put("year",insPlyIncomeVo.getYear());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())){
+            params.put("month",insPlyIncomeVo.getMonth());
+        }
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getDay())){
+            params.put("day",insPlyIncomeVo.getDay());
+        }
+        return params;
+    }
 
     @Override
     public HttpResult<BasePageResult<InsPlyIncome>> nonSettlementQuery(InsPlyIncomeVo insPlyIncomeVo) {
@@ -415,8 +533,8 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
                 params.put("year",insPlyIncomeVo.getYear());
             }
-            if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
-                params.put("year",insPlyIncomeVo.getYear());
+            if(StringUtils.isNotEmpty(insPlyIncomeVo.getMonth())){
+                params.put("month",insPlyIncomeVo.getMonth());
             }
             if(StringUtils.isNotEmpty(insPlyIncomeVo.getDocumentaryFeesStatus())){
                 params.put("documentaryFeesStatus",insPlyIncomeVo.getDocumentaryFeesStatus());
@@ -434,7 +552,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     @Override
     public HttpResult<List<InsPlyIncome>> nonSettldetail(InsPlyIncomeVo insPlyIncomeVo) {
         try {
-            String ids = insPlyIncomeVo.getIds();
+            String ids = insPlyIncomeVo.getIncomeIds();
             ArrayList<InsPlyIncome> resultList = new ArrayList<>();
             if (ObjectUtils.isNotEmpty(ids)) {
                 String[] split = ids.split(",");
@@ -457,12 +575,14 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             List<InsPlyIncomeExcelDto> dtoList = ExcelEasypoiUtils.importExcel(file, InsPlyIncomeExcelDto.class, 0, 1, 1);
             for (InsPlyIncomeExcelDto excelItem : dtoList) {
                 String licenseno = excelItem.getLicenseno();//车牌号
+                String policyno = excelItem.getPolicyno(); //交强保单号
+                String syPolicyno = excelItem.getSyPolicyno(); //商业保单号
+                String noPolicyno = excelItem.getNoPolicyno(); //非车保单号
+
                 if(ObjectUtils.isNotEmpty(licenseno)){
-                    InsPlyIncome insPlyIncome=baseMapper.findByLicenseno(licenseno);
+                    InsPlyIncome insPlyIncome=baseMapper.findByLicenseno(licenseno,policyno,syPolicyno,noPolicyno);
                     if(ObjectUtils.isNotEmpty(insPlyIncome)){
-                        insPlyIncome.setContractFileId(insPlyIncomeVo.getContractFileId());
-                        insPlyIncome.setContractId(insPlyIncomeVo.getContractId());
-                        insPlyIncome.setVoucherNumber(insPlyIncomeVo.getVoucherNumber());
+                        insPlyIncome.setHandlingFeesStatus("1"); //已结算
                         baseMapper.updateById(insPlyIncome);
                     }
                 }
@@ -475,6 +595,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     @Override
     @Transactional
     public void updateByEntity(InsPlyIncomeVo insPlyIncomeVo) {
+//        根据协议   如果是含增值税结算   用保费 *   如果是  不含税保费
         InsPlyIncome insPlyIncome = new InsPlyIncome();
         BeanUtils.copyProperties(insPlyIncomeVo, insPlyIncome);
         baseMapper.updateById(insPlyIncome);
@@ -485,6 +606,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     }
 
     private void saveLog(InsPlyIncomeVo insPlyIncomeVo) {
+
         //         添加记录
         SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
         settlementDocumentaryLogEntity.setCrudStatus(insPlyIncomeVo.getCrudStatus());
@@ -629,7 +751,112 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     @Transactional
     public HttpResult batchBalance(InsPlyIncomeVo insPlyIncomeVo) {
 //  通过ids 查出跟单非结算单
-        String ids = insPlyIncomeVo.getIds();
+        String ids = insPlyIncomeVo.getIncomeIds();
+        if(StringUtils.isNotEmpty(ids)){
+            String[] split = ids.split(",");
+            for (int i =0; i <split.length ; i++) {
+                String id = split[i];
+                InsPlyIncome insPlyIncome = baseMapper.selectById(id);
+                insPlyIncome.setDocumentaryFeesStatus("1"); //1  为跟单费已经结算
+                insPlyIncome.setSettlementTime(LocalDateTime.now());
+                baseMapper.updateById(insPlyIncome);
+            }
+        }
+        SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();  // 生成跟单费结算表
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
+            settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getYear());//年度
+        }
+
+        settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId());// 保险公司id
+        settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getOtherFeevalue());  //其他费用金额
+        settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getOtherFeevalue().subtract(insPlyIncomeVo.getInvoicCommissionFeevalue())); //未开票金额
+        settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getInvoicCommissionFeevalue());//已开票金额
+        settlementDocumentaryFeesVo.setSettlementStatus("2");
+        settlementDocumentaryFeesVo.setIds(insPlyIncomeVo.getIncomeIds());
+        return  settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
+    }
+
+
+    @Override
+    public List<InsPlyIncome> totalBxAmount(InsPlyIncomeVo insPlyIncomeVo) {
+        HashMap<String, Object> params = new HashMap<>();
+        params=this.saveParams(insPlyIncomeVo,params);
+        List<InsPlyIncome>  resultList  =  baseMapper.totalBxAmount(params);
+        return resultList;
+    }
+
+    @Override
+    @Transactional
+    public HttpResult<Object> batchInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
+//      开票时生成  记录 用来合计已经开票数据
+        HashMap<String, Object> params = new HashMap<>();
+        params = this.saveParams(insPlyIncomeVo, params);
+        List<InsPlyIncome> list= this.baseMapper.queryNew(params);
+        for (InsPlyIncome item :  list){
+            item.setHandlingFeesStatus("2");  //已开票
+            item.setInvoicTime(LocalDate.now());
+            item.setInvoicAmount(item.getCommissionFeevalue());
+            baseMapper.updateById(item);
+        }
+        return HttpResult.ok();
+    }
+
+    @Override
+    public HttpResult<InsPlyIncome> queryInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
+        HashMap<String, Object> params = new HashMap<>();
+        params = this.saveParams(insPlyIncomeVo, params);
+        InsPlyIncome result=  baseMapper.queryInvoicing(params);  //总金额
+        params.put("handlingFeesStatus","0");
+        InsPlyIncome noResult=  baseMapper.queryInvoicing(params);  //未结算金额
+        result.setReadyCommissionFeevalue(noResult.getCommissionFeevalue());
+        return HttpResult.ok(result);
+    }
+
+    @Override
+    public HttpResult<Object> batchBxBalance(InsPlyIncomeVo insPlyIncomeVo) {
+        InsPlyIncome insPlyIncome = new InsPlyIncome();
+
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getIds())){
+            String[] split = insPlyIncomeVo.getIds().split(",");
+            for(String  id : split){
+                insPlyIncome.setId(id);
+                insPlyIncome.setHandlingFeesStatus("2");
+                insPlyIncome.setSettlementTime(LocalDateTime.now());
+                baseMapper.updateById(insPlyIncome);
+            }
+
+        }
+        SettlementDocumentaryLogEntity settlementDocumentaryLogEntity = new SettlementDocumentaryLogEntity();
+
+        settlementDocumentaryLogEntity.setHandingAmount(insPlyIncomeVo.getReadyCommissionFeevalue());
+        settlementDocumentaryLogEntity.setIds(insPlyIncomeVo.getIds());
+        settlementDocumentaryLogEntity.setCreateTime(new Date());
+        settlementDocumentaryLogEntity.setCompanyId(insPlyIncomeVo.getCompanyId());
+        settlementDocumentaryLogService.save(settlementDocumentaryLogEntity);
+        return HttpResult.ok();
+    }
+
+    @Override
+    public HttpResult<InsPlyIncome> querySettInvoicing(InsPlyIncomeVo insPlyIncomeVo) {
+        HashMap<String, Object> params = new HashMap<>();
+        params = this.saveParams(insPlyIncomeVo, params);
+        InsPlyIncome insPlyIncome = baseMapper.queryInvoicing(params);  //已经开票
+        return HttpResult.ok(insPlyIncome);
+    }
+
+    @Override
+    public HttpResult<List<InsPlyIncome>> allOtherAmount(InsPlyIncomeVo insPlyIncomeVo) {
+        HashMap<String, Object> params = new HashMap<>();
+        params=this.saveParams(insPlyIncomeVo,params);
+        List<InsPlyIncome> result= baseMapper.allOtherAmount(params);
+        return HttpResult.ok(result);
+    }
+
+    @Override
+    @Transactional
+    public HttpResult<Object> batchInvoic(InsPlyIncomeVo insPlyIncomeVo) {
+        //  通过ids 查出跟单非结算单
+        String ids = insPlyIncomeVo.getIncomeIds();
         if(StringUtils.isNotEmpty(ids)){
             String[] split = ids.split(",");
             for (int i =0; i <split.length ; i++) {
@@ -638,16 +865,107 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
                 insPlyIncome.setContractId(insPlyIncomeVo.getContractId()); // 合同id
                 insPlyIncome.setContractFileId(insPlyIncomeVo.getContractFileId());
                 insPlyIncome.setVoucherNumber(insPlyIncomeVo.getVoucherNumber());
-                insPlyIncome.setDocumentaryFeesStatus("1"); //1  为跟单费已经结算
+                insPlyIncome.setSettlementTime(LocalDateTime.now());
                 baseMapper.updateById(insPlyIncome);
             }
         }
         SettlementDocumentaryFeesVo settlementDocumentaryFeesVo = new SettlementDocumentaryFeesVo();  // 生成跟单费结算表
-        settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getYear());//年度
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getYear())){
+            settlementDocumentaryFeesVo.setTimeFrame(insPlyIncomeVo.getYear());//年度
+        }
         settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId());// 保险公司id
-        settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());
-        settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getTotAmount());
+        settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getOtherFeevalue());  //其他费用金额
+        settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getNoInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算
+        settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());//已经开票
+        settlementDocumentaryFeesVo.setIds(insPlyIncomeVo.getIncomeIds());
+        settlementDocumentaryFeesVo.setSettlementStatus("1");
         return  settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
-//
     }
+
+    @Override
+    public HttpResult pinHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
+        HashMap<String, Object> params = new HashMap<>();
+        params =this.saveParams(insPlyIncomeVo,params);
+        List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
+
+        ExportParams exportParams = new ExportParams("保险手续费导出", null, ExcelType.HSSF);
+        exportParams.setStyle(ExcelStyleUtil.class);
+        List<SettlementFeesExcel> resultList = new ArrayList<>();
+        for (InsPlyIncome item :insPlyIncomes){
+            SettlementFeesExcel bxSettlementFeesExcel = new SettlementFeesExcel();
+            BeanUtils.copyProperties(item, bxSettlementFeesExcel);
+            resultList.add(bxSettlementFeesExcel);
+        }
+        String uploadPath = this.uploadPath + "/excel/";
+        Path path = Paths.get(uploadPath);
+        if (!Files.exists(path)) {
+            try {
+                Files.createDirectories(path);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        String fileName = EasyExcelUtils.downExcel(uploadPath, "保险手续费导出", SettlementFeesExcel.class, resultList);
+        return HttpResult.ok("",uploadUrl + "excel/" + fileName);
+
+    }
+
+    @Override
+    public HttpResult bxHandlingexcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
+        HashMap<String, Object> params = new HashMap<>();
+        params =this.saveParams(insPlyIncomeVo,params);
+        List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);
+
+        ExportParams exportParams = new ExportParams("平台手续费", null, ExcelType.HSSF);
+        exportParams.setStyle(ExcelStyleUtil.class);
+        List<BxSettlementFeesExcel> resultList = new ArrayList<>();
+        for (InsPlyIncome item :insPlyIncomes){
+            BxSettlementFeesExcel bxSettlementFeesExcel = new BxSettlementFeesExcel();
+            BeanUtils.copyProperties(item, bxSettlementFeesExcel);
+            resultList.add(bxSettlementFeesExcel);
+        }
+        String uploadPath = this.uploadPath + "/excel/";
+        Path path = Paths.get(uploadPath);
+        if (!Files.exists(path)) {
+            try {
+                Files.createDirectories(path);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        String fileName = EasyExcelUtils.downExcel(uploadPath, "平台手续费导出", BxSettlementFeesExcel.class, resultList);
+        return HttpResult.ok("",uploadUrl + "excel/" + fileName);
+    }
+
+    @Override
+    public HttpResult bxOtherExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response) {
+        HashMap<String, Object> params = new HashMap<>();
+        params =this.saveParams(insPlyIncomeVo,params);
+        params.put("agreementType","2");
+        params.put("isOther","1");
+        params.put("isNotCar","0");
+        List<InsPlyIncome> insPlyIncomes = baseMapper.allOtherAmount(params);
+
+        ExportParams exportParams = new ExportParams("跟单费导出", null, ExcelType.HSSF);
+        exportParams.setStyle(ExcelStyleUtil.class);
+        List<BxOtherExcel> resultList = new ArrayList<>();
+        for (InsPlyIncome item :insPlyIncomes){
+            BxOtherExcel bxSettlementFeesExcel = new BxOtherExcel();
+            BeanUtils.copyProperties(item, bxSettlementFeesExcel);
+            resultList.add(bxSettlementFeesExcel);
+        }
+        String uploadPath = this.uploadPath + "/excel/";
+        Path path = Paths.get(uploadPath);
+        if (!Files.exists(path)) {
+            try {
+                Files.createDirectories(path);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        String fileName = EasyExcelUtils.downExcel(uploadPath, "跟单费导出", BxOtherExcel.class, resultList);
+        return HttpResult.ok("",uploadUrl + "excel/" + fileName);
+    }
+
+
 }

+ 43 - 2
src/main/java/com/ydtech/modules/fnc/vo/InsPlyIncomeVo.java

@@ -48,6 +48,19 @@ public class InsPlyIncomeVo implements Serializable {
     @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private LocalDate endDate;
 
+
+    @ApiModelProperty(value = "签单日期")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private LocalDate signdate;
+
+    @ApiModelProperty(value = "创建日期")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private LocalDate createTime;
+
+    @ApiModelProperty(value = "结算日期")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private LocalDate settlementTime;
+
     @ApiModelProperty("交强保单号")
     private String policyno;
 
@@ -98,11 +111,11 @@ public class InsPlyIncomeVo implements Serializable {
     @ApiModelProperty("合同附件id")
     private String contractFileId;
 
-    @ApiModelProperty("手续费结算状态  1 为已结算")
+    @ApiModelProperty("手续费结算状态  1 为已结算  2 已经结算")
     private String handlingFeesStatus;
 
 
-    @ApiModelProperty("跟单费结算状态  1 为已结算")
+    @ApiModelProperty("跟单费结算状态  1 为已结算  2 已经结算")
     private String documentaryFeesStatus;
 
 
@@ -136,10 +149,38 @@ public class InsPlyIncomeVo implements Serializable {
     @JsonFormat(pattern = "yyyy", timezone = "GMT+8")
     private  String year;
 
+    @ApiModelProperty("月度")
+    @JsonFormat(pattern = "MM", timezone = "GMT+8")
+    private  String month;
+    @ApiModelProperty("天")
+    @JsonFormat(pattern = "dd", timezone = "GMT+8")
+    private  String day;
+
     @ApiModelProperty("其他费用比例")
     private BigDecimal otherFeerate;
 
     @ApiModelProperty("操作标识")
     private String crudStatus;
 
+    @ApiModelProperty("含税保费")
+    private BigDecimal taxPremium;
+
+    @ApiModelProperty("用户id")
+    private String userId;
+
+    @ApiModelProperty("用户id")
+    private String partnerCompaniesId;
+    @ApiModelProperty("未结算手续费")
+    private BigDecimal readyCommissionFeevalue;
+    @ApiModelProperty("未开票金额")
+    private BigDecimal noInvoicCommissionFeevalue;
+    @ApiModelProperty("开票金额")
+    private BigDecimal invoicCommissionFeevalue;
+    @ApiModelProperty("未结算金额")
+    private BigDecimal unSettledAmount;
+    @ApiModelProperty("未结算ids")
+    private String unSettledIds;
+
+    @ApiModelProperty("开票ids")
+    private String incomeIds;
 }

+ 5 - 0
src/main/java/com/ydtech/modules/fnc/vo/SettlementDocumentaryFeesVo.java

@@ -64,4 +64,9 @@ public class SettlementDocumentaryFeesVo implements Serializable {
     @ApiModelProperty("签单日期")
     @JsonFormat(pattern = "yyyy-MM-dd")
     private LocalDate signingTime;
+    @ApiModelProperty("是否是开票 结算")
+    private String settlementStatus;
+
+    @ApiModelProperty("结算ids")
+    private String ids;
 }

+ 49 - 0
src/main/java/com/ydtech/modules/ins/model/vo/res/BxOtherExcel.java

@@ -0,0 +1,49 @@
+package com.ydtech.modules.ins.model.vo.res;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import com.alibaba.excel.enums.poi.BorderStyleEnum;
+import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
+import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class BxOtherExcel implements Serializable {
+    private static final long serialVersionUID = 699797306438199251L;
+
+    @ApiModelProperty("保险公司名称")
+    @ExcelProperty( "保险公司名称")
+    private String companyName;
+
+
+    @ApiModelProperty("合作公司名称")
+    @ExcelProperty( "合作公司名称")
+    private String partnerCompaniesName;
+
+    @ApiModelProperty("跟单费总额")
+    @ExcelProperty( "跟单费总额")
+    private BigDecimal otherFeevalue;
+
+    @ApiModelProperty("未开票跟单")
+    @ExcelProperty( "未开票跟单")
+    private BigDecimal noInvoicCommissionFeevalue;
+
+    @ApiModelProperty("已开票跟单")
+    @ExcelProperty( "已开票跟单")
+    private BigDecimal invoicCommissionFeevalue;
+
+    @ApiModelProperty("已开票已结算跟单费")
+    @ExcelProperty( "已开票已结算跟单费")
+    private BigDecimal settleMentAmount;
+
+    @ApiModelProperty("已开票未结算跟单费")
+    @ExcelProperty( "已开票未结算跟单费")
+    private BigDecimal unsettledAmount;
+}

+ 131 - 0
src/main/java/com/ydtech/modules/ins/model/vo/res/BxSettlementFeesExcel.java

@@ -0,0 +1,131 @@
+package com.ydtech.modules.ins.model.vo.res;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import com.alibaba.excel.enums.poi.BorderStyleEnum;
+import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
+import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+@Data
+public class BxSettlementFeesExcel implements Serializable {
+    @ApiModelProperty("子订单号")
+    @ExcelProperty( "子订单号")
+    private String orderno;
+
+    @ApiModelProperty("签单日期")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    @ExcelProperty( "签单日期")
+    private LocalDate signDate;
+
+
+    @ApiModelProperty("车牌号")
+    @ExcelProperty( "车牌号")
+    private String licenseno;
+
+    @ApiModelProperty("被保险人")
+    @ExcelProperty( "被保险人")
+    private String userName;
+
+
+    @ApiModelProperty("险种")
+    @ExcelProperty( "险种")
+    private String riskcode;
+
+    @ApiModelProperty("保司机构")
+    @ExcelProperty( "保司机构")
+    private String partnerCompaniesName;
+
+    @ApiModelProperty("保险公司名称")
+    @ExcelProperty( "保险公司名称")
+    private String companyName;
+
+    @ApiModelProperty("协议号")
+    @ExcelProperty( "协议号")
+    private String agreementId;
+
+    @ApiModelProperty("交强保单号")
+    @ExcelProperty( "交强保单号")
+    private String policyno;
+
+
+    @ApiModelProperty("商业保单号")
+    @ExcelProperty( "商业保单号")
+    private String syPolicyno;
+
+    @ApiModelProperty("交强险保费")
+    @ExcelProperty( "交强险保费")
+    private BigDecimal jqPremium;
+    @ApiModelProperty("车船税")
+    @ExcelProperty( "车船税")
+    private BigDecimal taxamount;
+
+    @ApiModelProperty("商业险保费")
+    @ExcelProperty( "商业险保费")
+    private BigDecimal syPremium;
+
+
+    @ApiModelProperty("手续费比例")
+    @ExcelProperty( "手续费比例")
+    private BigDecimal commissionFeerate;
+
+
+    @ApiModelProperty("交强手续费比例")
+    @ExcelProperty( "交强手续费比例")
+    private BigDecimal jqSuperviseCostsProportion;
+
+
+
+    @ApiModelProperty("商业手续费比例")
+    @ExcelProperty( "商业手续费比例")
+    private BigDecimal sySuperviseCostsProportion;
+
+
+    @ApiModelProperty("手续费金额")
+    @ExcelProperty( "手续费金额")
+    private BigDecimal commissionFeevalue;
+
+
+
+    @ApiModelProperty("应收金额")
+    @ExcelProperty( "应收金额")
+    private BigDecimal receivableAmount;
+
+
+    @ExcelProperty( "创建日期")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    @ApiModelProperty(value = "创建日期")
+    private LocalDate createTime;
+
+
+    @ExcelProperty( "结算日期")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    @ApiModelProperty(value = "结算日期")
+    private LocalDate settlementTime;
+
+
+    @ApiModelProperty("结算人")
+    @ExcelProperty( "结算人")
+    private String settlementUserName;
+
+
+    @ApiModelProperty("结算人")
+    @ExcelProperty( "结算人")
+    private String updateUserName;
+
+
+    @ApiModelProperty("手续费结算状态  1 为已结算  2 已经结算")
+    @ExcelProperty( "手续费结算状态")
+    private String handlingFeesStatus;
+
+}

+ 173 - 0
src/main/java/com/ydtech/modules/ins/model/vo/res/SettlementFeesExcel.java

@@ -0,0 +1,173 @@
+package com.ydtech.modules.ins.model.vo.res;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import com.alibaba.excel.enums.poi.BorderStyleEnum;
+import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
+import com.alibaba.excel.enums.poi.VerticalAlignmentEnum;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+@Data
+public class SettlementFeesExcel implements Serializable {
+    private static final long serialVersionUID = 699797306438199251L;
+
+
+    @ApiModelProperty("子订单号")
+    @ExcelProperty( "子订单号")
+    private String orderno;
+
+
+    @ApiModelProperty("签单日期")
+    @ExcelProperty( "签单日期")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    private LocalDateTime signDate;
+
+
+    @ApiModelProperty("车牌号")
+    @ExcelProperty( "车牌号")
+    private String licenseno;
+
+    @ApiModelProperty("被保险人")
+    @ExcelProperty( "被保险人")
+    private String userName;
+
+
+
+    @ApiModelProperty("保险公司名称")
+    @ExcelProperty( "保险公司名称")
+    private String companyName;
+
+    @ApiModelProperty("险种")
+    @ExcelProperty( "险种")
+    private String riskcode;
+
+
+    @ApiModelProperty("保司机构")
+    @ExcelProperty( "保司机构")
+    private String partnerCompaniesName;
+
+    @ApiModelProperty("协议号")
+    @ExcelProperty( "协议号")
+    private String agreementId;
+
+    @ApiModelProperty("交强保单号")
+    @ExcelProperty( "交强保单号")
+    private String policyno;
+
+
+    @ApiModelProperty("商业保单号")
+    @ExcelProperty( "商业保单号")
+    private String syPolicyno;
+
+    @ApiModelProperty("非车保单号")
+    @ExcelProperty( "非车保单号")
+    private String noPolicyno;
+
+    @ApiModelProperty("交强险保费")
+    @ExcelProperty( "交强险保费")
+    private BigDecimal jqPremium;
+
+
+    @ApiModelProperty("车船税")
+    @ExcelProperty( "车船税")
+    private BigDecimal taxamount;
+
+
+    @ApiModelProperty("商业险保费")
+    @ExcelProperty( "商业险保费")
+    private BigDecimal syPremium;
+
+    @ApiModelProperty("非车保费")
+    @ExcelProperty( "非车保费")
+    private BigDecimal noPremium;
+
+    @ApiModelProperty("交强应收比例")
+    @ExcelProperty( "交强应收比例")
+    private BigDecimal jqReceivableProportion;
+
+    @ApiModelProperty("交强手续费比例")
+    @ExcelProperty( "交强手续费比例")
+    private BigDecimal jqSuperviseCostsProportion;
+
+    @ApiModelProperty("交强非跟单比例")
+    @ExcelProperty( "交强非跟单比例")
+    private BigDecimal jqOtherCostsProportion;
+
+    @ApiModelProperty("商业应收比例")
+    @ExcelProperty( "交强非跟单比例")
+    private BigDecimal syReceivableProportion;
+
+    @ApiModelProperty("商业手续费比例")
+    @ExcelProperty( "商业手续费比例")
+    private BigDecimal sySuperviseCostsProportion;
+
+    @ApiModelProperty("商业非跟单比例")
+    @ExcelProperty( "商业非跟单比例")
+    private BigDecimal syOtherCostsProportion;
+
+    @ApiModelProperty("非车应收比例")
+    @ExcelProperty( "非车应收比例")
+    private BigDecimal noReceivableProportion;
+
+
+    @ApiModelProperty("非车手续费比例")
+    @ExcelProperty( "非车手续费比例")
+    private BigDecimal noSuperviseCostsProportion;
+
+    @ApiModelProperty("非车跟单比例")
+    @ExcelProperty( "非车跟单比例")
+    private BigDecimal noOtherCostsProportion;
+
+
+    @ApiModelProperty("手续费金额")
+    @ExcelProperty( "手续费金额")
+    private BigDecimal commissionFeevalue;
+
+
+    @ApiModelProperty("非跟单金额")
+    @ExcelProperty( "非跟单金额")
+    private BigDecimal otherFeevalue;
+
+
+    @ApiModelProperty("应收金额")
+    @ExcelProperty( "应收金额")
+    private BigDecimal receivableAmount;
+
+    @ExcelProperty( "创建日期")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    @ApiModelProperty(value = "创建日期")
+    private LocalDate createTime;
+
+
+    @ExcelProperty( "结算日期")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    @ApiModelProperty(value = "结算日期")
+    private LocalDate settlementTime;
+
+
+    @ApiModelProperty("结算人")
+    @ExcelProperty( "结算人")
+    private String settlementUserName;
+
+
+    @ApiModelProperty("结算人")
+    @ExcelProperty( "结算人")
+    private String updateUserName;
+
+
+    @ApiModelProperty("手续费结算状态  1 为已结算  2 已经结算")
+    @ExcelProperty( "手续费结算状态")
+    private String handlingFeesStatus;
+
+
+}

+ 18 - 1
src/main/java/com/ydtech/modules/inv/model/dto/InsPlyIncomeExcelDto.java

@@ -7,8 +7,25 @@ import lombok.Data;
 @Data
 public class InsPlyIncomeExcelDto {
     /**
-     * 等级
+     * 车牌号
      */
     @Excel(name = "车牌号")
     private String licenseno;
+    /**
+     * 交强保单号
+     */
+    @Excel(name = "交强保单号")
+    private String policyno;
+
+    /**
+     * 商业保单号
+     */
+    @Excel(name = "商业保单号")
+    private String syPolicyno;
+
+    /**
+     * 非车保单号
+     */
+    @Excel(name = "非车保单号")
+    private String noPolicyno;
 }

+ 1 - 0
src/main/java/com/ydtech/modules/protocol/dao/PtlAgreementMapper.java

@@ -20,6 +20,7 @@ public interface PtlAgreementMapper extends BaseMapper<PtlAgreement> {
 
     PtlAgreementInsCompanyDto getAgreementCompanyByCompanyId(@Param("localDate") LocalDate localDate, @Param("deptId") String deptId,@Param("companyId") String companyId);
 
+    PtlAgreement getByAgreementIdNew(String agreementId);
 }
 
 

+ 2 - 0
src/main/java/com/ydtech/modules/protocol/service/PtlAgreementService.java

@@ -215,4 +215,6 @@ public interface PtlAgreementService extends IService<PtlAgreement> {
      */
     List<PtlAgreement> getCurrentAgreementList(String agreementId);
 
+    PtlAgreement getByAgreementIdNew(String agreementId);
+
 }

+ 6 - 0
src/main/java/com/ydtech/modules/protocol/service/impl/PtlAgreementServiceImpl.java

@@ -708,4 +708,10 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         return ptlAgreements;
     }
 
+    @Override
+    public PtlAgreement getByAgreementIdNew(String agreementId) {
+        PtlAgreement   ptlAgreement= baseMapper.getByAgreementIdNew(agreementId);
+        return ptlAgreement;
+    }
+
 }

+ 579 - 36
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -34,10 +34,41 @@
         <result column="sy_policyno" property="syPolicyno"/>
         <result column="is_not_car" property="isNotCar"/>
         <result column="is_not_documentary" property="isNotDocumentary"/>
+        <result column="invoic_amount" property="invoicAmount"/>
+        <result column="invoic_id" property="invoicId"/>
+        <result column="tax_premium" property="taxPremium"/>
+        <result column="jq_supervise_costs_premiums" property="jqSuperviseCostsPremiums"/>
+        <result column="jq_supervise_costs_proportion" property="jqSuperviseCostsProportion"/>
+        <result column="sy_supervise_costs_premiums" property="sySuperviseCostsPremiums"/>
+        <result column="sy_supervise_costs_proportion" property="sySuperviseCostsProportion"/>
+        <result column="no_supervise_costs_premiums" property="noSuperviseCostsPremiums"/>
+        <result column="no_supervise_costs_proportion" property="noSuperviseCostsProportion"/>
+        <result column="jq_premium" property="jqPremium"/>
+        <result column="sy_premium" property="syPremium"/>
+        <result column="no_premium" property="noPremium"/>
+        <result column="jq_no_tax_premium" property="jqNoTaxPremium"/>
+        <result column="sy_no_tax_premium" property="syNoTaxPremium"/>
+        <result column="no_no_tax_premium" property="noNoTaxPremium"/>
+        <result column="jq_receivable_proportion" property="jqReceivableProportion"/>
+        <result column="sy_receivable_proportion" property="syReceivableProportion"/>
+        <result column="no_receivable_proportion" property="noReceivableProportion"/>
+        <result column="jq_other_costs_proportion" property="jqOtherCostsProportion"/>
+        <result column="sy_other_costs_proportion" property="syOtherCostsProportion"/>
+        <result column="no_other_costs_proportion" property="noOtherCostsProportion"/>
+        <result column="settlement_time" property="settlementTime"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="settlement_user_id" property="settlementUserId"/>
+        <result column="update_user_id" property="updateUserId"/>
+        <result column="jq_other_costs_premium" property="jqOtherCostsPremium"/>
+        <result column="sy_other_costs_premium" property="syOtherCostsPremium"/>
+        <result column="no_other_costs_premium" property="noOtherCostsPremium"/>
+        <result column="user_id" property="userId"/>
+        <result column="update_user_id" property="updateUserId"/>
+        <result column="partner_companies_id" property="partnerCompaniesId"/>
+        <result column="partner_companies_name" property="partnerCompaniesName"/>
+        <result column="receivable_amount" property="receivableAmount"/>
     </resultMap>
-
-    <select id="queryNew"  resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
-            select
+    <sql id="income_com">
                 a.id      as  "id",
                 a.orderno  as  "orderno",
                 a.policyno  as  "policyno",
@@ -66,7 +97,43 @@
                 a.documentary_fees_status  as  "documentaryFeesStatus",
                 a.is_not_car  as  "isNotCar",
                 a.is_not_documentary  as  "isNotDocumentary",
+                a.invoic_amount  as  "invoicAmount",
+                a.invoic_id  as  "invoicId",
+                a.tax_premium  as  "taxPremium",
+                a.jq_supervise_costs_premiums  as  "jqSuperviseCostsPremiums",
+                a.jq_supervise_costs_proportion  as  "jqSuperviseCostsProportion",
+                a.sy_supervise_costs_premiums  as  "sySuperviseCostsPremiums",
+                a.sy_supervise_costs_proportion  as  "sySuperviseCostsProportion",
+                a.no_supervise_costs_premiums  as  "noSuperviseCostsPremiums",
+                a.no_supervise_costs_proportion  as  "noSuperviseCostsProportion",
+                a.jq_premium  as  "jqPremium",
+                a.sy_premium  as  "syPremium",
+                a.no_premium  as  "noPremium",
+                a.jq_no_tax_premium  as  "jqNoTaxPremium",
+                a.sy_no_tax_premium  as  "syNoTaxPremium",
+                a.no_no_tax_premium  as  "noNoTaxPremium",
+                a.jq_receivable_proportion  as  "jqReceivableProportion",
+                a.sy_receivable_proportion  as  "syReceivableProportion",
+                a.no_receivable_proportion  as  "noReceivableProportion",
+                a.jq_other_costs_proportion  as  "jqOtherCostsProportion",
+                a.sy_other_costs_proportion  as  "syOtherCostsProportion",
+                a.no_other_costs_proportion  as  "noOtherCostsProportion",
+                a.settlement_time  as  "settlementTime",
+                a.update_time  as  "updateTime",
+                a.settlement_user_id  as  "settlementUserId",
+                a.update_user_id  as  "updateUserId",
+                a.jq_other_costs_premium  as  "jqOtherCostsPremium",
+                a.sy_other_costs_premium  as  "syOtherCostsPremium",
+                a.no_other_costs_premium  as  "noOtherCostsPremium",
+                a.receivable_amount  as  "receivableAmount",
+                a.invoic_time  as  "invoicTime",
+                a.user_id  as  "userId",
                 a.create_time  as  "createTime"
+    </sql>
+
+    <select id="queryNew"  resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+            select
+                <include refid="income_com"/>
                 from  ins_ply_income a
                 LEFT  JOIN  ptl_agreement  pa  on  a.agreement_id  = pa.id
             <where>
@@ -77,7 +144,7 @@
                     and pa.agreement_type =#{agreementType}
                 </if>
 
-               <if test="handlingFeesStatus !=null  and  handlingFeesStatus  !=''">
+                <if test="handlingFeesStatus !=null  and  handlingFeesStatus  !=''">
                     and a.handling_fees_status =#{handlingFeesStatus}
                 </if>
 
@@ -99,7 +166,65 @@
                 <if test="isOther !=null  and  isOther  !=''">
                     and a.is_not_documentary   =#{isOther}
                 </if>
+                <if test="licenseno != null and licenseno != ''  and licenseno.length > 0">
+                    and a.licenseno in
+                    <foreach collection="licenseno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
 
+                <if test="policyno != null and policyno != ''  and policyno.length > 0">
+                    and a.policyno in
+                    <foreach collection="policyno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+
+                <if test="syPolicyno != null and syPolicyno != ''  and syPolicyno.length > 0">
+                    and a.sy_policyno in
+                    <foreach collection="syPolicyno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+
+                <if test="noPolicyno != null and noPolicyno != ''  and noPolicyno.length > 0">
+                    and a.no_policyno in
+                    <foreach collection="syPolicyno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+                <if test="signdate !=null  and  signdate  !=''">
+                    a.signdate =#{signdate}
+                </if>
+                <if test="partnerCompaniesId !=null  and  partnerCompaniesId  !=''">
+                    a.partner_companies_id =#{partnerCompaniesId}
+                </if>
+
+                <if test="createTime !=null  and  createTime  !=''">
+                    a.create_time =#{createTime}
+                </if>
+                <if test="settlementTime !=null  and  settlementTime  !=''">
+                    a.settlement_time =#{settlementTime}
+                </if>
+
+                <if test="userId !=null  and  userId  !=''">
+                    and a.userId   =#{userId}
+                </if>
+                <if test="companyId !=null  and  companyId  !=''">
+                    and a.company_id   =#{companyId}
+                </if>
+                <if test="riskcode !=null  and  riskcode  !=''">
+                    and a.riskcode   =#{riskcode}
+                </if>
+                <if test="year !=null  and  year  !=''">
+                    AND YEAR(a.signdate) =#{year}
+                </if>
+                <if test="month !=null  and  month !=''">
+                    AND month(a.signdate) =#{month}
+                </if>
+                <if test="day !=null  and  day !=''">
+                    AND day(a.signdate) =#{day}
+                </if>
             </where>
     </select>
 
@@ -148,10 +273,10 @@
                 contract_file_id = #{contractFileId},
             </if>
             <if test="handlingFeesStatus != null">
-                handling_fees_status = #{handlingFeesStatus},
+                handling_fees_status = #{handlingFeesStatus}
             </if>
             <if test="documentaryFeesStatus != null">
-                documentary_fees_status = #{documentaryFeesStatus},
+                documentary_fees_status = #{documentaryFeesStatus}
             </if>
         </set>
         where  orderno  =#{orderno}
@@ -180,7 +305,7 @@
                 and a.is_not_car =#{isNotCar}
         </if>
         <if test="documentaryFeesStatus != null and documentaryFeesStatus != '' ">
-            AND  a.documentary_fees_status = #{documentaryFeesStatus},
+            AND  a.documentary_fees_status = #{documentaryFeesStatus}
         </if>
 
         <if test="isOther !=null  and  isOther  !=''">
@@ -192,6 +317,9 @@
         <if test="year !=null  and  year  !=''">
             and YEAR(a.signdate) =#{year}
         </if>
+        <if test="month !=null  and  month !=''">
+            and month(a.signdate) =#{month}
+        </if>
         GROUP BY
         a.company_id
         ) a
@@ -200,40 +328,455 @@
 
     <select id="findByLicenseno" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
        select
-            a.id      as  "id",
-            a.orderno  as  "orderno",
-            a.policyno  as  "policyno",
-            a.dept_id  as  "deptId",
-            a.riskcode  as  "riskcode",
-            a.pay_date  as  "payDate",
-            a.signdate  as  "signdate",
-            a.company_id  as  "companyId",
-            a.agreement_id  as  "agreementId",
-            a.licenseno  as  "licenseno",
-            a.taxamount  as  "taxamount",
-            a.no_tax_premium  as  "noTaxPremium",
-            a.commission_feerate  as  "commissionFeerate",
-            a.other_feerate  as  "otherFeerate",
-            a.commission_feevalue  as  "commissionFeevalue",
-            a.other_feevalue  as  "otherFeevalue",
-            a.all_fee_value  as  "allFeeValue",
-            a.final_fee_value  as  "finalFeeValue",
-            a.doing_fee_value  as  "doingFeeValue",
-            a.voucher_number  as  "voucherNumber",
-            a.contract_id  as  "contractId",
-            a.contract_file_id  as  "contractFileId",
-            a.handling_fees_status  as  "handlingFeesStatus",
-            a.no_policyno  as  "noPolicyno",
-            a.sy_policyno  as  "syPolicyno",
-            a.documentary_fees_status  as  "documentaryFeesStatus",
-            a.is_not_car  as  "isNotCar",
-            a.is_not_documentary  as  "isNotDocumentary",
-            a.create_time  as  "createTime"
+        <include refid="income_com"/>
         from  ins_ply_income a
         <where>
             <if test="licenseno !=null  and  licenseno !=''">
                 a.licenseno=#{licenseno}
             </if>
+            <if test="policyno !=null  and  policyno !=''">
+                a.policyno=#{policyno}
+            </if>
+            <if test="syPolicyno !=null  and  syPolicyno !=''">
+                a.sy_policyno=#{syPolicyno}
+            </if>
+            <if test="noPolicyno !=null  and  noPolicyno !=''">
+                a.no_policyno=#{noPolicyno}
+            </if>
         </where>
     </select>
+
+    <select id="totalAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+            select
+                sum(a.commission_feevalue) as "commissionFeevalue",
+                sum(a.other_feevalue)  as "otherFeevalue",
+                SUM(a.commission_feevalue + a.other_feevalue) as "totalFeevalue"
+            from  ins_ply_income a
+            LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
+            <where>
+                1=1
+                <if test="startDate !=null  and  startDate!='' and  endDate !=null and endDate !=''">
+                    and DATE_FORMAT( a.signdate, '%Y-%m-%d')  between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
+                </if>
+                <if test="agreementType !=null  and  agreementType  !=''">
+                    and pa.agreement_type =#{agreementType}
+                </if>
+
+                <if test="handlingFeesStatus !=null  and  handlingFeesStatus  !=''">
+                    and a.handling_fees_status =#{handlingFeesStatus}
+                </if>
+
+                <if test="orderno !=null  and  orderno  !=''">
+                    and a.orderno =#{orderno}
+                </if>
+
+                <if test="policyno !=null  and  policyno  !=''">
+                    and a.policyno =#{policyno}
+                </if>
+                <if test="documentaryFeesStatus !=null  and  documentaryFeesStatus  !=''">
+                    and a.documentary_fees_status =#{documentaryFeesStatus}
+                </if>
+
+                <if test="isNotCar !=null  and  isNotCar  !=''">
+                    and a.is_not_car =#{isNotCar}
+                </if>
+
+                <if test="isOther !=null  and  isOther  !=''">
+                    and a.is_not_documentary   =#{isOther}
+                </if>
+                <if test="licenseno != null and licenseno != ''  and licenseno.length > 0">
+                    and a.licenseno in
+                    <foreach collection="licenseno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+
+                <if test="policyno != null and policyno != ''  and policyno.length > 0">
+                    and a.policyno in
+                    <foreach collection="policyno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+
+                <if test="syPolicyno != null and syPolicyno != ''  and syPolicyno.length > 0">
+                    and a.sy_policyno in
+                    <foreach collection="syPolicyno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+
+                <if test="noPolicyno != null and noPolicyno != ''  and noPolicyno.length > 0">
+                    and a.no_policyno in
+                    <foreach collection="syPolicyno" item="item" open="(" separator="," close=")">
+                        #{item}
+                    </foreach>
+                </if>
+                <if test="signdate !=null  and  signdate  !=''">
+                    a.signdate =#{signdate}
+                </if>
+                <if test="partnerCompaniesId !=null  and  partnerCompaniesId  !=''">
+                    a.partner_companies_id =#{partnerCompaniesId}
+                </if>
+
+                <if test="createTime !=null  and  createTime  !=''">
+                    a.create_time =#{createTime}
+                </if>
+                <if test="settlementTime !=null  and  settlementTime  !=''">
+                    a.settlement_time =#{settlementTime}
+                </if>
+
+                <if test="userId !=null  and  userId  !=''">
+                    and a.userId   =#{userId}
+                </if>
+                <if test="companyId !=null  and  companyId  !=''">
+                    and a.company_id   =#{companyId}
+                </if>
+                <if test="riskcode !=null  and  riskcode  !=''">
+                    and a.riskcode   =#{riskcode}
+                </if>
+                <if test="year !=null  and  year  !=''">
+                    AND YEAR(a.signdate) =#{year}
+                </if>
+                <if test="month !=null  and  month !=''">
+                    AND month(a.signdate) =#{month}
+                </if>
+                <if test="day !=null  and  day !=''">
+                    AND day(a.signdate) =#{day}
+                </if>
+            </where>
+    </select>
+
+
+    <select id="totalPinAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+                select
+                MAX( a.company_name ) AS "companyName",
+                sum( a.commission_feevalue ) AS "commissionFeevalue",
+                sum( a.other_feevalue ) AS "otherFeevalue",
+                SUM( a.commission_feevalue + a.other_feevalue ) AS "totalFeevalue",
+                GROUP_CONCAT(a.id) as  "ids",
+                MAX( a.partner_companies_name) as "partnerCompaniesName",
+                a.agreement_id AS "agreementId"
+                from  ins_ply_income a
+                LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
+                <where>
+                    1=1
+                <if test="agreementType !=null  and agreementType!='' ">
+                    AND pa.agreement_type =#{agreementType}
+                </if>
+                <if test="documentaryFeesStatus != null  and documentaryFeesStatus != '' ">
+                    AND   a.documentary_fees_status = #{documentaryFeesStatus}
+                </if>
+                <if test="handlingFeesStatus != null  and  handlingFeesStatus != ''">
+                    AND   handling_fees_status = #{handlingFeesStatus}
+                </if>
+                <if test="year !=null  and  year  !=''">
+                    AND YEAR(a.signdate) =#{year}
+                </if>
+                <if test="month !=null  and  month !=''">
+                    AND month(a.signdate) =#{month}
+                </if>
+                <if test="day !=null  and  day !=''">
+                    AND day(a.signdate) =#{day}
+                </if>
+                </where>
+            GROUP BY  a.agreement_id
+    </select>
+
+    <select id="queryInvoicing" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+        select
+            sum(a.commission_feevalue) as "commissionFeevalue",
+            sum(a.invoic_amount) as "invoicAmount"
+            from  ins_ply_income a
+            LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
+        <where>
+            1=1
+            <if test="startDate !=null  and  startDate!='' and  endDate !=null and endDate !=''">
+                and DATE_FORMAT( a.signdate, '%Y-%m-%d')  between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d')
+            </if>
+            <if test="agreementType !=null  and  agreementType  !=''">
+                and pa.agreement_type =#{agreementType}
+            </if>
+
+            <if test="handlingFeesStatus !=null  and  handlingFeesStatus  !=''">
+                and a.handling_fees_status =#{handlingFeesStatus}
+            </if>
+
+            <if test="orderno !=null  and  orderno  !=''">
+                and a.orderno =#{orderno}
+            </if>
+
+            <if test="policyno !=null  and  policyno  !=''">
+                and a.policyno =#{policyno}
+            </if>
+            <if test="documentaryFeesStatus !=null  and  documentaryFeesStatus  !=''">
+                and a.documentary_fees_status =#{documentaryFeesStatus}
+            </if>
+
+            <if test="isNotCar !=null  and  isNotCar  !=''">
+                and a.is_not_car =#{isNotCar}
+            </if>
+
+            <if test="isOther !=null  and  isOther  !=''">
+                and a.is_not_documentary   =#{isOther}
+            </if>
+            <if test="licenseno != null and licenseno != ''  and licenseno.length > 0">
+                and a.licenseno in
+                <foreach collection="licenseno" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="policyno != null and policyno != ''  and policyno.length > 0">
+                and a.policyno in
+                <foreach collection="policyno" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="syPolicyno != null and syPolicyno != ''  and syPolicyno.length > 0">
+                and a.sy_policyno in
+                <foreach collection="syPolicyno" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+
+            <if test="noPolicyno != null and noPolicyno != ''  and noPolicyno.length > 0">
+                and a.no_policyno in
+                <foreach collection="syPolicyno" item="item" open="(" separator="," close=")">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="signdate !=null  and  signdate  !=''">
+                a.signdate =#{signdate}
+            </if>
+            <if test="partnerCompaniesId !=null  and  partnerCompaniesId  !=''">
+                a.partner_companies_id =#{partnerCompaniesId}
+            </if>
+
+            <if test="createTime !=null  and  createTime  !=''">
+                a.create_time =#{createTime}
+            </if>
+            <if test="settlementTime !=null  and  settlementTime  !=''">
+                a.settlement_time =#{settlementTime}
+            </if>
+
+            <if test="userId !=null  and  userId  !=''">
+                and a.userId   =#{userId}
+            </if>
+            <if test="companyId !=null  and  companyId  !=''">
+                and a.company_id   =#{companyId}
+            </if>
+            <if test="riskcode !=null  and  riskcode  !=''">
+                and a.riskcode   =#{riskcode}
+            </if>
+            <if test="year !=null  and  year  !=''">
+                AND YEAR(a.signdate) =#{year}
+            </if>
+            <if test="month !=null  and  month !=''">
+                AND month(a.signdate) =#{month}
+            </if>
+            <if test="day !=null  and  day !=''">
+                AND day(a.signdate) =#{day}
+            </if>
+        </where>
+    </select>
+
+
+    <select id="totalBxAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+        select
+        MAX( a.company_name ) AS "companyName",
+        sum( a.commission_feevalue ) AS "commissionFeevalue",
+        MAX( a.partner_companies_name) as "partnerCompaniesName",
+        SUM(b.readyCommissionFeevalue)  as "readyCommissionFeevalue",
+        SUM(c.invoicCommissionFeevalue) as "invoicCommissionFeevalue",
+        SUM(d.noInvoicCommissionFeevalue) as "noInvoicCommissionFeevalue",
+        MAX(b.ids) as "ids",
+        a.agreement_id AS "agreementId"
+        from  ins_ply_income a
+        LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
+        LEFT JOIN   (
+            select
+            MAX( a.company_name ) AS "companyName",
+            sum( a.commission_feevalue ) AS "readyCommissionFeevalue",
+            MAX( a.partner_companies_name) as "partnerCompaniesName",
+            GROUP_CONCAT(a.id) as  "ids",
+            a.agreement_id AS "agreementId"
+        from  ins_ply_income a
+        LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
+        <where>
+            1=1
+            AND   a.handling_fees_status = '1'
+            <if test="agreementType !=null  and agreementType!='' ">
+                AND pa.agreement_type =#{agreementType}
+            </if>
+            <if test="documentaryFeesStatus != null  and documentaryFeesStatus != '' ">
+                AND   a.documentary_fees_status = #{documentaryFeesStatus}
+            </if>
+            <if test="isOther !=null  and  isOther  !=''">
+                and a.is_not_documentary   =#{isOther}
+            </if>
+
+            <if test="isNotCar !=null  and  isNotCar  !=''">
+                and a.is_not_car =#{isNotCar}
+            </if>
+            <if test="year !=null  and  year  !=''">
+                AND YEAR(a.signdate) =#{year}
+            </if>
+            <if test="month !=null  and  month !=''">
+                AND month(a.signdate) =#{month}
+            </if>
+            <if test="day !=null  and  day !=''">
+                AND day(a.signdate) =#{day}
+            </if>
+        </where>
+        GROUP BY  a.agreement_id
+        )  b  on  a.agreement_id =b.agreementId
+        LEFT JOIN   (
+            select
+            MAX( a.company_name ) AS "companyName",
+            sum( a.commission_feevalue ) AS "invoicCommissionFeevalue",
+            MAX( a.partner_companies_name) as "partnerCompaniesName",
+            GROUP_CONCAT(a.id) as  "ids",
+            a.agreement_id AS "agreementId"
+        from  ins_ply_income a
+        LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
+        <where>
+            1=1
+            AND   a.handling_fees_status = '2'
+            <if test="agreementType !=null  and agreementType!='' ">
+                AND pa.agreement_type =#{agreementType}
+            </if>
+            <if test="isOther !=null  and  isOther  !=''">
+                and a.is_not_documentary   =#{isOther}
+            </if>
+
+            <if test="documentaryFeesStatus != null  and documentaryFeesStatus != '' ">
+                AND   a.documentary_fees_status = #{documentaryFeesStatus}
+            </if>
+            <if test="isNotCar !=null  and  isNotCar  !=''">
+                and a.is_not_car =#{isNotCar}
+            </if>
+
+            <if test="year !=null  and  year  !=''">
+                AND YEAR(a.signdate) =#{year}
+            </if>
+            <if test="month !=null  and  month !=''">
+                AND month(a.signdate) =#{month}
+            </if>
+            <if test="day !=null  and  day !=''">
+                AND day(a.signdate) =#{day}
+            </if>
+        </where>
+        GROUP BY  a.agreement_id
+        )  c  on  a.agreement_id =c.agreementId
+        LEFT JOIN   (
+        select
+        MAX( a.company_name ) AS "companyName",
+        sum( a.commission_feevalue ) AS "noInvoicCommissionFeevalue",
+        MAX( a.partner_companies_name) as "partnerCompaniesName",
+        GROUP_CONCAT(a.id) as  "ids",
+        a.agreement_id AS "agreementId"
+        from  ins_ply_income a
+        LEFT JOIN   ptl_agreement  pa  on pa.id= a.agreement_id
+        <where>
+            1=1
+
+            AND   a.handling_fees_status = '0'
+            <if test="agreementType !=null  and agreementType!='' ">
+                AND pa.agreement_type =#{agreementType}
+            </if>
+            <if test="isOther !=null  and  isOther  !=''">
+                and a.is_not_documentary   =#{isOther}
+            </if>
+
+            <if test="documentaryFeesStatus != null  and documentaryFeesStatus != '' ">
+                AND   a.documentary_fees_status = #{documentaryFeesStatus}
+            </if>
+            <if test="isNotCar !=null  and  isNotCar  !=''">
+                and a.is_not_car =#{isNotCar}
+            </if>
+
+            <if test="year !=null  and  year  !=''">
+                AND YEAR(a.signdate) =#{year}
+            </if>
+            <if test="month !=null  and  month !=''">
+                AND month(a.signdate) =#{month}
+            </if>
+            <if test="day !=null  and  day !=''">
+                AND day(a.signdate) =#{day}
+            </if>
+        </where>
+        GROUP BY  a.agreement_id
+        )  d  on  a.agreement_id =d.agreementId
+        <where>
+            1=1
+
+            <if test="agreementType !=null  and agreementType!='' ">
+                AND pa.agreement_type =#{agreementType}
+            </if>
+            <if test="year !=null  and  year  !=''">
+                AND YEAR(a.signdate) =#{year}
+            </if>
+            <if test="isOther !=null  and  isOther  !=''">
+                and a.is_not_documentary   =#{isOther}
+            </if>
+            <if test="isNotCar !=null  and  isNotCar  !=''">
+                and a.is_not_car =#{isNotCar}
+            </if>
+            <if test="month !=null  and  month !=''">
+                AND month(a.signdate) =#{month}
+            </if>
+            <if test="day !=null  and  day !=''">
+                AND day(a.signdate) =#{day}
+            </if>
+        </where>
+        GROUP BY  a.agreement_id
+    </select>
+    <select id="allOtherAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
+        SELECT
+            a.company_id AS "companyId",
+            MAX( a.company_name ) AS "companyName",
+            MAX( a.partner_companies_name) as "partnerCompaniesName",
+            IF(SUM( c.unsettledAmount ) IS NULL , sum( a.other_feevalue ),  SUM( c.unsettledAmount )  ) AS "noInvoicCommissionFeevalue",
+            GROUP_CONCAT(a.id) as  "incomeIds",
+            MAX(d.settleMentAmount) as "invoicCommissionFeevalue",
+            MAX(e.settleMentAmount) as "settleMentAmount",
+            IF(MAX( f.unSettledAmount ) is null ,MAX( d.settleMentAmount ) ,MAX( f.unSettledAmount )) AS "unSettledAmount",
+            sum( a.other_feevalue ) AS "otherFeevalue"
+        FROM
+            ins_ply_income a
+                LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
+                LEFT JOIN ( SELECT a.company_id AS "companyId", sum( a.unsettled_amount ) AS "unsettledAmount" FROM settlement_documentary_fees a WHERE a.settlement_status = '1' GROUP BY company_id ) c ON c.companyId = a.company_id
+                LEFT JOIN ( SELECT a.company_id AS "companyId", sum( settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a WHERE a.settlement_status = '1' GROUP BY company_id ) d ON d.companyId = a.company_id
+                LEFT JOIN ( SELECT a.company_id AS "companyId", sum( settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a WHERE a.settlement_status = '2' GROUP BY company_id ) e ON e.companyId = a.company_id
+                LEFT JOIN ( SELECT a.company_id AS "companyId", sum( unsettled_amount ) AS "unSettledAmount" FROM settlement_documentary_fees a WHERE a.settlement_status = '2' GROUP BY company_id ) f ON f.companyId = a.company_id
+       <where>
+           1=1
+           <if test="agreementType !=null  and agreementType!='' ">
+               AND pa.agreement_type =#{agreementType}
+           </if>
+           <if test="year !=null  and  year  !=''">
+               AND YEAR(a.signdate) =#{year}
+           </if>
+           <if test="isOther !=null  and  isOther  !=''">
+               and a.is_not_documentary   =#{isOther}
+           </if>
+           <if test="isNotCar !=null  and  isNotCar  !=''">
+               and a.is_not_car =#{isNotCar}
+           </if>
+           <if test="month !=null  and  month !=''">
+               AND month(a.signdate) =#{month}
+           </if>
+           <if test="day !=null  and  day !=''">
+               AND day(a.signdate) =#{day}
+           </if>
+           <if test="documentaryFeesStatus != null  and documentaryFeesStatus != '' ">
+               AND   a.documentary_fees_status = #{documentaryFeesStatus}
+           </if>
+       </where>
+        GROUP BY
+            a.company_id
+    </select>
+
+
 </mapper>

+ 5 - 0
src/main/resources/mapper/modules/fnc/SettlementDocumentaryFeesMapper.xml

@@ -14,6 +14,10 @@
         <result column="settlement_amount" property="settlementAmount"/>
         <result column="unsettled_amount" property="unsettledAmount"/>
         <result column="company_id" property="companyId"/>
+        <result column="year" property="year"/>
+        <result column="month" property="month"/>
+        <result column="day" property="day"/>
+        <result column="agree_ment_id" property="agreeMentId"/>
     </resultMap>
 
 
@@ -28,6 +32,7 @@
             a.start_time as "startTime",
             a.end_time as "endTime",
             a.settlement_amount as "settlementAmount",
+            a.agree_ment_id as "agreeMentId",
             a.unsettled_amount as "unsettledAmount"
             from  settlement_documentary_fees  a
     </select>

+ 3 - 0
src/main/resources/mapper/modules/fnc/SettlementDocumentaryLogMapper.xml

@@ -11,6 +11,9 @@
         <result column="create_time" property="createTime"/>
         <result column="handing_amount" property="handingAmount"/>
         <result column="crud_status" property="crudStatus"/>
+        <result column="crud_status" property="crudStatus"/>
+        <result column="ids" property="ids"/>
+        <result column="company_id" property="companyId"/>
     </resultMap>
 
 

+ 11 - 0
src/main/resources/mapper/modules/protocol/PtlAgreementMapper.xml

@@ -103,5 +103,16 @@
         )
         order by pa.serial_number
     </select>
+    <select id="getByAgreementIdNew" resultType="com.ydtech.modules.protocol.entity.po.PtlAgreement">
+        select
+            partner_companies_id  as  "partnercompaniesId"
+            association_companies_id  as  "associationCompaniesId"
+        from  ptl_agreement_dept
+        <where>
+            <if test="agreementId!=null  and  agreementId !=''">
+                id=#{agreementId}
+            </if>
+        </where>
+    </select>
 
 </mapper>