CourseScheduleMapper.xml 43 KB

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