CourseScheduleMapper.xml 46 KB

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