|
@@ -1395,9 +1395,9 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getFinanceBalanceDataWithTimely" resultMap="IndexBaseMonthData">
|
|
|
- SELECT spo.organ_id_,SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,
|
|
|
- SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) activate_num_,
|
|
|
- SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
|
|
|
+ SELECT spo.organ_id_,SUM(IFNULL(spo.balance_payment_amount_,0)) total_num_,
|
|
|
+ SUM(IFNULL(spo.balance_payment_amount_,0)) activate_num_,
|
|
|
+ SUM(IFNULL(spo.balance_payment_amount_,0)) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
|
|
|
FROM student_payment_order spo
|
|
|
WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
|
|
|
<if test="organIds!=null and organIds.size()>0">
|
|
@@ -1410,19 +1410,17 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getOrganFinanceBalanceDataWithTimely" resultMap="IndexBaseMonthData">
|
|
|
- SELECT SUM(CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,
|
|
|
- o.id_ organ_id_,o.name_ organ_name_
|
|
|
- FROM organization o
|
|
|
- LEFT JOIN student_payment_order spo ON o.id_ = spo.organ_id_ AND o.tenant_id_ = spo.tenant_id_
|
|
|
- AND spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
|
|
|
- WHERE o.tenant_id_ = #{tenantId}
|
|
|
+ SELECT SUM(IFNULL(spo.balance_payment_amount_,0)) percent_,spo.organ_id_
|
|
|
+ FROM student_payment_order spo
|
|
|
+ WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
|
|
|
+ AND spo.tenant_id_ = #{tenantId}
|
|
|
<if test="organIds!=null and organIds.size() > 0">
|
|
|
- AND o.id_ IN
|
|
|
+ AND spo.organ_id_ IN
|
|
|
<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
|
|
|
#{organId}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
- GROUP BY o.id_ ORDER BY percent_ DESC
|
|
|
+ GROUP BY spo.organ_id_ ORDER BY percent_ DESC
|
|
|
</select>
|
|
|
|
|
|
<select id="getFinanceActualDataWithTimely" resultMap="IndexBaseMonthData">
|
|
@@ -1441,27 +1439,23 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getOrganFinanceActualDataWithTimely" resultMap="IndexBaseMonthData">
|
|
|
- SELECT SUM(spo.actual_amount_) percent_,o.id_ organ_id_,o.name_ organ_name_
|
|
|
- FROM organization o
|
|
|
- LEFT JOIN student_payment_order spo ON o.id_ = spo.organ_id_ AND o.tenant_id_ = spo.tenant_id_
|
|
|
- AND spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
|
|
|
- WHERE o.tenant_id_ = #{tenantId}
|
|
|
+ SELECT SUM(spo.actual_amount_) percent_,spo.organ_id_
|
|
|
+ FROM student_payment_order spo
|
|
|
+ WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
|
|
|
+ AND spo.tenant_id_ = #{tenantId}
|
|
|
<if test="organIds!=null and organIds.size()>0">
|
|
|
- AND o.id_ IN
|
|
|
+ AND spo.organ_id_ IN
|
|
|
<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
|
|
|
#{organId}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
- GROUP BY o.id_ ORDER BY percent_ DESC
|
|
|
+ GROUP BY spo.organ_id_ ORDER BY percent_ DESC
|
|
|
</select>
|
|
|
|
|
|
<select id="getTotalAmountDataWithTimely" resultMap="IndexBaseMonthData">
|
|
|
- SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
|
|
|
- CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,
|
|
|
- SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
|
|
|
- CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) activate_num_,
|
|
|
- SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
|
|
|
- CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
|
|
|
+ SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_,
|
|
|
+ SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) activate_num_,
|
|
|
+ SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
|
|
|
FROM student_payment_order spo
|
|
|
WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
|
|
|
<if test="organIds!=null and organIds.size()>0">
|
|
@@ -1474,29 +1468,23 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getOrganTotalAmountDataWithTimely" resultMap="IndexBaseMonthData">
|
|
|
- SELECT SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
|
|
|
- CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,
|
|
|
- o.id_ organ_id_,o.name_ organ_name_
|
|
|
- FROM organization o
|
|
|
- LEFT JOIN student_payment_order spo ON o.id_ = spo.organ_id_ AND o.tenant_id_ = spo.tenant_id_
|
|
|
- AND spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
|
|
|
- WHERE o.tenant_id_ = #{tenantId}
|
|
|
+ SELECT SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) percent_,spo.organ_id_
|
|
|
+ FROM student_payment_order spo
|
|
|
+ WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
|
|
|
+ AND spo.tenant_id_ = #{tenantId}
|
|
|
<if test="organIds!=null and organIds.size()>0">
|
|
|
- AND o.id_ IN
|
|
|
+ AND spo.organ_id_ IN
|
|
|
<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
|
|
|
#{organId}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
- GROUP BY o.id_ ORDER BY percent_ DESC
|
|
|
+ GROUP BY spo.organ_id_ ORDER BY percent_ DESC
|
|
|
</select>
|
|
|
|
|
|
<select id="getTotalAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
|
|
|
- SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
|
|
|
- CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,
|
|
|
- SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
|
|
|
- CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) activate_num_,
|
|
|
- SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
|
|
|
- CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
|
|
|
+ SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_,
|
|
|
+ SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) activate_num_,
|
|
|
+ SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) percent_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
|
|
|
FROM student_payment_order spo
|
|
|
WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
|
|
|
<if test="orderType != null">
|
|
@@ -1518,12 +1506,9 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getOrganTotalAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
|
|
|
- SELECT SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
|
|
|
- CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) percent_,
|
|
|
- o.id_ organ_id_,o.name_ organ_name_
|
|
|
- FROM organization o
|
|
|
- LEFT JOIN student_payment_order spo ON o.id_ = spo.organ_id_ AND o.tenant_id_ = spo.tenant_id_
|
|
|
- AND spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
|
|
|
+ SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) percent_
|
|
|
+ FROM student_payment_order spo
|
|
|
+ WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
|
|
|
<if test="orderType != null">
|
|
|
AND FIND_IN_SET(spo.type_,#{orderType})
|
|
|
</if>
|
|
@@ -1533,25 +1518,19 @@
|
|
|
#{item}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
+ AND spo.tenant_id_ = #{tenantId}
|
|
|
<if test="organIds!=null and organIds.size()>0">
|
|
|
AND spo.organ_id_ IN
|
|
|
<foreach collection="organIds" item="organId" open="(" close=")" separator=",">
|
|
|
#{organId}
|
|
|
</foreach>
|
|
|
</if>
|
|
|
- WHERE o.tenant_id_ = #{tenantId}
|
|
|
- <if test="organIds!=null and organIds.size()>0">
|
|
|
- AND o.id_ IN
|
|
|
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
|
|
|
- #{organId}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
- GROUP BY o.id_ ORDER BY percent_ DESC
|
|
|
+ GROUP BY spo.organ_id_ ORDER BY percent_ DESC
|
|
|
</select>
|
|
|
|
|
|
<select id="getVipAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
|
|
|
SELECT organ_id_,SUM(c.total_num_) total_num_,SUM(c.total_num_) activate_num_,SUM(c.total_num_) percent_,month_ FROM (
|
|
|
- SELECT spo.organ_id_,SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_num_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
|
|
|
+ SELECT spo.organ_id_,SUM(IFNULL(spod.price_,0)) total_num_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
|
|
|
FROM student_payment_order spo
|
|
|
LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
|
|
|
WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
|
|
@@ -1564,8 +1543,7 @@
|
|
|
</if>
|
|
|
GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d')
|
|
|
UNION ALL
|
|
|
- SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
|
|
|
- CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_
|
|
|
+ SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_
|
|
|
,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_
|
|
|
FROM student_payment_order spo
|
|
|
WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
|
|
@@ -1581,8 +1559,8 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getOrganVipAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
|
|
|
- SELECT o.id_ organ_id_,o.name_ organ_name_,SUM(c.total_num_) percent_ FROM organization o
|
|
|
- LEFT JOIN (SELECT spo.organ_id_,SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_num_
|
|
|
+ SELECT c.organ_id_,SUM(c.total_num_) percent_
|
|
|
+ FROM (SELECT spo.organ_id_,SUM(IFNULL(spod.price_,0)) total_num_
|
|
|
FROM student_payment_order spo
|
|
|
LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
|
|
|
WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
|
|
@@ -1595,8 +1573,7 @@
|
|
|
</if>
|
|
|
GROUP BY spo.organ_id_
|
|
|
UNION ALL
|
|
|
- SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
|
|
|
- CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_
|
|
|
+ SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_
|
|
|
FROM student_payment_order spo
|
|
|
WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
|
|
|
AND spo.type_ = 'SMALL_CLASS_TO_BUY'
|
|
@@ -1607,21 +1584,13 @@
|
|
|
</foreach>
|
|
|
</if>
|
|
|
GROUP BY spo.organ_id_
|
|
|
- )c ON c.organ_id_ = o.id_
|
|
|
- WHERE o.tenant_id_ = #{tenantId}
|
|
|
- <if test="organIds!=null and organIds.size()>0">
|
|
|
- AND o.id_ IN
|
|
|
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
|
|
|
- #{organId}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
- GROUP BY o.id_ ORDER BY percent_ DESC
|
|
|
+ )c
|
|
|
+ GROUP BY c.organ_id_ ORDER BY percent_ DESC
|
|
|
</select>
|
|
|
|
|
|
<select id="getOtherAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
|
|
|
SELECT organ_id_,SUM(c.total_num_) total_num_,SUM(c.total_num_) activate_num_,SUM(c.total_num_) percent_,month_,c.type_ order_type_ FROM (
|
|
|
- SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
|
|
|
- CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_
|
|
|
+ SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_
|
|
|
,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_,spo.type_
|
|
|
FROM student_payment_order spo
|
|
|
WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
|
|
@@ -1634,7 +1603,7 @@
|
|
|
</if>
|
|
|
GROUP BY DATE_FORMAT(spo.pay_time_,'%Y-%m-%d'),spo.type_
|
|
|
UNION ALL
|
|
|
- SELECT spo.organ_id_,SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_num_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_,spo.type_
|
|
|
+ SELECT spo.organ_id_,SUM(IFNULL(spod.price_,0)) total_num_,DATE_FORMAT(spo.pay_time_,'%Y-%m-%d') month_,spo.type_
|
|
|
FROM student_payment_order spo
|
|
|
LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
|
|
|
WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
|
|
@@ -1650,10 +1619,9 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getOrganOtherAmountDataWithTimelyDetails" resultMap="IndexBaseMonthData">
|
|
|
- SELECT o.id_ organ_id_,o.name_ organ_name_,SUM(c.total_num_) percent_ FROM organization o
|
|
|
- LEFT JOIN (
|
|
|
- SELECT spo.organ_id_,SUM(CASE WHEN spo.actual_amount_ IS NULL THEN 0 ELSE spo.actual_amount_ END +
|
|
|
- CASE WHEN spo.balance_payment_amount_ IS NULL THEN 0 ELSE spo.balance_payment_amount_ END) total_num_,spo.type_
|
|
|
+ SELECT c.organ_id_,SUM(c.total_num_) percent_
|
|
|
+ FROM (
|
|
|
+ SELECT spo.organ_id_,SUM(IFNULL(spo.actual_amount_,0) + IFNULL(spo.balance_payment_amount_,0)) total_num_,spo.type_
|
|
|
FROM student_payment_order spo
|
|
|
WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate} and spo.tenant_id_ = #{tenantId}
|
|
|
AND spo.type_ NOT IN ('APPLY','ADD_STUDENT','RENEW','PRACTICE_GROUP_BUY','PRACTICE_GROUP_RENEW','SMALL_CLASS_TO_BUY','DEGREE')
|
|
@@ -1665,7 +1633,7 @@
|
|
|
</if>
|
|
|
GROUP BY spo.organ_id_,spo.type_
|
|
|
UNION ALL
|
|
|
- SELECT spo.organ_id_,SUM(CASE WHEN spod.price_ IS NULL THEN 0 ELSE spod.price_ END) total_num_,spo.type_
|
|
|
+ SELECT spo.organ_id_,SUM(IFNULL(spod.price_,0)) total_num_,spo.type_
|
|
|
FROM student_payment_order spo
|
|
|
LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_
|
|
|
WHERE spo.status_ = 'SUCCESS' AND spo.pay_time_ BETWEEN #{startDate} AND #{endDate}
|
|
@@ -1677,15 +1645,8 @@
|
|
|
</foreach>
|
|
|
</if>
|
|
|
GROUP BY spo.organ_id_,spo.type_
|
|
|
- )c ON c.organ_id_ = o.id_
|
|
|
- WHERE o.tenant_id_ = #{tenantId}
|
|
|
- <if test="organIds!=null and organIds.size()>0">
|
|
|
- AND o.id_ IN
|
|
|
- <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
|
|
|
- #{organId}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
- GROUP BY o.id_ ORDER BY percent_ DESC
|
|
|
+ )c
|
|
|
+ GROUP BY c.organ_id_ ORDER BY percent_ DESC
|
|
|
</select>
|
|
|
|
|
|
<sql id="queryTeacherServeInfoCondition">
|