CourseScheduleMapper.xml 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  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. </resultMap>
  22. <sql id="Base_Column_List">
  23. id_
  24. , course_group_id_, type_, status_,class_num_, teacher_id_, class_date_, start_time_, end_time_, lock_, lock_time_, ex_student_num_, created_by_, created_time_, updated_by_, updated_time_
  25. </sql>
  26. <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
  27. parameterType="com.yonge.cooleshow.biz.dal.entity.CourseSchedule">
  28. insert into course_schedule(course_group_id_, type_, status_,class_num_, teacher_id_, class_date_, start_time_,
  29. end_time_, lock_, lock_time_, ex_student_num_, created_by_, created_time_, updated_by_,
  30. updated_time_)
  31. values
  32. <foreach collection="entities" item="entity" separator=",">
  33. (#{entity.courseGroupId}, #{entity.type}, #{entity.status},#{entity.classNum}, #{entity.teacherId}, #{entity.classDate},
  34. #{entity.startTime}, #{entity.endTime}, #{entity.lock}, #{entity.lockTime},
  35. #{entity.exStudentNum}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy},
  36. #{entity.updatedTime})
  37. </foreach>
  38. </insert>
  39. <select id="queryTeacherTotal" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherTotalVo">
  40. select a.*,b.starGrade from (
  41. <!-- 统计查询已上课时数,未上课时数 -->
  42. select
  43. a.teacher_id_ as userId,
  44. sum(if(a.end_time_ &lt;= now(),1,0)) as expTime,
  45. sum(if(a.end_time_ &gt; now(),1,0)) as unExpTime
  46. from course_schedule a
  47. where a.lock_ = 0 and a.type_ = 'PRACTICE'
  48. group by a.teacher_id_
  49. ) a
  50. left join (
  51. <!-- 统计老师星级评分 -->
  52. select
  53. a.teacher_id_ as userId,
  54. avg (b.score_) as starGrade
  55. from course_schedule a
  56. join course_schedule_replied b on a.id_ = b.course_schedule_id_
  57. where a.lock_ = 0 and type_ = 'PRACTICE' and b.score_ is not null
  58. group by a.teacher_id_
  59. ) b on a.userId = b.userId
  60. </select>
  61. <select id="queryStudentTotal" resultType="com.yonge.cooleshow.biz.dal.vo.StudentTotalVo">
  62. select
  63. b.user_id_ as userId,
  64. sum(if(a.end_time_ &lt;= now(),1,0)) as finshHours,
  65. sum(if(a.end_time_ &gt; now(),1,0)) as unfinshHours
  66. from course_schedule a
  67. join course_schedule_student_payment b on a.id_ = b.course_id_
  68. where a.lock_ = 0 and a.type_ = 'PRACTICE'
  69. group by b.user_id_
  70. </select>
  71. <select id="queryStudentCourse" resultMap="BaseResultMap">
  72. select b.id_,
  73. b.course_group_id_,
  74. b.type_,
  75. b.class_num_,
  76. b.teacher_id_,
  77. b.class_date_,
  78. b.start_time_,
  79. b.end_time_,
  80. b.lock_,
  81. b.lock_time_,
  82. b.ex_student_num_,
  83. b.status_,
  84. b.created_by_,
  85. b.created_time_,
  86. b.updated_by_,
  87. b.updated_time_
  88. from course_schedule_student_payment as a
  89. left join course_schedule as b on a.course_id_ = b.id_
  90. <where>
  91. a.user_id_ = #{param.studentId}
  92. <if test="param.greaterDate != null">
  93. AND <![CDATA[ b.start_time_ > #{param.greaterDate} ]]>
  94. </if>
  95. <if test="param.startClassDate != null">
  96. AND <![CDATA[ b.class_date_ >= #{param.startClassDate} ]]>
  97. </if>
  98. <if test="param.endClassDate != null">
  99. AND <![CDATA[ b.class_date_ <= #{param.endClassDate} ]]>
  100. </if>
  101. <if test="param.classDate != null">
  102. AND b.class_date_ = #{param.classDate}
  103. </if>
  104. <if test="param.status != null">
  105. AND b.status_ = #{param.status}
  106. </if>
  107. <if test="param.statusList != null">
  108. AND b.status_ IN
  109. <foreach collection="param.statusList" item="item" open="(" separator="," close=")">
  110. #{item}
  111. </foreach>
  112. </if>
  113. </where>
  114. order by b.start_time_ desc
  115. </select>
  116. <select id="queryLiveTeacherCourse" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherLiveCourseInfoVo">
  117. select
  118. b.id_ as courseGroupId,
  119. b.name_ as courseGroupName,
  120. a.id_ as courseId,
  121. a.class_num_ as classNum,
  122. s.name_ as subjectName,
  123. a.start_time_ as startTime,
  124. a.end_time_ as endTime,
  125. a.status_ as `status`,
  126. b.pre_student_num_ as studentCount,
  127. b.background_pic_ as backgroundPic,
  128. b.im_group_id_ as imGroupId
  129. from course_schedule as a
  130. left join course_group as b on a.course_group_id_ = b.id_
  131. left join subject as s on b.subject_id_ = s.id_
  132. where b.teacher_id_ = #{param.teacherId}
  133. AND a.lock_ = 0
  134. AND a.type_ = #{param.type}
  135. <![CDATA[ AND a.class_date_ >= #{param.startDate} ]]>
  136. <![CDATA[ AND a.class_date_ <= #{param.endDate} ]]>
  137. <if test="param.status !=null and param.status !=''">
  138. AND a.status_ = #{param.status}
  139. </if>
  140. <if test="param.subjectId != null">
  141. AND b.subject_id_ = #{param.subjectId}
  142. </if>
  143. order by start_time_
  144. </select>
  145. <select id="queryTeacherPracticeCourse" resultType="com.yonge.cooleshow.biz.dal.vo.MyCourseVo">
  146. SELECT
  147. u.id_ AS userId,
  148. u.username_ AS userName,
  149. u.real_name_ AS realName,
  150. u.avatar_ AS avatar,
  151. cs.class_date_ AS classDate,
  152. cs.start_time_ AS startTime,
  153. cs.end_time_ AS endTime,
  154. cs.status_ AS `status`,
  155. g.subject_id_ AS subjectId,
  156. sb.name_ AS subjectName,
  157. p.course_id_ AS courseId,
  158. p.course_group_id_ AS courseGoupId
  159. FROM course_schedule_student_payment p
  160. LEFT JOIN sys_user u ON p.user_id_ =u.id_
  161. LEFT JOIN course_schedule cs ON p.course_id_=cs.id_
  162. LEFT JOIN course_group g ON p.course_group_id_ = g.id_
  163. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  164. WHERE p.course_id_ IN
  165. (SELECT s.id_ FROM course_schedule s WHERE s.type_='PRACTICE' AND s.teacher_id_=#{param.teacherId})
  166. <if test="param.status !=null and param.status !=''">
  167. AND cs.status_ = #{param.status}
  168. </if>
  169. <if test="param.subjectId !=null">
  170. AND g.subject_id_ = #{param.subjectId}
  171. </if>
  172. <if test="param.classDate !=null and param.classDate !=''">
  173. AND cs.class_date_ = #{param.classDate}
  174. </if>
  175. <if test="param.startDate !=null and param.startDate !=''">
  176. <![CDATA[ AND cs.class_date_ >= #{param.startDate} ]]>
  177. </if>
  178. <if test="param.endDate !=null and param.endDate !=''">
  179. <![CDATA[ AND cs.class_date_ <= #{param.endDate} ]]>
  180. </if>
  181. <if test="param.repliedIds !=null">
  182. AND p.user_id_ IN
  183. <foreach collection="param.repliedIds" item="repliedIds" open="(" close=")" separator=",">
  184. #{repliedIds}
  185. </foreach>
  186. </if>
  187. <if test="param.studentName !=null and param.studentName !=''">
  188. AND u.username_ LIKE CONCAT('%', #{param.studentName}, '%')
  189. </if>
  190. ORDER BY cs.start_time_
  191. </select>
  192. <select id="countTeacherNoDecorateHomework" resultType="java.lang.Integer">
  193. select count(1)
  194. from course_schedule cs
  195. left join course_homework ch on ch.course_schedule_id_ = cs.id_
  196. <where>
  197. <!-- 没有布置作业记录 -->
  198. <if test="param.decorate != null">
  199. <if test="param.decorate.code == 0">
  200. and ch.id_ is null
  201. </if>
  202. <if test="param.decorate.code == 1">
  203. and ch.id_ is not null
  204. </if>
  205. </if>
  206. <if test="param.courseStatus != null">
  207. and cs.type_ = #{param.courseType}
  208. </if>
  209. <if test="param.courseType != null">
  210. and cs.status_ = #{param.courseStatus}
  211. </if>
  212. <if test="param.teacherId != null">
  213. and cs.teacher_id_ = #{param.teacherId}
  214. </if>
  215. <if test="param.courseScheduleId != null ">
  216. and cs.id_ = #{param.courseScheduleId}
  217. </if>
  218. </where>
  219. </select>
  220. <select id="queryCourseSchedule" resultType="java.lang.String"
  221. parameterType="com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch">
  222. SELECT s.class_date_
  223. FROM course_schedule_student_payment p
  224. LEFT JOIN course_schedule s ON p.course_id_ = s.id_
  225. WHERE s.teacher_id_=#{teacherId}
  226. <![CDATA[ AND s.class_date_ >= #{startDate} ]]>
  227. <![CDATA[ AND s.class_date_ <= #{endDate} ]]>
  228. </select>
  229. <select id="queryStudentPracticeCourse" resultType="com.yonge.cooleshow.biz.dal.vo.MyCourseVo">
  230. SELECT
  231. s.id_ AS courseId,
  232. s.course_group_id_ AS courseGoupId,
  233. s.class_date_ AS classDate,
  234. s.start_time_ AS startTime,
  235. s.end_time_ AS endTime,
  236. s.status_ AS `status`,
  237. s.teacher_id_ AS teacherId,
  238. u.id_ AS userId,
  239. u.username_ AS userName,
  240. u.real_name_ AS realName,
  241. u.avatar_ AS avatar,
  242. g.subject_id_ AS subjectId,
  243. b.name_ AS subjectName
  244. FROM course_schedule s
  245. LEFT JOIN sys_user u ON s.teacher_id_ = u.id_
  246. LEFT JOIN course_group g ON s.course_group_id_ = g.id_
  247. LEFT JOIN `subject` b ON g.subject_id_ = b.id_
  248. WHERE s.id_ IN
  249. (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{param.studentId} AND course_type_ = 'PRACTICE')
  250. <if test="param.status !=null and param.status !=''">
  251. AND s.status_ = #{param.status}
  252. </if>
  253. <if test="param.subjectId !=null">
  254. AND g.subject_id_ = #{param.subjectId}
  255. </if>
  256. <if test="param.classDate !=null and param.classDate !=''">
  257. AND s.class_date_ = #{param.classDate}
  258. </if>
  259. <if test="param.startDate !=null and param.startDate !=''">
  260. <![CDATA[ AND s.class_date_ >= #{param.startDate} ]]>
  261. </if>
  262. <if test="param.endDate !=null and param.endDate !=''">
  263. <![CDATA[ AND s.class_date_ <= #{param.endDate} ]]>
  264. </if>
  265. </select>
  266. <select id="queryCourseUser" resultType="com.yonge.cooleshow.biz.dal.vo.CourseStudent">
  267. SELECT
  268. cs.id_ AS courseId,
  269. cs.course_group_id_ AS courseGoupId,
  270. cs.class_date_ AS classDate,
  271. cs.start_time_ AS startTime,
  272. cs.end_time_ AS endTime,
  273. cs.status_ AS `status`,
  274. cs.type_ AS courseType,
  275. NULL AS userId,
  276. CONCAT(g.name_,'-第',cs.class_num_,'课') AS name,
  277. NULL AS realName,
  278. p.payCount AS payCount,
  279. g.background_pic_ AS cover,
  280. g.subject_id_ AS subjectId,
  281. sb.name_ AS subjectName
  282. FROM course_schedule cs
  283. LEFT JOIN course_group g ON cs.course_group_id_ = g.id_
  284. 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
  285. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  286. WHERE cs.type_='LIVE'
  287. AND cs.teacher_id_=#{param.teacherId}
  288. AND cs.class_date_=#{param.classDate}
  289. AND cs.id_ IN(
  290. SELECT c.id_
  291. FROM course_schedule_student_payment p,course_schedule c
  292. WHERE p.course_id_=c.id_
  293. AND p.course_group_id_ = c.course_group_id_
  294. AND c.teacher_id_=#{param.teacherId}
  295. AND c.class_date_=#{param.classDate}
  296. AND c.type_='LIVE')
  297. UNION
  298. SELECT
  299. p.course_id_ AS courseId,
  300. p.course_group_id_ AS courseGoupId,
  301. cs.class_date_ AS classDate,
  302. cs.start_time_ AS startTime,
  303. cs.end_time_ AS endTime,
  304. cs.status_ AS `status`,
  305. cs.type_ AS courseType,
  306. u.id_ AS userId,
  307. u.username_ AS name,
  308. u.real_name_ AS realName,
  309. NULL AS payCount,
  310. u.avatar_ AS cover,
  311. g.subject_id_ AS subjectId,
  312. sb.name_ AS subjectName
  313. FROM course_schedule_student_payment p
  314. LEFT JOIN sys_user u ON p.user_id_ =u.id_
  315. LEFT JOIN course_schedule cs ON p.course_id_=cs.id_
  316. LEFT JOIN course_group g ON p.course_group_id_ = g.id_
  317. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  318. WHERE p.course_id_ IN (SELECT s.id_ FROM course_schedule s WHERE s.type_='PRACTICE' AND s.teacher_id_=#{param.teacherId})
  319. AND cs.class_date_=#{param.classDate}
  320. ORDER BY startTime
  321. </select>
  322. <select id="queryCourseScheduleStudent" resultType="java.lang.String"
  323. parameterType="com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch">
  324. SELECT class_date_ FROM course_schedule
  325. WHERE id_ IN (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{studentId})
  326. <![CDATA[ AND class_date_ >= #{startDate} ]]>
  327. <![CDATA[ AND class_date_ <= #{endDate} ]]>
  328. </select>
  329. <select id="teacherList" resultType="com.yonge.cooleshow.biz.dal.vo.PracticeTeacherVo">
  330. SELECT
  331. t.user_id_ AS teacherId,
  332. u.username_ AS userName,
  333. u.real_name_ AS realName,
  334. u.avatar_ AS avatar,
  335. tt.star_grade_ AS starGrade,
  336. tt.exp_time_ AS expTime,
  337. t.graduate_school_ AS school,
  338. t.subject_ AS schoolSubject,
  339. (SELECT group_concat(p.subject_name_) FROM teacher_subject_price p WHERE find_in_set(t.user_id_,p.teacher_id_)) AS configSubject,
  340. sp.subjectId AS subjectId,
  341. sp.subjectName AS subjectName,
  342. sp.subjectPrice AS subjectPrice,
  343. sp.courseMinutes AS courseMinutes
  344. FROM teacher t
  345. LEFT JOIN sys_user u ON t.user_id_ = u.id_
  346. LEFT JOIN teacher_total tt ON t.user_id_=tt.user_id_
  347. LEFT JOIN (SELECT
  348. f.teacher_id_ AS teacherId,
  349. p.subject_id_ AS subjectId,
  350. p.subject_name_ AS subjectName,
  351. p.subject_price_ AS subjectPrice,
  352. p.course_minutes_ AS courseMinutes
  353. FROM teacher_free_time f
  354. LEFT JOIN teacher_subject_price p ON f.id_=p.teacher_free_time_id
  355. WHERE f.default_flag_=1
  356. AND p.subject_id_=#{param.subjectId}) sp ON t.user_id_=sp.teacherId
  357. WHERE t.user_id_ IN (SELECT teacher_id_ FROM teacher_free_time GROUP BY teacher_id_)
  358. <if test="param.subjectId !=null">
  359. AND sp.subjectId=#{param.subjectId}
  360. </if>
  361. <if test="param.search !=null and param.search !=''">
  362. AND u.username_ LIKE CONCAT('%', #{param.search}, '%')
  363. </if>
  364. <choose>
  365. <when test="param.sort !=null and param.sort !=''">
  366. ORDER BY ${param.sort}
  367. </when>
  368. </choose>
  369. </select>
  370. <select id="queryCourseTeacher" resultType="com.yonge.cooleshow.biz.dal.vo.CourseStudent"
  371. parameterType="com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch">
  372. SELECT
  373. s.id_ AS courseId,
  374. s.course_group_id_ AS courseGoupId,
  375. s.class_date_ AS classDate,
  376. s.start_time_ AS startTime,
  377. s.end_time_ AS endTime,
  378. s.type_ AS courseType,
  379. s.status_ AS `status`,
  380. u.id_ AS userId,
  381. u.username_ AS name,
  382. u.real_name_ AS realName,
  383. u.avatar_ AS cover,
  384. g.subject_id_ AS subjectId,
  385. b.name_ AS subjectName
  386. FROM course_schedule s
  387. LEFT JOIN sys_user u ON s.teacher_id_ = u.id_
  388. LEFT JOIN course_group g ON s.course_group_id_ = g.id_
  389. LEFT JOIN `subject` b ON g.subject_id_ = b.id_
  390. WHERE s.id_ IN
  391. (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{param.studentId} AND course_type_ = 'PRACTICE')
  392. AND s.class_date_ = #{param.classDate}
  393. UNION
  394. SELECT
  395. s.id_ AS courseId,
  396. s.course_group_id_ AS courseGoupId,
  397. s.class_date_ AS classDate,
  398. s.start_time_ AS startTime,
  399. s.end_time_ AS endTime,
  400. s.type_ AS courseType,
  401. s.status_ AS `status`,
  402. NULL AS userId,
  403. CONCAT(g.name_,'-第',s.class_num_,'课') AS name,
  404. NULL AS realName,
  405. g.background_pic_ AS cover,
  406. g.subject_id_ AS subjectId,
  407. sb.name_ AS subjectName
  408. FROM course_schedule s
  409. LEFT JOIN course_group g ON s.course_group_id_ = g.id_
  410. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  411. WHERE s.id_ IN
  412. (SELECT course_id_ FROM course_schedule_student_payment WHERE user_id_ = #{param.studentId} AND course_type_ = 'LIVE')
  413. AND s.class_date_ = #{param.classDate}
  414. ORDER BY startTime
  415. </select>
  416. <select id="queryStudentLiveCourse" parameterType="map" resultType="com.yonge.cooleshow.biz.dal.vo.CourseStudent">
  417. SELECT distinct
  418. cs.id_ AS courseId,
  419. cs.course_group_id_ AS courseGoupId,
  420. cs.class_date_ AS classDate,
  421. cs.start_time_ AS startTime,
  422. cs.end_time_ AS endTime,
  423. cs.status_ AS `status`,
  424. cs.type_ AS courseType,
  425. su.username_ AS userId,
  426. CONCAT(g.name_,'-第',cs.class_num_,'课') AS name,
  427. IFNULL(g.pre_student_num_, 0) AS payCount,
  428. g.background_pic_ AS cover,
  429. g.subject_id_ AS subjectId,
  430. sb.name_ AS subjectName,
  431. su.avatar_ AS avatar,
  432. g.im_group_id_ as imGroupId
  433. FROM
  434. course_schedule_student_payment as a
  435. LEFT JOIN course_schedule cs on a.course_id_ = cs.id_
  436. LEFT JOIN course_group g ON cs.course_group_id_ = g.id_
  437. LEFT JOIN `subject` sb ON g.subject_id_=sb.id_
  438. LEFT JOIN sys_user su on g.teacher_id_ = su.id_
  439. LEFT JOIN user_order o on a.order_no_ = o.order_no_
  440. WHERE cs.type_=#{param.type}
  441. AND a.user_id_ = #{param.studentId}
  442. <![CDATA[ AND class_date_ >= #{param.startDate} ]]>
  443. <![CDATA[ AND class_date_ <= #{param.endDate} ]]>
  444. <if test="param.orderState != null">
  445. AND o.status_ = #{param.orderState}
  446. </if>
  447. <if test="param.subjectId != null">
  448. AND g.subject_id_ = #{param.subjectId}
  449. </if>
  450. <if test="param.courseState != null">
  451. and cs.status_ = #{param.courseState}
  452. </if>
  453. </select>
  454. <insert id="addCourseGroup" parameterType="com.yonge.cooleshow.biz.dal.dto.PracticeScheduleDto" useGeneratedKeys="true" keyProperty="groupId">
  455. Insert INTO course_group(teacher_id_,type_,name_,subject_id_,single_course_minutes_,course_num_,course_introduce_,
  456. course_price_,status_,created_by_,mix_student_num_,course_start_time_,pre_student_num_)
  457. VALUES (#{teacherId},#{type},#{courseGroupName},#{subjectId},#{singleCourseMinutes},#{courseNum},#{courseIntroduce},
  458. #{coursePrice},#{status},#{studentId},#{mixStudentNum},#{courseStartTime},1)
  459. </insert>
  460. <update id="updateLock" parameterType="java.util.List">
  461. UPDATE course_schedule SET lock_ = 0 WHERE id_ IN
  462. <foreach collection="list" item="item" open="(" separator="," close=")">
  463. #{item}
  464. </foreach>
  465. </update>
  466. <update id="courseAdjust" parameterType="com.yonge.cooleshow.biz.dal.vo.CourseAdjustVo">
  467. UPDATE course_schedule
  468. SET class_date_=#{classDate},start_time_=#{startTime},end_time_=#{endTime}
  469. WHERE id_ = #{courseId}
  470. </update>
  471. <select id="selectLive" resultType="com.yonge.cooleshow.biz.dal.vo.StudentHomePage$Live">
  472. SELECT
  473. u.id_ AS teacherId,
  474. u.username_ AS teacherName,
  475. u.real_name_ AS realName,
  476. u.avatar_ AS avatar,
  477. g.id_ AS courseGroupId,
  478. g.name_ AS courseGroupName,
  479. g.course_price_ AS courseGroupPrice,
  480. g.course_start_time_ AS courseStartTime,
  481. g.background_pic_ AS backgroundPic,
  482. g.course_num_ AS courseNum,
  483. g.pre_student_num_ AS buyCount,
  484. g.subject_id_ AS subjectId,
  485. s.name_ AS subjectName
  486. FROM course_group g
  487. LEFT JOIN sys_user u ON g.teacher_id_=u.id_
  488. LEFT JOIN subject s ON g.subject_id_=s.id_
  489. WHERE type_='LIVE' and g.status_ = 'APPLY' and #{appAuditVersion} = g.audit_version_
  490. ORDER BY courseStartTime DESC LIMIT 4
  491. </select>
  492. <select id="selectVideo" resultType="com.yonge.cooleshow.biz.dal.vo.StudentHomePage$Video">
  493. SELECT
  494. u.id_ AS teacherId,
  495. u.username_ AS teacherName,
  496. u.real_name_ AS realName,
  497. u.avatar_ AS avatar,
  498. g.id_ AS videoGroupId,
  499. g.lesson_name_ AS videoGroupName,
  500. g.lesson_price_ AS lessonPrice,
  501. g.create_time_ AS createTime,
  502. g.lesson_cover_url_ AS lessonCoverUrl,
  503. g.lesson_count_ AS lessonCount,
  504. g.lesson_subject_ AS subjectId,
  505. s.name_ AS subjectName,
  506. IFNULL(r.count_,0) AS buyCount
  507. FROM video_lesson_group g
  508. LEFT JOIN sys_user u ON g.teacher_id_=u.id_
  509. LEFT JOIN `subject` s ON g.lesson_subject_=s.id_
  510. 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_
  511. WHERE g.audit_status_='PASS' and #{appAuditVersion} = g.audit_version_
  512. ORDER BY g.create_time_ DESC LIMIT 4
  513. </select>
  514. <select id="selectRecentCourses" resultType="com.yonge.cooleshow.biz.dal.vo.StudentHomePage$RecentCourses">
  515. SELECT
  516. u.id_ AS teacherId,
  517. u.username_ AS teacherName,
  518. u.real_name_ AS realName,
  519. u.avatar_ AS avatar,
  520. p.course_group_id_ AS courseGroupId,
  521. p.course_id_ AS courseId,
  522. g.name_ AS courseGroupName,
  523. p.course_type_ AS courseType,
  524. s.status_ AS `status`,
  525. s.start_time_ AS courseStartTime
  526. FROM course_schedule_student_payment p
  527. LEFT JOIN course_schedule s ON p.course_id_=s.id_
  528. LEFT JOIN sys_user u ON s.teacher_id_=u.id_
  529. LEFT JOIN course_group g ON p.course_group_id_=g.id_
  530. WHERE p.user_id_=#{studentId}
  531. AND s.status_ IN ('NOT_START','ING')
  532. ORDER BY ABS(NOW() - s.start_time_) ASC
  533. limit 1
  534. </select>
  535. <select id="selectRecentCoursesTeacher" resultType="com.yonge.cooleshow.biz.dal.vo.StudentHomePage$RecentCourses">
  536. SELECT
  537. u.id_ AS teacherId,
  538. u.username_ AS teacherName,
  539. u.real_name_ AS realName,
  540. u.avatar_ AS avatar,
  541. s.course_group_id_ AS courseGroupId,
  542. s.id_ AS courseId,
  543. g.name_ AS courseGroupName,
  544. s.type_ AS courseType,
  545. s.status_ AS `status`,
  546. s.start_time_ AS courseStartTime
  547. FROM course_schedule s
  548. LEFT JOIN sys_user u ON s.teacher_id_=u.id_
  549. LEFT JOIN course_group g ON s.course_group_id_=g.id_
  550. WHERE s.teacher_id_=#{teacherId}
  551. AND s.status_ IN ('NOT_START','ING')
  552. ORDER BY ABS(NOW() - s.start_time_) ASC
  553. limit 1
  554. </select>
  555. <select id="selectWeekNotStartCourseSchedule" resultType="java.lang.Integer">
  556. select count(1)
  557. from course_schedule cs
  558. where cs.teacher_id_ = #{userId} and cs.status_ = 'NOT_START'
  559. and YEARWEEK(date_format(cs.class_date_,'%Y-%m-%d'),7) = YEARWEEK(now(),7)
  560. </select>
  561. <select id="selectHomeworkNotDecorate" resultType="java.lang.Integer">
  562. select count(1)
  563. from course_schedule cs
  564. left join course_homework ch on cs.id_ = ch.course_schedule_id_
  565. where cs.teacher_id_ = #{userId} and cs.status_ = 'COMPLETE' and cs.type_ = 'PRACTICE'
  566. and YEARWEEK(date_format(cs.class_date_,'%Y-%m-%d'),7) = YEARWEEK(now(),7)
  567. and ch.id_ is null
  568. </select>
  569. <select id="selectNotRepliedCourseSchedule" resultType="java.lang.Integer">
  570. select count(1)
  571. from course_schedule cs
  572. left join course_schedule_replied csr on cs.id_ = csr.course_schedule_id_
  573. where cs.teacher_id_ = #{userId} and cs.status_ = 'COMPLETE' and cs.type_ = 'PRACTICE'
  574. and csr.teacher_replied_ is null
  575. </select>
  576. <select id="selectWeekStudentRepliedCourseSchedule" resultType="java.lang.Integer">
  577. select count(1)
  578. from course_schedule cs
  579. left join course_schedule_replied csr on cs.id_ = csr.course_schedule_id_
  580. where cs.teacher_id_ = #{userId} and cs.status_ = 'COMPLETE' and cs.type_ = 'PRACTICE'
  581. and csr.student_replied_ is not null
  582. </select>
  583. <select id="selectStartTime" resultType="java.lang.String" parameterType="java.lang.String">
  584. SELECT s.start_time_
  585. FROM course_schedule_student_payment p
  586. LEFT JOIN course_schedule s ON p.course_id_=s.id_
  587. WHERE p.order_no_=#{orderNo}
  588. </select>
  589. <select id="selectTeacher" resultType="com.yonge.cooleshow.auth.api.entity.SysUser"
  590. parameterType="java.lang.String">
  591. SELECT s.teacher_id_ AS id,u.phone_ AS phone
  592. FROM course_schedule s
  593. LEFT JOIN sys_user u ON s.teacher_id_=u.id_
  594. WHERE class_date_=#{tomorrow} AND lock_=0
  595. GROUP BY s.teacher_id_
  596. </select>
  597. <select id="selectTypeCount" resultType="com.yonge.cooleshow.biz.dal.vo.CountVo">
  598. SELECT type_ AS type, COUNT(1) AS count
  599. FROM course_schedule
  600. WHERE class_date_=#{tomorrow}
  601. AND teacher_id_=#{teacherId} AND lock_=0
  602. GROUP BY type_
  603. </select>
  604. <select id="selectTodayNotRepliedAndNotDecorateHomework"
  605. resultType="com.yonge.cooleshow.biz.dal.vo.TodayNotRepliedAndNotDecorateHomeworkVo">
  606. select sum(if(ch.id_ is null,1,0)) as decorateNum,
  607. sum(if(csr.teacher_replied_ is null,1,0)) as repliedNum,
  608. su.id_ as teacherId,
  609. su.phone_ as phone
  610. from course_schedule cs
  611. left join course_schedule_replied csr on cs.id_ = csr.course_schedule_id_
  612. left join course_homework ch on cs.id_ = ch.course_schedule_id_
  613. left join sys_user su on cs.teacher_id_ = su.id_
  614. where cs.status_ = 'COMPLETE' and date_format(cs.class_date_,'%Y-%m-%d') = date_format(now(),'%Y-%m-%d')
  615. and cs.type_ = 'PRACTICE'
  616. group by su.id_,su.phone_
  617. </select>
  618. <select id="countAllReplie" resultType="com.yonge.cooleshow.biz.dal.vo.RepliedCountVo"
  619. parameterType="java.lang.String">
  620. SELECT
  621. p.user_id_ AS userId,
  622. u.phone_ AS phone,
  623. COUNT(1) AS count
  624. FROM course_schedule_student_payment p
  625. LEFT JOIN sys_user u ON p.user_id_=u.id_
  626. WHERE p.course_id_ IN (SELECT id_ FROM course_schedule WHERE class_date_=#{today} AND lock_=0 AND type_='PRACTICE')
  627. GROUP BY p.user_id_;
  628. </select>
  629. <select id="countReplies" resultType="java.lang.Integer" parameterType="java.lang.Integer">
  630. SELECT COUNT(1)
  631. FROM course_schedule_replied
  632. WHERE student_id_=#{studentId}
  633. </select>
  634. <select id="queryCourseHomeOfYear" parameterType="map"
  635. resultType="com.yonge.cooleshow.biz.dal.vo.CourseHomeVo$CourseHomeInfoVo">
  636. select `date`,
  637. sum(a.not_start_count) as undoneCount,
  638. sum(a.complete_count) as doneCount
  639. from (select date_format(class_date_, '%Y-%m-01') as `date`,
  640. ifnull(case when status_ in ('NOT_START', 'ING') then count(1) end, 0) as not_start_count,
  641. ifnull(case when status_ = 'COMPLETE' then count(1) end, 0) as complete_count
  642. from course_schedule
  643. where type_ = #{param.type}
  644. and status_ in ('NOT_START', 'ING', 'COMPLETE')
  645. <![CDATA[ AND class_date_ >= #{param.startDate} ]]>
  646. <![CDATA[ AND class_date_ <= #{param.endDate} ]]>
  647. group by class_date_) as a
  648. group by date
  649. </select>
  650. <select id="queryCourseHomeOfMonth" parameterType="map"
  651. resultType="com.yonge.cooleshow.biz.dal.vo.CourseHomeVo$CourseHomeInfoVo">
  652. select class_date_ as `date`,
  653. ifnull(case when status_ in ('NOT_START', 'ING') then count(1) end, 0) as undoneCount,
  654. ifnull(case when status_ = 'COMPLETE' then count(1) end, 0) as doneCount
  655. from course_schedule
  656. where type_ = #{param.type}
  657. and status_ in ('NOT_START', 'ING', 'COMPLETE')
  658. <![CDATA[ AND class_date_ >= #{param.startDate} ]]>
  659. <![CDATA[ AND class_date_ <= #{param.endDate} ]]>
  660. group by class_date_
  661. </select>
  662. <select id="selectPrice" resultType="java.math.BigDecimal">
  663. SELECT p.subject_price_
  664. FROM teacher_free_time t
  665. LEFT JOIN teacher_subject_price p ON t.id_=p.teacher_free_time_id
  666. WHERE t.teacher_id_=#{teacherId}
  667. AND p.subject_id_=#{subjectId}
  668. AND t.default_flag_=1
  669. </select>
  670. <select id="selectSchedule" resultType="com.yonge.cooleshow.biz.dal.entity.CourseSchedule"
  671. parameterType="java.lang.Integer">
  672. SELECT * FROM course_schedule
  673. WHERE id_ IN (
  674. SELECT course_id_ FROM course_schedule_student_payment
  675. WHERE user_id_=(SELECT user_id_ FROM course_schedule_student_payment WHERE course_id_=200 AND course_type_='PRACTICE')
  676. )
  677. </select>
  678. </mapper>