MusicSheetMapper.xml 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  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. <result column="notation_" jdbcType="VARCHAR" property="notation"/>
  31. <result column="accompaniment_type_" jdbcType="VARCHAR" property="accompanimentType"/>
  32. <result column="title_img_" jdbcType="VARCHAR" property="titleImg"/>
  33. </resultMap>
  34. <sql id="Base_Column_List">
  35. t.id_ as id ,
  36. t.music_sheet_name_ as musicSheetName,
  37. t.user_id_ as userId,
  38. t.composer_ as composer,
  39. t.music_subject_ as musicSubject,
  40. t.audio_type_ as audioType,
  41. t.music_tag_ as musicTag,
  42. t.play_speed_ as playSpeed,
  43. t.can_evaluate_ as canEvaluate,
  44. t.show_fingering_ as showFingering,
  45. t.charge_type_ as chargeType,
  46. t.state_ as state,
  47. t.audit_status_ as auditStatus,
  48. t.sort_number_ as sortNumber,
  49. t.top_flag_ as topFlag,
  50. t.hot_flag_ as hotFlag,
  51. t.music_price_ as musicPrice,
  52. t.audio_file_url_ as audioFileUrl,
  53. t.xml_file_url_ as xmlFileUrl,
  54. t.has_beat_ as hasBeat,
  55. t.mp3_type_ as mp3Type,
  56. t.ext_config_json_ as extConfigJson,
  57. t.create_time_ as createTime,
  58. t.create_by_ as createBy,
  59. t.update_time_ as updateTime,
  60. t.update_by_ as updateBy,
  61. t.del_flag_ as delFlag,
  62. t.audit_version_ as auditVersion,
  63. t.source_type_ as sourceType,
  64. t.submit_audit_time_ as submitAuditTime,
  65. t.accompaniment_type_ as accompanimentType,
  66. t.remark_ as remark,
  67. t.title_img_ as titleImg,
  68. t.reason_ as reason,
  69. t.notation_ as notation
  70. </sql>
  71. <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  72. select <include refid="Base_Column_List"/>
  73. ,su.username_ as addName
  74. ,su.avatar_ as addUserAvatar
  75. ,(select group_concat(mt.name_) from music_tag mt
  76. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  77. ,(select group_concat(s.name_) from subject s
  78. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  79. from music_sheet t
  80. left join sys_user su on t.create_by_ = su.id_
  81. <where>
  82. su.del_flag_ = 0
  83. <include refid="QueryInfo"/>
  84. <if test="param.auditVersion != null ">
  85. and #{param.auditVersion} = t.audit_version_
  86. </if>
  87. </where>
  88. order by
  89. <if test="param.myself == null or param.myself == false ">
  90. t.top_flag_ desc,t.sort_number_ desc,
  91. </if>
  92. t.id_ desc
  93. </select>
  94. <sql id="QueryInfo">
  95. <if test="param.idAndName != null and param.idAndName != ''">
  96. and (t.id_ like concat('%',#{param.idAndName},'%') or
  97. t.music_sheet_name_ like concat('%',#{param.idAndName},'%') or
  98. t.composer_ like concat ('%',#{param.idAndName},'%') or
  99. su.username_ like concat ('%',#{param.idAndName},'%') )
  100. </if>
  101. <if test="param.musicTagIds != null and param.musicTagIds != ''">
  102. and
  103. <foreach collection="param.musicTagIdList" open="(" close=")" separator="or" item="item">
  104. find_in_set(#{item},t.music_tag_)
  105. </foreach>
  106. </if>
  107. <if test="param.subjectIds != null and param.subjectIds != ''">
  108. and
  109. <foreach collection="param.subjectIdList" separator="or" item="item" open="(" close=")" >
  110. find_in_set(#{item},t.music_subject_)
  111. </foreach>
  112. </if>
  113. <if test="param.state != null">
  114. and t.state_ = #{param.state}
  115. </if>
  116. <if test="param.auditStatus != null">
  117. and t.audit_status_ = #{param.auditStatus}
  118. </if>
  119. <if test="param.createBy != null">
  120. and t.create_by_ = #{param.createBy}
  121. </if>
  122. <if test="param.delFlag != null">
  123. and t.del_flag_ = #{param.delFlag}
  124. </if>
  125. <if test="param.sourceType != null">
  126. and t.source_type_ = #{param.sourceType}
  127. </if>
  128. <if test="param.chargeType != null">
  129. and t.charge_type_ = #{param.chargeType}
  130. </if>
  131. <if test="param.topFlag != null">
  132. and t.top_flag_ = #{param.topFlag}
  133. </if>
  134. <if test="param.accompanimentType != null">
  135. and t.accompaniment_type_ = #{param.accompanimentType}
  136. </if>
  137. </sql>
  138. <select id="selectAlbumDetailPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  139. select distinct <include refid="Base_Column_List"/>
  140. ,(select group_concat(mt.name_) from music_tag mt
  141. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  142. ,(select group_concat(s.name_) from subject s
  143. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  144. ,(select count(1) from music_favorite f
  145. where f.music_sheet_id_ = t.id_) as favoriteCount
  146. ,amr.sort_number_ as albumSortNumber
  147. from music_sheet t
  148. left join album_music_relate amr on t.id_ = amr.music_sheet_id_
  149. <where>
  150. <if test="param.idAndName != null and param.idAndName != ''">
  151. and (t.id_ like concat('%',#{param.idAndName},'%') or
  152. t.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  153. </if>
  154. <if test="param.chargeType != null">
  155. and t.charge_type_ = #{param.chargeType}
  156. </if>
  157. <if test="param.musicTagIds != null and param.musicTagIds != ''">
  158. and
  159. <foreach collection="param.musicTagIdList" separator="or" item="item" open="(" close=")" >
  160. find_in_set(#{item},t.music_tag_)
  161. </foreach>
  162. </if>
  163. <if test="param.subjectIds != null and param.subjectIds != ''">
  164. and
  165. <foreach collection="param.subjectIdList" separator="or" item="item" open="(" close=")" >
  166. find_in_set(#{item},t.music_subject_)
  167. </foreach>
  168. </if>
  169. <if test="param.state != null">
  170. and t.state_ = #{param.state}
  171. </if>
  172. <if test="param.delFlag != null">
  173. and t.del_flag_ = #{param.delFlag}
  174. </if>
  175. <if test="param.id != null">
  176. <if test="param.type == 2">
  177. and amr.album_id_ = #{param.id}
  178. order by amr.sort_number_ desc, t.id_ desc
  179. </if>
  180. <if test="param.type == 1">
  181. and t.id_ not in(select amr2.music_sheet_id_ from album_music_relate amr2
  182. where amr2.album_id_ = #{param.id})
  183. order by t.id_ desc
  184. </if>
  185. </if>
  186. </where>
  187. </select>
  188. <select id="detail" resultMap="DetailResultMap">
  189. SELECT
  190. <include refid="Base_Column_List"/>
  191. ,t.url_ as url
  192. ,t.midi_url_ as midiUrl
  193. ,t.metronome_url_ as metronomeUrl
  194. ,msa.id_ as accompanimentId
  195. ,msa.music_sheet_id_ as accompanimentMusicSheetId
  196. ,msa.music_subject_ as accompanimentMusicSubject
  197. ,msa.audio_file_url_ as accompanimentAudioFileUrl
  198. ,msa.sort_number_ as accompanimentSortNumber
  199. ,msa.create_time_ as accompanimentCreateTime
  200. ,msa.metronome_url_ as accompanimentMetronomeUrl
  201. ,msa.track_ as track
  202. ,su.username_ as userName
  203. ,su.avatar_ as userAvatar
  204. ,(
  205. select group_concat(mt.name_) from music_tag mt
  206. where find_in_set(mt.id_,t.music_tag_)
  207. and mt.del_flag_ = 0 and mt.state_ = 1
  208. ) as musicTagNames
  209. ,s2.name_ as subjectNames
  210. ,s2.code_ as code
  211. ,su.real_name_ as realName
  212. ,s2.ai_default_frequency_ as aiDefaultFrequency
  213. FROM music_sheet t
  214. left join music_sheet_accompaniment msa on msa.music_sheet_id_ = t.id_
  215. left join sys_user su on t.create_by_ = su.id_
  216. left join subject s2 on t.music_subject_ = s2.id_
  217. where t.id_ = #{id}
  218. order by msa.sort_number_
  219. </select>
  220. <resultMap id="DetailResultMap" type="com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo">
  221. <id column="id" jdbcType="BIGINT" property="id"/>
  222. <result column="musicSheetName" jdbcType="VARCHAR" property="musicSheetName"/>
  223. <result column="userId" jdbcType="BIGINT" property="userId"/>
  224. <result column="composer" jdbcType="VARCHAR" property="composer"/>
  225. <result column="titleImg" jdbcType="VARCHAR" property="titleImg"/>
  226. <result column="musicSubject" jdbcType="VARCHAR" property="musicSubject"/>
  227. <result column="audioType" jdbcType="VARCHAR" property="audioType"/>
  228. <result column="musicTag" jdbcType="VARCHAR" property="musicTag"/>
  229. <result column="playSpeed" jdbcType="INTEGER" property="playSpeed"/>
  230. <result column="canEvaluate" jdbcType="TINYINT" property="canEvaluate"/>
  231. <result column="showFingering" jdbcType="TINYINT" property="showFingering"/>
  232. <result column="chargeType" jdbcType="TINYINT" property="chargeType"/>
  233. <result column="auditStatus" property="auditStatus"/>
  234. <result column="state" jdbcType="TINYINT" property="state"/>
  235. <result column="sortNumber" jdbcType="INTEGER" property="sortNumber"/>
  236. <result column="topFlag" jdbcType="TINYINT" property="topFlag"/>
  237. <result column="hotFlag" jdbcType="TINYINT" property="hotFlag"/>
  238. <result column="musicPrice" jdbcType="DECIMAL" property="musicPrice"/>
  239. <result column="audioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  240. <result column="musicTagNames" jdbcType="VARCHAR" property="musicTagNames"/>
  241. <result column="subjectNames" jdbcType="VARCHAR" property="subjectNames"/>
  242. <result column="xmlFileUrl" jdbcType="VARCHAR" property="xmlFileUrl"/>
  243. <result column="hasBeat" jdbcType="TINYINT" property="hasBeat"/>
  244. <result column="createTime" jdbcType="TIMESTAMP" property="createTime"/>
  245. <result column="createBy" jdbcType="BIGINT" property="createBy"/>
  246. <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime"/>
  247. <result column="updateBy" jdbcType="BIGINT" property="updateBy"/>
  248. <result column="delFlag" jdbcType="BOOLEAN" property="delFlag"/>
  249. <result column="url" jdbcType="BOOLEAN" property="url"/>
  250. <result column="metronomeUrl" jdbcType="BOOLEAN" property="metronomeUrl"/>
  251. <result column="midiUrl" jdbcType="BOOLEAN" property="midiUrl"/>
  252. <result column="mp3Type" jdbcType="VARCHAR" property="mp3Type"/>
  253. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  254. <result column="userName" jdbcType="VARCHAR" property="userName"/>
  255. <result column="auditVersion" jdbcType="VARCHAR" property="auditVersion"/>
  256. <result column="code" jdbcType="VARCHAR" property="code"/>
  257. <result column="reason" jdbcType="VARCHAR" property="reason"/>
  258. <result column="accompanimentType" jdbcType="VARCHAR" property="accompanimentType"/>
  259. <result column="notation" jdbcType="VARCHAR" property="notation"/>
  260. <result column="realName" jdbcType="VARCHAR" property="realName"/>
  261. <result column="auditTime" jdbcType="VARCHAR" property="auditTime"/>
  262. <result column="auditName" jdbcType="VARCHAR" property="auditName"/>
  263. <result column="auditReason" jdbcType="VARCHAR" property="auditReason"/>
  264. <result column="aiDefaultFrequency" jdbcType="VARCHAR" property="aiDefaultFrequency"/>
  265. <collection property="background" ofType="com.yonge.cooleshow.biz.dal.entity.MusicSheetAccompaniment">
  266. <id column="accompanimentId" jdbcType="BIGINT" property="id"/>
  267. <result column="accompanimentMusicSheetId" jdbcType="BIGINT" property="musicSheetId"/>
  268. <result column="accompanimentMusicSubject" jdbcType="VARCHAR" property="musicSubject"/>
  269. <result column="accompanimentAudioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  270. <result column="accompanimentSortNumber" jdbcType="TINYINT" property="sortNumber"/>
  271. <result column="accompanimentCreateTime" jdbcType="TIMESTAMP" property="createTime"/>
  272. <result column="accompanimentMetronomeUrl" jdbcType="VARCHAR" property="metronomeUrl"/>
  273. <result column="track" jdbcType="VARCHAR" property="track"/>
  274. </collection>
  275. </resultMap>
  276. <select id="selectStudentMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  277. select <include refid="Base_Column_List"/>
  278. ,su.username_ as addName
  279. ,su.avatar_ as addUserAvatar
  280. ,(select group_concat(mt.name_) from music_tag mt
  281. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  282. ,(select count(1) as num from music_favorite af
  283. left join sys_user su on af.user_id_ = su.id_
  284. where su.del_flag_ = 0 and af.music_sheet_id_ = t.id_) as favoriteCount
  285. ,(select group_concat(s.name_) from subject s
  286. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0) as subjectNames
  287. <if test="param.studentId != null">
  288. ,if(mf.id_ is not null,1,0) as favorite
  289. ,case when mspr.id_ is not null then 1
  290. when t.charge_type_ = 'FREE' then 1
  291. else 0 end as play
  292. </if>
  293. from music_sheet t
  294. left join sys_user su on t.create_by_ = su.id_
  295. left join (select count(1) as num,mf.music_sheet_id_
  296. from music_favorite mf group by mf.music_sheet_id_) t2 on t2.music_sheet_id_ = t.id_
  297. <if test="param.studentId != null">
  298. left join music_sheet_purchase_record mspr
  299. on mspr.music_sheet_id_ = t.id_
  300. and mspr.student_id_ = #{param.studentId}
  301. and order_status_ = 'PAID'
  302. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mf.user_id_ = #{param.studentId}
  303. </if>
  304. <where>
  305. su.del_flag_ = 0
  306. <include refid="QueryInfo"/>
  307. <if test="param.auditVersion != null ">
  308. and #{param.auditVersion} = t.audit_version_
  309. </if>
  310. </where>
  311. order by
  312. <if test="param.myself == null or param.myself == false ">
  313. t.top_flag_ desc, t.sort_number_ desc, t2.num desc,
  314. </if>
  315. t.id_ desc
  316. </select>
  317. <select id="selectMyMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  318. select <include refid="Base_Column_List"/>
  319. ,su.username_ as addName
  320. ,su.avatar_ as addUserAvatar
  321. ,(select group_concat(mt.name_) from music_tag mt
  322. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  323. ,(select group_concat(s.name_) from subject s
  324. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  325. ,if(mf.id_ is not null,1,0) as favorite
  326. from music_sheet t
  327. left join sys_user su on t.create_by_ = su.id_
  328. left join music_sheet_purchase_record mspr on mspr.music_sheet_id_ = t.id_
  329. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mspr.student_id_ = mf.user_id_
  330. <where>
  331. <include refid="QueryInfo"/>
  332. <if test="param.studentId != null">
  333. and mspr.student_id_ = #{param.studentId}
  334. and mspr.order_status_ = 'PAID'
  335. </if>
  336. <if test="param.userType != null">
  337. and mspr.client_type_ = #{param.userType}
  338. </if>
  339. </where>
  340. order by mspr.id_ desc
  341. </select>
  342. <select id="selectFavoriteMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  343. select <include refid="Base_Column_List"/>
  344. ,su.username_ as addName
  345. ,su.avatar_ as addUserAvatar
  346. ,(select group_concat(mt.name_) from music_tag mt
  347. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  348. ,(select group_concat(s.name_) from subject s
  349. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  350. ,if(mf.id_ is not null,1,0) as favorite
  351. from music_sheet t
  352. left join sys_user su on t.create_by_ = su.id_
  353. left join music_favorite mf on t.id_ = mf.music_sheet_id_
  354. <where>
  355. su.del_flag_ = 0
  356. <include refid="QueryInfo"/>
  357. <if test="param.studentId != null">
  358. and mf.user_id_ = #{param.studentId}
  359. </if>
  360. </where>
  361. order by mf.id_ desc
  362. </select>
  363. <select id="selectPracticeMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  364. select <include refid="Base_Column_List"/>
  365. ,su.username_ as addName
  366. ,su.avatar_ as addUserAvatar
  367. ,(select group_concat(mt.name_) from music_tag mt
  368. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  369. ,(select group_concat(s.name_) from subject s where find_in_set(s.id_,t.music_subject_) ) as subjectNames
  370. ,if(mf.id_ is not null,1,0) as favorite
  371. from music_sheet t
  372. left join sys_user su on t.create_by_ = su.id_
  373. left join music_sheet_practice_record mspr on mspr.music_sheet_id_ = t.id_
  374. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mspr.user_id_ = mf.user_id_
  375. <where>
  376. su.del_flag_ = 0
  377. <include refid="QueryInfo"/>
  378. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  379. and mspr.id_ in
  380. <foreach collection="practiceMusicIdList" item="item" open="(" close=")" separator=",">
  381. #{item}
  382. </foreach>
  383. </if>
  384. </where>
  385. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  386. order by field(mspr.id_,
  387. <foreach collection="practiceMusicIdList" item="item" separator=",">
  388. #{item}
  389. </foreach>
  390. </if>
  391. )
  392. </select>
  393. <select id="selectStudentOrderPage" resultType="com.yonge.cooleshow.biz.dal.vo.StudentMusicSheetOrderVo">
  394. select mspr.music_sheet_id_ as musicSheetId
  395. ,ms.music_sheet_name_ as musicSheetName
  396. ,ms.composer_ as composer
  397. ,ms.title_img_ as titleImg
  398. ,ms.music_tag_ as musicTag
  399. ,(select group_concat(mt.name_) from music_tag mt
  400. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  401. ,mspr.purchase_price_ as purchasePrice
  402. ,mspr.order_no_ as orderNo
  403. ,mspr.purchase_time_ as purchaseTime
  404. from music_sheet_purchase_record mspr
  405. left join music_sheet ms on mspr.music_sheet_id_ = ms.id_
  406. <where>
  407. mspr.order_status_ = 'PAID'
  408. <if test="param.idAndName != null and param.idAndName != ''">
  409. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  410. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  411. </if>
  412. <if test="param.studentId != null">
  413. and mspr.student_id_ = #{param.studentId}
  414. </if>
  415. <if test="param.orderNo != null and param.orderNo != ''">
  416. and mspr.order_no_ = #{param.orderNo}
  417. </if>
  418. <if test="param.musicTagList != null and param.musicTagList.size() != 0">
  419. and
  420. <foreach collection="param.musicTagList" separator="or" item="item" open="(" close=")" >
  421. find_in_set(#{item},ms.music_tag_)
  422. </foreach>
  423. </if>
  424. <if test="param.startTime != null">
  425. and mspr.purchase_time_ &gt; #{param.startTime}
  426. </if>
  427. <if test="param.endTime != null">
  428. and mspr.purchase_time_ &lt; #{param.endTime}
  429. </if>
  430. <if test="param.delFlag != null">
  431. and ms.del_flag_ = #{param.delFlag}
  432. </if>
  433. </where>
  434. order by mspr.id_ desc
  435. </select>
  436. <select id="selectTeacherPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  437. select ms.id_ as musicSheetId
  438. ,ms.music_sheet_name_ as musicSheetName
  439. ,ms.composer_ as composer
  440. ,ms.title_img_ as titleImg
  441. ,ms.accompaniment_type_ as accompanimentType
  442. ,ms.music_tag_ as musicTag
  443. ,(select group_concat(mt.name_) from music_tag mt
  444. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  445. ,ms.play_speed_ as playSpeed
  446. ,ms.music_price_ as musicPrice
  447. ,ms.create_time_ as createTime
  448. ,ms.audit_status_ as auditStatus
  449. ,su.username_ as auditName
  450. from music_sheet ms
  451. left join music_sheet_auth_record msar on ms.id_ = msar.music_sheet_id_
  452. left join sys_user su on msar.verify_user_id_ = su.id_
  453. <where>
  454. <if test="param.idAndName != null and param.idAndName != ''">
  455. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  456. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%')
  457. or ms.composer_ like concat('%',#{param.idAndName},'%'))
  458. </if>
  459. <if test="param.teacherId != null">
  460. and ms.create_by_ = #{param.teacherId}
  461. </if>
  462. <if test="param.startTime != null">
  463. and ms.create_time_ &gt; #{param.startTime}
  464. </if>
  465. <if test="param.endTime != null">
  466. and ms.create_time_ &lt; #{param.endTime}
  467. </if>
  468. <if test="param.delFlag != null">
  469. and ms.del_flag_ = #{param.delFlag}
  470. </if>
  471. </where>
  472. order by ms.id_ desc
  473. </select>
  474. <select id="selectAuditPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  475. select
  476. msar.id_ as authMusicSheetId,
  477. ms.create_by_ as teacherId
  478. ,ms.title_img_ as titleImg
  479. ,ms.accompaniment_type_ as accompanimentType
  480. ,su.username_ as username
  481. ,su.real_name_ as realName
  482. ,su.phone_ as phone
  483. ,ms.id_ as musicSheetId
  484. ,ms.music_sheet_name_ as musicSheetName
  485. ,ms.composer_ as composer
  486. ,ms.music_tag_ as musicTag
  487. ,(select group_concat(mt.name_) from music_tag mt
  488. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  489. ,ms.play_speed_ as playSpeed
  490. ,ms.music_price_ as musicPrice
  491. ,ms.update_time_ as createTime
  492. ,if(msar.audit_state_ is null,ms.audit_status_,msar.audit_state_) as auditStatus
  493. ,su2.username_ as auditName
  494. ,msar.first_auth_ as authType
  495. from music_sheet_auth_record msar
  496. left join music_sheet ms on ms.id_ = msar.music_sheet_id_
  497. left join sys_user su on su.id_ = ms.create_by_
  498. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  499. <where>
  500. su.del_flag_ = 0 and
  501. ms.source_type_ = 'TEACHER'
  502. <if test="param.idAndName != null and param.idAndName != ''">
  503. and (su.id_ like concat('%',#{param.idAndName} ,'%')
  504. or su.username_ like concat('%',#{param.idAndName},'%')
  505. or su.phone_ like concat('%',#{param.idAndName},'%'))
  506. </if>
  507. <if test="param.auditName != null and param.auditName != ''">
  508. and su2.username_ like concat('%',#{param.auditName},'%')
  509. </if>
  510. <if test="param.authStatus != null">
  511. and msar.audit_state_ = #{param.authStatus}
  512. </if>
  513. <if test="param.startTime != null">
  514. and ms.create_time_ &gt; #{param.startTime}
  515. </if>
  516. <if test="param.endTime != null">
  517. and ms.create_time_ &lt; #{param.endTime}
  518. </if>
  519. <if test="param.chargeType != null">
  520. and ms.charge_type_ = #{param.chargeType}
  521. </if>
  522. <if test="param.firstAuth != null">
  523. and msar.first_auth_ = #{param.firstAuth}
  524. </if>
  525. </where>
  526. order by field(ms.audit_status_,'DOING') desc, ms.submit_audit_time_ desc
  527. </select>
  528. <select id="selectTeacherMusicSheetCount" resultType="java.lang.Integer">
  529. select count(1)
  530. from music_sheet
  531. where user_id_ = #{userId}
  532. and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0 and source_type_ = 'TEACHER'
  533. </select>
  534. <select id="selectMusicNum" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo">
  535. select
  536. sum(if(ms.source_type_ = 'PLATFORM',1,0)) as musicSheetPlatformCount,
  537. sum(if(ms.source_type_ = 'TEACHER',1,0)) as musicSheetTeacherCount,
  538. count(1) as musicSheetCount
  539. from music_sheet ms
  540. where ms.state_ = 1 and ms.del_flag_ = 0 and ms.audit_status_ = 'PASS' and ms.charge_type_ = 'CHARGE'
  541. </select>
  542. <select id="selectPayMusicSheet" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo$MusicSheetSmall">
  543. SELECT
  544. ms.id_ as musicSheetId,
  545. ms.music_sheet_name_ as musicSheetName,
  546. count(DISTINCT pr.student_id_) as num
  547. FROM
  548. music_sheet ms
  549. LEFT JOIN music_sheet_purchase_record pr ON ms.id_ = pr.music_sheet_id_
  550. WHERE
  551. ms.del_flag_=0
  552. AND ms.charge_type_='CHARGE'
  553. AND ms.state_=1
  554. AND pr.order_status_='PAID'
  555. GROUP BY ms.id_
  556. ORDER BY count(DISTINCT pr.student_id_) DESC,ms.id_ desc
  557. limit 5
  558. </select>
  559. <select id="selectTeacherCount" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherAuditMusicSheetVo">
  560. select
  561. sum(if(t.audit_status_ = 'DOING',1,0)) as doing,
  562. sum(if(t.audit_status_ = 'PASS'
  563. and t.state_ = 1,1,0)) as pass,
  564. sum(if(t.audit_status_ = 'UNPASS',1,0)) as upPass
  565. from
  566. music_sheet t
  567. where t.user_id_ = #{userId}
  568. </select>
  569. <select id="queryStudentTotal" resultType="com.yonge.cooleshow.biz.dal.vo.StudentTotalVo">
  570. select
  571. t.user_id_ as userId,
  572. a.musicAlbumNum,
  573. b.musicSheetNum
  574. from student t
  575. left join (
  576. select
  577. user_id_, count(1) as musicAlbumNum
  578. from album_favorite
  579. <where>
  580. <if test="null != userId">
  581. and user_id_ = #{userId}
  582. </if>
  583. </where>
  584. group by user_id_
  585. ) a on t.user_id_ = a.user_id_
  586. left join (
  587. select
  588. user_id_, count(1) as musicSheetNum
  589. from music_favorite
  590. <where>
  591. <if test="null != userId">
  592. and user_id_ = #{userId}
  593. </if>
  594. </where>
  595. group by user_id_
  596. ) b on t.user_id_ = b.user_id_
  597. <where>
  598. <if test="null != userId">
  599. and t.user_id_ = #{userId}
  600. </if>
  601. </where>
  602. </select>
  603. <select id="queryTeacherTotal" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherTotalVo">
  604. select
  605. t.user_id_ as userId,
  606. a.musicSheetNum as musicSheetNum
  607. from teacher t
  608. left join (
  609. select
  610. user_id_, count(1) as musicSheetNum
  611. from music_sheet
  612. where source_type_ = 'TEACHER' and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0
  613. <if test="null != userId">
  614. and user_id_ = #{userId}
  615. </if>
  616. group by user_id_
  617. ) a on t.user_id_ = a.user_id_
  618. <where>
  619. <if test="null != userId">
  620. and t.user_id_ = #{userId}
  621. </if>
  622. </where>
  623. </select>
  624. <select id="auditDetailList" resultMap="DetailResultMap">
  625. SELECT
  626. <include refid="Base_Column_List"/>
  627. ,t.url_ as url
  628. ,t.midi_url_ as midiUrl
  629. ,t.metronome_url_ as metronomeUrl
  630. ,msa.id_ as accompanimentId
  631. ,msa.music_sheet_id_ as accompanimentMusicSheetId
  632. ,msa.music_subject_ as accompanimentMusicSubject
  633. ,msa.audio_file_url_ as accompanimentAudioFileUrl
  634. ,msa.sort_number_ as accompanimentSortNumber
  635. ,msa.create_time_ as accompanimentCreateTime
  636. ,msa.metronome_url_ as accompanimentMetronomeUrl
  637. ,msa.track_ as track
  638. ,su.username_ as userName
  639. ,su.avatar_ as userAvatar
  640. ,(
  641. select group_concat(mt.name_) from music_tag mt
  642. where find_in_set(mt.id_,t.music_tag_)
  643. and mt.del_flag_ = 0 and mt.state_ = 1
  644. ) as musicTagNames
  645. ,s2.name_ as subjectNames
  646. ,s2.code_ as code
  647. ,s2.ai_default_frequency_ as aiDefaultFrequency
  648. ,su.real_name_ as realName
  649. ,msar.update_time_ as auditTime
  650. ,su2.username_ as auditName
  651. ,msar.reason_ as auditReason
  652. from music_sheet_auth_record msar
  653. left join music_sheet t on t.id_ = msar.music_sheet_id_
  654. left join sys_user su on su.id_ = t.create_by_
  655. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  656. left join music_sheet_accompaniment msa on msa.music_sheet_id_ = t.id_
  657. left join subject s2 on t.music_subject_ = s2.id_
  658. <where>
  659. <if test="originalMusicSheetId != null">
  660. and #{originalMusicSheetId} = msar.original_music_sheet_id_
  661. </if>
  662. <if test="authMusicSheetId != null">
  663. and #{authMusicSheetId} &gt; msar.id_
  664. </if>
  665. </where>
  666. order by msar.id_ desc
  667. </select>
  668. </mapper>