CourseScheduleMapper.xml 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.yonge.cooleshow.biz.dal.dao.CourseScheduleDao">
  4. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.CourseSchedule">
  5. <id column="id_" jdbcType="INTEGER" property="id"/>
  6. <result column="course_group_id_" jdbcType="INTEGER" property="courseGroupId"/>
  7. <result column="type_" jdbcType="VARCHAR" property="type"/>
  8. <result column="status_" jdbcType="VARCHAR" property="status"/>
  9. <result column="class_num_" jdbcType="INTEGER" property="classNum"/>
  10. <result column="teacher_id_" jdbcType="INTEGER" property="teacherId"/>
  11. <result column="class_date_" jdbcType="TIMESTAMP" property="classDate"/>
  12. <result column="start_time_" jdbcType="TIMESTAMP" property="startTime"/>
  13. <result column="end_time_" jdbcType="TIMESTAMP" property="endTime"/>
  14. <result column="lock_" jdbcType="INTEGER" property="lock"/>
  15. <result column="lock_time_" jdbcType="TIMESTAMP" property="lockTime"/>
  16. <result column="ex_student_num_" jdbcType="INTEGER" property="exStudentNum"/>
  17. <result column="created_by_" jdbcType="INTEGER" property="createdBy"/>
  18. <result column="created_time_" jdbcType="TIMESTAMP" property="createdTime"/>
  19. <result column="updated_by_" jdbcType="INTEGER" property="updatedBy"/>
  20. <result column="updated_time_" jdbcType="TIMESTAMP" property="updatedTime"/>
  21. <result column="service_provider_" property="serviceProvider"/>
  22. <result column="room_id_" property="roomId"/>
  23. <result column="mute_all_" property="muteAll"/>
  24. <result column="cancel_mute_flag_" property="cancelMuteFlag"/>
  25. </resultMap>
  26. <sql id="Base_Column_List">
  27. id_
  28. , course_group_id_, type_, status_,class_num_, teacher_id_, class_date_,
  29. start_time_, end_time_, lock_, lock_time_, ex_student_num_,
  30. created_by_, created_time_, updated_by_, updated_time_,service_provider_,room_id_,mute_all_,cancel_mute_flag_
  31. </sql>
  32. <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
  33. parameterType="com.yonge.cooleshow.biz.dal.entity.CourseSchedule">
  34. insert into course_schedule(course_group_id_, type_, status_,class_num_, teacher_id_, class_date_, start_time_,
  35. end_time_, lock_, lock_time_, ex_student_num_, created_by_, created_time_, updated_by_,
  36. updated_time_)
  37. values
  38. <foreach collection="entities" item="entity" separator=",">
  39. (#{entity.courseGroupId}, #{entity.type}, #{entity.status},#{entity.classNum}, #{entity.teacherId}, #{entity.classDate},
  40. #{entity.startTime}, #{entity.endTime}, #{entity.lock}, #{entity.lockTime},
  41. #{entity.exStudentNum}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy},
  42. #{entity.updatedTime})
  43. </foreach>
  44. </insert>
  45. <select id="queryTeacherTotal" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherTotalVo">
  46. select
  47. t.user_id_ as userId,
  48. a.expTime,
  49. a.unExpTime,
  50. b.starGrade
  51. from teacher t
  52. left join (
  53. <!-- 统计查询已上课时数,未上课时数 -->
  54. select
  55. a.teacher_id_ as userId,
  56. sum(if(a.end_time_ &lt;= now(),1,0)) as expTime,
  57. sum(if(a.end_time_ &gt; now(),1,0)) as unExpTime
  58. from course_schedule a
  59. where a.lock_ = 0 and a.type_ in ('PRACTICE','PIANO_ROOM_CLASS')
  60. <if test="userId != null and userId != ''">
  61. and a.teacher_id_ = #{userId}
  62. </if>
  63. group by a.teacher_id_
  64. ) a on t.user_id_ = a.userId
  65. left join (
  66. <!-- 统计老师星级评分 -->
  67. select
  68. a.teacher_id_ as userId,
  69. avg (b.score_) as starGrade
  70. from course_schedule a
  71. join course_schedule_replied b on a.id_ = b.course_schedule_id_
  72. where a.lock_ = 0 and a.type_ in ('PRACTICE','PIANO_ROOM_CLASS') and b.score_ is not null
  73. <if test="userId != null and userId != ''">
  74. and a.teacher_id_ = #{userId}
  75. </if>
  76. group by a.teacher_id_
  77. ) b on t.user_id_ = b.userId
  78. <where>
  79. <if test="userId != null and userId != ''">
  80. and t.user_id_ = #{userId}
  81. </if>
  82. </where>
  83. </select>
  84. <select id="queryStudentTotal" resultType="com.yonge.cooleshow.biz.dal.vo.StudentTotalVo">
  85. select
  86. t.user_id_ as userId,
  87. sum(if(b.end_time_ &lt;= now(),1,0)) as finshHours,
  88. sum(if(b.end_time_ &gt; now(),1,0)) as unfinshHours
  89. from student t
  90. left join course_schedule_student_payment a on t.user_id_ = a.user_id_
  91. left join course_schedule b on a.course_id_ = b.id_
  92. where b.lock_ = 0 and b.type_ in ('PRACTICE','PIANO_ROOM_CLASS')
  93. <if test="userId != null and userId != ''">
  94. and t.user_id_ = #{userId}
  95. </if>
  96. group by t.user_id_
  97. </select>
  98. <select id="queryStudentCourse" resultMap="BaseResultMap">
  99. select b.id_,
  100. b.course_group_id_,
  101. b.type_,
  102. b.class_num_,
  103. b.teacher_id_,
  104. b.class_date_,
  105. b.start_time_,
  106. b.end_time_,
  107. b.lock_,
  108. b.lock_time_,
  109. b.ex_student_num_,
  110. b.status_,
  111. b.created_by_,
  112. b.created_time_,
  113. b.updated_by_,
  114. b.updated_time_
  115. from course_schedule_student_payment as a
  116. left join course_schedule as b on a.course_id_ = b.id_
  117. <where>
  118. a.user_id_ = #{param.studentId}
  119. <if test="param.greaterDate != null">
  120. AND <![CDATA[ b.start_time_ > #{param.greaterDate} ]]>
  121. </if>
  122. <if test="param.startClassDate != null">
  123. AND <![CDATA[ b.class_date_ >= #{param.startClassDate} ]]>
  124. </if>
  125. <if test="param.endClassDate != null">
  126. AND <![CDATA[ b.class_date_ <= #{param.endClassDate} ]]>
  127. </if>
  128. <if test="param.classDate != null">
  129. AND b.class_date_ = #{param.classDate}
  130. </if>
  131. <if test="param.status != null">
  132. AND b.status_ = #{param.status}
  133. </if>
  134. <if test="param.statusList != null">
  135. AND b.status_ IN
  136. <foreach collection="param.statusList" item="item" open="(" separator="," close=")">
  137. #{item}
  138. </foreach>
  139. </if>
  140. </where>
  141. order by b.start_time_ desc
  142. </select>
  143. <select id="queryLiveTeacherCourse" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherLiveCourseInfoVo">
  144. select
  145. b.id_ as courseGroupId,
  146. b.name_ as courseGroupName,
  147. a.id_ as courseId,
  148. a.class_num_ as classNum,
  149. s.name_ as subjectName,
  150. a.start_time_ as startTime,
  151. a.end_time_ as endTime,
  152. a.status_ as `status`,
  153. b.pre_student_num_ as studentCount,
  154. b.background_pic_ as backgroundPic,
  155. b.im_group_id_ as imGroupId,
  156. su.username_ as username,
  157. su.id_ as userId,
  158. su.avatar_ as avatar,
  159. b.course_num_ as courseNum,
  160. b.complete_course_num_ as completeCourseNum,
  161. b.course_introduce_ as courseIntroduce
  162. from course_schedule as a
  163. left join course_group as b on a.course_group_id_ = b.id_
  164. left join subject as s on b.subject_id_ = s.id_
  165. left join sys_user su on su.id_ = a.teacher_id_
  166. where b.teacher_id_ = #{param.teacherId}
  167. AND a.lock_ = 0
  168. AND a.type_ = #{param.type}
  169. <if test="param.groupState !=null and param.groupState !=''">
  170. AND find_in_set(b.status_, #{param.groupState})
  171. </if>
  172. <if test="param.status !=null and param.status !=''">
  173. AND a.status_ = #{param.status}
  174. </if>
  175. <if test="param.subjectId != null and param.subjectId !=''">
  176. AND b.subject_id_ = #{param.subjectId}
  177. </if>
  178. order by start_time_
  179. </select>
  180. <select id="queryTeacherPracticeCourse" resultType="com.yonge.cooleshow.biz.dal.vo.MyCourseVo">
  181. SELECT distinct
  182. u.id_ AS userId,
  183. u.username_ AS userName,
  184. u.real_name_ AS realName,
  185. u.avatar_ AS avatar,
  186. cs.class_date_ AS classDate,
  187. cs.start_time_ AS startTime,
  188. cs.end_time_ AS endTime,
  189. cs.status_ AS `status`,
  190. g.subject_id_ AS subjectId,
  191. sb.name_ AS subjectName,
  192. g.name_ AS courseGroupName,
  193. u.del_flag_ as delFlag,
  194. p.course_id_ AS courseId,
  195. p.course_group_id_ AS courseGoupId,
  196. (r.student_replied_ IS NOT NULL) AS studentReplied,
  197. (r.teacher_replied_ IS NOT NULL) AS teacherReplied,
  198. CASE WHEN sa.course_schedule_id_ IS NULL THEN 0 ELSE 1 END AS attendanceStatus
  199. FROM course_schedule_student_payment p
  200. LEFT JOIN sys_user u ON p.user_id_ =u.id_
  201. LEFT JOIN course_schedule cs ON p.course_id_=cs.id_
  202. LEFT JOIN course_group g ON p.course_group_id_ = g.id_
  203. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  204. LEFT JOIN course_schedule_replied r ON cs.id_=r.course_schedule_id_
  205. LEFT JOIN student_attendance sa ON cs.id_ = sa.course_schedule_id_
  206. WHERE p.course_id_ IN
  207. (SELECT s.id_ FROM course_schedule s WHERE s.type_ = #{param.courseType} AND lock_=0 AND s.teacher_id_=#{param.teacherId})
  208. <if test="param.status !=null and param.status !=''">
  209. AND cs.status_ = #{param.status}
  210. </if>
  211. <if test="param.subjectId !=null">
  212. AND g.subject_id_ = #{param.subjectId}
  213. </if>
  214. <if test="param.attendanceStatus != null">
  215. <if test="param.attendanceStatus == true">
  216. AND sa.course_schedule_id_ IS NOT NULL
  217. </if>
  218. <if test="param.attendanceStatus == false">
  219. AND sa.course_schedule_id_ IS NULL
  220. </if>
  221. </if>
  222. <if test="param.classDate !=null and param.classDate !=''">
  223. AND cs.class_date_ = #{param.classDate}
  224. </if>
  225. <if test="param.startDate !=null and param.startDate !=''">
  226. <![CDATA[ AND cs.class_date_ >= #{param.startDate} ]]>
  227. </if>
  228. <if test="param.endDate !=null and param.endDate !=''">
  229. <![CDATA[ AND cs.class_date_ <= #{param.endDate} ]]>
  230. </if>
  231. <if test="param.repliedIds !=null and param.repliedIds.size > 0">
  232. AND p.user_id_ IN
  233. <foreach collection="param.repliedIds" item="repliedIds" open="(" close=")" separator=",">
  234. #{repliedIds}
  235. </foreach>
  236. </if>
  237. <if test="param.studentName !=null and param.studentName !=''">
  238. AND u.username_ LIKE CONCAT('%', #{param.studentName}, '%')
  239. </if>
  240. ORDER BY cs.start_time_
  241. </select>
  242. <select id="countTeacherNoDecorateHomework" resultType="java.lang.Integer">
  243. select count(1)
  244. from course_schedule cs
  245. left join course_homework ch on ch.course_schedule_id_ = cs.id_
  246. <where>
  247. <!-- 没有布置作业记录 -->
  248. <if test="param.decorate != null">
  249. <if test="param.decorate.code == 0">
  250. and ch.id_ is null
  251. </if>
  252. <if test="param.decorate.code == 1">
  253. and ch.id_ is not null
  254. </if>
  255. </if>
  256. <if test="param.courseStatus != null">
  257. and cs.type_ = #{param.courseType}
  258. </if>
  259. <if test="param.courseType != null">
  260. and cs.status_ = #{param.courseStatus}
  261. </if>
  262. <if test="param.teacherId != null">
  263. and cs.teacher_id_ = #{param.teacherId}
  264. </if>
  265. <if test="param.courseScheduleId != null ">
  266. and cs.id_ = #{param.courseScheduleId}
  267. </if>
  268. </where>
  269. </select>
  270. <select id="queryCourseSchedule" resultType="java.lang.String"
  271. parameterType="com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch">
  272. SELECT s.class_date_
  273. FROM course_schedule_student_payment p
  274. LEFT JOIN course_schedule s ON p.course_id_ = s.id_
  275. WHERE s.teacher_id_=#{teacherId}
  276. AND s.lock_=0
  277. AND s.status_ IN ('ING','COMPLETE','NOT_START')
  278. AND p.course_type_ IN ('PIANO_ROOM_CLASS','PRACTICE','VIP')
  279. <![CDATA[ AND s.class_date_ >= #{startDate} ]]>
  280. <![CDATA[ AND s.class_date_ <= #{endDate} ]]>
  281. UNION
  282. SELECT s.class_date_
  283. FROM course_group g
  284. LEFT JOIN course_schedule s ON g.id_=s.course_group_id_
  285. WHERE g.teacher_id_=#{teacherId}
  286. AND g.type_='LIVE'
  287. AND g.status_ IN ('COMPLETE','ING')
  288. <![CDATA[ AND s.class_date_ >= #{startDate} ]]>
  289. <![CDATA[ AND s.class_date_ <= #{endDate} ]]>
  290. </select>
  291. <select id="queryStudentPracticeCourse" resultType="com.yonge.cooleshow.biz.dal.vo.MyCourseVo">
  292. SELECT
  293. s.id_ AS courseId,
  294. s.course_group_id_ AS courseGoupId,
  295. s.class_date_ AS classDate,
  296. s.start_time_ AS startTime,
  297. s.end_time_ AS endTime,
  298. s.status_ AS `status`,
  299. s.teacher_id_ AS teacherId,
  300. u.id_ AS userId,
  301. u.username_ AS userName,
  302. u.real_name_ AS realName,
  303. u.avatar_ AS avatar,
  304. g.subject_id_ AS subjectId,
  305. b.name_ AS subjectName
  306. FROM course_schedule s
  307. LEFT JOIN sys_user u ON s.teacher_id_ = u.id_
  308. LEFT JOIN course_group g ON s.course_group_id_ = g.id_
  309. LEFT JOIN `subject` b ON g.subject_id_ = b.id_
  310. WHERE s.lock_=0
  311. AND s.status_ IN ('ING','NOT_START','COMPLETE')
  312. AND s.id_ IN
  313. (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{param.studentId} AND course_type_ = 'PRACTICE')
  314. <if test="param.status !=null and param.status !=''">
  315. AND s.status_ = #{param.status}
  316. </if>
  317. <if test="param.subjectId !=null">
  318. AND g.subject_id_ = #{param.subjectId}
  319. </if>
  320. <if test="param.classDate !=null and param.classDate !=''">
  321. AND s.class_date_ = #{param.classDate}
  322. </if>
  323. <if test="param.startDate !=null and param.startDate !=''">
  324. <![CDATA[ AND s.class_date_ >= #{param.startDate} ]]>
  325. </if>
  326. <if test="param.endDate !=null and param.endDate !=''">
  327. <![CDATA[ AND s.class_date_ <= #{param.endDate} ]]>
  328. </if>
  329. ORDER BY s.start_time_
  330. </select>
  331. <select id="queryCourseUser" resultType="com.yonge.cooleshow.biz.dal.vo.CourseStudent">
  332. SELECT
  333. cs.id_ AS courseId,
  334. cs.course_group_id_ AS courseGoupId,
  335. cs.class_date_ AS classDate,
  336. cs.start_time_ AS startTime,
  337. cs.end_time_ AS endTime,
  338. cs.status_ AS `status`,
  339. cs.type_ AS courseType,
  340. CONCAT(g.name_,'-第',cs.class_num_,'课') AS courseName,
  341. NULL AS userId,
  342. NULL AS name,
  343. NULL AS realName,
  344. p.payCount AS payCount,
  345. g.background_pic_ AS cover,
  346. g.subject_id_ AS subjectId,
  347. sb.name_ AS subjectName,
  348. (r.student_replied_ IS NOT NULL) AS studentReplied,
  349. (r.teacher_replied_ IS NOT NULL) AS teacherReplied,
  350. i.id_ AS imGroupId
  351. FROM course_schedule cs
  352. LEFT JOIN course_group g ON cs.course_group_id_ = g.id_
  353. LEFT JOIN (SELECT course_id_ AS pid,count(*) AS payCount FROM course_schedule_student_payment GROUP BY course_id_ ) p ON cs.id_=p.pid
  354. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  355. LEFT JOIN course_schedule_replied r ON cs.id_ = r.course_schedule_id_
  356. LEFT JOIN im_group i ON g.id_ = i.course_group_id_
  357. WHERE cs.lock_=0
  358. AND cs.status_ IN ('ING','COMPLETE','NOT_START')
  359. AND g.status_ IN ('ING', 'COMPLETE')
  360. AND cs.type_ IN ('LIVE','PIANO_ROOM_CLASS')
  361. AND cs.teacher_id_=#{param.teacherId}
  362. AND cs.class_date_=#{param.classDate}
  363. AND cs.id_ IN(
  364. SELECT c.id_
  365. FROM course_schedule_student_payment p,course_schedule c
  366. WHERE p.course_id_=c.id_
  367. AND p.course_group_id_ = c.course_group_id_
  368. AND c.teacher_id_=#{param.teacherId}
  369. AND c.class_date_=#{param.classDate}
  370. AND c.type_ IN ('LIVE','PIANO_ROOM_CLASS')
  371. )
  372. UNION
  373. SELECT
  374. p.course_id_ AS courseId,
  375. p.course_group_id_ AS courseGoupId,
  376. cs.class_date_ AS classDate,
  377. cs.start_time_ AS startTime,
  378. cs.end_time_ AS endTime,
  379. cs.status_ AS `status`,
  380. cs.type_ AS courseType,
  381. NULL AS courseName,
  382. u.id_ AS userId,
  383. u.username_ AS name,
  384. u.real_name_ AS realName,
  385. NULL AS payCount,
  386. u.avatar_ AS cover,
  387. g.subject_id_ AS subjectId,
  388. sb.name_ AS subjectName,
  389. (r.student_replied_ IS NOT NULL) AS studentReplied,
  390. (r.teacher_replied_ IS NOT NULL) AS teacherReplied,
  391. NULL AS imGroupId
  392. FROM course_schedule_student_payment p
  393. LEFT JOIN sys_user u ON p.user_id_ =u.id_
  394. LEFT JOIN course_schedule cs ON p.course_id_=cs.id_
  395. LEFT JOIN course_group g ON p.course_group_id_ = g.id_
  396. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  397. LEFT JOIN course_schedule_replied r ON cs.id_ = r.course_schedule_id_
  398. WHERE cs.lock_=0
  399. AND cs.status_ IN ('ING','COMPLETE','NOT_START')
  400. AND p.course_id_ IN (SELECT s.id_ FROM course_schedule s WHERE s.type_ IN ('PRACTICE','VIP') AND s.teacher_id_=#{param.teacherId})
  401. AND cs.class_date_=#{param.classDate}
  402. ORDER BY startTime
  403. </select>
  404. <select id="queryCourseScheduleStudent" resultType="java.lang.String"
  405. parameterType="com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch">
  406. SELECT class_date_ FROM course_schedule
  407. WHERE lock_=0
  408. AND status_ IN ('ING','NOT_START','COMPLETE')
  409. AND id_ IN (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{studentId})
  410. <![CDATA[ AND class_date_ >= #{startDate} ]]>
  411. <![CDATA[ AND class_date_ <= #{endDate} ]]>
  412. </select>
  413. <select id="teacherList" resultType="com.yonge.cooleshow.biz.dal.vo.PracticeTeacherVo">
  414. SELECT
  415. t.user_id_ AS teacherId,
  416. u.username_ AS userName,
  417. u.real_name_ AS realName,
  418. u.avatar_ AS avatar,
  419. tt.star_grade_ AS starGrade,
  420. tt.exp_time_ AS expTime,
  421. t.graduate_school_ AS school,
  422. t.subject_ AS schoolSubject,
  423. (SELECT group_concat(p.subject_name_) FROM teacher_subject_price p WHERE find_in_set(t.user_id_,p.teacher_id_)) AS configSubject,
  424. sp.subjectId AS subjectId,
  425. sp.subjectName AS subjectName,
  426. sp.subjectPrice AS subjectPrice,
  427. sp.courseMinutes AS courseMinutes
  428. FROM teacher t
  429. LEFT JOIN sys_user u ON t.user_id_ = u.id_
  430. LEFT JOIN teacher_total tt ON t.user_id_=tt.user_id_
  431. LEFT JOIN (SELECT
  432. f.teacher_id_ AS teacherId,
  433. p.subject_id_ AS subjectId,
  434. p.subject_name_ AS subjectName,
  435. p.subject_price_ AS subjectPrice,
  436. p.course_minutes_ AS courseMinutes
  437. FROM teacher_free_time f
  438. LEFT JOIN teacher_subject_price p ON f.id_=p.teacher_free_time_id
  439. WHERE f.default_flag_=1 AND f.enable_flag_=1
  440. AND p.subject_id_=#{param.subjectId}) sp ON t.user_id_=sp.teacherId
  441. <where>
  442. <if test="param.teacherIdList != null and param.teacherIdList.size>0">
  443. AND t.user_id_ IN
  444. <foreach collection="param.teacherIdList" item="item" open="(" separator="," close=")">
  445. #{item}
  446. </foreach>
  447. </if>
  448. <if test="param.subjectId !=null">
  449. AND sp.subjectId=#{param.subjectId}
  450. </if>
  451. <if test="param.search !=null and param.search !=''">
  452. AND u.username_ LIKE CONCAT('%', #{param.search}, '%')
  453. </if>
  454. <choose>
  455. <when test="param.sort !=null and param.sort !=''">
  456. ORDER BY ${param.sort}
  457. </when>
  458. </choose>
  459. </where>
  460. </select>
  461. <select id="queryCourseTeacher" resultType="com.yonge.cooleshow.biz.dal.vo.CourseStudent"
  462. parameterType="com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch">
  463. SELECT
  464. s.id_ AS courseId,
  465. s.course_group_id_ AS courseGoupId,
  466. s.class_date_ AS classDate,
  467. s.start_time_ AS startTime,
  468. s.end_time_ AS endTime,
  469. s.type_ AS courseType,
  470. s.status_ AS `status`,
  471. NULL AS courseName,
  472. u.id_ AS userId,
  473. u.username_ AS name,
  474. u.real_name_ AS realName,
  475. u.avatar_ AS cover,
  476. g.subject_id_ AS subjectId,
  477. b.name_ AS subjectName,
  478. ig.id_ AS imGroupId,
  479. (r.student_replied_ IS NOT NULL) AS studentReplied,
  480. (r.teacher_replied_ IS NOT NULL) AS teacherReplied,
  481. 1 AS payCount
  482. FROM course_schedule s
  483. LEFT JOIN sys_user u ON s.teacher_id_ = u.id_
  484. LEFT JOIN course_group g ON s.course_group_id_ = g.id_
  485. LEFT JOIN `subject` b ON g.subject_id_ = b.id_
  486. LEFT JOIN course_schedule_replied r ON s.id_ = r.course_schedule_id_
  487. LEFT JOIN im_group ig ON ig.course_group_id_ = g.id_
  488. WHERE s.lock_=0
  489. AND s.status_ IN ('ING','NOT_START','COMPLETE')
  490. AND s.id_ IN
  491. (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{param.studentId} AND course_type_ = 'PRACTICE')
  492. AND s.class_date_ = #{param.classDate}
  493. UNION
  494. SELECT
  495. s.id_ AS courseId,
  496. s.course_group_id_ AS courseGoupId,
  497. s.class_date_ AS classDate,
  498. s.start_time_ AS startTime,
  499. s.end_time_ AS endTime,
  500. s.type_ AS courseType,
  501. s.status_ AS `status`,
  502. CONCAT(g.name_,'-第',s.class_num_,'课') AS courseName,
  503. NULL AS userId,
  504. NULL AS name,
  505. NULL AS realName,
  506. g.background_pic_ AS cover,
  507. g.subject_id_ AS subjectId,
  508. sb.name_ AS subjectName,
  509. ig.id_ AS imGroupId,
  510. (r.student_replied_ IS NOT NULL) AS studentReplied,
  511. (r.teacher_replied_ IS NOT NULL) AS teacherReplied,
  512. IFNULL(a.payCount,0) AS payCount
  513. FROM course_schedule s
  514. LEFT JOIN course_group g ON s.course_group_id_ = g.id_
  515. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  516. LEFT JOIN course_schedule_replied r ON s.id_ = r.course_schedule_id_
  517. LEFT JOIN im_group ig ON ig.course_group_id_ = g.id_
  518. LEFT JOIN (SELECT course_id_,COUNT(1) AS payCount FROM course_schedule_student_payment GROUP BY course_id_) a ON s.id_=a.course_id_
  519. WHERE s.lock_=0
  520. AND s.status_ IN ('ING','NOT_START','COMPLETE')
  521. AND g.status_ IN ('ING', 'COMPLETE','APPLY','OUT_SALE')
  522. AND s.id_ IN
  523. (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{param.studentId} AND course_type_ IN ('LIVE','PIANO_ROOM_CLASS'))
  524. AND s.class_date_ = #{param.classDate}
  525. ORDER BY startTime
  526. </select>
  527. <select id="queryStudentLiveCourse" parameterType="map" resultType="com.yonge.cooleshow.biz.dal.vo.CourseStudent">
  528. SELECT distinct
  529. cs.id_ AS courseId,
  530. cs.course_group_id_ AS courseGoupId,
  531. cs.class_date_ AS classDate,
  532. cs.start_time_ AS startTime,
  533. cs.end_time_ AS endTime,
  534. cs.status_ AS `status`,
  535. cs.type_ AS courseType,
  536. su.username_ AS userId,
  537. CONCAT(g.name_,'-第',cs.class_num_,'课') AS name,
  538. IFNULL(g.pre_student_num_, 0) AS payCount,
  539. g.background_pic_ AS cover,
  540. g.subject_id_ AS subjectId,
  541. sb.name_ AS subjectName,
  542. su.avatar_ AS avatar,
  543. g.im_group_id_ as imGroupId
  544. FROM
  545. course_schedule_student_payment as a
  546. LEFT JOIN course_schedule cs on a.course_id_ = cs.id_
  547. LEFT JOIN course_group g ON cs.course_group_id_ = g.id_
  548. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  549. LEFT JOIN sys_user su on g.teacher_id_ = su.id_
  550. LEFT JOIN user_order o on a.order_no_ = o.order_no_
  551. WHERE cs.type_=#{param.type}
  552. AND a.user_id_ = #{param.studentId}
  553. <![CDATA[ AND class_date_ >= #{param.startDate} ]]>
  554. <![CDATA[ AND class_date_ <= #{param.endDate} ]]>
  555. <if test="param.orderState != null">
  556. AND o.status_ = #{param.orderState}
  557. </if>
  558. <if test="param.subjectId != null">
  559. AND g.subject_id_ = #{param.subjectId}
  560. </if>
  561. <if test="param.courseState != null">
  562. and cs.status_ = #{param.courseState}
  563. </if>
  564. </select>
  565. <insert id="addCourseGroup" parameterType="com.yonge.cooleshow.biz.dal.dto.PracticeScheduleDto" useGeneratedKeys="true" keyProperty="groupId">
  566. Insert INTO course_group(teacher_id_,type_,name_,subject_id_,single_course_minutes_,course_num_,course_introduce_,
  567. course_price_,status_,created_by_,mix_student_num_,course_start_time_,pre_student_num_)
  568. VALUES (#{teacherId},#{type},#{courseGroupName},#{subjectId},#{singleCourseMinutes},#{courseNum},#{courseIntroduce},
  569. #{coursePrice},#{status},#{studentId},#{mixStudentNum},#{courseStartTime},1)
  570. </insert>
  571. <update id="updateLock" parameterType="java.util.List">
  572. UPDATE course_schedule SET lock_ = 0 WHERE id_ IN
  573. <foreach collection="list" item="item" open="(" separator="," close=")">
  574. #{item}
  575. </foreach>
  576. </update>
  577. <update id="courseAdjust" parameterType="com.yonge.cooleshow.biz.dal.vo.CourseAdjustVo">
  578. UPDATE course_schedule
  579. SET class_date_=#{classDate},start_time_=#{startTime},end_time_=#{endTime}
  580. WHERE id_ = #{courseId}
  581. </update>
  582. <select id="selectLive" resultType="com.yonge.cooleshow.biz.dal.vo.StudentHomePage$Live">
  583. SELECT
  584. u.id_ AS teacherId,
  585. u.username_ AS teacherName,
  586. u.real_name_ AS realName,
  587. u.avatar_ AS avatar,
  588. g.id_ AS courseGroupId,
  589. g.name_ AS courseGroupName,
  590. g.course_price_ AS courseGroupPrice,
  591. g.course_start_time_ AS courseStartTime,
  592. g.background_pic_ AS backgroundPic,
  593. g.course_num_ AS courseNum,
  594. g.pre_student_num_ AS buyCount,
  595. g.subject_id_ AS subjectId,
  596. s.name_ AS subjectName
  597. FROM course_group g
  598. LEFT JOIN sys_user u ON g.teacher_id_=u.id_
  599. LEFT JOIN subject s ON g.subject_id_=s.id_
  600. WHERE u.del_flag_ = 0 and type_='LIVE' and g.status_ = 'APPLY' and #{appAuditVersion} = g.audit_version_
  601. <if test="subjectId != null">
  602. and g.subject_id_ = #{subjectId}
  603. </if>
  604. ORDER BY courseStartTime DESC LIMIT 4
  605. </select>
  606. <select id="selectVideo" resultType="com.yonge.cooleshow.biz.dal.vo.StudentHomePage$Video">
  607. SELECT
  608. u.id_ AS teacherId,
  609. u.username_ AS teacherName,
  610. u.real_name_ AS realName,
  611. u.avatar_ AS avatar,
  612. g.id_ AS videoGroupId,
  613. g.lesson_name_ AS videoGroupName,
  614. g.lesson_price_ AS lessonPrice,
  615. g.create_time_ AS createTime,
  616. g.lesson_cover_url_ AS lessonCoverUrl,
  617. g.lesson_count_ AS lessonCount,
  618. g.lesson_subject_ AS subjectId,
  619. s.name_ AS subjectName,
  620. IFNULL(r.count_,0) AS buyCount
  621. FROM video_lesson_group g
  622. LEFT JOIN sys_user u ON g.teacher_id_=u.id_
  623. LEFT JOIN `subject` s ON g.lesson_subject_=s.id_
  624. LEFT JOIN (SELECT video_lesson_group_id_ ,COUNT(1) AS count_ FROM video_lesson_purchase_record WHERE order_status_='PAID' GROUP BY video_lesson_group_id_) r ON g.id_= r.video_lesson_group_id_
  625. WHERE u.del_flag_ = 0 and g.audit_status_='PASS' and g.shelves_flag_ = 1 and #{appAuditVersion} = g.audit_version_
  626. <if test="subjectId != null">
  627. and g.lesson_subject_ = #{subjectId}
  628. </if>
  629. ORDER BY g.top_flag_ desc, g.sort_number_ desc, buyCount DESC LIMIT 10
  630. </select>
  631. <select id="selectRecentCourses" resultType="com.yonge.cooleshow.biz.dal.vo.StudentHomePage$RecentCourses">
  632. SELECT
  633. u.id_ AS teacherId,
  634. u.username_ AS teacherName,
  635. u.real_name_ AS realName,
  636. u.avatar_ AS avatar,
  637. p.course_group_id_ AS courseGroupId,
  638. p.course_id_ AS courseId,
  639. g.name_ AS courseGroupName,
  640. p.course_type_ AS courseType,
  641. s.status_ AS `status`,
  642. s.start_time_ AS courseStartTime
  643. FROM course_schedule_student_payment p
  644. LEFT JOIN course_schedule s ON p.course_id_=s.id_
  645. LEFT JOIN sys_user u ON s.teacher_id_=u.id_
  646. LEFT JOIN course_group g ON p.course_group_id_=g.id_
  647. WHERE p.user_id_=#{studentId}
  648. AND s.status_ = 'ING'
  649. ORDER BY ABS(NOW() - s.start_time_) ASC
  650. limit 1
  651. </select>
  652. <select id="selectRecentCoursesPractice" resultType="com.yonge.cooleshow.biz.dal.vo.StudentHomePage$RecentCourses">
  653. SELECT
  654. p.user_id_ AS studentId,
  655. u.id_ AS teacherId,
  656. u.username_ AS teacherName,
  657. u.real_name_ AS realName,
  658. u.avatar_ AS avatar,
  659. s.course_group_id_ AS courseGroupId,
  660. s.id_ AS courseId,
  661. g.name_ AS courseGroupName,
  662. s.type_ AS courseType,
  663. s.status_ AS `status`,
  664. s.start_time_ AS courseStartTime
  665. FROM course_schedule s
  666. LEFT JOIN sys_user u ON s.teacher_id_=u.id_
  667. LEFT JOIN course_group g ON s.course_group_id_=g.id_
  668. LEFT JOIN course_schedule_student_payment p ON s.id_=p.course_id_
  669. WHERE s.teacher_id_=#{teacherId}
  670. AND s.type_ IN ('PRACTICE','VIP')
  671. AND s.status_ = 'ING'
  672. ORDER BY ABS(NOW() - s.start_time_) ASC
  673. limit 1
  674. </select>
  675. <select id="selectRecentCoursesLive" resultType="com.yonge.cooleshow.biz.dal.vo.StudentHomePage$RecentCourses"
  676. parameterType="java.lang.Long">
  677. SELECT
  678. u.id_ AS teacherId,
  679. u.username_ AS teacherName,
  680. u.real_name_ AS realName,
  681. u.avatar_ AS avatar,
  682. s.course_group_id_ AS courseGroupId,
  683. s.id_ AS courseId,
  684. g.name_ AS courseGroupName,
  685. s.type_ AS courseType,
  686. s.status_ AS `status`,
  687. s.start_time_ AS courseStartTime
  688. FROM course_schedule s
  689. LEFT JOIN sys_user u ON s.teacher_id_=u.id_
  690. LEFT JOIN course_group g ON s.course_group_id_=g.id_
  691. WHERE s.teacher_id_=#{teacherId}
  692. AND s.type_ IN ('LIVE','PIANO_ROOM_CLASS')
  693. AND s.status_ ='ING'
  694. ORDER BY ABS(NOW() - s.start_time_) ASC
  695. limit 1
  696. </select>
  697. <select id="selectWeekNotStartCourseSchedule" resultType="java.lang.Integer">
  698. select count(1)
  699. from course_schedule cs
  700. left join course_group cg on cs.course_group_id_ = cg.id_
  701. where cs.teacher_id_ = #{userId} and cs.status_ in ('NOT_START','ING') and cg.status_ = 'ING'
  702. and YEARWEEK(date_format(cs.class_date_,'%Y-%m-%d'),7) = YEARWEEK(now(),7)
  703. </select>
  704. <select id="selectHomeworkNotDecorate" resultType="java.lang.Integer">
  705. select count(1)
  706. from course_schedule cs
  707. left join course_homework ch on cs.id_ = ch.course_schedule_id_
  708. where cs.teacher_id_ = #{userId} and cs.status_ = 'COMPLETE' and cs.type_ in( 'PRACTICE','PIANO_ROOM_CLASS')
  709. and YEARWEEK(date_format(cs.class_date_,'%Y-%m-%d'),7) = YEARWEEK(now(),7)
  710. and ch.id_ is null
  711. </select>
  712. <select id="selectNotRepliedCourseSchedule" resultType="java.lang.Integer">
  713. select count(1)
  714. from course_schedule cs
  715. left join course_schedule_replied csr on cs.id_ = csr.course_schedule_id_
  716. where cs.teacher_id_ = #{userId} and cs.status_ = 'COMPLETE' and cs.type_ = 'PRACTICE'
  717. and csr.teacher_replied_ is null
  718. </select>
  719. <select id="selectWeekStudentRepliedCourseSchedule" resultType="java.lang.Integer">
  720. select count(1)
  721. from course_schedule cs
  722. left join course_schedule_replied csr on cs.id_ = csr.course_schedule_id_
  723. where cs.teacher_id_ = #{userId} and cs.status_ = 'COMPLETE' and cs.type_ = 'PRACTICE'
  724. and csr.student_replied_ is not null
  725. and YEARWEEK(date_format(csr.student_replied_time_,'%Y-%m-%d'),7) = YEARWEEK(now(),7)
  726. </select>
  727. <select id="selectStartTime" resultType="java.lang.String" parameterType="java.lang.String">
  728. SELECT s.start_time_
  729. FROM course_schedule_student_payment p
  730. LEFT JOIN course_schedule s ON p.course_id_=s.id_
  731. WHERE p.order_no_=#{orderNo}
  732. </select>
  733. <select id="selectTeacher" resultType="com.yonge.cooleshow.auth.api.entity.SysUser"
  734. parameterType="java.lang.String">
  735. SELECT DISTINCT
  736. s.teacher_id_ AS id,
  737. u.phone_ AS phone
  738. FROM course_schedule s
  739. LEFT JOIN sys_user u ON s.teacher_id_ = u.id_
  740. LEFT JOIN course_group g ON s.course_group_id_=g.id_
  741. WHERE lock_=0
  742. AND class_date_ = DATE_SUB(curdate(),INTERVAL -1 DAY)
  743. AND g.status_='ING'
  744. </select>
  745. <select id="selectTypeCount" resultType="com.yonge.cooleshow.biz.dal.vo.CountVo">
  746. SELECT
  747. s.type_ AS type,
  748. COUNT(1) AS `count`
  749. FROM course_schedule s
  750. LEFT JOIN course_group g ON s.course_group_id_=g.id_
  751. WHERE s.lock_=0
  752. AND s.teacher_id_=#{teacherId}
  753. AND s.class_date_=DATE_SUB(curdate(),INTERVAL -1 DAY)
  754. AND g.status_='ING'
  755. GROUP BY s.type_
  756. </select>
  757. <select id="selectTodayNotRepliedAndNotDecorateHomework"
  758. resultType="com.yonge.cooleshow.biz.dal.vo.TodayNotRepliedAndNotDecorateHomeworkVo">
  759. select sum(if(ch.id_ is null,1,0)) as decorateNum,
  760. sum(if(csr.teacher_replied_ is null,1,0)) as repliedNum,
  761. su.id_ as teacherId,
  762. su.phone_ as phone
  763. from course_schedule cs
  764. left join course_schedule_replied csr on cs.id_ = csr.course_schedule_id_
  765. left join course_homework ch on cs.id_ = ch.course_schedule_id_
  766. left join sys_user su on cs.teacher_id_ = su.id_
  767. where cs.status_ = 'COMPLETE' and date_format(cs.class_date_,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
  768. and cs.type_ = 'PRACTICE'
  769. group by su.id_,su.phone_
  770. </select>
  771. <select id="countAllReplie" resultType="com.yonge.cooleshow.biz.dal.vo.RepliedCountVo"
  772. parameterType="java.lang.String">
  773. SELECT
  774. p.user_id_ AS userId,
  775. u.phone_ AS phone,
  776. COUNT(1) AS count
  777. FROM course_schedule_student_payment p
  778. LEFT JOIN sys_user u ON p.user_id_=u.id_
  779. WHERE p.course_id_ IN (SELECT id_ FROM course_schedule WHERE class_date_=#{today} AND lock_=0 AND type_='PRACTICE')
  780. GROUP BY p.user_id_;
  781. </select>
  782. <select id="countReplies" resultType="java.lang.Integer">
  783. SELECT COUNT(1)
  784. FROM course_schedule_replied
  785. WHERE student_id_=#{studentId}
  786. </select>
  787. <select id="queryCourseHomeOfYear" parameterType="map"
  788. resultType="com.yonge.cooleshow.biz.dal.vo.CourseHomeVo$CourseHomeInfoVo">
  789. select `date`,
  790. sum(a.not_start_count) as undoneCount,
  791. sum(a.complete_count) as doneCount
  792. from (select date_format(class_date_, '%Y-%m-01') as `date`,
  793. ifnull(case when status_ in ('NOT_START', 'ING') then count(1) end, 0) as not_start_count,
  794. ifnull(case when status_ = 'COMPLETE' then count(1) end, 0) as complete_count
  795. from course_schedule
  796. where type_ = #{param.type}
  797. and status_ in ('NOT_START', 'ING', 'COMPLETE')
  798. <![CDATA[ AND class_date_ >= #{param.startDate} ]]>
  799. <![CDATA[ AND class_date_ <= #{param.endDate} ]]>
  800. group by class_date_) as a
  801. group by date
  802. </select>
  803. <select id="queryCourseHomeOfMonth" parameterType="map"
  804. resultType="com.yonge.cooleshow.biz.dal.vo.CourseHomeVo$CourseHomeInfoVo">
  805. select class_date_ as `date`,
  806. sum( CASE WHEN status_ IN ( 'NOT_START', 'ING' ) THEN 1 else 0 END ) AS undoneCount,
  807. sum( CASE WHEN status_ = 'COMPLETE' THEN 1 else 0 END ) AS doneCount
  808. from course_schedule
  809. where type_ = #{param.type}
  810. and status_ in ('NOT_START', 'ING', 'COMPLETE')
  811. <![CDATA[ AND class_date_ >= #{param.startDate} ]]>
  812. <![CDATA[ AND class_date_ <= #{param.endDate} ]]>
  813. group by class_date_
  814. </select>
  815. <select id="selectPrice" resultType="java.math.BigDecimal">
  816. SELECT p.subject_price_
  817. FROM teacher_free_time t
  818. LEFT JOIN teacher_subject_price p ON t.id_=p.teacher_free_time_id
  819. WHERE t.teacher_id_=#{teacherId}
  820. AND p.subject_id_=#{subjectId}
  821. AND t.default_flag_=1
  822. </select>
  823. <select id="selectSchedule" resultType="com.yonge.cooleshow.biz.dal.entity.CourseSchedule"
  824. parameterType="java.lang.Integer">
  825. SELECT * FROM course_schedule
  826. WHERE id_ IN (
  827. SELECT course_id_ FROM course_schedule_student_payment
  828. WHERE user_id_=(SELECT user_id_ FROM course_schedule_student_payment WHERE course_id_=#{courseId} AND course_type_='PRACTICE')
  829. )
  830. </select>
  831. <select id="teacherIdList" resultType="java.lang.Long">
  832. SELECT teacher_id_ FROM teacher_free_time WHERE enable_flag_=1 GROUP BY teacher_id_
  833. </select>
  834. <select id="selectIdList" resultType="java.lang.Long">
  835. SELECT id_ FROM course_schedule WHERE lock_=0 AND class_date_ &lt;= #{day}
  836. </select>
  837. <select id="selectComplete" resultType="com.yonge.cooleshow.biz.dal.vo.CourseCompleteVo">
  838. SELECT *
  839. FROM (
  840. SELECT course_group_id_ AS courseGroupId ,COUNT(1) AS courseCount
  841. FROM course_schedule
  842. WHERE lock_=0 AND status_='COMPLETE' GROUP BY course_group_id_) a
  843. LEFT JOIN course_group g ON g.id_=a.courseGroupId
  844. </select>
  845. <update id="updateStartTime">
  846. UPDATE course_schedule SET status_='ING' WHERE id_ IN(
  847. <foreach collection="list" item="item" index="index" open="" close="" separator=",">
  848. #{item.id}
  849. </foreach>)
  850. </update>
  851. <update id="updateEndTime">
  852. UPDATE course_schedule SET status_='COMPLETE' WHERE id_ IN(
  853. <foreach collection="list" item="item" index="index" open="" close="" separator=",">
  854. #{item.courseId}
  855. </foreach>)
  856. </update>
  857. <update id="updateTeacherSalary" parameterType="java.util.List">
  858. UPDATE course_schedule_teacher_salary
  859. SET status_='COMPLETE',settlement_time_=NOW()
  860. WHERE status_='NOT_START'
  861. AND course_schedule_id_ IN
  862. <foreach collection="list" item="item" open="(" separator="," close=")">
  863. #{item}
  864. </foreach>
  865. </update>
  866. <select id="queryPianoClass" resultType="com.yonge.cooleshow.biz.dal.vo.PianoClassVo">
  867. SELECT DISTINCT
  868. s.id_ AS courseId,
  869. g.id_ AS courseGroupId,
  870. CONCAT(g.name_,'-第',s.class_num_,'课') AS courseGroupName,
  871. b.id_ AS subjectId,
  872. b.name_ AS subjectName,
  873. s.teacher_id_ AS teacherId,
  874. u.username_ AS teacherName,
  875. u.real_name_ AS teacherRealName,
  876. u.avatar_ AS avatar,
  877. s.status_ AS `status`,
  878. i.id_ AS imGroupId,
  879. s.start_time_ AS startTime,
  880. s.end_time_ AS endTime,
  881. CASE WHEN a.sign_in_time_ IS NOT NULL THEN 1 ELSE 0 END AS studentSign
  882. FROM course_schedule s
  883. LEFT JOIN sys_user u ON s.teacher_id_=u.id_
  884. LEFT JOIN course_group g ON s.course_group_id_=g.id_
  885. LEFT JOIN `subject` b ON g.subject_id_=b.id_
  886. LEFT JOIN course_schedule_student_payment p ON s.id_=p.course_id_
  887. LEFT JOIN student_attendance a ON s.id_=a.course_group_id_
  888. LEFT JOIN im_group i ON s.course_group_id_=i.course_group_id_
  889. WHERE s.type_='PIANO_ROOM_CLASS'
  890. AND p.user_id_=#{param.studentId}
  891. <if test="param.status !=null and param.status !=''">
  892. AND s.status_ = #{param.status}
  893. </if>
  894. <if test="param.subjectId !=null">
  895. AND b.id_ = #{param.subjectId}
  896. </if>
  897. <if test="param.classMonth !=null">
  898. <![CDATA[ AND s.class_date_ >= #{param.startDate} ]]>
  899. <![CDATA[ AND s.class_date_ <= #{param.endDate} ]]>
  900. </if>
  901. ORDER BY s.start_time_
  902. </select>
  903. <select id="selectWaitCourse" resultType="com.yonge.cooleshow.biz.dal.dto.UserAccountRecordDto">
  904. SELECT DISTINCT
  905. ts.teacher_id_ AS userId,
  906. ts.actual_salary_ AS transAmount,
  907. ts.course_group_type_ AS bizType,
  908. ts.course_schedule_id_ AS bizId,
  909. lr.room_title_ AS bizName,
  910. 'IN' AS inOrOut,
  911. sp.order_no_ AS orderNo,
  912. ts.update_time_ AS updateTime
  913. FROM course_schedule_teacher_salary ts
  914. LEFT JOIN live_room lr ON ts.course_schedule_id_ = lr.course_id_
  915. LEFT JOIN course_schedule_student_payment sp ON ts.course_schedule_id_ = sp.course_id_
  916. WHERE ts.course_group_type_ = 'LIVE'
  917. AND ts.status_ = 'WAIT'
  918. <![CDATA[ AND DATE_FORMAT(ts.update_time_,'%Y-%m-%d') <= #{day}]]>
  919. UNION
  920. SELECT DISTINCT
  921. ts.teacher_id_ AS userId,
  922. ts.actual_salary_ AS transAmount,
  923. ts.course_group_type_ AS bizType,
  924. ts.course_schedule_id_ AS bizId,
  925. g.name_ AS bizName,
  926. 'IN' AS inOrOut,
  927. sp.order_no_ AS orderNo,
  928. ts.update_time_ AS updateTime
  929. FROM course_schedule_teacher_salary ts
  930. LEFT JOIN course_group g ON ts.course_group_id_ = g.id_
  931. LEFT JOIN course_schedule_student_payment sp ON ts.course_schedule_id_ = sp.course_id_
  932. WHERE ts.course_group_type_ = 'PRACTICE'
  933. AND ts.status_ = 'WAIT'
  934. <![CDATA[ AND DATE_FORMAT(ts.update_time_,'%Y-%m-%d') <= #{day}]]>
  935. </select>
  936. <select id="selectStudentPianoCourse"
  937. resultType="com.yonge.cooleshow.biz.dal.vo.userBindingTeacher.UserBindingTeacherWrapper$CourseNum">
  938. select cssp.user_id_ as studentId
  939. ,cs.status_ as status
  940. from course_schedule_student_payment cssp
  941. left join course_group cg on cg.id_ = cssp.course_group_id_
  942. left join course_schedule cs on cs.id_ = cssp.course_id_
  943. <where>
  944. cssp.course_type_ = 'PIANO_ROOM_CLASS'
  945. and #{teacherId} = cg.teacher_id_
  946. and cs.status_ in ('NOT_START','ING','COMPLETE')
  947. and cssp.user_id_ in
  948. <foreach collection="studentIdList" close=")" open="(" item="item" separator=",">
  949. #{item}
  950. </foreach>
  951. </where>
  952. </select>
  953. <select id="selectBindingUserCoursePage"
  954. resultType="com.yonge.cooleshow.biz.dal.vo.userBindingTeacher.UserBindingCourseWrapper">
  955. select cssp.user_id_ as studentId
  956. ,cs.status_ as courseStatus
  957. ,cs.id_ as courseId
  958. ,cg.subject_id_ as subjectId
  959. ,cs.class_date_ as classDate
  960. ,cs.start_time_ as startTime
  961. ,cs.end_time_ as endTime
  962. ,cg.subject_id_ as subjectId
  963. from course_schedule_student_payment cssp
  964. left join course_group cg on cg.id_ = cssp.course_group_id_
  965. left join course_schedule cs on cs.id_ = cssp.course_id_
  966. <where>
  967. cssp.course_type_ = 'PIANO_ROOM_CLASS'
  968. and #{query.teacherId} = cg.teacher_id_
  969. and cs.status_ in ('NOT_START','ING','COMPLETE')
  970. and cssp.user_id_ =#{query.studentId}
  971. </where>
  972. </select>
  973. </mapper>