|
@@ -396,7 +396,8 @@
|
|
|
LEFT JOIN `course_schedule` cs on cs.`music_group_id_` = pg.`id_`
|
|
|
WHERE cs.`group_type_` = 'PRACTICE' AND pg.`buy_months_` IS NULL
|
|
|
GROUP BY pg.`student_id_` ) a
|
|
|
- left join (SELECT pg.`student_id_` ,min(pg.`create_time_`) firstBuyTime FROM `practice_group` pg WHERE pg.`buy_months_` IS NOT NULL GROUP BY pg.`student_id_` ) b
|
|
|
+ left join (SELECT pg.`student_id_` ,min(pg.`create_time_`) firstBuyTime
|
|
|
+ FROM `practice_group` pg WHERE pg.`buy_months_` IS NOT NULL AND pg.group_status_ != 'CANCEL' GROUP BY pg.`student_id_` ) b
|
|
|
on a.student_id_ = b.student_id_
|
|
|
left join `sys_user` u on u.`id_` = a.student_id_
|
|
|
<include refid="queryStudentBuysSql"/>
|
|
@@ -413,14 +414,16 @@
|
|
|
</resultMap>
|
|
|
<select id="queryStudentBuys" resultMap="queryStudentBuysMap">
|
|
|
SELECT o.`name_` organ_name_,a.student_id_,u.`username_` student_name_,u.phone_,a.lastClassDate last_class_date_,
|
|
|
- b.firstBuyTime first_buy_time_,DATEDIFF(b.firstBuyTime,a.lastClassDate) interval_day_,
|
|
|
+ b.firstBuyTime first_buy_time_,
|
|
|
+ CASE WHEN DATEDIFF(b.firstBuyTime,a.lastClassDate) < 0 THEN 0 ELSE DATEDIFF(b.firstBuyTime,a.lastClassDate) END interval_day_,
|
|
|
CASE WHEN b.firstBuyTime IS NULL THEN 0 ELSE 1 END buy_practice_ FROM
|
|
|
(SELECT pg.`student_id_` ,max(concat(cs.`class_date_`,' ',cs.`end_class_time_` )) lastClassDate
|
|
|
FROM `practice_group` pg
|
|
|
LEFT JOIN `course_schedule` cs on cs.`music_group_id_` = pg.`id_`
|
|
|
WHERE cs.`group_type_` = 'PRACTICE' AND pg.`buy_months_` IS NULL
|
|
|
GROUP BY pg.`student_id_` ) a
|
|
|
- left join (SELECT pg.`student_id_` ,min(pg.`create_time_`) firstBuyTime FROM `practice_group` pg WHERE pg.`buy_months_` IS NOT NULL GROUP BY pg.`student_id_` ) b
|
|
|
+ left join (SELECT pg.`student_id_` ,min(pg.`create_time_`) firstBuyTime
|
|
|
+ FROM `practice_group` pg WHERE pg.`buy_months_` IS NOT NULL AND pg.group_status_ != 'CANCEL' GROUP BY pg.`student_id_` ) b
|
|
|
on a.student_id_ = b.student_id_
|
|
|
left join `sys_user` u on u.`id_` = a.student_id_
|
|
|
left join `organization` o on o.`id_` = u.`organ_id_`
|
|
@@ -438,6 +441,9 @@
|
|
|
<if test="buyPractice != null and buyPractice == true">
|
|
|
AND b.firstBuyTime IS NOT NULL
|
|
|
</if>
|
|
|
+ <if test="organId != null">
|
|
|
+ AND FIND_IN_SET(u.`organ_id_`,#{organId})
|
|
|
+ </if>
|
|
|
</where>
|
|
|
</sql>
|
|
|
</mapper>
|