CourseScheduleStudentPaymentMapper.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment" id="CourseScheduleStudentPayment">
  9. <result column="id_" property="id" />
  10. <result column="group_type_" property="groupType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  11. <result column="music_group_id_" property="musicGroupId"/>
  12. <result column="course_schedule_id_" property="courseScheduleId" />
  13. <result column="user_id_" property="userId" />
  14. <result column="expect_price_" property="expectPrice" />
  15. <result column="actual_price_" property="actualPrice" />
  16. <result column="create_time_" property="createTime" />
  17. <result column="update_time_" property="updateTime" />
  18. <result column="settlement_time_" property="settlementTime" />
  19. <result column="class_group_id_" property="classGroupId" />
  20. </resultMap>
  21. <resultMap type="com.ym.mec.biz.dal.dto.StudentCourseTimesDto" id="studentCourseTimesDto">
  22. <result column="user_id_" property="userId" />
  23. <result column="totalTimes" property="totalCourseTimes"/>
  24. <result column="vipTimes" property="vipCourseTimes" />
  25. <result column="practiceTmes" property="practiceCourseTimes" />
  26. <result column="freePracticeTimes" property="freePracticeCourseTimes" />
  27. </resultMap>
  28. <!-- 根据主键查询一条记录 -->
  29. <select id="get" resultMap="CourseScheduleStudentPayment" >
  30. SELECT * FROM course_schedule_student_payment WHERE id_ = #{id}
  31. </select>
  32. <!-- 全查询 -->
  33. <select id="findAll" resultMap="CourseScheduleStudentPayment">
  34. SELECT * FROM course_schedule_student_payment ORDER BY id_
  35. </select>
  36. <!-- 向数据库增加一条记录 -->
  37. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  38. <!--
  39. <selectKey resultClass="int" keyProperty="id" >
  40. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  41. </selectKey>
  42. -->
  43. INSERT INTO course_schedule_student_payment (id_,group_type_,music_group_id_,course_schedule_id_,user_id_,expect_price_,actual_price_,create_time_,update_time_,settlement_time_,class_group_id_) VALUES(#{id},#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{musicGroupId},#{courseScheduleId},#{userId},#{expectPrice},#{actualPrice},#{createTime},NOW(),#{settlementTime},#{classGroupId})
  44. </insert>
  45. <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
  46. INSERT INTO course_schedule_student_payment (id_,group_type_,music_group_id_,course_schedule_id_,user_id_,expect_price_,actual_price_,create_time_,update_time_,settlement_time_,class_group_id_)
  47. VALUE
  48. <foreach collection="list" item="data" separator=",">
  49. (#{data.id},#{data.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{data.musicGroupId},#{data.courseScheduleId},#{data.userId},#{data.expectPrice},#{data.actualPrice},now(),now(),#{data.settlementTime},#{data.classGroupId})
  50. </foreach>
  51. </insert>
  52. <!-- 根据主键查询一条记录 -->
  53. <update id="update" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment">
  54. UPDATE course_schedule_student_payment
  55. <set>
  56. <if test="userId != null">
  57. user_id_ = #{userId},
  58. </if>
  59. <if test="id != null">
  60. id_ = #{id},
  61. </if>
  62. <if test="courseScheduleId != null">
  63. course_schedule_id_ = #{courseScheduleId},
  64. </if>
  65. <if test="groupType != null">
  66. group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  67. </if>
  68. <if test="musicGroupId != null">
  69. music_group_id_ = #{musicGroupId},
  70. </if>
  71. <if test="updateTime != null">
  72. update_time_ = NOW(),
  73. </if>
  74. <if test="settlementTime != null">
  75. settlement_time_ = #{settlementTime},
  76. </if>
  77. <if test="expectPrice != null">
  78. expect_price_ = #{expectPrice},
  79. </if>
  80. <if test="actualPrice != null">
  81. actual_price_ = #{actualPrice},
  82. </if>
  83. <if test="createTime != null">
  84. create_time_ = #{createTime},
  85. </if>
  86. <if test="classGroupId != null">
  87. class_group_id_ = #{classGroupId},
  88. </if>
  89. </set> WHERE id_ = #{id}
  90. </update>
  91. <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment">
  92. <foreach collection="courseScheduleStudentPayments" item="courseScheduleStudentPayment" separator=";">
  93. UPDATE course_schedule_student_payment
  94. <set>
  95. <if test="courseScheduleStudentPayment.userId != null">
  96. user_id_ = #{courseScheduleStudentPayment.userId},
  97. </if>
  98. <if test="courseScheduleStudentPayment.courseScheduleId != null">
  99. course_schedule_id_ = #{courseScheduleStudentPayment.courseScheduleId},
  100. </if>
  101. <if test="courseScheduleStudentPayment.groupType != null">
  102. group_type_ = #{courseScheduleStudentPayment.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  103. </if>
  104. <if test="courseScheduleStudentPayment.musicGroupId != null">
  105. music_group_id_ = #{courseScheduleStudentPayment.musicGroupId},
  106. </if>
  107. update_time_ = NOW(),
  108. <if test="courseScheduleStudentPayment.settlementTime != null">
  109. settlement_time_ = #{courseScheduleStudentPayment.settlementTime},
  110. </if>
  111. <if test="courseScheduleStudentPayment.expectPrice != null">
  112. expect_price_ = #{courseScheduleStudentPayment.expectPrice},
  113. </if>
  114. <if test="courseScheduleStudentPayment.actualPrice != null">
  115. actual_price_ = #{courseScheduleStudentPayment.actualPrice},
  116. </if>
  117. <if test="courseScheduleStudentPayment.createTime != null">
  118. create_time_ = #{courseScheduleStudentPayment.createTime},
  119. </if>
  120. <if test="courseScheduleStudentPayment.classGroupId != null">
  121. class_group_id_ = #{courseScheduleStudentPayment.classGroupId},
  122. </if>
  123. </set> WHERE id_ = #{courseScheduleStudentPayment.id}
  124. </foreach>
  125. </update>
  126. <update id="adjustPlayMidi">
  127. UPDATE course_schedule_student_payment cssp
  128. <set>
  129. <if test="content == null or content == ''">
  130. cssp.open_play_midi_ = NULL,cssp.update_time_ = NOW()
  131. </if>
  132. <if test="content != null and content != ''">
  133. cssp.open_play_midi_ = #{content},cssp.update_time_ = NOW()
  134. </if>
  135. </set>
  136. <where>
  137. cssp.course_schedule_id_ = #{courseScheduleId}
  138. <if test="userId != null and userId != ''">
  139. AND FIND_IN_SET(cssp.user_id_,#{userId})
  140. </if>
  141. </where>
  142. </update>
  143. <update id="adjustExamSong">
  144. UPDATE course_schedule_student_payment
  145. <set>
  146. <if test="examSongJson != null">
  147. exam_song_download_json_ = #{examSongJson}
  148. </if>
  149. </set>
  150. WHERE course_schedule_id_ = #{roomId}
  151. <if test="userId != null">
  152. AND user_id_ = #{userId}
  153. </if>
  154. </update>
  155. <select id="getExamSongDownloadStatus" resultType="String">
  156. SELECT exam_song_download_json_
  157. FROM course_schedule_student_payment
  158. WHERE course_schedule_id_ = #{roomId}
  159. <if test="userId != null">
  160. AND user_id_ = #{userId}
  161. </if>
  162. </select>
  163. <!-- 根据主键删除一条记录 -->
  164. <delete id="delete" >
  165. DELETE FROM course_schedule_student_payment WHERE id_ = #{id}
  166. </delete>
  167. <!-- 分页查询 -->
  168. <select id="queryPage" resultMap="CourseScheduleStudentPayment" parameterType="map">
  169. SELECT * FROM course_schedule_student_payment ORDER BY id_ <include refid="global.limit"/>
  170. </select>
  171. <!-- 查询当前表的总记录数 -->
  172. <select id="queryCount" resultType="int">
  173. SELECT COUNT(*) FROM course_schedule_student_payment
  174. </select>
  175. <select id="findByCourseScheduleIds" resultMap="CourseScheduleStudentPayment">
  176. SELECT * FROM course_schedule_student_payment WHERE course_schedule_id_ IN
  177. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  178. #{id}
  179. </foreach>
  180. </select>
  181. <resultMap id="StudentAttendanceStatisticsResp" type="com.ym.mec.biz.dal.dto.StudentAttendanceStatisticsResponse">
  182. <result property="userId" column="user_id_"/>
  183. <result property="studentName" column="username_"/>
  184. </resultMap>
  185. <select id="findStudentByClassGroup" resultMap="StudentAttendanceStatisticsResp">
  186. SELECT
  187. cssp.user_id_,
  188. su.username_
  189. FROM
  190. course_schedule_student_payment cssp
  191. LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
  192. WHERE
  193. cssp.class_group_id_ = #{classGroupId}
  194. GROUP BY
  195. cssp.user_id_
  196. ORDER BY cssp.user_id_
  197. <include refid="global.limit"/>
  198. </select>
  199. <select id="countStudentByClassGroup" resultType="int">
  200. SELECT
  201. COUNT(DISTINCT cssp.user_id_)
  202. FROM
  203. course_schedule_student_payment cssp
  204. WHERE
  205. cssp.class_group_id_ = #{classGroupId}
  206. </select>
  207. <select id="countSurplusCourseFee" resultType="java.math.BigDecimal">
  208. SELECT
  209. SUM(expect_price_)
  210. FROM
  211. course_schedule_student_payment cssp
  212. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  213. WHERE
  214. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  215. AND cssp.user_id_ = #{userId}
  216. AND CONCAT(cs.class_date_ ,' ',cs.start_class_time_) &gt; NOW()
  217. AND cs.class_group_id_ = #{classGroupId}
  218. </select>
  219. <select id="countAllCourseFee" resultType="java.math.BigDecimal">
  220. SELECT
  221. SUM(expect_price_)
  222. FROM
  223. course_schedule_student_payment cssp
  224. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  225. WHERE
  226. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  227. AND cs.class_group_id_ = #{classGroupId}
  228. </select>
  229. <select id="findNotStartCourseStudentPaymentIdsWithClassGroupAndStudent" resultType="int">
  230. SELECT
  231. cssp.id_
  232. FROM
  233. course_schedule_student_payment cssp
  234. LEFT JOIN course_schedule cs ON cs.id_=cssp.course_schedule_id_
  235. WHERE
  236. cssp.class_group_id_ = #{classGroupId}
  237. AND cssp.user_id_=#{userId}
  238. AND CONCAT(cs.class_date_,' ',cs.start_class_time_)>NOW()
  239. </select>
  240. <select id="findVipGroupCoursePrice" resultType="java.math.BigDecimal">
  241. SELECT
  242. cssp.expect_price_
  243. FROM
  244. course_schedule cs
  245. LEFT JOIN course_schedule_student_payment cssp ON cs.id_ = cssp.course_schedule_id_
  246. WHERE
  247. cs.music_group_id_ = #{vipGroupId}
  248. AND cs.teach_mode_ = #{teachMode}
  249. AND cs.group_type_ = 'VIP'
  250. AND cssp.expect_price_ IS NOT NULL
  251. ORDER BY CONCAT(cs.class_date_,' ',cs.start_class_time_) DESC LIMIT 1
  252. </select>
  253. <select id="findStudentCourseNum" resultType="java.util.Map">
  254. SELECT COUNT(DISTINCT cssp.id_) 'value',cssp.music_group_id_ 'key' FROM course_schedule cs
  255. LEFT JOIN course_schedule_student_payment cssp ON cs.music_group_id_ = cssp.music_group_id_ AND cs.id_ = cssp.course_schedule_id_
  256. WHERE cs.music_group_id_ IN
  257. <foreach collection="musicGroupIds" separator="," item="item" open="(" close=")">
  258. #{item}
  259. </foreach>
  260. AND cs.group_type_ = #{groupType} AND cssp.user_id_ = #{userId} AND cs.status_ = 'NOT_START' AND cs.del_flag_ = 0
  261. GROUP BY cssp.music_group_id_
  262. </select>
  263. <select id="countStudentCourseNumWithGroup" resultType="int">
  264. SELECT COUNT(id_) FROM course_schedule_student_payment WHERE group_type_=#{groupType} AND music_group_id_=#{groupId}
  265. </select>
  266. <select id="queryMusicStudentPer" resultType="java.lang.Integer">
  267. SELECT cssp.user_id_ FROM course_schedule_student_payment cssp
  268. LEFT JOIN music_group mg ON cssp.music_group_id_ = mg.id_ AND cssp.group_type_ = 'MUSIC'
  269. LEFT JOIN student_registration sr ON cssp.user_id_ = sr.user_id_ AND cssp.music_group_id_ = sr.music_group_id_
  270. WHERE mg.status_ = 'PROGRESS' AND sr.music_group_status_ != 'QUIT'
  271. GROUP BY cssp.user_id_
  272. </select>
  273. <select id="queryVipStudentPer" resultType="java.lang.Integer">
  274. SELECT cssp.user_id_ FROM course_schedule_student_payment cssp
  275. LEFT JOIN vip_group vg ON cssp.music_group_id_ = vg.id_
  276. WHERE vg.group_status_ IN (2,4) AND cssp.group_type_ = 'VIP'
  277. GROUP BY cssp.user_id_
  278. </select>
  279. <select id="countCourseStudentNum" resultType="java.util.Map">
  280. SELECT
  281. sa.course_schedule_id_ AS 'key',
  282. COUNT( DISTINCT sa.user_id_ ) AS 'value'
  283. FROM
  284. course_schedule_student_payment sa
  285. LEFT JOIN class_group_student_mapper cgsm ON sa.class_group_id_=cgsm.class_group_id_ AND sa.user_id_=cgsm.user_id_
  286. WHERE course_schedule_id_ IN
  287. <foreach collection="courseIds" item="courseId" open="(" close=")" separator=",">
  288. #{courseId}
  289. </foreach>
  290. AND cgsm.status_ NOT IN ('QUIT', 'QUIT_SCHOOL')
  291. GROUP BY
  292. course_schedule_id_
  293. </select>
  294. <select id="checkStudentHaveCourse" resultType="int">
  295. SELECT COUNT(id_) FROM course_schedule_student_payment WHERE course_schedule_id_=#{courseScheduleId} AND user_id_=#{userId}
  296. </select>
  297. <select id="findByCourseSchedule" resultMap="CourseScheduleStudentPayment">
  298. SELECT * FROM course_schedule_student_payment WHERE course_schedule_id_ = #{courseScheduleId}
  299. </select>
  300. <resultMap id="VipGroupGiveCourseSortDto" type="com.ym.mec.biz.dal.dto.VipGroupGiveCourseSortDto" extends="CourseScheduleStudentPayment">
  301. <result property="courseStartTime" column="course_start_time_"/>
  302. <result property="courseEndTime" column="course_end_time_"/>
  303. <result property="teachMode" column="teach_mode_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  304. </resultMap>
  305. <select id="findVipGroupSortCourseByGroup" resultMap="VipGroupGiveCourseSortDto">
  306. SELECT
  307. cssp.*,
  308. cs.teach_mode_,
  309. CONCAT(cs.class_date_,' ',cs.start_class_time_) course_start_time_,
  310. CONCAT(cs.class_date_,' ',cs.end_class_time_) course_end_time_
  311. FROM course_schedule_student_payment cssp
  312. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
  313. WHERE cssp.music_group_id_=#{groupId} AND cssp.group_type_='VIP'
  314. -- AND CONCAT(cs.class_date_,' ',cs.start_class_time_) &gt; NOW()
  315. AND cssp.settlement_time_ IS NULL
  316. </select>
  317. <select id="countStudentNum" resultType="java.lang.Integer">
  318. SELECT COUNT(id_) FROM course_schedule_student_payment WHERE course_schedule_id_ = #{courseScheduleId}
  319. </select>
  320. <select id="findStudents" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  321. SELECT su.id_ user_id_,su.username_,su.avatar_ head_url_,su.gender_
  322. FROM course_schedule_student_payment cssp
  323. LEFT JOIN sys_user su ON su.id_ = cssp.user_id_
  324. WHERE cssp.course_schedule_id_ = #{courseScheduleId}
  325. GROUP BY su.id_
  326. </select>
  327. <select id="getStudentIdMap" resultType="java.util.Map">
  328. SELECT cssp.course_schedule_id_ 'key',GROUP_CONCAT(DISTINCT cssp.user_id_) 'value'
  329. FROM course_schedule_student_payment cssp
  330. WHERE cssp.course_schedule_id_ IN
  331. <foreach collection="courseScheduleIds" item="scheduleId" open="(" close=")" separator=",">
  332. #{scheduleId}
  333. </foreach>
  334. GROUP BY cssp.course_schedule_id_
  335. </select>
  336. <resultMap id="Practice4ExercisesSituationDto" type="com.ym.mec.biz.dal.dto.Practice4ExercisesSituationDto">
  337. <result property="userId" column="user_id_"/>
  338. <result property="courseStartTime" column="start_class_time_"/>
  339. <result property="actualTeacherId" column="actual_teacher_id_"/>
  340. </resultMap>
  341. <select id="findNoPracticeStudentIdsOnWeek" resultMap="Practice4ExercisesSituationDto">
  342. SELECT
  343. cssp.user_id_,
  344. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  345. pg.user_id_ actual_teacher_id_
  346. FROM
  347. course_schedule_student_payment cssp
  348. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  349. LEFT JOIN practice_group pg ON cssp.music_group_id_=pg.id_
  350. LEFT JOIN student s ON cssp.user_id_=s.user_id_
  351. WHERE
  352. cssp.group_type_ = 'PRACTICE'
  353. AND s.service_tag_=1
  354. AND cssp.user_id_ NOT IN (
  355. SELECT
  356. cssp1.user_id_
  357. FROM
  358. course_schedule_student_payment cssp1
  359. LEFT JOIN course_schedule cs1 ON cssp1.course_schedule_id_ = cs1.id_
  360. WHERE cssp1.group_type_ = 'PRACTICE'
  361. AND cs1.class_date_ BETWEEN #{monday} AND #{sunday}
  362. )
  363. ORDER BY
  364. cssp.user_id_
  365. </select>
  366. <select id="findNoPracticeStudentTeacherId" resultType="java.lang.Integer">
  367. SELECT cs.actual_teacher_id_
  368. FROM course_schedule_student_payment cssp
  369. LEFT JOIN course_schedule cs ON cs.id_=cssp.course_schedule_id_
  370. WHERE cssp.group_type_='PRACTICE' AND cssp.user_id_=#{studentId} AND cs.actual_teacher_id_ IS NOT NULL
  371. ORDER BY CONCAT(cs.class_date_, ' ', cs.start_class_time_) DESC LIMIT 1;
  372. </select>
  373. <delete id="deleteStudentCourseSchedule">
  374. DELETE FROM course_schedule_student_payment WHERE user_id_ = #{userId} AND course_schedule_id_ IN
  375. <foreach collection="courseScheduleList" item="courseSchedule" index="index" open="(" close=")" separator=",">
  376. #{courseSchedule.id}
  377. </foreach>
  378. </delete>
  379. <delete id="deleteByCourseSchedule">
  380. DELETE FROM course_schedule_student_payment WHERE course_schedule_id_ IN
  381. <foreach collection="courseScheduleIds" item="courseScheduleId" index="index" open="(" close=")" separator=",">
  382. #{courseScheduleId}
  383. </foreach>
  384. </delete>
  385. <delete id="batchDeleteWithID">
  386. DELETE FROM course_schedule_student_payment WHERE id_ IN
  387. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  388. #{id}
  389. </foreach>
  390. </delete>
  391. <delete id="deleteStudentCourseScheduleByUserId">
  392. DELETE FROM course_schedule_student_payment WHERE course_schedule_id_ = #{courseScheduleId} AND user_id_ IN
  393. <foreach collection="userIdList" item="userId" index="index" open="(" close=")" separator=",">
  394. #{userId}
  395. </foreach>
  396. </delete>
  397. <delete id="deleteByMusicGroupId" parameterType="map">
  398. DELETE cssp FROM course_schedule_student_payment cssp left join course_schedule cs on cssp.course_schedule_id_ = cs.id_ WHERE cssp.music_group_id_=#{musicGroupId} AND cssp.group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} and cs.status_ = 'NOT_START'
  399. </delete>
  400. <delete id="deleteByGroup">
  401. DELETE FROM course_schedule_student_payment WHERE music_group_id_=#{groupId} AND group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  402. </delete>
  403. <select id="queryStudentNotStartCourseTimesOfOnline" resultMap="studentCourseTimesDto">
  404. SELECT cssp.`user_id_`,count(*) totalTimes,
  405. sum(CASE pg.type_ WHEN 'FREE' THEN 0 WHEN 'CHARGE' THEN 1 END) practiceTmes,
  406. sum(case when (pg.type_='FREE' AND cssp.`group_type_` = 'PRACTICE' ) then 1 ELSE 0 END) freePracticeTimes
  407. FROM course_schedule_student_payment cssp LEFT JOIN course_schedule cs on cssp.course_schedule_id_ = cs.id_
  408. LEFT JOIN practice_group pg ON pg.id_ = cs.music_group_id_ AND cs.group_type_ = 'PRACTICE'
  409. WHERE cs.`teach_mode_` = 'ONLINE' AND cs.status_ = 'NOT_START'
  410. GROUP BY cssp.`user_id_`
  411. </select>
  412. <resultMap id="StudentTeacherCourseDto" type="com.ym.mec.biz.dal.dto.StudentTeacherCourseDto">
  413. <result property="studentId" column="student_id_"/>
  414. <result property="teacherId" column="teacher_id_"/>
  415. <result property="groupType" column="group_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  416. <result property="groupId" column="group_id_"/>
  417. <result property="courseScheduleType" column="course_schedule_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  418. <result property="classesStartTime" column="classes_start_time_"/>
  419. </resultMap>
  420. <select id="findAllStudentCourseInfo" resultMap="StudentTeacherCourseDto">
  421. SELECT
  422. cssp.user_id_ student_id_,
  423. cssp.group_type_ group_type_,
  424. cssp.music_group_id_ group_id_,
  425. cs.type_ course_schedule_type_,
  426. CONCAT(cs.class_date_, ' ', cs.start_class_time_) classes_start_time_,
  427. cgtm.user_id_ teacher_id_
  428. FROM
  429. student s
  430. LEFT JOIN course_schedule_student_payment cssp ON s.user_id_=cssp.user_id_
  431. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  432. LEFT JOIN class_group_teacher_mapper cgtm ON cssp.class_group_id_=cgtm.class_group_id_
  433. WHERE cs.type_ IN ('PRACTICE', 'VIP', 'SINGLE', 'MIX') AND cgtm.teacher_role_='BISHOP';
  434. </select>
  435. <select id="findCoursePayment" resultType="map">
  436. SELECT
  437. course_schedule_id_ AS 'key',
  438. SUM( CASE WHEN actual_price_ IS NULL THEN expect_price_ ELSE actual_price_ END ) AS 'value'
  439. FROM
  440. course_schedule_student_payment
  441. WHERE course_schedule_id_ IN
  442. <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
  443. #{courseScheduleId}
  444. </foreach>
  445. GROUP BY
  446. course_schedule_id_
  447. </select>
  448. <select id="countStudentNotStartCourseNumWithCourseType" resultType="int">
  449. SELECT COUNT(DISTINCT cssp.course_schedule_id_) FROM course_schedule_student_payment cssp
  450. LEFT JOIN course_schedule cs ON cs.id_=cssp.course_schedule_id_
  451. WHERE cssp.user_id_=#{studentId}
  452. <if test="courseScheduleType != null">
  453. AND cs.type_= #{courseScheduleType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  454. </if>
  455. AND CONCAT(class_date_, ' ', start_class_time_)&gt;NOW()
  456. </select>
  457. <select id="queryMidiByUserIdsAndCourseId" resultType="java.util.Map">
  458. SELECT cssp.user_id_ 'key',CASE WHEN cssp.open_play_midi_ IS NULL THEN '' ELSE cssp.open_play_midi_ END 'value' FROM course_schedule_student_payment cssp
  459. WHERE cssp.user_id_ IN
  460. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  461. #{userId}
  462. </foreach>
  463. AND cssp.course_schedule_id_ = #{courseScheduleId}
  464. </select>
  465. <select id="queryExamSongByUserIdsAndCourseId" resultType="java.util.Map">
  466. SELECT user_id_ 'key',CASE WHEN exam_song_download_json_ IS NULL THEN '' ELSE exam_song_download_json_ END 'value' FROM course_schedule_student_payment
  467. WHERE user_id_ IN
  468. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  469. #{userId}
  470. </foreach>
  471. AND course_schedule_id_ = #{courseScheduleId}
  472. </select>
  473. <select id="getMidiByCourseIdAndUserId" resultType="java.lang.String">
  474. SELECT cssp.open_play_midi_ FROM course_schedule_student_payment cssp
  475. WHERE cssp.user_id_ = #{userId} AND cssp.course_schedule_id_ = #{courseScheduleId}
  476. </select>
  477. <select id="findGroupCoursesUnitPrice" resultType="java.util.Map">
  478. SELECT
  479. music_group_id_ AS 'key',
  480. CONVERT ( SUM( expect_price_ ) / COUNT(DISTINCT course_schedule_id_ ), DECIMAL ( 10, 2 ) ) AS 'value'
  481. FROM
  482. course_schedule_student_payment
  483. WHERE
  484. group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  485. AND music_group_id_ IN
  486. <foreach collection="groupIds" item="groupId" separator="," open="(" close=")">
  487. #{groupId}
  488. </foreach>
  489. GROUP BY
  490. music_group_id_;
  491. </select>
  492. <resultMap id="RongyunBasicUserDto" type="com.ym.mec.biz.dal.dto.RongyunBasicUserDto">
  493. <result property="userName" column="username_"/>
  494. <result property="userId" column="user_id_"/>
  495. <result property="headUrl" column="avatar_"/>
  496. </resultMap>
  497. <select id="queryNoJoinStu" resultMap="RongyunBasicUserDto">
  498. SELECT CASE WHEN su.username_ IS NULL THEN su.real_name_ ELSE su.username_ END username_,
  499. su.avatar_,cssp.user_id_
  500. FROM course_schedule_student_payment cssp
  501. LEFT JOIN sys_user su ON su.id_ = cssp.user_id_
  502. WHERE cssp.course_schedule_id_ = #{courseScheduleId}
  503. AND NOT EXISTS (SELECT * FROM rongyun_room_member rrm WHERE rrm.rid = #{roomId} AND rrm.uid = cssp.user_id_)
  504. </select>
  505. <select id="countNotStartCourseStudentNumWithGroup" resultType="int">
  506. SELECT
  507. COUNT( cssp.user_id_ )
  508. FROM
  509. course_schedule_student_payment cssp
  510. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  511. WHERE
  512. cssp.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  513. AND cssp.music_group_id_ = #{groupId}
  514. AND CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) > NOW( )
  515. </select>
  516. <select id="findStudentLastCourseSchedule" resultType="java.util.Map">
  517. SELECT
  518. cssp.user_id_ AS 'key',
  519. MAX(CONCAT( cs.class_date_, ' ', cs.start_class_time_ )) AS 'value'
  520. FROM
  521. course_schedule_student_payment cssp
  522. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  523. WHERE
  524. cssp.user_id_ IN
  525. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  526. #{studentId}
  527. </foreach>
  528. AND CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) &lt; NOW( )
  529. GROUP BY user_id_;
  530. </select>
  531. <sql id="queryAllCondition">
  532. <where>
  533. <if test="courseScheduleId != null">
  534. course_schedule_id_ = #{courseScheduleId}
  535. </if>
  536. </where>
  537. </sql>
  538. <select id="queryAll" resultMap="CourseScheduleStudentPayment">
  539. SELECT * FROM course_schedule_student_payment
  540. <include refid="queryAllCondition" />
  541. ORDER BY id_
  542. <include refid="global.limit"/>
  543. </select>
  544. <select id="countAll" resultType="int">
  545. SELECT COUNT(*) FROM course_schedule_student_payment
  546. <include refid="queryAllCondition" />
  547. </select>
  548. <select id="countStudentDouble11CourseTime" resultMap="com.ym.mec.biz.dal.dao.StudentPaymentOrderDao.StudentVipDouble11Dto">
  549. SELECT
  550. cssp.user_id_ userId,
  551. SUM(CASE vgc.student_num_ WHEN 1 THEN 1 ELSE 0 END) course_one_to_one_time_,
  552. SUM(CASE vgc.student_num_ WHEN 2 THEN 1 ELSE 0 END) course_one_to_two_time_
  553. FROM
  554. course_schedule_student_payment cssp
  555. LEFT JOIN vip_group vg ON cssp.music_group_id_ = vg.id_
  556. LEFT JOIN vip_group_category vgc ON vg.vip_group_category_id_ = vgc.id_
  557. WHERE
  558. cssp.user_id_ IN
  559. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  560. #{userId}
  561. </foreach>
  562. AND vg.vip_group_activity_id_ IN
  563. <foreach collection="specialActivityIds" item="specialActivityId" open="(" close=")" separator=",">
  564. #{specialActivityId}
  565. </foreach>
  566. GROUP BY
  567. cssp.user_id_
  568. </select>
  569. </mapper>