|
@@ -0,0 +1,237 @@
|
|
|
+<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
+<!--
|
|
|
+这个文件是自动生成的。
|
|
|
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
|
|
|
+-->
|
|
|
+<mapper namespace="com.ym.mec.biz.dal.dao.OperatingReportNewDao">
|
|
|
+
|
|
|
+ <resultMap type="com.ym.mec.biz.dal.entity.OperatingReportNew" id="OperatingReportNew">
|
|
|
+ <result column="id_" property="id" />
|
|
|
+ <result column="principal_" property="principal" />
|
|
|
+ <result column="organ_name_" property="organName" />
|
|
|
+ <result column="organ_id_" property="organId" />
|
|
|
+ <result column="sale_amount_" property="saleAmount" />
|
|
|
+ <result column="service_amount_" property="serviceAmount" />
|
|
|
+ <result column="business_refund_" property="businessRefund" />
|
|
|
+ <result column="total_income_" property="totalIncome" />
|
|
|
+ <result column="sale_cost_" property="saleCost" />
|
|
|
+ <result column="fixed_costs_" property="fixedCosts" />
|
|
|
+ <result column="variable_costs_" property="variableCosts" />
|
|
|
+ <result column="internal_settlement_" property="internalSettlement" />
|
|
|
+ <result column="total_cost_" property="totalCost" />
|
|
|
+ <result column="quasi_discretionary_profit_" property="quasiDiscretionaryProfit" />
|
|
|
+ <result column="prepaid_fee_" property="prepaidFee" />
|
|
|
+ <result column="prepayments_" property="prepayments" />
|
|
|
+ <result column="receivables_" property="receivables" />
|
|
|
+ <result column="payable_" property="payable" />
|
|
|
+ <result column="month_" property="month" />
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 根据主键查询一条记录 -->
|
|
|
+ <select id="get" resultMap="OperatingReportNew" >
|
|
|
+ SELECT * FROM operating_report_new WHERE id_ = #{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 全查询 -->
|
|
|
+ <select id="findAll" resultMap="OperatingReportNew">
|
|
|
+ SELECT * FROM operating_report_new ORDER BY id_
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 向数据库增加一条记录 -->
|
|
|
+ <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.OperatingReportNew" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
|
|
+ INSERT INTO operating_report_new (id_,principal_,organ_name_,sale_amount_,service_amount_,business_refund_,total_income_,sale_cost_,fixed_costs_,variable_costs_,internal_settlement_,total_cost_,quasi_discretionary_profit_,prepaid_fee_,prepayments_,receivables_,payable_,month_)
|
|
|
+ VALUES(#{id},#{principal},#{organName},#{saleAmount},#{serviceAmount},#{businessRefund},#{totalIncome},#{saleCost},#{fixedCosts},#{variableCosts},#{internalSettlement},#{totalCost},#{quasiDiscretionaryProfit},#{prepaidFee},#{prepayments},#{receivables},#{payable},#{month})
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <!-- 根据主键查询一条记录 -->
|
|
|
+ <update id="update" parameterType="com.ym.mec.biz.dal.entity.OperatingReportNew">
|
|
|
+ UPDATE operating_report_new <set>
|
|
|
+ <if test="saleAmount != null">
|
|
|
+ sale_amount_ = #{saleAmount},
|
|
|
+ </if>
|
|
|
+ <if test="prepaidFee != null">
|
|
|
+ prepaid_fee_ = #{prepaidFee},
|
|
|
+ </if>
|
|
|
+ <if test="serviceAmount != null">
|
|
|
+ service_amount_ = #{serviceAmount},
|
|
|
+ </if>
|
|
|
+ <if test="payable != null">
|
|
|
+ payable_ = #{payable},
|
|
|
+ </if>
|
|
|
+ <if test="businessRefund != null">
|
|
|
+ business_refund_ = #{businessRefund},
|
|
|
+ </if>
|
|
|
+ <if test="totalCost != null">
|
|
|
+ total_cost_ = #{totalCost},
|
|
|
+ </if>
|
|
|
+ <if test="totalIncome != null">
|
|
|
+ total_income_ = #{totalIncome},
|
|
|
+ </if>
|
|
|
+ <if test="quasiDiscretionaryProfit != null">
|
|
|
+ quasi_discretionary_profit_ = #{quasiDiscretionaryProfit},
|
|
|
+ </if>
|
|
|
+ <if test="fixedCosts != null">
|
|
|
+ fixed_costs_ = #{fixedCosts},
|
|
|
+ </if>
|
|
|
+ <if test="internalSettlement != null">
|
|
|
+ internal_settlement_ = #{internalSettlement},
|
|
|
+ </if>
|
|
|
+ <if test="prepayments != null">
|
|
|
+ prepayments_ = #{prepayments},
|
|
|
+ </if>
|
|
|
+ <if test="month != null">
|
|
|
+ month_ = #{month},
|
|
|
+ </if>
|
|
|
+ <if test="variableCosts != null">
|
|
|
+ variable_costs_ = #{variableCosts},
|
|
|
+ </if>
|
|
|
+ <if test="organName != null">
|
|
|
+ organ_name_ = #{organName},
|
|
|
+ </if>
|
|
|
+ <if test="saleCost != null">
|
|
|
+ sale_cost_ = #{saleCost},
|
|
|
+ </if>
|
|
|
+ <if test="receivables != null">
|
|
|
+ receivables_ = #{receivables},
|
|
|
+ </if>
|
|
|
+ <if test="principal != null">
|
|
|
+ principal_ = #{principal},
|
|
|
+ </if>
|
|
|
+ </set> WHERE id_ = #{id}
|
|
|
+ </update>
|
|
|
+ <update id="initCloudStartTime">
|
|
|
+ update operating_report_cloud orc
|
|
|
+ left join (
|
|
|
+ select orc.calender_id_,MIN(cs.class_date_) start_date_ from operating_report_cloud orc
|
|
|
+ LEFT JOIN cloud_teacher_free_course ctf ON ctf.calender_id_ = orc.calender_id_
|
|
|
+ LEFT JOIN course_schedule cs ON cs.id_ = ctf.course_id_
|
|
|
+ where orc.month_flag_ = false AND orc.settlement_flag_ = false AND orc.start_date_ IS NULL
|
|
|
+ AND cs.class_date_ <= #{lastDay}
|
|
|
+ group by orc.calender_id_) mc ON orc.calender_id_ = mc.calender_id_
|
|
|
+ LEFT JOIN (select calender_id_,DATE_ADD(
|
|
|
+ DATE_ADD(create_time_, interval CASE WHEN period_ = 'YEAR_HALF' THEN 6
|
|
|
+ WHEN period_ = 'YEAR' THEN 12
|
|
|
+ WHEN period_ = 'QUARTERLY' THEN 3 ELSE num_ END MONTH),interval 1 DAY) end_date_
|
|
|
+ from music_group_payment_calender_member order by id_ DESC) mgpcm
|
|
|
+ ON mc.calender_id_ = mgpcm.calender_id_
|
|
|
+ set orc.start_date_ = mc.start_date_,orc.end_date_ = mgpcm.end_date_
|
|
|
+ where orc.calender_id_ = mc.calender_id_
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <!-- 根据主键删除一条记录 -->
|
|
|
+ <delete id="delete" >
|
|
|
+ DELETE FROM operating_report_new WHERE id_ = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <!-- 分页查询 -->
|
|
|
+ <select id="queryPage" resultMap="OperatingReportNew" parameterType="map">
|
|
|
+ SELECT * FROM operating_report_new ORDER BY id_ <include refid="global.limit"/>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询当前表的总记录数 -->
|
|
|
+ <select id="queryCount" resultType="int">
|
|
|
+ SELECT COUNT(*) FROM operating_report_new
|
|
|
+ </select>
|
|
|
+ <select id="initOperatingReport" resultMap="OperatingReportNew">
|
|
|
+ select id_ organ_id_,name_ organ_name_ from organization where del_flag_ = 0 and tenant_id_ = 1
|
|
|
+ </select>
|
|
|
+ <select id="sumSellAmount" resultMap="OperatingReportNew">
|
|
|
+ select so.organ_id_,SUM(so.actual_amount_) sale_amount_,SUM(so.sell_cost_) sale_cost_ from sell_order so
|
|
|
+ left join student_payment_order spo ON spo.order_no_ = so.order_no_
|
|
|
+ left join music_group mg ON mg.id_ = spo.music_group_id_ AND spo.group_type_ = 'MUSIC'
|
|
|
+ LEFT JOIN organization o ON o.id_ = so.organ_id_
|
|
|
+ where (mg.musical_instruments_provide_status_ = 1 AND mg.musical_instruments_provide_date_ = #{month}) OR (DATE_FORMAT(so.create_ime_,'%Y-%m') = #{month} AND (mg.musical_instruments_provide_status_ IS NULL OR mg.musical_instruments_provide_status_ = 1))
|
|
|
+ group by so.organ_id_
|
|
|
+ </select>
|
|
|
+ <select id="sumCloudCourseAmount" resultType="java.util.Map">
|
|
|
+ SELECT cs.organ_id_ 'key',SUM(ctf.cost_) 'value' FROM cloud_teacher_free_course ctf
|
|
|
+ LEFT JOIN course_schedule cs ON cs.id_ = ctf.course_id_
|
|
|
+ where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.class_date_ BETWEEN #{firstDay} AND #{lastDay} group by cs.organ_id_;
|
|
|
+ </select>
|
|
|
+ <select id="sumCourseAmount" resultType="java.util.Map">
|
|
|
+ SELECT cs.organ_id_ 'key',SUM(cssp.actual_price_) 'value' FROM course_schedule cs
|
|
|
+ LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
|
|
|
+ left join organization o ON o.id_ = cs.organ_id_
|
|
|
+ where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.class_date_ BETWEEN #{firstDay} AND #{lastDay} group by cs.organ_id_;
|
|
|
+ </select>
|
|
|
+ <select id="sumPersonalCloudAmount" resultType="java.util.Map">
|
|
|
+ select cto.organ_id_ 'key',TRUNCATE(SUM(amount_ / TIMESTAMPDIFF(DAY,start_time_,end_time_) *
|
|
|
+ TIMESTAMPDIFF(DAY,CASE WHEN start_time_ < #{firstDay} THEN #{firstDay} ELSE DATE_FORMAT(start_time_,'%Y-%m-%d') END,
|
|
|
+ CASE WHEN end_time_ > #{month} THEN #{lastDay} ELSE DATE_FORMAT(end_time_,'%Y-%m-%d') END)),2) 'value'
|
|
|
+ from cloud_teacher_order cto
|
|
|
+ where music_group_id_ IS NULL AND amount_ > 0 AND #{month} BETWEEN DATE_FORMAT(start_time_,'%Y-%m') AND DATE_FORMAT(end_time_,'%Y-%m') group by cto.organ_id_;
|
|
|
+ </select>
|
|
|
+ <select id="sumGroupCloudAmount" resultType="java.util.Map">
|
|
|
+ select orc.organ_id_ 'key',TRUNCATE(SUM(orc.cloud_price_ / TIMESTAMPDIFF(DAY,orc.start_date_,orc.end_date_) *
|
|
|
+ TIMESTAMPDIFF(DAY,CASE WHEN orc.start_date_ < #{firstDay} THEN #{firstDay} ELSE orc.start_date_ END,
|
|
|
+ CASE WHEN orc.end_date_ > #{month} THEN #{lastDay} ELSE orc.end_date_ END)),2) 'value' from operating_report_cloud orc
|
|
|
+ where #{month} BETWEEN DATE_FORMAT(orc.start_date_,'%Y-%m') AND DATE_FORMAT(orc.end_date_,'%Y-%m') AND orc.start_date_ IS NOT NULL;
|
|
|
+ </select>
|
|
|
+ <select id="sumRefundAmount" resultType="java.util.Map">
|
|
|
+ select suc.organ_id_ 'key',SUM(amount_) 'value' from sys_user_cash_account_log suc
|
|
|
+ where DATE_FORMAT(suc.create_time_,'%Y-%m') = #{month} AND suc.amount_ > 0 group by suc.organ_id_;
|
|
|
+ </select>
|
|
|
+ <select id="sumVariableCosts" resultType="java.util.Map">
|
|
|
+ select fe.organ_id_ 'key',SUM(amount_) 'value' from financial_expenditure fe
|
|
|
+ where DATE_FORMAT(fe.create_time_,'%Y-%m') = #{month} AND fee_project_ BETWEEN 6 AND 18 AND process_id_ = 28 group by fe.organ_id_;
|
|
|
+ </select>
|
|
|
+ <select id="sumFixedCosts" resultType="java.util.Map">
|
|
|
+ select fe.organ_id_ 'key',SUM(amount_) 'value' from financial_expenditure fe
|
|
|
+ where DATE_FORMAT(fe.create_time_,'%Y-%m') = #{month} AND fee_project_ BETWEEN 1 AND 5 AND process_id_ = 28 group by fe.organ_id_;
|
|
|
+ </select>
|
|
|
+ <select id="sumCloudPreAmount" resultType="java.util.Map">
|
|
|
+ select orc.organ_id_ 'key',TRUNCATE(SUM(operating_amount_ / TIMESTAMPDIFF(DAY,start_time_,end_time_) * TIMESTAMPDIFF(DAY,#{lastDay},end_time_)),2) 'value'
|
|
|
+ from cloud_teacher_order orc
|
|
|
+ where operating_amount_ > 0 AND DATE_FORMAT(end_time_,'%Y-%m') > #{month} group by orc.organ_id_;
|
|
|
+ </select>
|
|
|
+ <select id="sumGroupCloudPreAmount" resultType="java.util.Map">
|
|
|
+ select orc.organ_id_ 'key',TRUNCATE(SUM(orc.cloud_price_ / TIMESTAMPDIFF(DAY,orc.start_date_,orc.end_date_) * TIMESTAMPDIFF(DAY,#{lastDay},orc.end_date_)),2) 'value'
|
|
|
+ from operating_report_cloud orc
|
|
|
+ where DATE_FORMAT(orc.end_date_,'%Y-%m') > #{month} AND orc.cloud_price_ > 0 AND orc.month_flag_ = false group by orc.organ_id_;
|
|
|
+ </select>
|
|
|
+ <select id="sumGroupAmount" resultType="java.util.Map">
|
|
|
+ select orc.organ_id_ 'key',SUM(orc.cloud_price_) 'value'
|
|
|
+ from operating_report_cloud orc
|
|
|
+ where orc.cloud_price_ > 0 AND orc.month_flag_ = true AND orc.settlement_flag_ = false group by orc.organ_id_;
|
|
|
+ </select>
|
|
|
+ <select id="sumCloudCoursePreAmount" resultType="java.util.Map">
|
|
|
+ SELECT cs.organ_id_ 'key',SUM(ctf.cost_) 'value' FROM cloud_teacher_free_course ctf
|
|
|
+ LEFT JOIN course_schedule cs ON cs.id_ = ctf.course_id_
|
|
|
+ where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.class_date_ > #{lastDay}
|
|
|
+ group by cs.organ_id_;
|
|
|
+ </select>
|
|
|
+ <select id="sumCoursePreAmount" resultType="java.util.Map">
|
|
|
+ SELECT cs.organ_id_ 'key',SUM(cssp.actual_price_) 'value' FROM course_schedule cs
|
|
|
+ LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
|
|
|
+ where cs.del_flag_ = 0 AND cs.is_lock_ = 0 AND cs.class_date_ > #{lastDay}
|
|
|
+ group by cs.organ_id_;
|
|
|
+ </select>
|
|
|
+ <select id="sumOtherPreAmount" resultType="java.util.Map">
|
|
|
+ select orc.organ_id_ 'key',SUM(orc.cloud_price_) 'value' from operating_report_cloud orc
|
|
|
+ where orc.course_price_ = 0 AND orc.month_flag_ = false AND orc.settlement_flag_ = false GROUP BY orc.organ_id_;
|
|
|
+ </select>
|
|
|
+ <select id="sumSalePreAmount" resultType="java.util.Map">
|
|
|
+ select mg.organ_id_ 'key',SUM(so.actual_amount_) 'value' from sell_order so
|
|
|
+ left join student_payment_order spo ON spo.order_no_ = so.order_no_
|
|
|
+ left join music_group mg ON mg.id_ = spo.music_group_id_ AND spo.group_type_ = 'MUSIC'
|
|
|
+ where mg.musical_instruments_provide_status_ = 0 AND so.actual_amount_ > 0
|
|
|
+ group by mg.organ_id_;
|
|
|
+ </select>
|
|
|
+ <select id="sumArrearsAmount" resultType="java.util.Map">
|
|
|
+ select a.organ_id_ 'key',SUM(a.amount_) 'value' FROM (
|
|
|
+ select SUM(mgpc.current_total_amount_) amount_,mgpc.organ_id_ from music_group_payment_calender_detail mgpcd
|
|
|
+ LEFT JOIN (select * from music_group_payment_student_course_detail where used_course_minutes_ > 0 group by music_group_payment_calender_id_,user_id_) mgpscd ON mgpscd.music_group_payment_calender_detail_id_ = mgpcd.id_
|
|
|
+ LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpscd.music_group_payment_calender_id_
|
|
|
+ WHERE mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpscd.used_course_minutes_ > 0 AND mgpc.current_total_amount_ > 0
|
|
|
+ GROUP BY mgpscd.music_group_payment_calender_id_,mgpscd.user_id_) a
|
|
|
+ group by organ_id_
|
|
|
+ </select>
|
|
|
+ <select id="sumSchoolAmount" resultType="java.util.Map">
|
|
|
+ select mgpc.organ_id_ 'key',SUM(mgpc.current_total_amount_ * mgpc.actual_num_) - SUM(spro.service_amount_) - SUM(spro.sale_amount_) 'value'
|
|
|
+ from student_payment_route_order spro
|
|
|
+ LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = spro.calender_id_
|
|
|
+ where spro.calender_id_ IS NOT NULL AND spro.audit_status_ = 'PASS' AND mgpc.id_ = spro.calender_id_
|
|
|
+ group by mgpc.organ_id_
|
|
|
+ </select>
|
|
|
+</mapper>
|