Explorar o código

1.控制台结算调整1.0

wuhp %!s(int64=2) %!d(string=hai) anos
pai
achega
eba8b321c7

+ 2 - 0
src/main/java/com/ydtech/modules/fnc/dao/InsPlyIncomeMapper.java

@@ -202,4 +202,6 @@ public interface InsPlyIncomeMapper extends BaseMapper<InsPlyIncome> {
 
     Collection<? extends FinancialReceivablesVo> queryDateByTypePt(FinancialReceivablesQueryVo financialReceivablesQueryVo);
 
+    List<FinancialReceivablesMonthVo> getPatherId( @Param("vo")  FinancialReceivablesQueryMonthVo financialReceivablesQueryVo);
+
 }

+ 74 - 42
src/main/java/com/ydtech/modules/fnc/service/impl/InsPlyIncomeServiceImpl.java

@@ -54,6 +54,7 @@ import com.ydtech.utils.excel.ExcelStyleUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -2164,7 +2165,6 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         }else{
             insuranceHandlingSettlementMonthService.saveBatch(insuranceHandlingListNew);
         }
-
         return HttpResult.ok();
     }
 
@@ -3448,9 +3448,9 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         } else {
              amountMap = this.platformSett(resultData, financialReceivablesQueryVo);
         }
-//        vo.setYisSumAmount(amountMap.get("yishouAmount").toString());
-//        vo.setYsSumAmount(amountMap.get("yinshouAmount").toString());
-//        vo.setWsSumAmount(amountMap.get("weishouAmount").toString());
+        vo.setYisSumAmount(amountMap.get("yishouAmount").toString());
+        vo.setYsSumAmount(amountMap.get("yinshouAmount").toString());
+        vo.setWsSumAmount(amountMap.get("weishouAmount").toString());
         return vo;
     }
 
@@ -3471,25 +3471,30 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
         //平台手续费
         List<FinancialReceivablesMonthVo> handList = baseMapper.queryPlatHanding(financialReceivablesQueryVo);
 
-        Map<String, FinancialReceivablesMonthVo> collect = handList.stream().collect(Collectors.toMap(FinancialReceivablesMonthVo::getPartnerCompaniesId, Function.identity()));
 
-        handList.stream().filter(item -> collect.containsKey(item.getPartnerCompaniesId()))
-                .forEach(item ->{
-                    FinancialReceivablesMonthVo otherItem = collect.get(item.getPartnerCompaniesId());
+        List<FinancialReceivablesMonthVo> patherIdList = baseMapper.getPatherId(financialReceivablesQueryVo);
+
+
 
+        Map<String, List<FinancialReceivablesMonthVo>> groupedByPartnerCompaniesId = handList.stream()
+                .collect(Collectors.groupingBy(FinancialReceivablesMonthVo::getPartnerCompaniesId));
+
+        patherIdList.stream().filter(item -> groupedByPartnerCompaniesId.containsKey(item.getPartnerCompaniesId()))
+                .forEach(item ->{
+                    List<FinancialReceivablesMonthVo> financialReceivablesMonthVosList = groupedByPartnerCompaniesId.get(item.getPartnerCompaniesId());
                     FinancialReceivablesMonthSignleVo financialReceivablesMonthSignleVo = new FinancialReceivablesMonthSignleVo();
                     List<FinancialReceivablesMonthVo> financialReceivablesMonthVos = financialReceivablesMonthSignleVo.getList();
                     financialReceivablesMonthSignleVo.setCompanyName(item.getCompanyName());
                     financialReceivablesMonthSignleVo.setAreaName(item.getAreaName());
-                    financialReceivablesMonthVos.add(otherItem);
-                    financialReceivablesMonthVos.add(item);
-                    if("合计".equals(item.getIsHand())){
-                        yinShouAmountList.add(this.stringToBigdecimal(item.getCommissionFeevalue()));
-                        yishouAmountList.add(this.stringToBigdecimal(item.getReadyCommissionFeevalue()));
-                        weishouAmountList.add(this.stringToBigdecimal(item.getNoInvoicCommissionFeevalue()));
-
-                    }
+                    financialReceivablesMonthVos.addAll(financialReceivablesMonthVosList);
                     resultData.add(financialReceivablesMonthSignleVo);
+                    financialReceivablesMonthVosList.forEach(financialReceivablesMonthVo  ->{
+                        if("合计".equals(financialReceivablesMonthVo.getIsHand())){
+                            yinShouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getCommissionFeevalue()));
+                            yishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getReadyCommissionFeevalue()));
+                            weishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getNoInvoicCommissionFeevalue()));
+                        }
+                    });
                 });
         yinshouAmount = yinshouAmount.add(yinShouAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add));
         yishouAmount = yishouAmount.add(yishouAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add));
@@ -3512,37 +3517,64 @@ public class InsPlyIncomeServiceImpl extends ServiceImpl<InsPlyIncomeMapper, Ins
 
         HashMap<String, BigDecimal> resultMap = new HashMap<>();
 
-
         //手续费未接应收
         List<FinancialReceivablesMonthVo> list = baseMapper.queryDateByTypeByMonthList(financialReceivablesQueryVo);
         //跟单统计
         List<FinancialReceivablesMonthVo> otherList = baseMapper.queryDateByTypeByMonthOtherList(financialReceivablesQueryVo);
 
-        Map<String, FinancialReceivablesMonthVo> collect = otherList.stream().collect(Collectors.toMap(FinancialReceivablesMonthVo::getPartnerCompaniesId, Function.identity()));
-        list.stream()
-                .filter(item -> collect.containsKey(item.getPartnerCompaniesId()))
-                .forEach(
-                        item -> {
-                            FinancialReceivablesMonthVo otherItem = collect.get(item.getPartnerCompaniesId());
-                            FinancialReceivablesMonthSignleVo financialReceivablesMonthSignleVo = new FinancialReceivablesMonthSignleVo();
-                            List<FinancialReceivablesMonthVo> financialReceivablesMonthVos = financialReceivablesMonthSignleVo.getList();
-                            financialReceivablesMonthSignleVo.setCompanyName(item.getCompanyName());
-                            financialReceivablesMonthSignleVo.setAreaName(item.getAreaName());
-//                          合计信息
-                            FinancialReceivablesMonthVo financialReceivablesMonthVo = new FinancialReceivablesMonthVo();
-                            financialReceivablesMonthVo.setCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getCommissionFeevalue()), new BigDecimal(otherItem.getCommissionFeevalue()), null).toString());
-                            financialReceivablesMonthVo.setNoInvoicCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getNoInvoicCommissionFeevalue()), new BigDecimal(otherItem.getNoInvoicCommissionFeevalue()), null).toString());
-                            financialReceivablesMonthVo.setReadyCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getReadyCommissionFeevalue()), new BigDecimal(otherItem.getReadyCommissionFeevalue()), null).toString());
-                            financialReceivablesMonthVo.setSettlementAmount(this.calculateTotal(this.stringToBigdecimal(item.getSettlementAmount()), new BigDecimal(otherItem.getSettlementAmount()), null).toString());
-                            financialReceivablesMonthVo.setNoSettlementAmount(this.calculateTotal(this.stringToBigdecimal(item.getNoSettlementAmount()), new BigDecimal(otherItem.getNoSettlementAmount()), null).toString());
-                            financialReceivablesMonthVo.setIsHand("合计");
-                            financialReceivablesMonthVos.add(otherItem);
-                            financialReceivablesMonthVos.add(item);
-                            financialReceivablesMonthVos.add(financialReceivablesMonthVo);
-                            yishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getReadyCommissionFeevalue()));
-                            yinShouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getCommissionFeevalue()));
-                            weishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getNoInvoicCommissionFeevalue()));
-                            resultData.add(financialReceivablesMonthSignleVo);
+        Map<String, FinancialReceivablesMonthVo> otherCollect = otherList.stream().collect(Collectors.toMap(FinancialReceivablesMonthVo::getPartnerCompaniesId, Function.identity()));
+        Map<String, FinancialReceivablesMonthVo>  commCollect= list.stream().collect(Collectors.toMap(FinancialReceivablesMonthVo::getPartnerCompaniesId, Function.identity()));
+        list.forEach(item -> {
+                            if(otherCollect.containsKey(item.getPartnerCompaniesId())){
+                                FinancialReceivablesMonthVo otherItem = otherCollect.get(item.getPartnerCompaniesId());
+                                FinancialReceivablesMonthSignleVo financialReceivablesMonthSignleVo = new FinancialReceivablesMonthSignleVo();
+                                List<FinancialReceivablesMonthVo> financialReceivablesMonthVos = financialReceivablesMonthSignleVo.getList();
+                                financialReceivablesMonthSignleVo.setCompanyName(item.getCompanyName());
+                                financialReceivablesMonthSignleVo.setAreaName(item.getAreaName());
+//                              合计信息
+                                FinancialReceivablesMonthVo financialReceivablesMonthVo = new FinancialReceivablesMonthVo();
+                                financialReceivablesMonthVo.setCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getCommissionFeevalue()), new BigDecimal(otherItem.getCommissionFeevalue()), null).toString());
+                                financialReceivablesMonthVo.setNoInvoicCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getNoInvoicCommissionFeevalue()), new BigDecimal(otherItem.getNoInvoicCommissionFeevalue()), null).toString());
+                                financialReceivablesMonthVo.setReadyCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getReadyCommissionFeevalue()), new BigDecimal(otherItem.getReadyCommissionFeevalue()), null).toString());
+                                financialReceivablesMonthVo.setSettlementAmount(this.calculateTotal(this.stringToBigdecimal(item.getSettlementAmount()), new BigDecimal(otherItem.getSettlementAmount()), null).toString());
+                                financialReceivablesMonthVo.setNoSettlementAmount(this.calculateTotal(this.stringToBigdecimal(item.getNoSettlementAmount()), new BigDecimal(otherItem.getNoSettlementAmount()), null).toString());
+                                financialReceivablesMonthVo.setIsHand("合计");
+                                financialReceivablesMonthVos.add(otherItem);
+                                financialReceivablesMonthVos.add(item);
+                                financialReceivablesMonthVos.add(financialReceivablesMonthVo);
+                                yishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getReadyCommissionFeevalue()));
+                                yinShouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getCommissionFeevalue()));
+                                weishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getNoInvoicCommissionFeevalue()));
+                                resultData.add(financialReceivablesMonthSignleVo);
+                            }else {
+                                FinancialReceivablesMonthVo otherItem = new FinancialReceivablesMonthVo() ;
+                                otherItem.setIsHand("跟单费");
+                                otherItem.setCommissionFeevalue(BigDecimal.ZERO.toString());
+                                otherItem.setNoInvoicCommissionFeevalue(BigDecimal.ZERO.toString());
+                                otherItem.setReadyCommissionFeevalue(BigDecimal.ZERO.toString());
+                                otherItem.setSettlementAmount(BigDecimal.ZERO.toString());
+                                otherItem.setNoSettlementAmount(BigDecimal.ZERO.toString());
+                                FinancialReceivablesMonthSignleVo financialReceivablesMonthSignleVo = new FinancialReceivablesMonthSignleVo();
+                                List<FinancialReceivablesMonthVo> financialReceivablesMonthVos = financialReceivablesMonthSignleVo.getList();
+                                financialReceivablesMonthSignleVo.setCompanyName(item.getCompanyName());
+                                financialReceivablesMonthSignleVo.setAreaName(item.getAreaName());
+//                              合计信息
+                                FinancialReceivablesMonthVo financialReceivablesMonthVo = new FinancialReceivablesMonthVo();
+                                financialReceivablesMonthVo.setCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getCommissionFeevalue()), BigDecimal.ZERO, null).toString());
+                                financialReceivablesMonthVo.setNoInvoicCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getNoInvoicCommissionFeevalue()), BigDecimal.ZERO, null).toString());
+                                financialReceivablesMonthVo.setReadyCommissionFeevalue(this.calculateTotal(this.stringToBigdecimal(item.getReadyCommissionFeevalue()), BigDecimal.ZERO, null).toString());
+                                financialReceivablesMonthVo.setSettlementAmount(this.calculateTotal(this.stringToBigdecimal(item.getSettlementAmount()), BigDecimal.ZERO, null).toString());
+                                financialReceivablesMonthVo.setNoSettlementAmount(this.calculateTotal(this.stringToBigdecimal(item.getNoSettlementAmount()), BigDecimal.ZERO, null).toString());
+                                financialReceivablesMonthVo.setIsHand("合计");
+                                financialReceivablesMonthVos.add(otherItem);
+                                financialReceivablesMonthVos.add(item);
+                                financialReceivablesMonthVos.add(financialReceivablesMonthVo);
+                                yishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getReadyCommissionFeevalue()));
+                                yinShouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getCommissionFeevalue()));
+                                weishouAmountList.add(this.stringToBigdecimal(financialReceivablesMonthVo.getNoInvoicCommissionFeevalue()));
+                                resultData.add(financialReceivablesMonthSignleVo);
+
+                            }
                         }
                 );
         yinshouAmount = yinshouAmount.add(yinShouAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add));

+ 4 - 4
src/main/resources/mapper/modules/admin/SysUserMapper.xml

@@ -1298,16 +1298,16 @@
             and su.id  LIKE '%M%'
             and su.status = '1'
             <if test="vo.provinceId != null and vo.provinceId != ''">
-                and sd.deptid like "$vo.provinceId}%"
+                and sd.id like  concat('%',#{vo.provinceId},'%')
             </if>
             <if test="vo.cityId != null and vo.cityId != ''">
-                and sd.deptid like "${vo.cityId}%"
+                and sd.id like concat('%',#{vo.cityId},'%')
             </if>
             <if test="vo.countyId != null and vo.countyId != ''">
-                and sd.deptid like "${vo.countyId}%"
+                and sd.id like concat('%',#{vo.countyId},'%')
             </if>
             <if test="vo.houseId != null and vo.houseId != ''">
-                and sd.deptid like "${vo.houseId}%"
+                and sd.id like concat('%',#{vo.houseId},'%')
             </if>
         </where>
     </select>

+ 216 - 145
src/main/resources/mapper/modules/fnc/InsPlyIncomeMapper.xml

@@ -2463,16 +2463,17 @@
     <select id="queryDateByType"
             resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesVo">
         SELECT
-            a.subSigning as "yearAndMonth",
+            a.subSigndate as "yearAndMonth",
             a.allAmount as "commissionFeevalue",
-            b.commSettLement +c.otherSettlementAmount as "noInvoicCommissionFeevalue",
-            a.allAmount-( b.commSettLement +c.otherSettlementAmount) as "readyCommissionFeevalue",
-            (c.invoicAmount - c.otherSettlementAmount) +  (b.remainingAmount) as "settlementAmount"
+            IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0) as "noInvoicCommissionFeevalue",
+            IFNULL(b.remainingAmount,0) +IFNULL(c.invoicNotOther,0) as "settlementAmount",
+            (a.allAmount-(IFNULL(b.invoicComm,0) + IFNULL(c.otherInvoic,0)))  as "noSettlementAmount",
+            a.allAmount-(IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0)) as "readyCommissionFeevalue"
         FROM
             (
                 SELECT
-                    sum( a.all_fee_value ) AS "allAmount",
-                    DATE_FORMAT( a.signdate, '%Y-%m' ) AS "subSigning"
+                    DATE_FORMAT( a.signdate, '%Y-%m' ) AS subSigndate,
+                    IFNULL( sum( a.commission_feevalue ), 0 ) + IFNULL( sum( a.other_feevalue ), 0 ) AS "allAmount"
                 FROM
                     ins_ply_income a
                         LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
@@ -2480,29 +2481,26 @@
                     pa.agreement_type = '2'
                 GROUP BY
                     DATE_FORMAT( a.signdate, '%Y-%m' )
-            )  a    left  join  (
+            ) a
+                LEFT JOIN (
                 SELECT
-                    sum( a.settlement_amount ) as "commSettLement",
-                    sum( a.remaining_amount ) as "remainingAmount",
-                    DATE_FORMAT( a.signing_time, '%Y-%m' )  as "subSigning"
+                    DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigndate",
+                    sum( a.settlement_amount ) AS "settCommAmount",
+                    sum(a.remaining_amount) as "remainingAmount",
+                    sum(a.total_amount) as "invoicComm"
                 FROM
                     sys_insurance_handling_settlement_month a
                 GROUP BY
                     DATE_FORMAT( a.signing_time, '%Y-%m' )
-            ) b  on  b.subSigning=a.subSigning
-                    left  join  (
-                SELECT
-                    SUM( CASE WHEN a.settlement_status = '2' THEN IFNULL( a.settlement_amount, 0 ) ELSE 0 END ) AS "otherSettlementAmount",
-                    SUM( CASE WHEN a.settlement_status = '1' THEN IFNULL( a.settlement_amount, 0 ) ELSE 0 END ) AS "invoicAmount",
-                    DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigning"
-                FROM
-                    settlement_documentary_fees a
-                WHERE
-                    a.handling_fees_status = '1'
-                GROUP BY
-                    DATE_FORMAT( a.signing_time, '%Y-%m' )
-            )  c  on  c.subSigning=a.subSigning
-
+            ) b ON a.subSigndate = b.subSigndate
+                left  join  (
+                select DATE_FORMAT( a.signing_time, '%Y-%m' ) as "subSigndate" ,  sum(settlement_amount) as "otherInvoic", sum(invoiced_settled_amount) as "settAmountOther", sum(Invoiced_not_settled_amount) as "invoicNotOther"
+                from
+                    settlement_documentary_fees  a
+                where a.settlement_status='1'
+                  and handling_fees_status ='1'
+                GROUP BY 	DATE_FORMAT( a.signing_time, '%Y-%m' )
+            )  c  on c.subSigndate=a.subSigndate
     </select>
 
     <select id="queryDateByTypeMonthSumAmount" resultType="java.math.BigDecimal">
@@ -2539,6 +2537,9 @@
             <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
                 AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
             </if>
+           <if test="vo.yearAndMonth  != null  and  vo.yearAndMonth!=''">
+                AND   DATE_FORMAT(a.signdate, '%Y-%m') =#{vo.yearAndMonth}
+            </if>
         </where>
     </select>
 
@@ -2547,74 +2548,64 @@
             a.subPathner,
             sa.area_cname as "areaName",
             eic.namesimple as "companyName",
-            a.handlingReceivable  as "commissionFeevalue",
             a.partnerCompaniesId  as "partnerCompaniesId",
+            IFNULL(a.allAmount,0) as "commissionFeevalue",
             a.companyId as "companyId",
-            IFNULL(a.settleAmount ,0 )   as "settlementAmount",
-            a.unlicensedHandlingFee  as "noSettlementAmount",
-            IFNULL(a.unlicensedHandlingFee ,0 ) + IFNULL(a.settleAmount,0 ) as  "noInvoicCommissionFeevalue",
+            IFNULL(b.noSettHandlingFee,0) as "settlementAmount",
+            IFNULL(a.allAmount,0) - IFNULL( b.settAmount,0)  as "noSettlementAmount",
+            (IFNULL(a.allAmount,0) - IFNULL( b.settAmount,0)) +IFNULL(b.noSettHandlingFee,0) as  "noInvoicCommissionFeevalue",
             "手续费" as  "isHand",
-            IFNULL(a.handlingReceivable ,0 ) - IFNULL((IFNULL(a.unlicensedHandlingFee ,0 ) + IFNULL(a.settleAmount,0 )),0 ) as  "readyCommissionFeevalue"
+            IFNULL( b.settAmount,0)  as "readyCommissionFeevalue"
+
         FROM
-            (SELECT
-                 SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
-                 a.company_id as "companyId",
-                 a.partner_companies_id as "partnerCompaniesId",
-                 sum( a.commission_feevalue ) as "handlingReceivable",
-                 SUM( CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END ) AS "unlicensedHandlingFee",
-                 MAX(b.noSettHandlingFee) AS "settleAmount"
-             FROM
-                 ins_ply_income a
-                     LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
-                     LEFT JOIN (
-                     SELECT
-                         sum(a.commission_feevalue)  as "invoicAmount",
-                         IFNULL(sum(a.commission_feevalue) ,0 ) - IFNULL(max(b.settlementAmount) ,0 ) as  "noSettHandlingFee",
-                         a.signdate,
-                         a.task_id as "taskId" ,
-                        a.partner_companies_id  as "subPathner"
-                     FROM
-                         ins_ply_income a
-                             LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
-                             LEFT JOIN (
-                             select sum(settlement_amount) as "settlementAmount", a.task_id  as "taskId" from settlement_documentary_fees   a
-                             <where>
-                                 a.task_id IS NOT NULL
-                                 and a.settlement_status ='2'
-                                 <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
-                                     and a.handling_fees_status =#{vo.isNoCar}
-                                 </if>
-                             </where>
-                             GROUP BY  a.task_id
-                         ) b  on  a.task_id=b.taskId
-                     <where>
-                         pa.agreement_type = '2'
-                         AND a.is_not_documentary = '0'
-                         AND a.task_id  is not  null
-                         <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
-                             AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
-                         </if>
-                         <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
-                             and a.is_not_car =#{vo.isNoCar}
-                         </if>
-                     </where>
-                     GROUP BY
-                         a.task_id , a.signdate,a.partner_companies_id
-                 ) b  on  b.subPathner = a.partner_companies_id
-             <where>
-                 pa.agreement_type = '2'
-                 AND a.is_not_documentary = '0'
-                 <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
-                     AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
-                 </if>
-                 <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
-                     and a.is_not_car =#{vo.isNoCar}
-                 </if>
-             </where>
-             GROUP BY
-        a.partner_companies_id ,a.company_id) a
-        LEFT JOIN esm_ins_company  eic  on eic.id = a.companyId
-        LEFT JOIN sys_area  sa  on sa.area_code = a.subPathner
+            (
+                SELECT
+                    SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
+                    a.company_id AS "companyId",
+                    a.partner_companies_id AS "partnerCompaniesId" ,
+                    sum(a.commission_feevalue)   as "allAmount"
+                FROM
+                    ins_ply_income a
+                        LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
+                <where>
+                    pa.agreement_type = '2'
+                    AND a.is_not_documentary = '0'
+                    <if test="vo.isNoCar  != null  and vo.isNoCar !='' ">
+                      and   a.is_not_car =#{vo.isNoCar}
+                    </if>
+                    <if test="vo.yearAndMonth !=null  and  vo.yearAndMonth != ''">
+                      and DATE_FORMAT( a.signdate, '%Y-%m' ) =#{vo.yearAndMonth}
+                    </if>
+                </where>
+                GROUP BY
+                    a.partner_companies_id,
+                    a.company_id
+            ) a
+                LEFT JOIN (
+                SELECT
+                    sum( a.total_amount ) AS "invoicAmount",
+                    sum( a.remaining_amount ) AS "noSettHandlingFee",
+                    sum( a.settlement_amount ) AS "settAmount",
+                    a.task_id AS "taskId",
+                    DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigne",
+                    a.partner_companies_id AS "subPathner"
+                FROM
+                    sys_insurance_handling_settlement_month a
+                <where>
+                    <if test="vo.isNoCar  != null  and vo.isNoCar !='' ">
+                        and   a.is_not_car =#{vo.isNoCar}
+                    </if>
+                    <if test="vo.yearAndMonth !=null  and  vo.yearAndMonth != ''">
+                        and  DATE_FORMAT( a.signing_time, '%Y-%m' ) =#{vo.yearAndMonth}
+                    </if>
+                </where>
+                GROUP BY
+                    a.partner_companies_id,
+                    DATE_FORMAT( a.signing_time, '%Y-%m' ),
+                    a.task_id
+            ) b ON b.subPathner = a.partnerCompaniesId
+                LEFT JOIN esm_ins_company  eic  on eic.id = a.companyId
+                LEFT JOIN sys_area  sa  on sa.area_code = a.subPathner
     </select>
 
 
@@ -2642,10 +2633,10 @@
                 FROM
                     settlement_documentary_fees a
                 <where>
-                    a.settlement_sum_id IS NOT NULL
+                    a.handling_fees_status  ='1'
                     AND settlement_status = '1'
-                    <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
-                        AND  a.signing_time  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+                    <if test="vo.yearAndMonth !=null  and  vo.yearAndMonth != ''">
+                        and  DATE_FORMAT( a.signing_time, '%Y-%m' ) =#{vo.yearAndMonth}
                     </if>
                     <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
                         and a.is_not_car =#{vo.isNoCar}
@@ -2659,8 +2650,8 @@
         <where>
             pa.agreement_type = '2'
             AND a.is_not_documentary = '1'
-            <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
-                AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+            <if test="vo.yearAndMonth !=null  and  vo.yearAndMonth != ''">
+                and  DATE_FORMAT( a.signdate, '%Y-%m' ) =#{vo.yearAndMonth}
             </if>
             <if test="vo.isNoCar !=null  and  vo.isNoCar  !=''">
                 and a.is_not_car =#{vo.isNoCar}
@@ -2681,7 +2672,8 @@
             SUM(a.commission_feevalue) AS commissionFeevalue,
             SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
             SUM(CASE WHEN a.handling_fees_status = '1' THEN a.commission_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
-            SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noInvoicCommissionFeevalue"
+            SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noInvoicCommissionFeevalue",
+            SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noSettlementAmount"
         FROM
             ins_ply_income a
                 LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
@@ -2689,7 +2681,6 @@
                 LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
         <where>
             pa.agreement_type = '1'
-            AND a.is_not_documentary = '1'
             <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
                 AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
             </if>
@@ -2711,7 +2702,8 @@
             SUM(a.other_feevalue) AS commissionFeevalue,
             SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
             SUM(CASE WHEN a.handling_fees_status = '1' THEN a.other_feevalue ELSE 0 END) AS "readyCommissionFeevalue",
-            SUM(CASE WHEN a.handling_fees_status = '0' THEN a.other_feevalue ELSE 0 END) AS "noInvoicCommissionFeevalue"
+            SUM(CASE WHEN a.handling_fees_status = '0' THEN a.other_feevalue ELSE 0 END) AS "noInvoicCommissionFeevalue",
+            SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noSettlementAmount"
         FROM
             ins_ply_income a
                 LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
@@ -2738,7 +2730,8 @@
             SUM(a.all_fee_value) AS commissionFeevalue,
             SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
             SUM(CASE WHEN a.handling_fees_status = '1' THEN a.all_fee_value ELSE 0 END) AS "readyCommissionFeevalue",
-            SUM(CASE WHEN a.handling_fees_status = '0' THEN a.all_fee_value ELSE 0 END) AS "noInvoicCommissionFeevalue"
+            SUM(CASE WHEN a.handling_fees_status = '0' THEN a.all_fee_value ELSE 0 END) AS "noInvoicCommissionFeevalue",
+            SUM(CASE WHEN a.handling_fees_status = '0' THEN a.commission_feevalue ELSE 0 END) AS "noSettlementAmount"
         FROM
             ins_ply_income a
                 LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
@@ -2763,73 +2756,94 @@
 
     <select id="queryPrivateCar" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesVo">
         SELECT
-            DATE_FORMAT( a.signdate, '%Y-%m' )  as "yearAndMonth" ,
-            sum(a.all_fee_value)  as "commissionFeevalue",
-            IFNULL(max(b.readyCommissionFeevalue),0) + IFNULL(max(c.readyCommissionFeevalue1),0)  as  "noInvoicCommissionFeevalue",
-            sum(a.all_fee_value) -(IFNULL(max(b.readyCommissionFeevalue),0) + IFNULL(max(c.readyCommissionFeevalue1),0)) as "readyCommissionFeevalue",
-            (IFNULL(max(b.inSettlementAmount),0) -IFNULL(sum(b.readyCommissionFeevalue),0)) +IFNULL(max(c.settlementAmount),0)  as "settlementAmount",
-            IFNULL(max(c.noInvoicCommissionFeevalue),0)  + ((SUM( CASE WHEN a.handling_fees_status = '0' and a.is_not_documentary ='0' THEN a.all_fee_value ELSE 0 END ))) as "noSettlementAmount"
+            a.subSigndate as "yearAndMonth",
+            a.allAmount as "commissionFeevalue",
+            IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0) as "noInvoicCommissionFeevalue",
+            IFNULL(b.remainingAmount,0) +IFNULL(c.invoicNotOther,0) as "settlementAmount",
+            (a.allAmount-(IFNULL(b.invoicComm,0) + IFNULL(c.otherInvoic,0)))  as "noSettlementAmount",
+            a.allAmount-(IFNULL(c.settAmountOther,0) +IFNULL(b.settCommAmount ,0)) as "readyCommissionFeevalue"
         FROM
-            ins_ply_income a
-                LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
-                left join (
+            (
                 SELECT
-                    SUM( CASE WHEN settlement_status = '2' THEN a.settlement_amount ELSE 0 END )  as "readyCommissionFeevalue",
-                    SUM( CASE WHEN settlement_status = '1' THEN a.settlement_amount ELSE 0 END )  as "inSettlementAmount",
-                    a.task_id AS "taskId"
+                    DATE_FORMAT( a.signdate, '%Y-%m' ) AS subSigndate,
+                    IFNULL( sum( a.commission_feevalue ), 0 ) + IFNULL( sum( a.other_feevalue ), 0 ) AS "allAmount"
                 FROM
-                    settlement_documentary_fees a
+                    ins_ply_income a
+                        LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
                 <where>
-                    a.task_id IS NOT NULL
+                    pa.agreement_type = '2'
                     <if test="vo.isNotCar !=null  and  vo.isNotCar  !=''">
                         and a.is_not_car =#{vo.isNotCar}
                     </if>
                 </where>
                 GROUP BY
-                    a.task_id
-            )  b   on  b .taskId =a.task_id
-                left  join (
+                    DATE_FORMAT( a.signdate, '%Y-%m' )
+            ) a
+                LEFT JOIN (
                 SELECT
-                    DATE_FORMAT( a.signing_time, '%Y-%m' ) as "singDateYear",
-                    sum( a.invoiced_settled_amount ) AS "readyCommissionFeevalue1",
-                    sum( a.Invoiced_not_settled_amount ) AS "settlementAmount",
-                    SUM( CASE WHEN settlement_status = '1' THEN a.settlement_amount ELSE 0 END )  as "invoiceAmount",
-                    IFNULL(sum(b.otherallFeeValue),0) -sum( a.invoiced_settled_amount ) as "noInvoicCommissionFeevalue",
-                    IFNULL(sum(b.otherallFeeValue),0) -sum( a.invoiced_settled_amount ) - SUM( CASE WHEN settlement_status = '1' THEN a.settlement_amount ELSE 0 END ) as "noSettlementAmount"
+                    DATE_FORMAT( a.signing_time, '%Y-%m' ) AS "subSigndate",
+                    sum( a.settlement_amount ) AS "settCommAmount",
+                    sum(a.remaining_amount) as "remainingAmount",
+                    sum(a.total_amount) as "invoicComm"
                 FROM
-                    settlement_documentary_fees a
-                        left join  (
-                        select sum(a.all_fee_value) as "otherallFeeValue", DATE_FORMAT( a.signdate, '%Y-%m' ) as "singDateYear"  from  ins_ply_income a
-                        LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
-                        <where>
-                            pa.agreement_type= '2'
-                            and a.is_not_documentary='1'
-                            <if test="vo.isNotCar !=null  and  vo.isNotCar  !=''">
-                                and a.is_not_car =#{vo.isNotCar}
-                            </if>
-                            <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
-                                AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
-                            </if>
-                        </where>
-
-                        GROUP BY DATE_FORMAT( a.signdate, '%Y-%m' )
-                    )  b  on b.singDateYear = DATE_FORMAT( a.signing_time, '%Y-%m' )
+                    sys_insurance_handling_settlement_month a
                 <where>
-                    a.settlement_sum_id IS NOT NULL
-                    AND settlement_status = '1'
+                    1=1
+                    <if test="vo.isNotCar !=null  and  vo.isNotCar  !=''">
+                        and a.is_not_car =#{vo.isNotCar}
+                    </if>
                 </where>
-                GROUP BY DATE_FORMAT( a.signing_time, '%Y-%m' )
-            )  c  on  c.singDateYear=DATE_FORMAT( a.signdate, '%Y-%m' )
+                GROUP BY
+                    DATE_FORMAT( a.signing_time, '%Y-%m' )
+            ) b ON a.subSigndate = b.subSigndate
+                left  join  (
+                select DATE_FORMAT( a.signing_time, '%Y-%m' ) as "subSigndate" ,  sum(settlement_amount) as "otherInvoic", sum(invoiced_settled_amount) as "settAmountOther", sum(Invoiced_not_settled_amount) as "invoicNotOther"
+                from
+                    settlement_documentary_fees  a
+                where a.settlement_status='1'
+                  and handling_fees_status ='1'
+                GROUP BY 	DATE_FORMAT( a.signing_time, '%Y-%m' )
+            )  c  on c.subSigndate=a.subSigndate
+    </select>
+
+    <select id="queryDateByTypeMonthSumAmount" resultType="java.math.BigDecimal">
+        SELECT
+        SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ))
+        FROM
+        ins_ply_income a
+        LEFT JOIN
+        ptl_agreement pa ON pa.id = a.agreement_id
         <where>
-            pa.agreement_type ='2'
-            <if test="vo.isNotCar !=null  and  vo.isNotCar  !=''">
-                and a.is_not_car =#{vo.isNotCar}
+            <if test="vo.type !=null  and  vo.type  !=''">
+                and pa.agreement_type =#{vo.type}
+            </if>
+            <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
+                AND  a.create_time  BETWEEN #{vo.beginDate} AND #{vo.endDate}
+            </if>
+        </where>
+    </select>
+    <select id="queryDateByTypeByMonth"
+            resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesAllMonthVo">
+        SELECT
+        SUM(IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 )) AS ysSumAmount,
+        SUM(CASE WHEN a.handling_fees_status = '0' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END ) AS "yisSumAmount",
+        SUM(CASE WHEN a.handling_fees_status = '1' THEN IFNULL(a.commission_feevalue ,0 ) + IFNULL(a.other_feevalue ,0 ) ELSE 0 END) AS "wsSumAmount"
+        FROM
+        ins_ply_income a
+        LEFT JOIN
+        ptl_agreement pa ON pa.id = a.agreement_id
+        <where>
+            1=1
+            <if test="vo.type !=null  and  vo.type  !=''">
+                and pa.agreement_type =#{vo.type}
             </if>
             <if test="vo.beginDate  != null  and  vo.beginDate!=''  and vo.endDate  != null  and  vo.endDate!=''">
                 AND  a.signdate  BETWEEN #{vo.beginDate} AND #{vo.endDate}
             </if>
+            <if test="vo.yearAndMonth  != null  and  vo.yearAndMonth!=''">
+                AND   DATE_FORMAT(a.signdate, '%Y-%m') =#{vo.yearAndMonth}
+            </if>
         </where>
-        GROUP BY DATE_FORMAT( a.signdate, '%Y-%m' )
     </select>
     <select id="getProfitAnalysisQueryList" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
         SELECT
@@ -3039,4 +3053,61 @@
         </where>
         group by   a.task_id  , DATE_FORMAT( a.signdate, '%Y-%m' )
     </select>
+
+    <select id="queryDateByTypePt"  resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesVo">
+        SELECT IFNULL(a.signingTime, 0)     as "yearAndMonth",
+               IFNULL(a.allAmount, 0)       as "commissionFeevalue",
+               IFNULL(c.settAmount, 0)      as "noInvoicCommissionFeevalue",
+               IFNULL(b.notInvoicAmount, 0) as "noSettlementAmount",
+               IFNULL(c.settAmount, 0)      as "readyCommissionFeevalue"
+        FROM (SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "allAmount",
+                     DATE_FORMAT(a.signdate, '%Y-%m')                   as "signingTime"
+              FROM ins_ply_income a
+                       LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
+              WHERE pa.agreement_type = '1'
+              GROUP BY DATE_FORMAT(a.signdate, '%Y-%m')) a
+                 left join (SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "notInvoicAmount",
+                                   DATE_FORMAT(a.signdate, '%Y-%m')                   as "signingTime"
+                            FROM ins_ply_income a
+                                     LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
+                            WHERE pa.agreement_type = '1'
+                              and a.handling_fees_status = '0'
+                            GROUP BY DATE_FORMAT(a.signdate, '%Y-%m')) b on a.signingTime = b.signingTime
+                 left join (SELECT sum(a.commission_feevalue) + sum(a.other_feevalue) AS "settAmount",
+                                   DATE_FORMAT(a.signdate, '%Y-%m')                   as "signingTime"
+                            FROM ins_ply_income a
+                                     LEFT JOIN ptl_agreement pa ON pa.id = a.agreement_id
+                            WHERE pa.agreement_type = '1'
+                              and a.handling_fees_status = '1'
+                            GROUP BY DATE_FORMAT(a.signdate, '%Y-%m')) c on c.signingTime = a.signingTime
+    </select>
+    <select id="getPatherId" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
+        SELECT
+        sa.area_cname as "areaName",
+        eic.namesimple as "companyName",
+        SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
+        a.company_id AS "companyId",
+        a.partner_companies_id AS "partnerCompaniesId"
+        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.company_id
+        LEFT JOIN sys_area  sa  on sa.area_code = SUBSTRING( a.partner_companies_id, 6, 11 )
+        <where>
+            <if test="vo.type !=null  and  vo.type!=''">
+                pa.agreement_type =#{vo.type}
+            </if>
+            <if test="vo.isNoCar  != null  and vo.isNoCar !='' ">
+                and   a.is_not_car =#{vo.isNoCar}
+            </if>
+            <if test="vo.yearAndMonth !=null  and  vo.yearAndMonth != ''">
+                and DATE_FORMAT( a.signdate, '%Y-%m' ) =#{vo.yearAndMonth}
+            </if>
+        </where>
+        GROUP BY
+        a.partner_companies_id,
+        a.company_id,
+        eic.namesimple,
+        sa.area_cname
+    </select>
 </mapper>