MusicSheetMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.yonge.cooleshow.biz.dal.dao.MusicSheetDao">
  5. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.MusicSheet">
  6. <id column="id_" jdbcType="BIGINT" property="id"/>
  7. <result column="music_sheet_name_" jdbcType="VARCHAR" property="musicSheetName"/>
  8. <result column="user_id_" jdbcType="BIGINT" property="userId"/>
  9. <result column="composer_" jdbcType="VARCHAR" property="composer"/>
  10. <result column="music_subject_" jdbcType="VARCHAR" property="musicSubject"/>
  11. <result column="audio_type_" jdbcType="VARCHAR" property="audioType"/>
  12. <result column="music_tag_" jdbcType="VARCHAR" property="musicTag"/>
  13. <result column="play_speed_" jdbcType="INTEGER" property="playSpeed"/>
  14. <result column="can_evaluate_" jdbcType="TINYINT" property="canEvaluate"/>
  15. <result column="show_fingering_" jdbcType="TINYINT" property="showFingering"/>
  16. <result column="charge_type_" jdbcType="TINYINT" property="chargeType"/>
  17. <result column="audit_status_" jdbcType="TINYINT" property="auditStatus"/>
  18. <result column="sort_number_" jdbcType="INTEGER" property="sortNumber"/>
  19. <result column="top_flag_" jdbcType="TINYINT" property="topFlag"/>
  20. <result column="hot_flag_" jdbcType="TINYINT" property="hotFlag"/>
  21. <result column="music_price_" jdbcType="DECIMAL" property="musicPrice"/>
  22. <result column="audio_file_url_" jdbcType="VARCHAR" property="audioFileUrl"/>
  23. <result column="xml_file_url_" jdbcType="VARCHAR" property="xmlFileUrl"/>
  24. <result column="has_beat_" jdbcType="TINYINT" property="hasBeat"/>
  25. <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
  26. <result column="create_by_" jdbcType="BIGINT" property="createBy"/>
  27. <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
  28. <result column="update_by_" jdbcType="BIGINT" property="updateBy"/>
  29. <result column="remark_" jdbcType="VARCHAR" property="remark"/>
  30. </resultMap>
  31. <sql id="Base_Column_List">
  32. t.id_ as id ,
  33. t.music_sheet_name_ as musicSheetName,
  34. t.user_id_ as userId,
  35. t.composer_ as composer,
  36. t.music_subject_ as musicSubject,
  37. t.audio_type_ as audioType,
  38. t.music_tag_ as musicTag,
  39. t.play_speed_ as playSpeed,
  40. t.can_evaluate_ as canEvaluate,
  41. t.show_fingering_ as showFingering,
  42. t.charge_type_ as chargeType,
  43. t.state_ as state,
  44. t.audit_status_ as auditStatus,
  45. t.sort_number_ as sortNumber,
  46. t.top_flag_ as topFlag,
  47. t.hot_flag_ as hotFlag,
  48. t.music_price_ as musicPrice,
  49. t.audio_file_url_ as audioFileUrl,
  50. t.xml_file_url_ as xmlFileUrl,
  51. t.has_beat_ as hasBeat,
  52. t.mp3_type_ as mp3Type,
  53. t.create_time_ as createTime,
  54. t.create_by_ as createBy,
  55. t.update_time_ as updateTime,
  56. t.update_by_ as updateBy,
  57. t.del_flag_ as delFlag,
  58. t.audit_version_ as auditVersion,
  59. t.source_type_ as sourceType,
  60. t.submit_audit_time_ as submitAuditTime,
  61. t.remark_ as remark
  62. </sql>
  63. <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  64. select <include refid="Base_Column_List"/>
  65. ,su.username_ as addName
  66. ,su.avatar_ as addUserAvatar
  67. ,(select group_concat(mt.name_) from music_tag mt
  68. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  69. ,(select group_concat(s.name_) from subject s
  70. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  71. from music_sheet t
  72. left join sys_user su on t.create_by_ = su.id_
  73. <where>
  74. <include refid="QueryInfo"/>
  75. </where>
  76. order by t.id_ desc
  77. </select>
  78. <sql id="QueryInfo">
  79. <if test="param.idAndName != null and param.idAndName != ''">
  80. and (t.id_ like concat('%',#{param.idAndName},'%') or
  81. t.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  82. </if>
  83. <if test="param.musicTagIds != null and param.musicTagIds != ''">
  84. and
  85. <foreach collection="param.musicTagIdList" separator="or" item="item">
  86. find_in_set(#{item},t.music_tag_)
  87. </foreach>
  88. </if>
  89. <if test="param.subjectIds != null and param.subjectIds != ''">
  90. and
  91. <foreach collection="param.subjectIdList" separator="or" item="item">
  92. find_in_set(#{item},t.music_subject_)
  93. </foreach>
  94. </if>
  95. <if test="param.state != null">
  96. and t.state_ = #{param.state}
  97. </if>
  98. <if test="param.auditStatus != null">
  99. and t.audit_status_ = #{param.auditStatus}
  100. </if>
  101. <if test="param.createBy != null">
  102. and t.create_by_ = #{param.createBy}
  103. </if>
  104. <if test="param.delFlag != null">
  105. and t.del_flag_ = #{param.delFlag}
  106. </if>
  107. <if test="param.sourceType != null">
  108. and t.source_type_ = #{param.sourceType}
  109. </if>
  110. <if test="param.chargeType != null">
  111. and t.charge_type_ = #{param.chargeType}
  112. </if>
  113. </sql>
  114. <select id="selectAlbumDetailPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  115. select distinct <include refid="Base_Column_List"/>
  116. ,(select group_concat(mt.name_) from music_tag mt
  117. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  118. ,(select group_concat(s.name_) from subject s
  119. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  120. from music_sheet t
  121. left join album_music_relate amr on t.id_ = amr.music_sheet_id_
  122. <where>
  123. <if test="param.idAndName != null and param.idAndName != ''">
  124. and (t.id_ like concat('%',#{param.idAndName},'%') or
  125. t.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  126. </if>
  127. <if test="param.musicTagIds != null and param.musicTagIds != ''">
  128. and
  129. <foreach collection="param.musicTagIdList" separator="and" item="item">
  130. find_in_set(#{item},t.music_tag_)
  131. </foreach>
  132. </if>
  133. <if test="param.subjectIds != null and param.subjectIds != ''">
  134. and
  135. <foreach collection="param.subjectIdList" separator="and" item="item">
  136. find_in_set(#{item},t.music_subject_)
  137. </foreach>
  138. </if>
  139. <if test="param.state != null">
  140. and t.state_ = #{param.state}
  141. </if>
  142. <if test="param.delFlag != null">
  143. and t.del_flag_ = #{param.delFlag}
  144. </if>
  145. <if test="param.id != null">
  146. <if test="param.type == 2">
  147. and amr.album_id_ = #{param.id}
  148. order by amr.create_time_ desc
  149. </if>
  150. <if test="param.type == 1">
  151. and t.id_ not in(select amr2.music_sheet_id_ from album_music_relate amr2
  152. where amr2.album_id_ = #{param.id})
  153. order by t.id_ desc
  154. </if>
  155. </if>
  156. </where>
  157. </select>
  158. <select id="detail" resultMap="DetailResultMap">
  159. SELECT
  160. <include refid="Base_Column_List"/>
  161. ,t.url_ as url
  162. ,t.midi_url_ as midiUrl
  163. ,t.metronome_url_ as metronomeUrl
  164. ,msa.id_ as accompanimentId
  165. ,msa.music_sheet_id_ as accompanimentMusicSheetId
  166. ,msa.music_subject_ as accompanimentMusicSubject
  167. ,msa.audio_file_url_ as accompanimentAudioFileUrl
  168. ,msa.sort_number_ as accompanimentSortNumber
  169. ,msa.create_time_ as accompanimentCreateTime
  170. ,msa.metronome_url_ as accompanimentMetronomeUrl
  171. ,msa.track_ as track
  172. ,su.username_ as userName
  173. ,su.avatar_ as userAvatar
  174. ,(select group_concat(mt.name_) from music_tag mt
  175. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  176. ,s2.name_ as subjectNames
  177. ,s2.code_ as code
  178. FROM music_sheet t
  179. left join music_sheet_accompaniment msa on msa.music_sheet_id_ = t.id_
  180. left join sys_user su on t.create_by_ = su.id_
  181. left join subject s2 on t.music_subject_ = s2.id_
  182. where t.id_ = #{id}
  183. order by msa.sort_number_
  184. </select>
  185. <resultMap id="DetailResultMap" type="com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo">
  186. <id column="id" jdbcType="BIGINT" property="id"/>
  187. <result column="musicSheetName" jdbcType="VARCHAR" property="musicSheetName"/>
  188. <result column="userId" jdbcType="BIGINT" property="userId"/>
  189. <result column="composer" jdbcType="VARCHAR" property="composer"/>
  190. <result column="musicSubject" jdbcType="VARCHAR" property="musicSubject"/>
  191. <result column="audioType" jdbcType="VARCHAR" property="audioType"/>
  192. <result column="musicTag" jdbcType="VARCHAR" property="musicTag"/>
  193. <result column="playSpeed" jdbcType="INTEGER" property="playSpeed"/>
  194. <result column="canEvaluate" jdbcType="TINYINT" property="canEvaluate"/>
  195. <result column="showFingering" jdbcType="TINYINT" property="showFingering"/>
  196. <result column="chargeType" jdbcType="TINYINT" property="chargeType"/>
  197. <result column="auditStatus" jdbcType="TINYINT" property="auditStatus"/>
  198. <result column="state" jdbcType="TINYINT" property="state"/>
  199. <result column="sortNumber" jdbcType="INTEGER" property="sortNumber"/>
  200. <result column="topFlag" jdbcType="TINYINT" property="topFlag"/>
  201. <result column="hotFlag" jdbcType="TINYINT" property="hotFlag"/>
  202. <result column="musicPrice" jdbcType="DECIMAL" property="musicPrice"/>
  203. <result column="audioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  204. <result column="musicTagNames" jdbcType="VARCHAR" property="musicTagNames"/>
  205. <result column="subjectNames" jdbcType="VARCHAR" property="subjectNames"/>
  206. <result column="xmlFileUrl" jdbcType="VARCHAR" property="xmlFileUrl"/>
  207. <result column="hasBeat" jdbcType="TINYINT" property="hasBeat"/>
  208. <result column="createTime" jdbcType="TIMESTAMP" property="createTime"/>
  209. <result column="createBy" jdbcType="BIGINT" property="createBy"/>
  210. <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime"/>
  211. <result column="updateBy" jdbcType="BIGINT" property="updateBy"/>
  212. <result column="delFlag" jdbcType="BOOLEAN" property="delFlag"/>
  213. <result column="url" jdbcType="BOOLEAN" property="url"/>
  214. <result column="metronomeUrl" jdbcType="BOOLEAN" property="metronomeUrl"/>
  215. <result column="midiUrl" jdbcType="BOOLEAN" property="midiUrl"/>
  216. <result column="mp3Type" jdbcType="VARCHAR" property="mp3Type"/>
  217. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  218. <result column="userName" jdbcType="VARCHAR" property="userName"/>
  219. <result column="auditVersion" jdbcType="VARCHAR" property="auditVersion"/>
  220. <result column="code" jdbcType="VARCHAR" property="code"/>
  221. <collection property="background" ofType="com.yonge.cooleshow.biz.dal.entity.MusicSheetAccompaniment">
  222. <id column="accompanimentId" jdbcType="BIGINT" property="id"/>
  223. <result column="accompanimentMusicSheetId" jdbcType="BIGINT" property="musicSheetId"/>
  224. <result column="accompanimentMusicSubject" jdbcType="VARCHAR" property="musicSubject"/>
  225. <result column="accompanimentAudioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  226. <result column="accompanimentSortNumber" jdbcType="TINYINT" property="sortNumber"/>
  227. <result column="accompanimentCreateTime" jdbcType="TIMESTAMP" property="createTime"/>
  228. <result column="accompanimentMetronomeUrl" jdbcType="VARCHAR" property="metronomeUrl"/>
  229. <result column="track" jdbcType="VARCHAR" property="track"/>
  230. </collection>
  231. </resultMap>
  232. <select id="selectStudentMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  233. select <include refid="Base_Column_List"/>
  234. ,su.username_ as addName
  235. ,su.avatar_ as addUserAvatar
  236. ,(select group_concat(mt.name_) from music_tag mt
  237. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  238. ,(select group_concat(s.name_) from subject s
  239. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0) as subjectNames
  240. <if test="param.studentId != null">
  241. ,if(mf.id_ is not null,1,0) as favorite
  242. ,case when mspr.id_ is not null then 1
  243. when t.charge_type_ = 'FREE' then 1
  244. else 0 end as play
  245. </if>
  246. from music_sheet t
  247. left join sys_user su on t.create_by_ = su.id_
  248. left join (select count(1) as num,mf.music_sheet_id_
  249. from music_favorite mf group by mf.music_sheet_id_) t2 on t2.music_sheet_id_ = t.id_
  250. <if test="param.studentId != null">
  251. left join music_sheet_purchase_record mspr
  252. on mspr.music_sheet_id_ = t.id_
  253. and mspr.student_id_ = #{param.studentId}
  254. and order_status_ = 'PAID'
  255. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mf.user_id_ = #{param.studentId}
  256. </if>
  257. <where>
  258. <include refid="QueryInfo"/>
  259. <if test="param.auditVersion != null ">
  260. and #{param.auditVersion} = t.audit_version_
  261. </if>
  262. </where>
  263. order by t2.num desc, t.id_ desc
  264. </select>
  265. <select id="selectMyMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  266. select <include refid="Base_Column_List"/>
  267. ,su.username_ as addName
  268. ,su.avatar_ as addUserAvatar
  269. ,(select group_concat(mt.name_) from music_tag mt
  270. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  271. ,(select group_concat(s.name_) from subject s
  272. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  273. from music_sheet t
  274. left join sys_user su on t.create_by_ = su.id_
  275. left join music_sheet_purchase_record mspr on mspr.music_sheet_id_ = t.id_
  276. <where>
  277. <include refid="QueryInfo"/>
  278. <if test="param.studentId != null">
  279. and mspr.student_id_ = #{param.studentId}
  280. and mspr.order_status_ = 'PAID'
  281. </if>
  282. </where>
  283. order by mspr.id_ desc
  284. </select>
  285. <select id="selectFavoriteMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  286. select <include refid="Base_Column_List"/>
  287. ,su.username_ as addName
  288. ,su.avatar_ as addUserAvatar
  289. ,(select group_concat(mt.name_) from music_tag mt
  290. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  291. ,(select group_concat(s.name_) from subject s
  292. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  293. ,if(mf.id_ is not null,1,0) as favorite
  294. from music_sheet t
  295. left join sys_user su on t.create_by_ = su.id_
  296. left join music_favorite mf on t.id_ = mf.music_sheet_id_
  297. <where>
  298. <include refid="QueryInfo"/>
  299. <if test="param.studentId != null">
  300. and mf.user_id_ = #{param.studentId}
  301. </if>
  302. </where>
  303. order by mf.id_ desc
  304. </select>
  305. <select id="selectPracticeMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  306. select <include refid="Base_Column_List"/>
  307. ,su.username_ as addName
  308. ,su.avatar_ as addUserAvatar
  309. ,(select group_concat(mt.name_) from music_tag mt
  310. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  311. ,(select group_concat(s.name_) from subject s where find_in_set(s.id_,t.music_subject_) ) as subjectNames
  312. from music_sheet t
  313. left join sys_user su on t.create_by_ = su.id_
  314. <where>
  315. <include refid="QueryInfo"/>
  316. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  317. and t.id_ in
  318. <foreach collection="practiceMusicIdList" item="item" open="(" close=")" separator=",">
  319. #{item}
  320. </foreach>
  321. </if>
  322. </where>
  323. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  324. order by field(t.id_,
  325. <foreach collection="practiceMusicIdList" item="item" separator=",">
  326. #{item}
  327. </foreach>
  328. </if>
  329. )
  330. </select>
  331. <select id="selectStudentOrderPage" resultType="com.yonge.cooleshow.biz.dal.vo.StudentMusicSheetOrderVo">
  332. select mspr.music_sheet_id_ as musicSheetId
  333. ,ms.music_sheet_name_ as musicSheetName
  334. ,ms.composer_ as composer
  335. ,ms.music_tag_ as musicTag
  336. ,(select group_concat(mt.name_) from music_tag mt
  337. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  338. ,mspr.purchase_price_ as purchasePrice
  339. ,mspr.order_no_ as orderNo
  340. ,mspr.purchase_time_ as purchaseTime
  341. from music_sheet_purchase_record mspr
  342. left join music_sheet ms on mspr.music_sheet_id_ = ms.id_
  343. <where>
  344. mspr.order_status_ = 'PAID'
  345. <if test="param.idAndName != null and param.idAndName != ''">
  346. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  347. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  348. </if>
  349. <if test="param.studentId != null">
  350. and mspr.student_id_ = #{param.studentId}
  351. </if>
  352. <if test="param.orderNo != null and param.orderNo != ''">
  353. and mspr.order_no_ = #{param.orderNo}
  354. </if>
  355. <if test="param.musicTagList != null and param.musicTagList.size() != 0">
  356. and
  357. <foreach collection="param.musicTagList" separator="and" item="item">
  358. find_in_set(#{item},ms.music_tag_)
  359. </foreach>
  360. </if>
  361. <if test="param.startTime != null">
  362. and mspr.purchase_time_ &gt; #{param.startTime}
  363. </if>
  364. <if test="param.endTime != null">
  365. and mspr.purchase_time_ &lt; #{param.endTime}
  366. </if>
  367. <if test="param.delFlag != null">
  368. and ms.del_flag_ = #{param.delFlag}
  369. </if>
  370. </where>
  371. order by mspr.id_ desc
  372. </select>
  373. <select id="selectTeacherPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  374. select ms.id_ as musicSheetId
  375. ,ms.music_sheet_name_ as musicSheetName
  376. ,ms.composer_ as composer
  377. ,ms.music_tag_ as musicTag
  378. ,(select group_concat(mt.name_) from music_tag mt
  379. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  380. ,ms.play_speed_ as playSpeed
  381. ,ms.music_price_ as musicPrice
  382. ,ms.create_time_ as createTime
  383. ,ms.audit_status_ as auditStatus
  384. ,su.username_ as auditName
  385. from music_sheet ms
  386. left join music_sheet_auth_record msar on ms.id_ = msar.music_sheet_id_
  387. left join sys_user su on msar.verify_user_id_ = su.id_
  388. <where>
  389. <if test="param.idAndName != null and param.idAndName != ''">
  390. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  391. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%')
  392. or ms.composer_ like concat('%',#{param.idAndName},'%'))
  393. </if>
  394. <if test="param.teacherId != null">
  395. and ms.create_by_ = #{param.teacherId}
  396. </if>
  397. <if test="param.startTime != null">
  398. and ms.create_time_ &gt; #{param.startTime}
  399. </if>
  400. <if test="param.endTime != null">
  401. and ms.create_time_ &lt; #{param.endTime}
  402. </if>
  403. <if test="param.delFlag != null">
  404. and ms.del_flag_ = #{param.delFlag}
  405. </if>
  406. </where>
  407. order by ms.id_ desc
  408. </select>
  409. <select id="selectAuditPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  410. select
  411. ms.create_by_ as teacherId
  412. ,su.username_ as username
  413. ,su.real_name_ as realName
  414. ,su.phone_ as phone
  415. ,ms.id_ as musicSheetId
  416. ,ms.music_sheet_name_ as musicSheetName
  417. ,ms.composer_ as composer
  418. ,ms.music_tag_ as musicTag
  419. ,(select group_concat(mt.name_) from music_tag mt
  420. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  421. ,ms.play_speed_ as playSpeed
  422. ,ms.music_price_ as musicPrice
  423. ,ms.create_time_ as createTime
  424. ,msar.audit_state_ as auditStatus
  425. ,su2.username_ as auditName
  426. from music_sheet ms
  427. left join sys_user su on su.id_ = ms.create_by_
  428. left join music_sheet_auth_record msar on ms.id_ = msar.music_sheet_id_
  429. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  430. <where>
  431. ms.source_type_ = 'TEACHER'
  432. <if test="param.idAndName != null and param.idAndName != ''">
  433. and (su.id_ like concat('%',#{param.idAndName} ,'%')
  434. or su.username_ like concat('%',#{param.idAndName},'%')
  435. or su.phone_ like concat('%',#{param.idAndName},'%'))
  436. </if>
  437. <if test="param.auditName != null and param.auditName != ''">
  438. and su2.username_ like concat('%',#{param.auditName},'%')
  439. </if>
  440. <if test="param.authStatus != null">
  441. and msar.audit_state_ = #{param.authStatus}
  442. </if>
  443. <if test="param.startTime != null">
  444. and ms.create_time_ &gt; #{param.startTime}
  445. </if>
  446. <if test="param.endTime != null">
  447. and ms.create_time_ &lt; #{param.endTime}
  448. </if>
  449. <if test="param.delFlag != null">
  450. and ms.del_flag_ = #{param.delFlag}
  451. </if>
  452. <if test="param.chargeType != null">
  453. and ms.charge_type_ = #{param.chargeType}
  454. </if>
  455. </where>
  456. order by field(ms.audit_status_,'DOING') desc, ms.submit_audit_time_ desc
  457. </select>
  458. <select id="selectTeacherMusicSheetCount" resultType="java.lang.Integer">
  459. select count(1)
  460. from music_sheet
  461. where user_id_ = #{userId}
  462. and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0
  463. </select>
  464. <select id="selectMusicNum" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo">
  465. select
  466. sum(if(ms.source_type_ = 'PLATFORM',1,0)) as musicSheetPlatformCount,
  467. sum(if(ms.source_type_ = 'TEACHER',1,0)) as musicSheetTeacherCount,
  468. count(1) as musicSheetCount
  469. from music_sheet ms
  470. where ms.state_ = 1 and ms.del_flag_ = 0 and ms.audit_status_ = 'PASS' and ms.charge_type_ = 'CHARGE'
  471. </select>
  472. <select id="selectPayMusicSheet" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo$MusicSheetSmall">
  473. SELECT
  474. ms.id_ as musicSheetId,
  475. ms.music_sheet_name_ as musicSheetName,
  476. count(DISTINCT pr.student_id_) as num
  477. FROM
  478. music_sheet ms
  479. LEFT JOIN music_sheet_purchase_record pr ON ms.id_ = pr.music_sheet_id_
  480. WHERE
  481. ms.del_flag_=0
  482. AND ms.charge_type_='CHARGE'
  483. AND ms.state_=1
  484. AND pr.order_status_='PAID'
  485. GROUP BY ms.id_
  486. ORDER BY count(DISTINCT pr.student_id_) DESC,ms.id_ desc
  487. limit 5
  488. </select>
  489. </mapper>