|
@@ -2838,4 +2838,212 @@
|
|
|
</where>
|
|
</where>
|
|
|
GROUP BY DATE_FORMAT( a.signdate, '%Y-%m' )
|
|
GROUP BY DATE_FORMAT( a.signdate, '%Y-%m' )
|
|
|
</select>
|
|
</select>
|
|
|
|
|
+ <select id="getProfitAnalysisQueryList" resultType="com.ydtech.modules.admin.model.report.profitAnalysis.ProfitAnalysisDto">
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ a.signingTime as "signingTime",
|
|
|
|
|
+ a.sumpremium as "sumpremium",
|
|
|
|
|
+ b.allAmount as "sumcount",
|
|
|
|
|
+ d.settlement as "meet",
|
|
|
|
|
+ c.ActualPayment as "paid",
|
|
|
|
|
+ ifnull(d.settlement,0) - IFNULL(c.ActualPayment,0) as "unpaid",
|
|
|
|
|
+ IFNULL( b.allAmount,0)- IFNULL (d.settlement,0) as "grossProfit",
|
|
|
|
|
+ e.applyAmount as "laborCost",
|
|
|
|
|
+ f.applyAmount as "fixedCost",
|
|
|
|
|
+ j.applyAmount as "variableCost",
|
|
|
|
|
+ (IFNULL (b.allAmount,0) - IFNULL(d.settlement,0) ) -( IFNULL(e.applyAmount,0) + IFNULL(f.applyAmount,0) + IFNULL(j.applyAmount,0) ) as "operatingProfit",
|
|
|
|
|
+ g.applyAmount as "税费",
|
|
|
|
|
+ (IFNULL(b.allAmount,0)- IFNULL(d.settlement,0) ) -( IFNULL(e.applyAmount,0) + IFNULL(f.applyAmount,0) + IFNULL(j.applyAmount,0) ) - IFNULL(g.applyAmount,0) as "netProfit"
|
|
|
|
|
+ FROM
|
|
|
|
|
+ (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ sum( iac.sumpremium ) as "sumpremium",
|
|
|
|
|
+ DATE_FORMAT( iac.signing_time, '%Y-%m' ) AS "signingTime"
|
|
|
|
|
+ FROM
|
|
|
|
|
+ `ins_fee_audit` ifa
|
|
|
|
|
+ LEFT JOIN ins_area_company iac ON iac.id = ifa.ins_order_no
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ ifa.auditstatus = '1'
|
|
|
|
|
+ AND iac.signing_time IS NOT NULL
|
|
|
|
|
+ GROUP BY
|
|
|
|
|
+ DATE_FORMAT( iac.signing_time, '%Y-%m' )
|
|
|
|
|
+ ) a
|
|
|
|
|
+ LEFT JOIN (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ sum( ipi.commission_feevalue +ipi.other_feevalue ) as "allAmount",
|
|
|
|
|
+ DATE_FORMAT( ipi.signdate, '%Y-%m' ) AS "signingTime"
|
|
|
|
|
+ FROM
|
|
|
|
|
+ ins_ply_income ipi
|
|
|
|
|
+ GROUP BY
|
|
|
|
|
+ DATE_FORMAT( ipi.signdate, '%Y-%m' )
|
|
|
|
|
+ ) b ON a.signingTime = b.signingTime
|
|
|
|
|
+ left join (
|
|
|
|
|
+ select
|
|
|
|
|
+ sum(a.amount) as "ActualPayment",DATE_FORMAT( a.auditing_time, '%Y-%m' ) as "auditingTime"
|
|
|
|
|
+ from sys_amount_auditing a
|
|
|
|
|
+ left join sys_user_account_history b on a.id = b.auditiing_id
|
|
|
|
|
+ left join sys_user su on su.id =a.user_id
|
|
|
|
|
+ where a.auditing_status= '3'
|
|
|
|
|
+ GROUP BY DATE_FORMAT( a.auditing_time, '%Y-%m' )
|
|
|
|
|
+ ) c on c.auditingTime =a.signingTime
|
|
|
|
|
+ left join (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ sum(
|
|
|
|
|
+ ifo.jq_export_supervise_costs_premiums + ifo.sy_export_supervise_costs_premiums + ifo.no_export_supervise_costs_premiums + ifo.jq_export_other_costs_premiums + ifo.sy_export_other_costs_premiums + ifo.no_export_other_costs_premiums + ifo.first_detail_premiums + ifo.second_detail_premiums + ifo.third_detail_premiums
|
|
|
|
|
+ ) AS "settlement",
|
|
|
|
|
+ DATE_FORMAT( iac.signing_time, '%Y-%m' ) as "signingTime"
|
|
|
|
|
+ FROM
|
|
|
|
|
+ ins_fee_order_new ifo
|
|
|
|
|
+ LEFT JOIN ins_fee_audit ifa ON ifo.ins_order_no = ifa.ins_order_no
|
|
|
|
|
+ LEFT JOIN ins_area_company iac ON ifa.ins_order_no = iac.id
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ ifa.auditstatus = '1'
|
|
|
|
|
+ AND iac.orderstatus = '3'
|
|
|
|
|
+ GROUP BY
|
|
|
|
|
+ DATE_FORMAT( iac.signing_time, '%Y-%m' )
|
|
|
|
|
+ ) d on d.signingTime =a.signingTime
|
|
|
|
|
+ left join (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ sum(apply_amount) as "applyAmount",
|
|
|
|
|
+ DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
|
|
|
|
|
+ b.expenditureDetails
|
|
|
|
|
+ FROM
|
|
|
|
|
+ inv_account_operate a
|
|
|
|
|
+ left join (
|
|
|
|
|
+ select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
|
|
|
|
|
+ left join inv_account_expenses b on a.parent_id =b.expenses_id
|
|
|
|
|
+ where b.category is not null
|
|
|
|
|
+ ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ a.out_card_num IN (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ bank_card_num
|
|
|
|
|
+ FROM
|
|
|
|
|
+ inv_account_card iac
|
|
|
|
|
+ LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ ia.del_flag = '0'
|
|
|
|
|
+ AND ia.outer_flag LIKE concat( '%', '0', '%' )
|
|
|
|
|
+ )
|
|
|
|
|
+ AND a.revenue_outlay = '1'
|
|
|
|
|
+ AND a.del_flag = '0'
|
|
|
|
|
+ AND b.expenditureDetails = '1'
|
|
|
|
|
+ GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
|
|
|
|
|
+ ) e on e.createTime =a.signingTime
|
|
|
|
|
+ left join (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ sum(apply_amount) as "applyAmount",
|
|
|
|
|
+ DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
|
|
|
|
|
+ b.expenditureDetails
|
|
|
|
|
+ FROM
|
|
|
|
|
+ inv_account_operate a
|
|
|
|
|
+ left join (
|
|
|
|
|
+ select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
|
|
|
|
|
+ left join inv_account_expenses b on a.parent_id =b.expenses_id
|
|
|
|
|
+ where b.category is not null
|
|
|
|
|
+ ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ a.out_card_num IN (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ bank_card_num
|
|
|
|
|
+ FROM
|
|
|
|
|
+ inv_account_card iac
|
|
|
|
|
+ LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ ia.del_flag = '0'
|
|
|
|
|
+ AND ia.outer_flag LIKE concat( '%', '0', '%' )
|
|
|
|
|
+ )
|
|
|
|
|
+ AND a.revenue_outlay = '1'
|
|
|
|
|
+ AND a.del_flag = '0'
|
|
|
|
|
+ AND b.expenditureDetails = '2'
|
|
|
|
|
+ GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
|
|
|
|
|
+ ) f on f.createTime =a.signingTime
|
|
|
|
|
+ left join (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ sum(apply_amount) as "applyAmount",
|
|
|
|
|
+ DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
|
|
|
|
|
+ b.expenditureDetails
|
|
|
|
|
+ FROM
|
|
|
|
|
+ inv_account_operate a
|
|
|
|
|
+ left join (
|
|
|
|
|
+ select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
|
|
|
|
|
+ left join inv_account_expenses b on a.parent_id =b.expenses_id
|
|
|
|
|
+ where b.category is not null
|
|
|
|
|
+ ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ a.out_card_num IN (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ bank_card_num
|
|
|
|
|
+ FROM
|
|
|
|
|
+ inv_account_card iac
|
|
|
|
|
+ LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ ia.del_flag = '0'
|
|
|
|
|
+ AND ia.outer_flag LIKE concat( '%', '0', '%' )
|
|
|
|
|
+ )
|
|
|
|
|
+ AND a.revenue_outlay = '1'
|
|
|
|
|
+ AND a.del_flag = '0'
|
|
|
|
|
+ AND b.expenditureDetails = '3'
|
|
|
|
|
+ GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
|
|
|
|
|
+ ) j on j.createTime =a.signingTime
|
|
|
|
|
+ left join (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ sum(apply_amount) as "applyAmount",
|
|
|
|
|
+ DATE_FORMAT( a.create_time, '%Y-%m' ) as "createTime",
|
|
|
|
|
+ b.expenditureDetails
|
|
|
|
|
+ FROM
|
|
|
|
|
+ inv_account_operate a
|
|
|
|
|
+ left join (
|
|
|
|
|
+ select a.category as "aCategory",b. category as "bCategory",a.expenditure_details as "expenditureDetails" from inv_account_expenses a
|
|
|
|
|
+ left join inv_account_expenses b on a.parent_id =b.expenses_id
|
|
|
|
|
+ where b.category is not null
|
|
|
|
|
+ ) b on a.fund_use = b.bCategory and a.fund_fen = b.aCategory
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ a.out_card_num IN (
|
|
|
|
|
+ SELECT
|
|
|
|
|
+ bank_card_num
|
|
|
|
|
+ FROM
|
|
|
|
|
+ inv_account_card iac
|
|
|
|
|
+ LEFT JOIN inv_account ia ON iac.account_id = ia.account_id
|
|
|
|
|
+ WHERE
|
|
|
|
|
+ ia.del_flag = '0'
|
|
|
|
|
+ AND ia.outer_flag LIKE concat( '%', '0', '%' )
|
|
|
|
|
+ )
|
|
|
|
|
+ AND a.revenue_outlay = '1'
|
|
|
|
|
+ AND a.del_flag = '0'
|
|
|
|
|
+ AND b.expenditureDetails = '4'
|
|
|
|
|
+ GROUP BY DATE_FORMAT( a.create_time, '%Y-%m' ) , b.expenditureDetails
|
|
|
|
|
+ ) g on g.createTime =a.signingTime
|
|
|
|
|
+
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <select id="getInvociAmount" resultType="com.ydtech.modules.fnc.dto.InsuranceHandlingSettlementMonthDto" >
|
|
|
|
|
+ select
|
|
|
|
|
+ DATE_FORMAT( a.signdate, '%Y-%m' ) as "incomeSigningTime",
|
|
|
|
|
+ a.task_id as "taskId",
|
|
|
|
|
+ sum(a.commission_feevalue) as "totalAmount"
|
|
|
|
|
+ from ins_ply_income a
|
|
|
|
|
+ LEFT JOIN ptl_agreement pa on a.agreement_id = pa.id
|
|
|
|
|
+ LEFT JOIN sys_user su on su.id=a.user_id
|
|
|
|
|
+ LEFT JOIN sys_user su1 on su1.id=a.settlement_user_id
|
|
|
|
|
+ LEFT JOIN sys_user su2 on su2.id=a.update_user_id
|
|
|
|
|
+ LEFT JOIN ins_upload_files upf on a.settlement_image_id=upf.id
|
|
|
|
|
+ LEFT JOIN esm_ins_company eic on eic.id=a.partner_companies_id
|
|
|
|
|
+ LEFT JOIN sys_dept b on pa.dept_id=b.id
|
|
|
|
|
+ <where>
|
|
|
|
|
+ 1=1
|
|
|
|
|
+ <if test="vo.isNotCar !=null and vo.isNotCar !=''">
|
|
|
|
|
+ and a.is_not_car =#{vo.isNotCar}
|
|
|
|
|
+ </if>
|
|
|
|
|
+
|
|
|
|
|
+ <if test="vo.isNotDocumentary !=null and vo.isNotDocumentary !=''">
|
|
|
|
|
+ and a.is_not_documentary =#{vo.isNotDocumentary}
|
|
|
|
|
+ </if>
|
|
|
|
|
+
|
|
|
|
|
+ <if test="vo.taskId != null and vo.taskId != ''">
|
|
|
|
|
+ and a.task_id = #{vo.taskId}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ </where>
|
|
|
|
|
+ group by a.task_id , DATE_FORMAT( a.signdate, '%Y-%m' )
|
|
|
|
|
+ </select>
|
|
|
</mapper>
|
|
</mapper>
|