CourseGroupMapper.xml 16 KB

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