MusicSheetMapper.xml 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576
  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="favorite_count_" jdbcType="INTEGER" property="favoriteCount"/>
  15. <result column="virtual_number_" property="virtualNumber" />
  16. <result column="first_pass_audit_time_" jdbcType="TIMESTAMP" property="firstPassAuditTime"/>
  17. <result column="can_evaluate_" jdbcType="TINYINT" property="canEvaluate"/>
  18. <result column="show_fingering_" jdbcType="TINYINT" property="showFingering"/>
  19. <result column="charge_type_" jdbcType="TINYINT" property="chargeType"/>
  20. <result column="audit_status_" jdbcType="TINYINT" property="auditStatus"/>
  21. <result column="sort_number_" jdbcType="INTEGER" property="sortNumber"/>
  22. <result column="top_flag_" jdbcType="TINYINT" property="topFlag"/>
  23. <result column="hot_flag_" jdbcType="TINYINT" property="hotFlag"/>
  24. <result column="exquisite_flag_" jdbcType="TINYINT" property="exquisiteFlag"/>
  25. <result column="music_price_" jdbcType="DECIMAL" property="musicPrice"/>
  26. <result column="audio_file_url_" jdbcType="VARCHAR" property="audioFileUrl"/>
  27. <result column="xml_file_url_" jdbcType="VARCHAR" property="xmlFileUrl"/>
  28. <result column="has_beat_" jdbcType="TINYINT" property="hasBeat"/>
  29. <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
  30. <result column="create_by_" jdbcType="BIGINT" property="createBy"/>
  31. <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
  32. <result column="update_by_" jdbcType="BIGINT" property="updateBy"/>
  33. <result column="remark_" jdbcType="VARCHAR" property="remark"/>
  34. <result column="notation_" jdbcType="VARCHAR" property="notation"/>
  35. <result column="accompaniment_type_" jdbcType="VARCHAR" property="accompanimentType"/>
  36. <result column="title_img_" jdbcType="VARCHAR" property="titleImg"/>
  37. <result column="music_img_" jdbcType="VARCHAR" property="musicImg"/>
  38. <result column="first_tone_" jdbcType="VARCHAR" property="firstTone"/>
  39. <result column="fixed_tone_" jdbcType="VARCHAR" property="fixedTone"/>
  40. <result column="music_sheet_type_" jdbcType="VARCHAR" property="musicSheetType"/>
  41. <result column="provider_type_" jdbcType="VARCHAR" property="providerType"/>
  42. <result column="cbs_music_sheet_id_" property="cbsMusicSheetId"/>
  43. <result column="score_type_" property="scoreType"/>
  44. <result column="tenant_sort_number_" property="tenantSortNumber"/>
  45. <result column="tenant_state_" property="tenantState"/>
  46. <result column="tenant_notation_" property="tenantNotation"/>
  47. <result column="tenant_category_id_" property="tenantCategoryId"/>
  48. <result column="tenant_score_type_" property="tenantScoreType"/>
  49. <result column="tenant_del_flag_" property="tenantCategoryId"/>
  50. </resultMap>
  51. <sql id="Base_Column_List">
  52. t.id_ as id ,
  53. t.music_sheet_name_ as musicSheetName,
  54. t.user_id_ as userId,
  55. t.composer_ as composer,
  56. t.music_subject_ as musicSubject,
  57. t.audio_type_ as audioType,
  58. t.music_tag_ as musicTag,
  59. t.play_speed_ as playSpeed,
  60. t.favorite_count_ as favoriteCount,
  61. t.virtual_number_ as virtualNumber,
  62. t.first_pass_audit_time_ as firstPassAuditTime,
  63. t.can_evaluate_ as canEvaluate,
  64. t.show_fingering_ as showFingering,
  65. t.charge_type_ as chargeType,
  66. t.payment_type_ as paymentType,
  67. t.provider_type_ as providerType,
  68. t.state_ as state,
  69. t.client_state_ as clientState,
  70. t.platform_state_ as platformState,
  71. t.sort_number_ as sortNumber,
  72. t.top_flag_ as topFlag,
  73. t.exquisite_flag_ as exquisiteFlag,
  74. t.hot_flag_ as hotFlag,
  75. t.music_price_ as musicPrice,
  76. t.audio_file_url_ as audioFileUrl,
  77. t.xml_file_url_ as xmlFileUrl,
  78. t.has_beat_ as hasBeat,
  79. t.mp3_type_ as mp3Type,
  80. t.ext_config_json_ as extConfigJson,
  81. t.create_time_ as createTime,
  82. t.create_by_ as createBy,
  83. t.update_time_ as updateTime,
  84. t.update_by_ as updateBy,
  85. t.del_flag_ as delFlag,
  86. t.audit_version_ as auditVersion,
  87. t.source_type_ as sourceType,
  88. t.accompaniment_type_ as accompanimentType,
  89. t.remark_ as remark,
  90. t.first_tone_ as firstTone,
  91. t.fixed_tone_ as fixedTone,
  92. t.title_img_ as titleImg,
  93. t.reason_ as reason,
  94. t.music_img_ as musicImg,
  95. t.notation_ as notation,
  96. t.music_json_ as musicJSON,
  97. t.music_svg_ as musicSvg,
  98. t.music_jian_svg_ as musicJianSvg,
  99. t.music_first_svg_ as musicFirstSvg,
  100. t.music_sheet_type_ as musicSheetType,
  101. t.audit_status_ as auditStatus,
  102. t.submit_audit_time_ as submitAuditTime,
  103. t.cbs_music_sheet_id_ as cbsMusicSheetId,
  104. t.score_type_ as scoreType,
  105. t.tenant_sort_number_ as tenantSortNumber,
  106. t.tenant_state_ as tenantState,
  107. t.tenant_notation_ as tenantNotation,
  108. t.tenant_category_id_ as tenantCategoryId,
  109. t.tenant_score_type_ as tenantScoreType,
  110. t.tenant_del_flag_ as tenantDelFlag
  111. </sql>
  112. <insert id="batchInsert">
  113. insert into music_sheet
  114. (cbs_music_sheet_id_,music_tag_,payment_type_,charge_type_,top_flag_,exquisite_flag_,sort_number_,state_,audit_status_
  115. ,music_sheet_name_,music_subject_,music_svg_,composer_,accompaniment_type_,play_speed_,
  116. music_price_,notation_,music_sheet_type_,source_type_,provider_type_,audio_type_,show_fingering_,
  117. can_evaluate_,create_by_,user_id_,score_type_,is_all_subject_,first_pass_audit_time_
  118. )
  119. values
  120. <foreach collection="vos" item="item" separator=",">
  121. (#{item.musicSheetId},
  122. #{item.musicTagIds},#{item.paymentType},#{item.paymentType},
  123. #{item.topFlag},#{item.exquisiteFlag},#{item.sortNo},0
  124. ,'PASS'
  125. ,#{item.musicSheetUpdate.name},
  126. #{item.musicSheetUpdate.subjectIds},
  127. #{item.musicSheetUpdate.musicSvg},
  128. #{item.musicSheetUpdate.composer},
  129. #{item.musicSheetUpdate.audioType},
  130. #{item.musicSheetUpdate.playSpeed},
  131. #{item.musicSheetUpdate.musicPrice},
  132. #{item.isConvertibleScore},
  133. #{item.musicSheetUpdate.musicSheetType},
  134. CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  135. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER'
  136. ELSE 'TENANT' END,
  137. CASE WHEN #{item.availableType} = 'PLATFORM' THEN 'PLATFORM' ELSE 'TENANT' END,
  138. #{item.musicSheetUpdate.playMode},
  139. #{item.musicSheetUpdate.showFingering},
  140. #{item.musicSheetUpdate.canEvaluate},
  141. #{item.musicSheetUpdate.userId},#{item.musicSheetUpdate.userId},
  142. #{item.scoreType},#{item.musicSheetUpdate.isAllSubject},now()
  143. )
  144. </foreach>
  145. </insert>
  146. <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  147. select <include refid="Base_Column_List"/>
  148. from music_sheet t
  149. left join sys_user su on t.create_by_ = su.id_
  150. <if test="param.sortByAlbumIdDesc != null">
  151. left join tenant_album_music tam on tam.music_sheet_id_ = t.id_ and tam.tenant_album_id_ = #{param.sortByAlbumIdDesc} and tam.del_flag_=0
  152. </if>
  153. <if test="param.auditStatus != null">
  154. left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
  155. </if>
  156. <where>
  157. 1=1
  158. <if test="param.clientState != null">
  159. and t.client_state_ = #{param.clientState}
  160. </if>
  161. <if test="param.platformState != null">
  162. and t.platform_state_ = #{param.platformState}
  163. </if>
  164. <if test="param.excludeMusicIds != null and param.excludeMusicIds.size() != 0">
  165. and t.id_ not in
  166. <foreach collection="param.excludeMusicIds" separator="," item="item" open="(" close=")">
  167. #{item}
  168. </foreach>
  169. </if>
  170. <if test="param.mustMatchSubjectIds != null and param.mustMatchSubjectIds.size() != 0">
  171. and
  172. <foreach collection="param.mustMatchSubjectIds" separator="and" item="item" open="(" close=")">
  173. find_in_set(#{item},t.music_subject_)
  174. </foreach>
  175. </if>
  176. <include refid="QueryInfo"/>
  177. <if test="param.auditStatus == null">
  178. AND t.cbs_music_sheet_id_ IS NOT NULL
  179. </if>
  180. <if test="param.tenantCategoryIds != null and param.tenantCategoryIds.size() != 0">
  181. and t.tenant_category_id_ in
  182. <foreach collection="param.tenantCategoryIds" separator="," item="item" open="(" close=")">
  183. #{item}
  184. </foreach>
  185. </if>
  186. <if test="param.auditVersion != null ">
  187. and #{param.auditVersion} = t.audit_version_
  188. </if>
  189. <if test="param.notation">
  190. AND t.notation_ = #{param.notation}
  191. </if>
  192. </where>
  193. <if test="param.auditStatus != null">
  194. group by msar.music_sheet_id_
  195. </if>
  196. order by
  197. <if test="param.sortByAlbumIdDesc != null">
  198. if(isnull(tam.id_),0,1),
  199. </if>
  200. <if test="param.myself != null and param.myself == true ">
  201. t.cbs_music_sheet_id_ desc,
  202. </if>
  203. t.sort_group_, t.sort_num_, t.sort_num2_, t.alias_
  204. </select>
  205. <sql id="QueryInfo">
  206. <if test="param.musicSheetType != null">
  207. and t.music_sheet_type_ = #{param.musicSheetType}
  208. </if>
  209. <if test="param.idAndName != null and param.idAndName != ''">
  210. <if test="param.auditStatus != null">
  211. AND ((su.id_ like concat('%',#{param.idAndName} ,'%')
  212. or su.username_ like concat('%',#{param.idAndName},'%')
  213. or su.phone_ like concat('%',#{param.idAndName},'%')) OR
  214. (t.music_sheet_name_ like concat('%',#{param.idAndName},'%') AND msar.last_audit_state_ = 'PASS') OR
  215. (JSON_UNQUOTE(JSON_EXTRACT(music_sheet_json_, '$.name')) LIKE CONCAT('%',#{param.idAndName},'%') AND msar.last_audit_state_ != 'PASS'))
  216. </if>
  217. <if test="param.auditStatus == null">
  218. AND (su.id_ like concat('%',#{param.idAndName} ,'%')
  219. or su.username_ like concat('%',#{param.idAndName},'%')
  220. or su.phone_ like concat('%',#{param.idAndName},'%') OR
  221. t.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  222. </if>
  223. </if>
  224. <if test="param.search != null and param.search != ''">
  225. and (t.cbs_music_sheet_id_ like concat('%',#{param.search},'%') or
  226. t.music_sheet_name_ like concat('%',#{param.search},'%') or
  227. t.composer_ like concat ('%',#{param.search},'%'))
  228. </if>
  229. <if test="param.providerType != null">
  230. and find_in_set(#{param.providerType},t.provider_type_)
  231. </if>
  232. <if test="param.musicTagIds != null and param.musicTagIds != ''">
  233. and
  234. <foreach collection="param.musicTagIdList" open="(" close=")" separator="or" item="item">
  235. find_in_set(#{item},t.music_tag_)
  236. </foreach>
  237. </if>
  238. <if test="param.subjectIdList != null and param.subjectIdList.size() != 0">
  239. and(
  240. <foreach collection="param.subjectIdList" separator="or" item="item" open="(" close=")">
  241. find_in_set(#{item},t.music_subject_)
  242. </foreach>
  243. or t.music_subject_ is null or t.music_subject_ = '' OR t.is_all_subject_
  244. )
  245. </if>
  246. <if test="param.subjectIds != null and param.subjectIds != ''">
  247. and(find_in_set(#{param.subjectIds},t.music_subject_) or t.music_subject_ is null or t.music_subject_ = '' OR t.is_all_subject_)
  248. </if>
  249. <if test="param.musicSheetIdlist != null and param.musicSheetIdlist.size() != 0">
  250. and t.id_ in
  251. <foreach collection="param.musicSheetIdlist" separator="," item="item" open="(" close=")">
  252. #{item}
  253. </foreach>
  254. </if>
  255. <if test="param.state != null">
  256. <if test="param.providerType != null">
  257. <if test="param.providerType.code == 'TENANT'">
  258. and t.tenant_state_ = #{param.state}
  259. </if>
  260. <if test="param.providerType.code == 'PLATFORM'">
  261. and t.state_ = #{param.state}
  262. </if>
  263. </if>
  264. <if test="param.providerType == null">
  265. and t.state_ = #{param.state}
  266. </if>
  267. </if>
  268. <if test="param.auditStatus != null">
  269. and msar.last_audit_state_ = #{param.auditStatus}
  270. </if>
  271. <if test="param.scoreType != null">
  272. and t.score_type_ = #{param.scoreType}
  273. </if>
  274. <if test="param.createBy != null">
  275. and t.create_by_ = #{param.createBy}
  276. </if>
  277. <if test="param.delFlag != null">
  278. <if test="param.providerType != null">
  279. <if test="param.providerType.code == 'TENANT'">
  280. and t.tenant_del_flag_ = #{param.delFlag}
  281. </if>
  282. <if test="param.providerType.code == 'PLATFORM'">
  283. and t.del_flag_ = #{param.delFlag}
  284. </if>
  285. </if>
  286. <if test="param.providerType == null">
  287. and t.del_flag_ = #{param.delFlag}
  288. </if>
  289. </if>
  290. <if test="param.sourceType != null">
  291. and t.source_type_ = #{param.sourceType}
  292. </if>
  293. <if test="param.chargeType != null">
  294. and (FIND_IN_SET(#{param.chargeType}, t.payment_type_))
  295. </if>
  296. <if test="param.topFlag != null">
  297. and t.top_flag_ = #{param.topFlag}
  298. </if>
  299. <if test="param.exquisiteFlag != null">
  300. and t.exquisite_flag_ = #{param.exquisiteFlag}
  301. </if>
  302. <if test="param.accompanimentType != null">
  303. and t.accompaniment_type_ = #{param.accompanimentType}
  304. </if>
  305. <if test="param.audioType != null">
  306. and t.audio_type_ = #{param.audioType}
  307. </if>
  308. </sql>
  309. <select id="selectAlbumDetailPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  310. select distinct <include refid="Base_Column_List"/>
  311. ,su.username_ as addName
  312. ,su.avatar_ as addUserAvatar
  313. ,(select group_concat(mt.name_) from music_tag mt
  314. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  315. ,(select group_concat(s.name_) from subject s
  316. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  317. from music_sheet t
  318. left join album_music_relate amr on t.id_ = amr.music_sheet_id_
  319. left join sys_user su on t.create_by_ = su.id_
  320. <where>
  321. t.cbs_music_sheet_id_ IS NOT NULL and find_in_set('PLATFORM',t.provider_type_)
  322. <if test="param.composer != null">
  323. AND t.composer_ LIKE '%${param.composer}%'
  324. </if>
  325. <if test="param.providerType != null">
  326. and find_in_set(#{param.providerType},t.provider_type_)
  327. </if>
  328. <if test="param.idAndName != null and param.idAndName != ''">
  329. and (t.id_ like concat('%',#{param.idAndName},'%') or
  330. t.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  331. </if>
  332. <if test="param.musicSheetName != null and param.musicSheetName != ''">
  333. and t.music_sheet_name_ like concat('%',#{param.musicSheetName},'%')
  334. </if>
  335. <if test="param.albumCategoryLevelId != null">
  336. and amr.album_category_level_id_ = #{param.albumCategoryLevelId}
  337. </if>
  338. <if test="param2.albumCategoryTypeId != null">
  339. and amr.album_category_type_id_ = #{param2.albumCategoryTypeId}
  340. </if>
  341. <if test="param.search != null and param.search != ''">
  342. and (t.cbs_music_sheet_id_ like concat('%',#{param.search},'%') or
  343. t.music_sheet_name_ like concat('%',#{param.search},'%'))
  344. </if>
  345. <if test="param.chargeType != null">
  346. and t.charge_type_ = #{param.chargeType}
  347. </if>
  348. <if test="param.excludeMusicIds != null and param.excludeMusicIds.size() != 0">
  349. and t.id_ not in
  350. <foreach collection="param.excludeMusicIds" separator="," item="item" open="(" close=")">
  351. #{item}
  352. </foreach>
  353. </if>
  354. <if test="param.musicTagIds != null and param.musicTagIds != ''">
  355. and
  356. <foreach collection="param.musicTagIdList" separator="or" item="item" open="(" close=")" >
  357. find_in_set(#{item},t.music_tag_)
  358. </foreach>
  359. </if>
  360. <if test="param.subjectIdList != null and param.subjectIdList.size() != 0">
  361. and
  362. <foreach collection="param.subjectIdList" separator="or" item="item" open="(" close=")" >
  363. find_in_set(#{item},t.music_subject_)
  364. </foreach>
  365. </if>
  366. <if test="param.musicSheetType != null">
  367. and t.music_sheet_type_ = #{param.musicSheetType}
  368. </if>
  369. <if test="param.state != null">
  370. and t.state_ = #{param.state}
  371. </if>
  372. <if test="param.delFlag != null">
  373. and t.del_flag_ = #{param.delFlag}
  374. </if>
  375. <if test="param.sourceType != null">
  376. AND t.source_type_ = #{param.sourceType}
  377. </if>
  378. <if test="param.chargeType != null">
  379. AND (t.payment_type_ = 'FREE' OR FIND_IN_SET(#{param.chargeType}, t.payment_type_))
  380. </if>
  381. <if test="param.paymentTypes != null">
  382. AND t.payment_type_ IN (<foreach collection="param.paymentTypes" separator="," item="item">#{item}</foreach>)
  383. </if>
  384. <if test="param.id != null">
  385. <if test="param.type == 2">
  386. and amr.album_id_ = #{param.id}
  387. order by amr.sort_number_ desc,
  388. t.sort_group_, t.sort_num_, t.sort_num2_, t.alias_
  389. </if>
  390. <if test="param.type == 1">
  391. and t.id_ not in(select amr2.music_sheet_id_ from album_music_relate amr2
  392. where amr2.album_id_ = #{param.id})
  393. ORDER BY t.sort_group_, t.sort_num_, t.sort_num2_, t.alias_
  394. </if>
  395. </if>
  396. <if test="param.id == null">
  397. ORDER BY t.sort_group_, t.sort_num_, t.sort_num2_, t.alias_
  398. </if>
  399. </where>
  400. </select>
  401. <select id="detail" resultMap="DetailResultMap">
  402. SELECT
  403. <include refid="Base_Column_List"/>
  404. ,t.url_ as url
  405. ,t.midi_url_ as midiUrl
  406. ,t.metronome_url_ as metronomeUrl
  407. ,msa.id_ as accompanimentId
  408. ,msa.music_sheet_id_ as accompanimentMusicSheetId
  409. ,msa.audio_file_url_ as accompanimentAudioFileUrl
  410. ,msa.sort_number_ as accompanimentSortNumber
  411. ,msa.create_time_ as accompanimentCreateTime
  412. ,msa.track_ as track
  413. ,msa.musical_instrument_id_ as musicalInstrumentId
  414. ,su.username_ as userName
  415. ,su.avatar_ as userAvatar
  416. ,(
  417. select group_concat(mt.name_) from music_tag mt
  418. where find_in_set(mt.id_,t.music_tag_)
  419. and mt.del_flag_ = 0 and mt.state_ = 1
  420. ) as musicTagNames
  421. ,s2.name_ as subjectNames
  422. ,s2.code_ as code
  423. ,su.real_name_ as realName
  424. ,s2.ai_default_frequency_ as aiDefaultFrequency
  425. FROM music_sheet t
  426. left join music_sheet_accompaniment msa on msa.music_sheet_id_ = t.id_
  427. left join sys_user su on t.create_by_ = su.id_
  428. left join subject s2 on t.music_subject_ = s2.id_
  429. where t.id_ = #{id} AND t.cbs_music_sheet_id_ IS NOT NULL
  430. order by msa.sort_number_
  431. </select>
  432. <resultMap id="DetailResultMap" type="com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo">
  433. <id column="id" jdbcType="BIGINT" property="id"/>
  434. <result column="musicSheetName" jdbcType="VARCHAR" property="musicSheetName"/>
  435. <result column="userId" jdbcType="BIGINT" property="userId"/>
  436. <result column="cbsMusicSheetId" jdbcType="BIGINT" property="cbsMusicSheetId"/>
  437. <result column="composer" jdbcType="VARCHAR" property="composer"/>
  438. <result column="titleImg" jdbcType="VARCHAR" property="titleImg"/>
  439. <result column="musicSubject" jdbcType="VARCHAR" property="musicSubject"/>
  440. <result column="audioType" jdbcType="VARCHAR" property="audioType"/>
  441. <result column="providerType" jdbcType="VARCHAR" property="providerType"/>
  442. <result column="musicTag" jdbcType="VARCHAR" property="musicTag"/>
  443. <result column="playSpeed" jdbcType="INTEGER" property="playSpeed"/>
  444. <result column="canEvaluate" jdbcType="TINYINT" property="canEvaluate"/>
  445. <result column="showFingering" jdbcType="TINYINT" property="showFingering"/>
  446. <result column="chargeType" jdbcType="TINYINT" property="chargeType"/>
  447. <result column="auditStatus" property="auditStatus"/>
  448. <result column="state" jdbcType="TINYINT" property="state"/>
  449. <result column="sortNumber" jdbcType="INTEGER" property="sortNumber"/>
  450. <result column="topFlag" jdbcType="TINYINT" property="topFlag"/>
  451. <result column="hotFlag" jdbcType="TINYINT" property="hotFlag"/>
  452. <result column="musicPrice" jdbcType="DECIMAL" property="musicPrice"/>
  453. <result column="audioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  454. <result column="musicTagNames" jdbcType="VARCHAR" property="musicTagNames"/>
  455. <result column="subjectNames" jdbcType="VARCHAR" property="subjectNames"/>
  456. <result column="xmlFileUrl" jdbcType="VARCHAR" property="xmlFileUrl"/>
  457. <result column="hasBeat" jdbcType="TINYINT" property="hasBeat"/>
  458. <result column="createTime" jdbcType="TIMESTAMP" property="createTime"/>
  459. <result column="createBy" jdbcType="BIGINT" property="createBy"/>
  460. <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime"/>
  461. <result column="updateBy" jdbcType="BIGINT" property="updateBy"/>
  462. <result column="delFlag" jdbcType="BOOLEAN" property="delFlag"/>
  463. <result column="url" jdbcType="BOOLEAN" property="url"/>
  464. <result column="metronomeUrl" jdbcType="BOOLEAN" property="metronomeUrl"/>
  465. <result column="midiUrl" jdbcType="BOOLEAN" property="midiUrl"/>
  466. <result column="mp3Type" jdbcType="VARCHAR" property="mp3Type"/>
  467. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  468. <result column="userName" jdbcType="VARCHAR" property="userName"/>
  469. <result column="auditVersion" jdbcType="VARCHAR" property="auditVersion"/>
  470. <result column="code" jdbcType="VARCHAR" property="code"/>
  471. <result column="reason" jdbcType="VARCHAR" property="reason"/>
  472. <result column="accompanimentType" jdbcType="VARCHAR" property="accompanimentType"/>
  473. <result column="notation" jdbcType="VARCHAR" property="notation"/>
  474. <result column="musicImg" jdbcType="VARCHAR" property="musicImg"/>
  475. <result column="favoriteCount" jdbcType="VARCHAR" property="favoriteCount"/>
  476. <result column="firstPassAuditTime" jdbcType="VARCHAR" property="firstPassAuditTime"/>
  477. <result column="realName" jdbcType="VARCHAR" property="realName"/>
  478. <result column="auditTime" jdbcType="VARCHAR" property="auditTime"/>
  479. <result column="auditName" jdbcType="VARCHAR" property="auditName"/>
  480. <result column="auditReason" jdbcType="VARCHAR" property="auditReason"/>
  481. <result column="aiDefaultFrequency" jdbcType="VARCHAR" property="aiDefaultFrequency"/>
  482. <result column="musicJSON" jdbcType="VARCHAR" property="musicJSON"/>
  483. <result column="musicSvg" jdbcType="VARCHAR" property="musicSvg"/>
  484. <result column="musicJianSvg" jdbcType="VARCHAR" property="musicJianSvg"/>
  485. <result column="musicFirstSvg" jdbcType="VARCHAR" property="musicFirstSvg"/>
  486. <result column="musicSheetType" jdbcType="VARCHAR" property="musicSheetType"/>
  487. <result column="musicSheetJson" jdbcType="VARCHAR" property="musicSheetJson"/>
  488. <result column="tenantSortNumber" jdbcType="VARCHAR" property="tenantSortNumber"/>
  489. <result column="tenantState" jdbcType="VARCHAR" property="tenantState"/>
  490. <result column="tenantNotation" jdbcType="VARCHAR" property="tenantNotation"/>
  491. <result column="tenantCategoryId" jdbcType="VARCHAR" property="tenantCategoryId"/>
  492. <result column="tenantScoreType" jdbcType="VARCHAR" property="tenantScoreType"/>
  493. <result column="tenantDelFlag" jdbcType="VARCHAR" property="tenantDelFlag"/>
  494. <result column="scoreType" jdbcType="VARCHAR" property="scoreType"/>
  495. <collection property="background" ofType="com.yonge.cooleshow.biz.dal.entity.MusicSheetAccompaniment">
  496. <id column="accompanimentId" jdbcType="BIGINT" property="id"/>
  497. <result column="accompanimentMusicSheetId" jdbcType="BIGINT" property="musicSheetId"/>
  498. <result column="accompanimentMusicSubject" jdbcType="VARCHAR" property="musicSubjectId"/>
  499. <result column="accompanimentAudioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  500. <result column="accompanimentSortNumber" jdbcType="TINYINT" property="sortNumber"/>
  501. <result column="accompanimentCreateTime" jdbcType="TIMESTAMP" property="createTime"/>
  502. <result column="accompanimentMetronomeUrl" jdbcType="VARCHAR" property="metronomeUrl"/>
  503. <result column="track" jdbcType="VARCHAR" property="track"/>
  504. <result column="musicalInstrumentId" jdbcType="VARCHAR" property="musicalInstrumentId"/>
  505. </collection>
  506. </resultMap>
  507. <select id="selectStudentMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  508. select <include refid="Base_Column_List"/>
  509. ,su.username_ as addName
  510. ,su.avatar_ as addUserAvatar
  511. from music_sheet t
  512. left join sys_user su on t.create_by_ = su.id_
  513. <if test="param.auditStatus != null">
  514. left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
  515. </if>
  516. <where>
  517. 1=1
  518. <include refid="QueryInfo"/>
  519. <if test="param.auditVersion != null ">
  520. and #{param.auditVersion} = t.audit_version_
  521. </if>
  522. </where>
  523. <if test="param.auditStatus != null">
  524. group by msar.music_sheet_id_
  525. </if>
  526. order by
  527. <choose>
  528. <when test="param.musicSortType != null and param.musicSortType.code == 'TOP'">
  529. t.top_flag_ desc, t.sort_number_ desc,
  530. </when>
  531. <when test="param.musicSortType != null and param.musicSortType.code == 'HOT'">
  532. t.favorite_count_ desc,
  533. </when>
  534. <when test="param.musicSortType != null and param.musicSortType.code == 'NEW'">
  535. t.first_pass_audit_time_ desc,
  536. </when>
  537. <otherwise>
  538. <if test="param.myself != null and param.myself == true ">
  539. t.cbs_music_sheet_id_ desc,
  540. </if>
  541. </otherwise>
  542. </choose>
  543. t.sort_group_, t.sort_num_, t.sort_num2_, t.alias_
  544. </select>
  545. <select id="selectMyMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  546. select distinct <include refid="Base_Column_List"/>
  547. ,su.username_ as addName
  548. ,su.avatar_ as addUserAvatar
  549. ,(select group_concat(mt.name_) from music_tag mt
  550. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  551. ,(select group_concat(s.name_) from subject s
  552. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  553. ,if(mf.id_ is not null,1,0) as favorite
  554. from music_sheet t
  555. left join sys_user su on t.create_by_ = su.id_
  556. left join music_sheet_purchase_record mspr on mspr.music_sheet_id_ = t.id_
  557. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mspr.student_id_ = mf.user_id_
  558. <if test="param.auditStatus != null">
  559. left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
  560. </if>
  561. <where>
  562. 1=1
  563. <include refid="QueryInfo"/>
  564. <if test="param.studentId != null">
  565. and mspr.student_id_ = #{param.studentId}
  566. and mspr.order_status_ = 'PAID'
  567. </if>
  568. <if test="param.userType != null">
  569. and mspr.client_type_ = #{param.userType}
  570. </if>
  571. <if test="param.purchaseType != null">
  572. AND mspr.purchase_type_ = #{param.purchaseType}
  573. </if>
  574. <if test="param.courseGift != null">
  575. AND mspr.course_music_album_id_ <choose><when test="param.courseGift == 0"> = </when><otherwise> > </otherwise> </choose> 0
  576. </if>
  577. </where>
  578. <if test="param.auditStatus != null">
  579. group by msar.music_sheet_id_
  580. </if>
  581. order by mspr.id_ desc
  582. </select>
  583. <select id="selectFavoriteMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  584. select distinct <include refid="Base_Column_List"/>
  585. ,su.username_ as addName
  586. ,su.avatar_ as addUserAvatar
  587. ,group_concat(mf.provider_type_) as favoriteProviderType
  588. ,(select group_concat(mt.name_) from music_tag mt
  589. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  590. ,(select group_concat(s.name_) from subject s
  591. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  592. ,if(mf.id_ is not null,1,0) as favorite
  593. from music_sheet t
  594. left join sys_user su on t.create_by_ = su.id_
  595. left join music_favorite mf on t.id_ = mf.music_sheet_id_
  596. <where>
  597. mf.client_type_ = #{clientType}
  598. <if test="clientType.code == 'STUDENT'">
  599. and t.del_flag_=0 and t.state_ =1 and find_in_set('PLATFORM',t.provider_type_)
  600. </if>
  601. <if test="clientType.code == 'TEACHER'">
  602. and ((t.del_flag_=0 and t.state_ =1 and find_in_set('PLATFORM',t.provider_type_))
  603. <if test="param.tenantId !=null">
  604. or (t.tenant_del_flag_=0 and t.tenant_state_ =1 and find_in_set('TENANT',t.provider_type_)
  605. and t.id_ in (select s.music_sheet_id_ from tenant_album_music s
  606. left join tenant_album s1 on s.tenant_album_id_ = s1.id_ where s.tenant_id_ = #{param.tenantId}
  607. and s.del_flag_ = 0 and s.subject_type_ in ('ENSEMBLE','MUSIC','SUBJECT') and s1.del_flag_= 0 and s1.status_ = 1
  608. )
  609. )
  610. </if>
  611. )
  612. </if>
  613. <if test="param.favoriteProviderType != null">
  614. and mf.provider_type_ = #{param.favoriteProviderType}
  615. </if>
  616. <if test="param.studentId != null">
  617. and mf.user_id_ = #{param.studentId}
  618. </if>
  619. </where>
  620. group by t.id_
  621. order by mf.id_ desc
  622. </select>
  623. <select id="selectPracticeMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  624. select <include refid="Base_Column_List"/>
  625. ,su.username_ as addName
  626. ,su.avatar_ as addUserAvatar
  627. ,(select group_concat(mt.name_) from music_tag mt
  628. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  629. ,(select group_concat(s.name_) from subject s where find_in_set(s.id_,t.music_subject_) ) as subjectNames
  630. ,if(mf.id_ is not null,1,0) as favorite
  631. from sys_music_compare_record mspr
  632. left join music_sheet t on mspr.music_sheet_id_ = t.id_
  633. <if test="param.auditStatus != null">
  634. left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
  635. </if>
  636. left join sys_user su on t.create_by_ = su.id_
  637. left join music_favorite mf on (t.id_ = mf.music_sheet_id_ and mspr.user_id_ = mf.user_id_ <if test="param.clientType != null"> AND mf.client_type_ = #{param.clientType}</if> )
  638. <where>
  639. 1=1
  640. <include refid="QueryInfo"/>
  641. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  642. and mspr.id_ in
  643. <foreach collection="practiceMusicIdList" item="item" open="(" close=")" separator=",">
  644. #{item}
  645. </foreach>
  646. </if>
  647. </where>
  648. <if test="param.auditStatus != null">
  649. group by msar.music_sheet_id_
  650. </if>
  651. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  652. order by field(mspr.id_,
  653. <foreach collection="practiceMusicIdList" item="item" separator=",">
  654. #{item}
  655. </foreach>
  656. </if>
  657. )
  658. </select>
  659. <select id="selectStudentOrderPage" resultType="com.yonge.cooleshow.biz.dal.vo.StudentMusicSheetOrderVo">
  660. select distinct mspr.music_sheet_id_ as musicSheetId
  661. ,ms.music_sheet_name_ as musicSheetName
  662. ,ms.composer_ as composer
  663. ,ms.title_img_ as titleImg
  664. ,ms.music_tag_ as musicTag
  665. ,(select group_concat(mt.name_) from music_tag mt
  666. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  667. ,mspr.purchase_price_ as purchasePrice
  668. ,mspr.order_no_ as orderNo
  669. ,mspr.purchase_time_ as purchaseTime
  670. from music_sheet_purchase_record mspr
  671. left join music_sheet ms on mspr.music_sheet_id_ = ms.id_
  672. <where>
  673. mspr.order_status_ = 'PAID' and mspr.purchase_type_ = 'MUSIC'
  674. <if test="param.idAndName != null and param.idAndName != ''">
  675. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  676. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  677. </if>
  678. <if test="param.studentId != null">
  679. and mspr.student_id_ = #{param.studentId}
  680. </if>
  681. <if test="param.orderNo != null and param.orderNo != ''">
  682. and mspr.order_no_ = #{param.orderNo}
  683. </if>
  684. <if test="param.musicTagList != null and param.musicTagList.size() != 0">
  685. and
  686. <foreach collection="param.musicTagList" separator="or" item="item" open="(" close=")" >
  687. find_in_set(#{item},ms.music_tag_)
  688. </foreach>
  689. </if>
  690. <if test="param.startTime != null">
  691. and mspr.purchase_time_ &gt; #{param.startTime}
  692. </if>
  693. <if test="param.endTime != null">
  694. and mspr.purchase_time_ &lt; #{param.endTime}
  695. </if>
  696. </where>
  697. order by mspr.id_ desc
  698. </select>
  699. <select id="selectTeacherPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  700. select ms.id_ as musicSheetId
  701. ,ms.music_sheet_name_ as musicSheetName
  702. ,ms.composer_ as composer
  703. ,ms.title_img_ as titleImg
  704. ,ms.accompaniment_type_ as accompanimentType
  705. ,ms.music_tag_ as musicTag
  706. ,(select group_concat(mt.name_) from music_tag mt
  707. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  708. ,ms.play_speed_ as playSpeed
  709. ,ms.music_price_ as musicPrice
  710. ,ms.create_time_ as createTime
  711. ,ms.audit_status_ as auditStatus
  712. <!-- ,su.username_ as auditName-->
  713. from music_sheet ms
  714. <!-- left join music_sheet_auth_record msar on ms.id_ = msar.music_sheet_id_-->
  715. <!-- left join sys_user su on msar.verify_user_id_ = su.id_-->
  716. <where>
  717. <if test="param.idAndName != null and param.idAndName != ''">
  718. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  719. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%')
  720. or ms.composer_ like concat('%',#{param.idAndName},'%'))
  721. </if>
  722. <if test="param.teacherId != null">
  723. and ms.create_by_ = #{param.teacherId} and ms.source_type_ = 'TEACHER'
  724. and ms.audit_status_ = 'PASS'
  725. </if>
  726. <if test="param.startTime != null">
  727. and ms.create_time_ &gt; #{param.startTime}
  728. </if>
  729. <if test="param.endTime != null">
  730. and ms.create_time_ &lt; #{param.endTime}
  731. </if>
  732. <if test="param.delFlag != null">
  733. and ms.del_flag_ = #{param.delFlag}
  734. </if>
  735. </where>
  736. order by ms.id_ desc
  737. </select>
  738. <select id="selectAuditPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  739. select
  740. msar.id_ as authMusicSheetId,
  741. ms.create_by_ as teacherId
  742. ,ms.exquisite_flag_ as exquisiteFlag
  743. ,ms.title_img_ as titleImg
  744. ,ms.accompaniment_type_ as accompanimentType
  745. ,su.username_ as username
  746. ,su.real_name_ as realName
  747. ,su.phone_ as phone
  748. ,ms.id_ as musicSheetId
  749. ,ms.music_sheet_name_ as musicSheetName
  750. ,ms.composer_ as composer
  751. ,ms.music_tag_ as musicTag
  752. ,(select group_concat(mt.name_) from music_tag mt
  753. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  754. ,ms.play_speed_ as playSpeed
  755. ,ms.music_price_ as musicPrice
  756. ,ms.update_time_ as createTime
  757. ,if(msar.audit_state_ is null,ms.audit_status_,msar.audit_state_) as auditStatus
  758. ,su2.username_ as auditName
  759. ,msar.first_auth_ as firstAuth
  760. from music_sheet_auth_record msar
  761. left join music_sheet ms on ms.id_ = msar.music_sheet_id_
  762. left join sys_user su on su.id_ = ms.create_by_
  763. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  764. <where>ms.source_type_ = 'TEACHER'
  765. <if test="param.idAndName != null and param.idAndName != ''">
  766. and (su.id_ like concat('%',#{param.idAndName} ,'%')
  767. or su.username_ like concat('%',#{param.idAndName},'%')
  768. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%')
  769. or su.phone_ like concat('%',#{param.idAndName},'%'))
  770. </if>
  771. <if test="param.auditName != null and param.auditName != ''">
  772. and su2.username_ like concat('%',#{param.auditName},'%')
  773. </if>
  774. <if test="param.authStatus != null">
  775. and msar.audit_state_ = #{param.authStatus} and msar.audit_state_ = msar.last_audit_state_
  776. </if>
  777. <if test="param.startTime != null">
  778. and ms.create_time_ &gt; #{param.startTime}
  779. </if>
  780. <if test="param.endTime != null">
  781. and ms.create_time_ &lt; #{param.endTime}
  782. </if>
  783. <if test="param.chargeType != null">
  784. and ms.charge_type_ = #{param.chargeType}
  785. </if>
  786. <if test="param.firstAuth != null">
  787. and msar.first_auth_ = #{param.firstAuth}
  788. </if>
  789. <if test="param.exquisiteFlag != null">
  790. and ms.exquisite_flag_ = #{param.exquisiteFlag}
  791. </if>
  792. </where>
  793. order by field(ms.audit_status_,'DOING') desc, ms.submit_audit_time_ desc
  794. </select>
  795. <select id="selectTeacherMusicSheetCount" resultType="java.lang.Integer">
  796. select count(1)
  797. from music_sheet
  798. where user_id_ = #{userId}
  799. and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0 and source_type_ = 'TEACHER'
  800. </select>
  801. <select id="selectMusicNum" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo">
  802. select
  803. sum(if(ms.source_type_ = 'PLATFORM',1,0)) as musicSheetPlatformCount,
  804. sum(if(ms.source_type_ = 'TEACHER',1,0)) as musicSheetTeacherCount,
  805. count(1) as musicSheetCount
  806. from music_sheet ms
  807. where ms.state_ = 1 and ms.del_flag_ = 0 and ms.audit_status_ = 'PASS' and find_in_set('CHARGE',ms.payment_type_) and find_in_set('PLATFORM',ms.provider_type_)
  808. </select>
  809. <select id="selectPayMusicSheet" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo$MusicSheetSmall">
  810. SELECT
  811. ms.id_ as musicSheetId,
  812. ms.cbs_music_sheet_id_ as cbsMusicSheetId,
  813. ms.music_sheet_name_ as musicSheetName,
  814. count(DISTINCT pr.student_id_) as num
  815. FROM
  816. music_sheet ms
  817. LEFT JOIN music_sheet_purchase_record pr ON ms.id_ = pr.music_sheet_id_
  818. WHERE
  819. ms.del_flag_=0 and ms.cbs_music_sheet_id_ is not null
  820. AND ms.charge_type_='CHARGE'
  821. AND ms.state_=1
  822. AND pr.order_status_='PAID'
  823. GROUP BY ms.id_
  824. ORDER BY count(DISTINCT pr.student_id_) DESC,ms.id_ desc
  825. limit 5
  826. </select>
  827. <select id="selectTeacherCount" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherAuditMusicSheetVo">
  828. select
  829. sum(if(t.audit_status_ = 'DOING',1,0)) as doing,
  830. sum(if(t.audit_status_ = 'PASS'
  831. and t.state_ = 1,1,0)) as pass,
  832. sum(if(t.audit_status_ = 'UNPASS',1,0)) as upPass
  833. from
  834. music_sheet t
  835. where t.user_id_ = #{userId}
  836. </select>
  837. <select id="queryStudentTotal" resultType="com.yonge.cooleshow.biz.dal.vo.StudentTotalVo">
  838. select
  839. t.user_id_ as userId,
  840. a.musicAlbumNum,
  841. b.musicSheetNum
  842. from student t
  843. left join (
  844. select
  845. user_id_, count(1) as musicAlbumNum
  846. from album_favorite
  847. <where>
  848. <if test="null != userId">
  849. and user_id_ = #{userId}
  850. </if>
  851. </where>
  852. group by user_id_
  853. ) a on t.user_id_ = a.user_id_
  854. left join (
  855. select
  856. user_id_, count(1) as musicSheetNum
  857. from music_favorite
  858. <where>
  859. <if test="null != userId">
  860. and user_id_ = #{userId}
  861. </if>
  862. </where>
  863. group by user_id_
  864. ) b on t.user_id_ = b.user_id_
  865. <where>
  866. <if test="null != userId">
  867. and t.user_id_ = #{userId}
  868. </if>
  869. </where>
  870. </select>
  871. <select id="queryTeacherTotal" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherTotalVo">
  872. select
  873. t.user_id_ as userId,
  874. a.musicSheetNum as musicSheetNum
  875. from teacher t
  876. left join (
  877. select
  878. user_id_, count(1) as musicSheetNum
  879. from music_sheet
  880. where source_type_ = 'TEACHER' and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0
  881. <if test="null != userId">
  882. and user_id_ = #{userId}
  883. </if>
  884. group by user_id_
  885. ) a on t.user_id_ = a.user_id_
  886. <where>
  887. <if test="null != userId">
  888. and t.user_id_ = #{userId}
  889. </if>
  890. </where>
  891. </select>
  892. <select id="auditDetail" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo">
  893. SELECT
  894. su.username_ as userName
  895. ,su.avatar_ as userAvatar
  896. ,su.real_name_ as realName
  897. ,msar.update_time_ as auditTime
  898. ,msar.create_time_ as submitAuditTime
  899. ,msar.audit_state_ as auditStatus
  900. ,su2.username_ as auditName
  901. ,msar.reason_ as auditReason
  902. ,msar.music_sheet_json_ as musicSheetJson
  903. ,msar.batch_no_ as batchNo
  904. ,msar.id_ as id
  905. from music_sheet_auth_record msar
  906. left join music_sheet t on t.id_ = msar.music_sheet_id_
  907. left join sys_user su on su.id_ = t.create_by_
  908. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  909. WHERE msar.id_ = #{recordId}
  910. </select>
  911. <select id="auditDetailList" resultType="com.yonge.cooleshow.biz.dal.wrapper.MusicSheetWrapper$MusicSheetDetailVo">
  912. SELECT
  913. su.username_ as userName
  914. ,su.avatar_ as userAvatar
  915. ,su.real_name_ as realName
  916. ,msar.update_time_ as auditTime
  917. ,msar.create_time_ as submitAuditTime
  918. ,msar.audit_state_ as auditStatus
  919. ,su2.username_ as auditName
  920. ,msar.reason_ as auditReason
  921. ,msar.music_sheet_json_ as musicSheetJson
  922. ,msar.batch_no_ as batchNo
  923. ,msar.id_ as id
  924. from music_sheet_auth_record msar
  925. left join music_sheet t on t.id_ = msar.music_sheet_id_
  926. left join sys_user su on su.id_ = t.create_by_
  927. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  928. <where>
  929. <if test="batchNo != null and batchNo != ''">
  930. and #{batchNo} = msar.batch_no_
  931. </if>
  932. </where>
  933. order by msar.id_ desc
  934. </select>
  935. <!--单曲专辑数量统计-->
  936. <select id="selectMusicAlbumStatInfo" resultType="com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper">
  937. SELECT t1.music_sheet_id_ AS id, COUNT(DISTINCT t1.id_) AS total
  938. FROM album_music_relate t1 JOIN music_sheet t2 ON (t1.music_sheet_id_ = t2.id_)
  939. <where>
  940. <if test="musicIds != null">
  941. AND t1.music_sheet_id_ IN (<foreach collection="musicIds" separator="," item="item">#{item}</foreach>)
  942. </if>
  943. </where>
  944. GROUP BY t1.music_sheet_id_
  945. </select>
  946. <update id="updateFavoriteCount">
  947. update music_sheet set favorite_count_ =
  948. <choose>
  949. <when test="state.code == 0">
  950. favorite_count_ - 1
  951. </when>
  952. <when test="state.code == 1">
  953. favorite_count_ + 1
  954. </when>
  955. <otherwise>
  956. favorite_count_
  957. </otherwise>
  958. </choose>
  959. where id_ = #{musicSheetId}
  960. </update>
  961. <update id="updateBatchByCbsId">
  962. <foreach collection="vos" item="item" index="index" separator=";">
  963. update music_sheet ms set
  964. ms.music_tag_ = #{item.musicTagIds},ms.payment_type_ = #{item.paymentType},
  965. ms.charge_type_ = #{item.paymentType},
  966. ms.music_price_ = #{item.musicPrice},ms.top_flag_ = #{item.topFlag},
  967. ms.exquisite_flag_ = #{item.exquisiteFlag},ms.sort_number_ = #{item.sortNo},ms.del_flag_ = 0,
  968. ms.audit_status_ = 'PASS',
  969. ms.score_type_ = #{item.scoreType},
  970. ms.state_ = #{item.status},
  971. ms.notation_ = #{item.isConvertibleScore},
  972. ms.provider_type_ = CASE WHEN #{item.availableType} = 'PLATFORM' THEN 'PLATFORM' ELSE 'TENANT' END
  973. <if test="item.musicSheetUpdate != null">
  974. ,ms.music_sheet_name_ = #{item.musicSheetUpdate.name},
  975. ms.music_subject_ = #{item.musicSheetUpdate.subjectIds},
  976. ms.music_svg_ = #{item.musicSheetUpdate.musicSvg},
  977. ms.composer_ = #{item.musicSheetUpdate.composer},
  978. ms.accompaniment_type_ = #{item.musicSheetUpdate.audioType},
  979. ms.play_speed_ = #{item.musicSheetUpdate.playSpeed},
  980. ms.notation_ = #{item.musicSheetUpdate.notation},
  981. ms.music_sheet_type_ = #{item.musicSheetUpdate.musicSheetType},
  982. ms.create_by_ = #{item.musicSheetUpdate.userId},
  983. ms.audio_type_ = #{item.musicSheetUpdate.playMode},
  984. ms.show_fingering_ = #{item.musicSheetUpdate.showFingering},
  985. ms.can_evaluate_ = #{item.musicSheetUpdate.canEvaluate},
  986. ms.is_all_subject_ = #{item.musicSheetUpdate.isAllSubject},
  987. ms.source_type_ = CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  988. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER' ELSE 'TENANT' END,
  989. ms.first_pass_audit_time_ = IF(#{item.musicSheetUpdate.sourceType} = 'PERSON' and ms.first_pass_audit_time_ is null, now(), ms.first_pass_audit_time_)
  990. </if>
  991. where ms.cbs_music_sheet_id_ = #{item.musicSheetId}
  992. </foreach>
  993. </update>
  994. <update id="batchEnable">
  995. update music_sheet
  996. <set>
  997. <if test="tenantFlag == 1">
  998. tenant_state_ = #{status},
  999. </if>
  1000. <if test="tenantFlag == 0">
  1001. client_state_ = #{status}
  1002. </if>
  1003. </set>
  1004. where FIND_IN_SET(cbs_music_sheet_id_,#{ids})
  1005. </update>
  1006. <update id="batchDel">
  1007. update music_sheet
  1008. <set>
  1009. <if test="tenantFlag == 1">
  1010. tenant_del_flag_ = 1,
  1011. </if>
  1012. <if test="tenantFlag == 0">
  1013. del_flag_ = 1
  1014. </if>
  1015. </set>
  1016. where FIND_IN_SET(cbs_music_sheet_id_,#{ids})
  1017. </update>
  1018. <update id="updateMusicSheet">
  1019. update music_sheet
  1020. set music_sheet_name_ = #{param.name},music_subject_ = #{param.subjectIds},music_svg_ = #{param.musicSvg},
  1021. composer_ = #{param.composer},title_img_ = #{param.musicCover},music_img_ = #{param.musicCover},accompaniment_type_ = #{param.audioType},
  1022. play_speed_ = #{param.playSpeed},is_all_subject_ = #{param.isAllSubject},platform_state_ = #{param.platformStatus},
  1023. music_sheet_type_ = #{param.musicSheetType},source_type_ = CASE WHEN #{param.sourceType} = 'PLATFORM' THEN 'PLATFORM' ELSE 'TEACHER' END,
  1024. create_by_ = #{param.userId},tenant_category_id_ = #{param.musicCategoryId}
  1025. where cbs_music_sheet_id_ = #{param.id}
  1026. </update>
  1027. <select id="countByUser" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetUploadCountVo">
  1028. select user_id_ userId, count(id_) count
  1029. from music_sheet
  1030. where del_flag_ = false and state_ =1 and source_type_ = 'TEACHER' and user_id_ in
  1031. <foreach collection="userIds" open="(" close=")" separator="," item="item">
  1032. #{item}
  1033. </foreach>
  1034. group by user_id_
  1035. </select>
  1036. <select id="searchMusic" resultType="java.lang.Long">
  1037. select t.id_ from music_sheet t
  1038. <if test="param.tenantAlbumIds != null and param.tenantAlbumIds.size() != 0">
  1039. left join tenant_album_music tam on t.id_ = tam.music_sheet_id_
  1040. </if>
  1041. <where>
  1042. <if test="param.subjectId != null">
  1043. and ( t.music_subject_ = #{param.subjectId} or t.music_subject_ is null or t.music_subject_ = '' OR t.is_all_subject_)
  1044. </if>
  1045. <if test="param.name != null and param.name != ''">
  1046. and t.music_sheet_name_ like concat('%',#{param.name},'%')
  1047. </if>
  1048. <if test="param.tenantAlbumIds != null and param.tenantAlbumIds.size() != 0">
  1049. and tam.tenant_album_id_ in
  1050. <foreach collection="param.tenantAlbumIds" item="item" open="(" close=")" separator=",">
  1051. #{item}
  1052. </foreach>
  1053. and tam.del_flag_=0
  1054. and tam.subject_type_ in ('ENSEMBLE', 'MUSIC', 'SUBJECT')
  1055. </if>
  1056. <if test="param.providerType != null">
  1057. and find_in_set(#{param.providerType},t.provider_type_)
  1058. <if test="param.providerType != null">
  1059. <if test="param.providerType.code == 'TENANT'">
  1060. and t.tenant_state_ = true and t.tenant_del_flag_ = 0
  1061. </if>
  1062. <if test="param.providerType.code == 'PLATFORM'">
  1063. and t.state_=1 and t.audit_version_ = 0 and t.del_flag_ = 0 and t.audit_status_ = 'PASS'
  1064. </if>
  1065. </if>
  1066. </if>
  1067. </where>
  1068. order by t.top_flag_ desc, t.sort_number_ desc, t.favorite_count_ desc
  1069. </select>
  1070. <select id="searchAlbum" resultType="java.lang.Long">
  1071. select id_ from music_album t
  1072. <where>
  1073. t.album_status_=1 and del_flag_=0 and audit_version_ = 0
  1074. <if test="param.subjectId != null">
  1075. and ( t.subject_id_ = #{param.subjectId} or t.subject_id_ is null or t.subject_id_ = '')
  1076. </if>
  1077. <if test="param.name != null and param.name != ''">
  1078. and t.album_name_ like concat('%',#{param.name},'%')
  1079. </if>
  1080. </where>
  1081. order by t.sort_number_ desc
  1082. </select>
  1083. <select id="personOwnerList"
  1084. resultType="com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetExtendWrapper$MusicSheetExtend">
  1085. select su.id_ userId,su.username_ username
  1086. ,'TEACHER' clientType,su.phone_ phone from teacher t
  1087. left join sys_user su ON su.id_ = t.user_id_
  1088. where su.user_type_ LIKE '%TEACHER%' AND su.del_flag_ = 0 AND su.lock_flag_ = 0 AND t.lock_flag_ = 0
  1089. <if test="param.name != null and param.name != ''">
  1090. AND (su.phone_ LIKE CONCAT('%',#{param.name},'%') OR su.username_ LIKE CONCAT('%',#{param.name},'%'))
  1091. </if>
  1092. <if test="param.userIdList != null and param.userIdList.size > 0">
  1093. AND su.id_ IN
  1094. <foreach collection="param.userIdList" item="item" open="(" close=")" separator=",">
  1095. #{item}
  1096. </foreach>
  1097. </if>
  1098. </select>
  1099. <select id="orgOwnerList"
  1100. resultType="com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetExtendWrapper$MusicSheetExtend">
  1101. select id_ organizationRoleId,name_ organizationRole,'ORG' clientType,phone_ phone from tenant_info where enable_flag_ = 1
  1102. <if test="param.name != null and param.name != ''">
  1103. AND (phone_ LIKE CONCAT('%',#{param.name},'%') OR name_ LIKE CONCAT('%',#{param.name},'%'))
  1104. </if>
  1105. <if test="param.userIdList != null and param.userIdList.size > 0">
  1106. AND id_ IN
  1107. <foreach collection="param.userIdList" item="item" open="(" close=")" separator=",">
  1108. #{item}
  1109. </foreach>
  1110. </if>
  1111. </select>
  1112. <select id="get" resultType="com.yonge.cooleshow.biz.dal.entity.MusicSheet">
  1113. select <include refid="Base_Column_List"/>
  1114. from music_sheet t
  1115. where t.id_ = #{id}
  1116. </select>
  1117. <select id="selectSyncPage" resultType="com.yonge.cooleshow.biz.dal.entity.MusicSheet">
  1118. select *
  1119. from music_sheet
  1120. where del_flag_ = 0 and audit_status_ = 'PASS' and cbs_music_sheet_id_ is null
  1121. </select>
  1122. <select id="queryTenantRelatedList" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  1123. select
  1124. <include refid="Base_Column_List"/>
  1125. from music_sheet t
  1126. left join tenant_album_music t1 on t1.music_sheet_id_ = t.id_
  1127. <where>
  1128. t.tenant_del_flag_ = 0 and t.tenant_state_ =1 and t.cbs_music_sheet_id_ is not null
  1129. and t1.del_flag_=0 and t1.subject_type_ in ('ENSEMBLE', 'MUSIC', 'SUBJECT')
  1130. <if test="queryInfo.albumId != null">
  1131. and t1.tenant_album_id_ = #{queryInfo.albumId}
  1132. </if>
  1133. <if test="queryInfo.albumId == null">
  1134. and 1=2
  1135. </if>
  1136. <if test="queryInfo.musicSheetId != null">
  1137. and t.id_ != #{queryInfo.musicSheetId}
  1138. </if>
  1139. <if test="queryInfo.subjectId != null">
  1140. and find_in_set(#{queryInfo.subjectId},t.music_subject_)
  1141. </if>
  1142. <if test="queryInfo.musicSheetType != null">
  1143. and t.music_sheet_type_ = #{queryInfo.musicSheetType}
  1144. </if>
  1145. </where>
  1146. </select>
  1147. <select id="countTeacherEnable" resultType="int">
  1148. select count(1)
  1149. from music_sheet
  1150. where state_ = 1 and del_flag_ = 0 and source_type_ = 'TEACHER' and create_by_ = #{userId}
  1151. </select>
  1152. <update id="updateTenantByCbsId">
  1153. update music_sheet ms set
  1154. ms.tenant_sort_number_ = #{item.sortNo},ms.tenant_del_flag_ = 0,
  1155. ms.tenant_score_type_ = #{item.scoreType},
  1156. ms.audit_status_ = 'PASS',
  1157. ms.tenant_state_ = #{item.status},
  1158. ms.tenant_notation_ = #{item.isConvertibleScore},
  1159. ms.provider_type_ = CASE WHEN ms.provider_type_ is null or ms.provider_type_ = '' THEN 'TENANT'
  1160. when find_in_set('TENANT',ms.provider_type_) then ms.provider_type_
  1161. else concat(ms.provider_type_,',','TENANT') end
  1162. <if test="item.musicSheetUpdate != null">
  1163. ,ms.music_sheet_name_ = #{item.musicSheetUpdate.name},
  1164. ms.music_subject_ = #{item.musicSheetUpdate.subjectIds},
  1165. ms.music_svg_ = #{item.musicSheetUpdate.musicSvg},
  1166. ms.composer_ = #{item.musicSheetUpdate.composer},
  1167. ms.accompaniment_type_ = #{item.musicSheetUpdate.audioType},
  1168. ms.play_speed_ = #{item.musicSheetUpdate.playSpeed},
  1169. ms.music_sheet_type_ = #{item.musicSheetUpdate.musicSheetType},
  1170. ms.create_by_ = #{item.musicSheetUpdate.userId},
  1171. ms.audio_type_ = #{item.musicSheetUpdate.playMode},
  1172. ms.tenant_category_id_ = #{item.musicSheetUpdate.musicCategoryId},
  1173. ms.show_fingering_ = #{item.musicSheetUpdate.showFingering},
  1174. ms.can_evaluate_ = #{item.musicSheetUpdate.canEvaluate},
  1175. ms.alias_ = #{item.musicSheetUpdate.alias},
  1176. ms.sort_num_ = #{item.musicSheetUpdate.sortNum},
  1177. ms.sort_group_ = #{item.musicSheetUpdate.sortGroup},
  1178. ms.sort_num2_ = #{item.musicSheetUpdate.sortNum2},
  1179. ms.upload_time_ = #{item.musicSheetUpdate.createTime},
  1180. ms.source_type_ = CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  1181. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER' ELSE 'TENANT' END
  1182. </if>
  1183. where ms.cbs_music_sheet_id_ = #{item.musicSheetId}
  1184. </update>
  1185. <update id="updatePlatformByCbsId">
  1186. update music_sheet ms set
  1187. ms.music_tag_ = #{item.musicTagIds},ms.payment_type_ = #{item.paymentType},
  1188. ms.first_pass_audit_time_ = IF((#{item.musicSheetUpdate.sourceType} = 'PERSON' and ms.first_pass_audit_time_ is null) or !find_in_set('PLATFORM',ms.provider_type_),
  1189. now(), ms.first_pass_audit_time_),
  1190. ms.charge_type_ = #{item.paymentType},
  1191. ms.music_price_ = #{item.musicPrice},ms.top_flag_ = #{item.topFlag},
  1192. ms.exquisite_flag_ = #{item.exquisiteFlag},ms.sort_number_ = #{item.sortNo},ms.del_flag_ = 0,
  1193. ms.audit_status_ = 'PASS',
  1194. ms.score_type_ = #{item.scoreType},
  1195. ms.state_ = #{item.status},
  1196. ms.client_state_ = #{item.clientStatus},
  1197. ms.notation_ = #{item.isConvertibleScore},
  1198. ms.provider_type_ = CASE WHEN ms.provider_type_ is null or ms.provider_type_ = '' THEN 'PLATFORM'
  1199. when find_in_set('PLATFORM',ms.provider_type_) then ms.provider_type_
  1200. else concat(ms.provider_type_,',','PLATFORM') end
  1201. <if test="item.musicSheetUpdate != null">
  1202. ,ms.music_sheet_name_ = #{item.musicSheetUpdate.name}
  1203. ,ms.platform_state_ = #{item.musicSheetUpdate.platformStatus},
  1204. ms.music_subject_ = #{item.musicSheetUpdate.subjectIds},
  1205. ms.music_svg_ = #{item.musicSheetUpdate.musicSvg},
  1206. ms.composer_ = #{item.musicSheetUpdate.composer},
  1207. ms.accompaniment_type_ = #{item.musicSheetUpdate.audioType},
  1208. ms.play_speed_ = #{item.musicSheetUpdate.playSpeed},
  1209. ms.notation_ = #{item.musicSheetUpdate.notation},
  1210. ms.music_sheet_type_ = #{item.musicSheetUpdate.musicSheetType},
  1211. ms.create_by_ = #{item.musicSheetUpdate.userId},
  1212. ms.audio_type_ = #{item.musicSheetUpdate.playMode},
  1213. ms.show_fingering_ = #{item.musicSheetUpdate.showFingering},
  1214. ms.can_evaluate_ = #{item.musicSheetUpdate.canEvaluate},
  1215. ms.alias_ = #{item.musicSheetUpdate.alias},
  1216. ms.sort_num_ = #{item.musicSheetUpdate.sortNum},
  1217. ms.sort_group_ = #{item.musicSheetUpdate.sortGroup},
  1218. ms.sort_num2_ = #{item.musicSheetUpdate.sortNum2},
  1219. ms.source_type_ = CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  1220. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER' ELSE 'TENANT' END
  1221. </if>
  1222. where ms.cbs_music_sheet_id_ = #{item.musicSheetId}
  1223. </update>
  1224. <insert id="tenantInsert">
  1225. insert into music_sheet
  1226. (cbs_music_sheet_id_,tenant_sort_number_,tenant_score_type_,tenant_state_,tenant_notation_,tenant_category_id_,tenant_del_flag_
  1227. ,music_sheet_name_,music_subject_,music_svg_,composer_,accompaniment_type_,play_speed_,
  1228. music_sheet_type_,provider_type_,audio_type_,show_fingering_,
  1229. can_evaluate_,create_by_,user_id_,audit_status_,upload_time_,source_type_
  1230. )
  1231. values
  1232. (#{item.musicSheetId},
  1233. #{item.sortNo},#{item.scoreType},#{item.status},#{item.isConvertibleScore}
  1234. ,#{item.musicSheetUpdate.musicCategoryId}
  1235. ,#{item.delFlag}
  1236. ,#{item.musicSheetUpdate.name},
  1237. #{item.musicSheetUpdate.subjectIds},
  1238. #{item.musicSheetUpdate.musicSvg},
  1239. #{item.musicSheetUpdate.composer},
  1240. #{item.musicSheetUpdate.audioType},
  1241. #{item.musicSheetUpdate.playSpeed},
  1242. #{item.musicSheetUpdate.musicSheetType},
  1243. 'TENANT',
  1244. #{item.musicSheetUpdate.playMode},
  1245. #{item.musicSheetUpdate.showFingering},
  1246. #{item.musicSheetUpdate.canEvaluate},
  1247. #{item.musicSheetUpdate.userId},
  1248. #{item.musicSheetUpdate.userId},
  1249. 'PASS',
  1250. #{item.musicSheetUpdate.createTime},
  1251. CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  1252. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER'
  1253. ELSE 'TENANT' END
  1254. )
  1255. </insert>
  1256. <insert id="platformInsert">
  1257. insert into music_sheet
  1258. (cbs_music_sheet_id_,music_tag_,payment_type_,charge_type_,top_flag_,exquisite_flag_,sort_number_,state_,audit_status_
  1259. ,music_sheet_name_,music_subject_,music_svg_,composer_,accompaniment_type_,play_speed_,
  1260. music_price_,notation_,music_sheet_type_,source_type_,provider_type_,audio_type_,show_fingering_,
  1261. can_evaluate_,create_by_,user_id_,score_type_,platform_state_,client_state_,first_pass_audit_time_
  1262. )
  1263. values
  1264. (#{item.musicSheetId},
  1265. #{item.musicTagIds},#{item.paymentType},#{item.paymentType},
  1266. #{item.topFlag},#{item.exquisiteFlag},#{item.sortNo},#{item.status}
  1267. ,'PASS'
  1268. ,#{item.musicSheetUpdate.name},
  1269. #{item.musicSheetUpdate.subjectIds},
  1270. #{item.musicSheetUpdate.musicSvg},
  1271. #{item.musicSheetUpdate.composer},
  1272. #{item.musicSheetUpdate.audioType},
  1273. #{item.musicSheetUpdate.playSpeed},
  1274. #{item.musicSheetUpdate.musicPrice},
  1275. #{item.isConvertibleScore},
  1276. #{item.musicSheetUpdate.musicSheetType},
  1277. CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  1278. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER'
  1279. ELSE 'TENANT' END,
  1280. 'PLATFORM',
  1281. #{item.musicSheetUpdate.playMode},
  1282. #{item.musicSheetUpdate.showFingering},
  1283. #{item.musicSheetUpdate.canEvaluate},
  1284. #{item.musicSheetUpdate.userId},#{item.musicSheetUpdate.userId},
  1285. #{item.scoreType},
  1286. #{item.musicSheetUpdate.platformStatus},
  1287. #{item.clientStatus},
  1288. now()
  1289. )
  1290. </insert>
  1291. <update id="updateState">
  1292. update music_sheet
  1293. set state_ = client_state_ and platform_state_
  1294. where FIND_IN_SET(cbs_music_sheet_id_,#{ids})
  1295. </update>
  1296. <update id="delPractice">
  1297. update sys_music_compare_record
  1298. set hidden_flag_ = 1
  1299. where user_id_ = #{userId} and music_sheet_id_ = #{musicSheetId} and client_id_ = #{clientEnum}
  1300. </update>
  1301. <update id="updateExposureNum">
  1302. update music_sheet
  1303. set exposure_num_ = exposure_num_ + #{exposureNum}
  1304. where id_ = #{musicSheetId}
  1305. </update>
  1306. <select id="musicSheetTotal"
  1307. resultType="com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper$MusicSheetTotal">
  1308. select
  1309. if(t.audit_status_ = 'PASS' and t.state_ = 1,1,0) as musicSheetNum,
  1310. if(t.audit_status_ = 'DOING' ,1,0) musicSheetAuditNum,
  1311. t.exposure_num_ musicSheetExposureNum
  1312. from music_sheet t
  1313. where t.del_flag_=0 and t.user_id_ = #{teacherId}
  1314. </select>
  1315. <select id="musicSheetPage"
  1316. resultType="com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper$MusicSheetTotal">
  1317. select
  1318. t.music_sheet_name_ musicSheetName,
  1319. t.create_time_ createTime,
  1320. t.exposure_num_ musicSheetExposureNum,
  1321. count(distinct t1.buy_user_) musicSheetPayNum,
  1322. sum(t1.trans_amount_) as musicSheetIncome
  1323. from music_sheet t
  1324. left join user_cash_account_record t1 on t.id_ = t1.biz_id_
  1325. where t1.account_id_ = #{param.teacherId}
  1326. and t1.biz_type_ = 'MUSIC_SHARE'
  1327. and t1.post_status_ = 'RECORDED'
  1328. and t1.in_or_out_ = 'IN'
  1329. and t.del_flag_=0 and t.user_id_ = #{param.teacherId}
  1330. group by t.id_
  1331. order by t.create_time_ desc
  1332. limit #{param.rows}
  1333. </select>
  1334. <select id="cloudPage" resultType="com.yonge.cooleshow.biz.dal.wrapper.MusicSheetWrapper$MusicSheetCloud">
  1335. select t.id_, t.music_sheet_name_,t.title_img_,t.composer_,t.cbs_music_sheet_id_ ,t.payment_type_,t.music_price_ as musicPrice
  1336. from (
  1337. select a.* from
  1338. music_sheet a
  1339. <if test="param.providerType != null and param.providerType.code == 'TENANT'">
  1340. left join tenant_album_music tam on a.id_ = tam.music_sheet_id_ and tam.del_flag_ = 0 and tam.tenant_album_id_ in
  1341. <foreach collection="param.tenantAlbumIds" item="item" open="(" close=")" separator=",">
  1342. #{item}
  1343. </foreach>
  1344. </if>
  1345. <where>
  1346. a.cbs_music_sheet_id_ is not null
  1347. <if test="param.providerType != null and param.providerType.code == 'TENANT'">
  1348. and tam.id_ is not null
  1349. </if>
  1350. <if test="param.name != null and param.name != ''">
  1351. and a.music_sheet_name_ like concat('%',#{param.name},'%')
  1352. </if>
  1353. <if test="param.status != null">
  1354. <if test="param.providerType != null">
  1355. <if test="param.providerType.code == 'TENANT'">
  1356. and a.tenant_state_ = #{param.status}
  1357. </if>
  1358. <if test="param.providerType.code == 'PLATFORM'">
  1359. and a.state_ = #{param.status}
  1360. </if>
  1361. </if>
  1362. <if test="param.providerType == null">
  1363. and a.state_ = #{param.status}
  1364. </if>
  1365. </if>
  1366. <if test="param.delFlag != null">
  1367. <if test="param.providerType != null">
  1368. <if test="param.providerType.code == 'TENANT'">
  1369. and a.tenant_del_flag_ = #{param.delFlag}
  1370. </if>
  1371. <if test="param.providerType.code == 'PLATFORM'">
  1372. and a.del_flag_ = #{param.delFlag}
  1373. </if>
  1374. </if>
  1375. <if test="param.providerType == null">
  1376. and a.del_flag_ = #{param.delFlag}
  1377. </if>
  1378. </if>
  1379. <if test="param.versionFlag != null">
  1380. and a.audit_version_ = #{param.versionFlag}
  1381. </if>
  1382. <if test="param.mustMatchSubjectIds != null and param.mustMatchSubjectIds.size() != 0">
  1383. and
  1384. <foreach collection="param.mustMatchSubjectIds" separator="and" item="item" open="(" close=")">
  1385. find_in_set(#{item},a.music_subject_)
  1386. </foreach>
  1387. </if>
  1388. <if test="param.excludeMusicId != null">
  1389. and a.id_ != #{param.excludeMusicId}
  1390. </if>
  1391. <if test="param.ids != null and param.ids.size() != 0">
  1392. and a.id_ in
  1393. <foreach collection="param.ids" item="item" open="(" close=")" separator=",">
  1394. #{item}
  1395. </foreach>
  1396. </if>
  1397. <if test="param.providerType != null and param.providerType.code == 'TENANT'">
  1398. <if test="param.albumId != null">
  1399. and tam.tenant_album_id_ = #{param.albumId}
  1400. and tam.subject_type_ in ('ENSEMBLE', 'MUSIC', 'SUBJECT')
  1401. </if>
  1402. <if test="param.albumId == null and (param.recentFlag == null or param.recentFlag == 0) and (param.favoriteFlag == null or param.favoriteFlag == 0)">
  1403. and 1=2
  1404. </if>
  1405. </if>
  1406. <if test="param.providerType != null">
  1407. and find_in_set(#{param.providerType},a.provider_type_)
  1408. </if>
  1409. <if test="param.musicSheetType != null">
  1410. and a.music_sheet_type_ = #{param.musicSheetType}
  1411. </if>
  1412. <if test="param.subjectId != null">
  1413. and (find_in_set(#{param.subjectId},a.music_subject_)or a.music_subject_ is null or a.music_subject_ = '' OR a.is_all_subject_)
  1414. </if>
  1415. <if test="param.musicTagIdList != null and param.musicTagIdList.size() >0">
  1416. and
  1417. <foreach collection="param.musicTagIdList" open="(" close=")" separator="or" item="item">
  1418. find_in_set(#{item},a.music_tag_)
  1419. </foreach>
  1420. </if>
  1421. </where>
  1422. ) t
  1423. <if test="param.recentFlag != null and param.recentFlag == 1">
  1424. left join sys_music_compare_record msar on t.id_ = msar.music_sheet_id_ and msar.provider_type_ = #{param.providerType}
  1425. </if>
  1426. <if test="param.albumId != null and param.providerType.code == 'TENANT'">
  1427. left join tenant_album_music tam on t.id_ = tam.music_sheet_id_ and tam.del_flag_ = 0 and tam.tenant_album_id_ = #{param.albumId}
  1428. </if>
  1429. <if test="param.albumId != null and param.providerType.code == 'PLATFORM'">
  1430. left join album_music_relate amr on t.id_ = amr.music_sheet_id_ and amr.album_id_ = #{param.albumId}
  1431. </if>
  1432. <if test="param.favoriteFlag != null and param.favoriteFlag == 1">
  1433. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mf.user_id_ = #{param.userId} and mf.client_type_ = #{param.clientType} and mf.provider_type_ = #{param.providerType}
  1434. </if>
  1435. <where>
  1436. <if test="param.favoriteFlag != null and param.favoriteFlag == 1">
  1437. and mf.id_ is not null
  1438. </if>
  1439. <if test="param.recentFlag != null and param.recentFlag == 1">
  1440. <if test="param.userId != null">
  1441. and msar.user_id_ = #{param.userId}
  1442. </if>
  1443. <if test="param.clientType != null and param.clientType != ''">
  1444. and msar.client_id_ = #{param.clientType}
  1445. </if>
  1446. </if>
  1447. <if test="param.providerType != null and param.providerType.code == 'PLATFORM'">
  1448. <if test="param.albumId != null">
  1449. and amr.id_ is not null
  1450. </if>
  1451. </if>
  1452. </where>
  1453. GROUP BY t.id_
  1454. order by
  1455. <if test="param.recentFlag !=null and param.recentFlag == true">
  1456. max(msar.create_time_) desc,
  1457. </if>
  1458. <if test="param.favoriteFlag != null and param.favoriteFlag == 1">
  1459. mf.id_ desc,
  1460. </if>
  1461. t.sort_group_, t.sort_num_, t.sort_num2_, t.alias_
  1462. </select>
  1463. <select id="musicSheetTotal"
  1464. resultType="com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper$MusicSheetTotal">
  1465. select
  1466. if(t.audit_status_ = 'PASS' and t.state_ = 1,1,0) as musicSheetNum,
  1467. if(t.audit_status_ = 'DOING' ,1,0) musicSheetAuditNum,
  1468. t.exposure_num_ musicSheetExposureNum
  1469. from music_sheet t
  1470. where t.del_flag_=0 and t.user_id_ = #{teacherId}
  1471. </select>
  1472. <select id="musicSheetPage"
  1473. resultType="com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper$MusicSheetTotal">
  1474. select
  1475. t.music_sheet_name_ musicSheetName,
  1476. t.create_time_ createTime,
  1477. t.exposure_num_ musicSheetExposureNum,
  1478. count(distinct t1.buy_user_) musicSheetPayNum,
  1479. sum(t1.trans_amount_) as musicSheetIncome
  1480. from music_sheet t
  1481. left join user_cash_account_record t1 on t.id_ = t1.biz_id_
  1482. where t1.account_id_ = #{param.teacherId}
  1483. and t1.biz_type_ = 'MUSIC_SHARE'
  1484. and t1.post_status_ = 'RECORDED'
  1485. and t1.in_or_out_ = 'IN'
  1486. and t.del_flag_=0 and t.user_id_ = #{param.teacherId}
  1487. group by t.id_
  1488. order by t.create_time_ desc
  1489. limit #{param.rows}
  1490. </select>
  1491. <select id="selectMusicAlbumNum" resultType="java.lang.Long">
  1492. SELECT COUNT(DISTINCT t1.id_) AS total
  1493. FROM album_music_relate t1 JOIN music_sheet t2 ON (t1.music_sheet_id_ = t2.id_)
  1494. WHERE t1.music_sheet_id_ = #{musicId}
  1495. </select>
  1496. <!--单曲专辑数量统计-->
  1497. </mapper>