CourseScheduleStudentPaymentMapper.xml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887
  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="original_price_" property="originalPrice"/>
  15. <result column="expect_price_" property="expectPrice" />
  16. <result column="actual_price_" property="actualPrice" />
  17. <result column="create_time_" property="createTime" />
  18. <result column="update_time_" property="updateTime" />
  19. <result column="settlement_time_" property="settlementTime" />
  20. <result column="class_group_id_" property="classGroupId" />
  21. <result column="batch_no_" property="batchNo"/>
  22. <result column="be_merged_" property="beMerged"/>
  23. </resultMap>
  24. <resultMap type="com.ym.mec.biz.dal.dto.StudentCourseTimesDto" id="studentCourseTimesDto">
  25. <result column="user_id_" property="userId" />
  26. <result column="totalTimes" property="totalCourseTimes"/>
  27. <result column="vipTimes" property="vipCourseTimes" />
  28. <result column="practiceTmes" property="practiceCourseTimes" />
  29. <result column="freePracticeTimes" property="freePracticeCourseTimes" />
  30. </resultMap>
  31. <resultMap id="CourseScheduleStudentPaymentDto" type="com.ym.mec.biz.dal.entity.CourseScheduleStudentPaymentDto" extends="CourseScheduleStudentPayment">
  32. <result column="course_status_" property="courseStatus" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  33. <result column="course_start_time_" property="courseStartTime"/>
  34. </resultMap>
  35. <!-- 根据主键查询一条记录 -->
  36. <select id="get" resultMap="CourseScheduleStudentPayment" >
  37. SELECT * FROM course_schedule_student_payment WHERE id_ = #{id}
  38. </select>
  39. <!-- 全查询 -->
  40. <select id="findAll" resultMap="CourseScheduleStudentPayment">
  41. SELECT * FROM course_schedule_student_payment ORDER BY id_
  42. </select>
  43. <!-- 向数据库增加一条记录 -->
  44. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  45. INSERT INTO course_schedule_student_payment (id_,group_type_,music_group_id_,course_schedule_id_,user_id_,
  46. original_price_,expect_price_,actual_price_,create_time_,update_time_,settlement_time_,class_group_id_,batch_no_,be_merged_)
  47. VALUES(#{id},#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{musicGroupId},#{courseScheduleId},#{userId},
  48. #{originalPrice},#{expectPrice},#{actualPrice},#{createTime},NOW(),#{settlementTime},#{classGroupId},#{batchNo},#{beMerged})
  49. </insert>
  50. <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
  51. INSERT INTO course_schedule_student_payment (id_,group_type_,music_group_id_,course_schedule_id_,user_id_,expect_price_,
  52. original_price_,actual_price_,create_time_,update_time_,settlement_time_,class_group_id_,batch_no_,be_merged_)
  53. VALUE
  54. <foreach collection="list" item="data" separator=",">
  55. (#{data.id},#{data.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{data.musicGroupId},#{data.courseScheduleId},#{data.userId},#{data.expectPrice},
  56. #{data.originalPrice},#{data.actualPrice},now(),now(),#{data.settlementTime},#{data.classGroupId},#{data.batchNo},#{data.beMerged})
  57. </foreach>
  58. </insert>
  59. <!-- 根据主键查询一条记录 -->
  60. <update id="update" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment">
  61. UPDATE course_schedule_student_payment
  62. <set>
  63. <if test="userId != null">
  64. user_id_ = #{userId},
  65. </if>
  66. <if test="courseScheduleId != null">
  67. course_schedule_id_ = #{courseScheduleId},
  68. </if>
  69. <if test="groupType != null">
  70. group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  71. </if>
  72. <if test="musicGroupId != null">
  73. music_group_id_ = #{musicGroupId},
  74. </if>
  75. <if test="settlementTime != null">
  76. settlement_time_ = #{settlementTime},
  77. </if>
  78. <if test="expectPrice != null">
  79. expect_price_ = #{expectPrice},
  80. </if>
  81. <if test="actualPrice != null">
  82. actual_price_ = #{actualPrice},
  83. </if>
  84. <if test="createTime != null">
  85. create_time_ = #{createTime},
  86. </if>
  87. <if test="classGroupId != null">
  88. class_group_id_ = #{classGroupId},
  89. </if>
  90. <if test="batchNo != null">
  91. batch_no_ = #{batchNo},
  92. </if>
  93. <if test="originalPrice != null">
  94. original_price_ = #{originalPrice},
  95. </if>
  96. <if test="beMerged != null">
  97. be_merged_ = #{beMerged},
  98. </if>
  99. update_time_ = NOW()
  100. </set> WHERE id_ = #{id}
  101. </update>
  102. <update id="batchUpdate" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment">
  103. <foreach collection="courseScheduleStudentPayments" item="courseScheduleStudentPayment" separator=";">
  104. UPDATE course_schedule_student_payment
  105. <set>
  106. <if test="courseScheduleStudentPayment.userId != null">
  107. user_id_ = #{courseScheduleStudentPayment.userId},
  108. </if>
  109. <if test="courseScheduleStudentPayment.courseScheduleId != null">
  110. course_schedule_id_ = #{courseScheduleStudentPayment.courseScheduleId},
  111. </if>
  112. <if test="courseScheduleStudentPayment.groupType != null">
  113. group_type_ = #{courseScheduleStudentPayment.groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  114. </if>
  115. <if test="courseScheduleStudentPayment.musicGroupId != null">
  116. music_group_id_ = #{courseScheduleStudentPayment.musicGroupId},
  117. </if>
  118. <if test="courseScheduleStudentPayment.settlementTime != null">
  119. settlement_time_ = #{courseScheduleStudentPayment.settlementTime},
  120. </if>
  121. <if test="courseScheduleStudentPayment.expectPrice != null">
  122. expect_price_ = #{courseScheduleStudentPayment.expectPrice},
  123. </if>
  124. <if test="courseScheduleStudentPayment.actualPrice != null">
  125. actual_price_ = #{courseScheduleStudentPayment.actualPrice},
  126. </if>
  127. <if test="courseScheduleStudentPayment.createTime != null">
  128. create_time_ = #{courseScheduleStudentPayment.createTime},
  129. </if>
  130. <if test="courseScheduleStudentPayment.classGroupId != null">
  131. class_group_id_ = #{courseScheduleStudentPayment.classGroupId},
  132. </if>
  133. <if test="courseScheduleStudentPayment.batchNo != null">
  134. batch_no_ = #{courseScheduleStudentPayment.batchNo},
  135. </if>
  136. <if test="courseScheduleStudentPayment.originalPrice != null">
  137. original_price_ = #{courseScheduleStudentPayment.originalPrice},
  138. </if>
  139. <if test="courseScheduleStudentPayment.beMerged != null">
  140. be_merged_ = #{courseScheduleStudentPayment.beMerged},
  141. </if>
  142. update_time_ = NOW()
  143. </set> WHERE id_ = #{courseScheduleStudentPayment.id}
  144. </foreach>
  145. </update>
  146. <update id="adjustPlayMidi">
  147. UPDATE course_schedule_student_payment cssp
  148. <set>
  149. <if test="content == null or content == ''">
  150. cssp.open_play_midi_ = NULL,cssp.update_time_ = NOW()
  151. </if>
  152. <if test="content != null and content != ''">
  153. cssp.open_play_midi_ = #{content},cssp.update_time_ = NOW()
  154. </if>
  155. </set>
  156. <where>
  157. cssp.course_schedule_id_ = #{courseScheduleId}
  158. <if test="userId != null and userId != ''">
  159. AND FIND_IN_SET(cssp.user_id_,#{userId})
  160. </if>
  161. </where>
  162. </update>
  163. <update id="adjustExamSong">
  164. UPDATE course_schedule_student_payment SET exam_song_download_json_ = #{examSongJson}
  165. WHERE course_schedule_id_ = #{roomId}
  166. <if test="userId != null">
  167. AND user_id_ = #{userId}
  168. </if>
  169. </update>
  170. <!-- 根据主键删除一条记录 -->
  171. <delete id="delete" >
  172. DELETE FROM course_schedule_student_payment WHERE id_ = #{id}
  173. </delete>
  174. <!-- 分页查询 -->
  175. <select id="queryPage" resultMap="CourseScheduleStudentPayment" parameterType="map">
  176. SELECT * FROM course_schedule_student_payment ORDER BY id_ <include refid="global.limit"/>
  177. </select>
  178. <!-- 查询当前表的总记录数 -->
  179. <select id="queryCount" resultType="int">
  180. SELECT COUNT(*) FROM course_schedule_student_payment
  181. </select>
  182. <select id="findByCourseScheduleIds" resultMap="CourseScheduleStudentPayment">
  183. SELECT * FROM course_schedule_student_payment WHERE course_schedule_id_ IN
  184. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  185. #{id}
  186. </foreach>
  187. </select>
  188. <resultMap id="StudentAttendanceStatisticsResp" type="com.ym.mec.biz.dal.dto.StudentAttendanceStatisticsResponse">
  189. <result property="userId" column="user_id_"/>
  190. <result property="studentName" column="username_"/>
  191. </resultMap>
  192. <select id="findStudentByClassGroup" resultMap="StudentAttendanceStatisticsResp">
  193. SELECT
  194. cssp.user_id_,
  195. su.username_
  196. FROM
  197. course_schedule_student_payment cssp
  198. LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
  199. WHERE
  200. cssp.class_group_id_ = #{classGroupId}
  201. GROUP BY
  202. cssp.user_id_
  203. ORDER BY cssp.user_id_
  204. <include refid="global.limit"/>
  205. </select>
  206. <select id="countStudentByClassGroup" resultType="int">
  207. SELECT
  208. COUNT(DISTINCT cssp.user_id_)
  209. FROM
  210. course_schedule_student_payment cssp
  211. WHERE
  212. cssp.class_group_id_ = #{classGroupId}
  213. </select>
  214. <select id="countSurplusCourseFee" resultType="java.math.BigDecimal">
  215. SELECT
  216. SUM(expect_price_)
  217. FROM
  218. course_schedule_student_payment cssp
  219. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  220. WHERE
  221. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  222. AND cssp.user_id_ = #{userId}
  223. AND CONCAT(cs.class_date_ ,' ',cs.start_class_time_) &gt; NOW()
  224. AND cs.class_group_id_ = #{classGroupId} AND cs.pre_course_flag_ = 0
  225. </select>
  226. <select id="countAllCourseFee" resultType="java.math.BigDecimal">
  227. SELECT
  228. SUM(expect_price_)
  229. FROM
  230. course_schedule_student_payment cssp
  231. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  232. WHERE
  233. (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL)
  234. AND cs.class_group_id_ = #{classGroupId} AND cs.pre_course_flag_ = 0
  235. </select>
  236. <select id="findNotStartCourseStudentPaymentIdsWithClassGroupAndStudent" resultType="int">
  237. SELECT
  238. cssp.id_
  239. FROM
  240. course_schedule_student_payment cssp
  241. LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
  242. WHERE
  243. cssp.class_group_id_ = #{classGroupId}
  244. AND cssp.user_id_ = #{userId}
  245. AND CONCAT(cs.class_date_,' ',cs.start_class_time_) > NOW() AND cs.pre_course_flag_ = 0
  246. </select>
  247. <select id="findVipGroupCoursePrice" resultType="java.math.BigDecimal">
  248. SELECT
  249. cssp.expect_price_
  250. FROM
  251. course_schedule cs
  252. LEFT JOIN course_schedule_student_payment cssp ON cs.id_ = cssp.course_schedule_id_
  253. WHERE
  254. cs.music_group_id_ = #{vipGroupId}
  255. AND cs.teach_mode_ = #{teachMode}
  256. AND cs.group_type_ = 'VIP'
  257. AND cssp.expect_price_ IS NOT NULL
  258. ORDER BY CONCAT(cs.class_date_,' ',cs.start_class_time_) DESC LIMIT 1
  259. </select>
  260. <select id="findStudentCourseNum" resultType="java.util.Map">
  261. SELECT COUNT(DISTINCT cssp.id_) 'value',cssp.music_group_id_ 'key' FROM course_schedule cs
  262. LEFT JOIN course_schedule_student_payment cssp ON cs.music_group_id_ = cssp.music_group_id_ AND cs.id_ = cssp.course_schedule_id_
  263. WHERE cs.music_group_id_ IN
  264. <foreach collection="musicGroupIds" separator="," item="item" open="(" close=")">
  265. #{item}
  266. </foreach>
  267. AND cs.group_type_ = #{groupType} AND cssp.user_id_ = #{userId}
  268. AND cs.status_ = 'NOT_START' AND cs.del_flag_ = 0 AND cs.pre_course_flag_ = 0
  269. GROUP BY cssp.music_group_id_
  270. </select>
  271. <select id="countStudentCourseNumWithGroup" resultType="int">
  272. SELECT COUNT(id_) FROM course_schedule_student_payment WHERE group_type_=#{groupType} AND music_group_id_=#{groupId}
  273. </select>
  274. <select id="queryMusicStudentPer" resultType="java.lang.Integer">
  275. SELECT cssp.user_id_ FROM course_schedule_student_payment cssp
  276. LEFT JOIN music_group mg ON cssp.music_group_id_ = mg.id_ AND cssp.group_type_ = 'MUSIC'
  277. LEFT JOIN student_registration sr ON cssp.user_id_ = sr.user_id_ AND cssp.music_group_id_ = sr.music_group_id_
  278. WHERE mg.status_ = 'PROGRESS' AND sr.music_group_status_ != 'QUIT'
  279. GROUP BY cssp.user_id_
  280. </select>
  281. <select id="queryVipStudentPer" resultType="java.lang.Integer">
  282. SELECT cssp.user_id_ FROM course_schedule_student_payment cssp
  283. LEFT JOIN vip_group vg ON cssp.music_group_id_ = vg.id_
  284. WHERE vg.group_status_ IN (2,4) AND cssp.group_type_ = 'VIP'
  285. GROUP BY cssp.user_id_
  286. </select>
  287. <select id="countCourseStudentNum" resultType="java.util.Map">
  288. SELECT
  289. sa.course_schedule_id_ AS 'key',
  290. COUNT( DISTINCT sa.user_id_ ) AS 'value'
  291. FROM
  292. course_schedule_student_payment sa
  293. WHERE course_schedule_id_ IN
  294. <foreach collection="courseIds" item="courseId" open="(" close=")" separator=",">
  295. #{courseId}
  296. </foreach>
  297. GROUP BY
  298. course_schedule_id_
  299. </select>
  300. <select id="checkStudentHaveCourse" resultType="int">
  301. SELECT COUNT(id_) FROM course_schedule_student_payment WHERE course_schedule_id_=#{courseScheduleId} AND user_id_=#{userId}
  302. </select>
  303. <select id="findByCourseSchedule" resultMap="CourseScheduleStudentPayment">
  304. SELECT * FROM course_schedule_student_payment WHERE course_schedule_id_ = #{courseScheduleId}
  305. </select>
  306. <resultMap id="VipGroupGiveCourseSortDto" type="com.ym.mec.biz.dal.dto.VipGroupGiveCourseSortDto" extends="CourseScheduleStudentPayment">
  307. <result property="courseStartTime" column="course_start_time_"/>
  308. <result property="courseEndTime" column="course_end_time_"/>
  309. <result property="teachMode" column="teach_mode_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  310. </resultMap>
  311. <select id="findVipGroupSortCourseByGroup" resultMap="VipGroupGiveCourseSortDto">
  312. SELECT
  313. cssp.*,
  314. cs.teach_mode_,
  315. CONCAT(cs.class_date_,' ',cs.start_class_time_) course_start_time_,
  316. CONCAT(cs.class_date_,' ',cs.end_class_time_) course_end_time_
  317. FROM course_schedule_student_payment cssp
  318. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
  319. WHERE cssp.music_group_id_=#{groupId} AND cssp.group_type_='VIP'
  320. -- AND CONCAT(cs.class_date_,' ',cs.start_class_time_) &gt; NOW()
  321. AND cssp.settlement_time_ IS NULL
  322. </select>
  323. <select id="countStudentNum" resultType="java.lang.Integer">
  324. SELECT COUNT(id_) FROM course_schedule_student_payment WHERE course_schedule_id_ = #{courseScheduleId}
  325. </select>
  326. <select id="countCourseOnlyStudentNum" resultType="int">
  327. SELECT COUNT(user_id_) FROM course_schedule_student_payment WHERE course_schedule_id_ = #{courseScheduleId}
  328. </select>
  329. <select id="findStudents" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  330. SELECT su.id_ user_id_,su.username_,su.avatar_ head_url_,su.gender_
  331. FROM course_schedule_student_payment cssp
  332. LEFT JOIN sys_user su ON su.id_ = cssp.user_id_
  333. WHERE cssp.course_schedule_id_ = #{courseScheduleId}
  334. GROUP BY su.id_
  335. </select>
  336. <select id="getStudentIdMap" resultType="java.util.Map">
  337. SELECT cssp.course_schedule_id_ 'key',GROUP_CONCAT(DISTINCT cssp.user_id_) 'value'
  338. FROM course_schedule_student_payment cssp
  339. WHERE cssp.course_schedule_id_ IN
  340. <foreach collection="courseScheduleIds" item="scheduleId" open="(" close=")" separator=",">
  341. #{scheduleId}
  342. </foreach>
  343. GROUP BY cssp.course_schedule_id_
  344. </select>
  345. <resultMap id="Practice4ExercisesSituationDto" type="com.ym.mec.biz.dal.dto.Practice4ExercisesSituationDto">
  346. <result property="userId" column="user_id_"/>
  347. <result property="courseStartTime" column="start_class_time_"/>
  348. <result property="actualTeacherId" column="actual_teacher_id_"/>
  349. </resultMap>
  350. <select id="findNoPracticeStudentIdsOnWeek" resultMap="Practice4ExercisesSituationDto">
  351. SELECT
  352. cssp.user_id_,
  353. CONCAT(cs.class_date_, ' ', cs.start_class_time_) start_class_time_,
  354. pg.user_id_ actual_teacher_id_
  355. FROM
  356. course_schedule_student_payment cssp
  357. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  358. LEFT JOIN practice_group pg ON cssp.music_group_id_=pg.id_
  359. LEFT JOIN student s ON cssp.user_id_=s.user_id_
  360. WHERE
  361. cssp.group_type_ = 'PRACTICE'
  362. AND s.service_tag_=1
  363. AND cssp.user_id_ NOT IN (
  364. SELECT
  365. cssp1.user_id_
  366. FROM
  367. course_schedule_student_payment cssp1
  368. LEFT JOIN course_schedule cs1 ON cssp1.course_schedule_id_ = cs1.id_
  369. WHERE cssp1.group_type_ = 'PRACTICE'
  370. AND cs1.class_date_ BETWEEN #{monday} AND #{sunday}
  371. )
  372. ORDER BY
  373. cssp.user_id_
  374. </select>
  375. <select id="findNoPracticeStudentTeacherId" resultType="java.lang.Integer">
  376. SELECT cs.actual_teacher_id_
  377. FROM course_schedule_student_payment cssp
  378. LEFT JOIN course_schedule cs ON cs.id_=cssp.course_schedule_id_
  379. WHERE cssp.group_type_='PRACTICE' AND cssp.user_id_=#{studentId} AND cs.actual_teacher_id_ IS NOT NULL
  380. ORDER BY CONCAT(cs.class_date_, ' ', cs.start_class_time_) DESC LIMIT 1;
  381. </select>
  382. <delete id="deleteStudentCourseSchedule">
  383. DELETE FROM course_schedule_student_payment WHERE user_id_ = #{userId} AND course_schedule_id_ IN
  384. <foreach collection="courseScheduleIdList" item="courseScheduleId" index="index" open="(" close=")" separator=",">
  385. #{courseScheduleId}
  386. </foreach>
  387. </delete>
  388. <delete id="deleteByCourseSchedule">
  389. DELETE FROM course_schedule_student_payment WHERE course_schedule_id_ IN
  390. <foreach collection="courseScheduleIds" item="courseScheduleId" index="index" open="(" close=")" separator=",">
  391. #{courseScheduleId}
  392. </foreach>
  393. </delete>
  394. <delete id="batchDeleteWithID">
  395. DELETE FROM course_schedule_student_payment WHERE id_ IN
  396. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  397. #{id}
  398. </foreach>
  399. </delete>
  400. <delete id="deleteStudentCourseScheduleByUserId">
  401. DELETE FROM course_schedule_student_payment WHERE course_schedule_id_ = #{courseScheduleId} AND user_id_ IN
  402. <foreach collection="userIdList" item="userId" index="index" open="(" close=")" separator=",">
  403. #{userId}
  404. </foreach>
  405. </delete>
  406. <delete id="deleteByMusicGroupId" parameterType="map">
  407. 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'
  408. </delete>
  409. <delete id="deleteByGroup">
  410. DELETE FROM course_schedule_student_payment WHERE music_group_id_=#{groupId} AND group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  411. </delete>
  412. <delete id="deletePreCourse">
  413. DELETE FROM course_schedule_student_payment WHERE course_schedule_id_ IN (
  414. SELECT id_ FROM course_schedule WHERE music_group_id_ = #{musicGroupId} AND group_type_ = 'MUSIC' AND pre_course_flag_ = 1)
  415. </delete>
  416. <select id="queryStudentNotStartCourseTimesOfOnline" resultMap="studentCourseTimesDto">
  417. SELECT cssp.`user_id_`,count(*) totalTimes,
  418. sum(CASE pg.type_ WHEN 'FREE' THEN 0 WHEN 'CHARGE' THEN 1 END) practiceTmes,
  419. sum(case when (pg.type_='FREE' AND cssp.`group_type_` = 'PRACTICE' ) then 1 ELSE 0 END) freePracticeTimes
  420. FROM course_schedule_student_payment cssp LEFT JOIN course_schedule cs on cssp.course_schedule_id_ = cs.id_
  421. LEFT JOIN practice_group pg ON pg.id_ = cs.music_group_id_ AND cs.group_type_ = 'PRACTICE'
  422. WHERE cs.`teach_mode_` = 'ONLINE' AND cs.status_ = 'NOT_START'
  423. GROUP BY cssp.`user_id_`
  424. </select>
  425. <resultMap id="StudentTeacherCourseDto" type="com.ym.mec.biz.dal.dto.StudentTeacherCourseDto">
  426. <result property="studentId" column="student_id_"/>
  427. <result property="teacherId" column="teacher_id_"/>
  428. <result property="groupType" column="group_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  429. <result property="groupId" column="group_id_"/>
  430. <result property="courseScheduleType" column="course_schedule_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  431. <result property="classesStartTime" column="classes_start_time_"/>
  432. </resultMap>
  433. <select id="findAllStudentCourseInfo" resultMap="StudentTeacherCourseDto">
  434. SELECT
  435. cssp.user_id_ student_id_,
  436. cssp.group_type_ group_type_,
  437. cssp.music_group_id_ group_id_,
  438. cs.type_ course_schedule_type_,
  439. CONCAT(cs.class_date_, ' ', cs.start_class_time_) classes_start_time_,
  440. cgtm.user_id_ teacher_id_
  441. FROM
  442. student s
  443. LEFT JOIN course_schedule_student_payment cssp ON s.user_id_=cssp.user_id_
  444. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  445. LEFT JOIN class_group_teacher_mapper cgtm ON cssp.class_group_id_=cgtm.class_group_id_
  446. WHERE cs.type_ IN ('PRACTICE', 'VIP', 'SINGLE', 'MIX') AND cs.pre_course_flag_ = 0 AND cgtm.teacher_role_='BISHOP';
  447. </select>
  448. <select id="findCoursePayment" resultType="map">
  449. SELECT
  450. course_schedule_id_ AS 'key',
  451. SUM( CASE WHEN actual_price_ IS NULL THEN expect_price_ ELSE actual_price_ END ) AS 'value'
  452. FROM
  453. course_schedule_student_payment
  454. WHERE course_schedule_id_ IN
  455. <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
  456. #{courseScheduleId}
  457. </foreach>
  458. GROUP BY
  459. course_schedule_id_
  460. </select>
  461. <select id="countStudentNotStartCourseNumWithCourseType" resultType="int">
  462. SELECT COUNT(DISTINCT cssp.course_schedule_id_) FROM course_schedule_student_payment cssp
  463. LEFT JOIN course_schedule cs ON cs.id_=cssp.course_schedule_id_
  464. WHERE cssp.user_id_=#{studentId}
  465. <if test="courseScheduleType != null">
  466. AND cs.type_= #{courseScheduleType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  467. </if>
  468. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW() AND cs.pre_course_flag_ = 0
  469. </select>
  470. <select id="countStudentsNotStartCourseNumWithCourseType" resultType="map">
  471. SELECT cssp.user_id_ 'key',COUNT(DISTINCT cssp.course_schedule_id_) 'value'
  472. FROM course_schedule_student_payment cssp
  473. LEFT JOIN course_schedule cs ON cs.id_=cssp.course_schedule_id_
  474. WHERE cssp.user_id_ IN
  475. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  476. #{studentId}
  477. </foreach>
  478. <if test="courseScheduleType != null">
  479. AND cs.type_= #{courseScheduleType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  480. </if>
  481. AND CONCAT(cs.class_date_, ' ', cs.start_class_time_) &gt; NOW() AND cs.pre_course_flag_ = 0
  482. GROUP BY cssp.user_id_
  483. </select>
  484. <select id="queryMidiByUserIdsAndCourseId" resultType="java.util.Map">
  485. 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
  486. WHERE cssp.user_id_ IN
  487. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  488. #{userId}
  489. </foreach>
  490. AND cssp.course_schedule_id_ = #{courseScheduleId}
  491. </select>
  492. <select id="queryExamSongByUserIdsAndCourseId" resultType="java.util.Map">
  493. 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
  494. WHERE user_id_ IN
  495. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  496. #{userId}
  497. </foreach>
  498. AND course_schedule_id_ = #{courseScheduleId}
  499. </select>
  500. <select id="getMidiByCourseIdAndUserId" resultType="java.lang.String">
  501. SELECT cssp.open_play_midi_ FROM course_schedule_student_payment cssp
  502. WHERE cssp.user_id_ = #{userId} AND cssp.course_schedule_id_ = #{courseScheduleId}
  503. </select>
  504. <select id="getExamJsonByCourseIdAndUserId" resultType="java.lang.String">
  505. SELECT cssp.exam_song_download_json_ FROM course_schedule_student_payment cssp
  506. WHERE cssp.user_id_ = #{userId} AND cssp.course_schedule_id_ = #{courseScheduleId}
  507. </select>
  508. <select id="findGroupCoursesUnitPrice" resultType="java.util.Map">
  509. SELECT
  510. music_group_id_ AS 'key',
  511. CONVERT ( SUM( expect_price_ ) / COUNT(DISTINCT course_schedule_id_ ), DECIMAL ( 10, 2 ) ) AS 'value'
  512. FROM
  513. course_schedule_student_payment
  514. WHERE
  515. group_type_ = #{groupType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  516. AND music_group_id_ IN
  517. <foreach collection="groupIds" item="groupId" separator="," open="(" close=")">
  518. #{groupId}
  519. </foreach>
  520. GROUP BY
  521. music_group_id_;
  522. </select>
  523. <resultMap id="RongyunBasicUserDto" type="com.ym.mec.biz.dal.dto.RongyunBasicUserDto">
  524. <result property="userName" column="username_"/>
  525. <result property="userId" column="user_id_"/>
  526. <result property="headUrl" column="avatar_"/>
  527. </resultMap>
  528. <select id="queryNoJoinStu" resultMap="RongyunBasicUserDto">
  529. SELECT CASE WHEN su.username_ IS NULL THEN su.real_name_ ELSE su.username_ END username_,
  530. su.avatar_,cssp.user_id_
  531. FROM course_schedule_student_payment cssp
  532. LEFT JOIN sys_user su ON su.id_ = cssp.user_id_
  533. WHERE cssp.course_schedule_id_ = #{courseScheduleId}
  534. AND NOT EXISTS (SELECT * FROM rongyun_room_member rrm WHERE rrm.rid = #{roomId} AND rrm.uid = cssp.user_id_)
  535. </select>
  536. <select id="countNotStartCourseStudentNumWithGroup" resultType="int">
  537. SELECT
  538. COUNT( cssp.user_id_ )
  539. FROM
  540. course_schedule_student_payment cssp
  541. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  542. WHERE
  543. cssp.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  544. AND cssp.music_group_id_ = #{groupId} AND cs.pre_course_flag_ = 0
  545. AND CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) > NOW( )
  546. </select>
  547. <select id="findByBatchNo" resultMap="CourseScheduleStudentPayment">
  548. SELECT * FROM course_schedule_student_payment WHERE batch_no_=#{batchNo}
  549. </select>
  550. <select id="getClassGroupNoStartCourse" resultMap="CourseScheduleStudentPayment">
  551. SELECT cssp.* FROM course_schedule_student_payment cssp
  552. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  553. WHERE cssp.class_group_id_ IN
  554. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  555. #{classGroupId}
  556. </foreach>
  557. AND cs.status_ = 'NOT_START' AND cs.pre_course_flag_ = 0 ORDER BY cssp.id_ ASC
  558. </select>
  559. <select id="findStudentLastCourseSchedule" resultType="java.util.Map">
  560. SELECT
  561. cssp.user_id_ AS 'key',
  562. MAX(CONCAT( cs.class_date_, ' ', cs.start_class_time_ )) AS 'value'
  563. FROM
  564. course_schedule_student_payment cssp
  565. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  566. WHERE
  567. cssp.user_id_ IN
  568. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  569. #{studentId}
  570. </foreach>
  571. AND CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) &lt; NOW( ) AND cs.pre_course_flag_ = 0
  572. GROUP BY user_id_;
  573. </select>
  574. <sql id="queryAllCondition">
  575. <where>
  576. <if test="courseScheduleId != null">
  577. course_schedule_id_ = #{courseScheduleId}
  578. </if>
  579. </where>
  580. </sql>
  581. <select id="queryAll" resultMap="CourseScheduleStudentPayment">
  582. SELECT * FROM course_schedule_student_payment
  583. <include refid="queryAllCondition" />
  584. ORDER BY id_
  585. <include refid="global.limit"/>
  586. </select>
  587. <select id="countAll" resultType="int">
  588. SELECT COUNT(*) FROM course_schedule_student_payment
  589. <include refid="queryAllCondition" />
  590. </select>
  591. <select id="countStudentDouble11CourseTime" resultMap="com.ym.mec.biz.dal.dao.StudentPaymentOrderDao.StudentVipDouble11Dto">
  592. SELECT
  593. cssp.user_id_ userId,
  594. SUM(CASE vgc.student_num_ WHEN 1 THEN 1 ELSE 0 END) course_one_to_one_time_,
  595. SUM(CASE vgc.student_num_ WHEN 2 THEN 1 ELSE 0 END) course_one_to_two_time_
  596. FROM
  597. course_schedule_student_payment cssp
  598. LEFT JOIN vip_group vg ON cssp.music_group_id_ = vg.id_
  599. LEFT JOIN vip_group_category vgc ON vg.vip_group_category_id_ = vgc.id_
  600. WHERE
  601. cssp.group_type_ = 'VIP'
  602. AND cssp.create_time_ > '2020-11-11 00:00:00'
  603. AND cssp.user_id_ IN
  604. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  605. #{userId}
  606. </foreach>
  607. AND vg.vip_group_activity_id_ IN
  608. <foreach collection="specialActivityIds" item="specialActivityId" open="(" close=")" separator=",">
  609. #{specialActivityId}
  610. </foreach>
  611. GROUP BY
  612. cssp.user_id_
  613. </select>
  614. <select id="findNeedUpdateActualPriceStudentCourses" resultMap="CourseScheduleStudentPaymentDto">
  615. SELECT
  616. cssp.*,
  617. CASE WHEN cs.new_course_id_ IS NULL THEN CONCAT( cs.class_date_, ' ', cs.start_class_time_ ) ELSE CONCAT( cs1.class_date_, ' ', cs1.start_class_time_ ) END course_start_time_,
  618. CASE WHEN cs.new_course_id_ IS NULL THEN cs.status_ ELSE cs1.status_ END course_status_
  619. FROM
  620. course_schedule_student_payment cssp
  621. LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
  622. LEFT JOIN course_schedule cs1 ON cs.new_course_id_=cs1.id_
  623. WHERE
  624. cssp.batch_no_ IS NOT NULL
  625. AND cs.id_ IS NOT NULL AND cs.pre_course_flag_ = 0
  626. AND (((cs.status_ IN ('OVER', 'UNDERWAY') OR cs1.status_ IN ( 'OVER', 'UNDERWAY' ))
  627. AND (cssp.actual_price_ IS NULL OR cssp.actual_price_ &lt; cssp.expect_price_))
  628. OR ( cs.status_ = 'NOT_START' AND cssp.actual_price_ IS NOT NULL AND cssp.actual_price_ &gt; 0))
  629. <if test="groupIds!=null and groupIds.size()>0">
  630. AND cs.group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  631. AND cs.music_group_id_ IN
  632. <foreach collection="groupIds" item="groupId" open="(" close=")" separator=",">
  633. #{groupId}
  634. </foreach>
  635. </if>
  636. <if test="userIds!=null and userIds.size()>0">
  637. AND cssp.user_id_ IN
  638. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  639. #{userId}
  640. </foreach>
  641. </if>
  642. </select>
  643. <select id="queryCourseByIdsAndStudentId" resultMap="CourseScheduleStudentPayment">
  644. SELECT cssp.* FROM course_schedule_student_payment cssp
  645. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  646. WHERE cssp.course_schedule_id_ IN
  647. <foreach collection="courseIds" open="(" item="item" close=")" separator=",">
  648. #{item}
  649. </foreach>
  650. AND cssp.user_id_ = #{studentId} AND cs.type_ = #{courseType}
  651. </select>
  652. <select id="queryStudentNotStartByClassIdsAndStudentIds" resultType="java.lang.Long">
  653. SELECT cssp.id_ FROM course_schedule_student_payment cssp
  654. LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
  655. WHERE cssp.class_group_id_ IN
  656. <foreach collection="classGroupIds" open="(" close=")" separator="," item="item">
  657. #{item}
  658. </foreach>
  659. <if test="studentIds != null">
  660. AND cssp.user_id_ IN
  661. <foreach collection="studentIds" open="(" close=")" separator="," item="item">
  662. #{item}
  663. </foreach>
  664. </if>
  665. AND CONCAT(cs.class_date_," ",cs.start_class_time_) > NOW() AND cs.pre_course_flag_ = 0
  666. GROUP BY cssp.id_
  667. </select>
  668. <select id="queryByIdsAndStudentId" resultMap="CourseScheduleStudentPayment">
  669. SELECT cssp.* FROM course_schedule_student_payment cssp
  670. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
  671. WHERE cssp.id_ IN
  672. <foreach collection="studentPaymentIds" open="(" item="item" close=")" separator=",">
  673. #{item}
  674. </foreach>
  675. AND cssp.user_id_ = #{studentId} AND cs.type_ = #{courseType}
  676. </select>
  677. <select id="countFinishCoursePriceWithMusicGroup" resultType="java.math.BigDecimal">
  678. SELECT SUM(expect_price_)-SUM(actual_price_) FROM course_schedule_student_payment
  679. WHERE music_group_id_=#{groupId} AND user_id_=#{userId} AND group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  680. </select>
  681. <select id="getStudentHistoryLastCourse" resultMap="com.ym.mec.biz.dal.dao.CourseScheduleDao.CourseSchedule">
  682. SELECT cs.* FROM course_schedule_student_payment cssp
  683. LEFT JOIN course_schedule cs ON cs.id_=cssp.course_schedule_id_
  684. WHERE cssp.user_id_=#{studentId}
  685. <if test="groupId!=null">
  686. AND cs.music_group_id_=#{groupId}
  687. </if>
  688. AND cs.class_date_&lt;#{monday}
  689. AND cs.type_=#{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  690. AND (cs.del_flag_ != 1 OR cs.del_flag_ IS NULL) AND cs.pre_course_flag_ = 0
  691. ORDER BY CONCAT(cs.class_date_, ' ', cs.start_class_time_) DESC LIMIT 1
  692. </select>
  693. <select id="findByMainMergedCourse" resultMap="CourseScheduleStudentPayment">
  694. SELECT cssp.*
  695. FROM course_schedule_student_payment cssp
  696. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
  697. WHERE cs.new_course_id_=#{mainMergeCourseId}
  698. </select>
  699. <select id="querySubCoursePriceMap" resultType="java.math.BigDecimal">
  700. SELECT SUM(cssp.expect_price_) FROM course_schedule_student_payment cssp
  701. LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
  702. WHERE cssp.class_group_id_ = #{classGroupId} AND cssp.user_id_ = #{studentId} AND CONCAT(cs.class_date_,' ',cs.start_class_time_) > NOW()
  703. AND cs.pre_course_flag_ = 0
  704. <if test="courseType != null">
  705. AND cs.type_ = #{courseType}
  706. </if>
  707. </select>
  708. <select id="getCourseScheduleStudentNum" resultMap="com.ym.mec.biz.dal.dao.CourseScheduleDao.CourseSchedule">
  709. SELECT course_schedule_id_ id_,COUNT(*) student_num_ FROM course_schedule_student_payment WHERE course_schedule_id_ IN
  710. <foreach collection="courseIds" item="courseId" open="(" close=")" separator=",">
  711. #{courseId}
  712. </foreach>
  713. GROUP BY course_schedule_id_
  714. </select>
  715. <select id="getWithClassGroupIds" resultMap="CourseScheduleStudentPayment">
  716. SELECT * FROM course_schedule_student_payment WHERE class_group_id_ IN
  717. <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
  718. #{classGroupId}
  719. </foreach>
  720. <if test="studentId!=null">
  721. AND user_id_ = #{studentId}
  722. </if>
  723. </select>
  724. <select id="getWithGroup" resultMap="CourseScheduleStudentPayment">
  725. SELECT * FROM course_schedule_student_payment
  726. WHERE music_group_id_ = #{groupId} AND group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  727. <if test="studentIds!=null and studentIds.size()>0">
  728. AND user_id_ IN
  729. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  730. #{studentId}
  731. </foreach>
  732. </if>
  733. </select>
  734. <select id="getStudentEduTeacher" resultType="string">
  735. SELECT edut.real_name_ FROM course_schedule_student_payment cssp
  736. LEFT JOIN vip_group vg ON vg.id_ = cssp.music_group_id_ AND cssp.group_type_='VIP'
  737. LEFT JOIN sys_user edut ON edut.id_ = vg.educational_teacher_id_
  738. WHERE cssp.user_id_ = #{studentId}
  739. AND vg.group_status_ IN (0,1,2)
  740. ORDER BY vg.create_time_ DESC LIMIT 1
  741. </select>
  742. <select id="getHasVipCourseStudentIds" resultType="int">
  743. SELECT cssp.user_id_ FROM course_schedule_student_payment cssp
  744. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
  745. WHERE cssp.group_type_='VIP' AND cs.del_flag_=0
  746. <if test="studentIds!=null and studentIds.size()>0">
  747. AND cssp.user_id_ IN
  748. <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
  749. #{studentId}
  750. </foreach>
  751. </if>
  752. </select>
  753. <select id="getHasVPCourseStudentNum" resultType="int">
  754. SELECT
  755. COUNT( DISTINCT cssp.user_id_ )
  756. FROM
  757. course_schedule_student_payment cssp
  758. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
  759. LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
  760. WHERE
  761. cssp.group_type_ IN ('VIP', 'PRACTICE')
  762. AND cs.status_='NOT_START'
  763. AND su.del_flag_ = 0
  764. AND su.organ_id_ = #{organId}
  765. </select>
  766. <select id="getOrganHasVPCourseStudentNum" resultType="map">
  767. SELECT
  768. su.organ_id_ 'key',
  769. COUNT( DISTINCT cssp.user_id_ ) 'value'
  770. FROM
  771. course_schedule_student_payment cssp
  772. LEFT JOIN course_schedule cs ON cssp.course_schedule_id_=cs.id_
  773. LEFT JOIN sys_user su ON cssp.user_id_ = su.id_
  774. WHERE
  775. cssp.group_type_ IN ('VIP', 'PRACTICE')
  776. AND cs.status_='NOT_START'
  777. AND su.del_flag_ = 0
  778. <if test="studentIds!=null and studentIds.size()>0">
  779. AND su.organ_id_ IN
  780. <foreach collection="organIds" item="organId" open="(" close=")" separator=",">
  781. #{organId}
  782. </foreach>
  783. </if>
  784. GROUP BY
  785. su.organ_id_
  786. </select>
  787. <select id="getCourseStudents" resultType="com.ym.mec.biz.dal.dto.BasicUserDto">
  788. SELECT cssp.user_id_ userId,st.member_rank_setting_id_ memberRankSettingId,s.name_ subjectName,su.avatar_ headUrl,su.username_ name,st.subject_id_list_ subjectIdList
  789. FROM course_schedule_student_payment cssp
  790. LEFT JOIN sys_user su ON su.id_ = cssp.user_id_
  791. LEFT JOIN student st ON st.user_id_ = cssp.user_id_
  792. LEFT JOIN `subject` s ON s.id_ = st.subject_id_list_
  793. WHERE cssp.course_schedule_id_ = #{courseScheduleId}
  794. </select>
  795. <select id="hasCourse" resultType="java.lang.Boolean">
  796. SELECT CASE WHEN s.user_id_ = NULL THEN 0 ELSE 1 END hasCourse FROM student s
  797. LEFT JOIN sys_user su ON s.user_id_ = su.id_
  798. LEFT JOIN course_schedule_student_payment cssp FORCE INDEX(group_type_) ON cssp.user_id_ = s.user_id_
  799. WHERE cssp.group_type_ IN ('VIP','PRACTICE')
  800. <if test="organId != null">
  801. AND su.organ_id_ = #{organId}
  802. </if>
  803. LIMIT 1
  804. </select>
  805. <resultMap id="StudentVipPracticeExportDto" type="com.ym.mec.biz.dal.dto.StudentVipPracticeExportDto">
  806. <result property="userId" column="user_id_"/>
  807. <result property="username" column="username_"/>
  808. <result property="vipOverNum" column="vip_over_num_"/>
  809. <result property="vipNotStartNum" column="vip_not_start_num_"/>
  810. <result property="vipOverTeacherIds" column="vip_over_teacher_ids_"/>
  811. <result property="vipOverTeacherNames" column="vip_over_teacher_names_"/>
  812. <result property="vipNotStartTeacherIds" column="vip_not_start_teacher_ids_"/>
  813. <result property="vipNotStartTeacherNames" column="vip_not_start_teacher_names_"/>
  814. <result property="practiceOverNum" column="practice_over_num_"/>
  815. <result property="practiceNotStartNum" column="practice_not_start_num_"/>
  816. <result property="practiceOverTeacherIds" column="practice_over_teacher_ids_"/>
  817. <result property="practiceOverTeacherNames" column="practice_over_teacher_names_"/>
  818. <result property="practiceNotStartTeacherIds" column="practice_not_start_teacher_ids_"/>
  819. <result property="practiceNotStartTeacherNames" column="practice_not_start_teacher_names_"/>
  820. <result property="teacherId" column="teacher_id_"/>
  821. <result property="teacherName" column="real_name_"/>
  822. </resultMap>
  823. <select id="exportStudentVipPractice" resultMap="StudentVipPracticeExportDto">
  824. SELECT s.user_id_,su.username_,
  825. COUNT(CASE WHEN cssp.group_type_ = 'VIP' AND cs.status_ != 'NOT_START' THEN 1 ELSE NULL END) vip_over_num_,
  826. COUNT(CASE WHEN cssp.group_type_ = 'VIP' AND cs.status_ = 'NOT_START' THEN 1 ELSE NULL END) vip_not_start_num_,
  827. GROUP_CONCAT(DISTINCT (CASE WHEN cssp.group_type_ = 'VIP' AND cs.status_ != 'NOT_START' THEN sut.id_ ELSE NULL END) ORDER BY cs.class_date_ DESC,start_class_time_ DESC) vip_over_teacher_ids_,
  828. GROUP_CONCAT(DISTINCT (CASE WHEN cssp.group_type_ = 'VIP' AND cs.status_ != 'NOT_START' THEN sut.real_name_ ELSE NULL END) ORDER BY cs.class_date_ DESC,start_class_time_ DESC) vip_over_teacher_names_,
  829. COUNT(CASE WHEN cssp.group_type_ = 'PRACTICE' AND cs.status_ != 'NOT_START' THEN 1 ELSE NULL END) practice_over_num_,
  830. COUNT(CASE WHEN cssp.group_type_ = 'PRACTICE' AND cs.status_ = 'NOT_START' THEN 1 ELSE NULL END) practice_not_start_num_,
  831. GROUP_CONCAT(DISTINCT (CASE WHEN cssp.group_type_ = 'PRACTICE' AND cs.status_ != 'NOT_START' THEN sut.id_ ELSE NULL END) ORDER BY cs.class_date_ DESC,start_class_time_ DESC) practice_over_teacher_ids_,
  832. GROUP_CONCAT(DISTINCT (CASE WHEN cssp.group_type_ = 'PRACTICE' AND cs.status_ != 'NOT_START' THEN sut.real_name_ ELSE NULL END) ORDER BY cs.class_date_ DESC,start_class_time_ DESC) practice_over_teacher_names_,
  833. s.teacher_id_,ste.real_name_
  834. FROM student s
  835. LEFT JOIN course_schedule_student_payment cssp FORCE INDEX(group_type_) ON cssp.user_id_ = s.user_id_
  836. LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
  837. LEFT JOIN sys_user su ON s.user_id_ = su.id_
  838. LEFT JOIN sys_user ste ON s.teacher_id_ = ste.id_
  839. LEFT JOIN sys_user sut ON cs.actual_teacher_id_ = sut.id_
  840. WHERE cssp.group_type_ IN ('VIP','PRACTICE')
  841. <if test="organId != null">
  842. AND su.organ_id_ = #{organId}
  843. </if>
  844. GROUP BY s.user_id_
  845. </select>
  846. </mapper>