Kaynağa Gözat

1. 金额逻辑修改2.0

wuhp 2 yıl önce
ebeveyn
işleme
fadd6a6bce

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

@@ -2,6 +2,7 @@ package com.ydtech.modules.fnc.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity;
 import com.ydtech.modules.fnc.entity.SettlementDocumentaryLogEntity;
 import com.ydtech.modules.fnc.vo.SettlementDocumentaryFeesVo;
@@ -28,4 +29,7 @@ public interface SettlementDocumentaryFeesMapper  extends BaseMapper<SettlementD
     List<HashMap<String, Object>> getInvoicIds(HashMap<String, Object> params);
 
     SettlementDocumentaryFeesEntity getByParentSettlementAmount(String id);
+
+    List<SettlementDocumentaryFeesEntity> queryNew(HashMap<String, Object> params);
+
 }

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

@@ -2,6 +2,7 @@ package com.ydtech.modules.fnc.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.fnc.entity.InsPlyIncome;
 import com.ydtech.modules.fnc.entity.SettlementDocumentaryFeesEntity;
 import com.ydtech.modules.fnc.vo.InsPlyIncomeVo;
 import com.ydtech.modules.fnc.vo.SettlementDocumentaryFeesVo;
@@ -29,4 +30,6 @@ public interface SettlementDocumentaryFeesService extends IService<SettlementDoc
     SettlementDocumentaryFeesEntity getByParentSettlementAmount(String id);
 
     void voidInvoicing(SettlementDocumentaryFeesVo settlementDocumentaryFeesVo);
+
+    List<SettlementDocumentaryFeesEntity> queryNew(HashMap<String, Object> params);
 }

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

@@ -1,5 +1,6 @@
 package com.ydtech.modules.fnc.service.impl;
 
+import cn.hutool.core.util.NumberUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -483,7 +484,7 @@ public class ImportAsyncServiceImpl extends ServiceImpl<ImportAsyncMapper, Impor
                 }
 
 //                  只查手续费
-                params.put("isOther", "1");
+                params.put("isOther", "0");
                 params.put("isNotCar", "1");
                 InsPlyIncome insPlyIncome = insPlyIncomeMapper.findByBxLicenseno(params);
                 if (ObjectUtils.isNotEmpty(insPlyIncome) && open) {

+ 193 - 11
src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java

@@ -1454,13 +1454,55 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     @Override
     public List<InsPlyIncome> totalBxAmount(InsPlyIncomeVo insPlyIncomeVo) {
         HashMap<String, Object> params = new HashMap<>();
-        params=this.saveParams(insPlyIncomeVo,params);
-        params.remove("handlingFeesStatus");
-        List<InsPlyIncome>  resultList  =  baseMapper.totalBxAmount(params);
-//      数据库数据太多是 用sql拼接id会丢失 所以只能逻辑拼接
-        List<InsPlyIncome> idList=baseMapper.getIncomeIdList(params);
-        if(!CollectionUtils.isEmpty(idList) && !CollectionUtils.isEmpty(resultList)){
-            this.splicingIds(idList,resultList);
+        params = this.saveParams(insPlyIncomeVo, params);
+        List<InsPlyIncome> resultList = baseMapper.totalBxAmount(params);
+        for (InsPlyIncome item : resultList) {
+            BigDecimal commissionFeevalue = BigDecimal.ZERO;  //总金额
+            BigDecimal invoicCommissionFeevalue = BigDecimal.ZERO; //开票未结算
+            BigDecimal readyCommissionFeevalue = BigDecimal.ZERO; // 已开票已结算
+            BigDecimal noInvoicCommissionFeevalue = BigDecimal.ZERO; //未开票金额
+            BigDecimal unSettledAmount; //未结算金额
+            params.put("partnerCompaniesId", item.getPartnerCompaniesId());
+
+            params.remove("handlingFeesStatus");
+            List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);  //金额总数
+            for (InsPlyIncome all : insPlyIncomes) {
+                commissionFeevalue = commissionFeevalue.add(all.getCommissionFeevalue());
+            }
+            //已开票金额  =  开票未结算+  开票已结算
+            params.put("handlingFeesStatus","0"); // 开票
+            params.put("settlementStatus","1"); // 开票
+            List<SettlementDocumentaryFeesEntity> invoicInsPlyIncomes = settlementDocumentaryFeesService.queryNew(params);  //金额总数
+            for (SettlementDocumentaryFeesEntity invoicInsPlyIncome : invoicInsPlyIncomes) {
+                BigDecimal invoicIcommissionFeevalue = invoicInsPlyIncome.getSettlementAmount();// 已经开票金额
+                invoicCommissionFeevalue = invoicCommissionFeevalue.add(invoicIcommissionFeevalue);  //开票金额
+
+            }
+            params.put("settlementStatus","2"); // 结算
+            List<SettlementDocumentaryFeesEntity> settleInsPlyIncomes = settlementDocumentaryFeesService.queryNew(params);  //金额总数
+            for (SettlementDocumentaryFeesEntity settleInsPlyIncome : settleInsPlyIncomes) {
+                BigDecimal settleIcommissionFeevalue = settleInsPlyIncome.getSettlementAmount();// 已结算金额
+                readyCommissionFeevalue = readyCommissionFeevalue.add(settleIcommissionFeevalue);  //已结算总
+            }
+            params.put("settlementStatus" ,0);  //未开票金额
+            List<SettlementDocumentaryFeesEntity> noInvoicInsPlyIncomes = settlementDocumentaryFeesService.queryNew(params);  //金额总数
+            for (SettlementDocumentaryFeesEntity noInvoicInsPlyIncome : noInvoicInsPlyIncomes) {
+                BigDecimal noInvoicIcommissionFeevalue = noInvoicInsPlyIncome.getSettlementAmount();// 未开票金额
+                noInvoicCommissionFeevalue = noInvoicCommissionFeevalue.add(noInvoicIcommissionFeevalue);  //未开票总金额
+            }
+
+            noInvoicCommissionFeevalue = commissionFeevalue.subtract(invoicCommissionFeevalue);// 未开票
+            unSettledAmount =commissionFeevalue.subtract(readyCommissionFeevalue);   //未结算
+             //已开票金额
+
+            item.setCommissionFeevalue(commissionFeevalue);  //总手续费
+            item.setAllInvoicCommissionFeevalue(invoicCommissionFeevalue);  //总开票金额
+            //  开票未结算   = 开票金额 -  已开票已结算
+            invoicCommissionFeevalue  = invoicCommissionFeevalue.subtract(readyCommissionFeevalue);
+            item.setInvoicCommissionFeevalue(invoicCommissionFeevalue); //开票未结算
+            item.setReadyCommissionFeevalue(readyCommissionFeevalue);  //已开票已结算
+            item.setNoInvoicCommissionFeevalue(noInvoicCommissionFeevalue);   //未开票金额
+            item.setUnSettledAmount(unSettledAmount);   // 未结算金额
         }
         return resultList;
     }
@@ -1535,6 +1577,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         insPlyIncomeVo.setHandlingFeesStatus("0");  // 0手续费 1  跟单费
         insPlyIncomeVo.setIsNotCar(insPlyIncomeVo.getIsNotCar());
         insPlyIncomeVo.setAgreementId(importResult.getAgreementId());
+        insPlyIncomeVo.setAgreementType(insPlyIncomeVo.getAgreementType());
         insPlyIncomeVo.setPartnerCompaniesId(importResult.getPartnerCompaniesId());
         insPlyIncomeVo.setSettlementAmount(importResult.getTotalAmount());
         insPlyIncomeVo.setContractId(insPlyIncomeVo.getInvoicId());
@@ -1629,8 +1672,72 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
     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);
+        List<InsPlyIncome> resultList = baseMapper.totalBxAmount(params);
+        //总跟单费
+        for (InsPlyIncome  item  : resultList ){
+            BigDecimal otherFeevalue = BigDecimal.ZERO;  //总跟单金额
+            BigDecimal invoicCommissionFeevalue = BigDecimal.ZERO; //已开票跟单费
+            BigDecimal readyCommissionFeevalue = BigDecimal.ZERO; // 已开票已结算 跟单费
+            BigDecimal noInvoicCommissionFeevalue = BigDecimal.ZERO; //未开票跟单金额
+            BigDecimal unSettledAmount = BigDecimal.ZERO; //未结算跟单金额
+            BigDecimal expendAmount = BigDecimal.ZERO; //实收金额
+            BigDecimal taxesFees = BigDecimal.ZERO; //税费
+            BigDecimal taxPoints = BigDecimal.ZERO; //税点
+
+
+
+            params.put("partnerCompaniesId", item.getPartnerCompaniesId());
+
+            List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);  // 总跟单费
+            for (InsPlyIncome all : insPlyIncomes) {
+                otherFeevalue = otherFeevalue.add(all.getOtherFeevalue());
+            }
+
+
+            //已开票金额  =  开票未结算+  开票已结算
+            params.put("handlingFeesStatus","1"); // 开票
+            params.put("settlementStatus","1"); // 开票
+            List<SettlementDocumentaryFeesEntity> invoicInsPlyIncomes = settlementDocumentaryFeesService.queryNew(params);  //金额总数
+            for (SettlementDocumentaryFeesEntity invoicInsPlyIncome : invoicInsPlyIncomes) {
+                BigDecimal invoicIcommissionFeevalue = invoicInsPlyIncome.getSettlementAmount();// 已经开票金额
+                invoicCommissionFeevalue = invoicCommissionFeevalue.add(invoicIcommissionFeevalue);  //开票金额
+
+            }
+            params.put("settlementStatus","2"); // 结算
+            List<SettlementDocumentaryFeesEntity> settleInsPlyIncomes = settlementDocumentaryFeesService.queryNew(params);  //金额总数
+            for (SettlementDocumentaryFeesEntity settleInsPlyIncome : settleInsPlyIncomes) {
+                BigDecimal settleIcommissionFeevalue = settleInsPlyIncome.getSettlementAmount();// 已结算金额
+                readyCommissionFeevalue = readyCommissionFeevalue.add(settleIcommissionFeevalue);  //已结算总
+
+                BigDecimal divide = new BigDecimal(100).subtract(settleInsPlyIncome.getTaxPoints()).divide(new BigDecimal(100));
+                expendAmount=expendAmount.add(settleInsPlyIncome.getSettlementAmount().multiply(divide));
+
+            }
+            params.put("settlementStatus" ,0);  //未开票金额
+            List<SettlementDocumentaryFeesEntity> noInvoicInsPlyIncomes = settlementDocumentaryFeesService.queryNew(params);  //金额总数
+            for (SettlementDocumentaryFeesEntity noInvoicInsPlyIncome : noInvoicInsPlyIncomes) {
+                BigDecimal noInvoicIcommissionFeevalue = noInvoicInsPlyIncome.getSettlementAmount();// 未开票金额
+                noInvoicCommissionFeevalue = noInvoicCommissionFeevalue.add(noInvoicIcommissionFeevalue);  //未开票总金额
+            }
+
+            noInvoicCommissionFeevalue = otherFeevalue.subtract(invoicCommissionFeevalue);// 未开票
+            unSettledAmount =otherFeevalue.subtract(readyCommissionFeevalue);   //未结算
+            //已开票金额
+
+            item.setOtherFeevalue(otherFeevalue);  //总手续费
+            item.setAllInvoicCommissionFeevalue(invoicCommissionFeevalue);  //总开票金额
+            //  开票未结算   = 开票金额 -  已开票已结算
+            invoicCommissionFeevalue  = invoicCommissionFeevalue.subtract(readyCommissionFeevalue);
+            item.setInvoicCommissionFeevalue(invoicCommissionFeevalue); //开票未结算
+            item.setReadyCommissionFeevalue(readyCommissionFeevalue);  //已开票已结算
+            item.setNoInvoicCommissionFeevalue(noInvoicCommissionFeevalue);   //未开票金额
+            item.setUnSettledAmount(unSettledAmount);   // 未结算金额
+            //               实收金额  =   结算金额  *1-税点
+            taxesFees=readyCommissionFeevalue.subtract(expendAmount);
+            item.setExpendAmount(expendAmount);
+            item.setTaxesFees(taxesFees);
+        }
+        return HttpResult.ok(resultList);
     }
 
 
@@ -1675,6 +1782,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         if(StringUtils.isNotEmpty(insPlyIncomeVo.getTaskId())){
             settlementDocumentaryFeesVo.setTaskId(insPlyIncomeVo.getTaskId());
         }
+        settlementDocumentaryFeesVo.setAgreementType("2");
         settlementDocumentaryFeesVo.setHandlingFeesStatus(insPlyIncomeVo.getHandlingFeesStatus());
         settlementDocumentaryFeesVo.setInvoicingMethod(insPlyIncomeVo.getInvoicingMethod()); //开票方式
         settlementDocumentaryFeesVo.setTaxPoints(insPlyIncomeVo.getTaxPoints()); //税点
@@ -1806,10 +1914,83 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
 
     @Override
     public InsPlyIncome bxTotalAmount(InsPlyIncomeVo insPlyIncomeVo) {
+        InsPlyIncome insPlyIncome = new InsPlyIncome();
         HashMap<String, Object> params = new HashMap<>();
         params = this.saveParams(insPlyIncomeVo, params);
-        InsPlyIncome totalledAmount =baseMapper.bxTotalAmount(params);  //总金额
-        return totalledAmount;
+
+
+        BigDecimal sumCommissionFeevalue = BigDecimal.ZERO;  //总金额
+        BigDecimal sumInvoicCommissionFeevalue = BigDecimal.ZERO; //开票未结算
+        BigDecimal sumReadyCommissionFeevalue = BigDecimal.ZERO; // 已开票已结算
+        BigDecimal sumNoInvoicCommissionFeevalue = BigDecimal.ZERO; //未开票金额
+        BigDecimal sumUnSettledAmount = BigDecimal.ZERO; //未结算金额
+        BigDecimal sumAllInvoicCommissionFeevalue = BigDecimal.ZERO; //总开票
+
+
+        List<InsPlyIncome> resultList = baseMapper.totalBxAmount(params);
+        for (InsPlyIncome item : resultList) {
+            BigDecimal commissionFeevalue = BigDecimal.ZERO;  //总金额
+            BigDecimal invoicCommissionFeevalue = BigDecimal.ZERO; //开票未结算
+            BigDecimal readyCommissionFeevalue = BigDecimal.ZERO; // 已开票已结算
+            BigDecimal noInvoicCommissionFeevalue = BigDecimal.ZERO; //未开票金额
+            BigDecimal unSettledAmount; //未结算金额
+            params.put("partnerCompaniesId", item.getPartnerCompaniesId());
+
+            params.remove("handlingFeesStatus");
+            List<InsPlyIncome> insPlyIncomes = baseMapper.queryNew(params);  //金额总数
+            for (InsPlyIncome all : insPlyIncomes) {
+                commissionFeevalue = commissionFeevalue.add(all.getCommissionFeevalue());
+            }
+            //已开票金额  =  开票未结算+  开票已结算
+            params.put("handlingFeesStatus", "0"); // 开票
+            params.put("settlementStatus", "1"); // 开票
+            List<SettlementDocumentaryFeesEntity> invoicInsPlyIncomes = settlementDocumentaryFeesService.queryNew(params);  //金额总数
+            for (SettlementDocumentaryFeesEntity invoicInsPlyIncome : invoicInsPlyIncomes) {
+                BigDecimal invoicIcommissionFeevalue = invoicInsPlyIncome.getSettlementAmount();// 已经开票金额
+                invoicCommissionFeevalue = invoicCommissionFeevalue.add(invoicIcommissionFeevalue);  //开票金额
+
+            }
+            params.put("settlementStatus", "2"); // 结算
+            List<SettlementDocumentaryFeesEntity> settleInsPlyIncomes = settlementDocumentaryFeesService.queryNew(params);  //金额总数
+            for (SettlementDocumentaryFeesEntity settleInsPlyIncome : settleInsPlyIncomes) {
+                BigDecimal settleIcommissionFeevalue = settleInsPlyIncome.getSettlementAmount();// 已结算金额
+                readyCommissionFeevalue = readyCommissionFeevalue.add(settleIcommissionFeevalue);  //已结算总
+            }
+            params.put("settlementStatus", 0);  //未开票金额
+            List<SettlementDocumentaryFeesEntity> noInvoicInsPlyIncomes = settlementDocumentaryFeesService.queryNew(params);  //金额总数
+            for (SettlementDocumentaryFeesEntity noInvoicInsPlyIncome : noInvoicInsPlyIncomes) {
+                BigDecimal noInvoicIcommissionFeevalue = noInvoicInsPlyIncome.getSettlementAmount();// 未开票金额
+                noInvoicCommissionFeevalue = noInvoicCommissionFeevalue.add(noInvoicIcommissionFeevalue);  //未开票总金额
+            }
+
+            noInvoicCommissionFeevalue = commissionFeevalue.subtract(invoicCommissionFeevalue);// 未开票
+            unSettledAmount = commissionFeevalue.subtract(readyCommissionFeevalue);   //未结算
+            //已开票金额
+
+            item.setCommissionFeevalue(commissionFeevalue);  //总手续费
+            item.setAllInvoicCommissionFeevalue(invoicCommissionFeevalue);  //总开票金额
+            //  开票未结算   = 开票金额 -  已开票已结算
+            invoicCommissionFeevalue = invoicCommissionFeevalue.subtract(readyCommissionFeevalue);
+            item.setInvoicCommissionFeevalue(invoicCommissionFeevalue); //开票未结算
+            item.setReadyCommissionFeevalue(readyCommissionFeevalue);  //已开票已结算
+            item.setNoInvoicCommissionFeevalue(noInvoicCommissionFeevalue);   //未开票金额
+            item.setUnSettledAmount(unSettledAmount);   // 未结算金额
+
+            sumCommissionFeevalue = sumCommissionFeevalue.add(item.getCommissionFeevalue());
+            sumInvoicCommissionFeevalue = sumInvoicCommissionFeevalue.add(item.getInvoicCommissionFeevalue());
+            sumReadyCommissionFeevalue = sumReadyCommissionFeevalue.add(item.getReadyCommissionFeevalue());
+            sumNoInvoicCommissionFeevalue = sumNoInvoicCommissionFeevalue.add(item.getNoInvoicCommissionFeevalue());
+            sumUnSettledAmount = sumUnSettledAmount.add(item.getUnSettledAmount());
+            sumAllInvoicCommissionFeevalue = sumAllInvoicCommissionFeevalue.add(item.getAllInvoicCommissionFeevalue());
+        }
+
+        insPlyIncome.setCommissionFeevalue(sumCommissionFeevalue);
+        insPlyIncome.setInvoicCommissionFeevalue(sumInvoicCommissionFeevalue);
+        insPlyIncome.setReadyCommissionFeevalue(sumReadyCommissionFeevalue);
+        insPlyIncome.setNoInvoicCommissionFeevalue(sumNoInvoicCommissionFeevalue);
+        insPlyIncome.setAllInvoicCommissionFeevalue(sumAllInvoicCommissionFeevalue);
+        insPlyIncome.setUnSettledAmount(sumUnSettledAmount);
+        return insPlyIncome;
     }
     @Override
     public InsPlyIncome ptTotalAmount(InsPlyIncomeVo insPlyIncomeVo) {
@@ -1925,6 +2106,7 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         settlementDocumentaryFeesVo.setUnsettledAmount(insPlyIncomeVo.getNoInvoicCommissionFeevalue().subtract(insPlyIncomeVo.getSettlementAmount())); //未结算
         settlementDocumentaryFeesVo.setSettlementAmount(insPlyIncomeVo.getSettlementAmount());//已经开票
         settlementDocumentaryFeesVo.setCreateTime(LocalDateTime.now());
+        settlementDocumentaryFeesVo.setAgreementType(insPlyIncomeVo.getAgreementType());
         settlementDocumentaryFeesVo.setIds(insPlyIncomeVo.getIncomeIds());
         settlementDocumentaryFeesVo.setSettlementStatus("1");
         settlementDocumentaryFeesVo.setIsNotCar(insPlyIncomeVo.getIsNotCar());

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

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

+ 1 - 0
src/main/resources/mapper/modules/fnc/ImportAsyncMapper.xml

@@ -47,5 +47,6 @@
              AND   DATE(a.create_time) =#{createTime}
             </if>
         </where>
+        order  by  a.create_time  desc
     </select>
 </mapper>

+ 1 - 40
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -1015,55 +1015,16 @@
         </where>
     </select>
 
-<!--noInvoicCommissionFeevalue-->
     <select id="totalBxAmount" resultType="com.ydtech.modules.fnc.entity.InsPlyIncome">
         SELECT
         a.partner_companies_id AS "partnerCompaniesId",
         MAX( a.company_name ) AS "companyName",
         MAX( a.company_id ) AS "companyId",
-        MAX( a.partner_companies_name ) AS "partnerCompaniesName",
-        MAX(IFNULL(F.settleMentAmount ,0)) AS "invoicCommissionFeevalue",
-        IFNULL(max(f.settleMentAmount) , 0.00)  as  "readyCommissionFeevalue",
-        IFNULL ( max(d.settleMentAmount),0.00) as "allInvoicCommissionFeevalue",
-        sum(COALESCE( a.commission_feevalue,0.00) )-IFNULL ( max(d.settleMentAmount),0.00)  as "noInvoicCommissionFeevalue",
-        sum(COALESCE( a.commission_feevalue,0.00) )-COALESCE(max(c.settleMentAmount),0.00)+IFNULL ( max(d.settleMentAmount),0.00)  AS "unSettledAmount",
-        IFNULL(MAX(f.expendAmount),0.00) as   "expendAmount",
-        MAX(COALESCE( f.settleMentAmount,0.00) )-IFNULL ( max(f.expendAmount),0.00)  as "taxesFees",
-        sum( a.commission_feevalue ) AS "commissionFeevalue"
+        MAX( a.partner_companies_name ) AS "partnerCompaniesName"
         FROM
         ins_ply_income a
         LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
         LEFT  JOIN   esm_ins_company  eic   on  eic.id=a.partner_companies_id
-        LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
-        settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
-        WHERE ( a.settlement_status = '1' or a.settlement_status = '2')
-        and  a.handling_fees_status ='0'
-        <if test="isNotCar !=null  and  isNotCar  !=''">
-            and a.is_not_car =#{isNotCar}
-        </if>
-        GROUP BY partner_companies_id
-        ) c ON c.partnerCompaniesId = a.partner_companies_id
-        LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId" ,sum(
-        settlement_amount ) AS "settleMentAmount" FROM settlement_documentary_fees a
-        WHERE a.settlement_status = '1'
-        and  a.handling_fees_status ='0'
-        <if test="isNotCar !=null  and  isNotCar  !=''">
-            and a.is_not_car =#{isNotCar}
-        </if>
-        GROUP BY partner_companies_id
-        ) d ON d.partnerCompaniesId = a.partner_companies_id
-        LEFT JOIN ( SELECT a.partner_companies_id AS "partnerCompaniesId",sum(
-        settlement_amount ) AS "settleMentAmount" ,
-        SUM(CASE WHEN a.invoicing_method = '0' THEN a.expend_amount ELSE 0 END) as  "expendAmount",
-        SUM(CASE WHEN a.invoicing_method = '0' THEN a.tax_points ELSE 0 END) as  "taxPoints"
-        FROM settlement_documentary_fees a
-        WHERE a.settlement_status = '2'
-        and  a.handling_fees_status ='0'
-        <if test="isNotCar !=null  and  isNotCar  !=''">
-            and a.is_not_car =#{isNotCar}
-        </if>
-        GROUP BY partner_companies_id
-        ) f ON f.partnerCompaniesId = a.partner_companies_id
         <where>
             1=1
             <if test="agreementType !=null  and agreementType!='' ">

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

@@ -76,6 +76,9 @@
             <if test="parentId !=null  and  parentId  !=''">
                 and a.parent_id =#{parentId}
             </if>
+            <if test="settlementStatus !=null  and  settlementStatus  !=''">
+                and a.settlement_status =#{settlementStatus}
+            </if>
         </where>
     </select>
 
@@ -177,6 +180,55 @@
         </where>
     </select>
 
+    <select id="queryNew" 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.create_time as "createTime",
+        a.start_time as "startTime",
+        a.end_time as "endTime",
+        a.settlement_amount as "settlementAmount",
+        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",
+        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>
+        </where>
+
+    </select>
+