CourseGroupMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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. </resultMap>
  27. <sql id="Base_Column_List">
  28. id_
  29. , 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_, course_start_time_, created_by_, created_time_, updated_by_, updated_time_
  30. </sql>
  31. <insert id="insertBatch" keyColumn="id_" keyProperty="id" useGeneratedKeys="true"
  32. parameterType="com.yonge.cooleshow.biz.dal.entity.CourseGroup">
  33. insert into course_group(type_, teacher_id_, name_, subject_id_, single_course_minutes_, course_num_,
  34. complete_course_num_, course_introduce_, course_price_, status_, sales_start_date_, sales_end_date_, background_pic_,
  35. mix_student_num_,pre_student_num_, course_start_time_, created_by_, created_time_, updated_by_, updated_time_)
  36. values
  37. <foreach collection="entities" item="entity" separator=",">
  38. (#{entity.type}, #{entity.teacherId}, #{entity.name}, #{entity.subjectId}, #{entity.singleCourseMinutes},
  39. #{entity.courseNum}, #{entity.completeCourseNum}, #{entity.courseIntroduce}, #{entity.coursePrice}, #{entity.status},
  40. #{entity.salesStartDate}, #{entity.salesEndDate}, #{entity.backgroundPic}, #{entity.mixStudentNum},
  41. #{entity.preStudentNum},#{entity.courseStartTime}, #{entity.createdBy}, #{entity.createdTime}, #{entity.updatedBy},
  42. #{entity.updatedTime})
  43. </foreach>
  44. </insert>
  45. <select id="queryTeacherCourseGroup" resultType="com.yonge.cooleshow.biz.dal.vo.CourseGroupVo">
  46. select
  47. b.id_ as courseGroupId,
  48. b.name_ as courseGroupName,
  49. s.name_ as subjectName,
  50. b.teacher_id_ as teacherId,
  51. u.real_name_ as teacherName,
  52. b.course_start_time_ as courseStartTime,
  53. b.single_course_minutes_ as singleCourseMinutes,
  54. b.status_ as `status`,
  55. ifnull(b.pre_student_num_, 0) as studentCount,
  56. b.background_pic_ as backgroundPic,
  57. b.course_price_ as coursePrice,
  58. b.course_num_ as courseNum,
  59. u.avatar_ as avatar,
  60. b.sales_start_date_ as salesStartDate,
  61. b.sales_end_date_ as salesEndDate,
  62. b.mix_student_num_ as mixStudentNum
  63. from course_group as b
  64. left join subject as s on b.subject_id_ = s.id_
  65. left join sys_user as u on b.teacher_id_ = u.id_
  66. <where>
  67. <if test="param.teacherId != null">
  68. and b.teacher_id_ = #{param.teacherId}
  69. </if>
  70. <if test="param.groupStatus != null">
  71. and b.status_ = #{param.groupStatus}
  72. </if>
  73. <if test="param.subjectId != null">
  74. AND b.subject_id_ = #{param.subjectId}
  75. </if>
  76. <if test="param.search != null and param.search !=''">
  77. and (
  78. u.real_name_ like concat('%',#{param.search},'%')
  79. or b.name_ like concat('%',#{param.search},'%')
  80. )
  81. </if>
  82. </where>
  83. </select>
  84. <select id="selectAdminLivePage" resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupVo">
  85. select distinct
  86. cg.id_ as courseGroupId,
  87. cg.name_ as name,
  88. cg.complete_course_num_ as endCourseNum,
  89. if(cg.complete_course_num_ = 0 ,cg.course_num_,cg.course_num_ - cg.complete_course_num_) as noStartCourseNum,
  90. cg.course_price_ as coursePrice,
  91. cg.pre_student_num_ as preStudentNum,
  92. cg.status_ as status,
  93. cg.course_num_ as courseNum,
  94. cg.created_time_ as createTime,
  95. cg.course_introduce_ as courseIntroduce
  96. from course_group cg
  97. left join course_schedule_student_payment cssp on cg.id_ = cssp.course_group_id_
  98. <if test="param.search != null and param.search != ''">
  99. left join sys_user su on su.id_ = cssp.user_id_
  100. </if>
  101. <where>
  102. <if test="param.teacherId != null">
  103. and #{param.teacherId} = cg.teacher_id_
  104. </if>
  105. <if test="param.studentId != null">
  106. and #{param.studentId} = cssp.user_id_
  107. </if>
  108. <if test="param.search != null and param.search !=''">
  109. and (
  110. cg.id_ like concat('%',#{param.search},'%')
  111. or su.id_ like concat('%',#{param.search},'%')
  112. or su.username_ like concat('%',#{param.search},'%')
  113. or su.phone_ like concat('%',#{param.search},'%')
  114. )
  115. </if>
  116. <if test="param.orderNo != null and param.orderNo != ''">
  117. and cssp.order_no_ like concat('%',#{param.orderNo},'%')
  118. </if>
  119. <if test="param.subjectId != null">
  120. and #{param.subjectId} = cg.subject_id_
  121. </if>
  122. <if test="param.status != null">
  123. and #{param.status} = cg.status_
  124. </if>
  125. <if test="param.startTime != null">
  126. and #{param.startTime} &lt;= cg.created_time_
  127. </if>
  128. <if test="param.endTime != null">
  129. and #{param.endTime} &gt;= cg.created_time_
  130. </if>
  131. <if test="param.courseType != null">
  132. and #{param.courseType} = cg.type_
  133. </if>
  134. </where>
  135. order by cg.id_ desc
  136. </select>
  137. <select id="selectCourseGroupSubject" resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupVo">
  138. select
  139. cg.id_ as courseGroupId,
  140. s.name_ as subjectName
  141. from course_group cg
  142. left join subject s on cg.subject_id_ = s.id_
  143. <where>
  144. <if test="courseGroupIdList != null and courseGroupIdList.size() != 0">
  145. and cg.id_ in
  146. <foreach collection="courseGroupIdList" item="item" open="(" close=")" separator=",">
  147. #{item}
  148. </foreach>
  149. </if>
  150. </where>
  151. <if test="courseGroupIdList != null and courseGroupIdList.size() != 0">
  152. order by field(cg.id_,
  153. <foreach collection="courseGroupIdList" item="item" open="" close=")" separator=",">
  154. #{item}
  155. </foreach>
  156. </if>
  157. </select>
  158. <select id="selectAdminLiveStudentPage" resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupStudentVo">
  159. select
  160. su.id_ as studentId,
  161. su.username_ as studentName,
  162. cssp.actual_price_ as price,
  163. cssp.order_no_ as orderNo,
  164. cssp.created_time_ as payTime
  165. from course_schedule_student_payment cssp
  166. left join sys_user su on cssp.user_id_ = su.id_
  167. <where>
  168. <if test="param.courseGroupId != null">
  169. and #{param.courseGroupId} = cssp.course_group_id_
  170. </if>
  171. <if test="param.search != null and param.search != ''">
  172. and (
  173. cssp.course_group_id_ like concat('%',#{param.search},'%')
  174. or su.id_ like concat('%',#{param.search},'%')
  175. or su.username_ like concat('%',#{param.search},'%')
  176. or su.phone_ like concat('%',#{param.search},'%')
  177. )
  178. </if>
  179. <if test="param.orderNo != null and param.orderNo != ''">
  180. and cssp.order_no_ like concat('%',#{param.orderNo},'%')
  181. </if>
  182. <if test="param.startTime != null">
  183. and #{param.startTime} &lt;= cssp.created_time_
  184. </if>
  185. <if test="param.endTime != null">
  186. and #{param.endTime} &gt;= cssp.created_time_
  187. </if>
  188. </where>
  189. order by cssp.id_ desc
  190. </select>
  191. <select id="selectAdminLivePlan" resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupPlanVo">
  192. select
  193. cs.id_ as courseId,
  194. cs.class_num_ as classNum,
  195. cs.class_date_ as classDate,
  196. cs.start_time_ as startTime,
  197. cs.end_time_ as endTime,
  198. cs.status_ as courseStatus,
  199. cp.plan_ as planInfo,
  200. lrv.url_ as videoUrl
  201. from course_schedule cs
  202. left join live_room_video lrv on cs.id_ = lrv.course_id_
  203. left join course_plan cp on cp.course_group_id_ = cs.course_group_id_ and cp.class_num_ = cs.class_num_
  204. <where>
  205. <if test="courseGroupId != null">
  206. and #{courseGroupId} = cs.course_group_id_
  207. </if>
  208. </where>
  209. order by cs.class_num_
  210. </select>
  211. <select id="selectAdminLiveCourseGroup" resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupVo">
  212. select distinct
  213. cg.id_ as courseGroupId,
  214. cg.name_ as name,
  215. cg.complete_course_num_ as endCourseNum,
  216. if(cg.complete_course_num_ = 0 ,cg.course_num_,cg.course_num_ - cg.complete_course_num_) as noStartCourseNum,
  217. cg.course_price_ as coursePrice,
  218. cg.pre_student_num_ as preStudentNum,
  219. cg.status_ as status,
  220. cg.course_num_ as courseNum,
  221. cg.created_time_ as createTime,
  222. cg.course_introduce_ as courseIntroduce,
  223. s.name_ as subjectName
  224. from course_group cg
  225. left join course_schedule_student_payment cssp on cg.id_ = cssp.course_group_id_
  226. left join subject s on cg.subject_id_ = s.id_
  227. <where>
  228. <if test="courseGroupId != null">
  229. and #{courseGroupId} = cg.id_
  230. </if>
  231. </where>
  232. </select>
  233. <select id="selectAdminLiveStudentCoursePage"
  234. resultType="com.yonge.cooleshow.biz.dal.vo.LiveCourseGroupStudentCourseVo">
  235. select distinct
  236. cs.id_ as courseId,
  237. cs.class_date_ as classDate,
  238. cs.start_time_ as startTime,
  239. cs.end_time_ as endTime,
  240. cs.status_ as courseStatue,
  241. cssp.order_no_ as orderNo,
  242. sa.id_ as studentAttendanceId
  243. from course_schedule cs
  244. left join course_schedule_student_payment cssp on cs.id_ = cssp.course_id_
  245. left join student_attendance sa on cssp.course_id_ = sa.course_schedule_id_
  246. <where>
  247. cs.status_ != '${@ com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum@CANCEL}'
  248. <if test="param.studentId != null">
  249. and cssp.user_id_ = #{param.studentId}
  250. </if>
  251. <if test="param.status != null">
  252. <choose>
  253. <when test="param.status == @com.yonge.cooleshow.biz.dal.enums.StudentCourseEnum@TRUANT">
  254. and sa.id_ is null
  255. </when>
  256. <when test="param.status == @com.yonge.cooleshow.biz.dal.enums.StudentCourseEnum@ATTENDCLASS">
  257. and sa.id_ is not null
  258. and #{param.studentId} = sa.student_id_
  259. </when>
  260. <when test="param.status == @com.yonge.cooleshow.biz.dal.enums.StudentCourseEnum@NOTSTART">
  261. and cs.status_ = '${@ com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum@NOT_START}'
  262. </when>
  263. </choose>
  264. </if>
  265. <if test="param.courseGroupId != null">
  266. and #{param.courseGroupId} = cs.course_group_id_
  267. </if>
  268. <if test="param.courseId != null">
  269. and cs.id_ like concat('%',#{param.courseId},'%')
  270. </if>
  271. </where>
  272. order by cs.id_ desc
  273. </select>
  274. <update id="opsPreStudentNum">
  275. update course_group
  276. set
  277. pre_student_num_ = pre_student_num_ + #{num}
  278. where id_ = #{id}
  279. </update>
  280. </mapper>