|
|
@@ -2451,6 +2451,9 @@
|
|
|
<if test="vo.type !=null and vo.type !=''">
|
|
|
and pa.agreement_type =#{vo.type}
|
|
|
</if>
|
|
|
+ <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.create_time BETWEEN #{vo.beginDate} AND #{vo.endDate}
|
|
|
</if>
|
|
|
@@ -2529,14 +2532,14 @@
|
|
|
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 "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
|
|
|
+ LEFT JOIN
|
|
|
ptl_agreement pa ON pa.id = a.agreement_id
|
|
|
- where
|
|
|
<where>
|
|
|
+ 1=1
|
|
|
<if test="vo.type !=null and vo.type !=''">
|
|
|
and pa.agreement_type =#{vo.type}
|
|
|
</if>
|
|
|
@@ -2545,11 +2548,294 @@
|
|
|
</if>
|
|
|
</where>
|
|
|
</select>
|
|
|
- <select id="queryDateByTypeByMonthList"
|
|
|
- resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
|
|
|
|
|
|
+ <select id="queryDateByTypeByMonthList" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
|
|
|
+ SELECT
|
|
|
+ a.subPathner,
|
|
|
+ sa.area_cname as "areaName",
|
|
|
+ eic.namesimple as "companyName",
|
|
|
+ a.handlingReceivable as "commissionFeevalue",
|
|
|
+ a.partnerCompaniesId as "partnerCompaniesId",
|
|
|
+ a.companyId as "companyId",
|
|
|
+ IFNULL(a.settleAmount ,0 ) as "settlementAmount",
|
|
|
+ a.unlicensedHandlingFee as "noSettlementAmount",
|
|
|
+ IFNULL(a.unlicensedHandlingFee ,0 ) + IFNULL(a.settleAmount,0 ) as "noInvoicCommissionFeevalue",
|
|
|
+ "手续费" as "isHand",
|
|
|
+ IFNULL(a.handlingReceivable ,0 ) - IFNULL((IFNULL(a.unlicensedHandlingFee ,0 ) + IFNULL(a.settleAmount,0 )),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>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="queryDateByTypeByMonthOtherList" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
|
|
|
+ SELECT
|
|
|
+ a.partner_companies_id,
|
|
|
+ sa.area_cname as "areaName",
|
|
|
+ eic.namesimple as "companyName",
|
|
|
+ sum(a.other_feevalue) as "commissionFeevalue",
|
|
|
+ IFNULL(max(b.invoicedSettledAmount) ,0 ) as "readyCommissionFeevalue",
|
|
|
+ sum(a.other_feevalue) -IFNULL(max(b.invoicedSettledAmount) ,0 ) as "noInvoicCommissionFeevalue",
|
|
|
+ IFNULL(max(b.invoicedNotSettledAmount) ,0 ) as "settlementAmount",
|
|
|
+ sum(a.other_feevalue) -IFNULL(max(b.invoicedSettledAmount) ,0 )-IFNULL(max(b.invoicedNotSettledAmount) ,0 ) as "noSettlementAmount",
|
|
|
+ SUBSTRING( a.partner_companies_id, 6, 11 ) AS "subPathner",
|
|
|
+ "跟单费" as "isHand",
|
|
|
+ a.company_id AS "companyId"
|
|
|
+ FROM
|
|
|
+ ins_ply_income a
|
|
|
+ LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
|
|
|
+ LEFT JOIN (
|
|
|
+ SELECT
|
|
|
+ a.partner_companies_id,
|
|
|
+ sum(a.invoiced_settled_amount) as "invoicedSettledAmount",
|
|
|
+ sum(a.Invoiced_not_settled_amount) as "invoicedNotSettledAmount"
|
|
|
+ FROM
|
|
|
+ settlement_documentary_fees a
|
|
|
+ <where>
|
|
|
+ a.settlement_sum_id IS NOT NULL
|
|
|
+ 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>
|
|
|
+ <if test="vo.isNoCar !=null and vo.isNoCar !=''">
|
|
|
+ and a.is_not_car =#{vo.isNoCar}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ a.partner_companies_id
|
|
|
+ ) b on b.partner_companies_id =a.partner_companies_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>
|
|
|
+ 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>
|
|
|
+ <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,sa.area_cname
|
|
|
+ </select>
|
|
|
+
|
|
|
+
|
|
|
+ <select id="queryPlatHanding" resultType="com.ydtech.modules.admin.model.report.financialReceivables.FinancialReceivablesMonthVo">
|
|
|
+ SELECT
|
|
|
+ 1 as orderNumber,
|
|
|
+ '手续费' AS isHand,
|
|
|
+ sa.area_cname AS areaName,
|
|
|
+ eic.namesimple AS companyName,
|
|
|
+ a.partner_companies_id AS partnerCompaniesId,
|
|
|
+ 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"
|
|
|
+ FROM
|
|
|
+ ins_ply_income a
|
|
|
+ LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
|
|
|
+ LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
|
|
|
+ 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>
|
|
|
+ <if test="vo.isNoCar !=null and vo.isNoCar !=''">
|
|
|
+ and a.is_not_car =#{vo.isNoCar}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ a.partner_companies_id, eic.namesimple, sa.area_cname
|
|
|
|
|
|
+ UNION ALL
|
|
|
|
|
|
+ SELECT
|
|
|
+ 2 as orderNumber,
|
|
|
+ '跟单费' AS isHand,
|
|
|
+ sa.area_cname AS areaName,
|
|
|
+ eic.namesimple AS companyName,
|
|
|
+ a.partner_companies_id AS partnerCompaniesId,
|
|
|
+ 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"
|
|
|
+ FROM
|
|
|
+ ins_ply_income a
|
|
|
+ LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
|
|
|
+ LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
|
|
|
+ LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
|
|
|
+ <where>
|
|
|
+ pa.agreement_type = '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>
|
|
|
+ <if test="vo.isNoCar !=null and vo.isNoCar !=''">
|
|
|
+ and a.is_not_car =#{vo.isNoCar}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ a.partner_companies_id, eic.namesimple, sa.area_cname
|
|
|
+ UNION ALL
|
|
|
+ SELECT
|
|
|
+ 3 as orderNumber,
|
|
|
+ '合计' AS isHand,
|
|
|
+ sa.area_cname AS areaName,
|
|
|
+ eic.namesimple AS companyName,
|
|
|
+ a.partner_companies_id AS partnerCompaniesId,
|
|
|
+ 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"
|
|
|
+ FROM
|
|
|
+ ins_ply_income a
|
|
|
+ LEFT JOIN ptl_agreement pa ON a.agreement_id = pa.id
|
|
|
+ LEFT JOIN sys_area sa ON sa.area_code = SUBSTRING(a.partner_companies_id, 6, 11)
|
|
|
+ LEFT JOIN esm_ins_company eic ON eic.id = a.company_id
|
|
|
+ <where>
|
|
|
+ pa.agreement_type = '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>
|
|
|
+ <if test="vo.isNoCar !=null and vo.isNoCar !=''">
|
|
|
+ and a.is_not_car =#{vo.isNoCar}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ GROUP BY
|
|
|
+ a.partner_companies_id, eic.namesimple, sa.area_cname
|
|
|
+ ORDER BY
|
|
|
+ companyName,
|
|
|
+ areaName,
|
|
|
+ orderNumber;
|
|
|
+ </select>
|
|
|
|
|
|
+ <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"
|
|
|
+ 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"
|
|
|
+ FROM
|
|
|
+ settlement_documentary_fees a
|
|
|
+ <where>
|
|
|
+ a.task_id IS NOT NULL
|
|
|
+ <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 (
|
|
|
+ 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"
|
|
|
+ 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' )
|
|
|
+ <where>
|
|
|
+ a.settlement_sum_id IS NOT NULL
|
|
|
+ AND settlement_status = '1'
|
|
|
+ </where>
|
|
|
+ GROUP BY DATE_FORMAT( a.signing_time, '%Y-%m' )
|
|
|
+ ) c on c.singDateYear=DATE_FORMAT( a.signdate, '%Y-%m' )
|
|
|
+ <where>
|
|
|
+ pa.agreement_type ='2'
|
|
|
+ <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' )
|
|
|
</select>
|
|
|
</mapper>
|