|  | @@ -411,6 +411,7 @@
 | 
	
		
			
				|  |  |          <result property="phone" column="phone_"/>
 | 
	
		
			
				|  |  |          <result property="studentId" column="student_id_"/>
 | 
	
		
			
				|  |  |          <result property="studentName" column="student_name_"/>
 | 
	
		
			
				|  |  | +        <result property="teacherName" column="teacher_name_"/>
 | 
	
		
			
				|  |  |          <result property="firstBuyTime" column="first_buy_time_"/>
 | 
	
		
			
				|  |  |          <result property="intervalDay" column="interval_day_"/>
 | 
	
		
			
				|  |  |          <result property="lastClassDate" column="last_class_date_"/>
 | 
	
	
		
			
				|  | @@ -422,21 +423,26 @@
 | 
	
		
			
				|  |  |          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_
 | 
	
		
			
				|  |  | +        CASE WHEN c.firstBuyTime IS NULL THEN 0 ELSE 1 END buy_practice_,d.teacher_name_
 | 
	
		
			
				|  |  |          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'
 | 
	
		
			
				|  |  | +        LEFT JOIN `course_schedule` cs on cs.`music_group_id_` = pg.`id_`
 | 
	
		
			
				|  |  |          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_` 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_
 | 
	
		
			
				|  |  | +        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 (SELECT GROUP_CONCAT(DISTINCT su.real_name_) teacher_name_,pg.student_id_
 | 
	
		
			
				|  |  | +        FROM `practice_group` pg
 | 
	
		
			
				|  |  | +        LEFT JOIN `course_schedule` cs ON cs.`music_group_id_` = pg.`id_`
 | 
	
		
			
				|  |  | +        LEFT JOIN sys_user su ON su.id_ = cs.actual_teacher_id_
 | 
	
		
			
				|  |  | +        WHERE cs.`group_type_` = 'PRACTICE' AND pg.`group_status_` IN ('NORMAL','FINISH') GROUP BY pg.`student_id_` ) d ON a.student_id_ = d.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"/>
 | 
	
		
			
				|  |  |          <include refid="global.limit"/>
 | 
	
		
			
				|  |  |      </select>
 |