|
@@ -391,15 +391,16 @@
|
|
|
|
|
|
<select id="countStudentBuys" resultType="java.lang.Integer">
|
|
|
SELECT COUNT(a.student_id_) 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 AND pg.group_status_ != 'CANCEL'
|
|
|
- GROUP BY pg.`student_id_` ) a
|
|
|
+ (SELECT DISTINCT(pg.`student_id_`),pg.`organ_id_` FROM `practice_group` pg WHERE pg.`group_status_` in ('NORMAL','FINISH')) a
|
|
|
+ LEFT JOIN (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_` and cs.`group_type_` = 'PRACTICE'
|
|
|
+ WHERE pg.`buy_months_` IS NULL AND cs.`group_type_` = 'PRACTICE'
|
|
|
+ GROUP BY pg.`student_id_` ) b on a.student_id_ = b.student_id_
|
|
|
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_
|
|
|
+ FROM `practice_group` pg WHERE pg.`buy_months_` IS NOT NULL AND pg.`group_status_` in ('NORMAL','FINISH') GROUP BY pg.`student_id_` ) c
|
|
|
+ on a.student_id_ = c.student_id_
|
|
|
left join `sys_user` u on u.`id_` = a.student_id_
|
|
|
+ left join `organization` o on o.`id_` = a.organ_id_
|
|
|
<include refid="queryStudentBuysSql"/>
|
|
|
</select>
|
|
|
<resultMap id="queryStudentBuysMap" type="com.ym.mec.biz.dal.dto.StudentBuyPracticeDto">
|
|
@@ -413,20 +414,21 @@
|
|
|
<result property="buyPractice" column="buy_practice_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
|
|
|
</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_,
|
|
|
- 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 AND pg.group_status_ != 'CANCEL'
|
|
|
- GROUP BY pg.`student_id_` ) a
|
|
|
+ SELECT o.`name_` organ_name_,a.student_id_,u.`username_` student_name_,u.phone_,
|
|
|
+ b.lastClassDate last_class_date_,c.firstBuyTime first_buy_time_,
|
|
|
+ CASE WHEN DATEDIFF(c.firstBuyTime,b.lastClassDate) < 0 THEN 0 ELSE DATEDIFF(c.firstBuyTime,b.lastClassDate) END interval_day_,
|
|
|
+ CASE WHEN c.firstBuyTime IS NULL THEN 0 ELSE 1 END buy_practice_
|
|
|
+ FROM
|
|
|
+ (SELECT DISTINCT(pg.`student_id_`),pg.`organ_id_` FROM `practice_group` pg WHERE pg.`group_status_` in ('NORMAL','FINISH')) a
|
|
|
+ LEFT JOIN (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_` and cs.`group_type_` = 'PRACTICE'
|
|
|
+ WHERE pg.`buy_months_` IS NULL AND cs.`group_type_` = 'PRACTICE'
|
|
|
+ GROUP BY pg.`student_id_` ) b on a.student_id_ = b.student_id_
|
|
|
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_
|
|
|
+ FROM `practice_group` pg WHERE pg.`buy_months_` IS NOT NULL AND pg.`group_status_` in ('NORMAL','FINISH') GROUP BY pg.`student_id_` ) c
|
|
|
+ on a.student_id_ = c.student_id_
|
|
|
left join `sys_user` u on u.`id_` = a.student_id_
|
|
|
- left join `organization` o on o.`id_` = u.`organ_id_`
|
|
|
+ left join `organization` o on o.`id_` = a.organ_id_
|
|
|
<include refid="queryStudentBuysSql"/>
|
|
|
<include refid="global.limit"/>
|
|
|
</select>
|
|
@@ -436,13 +438,13 @@
|
|
|
(u.id_ = #{search} OR u.`username_` LIKE CONCAT('%',#{search},'%'))
|
|
|
</if>
|
|
|
<if test="buyPractice != null and buyPractice == false">
|
|
|
- AND b.firstBuyTime IS NULL
|
|
|
+ AND c.firstBuyTime IS NULL
|
|
|
</if>
|
|
|
<if test="buyPractice != null and buyPractice == true">
|
|
|
- AND b.firstBuyTime IS NOT NULL
|
|
|
+ AND c.firstBuyTime IS NOT NULL
|
|
|
</if>
|
|
|
<if test="organId != null">
|
|
|
- AND FIND_IN_SET(u.`organ_id_`,#{organId})
|
|
|
+ AND FIND_IN_SET(a.organ_id_`,#{organId})
|
|
|
</if>
|
|
|
</where>
|
|
|
</sql>
|