CourseScheduleMapper.xml 46 KB

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