Procházet zdrojové kódy

1. 结算明细调整

wuhp před 2 roky
rodič
revize
b3269f8cf2

+ 2 - 1
src/main/java/com/ydtech/modules/fnc/controller/InsPlyIncomeController.java

@@ -3,6 +3,7 @@ package com.ydtech.modules.fnc.controller;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.base.controller.BaseController;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
+import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity;
 import com.ydtech.modules.fnc.service.ImportAsyncService;
 import com.ydtech.modules.fnc.service.InsPlyIncomeService;
 import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
@@ -385,7 +386,7 @@ public class InsPlyIncomeController extends BaseController {
 
     @PostMapping("/invicdetail")
     @ApiOperation(value = "开票未结算详情查询")
-    public HttpResult<List<HashMap<String, Object>>> invicdetail(@Valid @RequestBody InsPlyIncomeVo insPlyIncomeVo) {
+    public HttpResult<List<SettlementDocumentaryFeesEntity>> invicdetail(@Valid @RequestBody InsPlyIncomeVo insPlyIncomeVo) {
         return insPlyIncomeService.invicdetail(insPlyIncomeVo);
     }
 

+ 1 - 0
src/main/java/com/ydtech/modules/fnc/dao/SettlementDocumentaryFeesMapper.java

@@ -32,4 +32,5 @@ public interface SettlementDocumentaryFeesMapper  extends BaseMapper<SettlementD
 
     List<SettlementDocumentaryFeesEntity> queryNew(HashMap<String, Object> params);
 
+    List<SettlementDocumentaryFeesEntity> querySettleNew(HashMap<String, Object> params);
 }

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

@@ -53,6 +53,8 @@ public class SettlementDocumentaryFeesEntity implements Serializable {
     private LocalDateTime createTime;
 
 
+
+
     @ApiModelProperty("结算日期")
     @TableField("settlement_time")
     private LocalDate settlementTime;
@@ -138,6 +140,19 @@ public class SettlementDocumentaryFeesEntity implements Serializable {
     @TableField("task_id")
     private String taskId;
 
+    @ApiModelProperty("已开票已结算")
+    @TableField("invoiced_settled_amount")
+    private BigDecimal invoicedSettledAmount;
+
+
+    @ApiModelProperty("已开票未结算")
+    @TableField("Invoiced_not_settled_amount")
+    private BigDecimal InvoicedNotSettledAmount;
+
+    @ApiModelProperty("结清状态")
+    @TableField("completion_status")
+    private String completionStatus;
+
 
     @ApiModelProperty("图片路径")
     @TableField(exist = false)
@@ -148,4 +163,14 @@ public class SettlementDocumentaryFeesEntity implements Serializable {
     private String taxesFees;
 
 
+    @ApiModelProperty("开票金额")
+    @TableField(exist = false)
+    private BigDecimal invoicCommissionFeevalue;
+
+
+    @ApiModelProperty("开票时间")
+    @TableField(exist = false)
+    private String invoicTime;
+
+
 }

+ 2 - 1
src/main/java/com/ydtech/modules/fnc/service/InsPlyIncomeService.java

@@ -4,6 +4,7 @@ import com.ydtech.core.page.HttpResult;
 import com.ydtech.modules.fnc.entity.InsAreaCompany;
 import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity;
 import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
 import com.ydtech.modules.inv.model.dto.InsBxPlyIncomeExcelDto;
 import com.ydtech.modules.order.entity.BasePageResult;
@@ -110,7 +111,7 @@ public interface InsPlyIncomeService extends IService<InsPlyIncome> {
      * @param insPlyIncomeVo  传参字段
      * @return  开票未结算金额  开票号   ids  开票时间
      */
-    HttpResult<List<HashMap<String,Object>>> invicdetail(InsPlyIncomeVo insPlyIncomeVo);
+    HttpResult<List<SettlementDocumentaryFeesEntity>> invicdetail(InsPlyIncomeVo insPlyIncomeVo);
 
     HttpResult bxNoOtherDetailsExcel(InsPlyIncomeVo insPlyIncomeVo, HttpServletRequest request, HttpServletResponse response);
 

+ 2 - 0
src/main/java/com/ydtech/modules/fnc/service/SettlementDocumentaryFeesService.java

@@ -32,4 +32,6 @@ public interface SettlementDocumentaryFeesService extends IService<SettlementDoc
     HttpResult<Object> voidInvoicing(SettlementDocumentaryFeesVo settlementDocumentaryFeesVo);
 
     List<SettlementDocumentaryFeesEntity> queryNew(HashMap<String, Object> params);
+    List<SettlementDocumentaryFeesEntity> querySettleNew(HashMap<String, Object> params);
+
 }

+ 64 - 22
src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java

@@ -2,6 +2,8 @@ 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.json.JSONArray;
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fasterxml.jackson.databind.JsonNode;
@@ -24,8 +26,10 @@ import com.ydtech.modules.inv.model.dto.*;
 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.entity.crawler.response.CrawlerVerifyPaymentResponse;
 import com.ydtech.modules.order.service.InsAreaCompanyService;
 import com.ydtech.modules.order.service.InsOrdersService;
+import com.ydtech.modules.protocol.entity.constants.PtlApiType;
 import com.ydtech.modules.protocol.entity.po.PtlAgreement;
 import com.ydtech.modules.protocol.entity.vo.PtlAgreementQueryVo;
 import com.ydtech.modules.protocol.service.PtlAgreementService;
@@ -311,15 +315,12 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         if (StringUtils.isEmpty(crossInsurance)) {
             return null;
         }
-
         try {
             ObjectMapper objJson = new ObjectMapper();
             JsonNode jsonArryNode = objJson.readTree(crossInsurance);
-
             if (jsonArryNode.isArray() && jsonArryNode.size() > 0) {
                 JsonNode firstNode = jsonArryNode.get(0);
                 JsonNode policyNumberNode = firstNode.get("policyNumber");
-
                 if (policyNumberNode != null) {
                     return policyNumberNode.asText();
                 } else {
@@ -1045,7 +1046,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
      * @return
      */
     @Override
-    public HttpResult<List<HashMap<String,Object>>> invicdetail(InsPlyIncomeVo insPlyIncomeVo) {
+    public HttpResult<List<SettlementDocumentaryFeesEntity>> invicdetail(InsPlyIncomeVo insPlyIncomeVo) {
         HashMap<String, Object> params = new HashMap<>();
         params =this.saveParams(insPlyIncomeVo,params);
         if (StringUtils.isEmpty(insPlyIncomeVo.getIsSettlement())){
@@ -1054,7 +1055,11 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         if(StringUtils.isNotEmpty(insPlyIncomeVo.getSettlementStatus())){
             params.put("settlementStatus",insPlyIncomeVo.getSettlementStatus());
         }
-        List<HashMap<String, Object>> resultList = settlementDocumentaryFeesService.getOtherSettldetail(params);
+
+        if(StringUtils.isNotEmpty(insPlyIncomeVo.getCompletionStatus())){
+            params.put("completionStatus",insPlyIncomeVo.getCompletionStatus());
+        }
+        List<SettlementDocumentaryFeesEntity> resultList = settlementDocumentaryFeesService.querySettleNew(params);
         if (resultList.size() > 0) {
             return HttpResult.ok(resultList);
         }
@@ -1182,38 +1187,40 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             insPlyIncome.setNoReceivableProportion(this.calculateTotal(noSuperviseCostsProportion,noOtherCostsProportion,null)); //非车应收
 
         }else {
-            BigDecimal jqNoTaxPremium = insPlyIncomeVo.getJqNoTaxPremium();// 交强手续费  按照思路  交强不含税保费* 交强手续费比例  =交强手续费
-            BigDecimal syNoTaxPremium = insPlyIncomeVo.getSyNoTaxPremium();// 商业手续费  按照思路  商业不含税保费* 商业手续费比例  =商业手续费
-            BigDecimal noNoTaxPremium = insPlyIncomeVo.getNoNoTaxPremium();// 非车手续费  按照思路  非车不含税保费* 非车手续费比例  =非车手续费
+            BigDecimal divisor = new BigDecimal("1.06"); // 最好是使用字符串来避免精度损失
+            BigDecimal jqNoTaxPremium = insPlyIncomeVo.getJqPremium();// 交强手续费  按照思路  交强不含税保费* 交强手续费比例  =交强手续费
+            BigDecimal syNoTaxPremium = insPlyIncomeVo.getSyPremium();// 商业手续费  按照思路  商业不含税保费* 商业手续费比例  =商业手续费
+            BigDecimal noNoTaxPremium = insPlyIncomeVo.getNoPremium();// 非车手续费  按照思路  非车不含税保费* 非车手续费比例  =非车手续费
             if( jqNoTaxPremium != null  && insPlyIncomeVo.getJqSuperviseCostsProportion()  !=null  &&   insPlyIncomeVo.getJqSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0){
-                BigDecimal  jqhandingFee = jqNoTaxPremium.multiply(insPlyIncomeVo.getJqSuperviseCostsProportion().divide(new BigDecimal(100)));
-                insPlyIncome.setJqSuperviseCostsPremiums(jqhandingFee);
+
+                insPlyIncome.setJqSuperviseCostsPremiums(getBigDecimal(syNoTaxPremium,insPlyIncomeVo.getJqSuperviseCostsProportion()));
+                insPlyIncome.setJqSuperviseCostsProportion(insPlyIncomeVo.getJqSuperviseCostsProportion());
+
             }
 
             if( syNoTaxPremium!= null  &&  insPlyIncomeVo.getSySuperviseCostsProportion()  !=null  && insPlyIncomeVo.getSySuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0){
-                BigDecimal  syhandingFee = syNoTaxPremium.multiply(insPlyIncomeVo.getSySuperviseCostsProportion().divide(new BigDecimal(100)));
-                insPlyIncome.setSySuperviseCostsPremiums(syhandingFee);
+                insPlyIncome.setSySuperviseCostsPremiums(getBigDecimal(syNoTaxPremium,insPlyIncomeVo.getSySuperviseCostsProportion()));
+                insPlyIncome.setSySuperviseCostsProportion(insPlyIncomeVo.getSySuperviseCostsProportion());
             }
 
             if(noNoTaxPremium!= null  &&  insPlyIncomeVo.getNoSuperviseCostsProportion()  !=null  && insPlyIncomeVo.getNoSuperviseCostsProportion().compareTo(BigDecimal.ZERO) != 0){
-                BigDecimal  nohandingFee = noNoTaxPremium.multiply(insPlyIncomeVo.getNoSuperviseCostsProportion().divide(new BigDecimal(100)));
-                insPlyIncome.setNoSuperviseCostsPremiums(nohandingFee);
+                insPlyIncome.setNoSuperviseCostsProportion(insPlyIncome.getNoSuperviseCostsProportion());
+                insPlyIncome.setNoSuperviseCostsPremiums(getBigDecimal(noNoTaxPremium,insPlyIncomeVo.getNoSuperviseCostsProportion()));
             }
 
             if( jqNoTaxPremium!= null  &&  insPlyIncomeVo.getJqOtherCostsProportion() !=null &&   insPlyIncomeVo.getJqOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0){
-                BigDecimal jqother = jqNoTaxPremium.multiply(insPlyIncomeVo.getJqOtherCostsProportion().divide(new BigDecimal(100)));//交强跟单费  按照思路  交强不含税保费* 交强跟单比例 = 交强跟单金额
-                insPlyIncome.setJqOtherCostsPremium(jqother);
+                insPlyIncome.setJqOtherCostsPremium(getBigDecimal(jqNoTaxPremium,insPlyIncomeVo.getJqOtherCostsProportion()));
+                insPlyIncome.setJqOtherCostsProportion(insPlyIncomeVo.getJqOtherCostsProportion());
             }
 
             if( syNoTaxPremium!= null  &&  insPlyIncomeVo.getSyOtherCostsProportion() !=null   &&  insPlyIncomeVo.getSyOtherCostsProportion().compareTo(BigDecimal.ZERO) != 0){
-                BigDecimal syother = syNoTaxPremium.multiply(insPlyIncomeVo.getSyOtherCostsProportion().divide(new BigDecimal(100)));//交强跟单费  按照思路  交强不含税保费* 交强跟单比例 = 交强跟单金额
-                insPlyIncome.setSyOtherCostsPremium(syother);
+                insPlyIncome.setSyOtherCostsProportion(insPlyIncome.getSyOtherCostsProportion());
+                insPlyIncome.setSyOtherCostsPremium(getBigDecimal(syNoTaxPremium,insPlyIncomeVo.getSyOtherCostsProportion()));
             }
 
             if( noNoTaxPremium!= null  && insPlyIncomeVo.getOtherFeerate() !=null  &&  insPlyIncomeVo.getOtherFeerate().compareTo(BigDecimal.ZERO) != 0){
-                BigDecimal syother = noNoTaxPremium.multiply(insPlyIncomeVo.getOtherFeerate().divide(new BigDecimal(100)));//非车跟单费  按照思路  非车不含税保费* 非车跟单比例 = 非车跟单金额
-                insPlyIncome.setNoOtherCostsProportion(insPlyIncome.getOtherFeerate());
-                insPlyIncome.setNoOtherCostsPremium(syother);
+                 insPlyIncome.setNoOtherCostsProportion(insPlyIncome.getOtherFeerate());
+                 insPlyIncome.setNoOtherCostsPremium(getBigDecimal(noNoTaxPremium,insPlyIncomeVo.getOtherFeerate()));
             }
 
             if("0".equals(insPlyIncomeVo.getIsNotDocumentary()) && "0".equals(insPlyIncomeVo.getIsNotCar())){  //保险  手续费 =不含税保费* 手续费比例
@@ -1238,6 +1245,18 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
 
     }
 
+    /**
+     *   计算 金额
+     * @param jqNoTaxPremium
+     * @param proportion
+     * @return
+     */
+    private static BigDecimal getBigDecimal(BigDecimal jqNoTaxPremium,BigDecimal  proportion ) {
+        BigDecimal divisor = new BigDecimal("1.06"); // 最好是使用字符串来避免精度损失
+        BigDecimal  amount = jqNoTaxPremium.divide(divisor, 5, RoundingMode.HALF_UP).multiply(proportion.divide(new BigDecimal(100)));//交强保费 / 1.06
+        return amount;
+    }
+
     /**
      *
      * @param value1   保费
@@ -1456,6 +1475,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         settlementDocumentaryFeesVo.setIsNotCar(insPlyIncomeVo.getIsNotCar()); // 是否是非车
         settlementDocumentaryFeesVo.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod());  //开票方式
         settlementDocumentaryFeesVo.setTaxPoints(insPlyIncomeVo.getTaxPoints());  //税点
+        settlementDocumentaryFeesVo.setSettlementImageId(insPlyIncomeVo.getSettlementImageId());
         if ("0".equals(insPlyIncomeVo.getInvoicingMethod())) {
             settlementDocumentaryFeesVo.setExpendAmount(insPlyIncomeVo.getSettlementAmount().multiply(BigDecimal.ONE.subtract(insPlyIncomeVo.getTaxPoints().divide(new BigDecimal(100)))));
         } else {
@@ -1680,7 +1700,22 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         settlementDocumentaryFeesVo.setSettlementImageId(insPlyIncomeVo.getSettlementImageId());
         settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
         settlementDocumentaryFeesVo.setAgreementType("2");  //1平台 2  保险
+
+        BigDecimal add = byIdSettlementDocumentaryFeesEntity.getInvoicedSettledAmount().add(insPlyIncomeVo.getSettlementAmount());
+        byIdSettlementDocumentaryFeesEntity.setInvoicedSettledAmount(add);
+
+        BigDecimal subtract = byIdSettlementDocumentaryFeesEntity.getTotalAmount().subtract(add);
+        byIdSettlementDocumentaryFeesEntity.setInvoicedNotSettledAmount(subtract);
+
+        if(subtract.compareTo(BigDecimal.ZERO) == 0){
+            byIdSettlementDocumentaryFeesEntity.setCompletionStatus("2");
+        }else if(subtract.compareTo(BigDecimal.ZERO) != 0){
+            byIdSettlementDocumentaryFeesEntity.setCompletionStatus("1");
+        }
+        settlementDocumentaryFeesService.updateById(byIdSettlementDocumentaryFeesEntity);
+
         settlementDocumentaryFeesService.inertSettle(settlementDocumentaryFeesVo);
+
         return HttpResult.ok();
     }
 
@@ -1787,8 +1822,8 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
             YearMonth yearMonth = YearMonth.parse(insPlyIncomeVo1.getMonthYear());
             LocalDate signingTime = yearMonth.atDay(1);
             settlementDocumentaryFeesVo.setSigningTime(signingTime);
-
         }
+
         if(insPlyIncomeVo.getOtherFeevalue().compareTo(BigDecimal.ZERO) ==0 ){
             throw  new SystemException("总金额为0不允许开票");
         }
@@ -1828,6 +1863,9 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         }
         settlementDocumentaryFeesVo.setAgreementType("2");
         settlementDocumentaryFeesVo.setHandlingFeesStatus(insPlyIncomeVo.getHandlingFeesStatus());
+        settlementDocumentaryFeesVo.setCompletionStatus("0");
+        settlementDocumentaryFeesVo.setInvoicedSettledAmount(BigDecimal.ZERO);
+        settlementDocumentaryFeesVo.setInvoicedNotSettledAmount(insPlyIncomeVo.getSettlementAmount());
         settlementDocumentaryFeesVo.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod()); //开票方式
         settlementDocumentaryFeesVo.setTaxPoints(insPlyIncomeVo.getTaxPoints()); //税点
         settlementDocumentaryFeesVo.setIds(insPlyIncomeVo.getIds());
@@ -2161,6 +2199,10 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
                     settlementDocumentaryFeesVo.setDay(insPlyIncomeVo.getDay());
                 }
 
+
+                settlementDocumentaryFeesVo.setCompletionStatus("0");
+                settlementDocumentaryFeesVo.setInvoicedSettledAmount(BigDecimal.ZERO);
+                settlementDocumentaryFeesVo.setInvoicedNotSettledAmount(insPlyIncomeVo.getSettlementAmount());
                 settlementDocumentaryFeesVo.setCompanyId(insPlyIncomeVo.getCompanyId());// 保险公司id
                 settlementDocumentaryFeesVo.setPartnerCompaniesId(insPlyIncomeVo.getPartnerCompaniesId());  //合作公司id
                 settlementDocumentaryFeesVo.setTotalAmount(insPlyIncomeVo.getOtherFeevalue());  //其他费用金额

+ 5 - 0
src/main/java/com/ydtech/modules/fnc/service/impl/SettlementDocumentaryFeesServiceImpl.java

@@ -223,6 +223,11 @@ public class SettlementDocumentaryFeesServiceImpl extends ServiceImpl<Settlement
 
     }
 
+    @Override
+    public List<SettlementDocumentaryFeesEntity> querySettleNew(HashMap<String, Object> params) {
+        return baseMapper.querySettleNew(params);
+    }
+
     private int compareAmount(BigDecimal settlementAmount, BigDecimal settlementAmount1) {
 
         return settlementAmount.compareTo(settlementAmount1);

+ 4 - 1
src/main/java/com/ydtech/modules/fnc/vo/InsPlyIncomeVo.java

@@ -55,7 +55,7 @@ public class InsPlyIncomeVo implements Serializable {
 //    private LocalDate signdate;
 
     @ApiModelProperty(value = "创建日期")
-    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss ", timezone = "GMT+8")
     private LocalDate createTime;
 
     @ApiModelProperty(value = "结算日期")
@@ -346,6 +346,9 @@ public class InsPlyIncomeVo implements Serializable {
     @ApiModelProperty(value = "开票总额")
     private BigDecimal allInvoicCommissionFeevalue;
 
+    @ApiModelProperty(value = "结清状态")
+    private String completionStatus;
+
 
 
 

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

@@ -119,4 +119,14 @@ public class SettlementDocumentaryFeesVo implements Serializable {
 
     @ApiModelProperty("已开票已结算")
     private BigDecimal readyCommissionFeevalue;
+
+    @ApiModelProperty("已开票已结算")
+    private BigDecimal invoicedSettledAmount;
+
+
+    @ApiModelProperty("已开票未结算")
+    private BigDecimal InvoicedNotSettledAmount;
+
+    @ApiModelProperty("结清状态")
+    private String completionStatus;
 }

+ 44 - 35
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -896,41 +896,50 @@
 
 
     <select id="totalPinAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
-                select
-                MAX(a.partner_companies_id) as "partnerCompaniesId",
-                MAX( ec.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",
-                MAX(pa.docking_person)  as "dockingPerson",
-                a.agreement_id AS "agreementId"
-                from  ins_ply_income a
-                LEFT JOIN  esm_ins_company  ec  on ec.id= a.company_id
-                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   a.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
+        MAX(a.partner_companies_id) as "partnerCompaniesId",
+        MAX( ec.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",
+        MAX(pa.docking_person) as "dockingPerson",
+        a.agreement_id AS "agreementId"
+        from ins_ply_income a
+        LEFT JOIN esm_ins_company ec on ec.id= a.company_id
+        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 a.handling_fees_status = #{handlingFeesStatus}
+            </if>
+            <if test="year !=null  and  year  !=''">
+                AND YEAR(a.signdate) =#{year}
+            </if>
+            <if test="companyName !=null  and  companyName  !=''">
+                and a.company_id =#{companyName}
+            </if>
+            <if test="partnerCompaniesName !=null  and  partnerCompaniesName  !=''">
+                AND a.partner_companies_name =#{partnerCompaniesName}
+            </if>
+            <if test="dockingPerson !=null  and  dockingPerson  !=''">
+                and pa.docking_person =#{dockingPerson}
+            </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">

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

@@ -30,6 +30,9 @@
         <result column="settlement_status" property="settlementStatus"/>
         <result column="settlement_image_id" property="settlementImageId"/>
         <result column="task_id" property="taskId"/>
+        <result column="invoiced_settled_amount" property="invoicedSettledAmount"/>
+        <result column="Invoiced_not_settled_amount" property="InvoicedNotSettledAmount"/>
+        <result column="completion_status" property="completionStatus"/>
     </resultMap>
 
 
@@ -55,6 +58,9 @@
             a.settlement_time as "settlementTime",
             a.settlement_image_id as "settlementImageId",
             a.task_id as "taskId",
+            a.invoiced_settled_amount as "invoicedSettledAmount",
+            a.Invoiced_not_settled_amount as "InvoicedNotSettledAmount",
+            a.completion_status as "completionStatus",
             upf.url as "imageUrl",
             a.unsettled_amount as "unsettledAmount"
             from  settlement_documentary_fees  a
@@ -79,6 +85,9 @@
             <if test="settlementStatus !=null  and  settlementStatus  !=''">
                 and a.settlement_status =#{settlementStatus}
             </if>
+            <if test="completionStatus !=null  and  completionStatus  !=''">
+                and a.completion_status =#{completionStatus}
+            </if>
         </where>
     </select>
 
@@ -205,6 +214,9 @@
         a.agreement_type as "agreementType",
         a.settlement_time as "settlementTime",
         a.settlement_image_id as "settlementImageId",
+        a.invoiced_settled_amount as "invoicedSettledAmount",
+        a.Invoiced_not_settled_amount as "InvoicedNotSettledAmount",
+        a.completion_status as "completionStatus",
         a.task_id as "taskId",
         upf.url as "imageUrl",
         a.unsettled_amount as "unsettledAmount"
@@ -230,10 +242,69 @@
             <if test="settlementStatus !=null  and  settlementStatus  !=''">
                 and a.settlement_status =#{settlementStatus}
             </if>
+            <if test="completionStatus !=null  and  completionStatus  !=''">
+                and a.completion_status =#{completionStatus}
+            </if>
         </where>
 
     </select>
 
+    <select id="querySettleNew" resultType="com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity">
+        select
+        a.id as "id",
+        a.total_orders as "totalOrders",
+        a.time_frame as "timeFrame",
+        a.total_amount as "totalAmount",
+        a.start_time as "startTime",
+        a.end_time as "endTime",
+        a.settlement_amount as "settlementAmount",
+        a.settlement_amount as "invoicCommissionFeevalue",
+        a.agree_ment_id as "agreeMentId",
+        a.partner_companies_id as "partnerCompaniesId",
+        a.invoicing_method as "invoicingMethod",
+        a.tax_points as "taxPoints",
+        a.expend_amount as "expendAmount",
+        a.parent_id as "parentId",
+        a.handling_fees_status as "handlingFeesStatus",
+        a.agreement_type as "agreementType",
+        a.settlement_time as "settlementTime",
+        a.settlement_image_id as "settlementImageId",
+        a.task_id as "taskId",
+        a.create_time as "invoicTime",
+        a.invoice_id AS  "invoicId",
+        a.invoiced_settled_amount as "invoicedSettledAmount",
+        a.Invoiced_not_settled_amount as "InvoicedNotSettledAmount",
+        a.completion_status as "completionStatus",
+        upf.url as "imageUrl",
+        a.unsettled_amount as "unsettledAmount"
+        from  settlement_documentary_fees  a
+        LEFT  JOIN   ins_upload_files  upf   on  a.settlement_image_id=upf.id
+        <where>
+            1=1
+            <if test="partnerCompaniesId !=null  and  partnerCompaniesId  !=''">
+                and a.partner_companies_id =#{partnerCompaniesId}
+            </if>
+            <if test="handlingFeesStatus !=null  and  handlingFeesStatus  !=''">
+                and a.handling_fees_status =#{handlingFeesStatus}
+            </if>
+            <if test="isNotCar !=null  and  isNotCar  !=''">
+                and a.is_not_car =#{isNotCar}
+            </if>
+            <if test="agreementType !=null  and  agreementType  !=''">
+                and a.agreement_type =#{agreementType}
+            </if>
+            <if test="parentId !=null  and  parentId  !=''">
+                and a.parent_id =#{parentId}
+            </if>
+            <if test="settlementStatus !=null  and  settlementStatus  !=''">
+                and a.settlement_status =#{settlementStatus}
+            </if>
+            <if test="completionStatus !=null  and  completionStatus  !=''">
+                and a.completion_status =#{completionStatus}
+            </if>
+        </where>
+    </select>
+