CourseGroupMapper.xml 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987
  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.CourseGroupDao">
  4. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.CourseGroup">
  5. <id column="id_" jdbcType="BIGINT" property="id"/>
  6. <result column="type_" jdbcType="VARCHAR" property="type"/>
  7. <result column="teacher_id_" jdbcType="INTEGER" property="teacherId"/>
  8. <result column="name_" jdbcType="VARCHAR" property="name"/>
  9. <result column="subject_id_" jdbcType="INTEGER" property="subjectId"/>
  10. <result column="single_course_minutes_" jdbcType="INTEGER" property="singleCourseMinutes"/>
  11. <result column="course_num_" jdbcType="INTEGER" property="courseNum"/>
  12. <result column="complete_course_num_" jdbcType="INTEGER" property="completeCourseNum"/>
  13. <result column="course_introduce_" jdbcType="VARCHAR" property="courseIntroduce"/>
  14. <result column="course_price_" jdbcType="VARCHAR" property="coursePrice"/>
  15. <result column="status_" jdbcType="VARCHAR" property="status"/>
  16. <result column="sales_start_date_" jdbcType="TIMESTAMP" property="salesStartDate"/>
  17. <result column="sales_end_date_" jdbcType="TIMESTAMP" property="salesEndDate"/>
  18. <result column="background_pic_" jdbcType="VARCHAR" property="backgroundPic"/>
  19. <result column="mix_student_num_" jdbcType="INTEGER" property="mixStudentNum"/>
  20. <result column="course_start_time_" jdbcType="TIMESTAMP" property="courseStartTime"/>
  21. <result column="created_by_" jdbcType="INTEGER" property="createdBy"/>
  22. <result column="created_time_" jdbcType="TIMESTAMP" property="createdTime"/>
  23. <result column="updated_by_" jdbcType="INTEGER" property="updatedBy"/>
  24. <result column="updated_time_" jdbcType="TIMESTAMP" property="updatedTime"/>
  25. <result column="pre_student_num_" jdbcType="INTEGER" property="preStudentNum"/>
  26. <result column="im_group_id_" jdbcType="VARCHAR" property="imGroupId"/>
  27. <result column="reason_" jdbcType="VARCHAR" property="reason"/>
  28. </resultMap>
  29. <sql id="Base_Column_List">
  30. id_
  31. , type_, teacher_id_, name_, subject_id_, single_course_minutes_, course_num_, complete_course_num_, course_introduce_, course_price_, status_, sales_start_date_, sales_end_date_, background_pic_, mix_student_num_,pre_student_num_, im_group_id_, course_start_time_, created_by_, created_time_, updated_by_, updated_time_,reason_
  32. </sql>
  33. <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
  34. parameterType="com.yonge.cooleshow.biz.dal.entity.CourseGroup">
  35. insert into course_group(type_, teacher_id_, name_, subject_id_, single_course_minutes_, course_num_,
  36. complete_course_num_, course_introduce_, course_price_, status_, sales_start_date_, sales_end_date_, background_pic_,
  37. mix_student_num_,pre_student_num_,im_group_id_, course_start_time_, created_by_, created_time_, updated_by_, updated_time_,reason_)
  38. values
  39. <foreach collection="entities" item="entity" separator=",">
  40. (#{entity.type}, #{entity.teacherId}, #{entity.name}, #{entity.subjectId}, #{entity.singleCourseMinutes},
  41. #{entity.courseNum}, #{entity.completeCourseNum}, #{entity.courseIntroduce}, #{entity.coursePrice}, #{entity.status},
  42. #{entity.salesStartDate}, #{entity.salesEndDate}, #{entity.backgroundPic}, #{entity.mixStudentNum},
  43. #{entity.preStudentNum},#{entity.imGroupId},#{entity.courseStartTime}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy},
  44. #{entity.updatedTime},#{entity.reason})
  45. </foreach>
  46. </insert>
  47. <select id="queryTeacherCourseGroup" resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupVo">
  48. select distinct
  49. b.id_ as courseGroupId,
  50. b.name_ as courseGroupName,
  51. s.name_ as subjectName,
  52. b.teacher_id_ as teacherId,
  53. u.username_ as teacherName,
  54. b.course_start_time_ as courseStartTime,
  55. b.single_course_minutes_ as singleCourseMinutes,
  56. b.status_ as `status`,
  57. ifnull(b.pre_student_num_, 0) as studentCount,
  58. b.background_pic_ as backgroundPic,
  59. b.course_price_ as coursePrice,
  60. b.course_num_ as courseNum,
  61. u.avatar_ as avatar,
  62. b.sales_start_date_ as salesStartDate,
  63. b.sales_end_date_ as salesEndDate,
  64. b.mix_student_num_ as mixStudentNum,
  65. b.im_group_id_ as imGroupId,
  66. b.reason_ as reason,
  67. 0 as existBuy
  68. from course_group as b
  69. left join subject as s on b.subject_id_ = s.id_
  70. left join sys_user as u on b.teacher_id_ = u.id_
  71. <where>
  72. u.del_flag_ = 0
  73. <if test="param.teacherId != null">
  74. and b.teacher_id_ = #{param.teacherId}
  75. </if>
  76. <if test="param.groupStatus != null">
  77. and b.status_ = #{param.groupStatus}
  78. </if>
  79. <if test="param.subjectId != null">
  80. AND b.subject_id_ = #{param.subjectId}
  81. </if>
  82. <if test="param.search != null and param.search !=''">
  83. and (
  84. u.real_name_ like concat('%',#{param.search},'%')
  85. or b.name_ like concat('%',#{param.search},'%')
  86. )
  87. </if>
  88. <if test="param.type != null and param.type != ''">
  89. and b.type_ = #{param.type}
  90. </if>
  91. </where>
  92. order by b.created_time_
  93. </select>
  94. <select id="queryStudentCourseGroup" resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupVo">
  95. select distinct b.id_ as courseGroupId,
  96. b.name_ as courseGroupName,
  97. s.name_ as subjectName,
  98. b.teacher_id_ as teacherId,
  99. u.username_ as teacherName,
  100. b.course_start_time_ as courseStartTime,
  101. b.single_course_minutes_ as singleCourseMinutes,
  102. b.status_ as `status`,
  103. ifnull(b.pre_student_num_, 0) as studentCount,
  104. b.background_pic_ as backgroundPic,
  105. b.course_price_ as coursePrice,
  106. b.course_num_ as courseNum,
  107. u.avatar_ as avatar,
  108. b.sales_start_date_ as salesStartDate,
  109. b.sales_end_date_ as salesEndDate,
  110. b.mix_student_num_ as mixStudentNum,
  111. b.im_group_id_ as imGroupId,
  112. b.reason_ as reason,
  113. if(y.status_ = 'PAID', 1, 0) as existBuy
  114. from course_group as b
  115. left join subject as s on b.subject_id_ = s.id_
  116. left join sys_user as u on b.teacher_id_ = u.id_
  117. left join
  118. (select x.user_id_, x.course_group_id_, o.status_
  119. from course_schedule_student_payment as x
  120. left join user_order as o on x.order_no_ = o.order_no_ and x.user_id_ = o.user_id_
  121. left join user_order_detail as d on d.order_no_ = x.order_no_
  122. where x.user_id_ = #{param.studentId}) as y on b.id_ = y.course_group_id_
  123. <where>
  124. u.del_flag_ = 0
  125. <if test="param.teacherId != null">
  126. and b.teacher_id_ = #{param.teacherId}
  127. </if>
  128. <if test="param.groupStatus != null">
  129. and b.status_ = #{param.groupStatus}
  130. </if>
  131. <if test="param.subjectId != null">
  132. AND b.subject_id_ = #{param.subjectId}
  133. </if>
  134. <if test="param.search != null and param.search !=''">
  135. and (
  136. u.real_name_ like concat('%',#{param.search},'%')
  137. or b.name_ like concat('%',#{param.search},'%')
  138. )
  139. </if>
  140. <if test="param.auditVersion != null ">
  141. and #{param.auditVersion} = b.audit_version_
  142. </if>
  143. <if test="param.subjectId != null ">
  144. and #{param.subjectId} = b.subject_id_
  145. </if>
  146. </where>
  147. </select>
  148. <select id="selectAdminLivePage" resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupVo">
  149. select distinct
  150. cg.id_ as courseGroupId,
  151. cg.reason_ as reason,
  152. cg.name_ as name,
  153. cg.complete_course_num_ as endCourseNum,
  154. if(cg.complete_course_num_ = 0 ,cg.course_num_,cg.course_num_ - cg.complete_course_num_) as noStartCourseNum,
  155. cg.course_price_ as coursePrice,
  156. cg.pre_student_num_ as preStudentNum,
  157. cg.status_ as status,
  158. cg.course_num_ as courseNum,
  159. cg.created_time_ as createTime,
  160. cg.course_introduce_ as courseIntroduce,
  161. <if test="param.studentId != null">
  162. cssp.order_no_ as orderNo,
  163. </if>
  164. cg.im_group_id_ as imGroupId
  165. from course_group cg
  166. left join course_schedule_student_payment cssp on cg.id_ = cssp.course_group_id_
  167. left join sys_user su on su.id_ = cssp.user_id_
  168. <where>
  169. <if test="param.teacherId != null">
  170. and #{param.teacherId} = cg.teacher_id_
  171. </if>
  172. <if test="param.studentId != null">
  173. and #{param.studentId} = cssp.user_id_
  174. </if>
  175. <if test="param.search != null and param.search !=''">
  176. and (
  177. cg.id_ like concat('%',#{param.search},'%')
  178. or su.id_ like concat('%',#{param.search},'%')
  179. or su.username_ like concat('%',#{param.search},'%')
  180. or su.phone_ like concat('%',#{param.search},'%')
  181. )
  182. </if>
  183. <if test="param.orderNo != null and param.orderNo != ''">
  184. and cssp.order_no_ like concat('%',#{param.orderNo},'%')
  185. </if>
  186. <if test="param.subjectId != null">
  187. and #{param.subjectId} = cg.subject_id_
  188. </if>
  189. <if test="param.status != null">
  190. and #{param.status} = cg.status_
  191. </if>
  192. <if test="param.startTime != null">
  193. and #{param.startTime} &lt;= cg.created_time_
  194. </if>
  195. <if test="param.endTime != null">
  196. and #{param.endTime} &gt;= cg.created_time_
  197. </if>
  198. <if test="param.courseType != null">
  199. and #{param.courseType} = cg.type_
  200. </if>
  201. </where>
  202. order by cg.id_ desc
  203. </select>
  204. <select id="selectCourseGroupSubject" resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupVo">
  205. select
  206. cg.id_ as courseGroupId,
  207. s.name_ as subjectName
  208. from course_group cg
  209. left join subject s on cg.subject_id_ = s.id_
  210. <where>
  211. <if test="courseGroupIdList != null and courseGroupIdList.size() != 0">
  212. and cg.id_ in
  213. <foreach collection="courseGroupIdList" item="item" open="(" close=")" separator=",">
  214. #{item}
  215. </foreach>
  216. </if>
  217. </where>
  218. </select>
  219. <select id="selectAdminLiveStudentPage" resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupStudentVo">
  220. select
  221. a.id_ as paymentId,
  222. su.id_ as studentId,
  223. su.username_ as studentName,
  224. a.actual_price_ as price,
  225. a.order_no_ as orderNo,
  226. su.phone_ as phone,
  227. a.create_time_ as payTime
  228. from user_order_detail as a
  229. left join user_order as o on a.order_no_ = o.order_no_
  230. left join sys_user as su on o.user_id_ = su.id_
  231. <where>
  232. a.good_type_ = 'LIVE' and o.status_ = 'PAID'
  233. <if test="param.courseGroupId != null">
  234. and #{param.courseGroupId} = a.biz_id_
  235. </if>
  236. <if test="param.search != null and param.search != ''">
  237. and (
  238. a.biz_id_ like concat('%',#{param.search},'%')
  239. or su.id_ like concat('%',#{param.search},'%')
  240. or su.username_ like concat('%',#{param.search},'%')
  241. or su.phone_ like concat('%',#{param.search},'%')
  242. )
  243. </if>
  244. <if test="param.orderNo != null and param.orderNo != ''">
  245. and a.order_no_ like concat('%',#{param.orderNo},'%')
  246. </if>
  247. <if test="param.startTime != null">
  248. and #{param.startTime} &lt;= a.create_time_
  249. </if>
  250. <if test="param.endTime != null">
  251. and #{param.endTime} &gt;= a.create_time_
  252. </if>
  253. </where>
  254. group by o.user_id_
  255. order by a.id_ desc
  256. </select>
  257. <select id="selectAdminLivePlan" resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupPlanVo">
  258. select
  259. cs.id_ as courseId,
  260. cs.class_num_ as classNum,
  261. cs.class_date_ as classDate,
  262. cs.start_time_ as startTime,
  263. cs.end_time_ as endTime,
  264. cs.status_ as courseStatus,
  265. cp.plan_ as planInfo,
  266. lrv.url_ as videoUrl
  267. from course_schedule cs
  268. left join live_room_video lrv on cs.id_ = lrv.course_id_
  269. left join course_plan cp on cp.course_group_id_ = cs.course_group_id_ and cp.class_num_ = cs.class_num_
  270. <where>
  271. <if test="courseGroupId != null">
  272. and #{courseGroupId} = cs.course_group_id_
  273. </if>
  274. </where>
  275. order by cs.class_num_
  276. </select>
  277. <select id="selectAdminLiveCourseGroup" resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupVo">
  278. select distinct
  279. cg.id_ as courseGroupId,
  280. cg.name_ as name,
  281. cg.complete_course_num_ as endCourseNum,
  282. if(cg.complete_course_num_ = 0 ,cg.course_num_,cg.course_num_ - cg.complete_course_num_) as noStartCourseNum,
  283. cg.course_price_ as coursePrice,
  284. cg.pre_student_num_ as preStudentNum,
  285. cg.status_ as status,
  286. cg.course_num_ as courseNum,
  287. cg.created_time_ as createTime,
  288. cg.course_introduce_ as courseIntroduce,
  289. cg.type_ as type,
  290. s.name_ as subjectName
  291. from course_group cg
  292. left join course_schedule_student_payment cssp on cg.id_ = cssp.course_group_id_
  293. left join subject s on cg.subject_id_ = s.id_
  294. <where>
  295. <if test="courseGroupId != null">
  296. and #{courseGroupId} = cg.id_
  297. </if>
  298. </where>
  299. </select>
  300. <select id="selectAdminLiveStudentCoursePage"
  301. resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupStudentCourseVo">
  302. select distinct
  303. cs.id_ as courseId,
  304. cs.class_date_ as classDate,
  305. cs.start_time_ as startTime,
  306. cs.end_time_ as endTime,
  307. cs.status_ as courseStatue,
  308. cssp.order_no_ as orderNo,
  309. sa.id_ as studentAttendanceId
  310. from course_schedule cs
  311. left join course_schedule_student_payment cssp on cs.id_ = cssp.course_id_
  312. left join student_attendance sa on cssp.course_id_ = sa.course_schedule_id_
  313. <where>
  314. cs.status_ != '${@ com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum@CANCEL}'
  315. <if test="param.studentId != null">
  316. and cssp.user_id_ = #{param.studentId}
  317. </if>
  318. <if test="param.status != null">
  319. <choose>
  320. <when test="param.status == @com.yonge.cooleshow.biz.dal.enums.StudentCourseEnum@TRUANT">
  321. and sa.id_ is null
  322. </when>
  323. <when test="param.status == @com.yonge.cooleshow.biz.dal.enums.StudentCourseEnum@ATTENDCLASS">
  324. and sa.id_ is not null
  325. and #{param.studentId} = sa.student_id_
  326. </when>
  327. <when test="param.status == @com.yonge.cooleshow.biz.dal.enums.StudentCourseEnum@NOTSTART">
  328. and cs.status_ = '${@ com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum@NOT_START}'
  329. </when>
  330. </choose>
  331. </if>
  332. <if test="param.courseGroupId != null">
  333. and #{param.courseGroupId} = cs.course_group_id_
  334. </if>
  335. <if test="param.courseId != null">
  336. and cs.id_ like concat('%',#{param.courseId},'%')
  337. </if>
  338. </where>
  339. order by cs.id_ desc
  340. </select>
  341. <select id="selectPracticeGroup" resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupPracticeVo">
  342. SELECT
  343. cg.id_ AS groupId,
  344. cg.name_ AS groupName,
  345. cg.subject_id_ AS subjectId,
  346. sub.name_ AS subjectName,
  347. cg.course_num_ AS courseNum,
  348. IFNULL(cs.count_ ,0)AS completeCount,
  349. cg.teacher_id_ AS teacherId,
  350. tu.username_ AS teacherName,
  351. tu.real_name_ AS teacherRealName,
  352. sp.user_id_ AS studentId,
  353. su.username_ AS studentName,
  354. su.real_name_ AS studentRealName,
  355. cg.status_ AS `status`,
  356. cst.start_time_ AS startTime
  357. FROM course_group cg
  358. LEFT JOIN `subject` sub ON cg.subject_id_=sub.id_
  359. LEFT JOIN sys_user tu ON cg.teacher_id_=tu.id_
  360. LEFT JOIN (SELECT user_id_,course_group_id_ FROM course_schedule_student_payment WHERE course_type_='PRACTICE' GROUP BY course_group_id_) sp ON cg.id_=sp.course_group_id_
  361. LEFT JOIN sys_user su ON sp.user_id_=su.id_
  362. LEFT JOIN (SELECT course_group_id_,COUNT(1) AS count_ FROM course_schedule WHERE type_='PRACTICE' AND status_='COMPLETE' GROUP BY course_group_id_) cs ON cg.id_=cs.course_group_id_
  363. LEFT JOIN (SELECT course_group_id_,start_time_ FROM course_schedule WHERE type_='PRACTICE' GROUP BY course_group_id_) cst ON cg.id_=cst.course_group_id_
  364. WHERE cg.type_='PRACTICE' AND cg.status_ IN('ING','COMPLETE')
  365. <if test="param.search != null and param.search != ''">
  366. AND (
  367. cg.id_ LIKE concat('%',#{param.search},'%') OR
  368. cg.teacher_id_ LIKE concat('%',#{param.search},'%') OR
  369. sp.user_id_ LIKE concat('%',#{param.search},'%') OR
  370. cg.name_ LIKE concat('%',#{param.search},'%') OR
  371. tu.username_ LIKE concat('%',#{param.search},'%') OR
  372. su.username_ LIKE concat('%',#{param.search},'%')
  373. )
  374. </if>
  375. <if test="param.subjectId != null">
  376. AND cg.subject_id_ = #{param.subjectId}
  377. </if>
  378. <if test="param.status != null and param.status != ''">
  379. AND cg.status_ = #{param.status}
  380. </if>
  381. <if test="param.studentId != null">
  382. AND sp.user_id_ = #{param.studentId}
  383. </if>
  384. <if test="param.teacherId != null">
  385. AND cg.teacher_id_ = #{param.teacherId}
  386. </if>
  387. </select>
  388. <select id="selectPracticeGroupDetail"
  389. resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupPracticeDetailVo">
  390. SELECT * FROM
  391. (SELECT
  392. cs.id_ AS courseId,
  393. sb.name_ AS subjectName,
  394. cs.teacher_id_ AS teacherId,
  395. tu.username_ AS teacherName,
  396. tu.real_name_ AS teacherRealName,
  397. sp.user_id_ AS studentId,
  398. su.username_ AS studentName,
  399. su.real_name_ AS studentRealName,
  400. cs.status_ AS `status`,
  401. cs.start_time_ AS startTime,
  402. cs.end_time_ AS endTime,
  403. (CASE WHEN cs.start_time_ &gt;= ta.sign_in_time_ THEN 1 ELSE 0 END) AS teacherInSign,
  404. (CASE WHEN cs.end_time_ &lt;= ta.sign_out_time_ THEN 1 ELSE 0 END) AS teacherOutSign,
  405. (CASE WHEN cs.start_time_ &gt;= sa.sign_in_time_ THEN 1 ELSE 0 END) AS studentInSign,
  406. (CASE WHEN cs.end_time_ &lt;= sa.sign_out_time_ THEN 1 ELSE 0 END) AS studentOutSign,
  407. ts.status_ AS salaryStatus
  408. FROM course_schedule cs
  409. LEFT JOIN course_group cg ON cs.course_group_id_=cg.id_
  410. LEFT JOIN `subject` sb ON cg.subject_id_=sb.id_
  411. LEFT JOIN sys_user tu ON cs.teacher_id_=tu.id_
  412. LEFT JOIN course_schedule_student_payment sp ON cs.id_=sp.course_id_
  413. LEFT JOIN sys_user su ON sp.user_id_=su.id_
  414. LEFT JOIN teacher_attendance ta ON cs.id_=ta.course_schedule_id_
  415. LEFT JOIN student_attendance sa ON cs.id_=sa.course_schedule_id_
  416. LEFT JOIN course_schedule_teacher_salary ts ON cs.id_=ts.course_schedule_id_
  417. WHERE cs.type_='PRACTICE'
  418. AND cs.lock_=0
  419. AND cs.course_group_id_=#{param.courseGroupId}) a
  420. <where>
  421. <if test="param.search != null and param.search != ''">
  422. AND (
  423. courseId LIKE concat('%',#{param.search},'%') OR
  424. teacherName LIKE concat('%',#{param.search},'%') OR
  425. teacherId LIKE concat('%',#{param.search},'%') OR
  426. studentName LIKE concat('%',#{param.search},'%') OR
  427. studentId LIKE concat('%',#{param.search},'%')
  428. )
  429. </if>
  430. <if test="param.teacherSign == 1">
  431. AND teacherInSign = #{param.teacherSign}
  432. </if>
  433. <if test="param.teacherSign == 0">
  434. AND teacherOutSign = #{param.teacherSign}
  435. </if>
  436. <if test="param.studentSign == 1">
  437. AND studentInSign = #{param.studentSign}
  438. </if>
  439. <if test="param.studentSign == 0">
  440. AND studentOutSign = #{param.studentSign}
  441. </if>
  442. <if test="param.status != null and param.status != ''">
  443. AND `status` = #{param.status}
  444. </if>
  445. <if test="param.salaryStatus != null and param.salaryStatus != ''">
  446. AND salaryStatus = #{param.salaryStatus}
  447. </if>
  448. <if test="param.startTime != null">
  449. AND startTime &lt;= #{param.startTime}
  450. </if>
  451. <if test="param.endTime != null">
  452. AND endTime &gt;= #{param.endTime}
  453. </if>
  454. <if test="param.studentId != null">
  455. AND studentId = #{param.studentId}
  456. </if>
  457. <if test="param.teacherId != null">
  458. AND teacherId = #{param.teacherId}
  459. </if>
  460. </where>
  461. </select>
  462. <select id="selectLiveGroup" resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupLiveVo">
  463. SELECT
  464. cg.id_ AS courseGroupId,
  465. cg.name_ AS courseGroupName,
  466. cg.subject_id_ AS subjectId,
  467. sb.name_ AS subjectName,
  468. cg.teacher_id_ AS teacherId,
  469. su.username_ AS teacherName,
  470. su.real_name_ AS teacherRealName,
  471. cg.course_num_ AS courseNum,
  472. cg.pre_student_num_ AS studentNum,
  473. cg.status_ AS `status`,
  474. IFNULL(cm.count_,0) AS completeCount,
  475. st.start_time_ AS startTime
  476. FROM course_group cg
  477. LEFT JOIN `subject` sb ON cg.subject_id_=sb.id_
  478. LEFT JOIN sys_user su ON su.id_=cg.teacher_id_
  479. LEFT JOIN (SELECT course_group_id_,COUNT(1) AS count_ FROM course_schedule WHERE type_='LIVE' AND status_='COMPLETE' GROUP BY course_group_id_) cm ON cg.id_=cm.course_group_id_
  480. LEFT JOIN (SELECT course_group_id_,start_time_ FROM course_schedule WHERE type_='LIVE' GROUP BY course_group_id_) st ON cg.id_=st.course_group_id_
  481. WHERE cg.type_='LIVE'
  482. <if test="param.search != null and param.search != ''">
  483. AND (
  484. cg.id_ LIKE concat('%',#{param.search},'%') OR
  485. cg.teacher_id_ LIKE concat('%',#{param.search},'%') OR
  486. cg.name_ LIKE concat('%',#{param.search},'%') OR
  487. su.username_ LIKE concat('%',#{param.search},'%')
  488. )
  489. </if>
  490. <if test="param.subjectId != null">
  491. AND cg.subject_id_ = #{param.subjectId}
  492. </if>
  493. <if test="param.status != null and param.status != ''">
  494. AND cg.status_ = #{param.status}
  495. </if>
  496. </select>
  497. <select id="selectLiveGroupStudent" resultType="com.yonge.cooleshow.biz.dal.vo.CourseSchedulePaymentVo">
  498. SELECT
  499. p.user_id_ AS studentId,
  500. u.username_ AS studentName,
  501. u.real_name_ AS studentRealName,
  502. u.phone_ AS studentPhone,
  503. p.actual_price_ AS actualPrice,
  504. p.order_no_ AS orderNo,
  505. o.create_time_ AS createdOrderTime
  506. FROM course_schedule_student_payment p
  507. LEFT JOIN sys_user u ON p.user_id_=u.id_
  508. LEFT JOIN user_order o ON p.order_no_ = o.order_no_
  509. WHERE p.course_group_id_=#{param.groupId}
  510. <if test="param.search != null and param.search != ''">
  511. AND (
  512. p.course_id_ LIKE concat('%',#{param.search},'%') OR
  513. p.user_id_ LIKE concat('%',#{param.search},'%') OR
  514. u.username_ LIKE concat('%',#{param.search},'%') OR
  515. u.phone_ LIKE concat('%',#{param.search},'%')
  516. )
  517. </if>
  518. <if test="param.orderNo != null and param.orderNo != ''">
  519. AND p.order_no_ = #{param.orderNo}
  520. </if>
  521. <if test="param.startTime != null">
  522. AND o.create_time_ &lt;= #{param.startTime}
  523. </if>
  524. <if test="param.endTime != null">
  525. AND o.create_time_ &gt;= #{param.endTime}
  526. </if>
  527. </select>
  528. <select id="selectLiveGroupPlan" resultType="com.yonge.cooleshow.biz.dal.vo.CourseSchedulePlanVo">
  529. SELECT
  530. distinct
  531. cs.id_ AS courseId,
  532. cp.plan_ AS courseIntroduce,
  533. cs.class_num_ AS classNum,
  534. cs.class_date_ AS classDate,
  535. cs.start_time_ AS startTime,
  536. cs.end_time_ AS endTime,
  537. ts.status_ AS salaryStatus,
  538. (select group_concat(lrv.url_) from live_room_video lrv where lrv.course_id_ = cs.id_)AS url,
  539. cs.status_ AS courseStatus,
  540. (CASE WHEN cs.start_time_ &gt;= ta.sign_in_time_ THEN 1 ELSE 0 END) AS teacherInSign,
  541. (CASE WHEN cs.end_time_ &lt;= ta.sign_out_time_ THEN 1 ELSE 0 END) AS teacherOutSign
  542. FROM course_schedule cs
  543. LEFT JOIN course_group g ON cs.course_group_id_=g.id_
  544. LEFT JOIN course_schedule_teacher_salary ts ON cs.id_=ts.course_schedule_id_
  545. LEFT JOIN teacher_attendance ta ON cs.id_=ta.course_schedule_id_
  546. left join course_plan cp on cp.course_group_id_ = cs.course_group_id_ and cp.class_num_ = cs.class_num_
  547. WHERE cs.course_group_id_= #{param.groupId}
  548. <if test="param.salaryStatus != null and param.salaryStatus != ''">
  549. AND ts.status_ = #{param.salaryStatus}
  550. </if>
  551. <if test="param.startTime != null">
  552. AND cs.start_time_ &lt;= #{param.startTime}
  553. </if>
  554. <if test="param.endTime != null">
  555. AND cs.end_time_ &gt;= #{param.endTime}
  556. </if>
  557. <if test="param.endTime != null">
  558. AND cs.id_ LIKE concat('%',#{param.courseId},'%')
  559. </if>
  560. </select>
  561. <select id="selectVideoGroup" resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupVideoVo">
  562. SELECT
  563. g.id_ AS groupId,
  564. g.lesson_name_ AS lessonName,
  565. g.lesson_subject_ AS subjectId,
  566. s.name_ AS subjectName,
  567. g.lesson_count_ AS lessonCount,
  568. IFNULL(p.count_,0) AS buyCount,
  569. g.teacher_id_ AS teacherId,
  570. u.username_ AS teacherName,
  571. u.real_name_ AS teacherRealName,
  572. g.create_time_ AS createTime,
  573. r.create_time_ AS recordTime,
  574. g.shelves_flag_ as shelvesFlag
  575. FROM video_lesson_group g
  576. LEFT JOIN `subject` s ON g.lesson_subject_=s.id_
  577. LEFT JOIN sys_user u ON g.teacher_id_=u.id_
  578. LEFT JOIN (
  579. SELECT video_lesson_group_id_,COUNT(1) AS count_ FROM video_lesson_purchase_record
  580. WHERE order_status_='PAID' GROUP BY video_lesson_group_id_) p ON g.id_=p.video_lesson_group_id_
  581. LEFT JOIN (
  582. SELECT video_group_id_,create_time_ FROM video_lesson_auth_record
  583. WHERE audit_status_='PASS' order by version_ desc limit 1) r ON g.id_=r.video_group_id_
  584. <where>
  585. <if test="param.search != null and param.search != ''">
  586. AND (
  587. g.id_ LIKE concat('%',#{param.search},'%') OR
  588. g.lesson_name_ LIKE concat('%',#{param.search},'%') OR
  589. g.teacher_id_ LIKE concat('%',#{param.search},'%') OR
  590. u.username_ LIKE concat('%',#{param.search},'%')
  591. )
  592. </if>
  593. <if test="param.subjectId != null and param.subjectId != ''">
  594. AND g.lesson_subject_ = #{param.subjectId}
  595. </if>
  596. <if test="param.status != null and param.status != ''">
  597. AND g.audit_status_ = #{param.status}
  598. </if>
  599. <if test="param.shelvesFlag != null">
  600. AND g.shelves_flag_ = #{param.shelvesFlag}
  601. </if>
  602. </where>
  603. order by g.top_flag_ desc ,g.sort_number_ desc,g.id_ desc
  604. </select>
  605. <select id="selectVideoGroupStudent" resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupStudentVo">
  606. SELECT
  607. r.student_id_ AS studentId,
  608. u.username_ AS studentName,
  609. u.real_name_ AS studentRealName,
  610. u.phone_ AS studentPhone,
  611. r.order_no_ AS orderNo,
  612. r.pay_money_ AS payMoney,
  613. o.create_time_ AS createTime
  614. FROM video_lesson_purchase_record r
  615. LEFT JOIN sys_user u ON r.student_id_=u.id_
  616. LEFT JOIN user_order o ON r.order_no_=o.order_no_
  617. WHERE r.order_status_='PAID'
  618. AND video_lesson_group_id_ = #{param.groupId}
  619. <if test="param.search != null and param.search != ''">
  620. AND (
  621. r.student_id_ LIKE concat('%',#{param.search},'%') OR
  622. u.username_ LIKE concat('%',#{param.search},'%') OR
  623. u.phone_ LIKE concat('%',#{param.search},'%')
  624. )
  625. </if>
  626. <if test="param.orderNo != null and param.orderNo != ''">
  627. AND r.order_no_ = #{param.orderNo}
  628. </if>
  629. <if test="param.startTime != null">
  630. AND o.create_time_ &lt;= #{param.startTime}
  631. </if>
  632. <if test="param.endTime != null">
  633. AND o.create_time_ &gt;= #{param.endTime}
  634. </if>
  635. </select>
  636. <select id="selectVideoGroupPlan" resultType="com.yonge.cooleshow.biz.dal.entity.VideoLessonGroupDetail">
  637. SELECT
  638. id_ AS id,
  639. video_title_ AS videoTitle,
  640. video_content_ AS videoContent,
  641. video_url_ AS videoUrl,
  642. cover_url_ AS coverUrl
  643. FROM video_lesson_group_detail
  644. WHERE video_lesson_group_id_=#{param.groupId}
  645. </select>
  646. <select id="selectGroupInfoVo" resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupInfoVo"
  647. parameterType="java.lang.Long">
  648. SELECT
  649. g.id_ AS id,
  650. g.name_ AS name,
  651. g.subject_id_ AS subjectId,
  652. s.name_ AS subjectName,
  653. g.course_num_ AS courseNum,
  654. g.course_price_ AS coursePrice,
  655. g.status_ AS `status`,
  656. g.course_introduce_ AS courseIntroduce,
  657. g.created_time_ AS createdTime
  658. FROM course_group g
  659. LEFT JOIN `subject` s ON g.subject_id_=s.id_
  660. WHERE g.id_ =#{groupId}
  661. </select>
  662. <update id="opsPreStudentNum">
  663. update course_group
  664. set
  665. pre_student_num_ = pre_student_num_ + #{num}
  666. where id_ = #{id}
  667. </update>
  668. <update id="updateBatch">
  669. UPDATE course_group
  670. SET status_='COMPLETE'
  671. WHERE id_ IN
  672. <foreach collection="list" item="item" open="(" separator="," close=")">
  673. #{item}
  674. </foreach>
  675. </update>
  676. <select id="selectPianoGroup" resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupPianoVo">
  677. SELECT
  678. cg.id_ AS courseGroupId,
  679. cg.name_ AS courseGroupName,
  680. cg.subject_id_ AS subjectId,
  681. sb.name_ AS subjectName,
  682. cg.teacher_id_ AS teacherId,
  683. su.username_ AS teacherName,
  684. su.real_name_ AS teacherRealName,
  685. cg.course_num_ AS courseNum,
  686. cg.status_ AS `status`,
  687. IFNULL(cm.count_,0) AS completeCount,
  688. st.start_time_ AS startTime
  689. FROM course_group cg
  690. LEFT JOIN `subject` sb ON cg.subject_id_=sb.id_
  691. LEFT JOIN sys_user su ON su.id_=cg.teacher_id_
  692. LEFT JOIN (SELECT course_group_id_,COUNT(1) AS count_ FROM course_schedule WHERE type_='PIANO_ROOM_CLASS' AND status_='COMPLETE' GROUP BY course_group_id_) cm ON cg.id_=cm.course_group_id_
  693. LEFT JOIN (SELECT course_group_id_,start_time_ FROM course_schedule WHERE type_='PIANO_ROOM_CLASS' GROUP BY course_group_id_) st ON cg.id_=st.course_group_id_
  694. WHERE cg.type_='PIANO_ROOM_CLASS'
  695. <if test="param.search != null and param.search != ''">
  696. AND (
  697. cg.id_ LIKE concat('%',#{param.search},'%') OR
  698. cg.teacher_id_ LIKE concat('%',#{param.search},'%') OR
  699. cg.name_ LIKE concat('%',#{param.search},'%') OR
  700. su.username_ LIKE concat('%',#{param.search},'%')
  701. )
  702. </if>
  703. <if test="param.subjectId != null">
  704. AND cg.subject_id_ = #{param.subjectId}
  705. </if>
  706. <if test="param.status != null and param.status != ''">
  707. AND cg.status_ = #{param.status}
  708. </if>
  709. </select>
  710. <select id="selectPianoGroupDetail"
  711. resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupPianoDetailVo">
  712. SELECT
  713. cs.id_ AS courseId,
  714. sb.id_ AS subjectId,
  715. sb.name_ AS subjectName,
  716. cs.teacher_id_ AS teacherId,
  717. tu.username_ AS teacherName,
  718. tu.real_name_ AS teacherRealName,
  719. cs.status_ AS `status`,
  720. a.studentCount AS studentCount,
  721. (cs.single_course_time_ * (a.studentCount+1)*(a.studentCount+1-1)) AS courseTime,
  722. cs.start_time_ AS startTime,
  723. cs.end_time_ AS endTime,
  724. b.teacherInSign AS teacherInSign,
  725. b.teacherOutSign AS teacherOutSign
  726. FROM course_schedule cs
  727. LEFT JOIN course_group cg ON cs.course_group_id_ = cg.id_
  728. LEFT JOIN `subject` sb ON cg.subject_id_ = sb.id_
  729. LEFT JOIN sys_user tu ON cs.teacher_id_ = tu.id_
  730. LEFT JOIN (SELECT course_id_,COUNT(1) AS studentCount FROM course_schedule_student_payment WHERE course_type_='PIANO_ROOM_CLASS' GROUP BY course_id_) a ON cs.id_=a.course_id_
  731. LEFT JOIN (SELECT cs.id_ AS cid,( CASE WHEN cs.start_time_ &gt;= ta.sign_in_time_ THEN 1 ELSE 0 END ) AS teacherInSign,( CASE WHEN cs.end_time_ &lt;= ta.sign_out_time_ THEN 1 ELSE 0 END ) AS teacherOutSign
  732. FROM course_schedule cs LEFT JOIN teacher_attendance ta ON cs.id_=ta.course_schedule_id_ WHERE cs.type_='PIANO_ROOM_CLASS') b ON cs.id_=b.cid
  733. WHERE cs.type_='PIANO_ROOM_CLASS'
  734. AND cs.course_group_id_=#{param.courseGroupId}
  735. <if test="param.search != null and param.search != ''">
  736. AND cs.id_ LIKE concat('%',#{param.search},'%')
  737. </if>
  738. <if test="param.status != null and param.status != ''">
  739. AND cs.status_ = #{param.status}
  740. </if>
  741. <if test="param.startTime != null">
  742. AND cs.start_time_ &gt;= #{param.startTime}
  743. </if>
  744. <if test="param.endTime != null">
  745. AND cs.start_time_ &lt;= #{param.endTime}
  746. </if>
  747. <if test="param.teacherSign == 1">
  748. AND b.teacherInSign = #{param.teacherSign}
  749. </if>
  750. <if test="param.teacherSign == 0">
  751. AND b.teacherOutSign = #{param.teacherSign}
  752. </if>
  753. <if test="param.studentSign != null">
  754. AND cs.id_ IN
  755. <foreach collection="param.courseIds" item="item" open="(" close=")" separator=",">
  756. #{item}
  757. </foreach>
  758. </if>
  759. </select>
  760. <select id="studentSign" resultType="com.yonge.cooleshow.biz.dal.vo.StudentSignVo">
  761. SELECT DISTINCT
  762. p.course_id_ AS courseId,
  763. p.user_id_ AS userId,
  764. u.username_ AS userName,
  765. u.real_name_ AS realName,
  766. ( CASE WHEN c.start_time_ &gt;= a.sign_in_time_ THEN 1 ELSE 0 END ) AS studentInSign,
  767. ( CASE WHEN c.end_time_ &lt;= a.sign_out_time_ THEN 1 ELSE 0 END ) AS studentOutSign
  768. FROM course_schedule_student_payment p
  769. LEFT JOIN sys_user u ON p.user_id_=u.id_
  770. LEFT JOIN course_schedule c ON p.course_id_=c.id_
  771. LEFT JOIN student_attendance a ON p.user_id_=a.student_id_
  772. <where>
  773. <if test="courseId !=null">
  774. AND p.course_id_=#{courseId}
  775. </if>
  776. <if test="type !=null and type!=''">
  777. AND p.course_type_=#{type}
  778. </if>
  779. </where>
  780. </select>
  781. <select id="selectPianoGroupStudent" resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupPianoVo">
  782. SELECT DISTINCT
  783. g.id_ AS courseGroupId,
  784. g.name_ AS courseGroupName,
  785. s.id_ AS subjectId,
  786. s.name_ AS subjectName,
  787. g.teacher_id_ AS teacherId,
  788. u.username_ AS teacherName,
  789. u.real_name_ AS teacherRealName,
  790. g.course_num_ AS courseNum,
  791. IFNULL(cm.count_,0) AS completeCount,
  792. g.status_ AS `status`,
  793. st.start_time_ AS startTime
  794. FROM course_schedule_student_payment p
  795. LEFT JOIN course_group g ON p.course_group_id_=g.id_
  796. LEFT JOIN `subject` s ON g.subject_id_=s.id_
  797. LEFT JOIN sys_user u ON g.teacher_id_=u.id_
  798. LEFT JOIN (SELECT course_group_id_,COUNT(1) AS count_ FROM course_schedule WHERE type_='PIANO_ROOM_CLASS' AND status_='COMPLETE' GROUP BY course_group_id_) cm ON p.course_group_id_=cm.course_group_id_
  799. LEFT JOIN (SELECT course_group_id_,start_time_ FROM course_schedule WHERE type_='PIANO_ROOM_CLASS' GROUP BY course_group_id_) st ON p.course_group_id_=st.course_group_id_
  800. WHERE p.course_type_='PIANO_ROOM_CLASS'
  801. AND p.user_id_=#{param.studentId}
  802. <if test="param.search != null and param.search != ''">
  803. AND (
  804. g.id_ LIKE concat('%',#{param.search},'%') OR
  805. g.teacher_id_ LIKE concat('%',#{param.search},'%') OR
  806. u.username_ LIKE concat('%',#{param.search},'%') OR
  807. g.name_ LIKE concat('%',#{param.search},'%')
  808. )
  809. </if>
  810. <if test="param.subjectId != null">
  811. AND s.id_ = #{param.subjectId}
  812. </if>
  813. <if test="param.status != null and param.status != ''">
  814. AND g.status_ = #{param.status}
  815. </if>
  816. </select>
  817. <select id="selectPianoGroupStudentDetail"
  818. resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupPianoDetailVo">
  819. SELECT * FROM (
  820. SELECT
  821. cs.id_ AS courseId,
  822. sb.id_ AS subjectId,
  823. sb.name_ AS subjectName,
  824. cs.teacher_id_ AS teacherId,
  825. tu.username_ AS teacherName,
  826. tu.real_name_ AS teacherRealName,
  827. cs.status_ AS `status`,
  828. a.studentCount AS studentCount,
  829. (cs.single_course_time_ * (a.studentCount+1)*(a.studentCount+1-1)) AS courseTime,
  830. cs.start_time_ AS startTime,
  831. cs.end_time_ AS endTime,
  832. p.user_id_ AS studentId,
  833. su.username_ AS studentName,
  834. su.real_name_ AS studentRealName,
  835. (CASE WHEN cs.start_time_ &gt;= ta.sign_in_time_ THEN 1 ELSE 0 END) AS teacherInSign,
  836. (CASE WHEN cs.end_time_ &lt;= ta.sign_out_time_ THEN 1 ELSE 0 END) AS teacherOutSign,
  837. (CASE WHEN cs.start_time_ &gt;= sa.sign_in_time_ THEN 1 ELSE 0 END) AS studentInSign,
  838. (CASE WHEN cs.end_time_ &lt;= sa.sign_out_time_ THEN 1 ELSE 0 END) AS studentOutSign,
  839. (CASE WHEN cs.start_time_ &gt;= sa.sign_in_time_ AND cs.end_time_ &lt;= sa.sign_out_time_ THEN 1 ELSE 0 END) AS studentSign,
  840. (CASE WHEN cs.start_time_ &gt;= ta.sign_in_time_ AND cs.end_time_ &lt;= ta.sign_out_time_ THEN 1 ELSE 0 END) AS teacherSign
  841. FROM course_schedule cs
  842. LEFT JOIN course_group cg ON cs.course_group_id_ = cg.id_
  843. LEFT JOIN `subject` sb ON cg.subject_id_ = sb.id_
  844. LEFT JOIN sys_user tu ON cs.teacher_id_ = tu.id_
  845. LEFT JOIN (SELECT course_id_,COUNT(1) AS studentCount FROM course_schedule_student_payment WHERE course_type_='PIANO_ROOM_CLASS' GROUP BY course_id_) a ON cs.id_=a.course_id_
  846. LEFT JOIN teacher_attendance ta ON cs.id_=ta.course_schedule_id_
  847. LEFT JOIN student_attendance sa ON cs.id_=sa.course_schedule_id_
  848. LEFT JOIN course_schedule_student_payment p ON cs.id_=p.course_id_
  849. LEFT JOIN sys_user su ON p.user_id_ = su.id_
  850. WHERE cs.type_='PIANO_ROOM_CLASS'
  851. AND p.user_id_=#{param.studentId}
  852. AND p.course_group_id_=#{param.courseGroupId}) m
  853. <where>
  854. <if test="param.search != null and param.search != ''">
  855. AND courseId LIKE concat('%',#{param.search},'%')
  856. </if>
  857. <if test="param.studentSign != null">
  858. AND studentSign = #{param.studentSign}
  859. </if>
  860. <if test="param.teacherSign != null">
  861. AND teacherSign = #{param.teacherSign}
  862. </if>
  863. <if test="param.status != null and param.status != ''">
  864. AND `status` = #{param.status}
  865. </if>
  866. <if test="param.startTime != null">
  867. AND startTime &gt;= #{param.startTime}
  868. </if>
  869. <if test="param.endTime != null">
  870. AND startTime &lt;= #{param.endTime}
  871. </if>
  872. </where>
  873. </select>
  874. <select id="selectPianoGroupTeacher" resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupPianoVo">
  875. SELECT
  876. cg.id_ AS courseGroupId,
  877. cg.name_ AS courseGroupName,
  878. cg.subject_id_ AS subjectId,
  879. sb.name_ AS subjectName,
  880. cg.teacher_id_ AS teacherId,
  881. su.username_ AS teacherName,
  882. su.real_name_ AS teacherRealName,
  883. cg.course_num_ AS courseNum,
  884. cg.status_ AS `status`,
  885. IFNULL(cm.count_,0) AS completeCount,
  886. st.start_time_ AS startTime
  887. FROM course_group cg
  888. LEFT JOIN `subject` sb ON cg.subject_id_=sb.id_
  889. LEFT JOIN sys_user su ON su.id_=cg.teacher_id_
  890. LEFT JOIN (SELECT course_group_id_,COUNT(1) AS count_ FROM course_schedule WHERE type_='PIANO_ROOM_CLASS' AND status_='COMPLETE' GROUP BY course_group_id_) cm ON cg.id_=cm.course_group_id_
  891. LEFT JOIN (SELECT course_group_id_,start_time_ FROM course_schedule WHERE type_='PIANO_ROOM_CLASS' GROUP BY course_group_id_) st ON cg.id_=st.course_group_id_
  892. WHERE cg.type_='PIANO_ROOM_CLASS'
  893. AND cg.teacher_id_=#{param.teacherId}
  894. <if test="param.search != null and param.search != ''">
  895. AND (
  896. cg.name_ LIKE concat('%',#{param.search},'%') OR
  897. cg.id_ LIKE concat('%',#{param.search},'%')
  898. )
  899. </if>
  900. <if test="param.subjectId != null">
  901. AND cg.subject_id_ = #{param.subjectId}
  902. </if>
  903. <if test="param.status != null and param.status != ''">
  904. AND cg.status_ = #{param.status}
  905. </if>
  906. </select>
  907. <select id="selectPianoGroupTeacherDetail"
  908. resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupPianoDetailVo">
  909. SELECT * FROM (
  910. SELECT
  911. cs.id_ AS courseId,
  912. sb.id_ AS subjectId,
  913. sb.name_ AS subjectName,
  914. cs.teacher_id_ AS teacherId,
  915. tu.username_ AS teacherName,
  916. tu.real_name_ AS teacherRealName,
  917. cs.status_ AS `status`,
  918. a.studentCount AS studentCount,
  919. (cs.single_course_time_ * (a.studentCount+1)*(a.studentCount+1-1)) AS courseTime,
  920. cs.start_time_ AS startTime,
  921. cs.end_time_ AS endTime,
  922. p.user_id_ AS studentId,
  923. su.username_ AS studentName,
  924. su.real_name_ AS studentRealName,
  925. (CASE WHEN cs.start_time_ &gt;= ta.sign_in_time_ THEN 1 ELSE 0 END) AS teacherInSign,
  926. (CASE WHEN cs.end_time_ &lt;= ta.sign_out_time_ THEN 1 ELSE 0 END) AS teacherOutSign,
  927. (CASE WHEN cs.start_time_ &gt;= ta.sign_in_time_ AND cs.end_time_ &lt;= ta.sign_out_time_ THEN 1 ELSE 0 END) AS teacherSign
  928. FROM course_schedule cs
  929. LEFT JOIN course_group cg ON cs.course_group_id_ = cg.id_
  930. LEFT JOIN `subject` sb ON cg.subject_id_ = sb.id_
  931. LEFT JOIN sys_user tu ON cs.teacher_id_ = tu.id_
  932. LEFT JOIN (SELECT course_id_,COUNT(1) AS studentCount FROM course_schedule_student_payment WHERE course_type_='PIANO_ROOM_CLASS' GROUP BY course_id_) a ON cs.id_=a.course_id_
  933. LEFT JOIN teacher_attendance ta ON cs.id_=ta.course_schedule_id_
  934. LEFT JOIN student_attendance sa ON cs.id_=sa.course_schedule_id_
  935. LEFT JOIN course_schedule_student_payment p ON cs.id_=p.course_id_
  936. LEFT JOIN sys_user su ON cs.teacher_id_ = su.id_
  937. WHERE cs.type_='PIANO_ROOM_CLASS'
  938. AND cs.teacher_id_=#{param.teacherId}
  939. AND p.course_group_id_=#{param.courseGroupId}
  940. <if test="param.studentSign != null">
  941. AND cs.id_ IN
  942. <foreach collection="param.courseIds" item="item" open="(" close=")" separator=",">
  943. #{item}
  944. </foreach>
  945. </if>) m
  946. <where>
  947. <if test="param.search != null and param.search != ''">
  948. AND (
  949. courseId LIKE concat('%',#{param.search},'%') OR
  950. studentName LIKE concat('%',#{param.search},'%') OR
  951. studentId LIKE concat('%',#{param.search},'%')
  952. )
  953. </if>
  954. <if test="param.teacherSign != null">
  955. AND teacherSign = #{param.teacherSign}
  956. </if>
  957. <if test="param.status != null and param.status != ''">
  958. AND `status` = #{param.status}
  959. </if>
  960. <if test="param.startTime != null">
  961. AND startTime &gt;= #{param.startTime}
  962. </if>
  963. <if test="param.endTime != null">
  964. AND endTime &lt;= #{param.endTime}
  965. </if>
  966. </where>
  967. GROUP BY courseId
  968. </select>
  969. <select id="selectLiveSubject" resultType="com.yonge.cooleshow.biz.dal.entity.Subject">
  970. select distinct s.* from course_group cg
  971. left join subject s on cg.subject_id_ = s.id_
  972. where cg.status_ = 'APPLY' and cg.type_ = 'LIVE'
  973. </select>
  974. </mapper>