MusicSheetMapper.xml 70 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488
  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. ,amr.sort_number_ as albumSortNumber
  318. from music_sheet t
  319. left join album_music_relate amr on t.id_ = amr.music_sheet_id_
  320. left join sys_user su on t.create_by_ = su.id_
  321. <where>
  322. t.cbs_music_sheet_id_ IS NOT NULL and find_in_set('PLATFORM',t.provider_type_)
  323. <if test="param.composer != null">
  324. AND t.composer_ LIKE '%${param.composer}%'
  325. </if>
  326. <if test="param.providerType != null">
  327. and find_in_set(#{param.providerType},t.provider_type_)
  328. </if>
  329. <if test="param.idAndName != null and param.idAndName != ''">
  330. and (t.id_ like concat('%',#{param.idAndName},'%') or
  331. t.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  332. </if>
  333. <if test="param.search != null and param.search != ''">
  334. and (t.cbs_music_sheet_id_ like concat('%',#{param.search},'%') or
  335. t.music_sheet_name_ like concat('%',#{param.search},'%'))
  336. </if>
  337. <if test="param.chargeType != null">
  338. and t.charge_type_ = #{param.chargeType}
  339. </if>
  340. <if test="param.excludeMusicIds != null and param.excludeMusicIds.size() != 0">
  341. and t.id_ not in
  342. <foreach collection="param.excludeMusicIds" separator="," item="item" open="(" close=")">
  343. #{item}
  344. </foreach>
  345. </if>
  346. <if test="param.musicTagIds != null and param.musicTagIds != ''">
  347. and
  348. <foreach collection="param.musicTagIdList" separator="or" item="item" open="(" close=")" >
  349. find_in_set(#{item},t.music_tag_)
  350. </foreach>
  351. </if>
  352. <if test="param.subjectIdList != null and param.subjectIdList.size() != 0">
  353. and
  354. <foreach collection="param.subjectIdList" separator="or" item="item" open="(" close=")" >
  355. find_in_set(#{item},t.music_subject_)
  356. </foreach>
  357. </if>
  358. <if test="param.musicSheetType != null">
  359. and t.music_sheet_type_ = #{param.musicSheetType}
  360. </if>
  361. <if test="param.state != null">
  362. and t.state_ = #{param.state}
  363. </if>
  364. <if test="param.delFlag != null">
  365. and t.del_flag_ = #{param.delFlag}
  366. </if>
  367. <if test="param.sourceType != null">
  368. AND t.source_type_ = #{param.sourceType}
  369. </if>
  370. <if test="param.chargeType != null">
  371. AND (t.payment_type_ = 'FREE' OR FIND_IN_SET(#{param.chargeType}, t.payment_type_))
  372. </if>
  373. <if test="param.paymentTypes != null">
  374. AND t.payment_type_ IN (<foreach collection="param.paymentTypes" separator="," item="item">#{item}</foreach>)
  375. </if>
  376. <if test="param.id != null">
  377. <if test="param.type == 2">
  378. and amr.album_id_ = #{param.id}
  379. order by amr.sort_number_ desc,
  380. t.sort_group_, t.sort_num_, t.sort_num2_, t.alias_
  381. </if>
  382. <if test="param.type == 1">
  383. and t.id_ not in(select amr2.music_sheet_id_ from album_music_relate amr2
  384. where amr2.album_id_ = #{param.id})
  385. ORDER BY t.sort_group_, t.sort_num_, t.sort_num2_, t.alias_
  386. </if>
  387. </if>
  388. <if test="param.id == null">
  389. ORDER BY t.sort_group_, t.sort_num_, t.sort_num2_, t.alias_
  390. </if>
  391. </where>
  392. </select>
  393. <select id="detail" resultMap="DetailResultMap">
  394. SELECT
  395. <include refid="Base_Column_List"/>
  396. ,t.url_ as url
  397. ,t.midi_url_ as midiUrl
  398. ,t.metronome_url_ as metronomeUrl
  399. ,msa.id_ as accompanimentId
  400. ,msa.music_sheet_id_ as accompanimentMusicSheetId
  401. ,msa.audio_file_url_ as accompanimentAudioFileUrl
  402. ,msa.sort_number_ as accompanimentSortNumber
  403. ,msa.create_time_ as accompanimentCreateTime
  404. ,msa.track_ as track
  405. ,msa.musical_instrument_id_ as musicalInstrumentId
  406. ,su.username_ as userName
  407. ,su.avatar_ as userAvatar
  408. ,(
  409. select group_concat(mt.name_) from music_tag mt
  410. where find_in_set(mt.id_,t.music_tag_)
  411. and mt.del_flag_ = 0 and mt.state_ = 1
  412. ) as musicTagNames
  413. ,s2.name_ as subjectNames
  414. ,s2.code_ as code
  415. ,su.real_name_ as realName
  416. ,s2.ai_default_frequency_ as aiDefaultFrequency
  417. FROM music_sheet t
  418. left join music_sheet_accompaniment msa on msa.music_sheet_id_ = t.id_
  419. left join sys_user su on t.create_by_ = su.id_
  420. left join subject s2 on t.music_subject_ = s2.id_
  421. where t.id_ = #{id} AND t.cbs_music_sheet_id_ IS NOT NULL
  422. order by msa.sort_number_
  423. </select>
  424. <resultMap id="DetailResultMap" type="com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo">
  425. <id column="id" jdbcType="BIGINT" property="id"/>
  426. <result column="musicSheetName" jdbcType="VARCHAR" property="musicSheetName"/>
  427. <result column="userId" jdbcType="BIGINT" property="userId"/>
  428. <result column="cbsMusicSheetId" jdbcType="BIGINT" property="cbsMusicSheetId"/>
  429. <result column="composer" jdbcType="VARCHAR" property="composer"/>
  430. <result column="titleImg" jdbcType="VARCHAR" property="titleImg"/>
  431. <result column="musicSubject" jdbcType="VARCHAR" property="musicSubject"/>
  432. <result column="audioType" jdbcType="VARCHAR" property="audioType"/>
  433. <result column="providerType" jdbcType="VARCHAR" property="providerType"/>
  434. <result column="musicTag" jdbcType="VARCHAR" property="musicTag"/>
  435. <result column="playSpeed" jdbcType="INTEGER" property="playSpeed"/>
  436. <result column="canEvaluate" jdbcType="TINYINT" property="canEvaluate"/>
  437. <result column="showFingering" jdbcType="TINYINT" property="showFingering"/>
  438. <result column="chargeType" jdbcType="TINYINT" property="chargeType"/>
  439. <result column="auditStatus" property="auditStatus"/>
  440. <result column="state" jdbcType="TINYINT" property="state"/>
  441. <result column="sortNumber" jdbcType="INTEGER" property="sortNumber"/>
  442. <result column="topFlag" jdbcType="TINYINT" property="topFlag"/>
  443. <result column="hotFlag" jdbcType="TINYINT" property="hotFlag"/>
  444. <result column="musicPrice" jdbcType="DECIMAL" property="musicPrice"/>
  445. <result column="audioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  446. <result column="musicTagNames" jdbcType="VARCHAR" property="musicTagNames"/>
  447. <result column="subjectNames" jdbcType="VARCHAR" property="subjectNames"/>
  448. <result column="xmlFileUrl" jdbcType="VARCHAR" property="xmlFileUrl"/>
  449. <result column="hasBeat" jdbcType="TINYINT" property="hasBeat"/>
  450. <result column="createTime" jdbcType="TIMESTAMP" property="createTime"/>
  451. <result column="createBy" jdbcType="BIGINT" property="createBy"/>
  452. <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime"/>
  453. <result column="updateBy" jdbcType="BIGINT" property="updateBy"/>
  454. <result column="delFlag" jdbcType="BOOLEAN" property="delFlag"/>
  455. <result column="url" jdbcType="BOOLEAN" property="url"/>
  456. <result column="metronomeUrl" jdbcType="BOOLEAN" property="metronomeUrl"/>
  457. <result column="midiUrl" jdbcType="BOOLEAN" property="midiUrl"/>
  458. <result column="mp3Type" jdbcType="VARCHAR" property="mp3Type"/>
  459. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  460. <result column="userName" jdbcType="VARCHAR" property="userName"/>
  461. <result column="auditVersion" jdbcType="VARCHAR" property="auditVersion"/>
  462. <result column="code" jdbcType="VARCHAR" property="code"/>
  463. <result column="reason" jdbcType="VARCHAR" property="reason"/>
  464. <result column="accompanimentType" jdbcType="VARCHAR" property="accompanimentType"/>
  465. <result column="notation" jdbcType="VARCHAR" property="notation"/>
  466. <result column="musicImg" jdbcType="VARCHAR" property="musicImg"/>
  467. <result column="favoriteCount" jdbcType="VARCHAR" property="favoriteCount"/>
  468. <result column="firstPassAuditTime" jdbcType="VARCHAR" property="firstPassAuditTime"/>
  469. <result column="realName" jdbcType="VARCHAR" property="realName"/>
  470. <result column="auditTime" jdbcType="VARCHAR" property="auditTime"/>
  471. <result column="auditName" jdbcType="VARCHAR" property="auditName"/>
  472. <result column="auditReason" jdbcType="VARCHAR" property="auditReason"/>
  473. <result column="aiDefaultFrequency" jdbcType="VARCHAR" property="aiDefaultFrequency"/>
  474. <result column="musicJSON" jdbcType="VARCHAR" property="musicJSON"/>
  475. <result column="musicSvg" jdbcType="VARCHAR" property="musicSvg"/>
  476. <result column="musicJianSvg" jdbcType="VARCHAR" property="musicJianSvg"/>
  477. <result column="musicFirstSvg" jdbcType="VARCHAR" property="musicFirstSvg"/>
  478. <result column="musicSheetType" jdbcType="VARCHAR" property="musicSheetType"/>
  479. <result column="musicSheetJson" jdbcType="VARCHAR" property="musicSheetJson"/>
  480. <result column="tenantSortNumber" jdbcType="VARCHAR" property="tenantSortNumber"/>
  481. <result column="tenantState" jdbcType="VARCHAR" property="tenantState"/>
  482. <result column="tenantNotation" jdbcType="VARCHAR" property="tenantNotation"/>
  483. <result column="tenantCategoryId" jdbcType="VARCHAR" property="tenantCategoryId"/>
  484. <result column="tenantScoreType" jdbcType="VARCHAR" property="tenantScoreType"/>
  485. <result column="tenantDelFlag" jdbcType="VARCHAR" property="tenantDelFlag"/>
  486. <result column="scoreType" jdbcType="VARCHAR" property="scoreType"/>
  487. <collection property="background" ofType="com.yonge.cooleshow.biz.dal.entity.MusicSheetAccompaniment">
  488. <id column="accompanimentId" jdbcType="BIGINT" property="id"/>
  489. <result column="accompanimentMusicSheetId" jdbcType="BIGINT" property="musicSheetId"/>
  490. <result column="accompanimentMusicSubject" jdbcType="VARCHAR" property="musicSubjectId"/>
  491. <result column="accompanimentAudioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  492. <result column="accompanimentSortNumber" jdbcType="TINYINT" property="sortNumber"/>
  493. <result column="accompanimentCreateTime" jdbcType="TIMESTAMP" property="createTime"/>
  494. <result column="accompanimentMetronomeUrl" jdbcType="VARCHAR" property="metronomeUrl"/>
  495. <result column="track" jdbcType="VARCHAR" property="track"/>
  496. <result column="musicalInstrumentId" jdbcType="VARCHAR" property="musicalInstrumentId"/>
  497. </collection>
  498. </resultMap>
  499. <select id="selectStudentMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  500. select <include refid="Base_Column_List"/>
  501. ,su.username_ as addName
  502. ,su.avatar_ as addUserAvatar
  503. from music_sheet t
  504. left join sys_user su on t.create_by_ = su.id_
  505. <if test="param.auditStatus != null">
  506. left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
  507. </if>
  508. <where>
  509. 1=1
  510. <include refid="QueryInfo"/>
  511. <if test="param.auditVersion != null ">
  512. and #{param.auditVersion} = t.audit_version_
  513. </if>
  514. </where>
  515. <if test="param.auditStatus != null">
  516. group by msar.music_sheet_id_
  517. </if>
  518. order by
  519. <choose>
  520. <when test="param.musicSortType != null and param.musicSortType.code == 'TOP'">
  521. t.top_flag_ desc, t.sort_number_ desc,
  522. </when>
  523. <when test="param.musicSortType != null and param.musicSortType.code == 'HOT'">
  524. t.favorite_count_ desc,
  525. </when>
  526. <when test="param.musicSortType != null and param.musicSortType.code == 'NEW'">
  527. t.first_pass_audit_time_ desc,
  528. </when>
  529. <otherwise>
  530. <if test="param.myself != null and param.myself == true ">
  531. t.cbs_music_sheet_id_ desc,
  532. </if>
  533. </otherwise>
  534. </choose>
  535. t.sort_group_, t.sort_num_, t.sort_num2_, t.alias_
  536. </select>
  537. <select id="selectMyMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  538. select distinct <include refid="Base_Column_List"/>
  539. ,su.username_ as addName
  540. ,su.avatar_ as addUserAvatar
  541. ,(select group_concat(mt.name_) from music_tag mt
  542. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  543. ,(select group_concat(s.name_) from subject s
  544. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  545. ,if(mf.id_ is not null,1,0) as favorite
  546. from music_sheet t
  547. left join sys_user su on t.create_by_ = su.id_
  548. left join music_sheet_purchase_record mspr on mspr.music_sheet_id_ = t.id_
  549. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mspr.student_id_ = mf.user_id_
  550. <if test="param.auditStatus != null">
  551. left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
  552. </if>
  553. <where>
  554. 1=1
  555. <include refid="QueryInfo"/>
  556. <if test="param.studentId != null">
  557. and mspr.student_id_ = #{param.studentId}
  558. and mspr.order_status_ = 'PAID'
  559. </if>
  560. <if test="param.userType != null">
  561. and mspr.client_type_ = #{param.userType}
  562. </if>
  563. <if test="param.purchaseType != null">
  564. AND mspr.purchase_type_ = #{param.purchaseType}
  565. </if>
  566. <if test="param.courseGift != null">
  567. AND mspr.course_music_album_id_ <choose><when test="param.courseGift == 0"> = </when><otherwise> > </otherwise> </choose> 0
  568. </if>
  569. </where>
  570. <if test="param.auditStatus != null">
  571. group by msar.music_sheet_id_
  572. </if>
  573. order by mspr.id_ desc
  574. </select>
  575. <select id="selectFavoriteMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  576. select <include refid="Base_Column_List"/>
  577. ,su.username_ as addName
  578. ,su.avatar_ as addUserAvatar
  579. ,(select group_concat(mt.name_) from music_tag mt
  580. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  581. ,(select group_concat(s.name_) from subject s
  582. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  583. ,if(mf.id_ is not null,1,0) as favorite
  584. from music_sheet t
  585. left join sys_user su on t.create_by_ = su.id_
  586. left join music_favorite mf on t.id_ = mf.music_sheet_id_
  587. <if test="param.auditStatus != null">
  588. left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
  589. </if>
  590. <where>
  591. mf.client_type_ = #{clientType}
  592. <if test="clientType.code == 'STUDENT'">
  593. and t.del_flag_=0 and t.state_ =1 and find_in_set('PLATFORM',t.provider_type_)
  594. </if>
  595. <if test="clientType.code == 'TEACHER'">
  596. and ((t.del_flag_=0 and t.state_ =1 and find_in_set('PLATFORM',t.provider_type_))
  597. <if test="param.tenantId !=null">
  598. or (t.tenant_del_flag_=0 and t.tenant_state_ =1 and find_in_set('TENANT',t.provider_type_)
  599. and t.id_ in (select s.music_sheet_id_ from tenant_album_music s
  600. left join tenant_album s1 on s.tenant_album_id_ = s1.id_ where s.tenant_id_ = #{param.tenantId}
  601. and s.del_flag_ = 0 and s.subject_type_ in ('ENSEMBLE','MUSIC','SUBJECT') and s1.del_flag_= 0 and s1.status_ = 1
  602. )
  603. )
  604. </if>
  605. )
  606. </if>
  607. <if test="param.studentId != null">
  608. and mf.user_id_ = #{param.studentId}
  609. </if>
  610. </where>
  611. <if test="param.auditStatus != null">
  612. group by msar.music_sheet_id_
  613. </if>
  614. order by mf.id_ desc
  615. </select>
  616. <select id="selectPracticeMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  617. select <include refid="Base_Column_List"/>
  618. ,su.username_ as addName
  619. ,su.avatar_ as addUserAvatar
  620. ,(select group_concat(mt.name_) from music_tag mt
  621. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  622. ,(select group_concat(s.name_) from subject s where find_in_set(s.id_,t.music_subject_) ) as subjectNames
  623. ,if(mf.id_ is not null,1,0) as favorite
  624. from sys_music_compare_record mspr
  625. left join music_sheet t on mspr.music_sheet_id_ = t.id_
  626. <if test="param.auditStatus != null">
  627. left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
  628. </if>
  629. left join sys_user su on t.create_by_ = su.id_
  630. 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> )
  631. <where>
  632. 1=1
  633. <include refid="QueryInfo"/>
  634. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  635. and mspr.id_ in
  636. <foreach collection="practiceMusicIdList" item="item" open="(" close=")" separator=",">
  637. #{item}
  638. </foreach>
  639. </if>
  640. </where>
  641. <if test="param.auditStatus != null">
  642. group by msar.music_sheet_id_
  643. </if>
  644. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  645. order by field(mspr.id_,
  646. <foreach collection="practiceMusicIdList" item="item" separator=",">
  647. #{item}
  648. </foreach>
  649. </if>
  650. )
  651. </select>
  652. <select id="selectStudentOrderPage" resultType="com.yonge.cooleshow.biz.dal.vo.StudentMusicSheetOrderVo">
  653. select distinct mspr.music_sheet_id_ as musicSheetId
  654. ,ms.music_sheet_name_ as musicSheetName
  655. ,ms.composer_ as composer
  656. ,ms.title_img_ as titleImg
  657. ,ms.music_tag_ as musicTag
  658. ,(select group_concat(mt.name_) from music_tag mt
  659. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  660. ,mspr.purchase_price_ as purchasePrice
  661. ,mspr.order_no_ as orderNo
  662. ,mspr.purchase_time_ as purchaseTime
  663. from music_sheet_purchase_record mspr
  664. left join music_sheet ms on mspr.music_sheet_id_ = ms.id_
  665. <where>
  666. mspr.order_status_ = 'PAID' and mspr.purchase_type_ = 'MUSIC'
  667. <if test="param.idAndName != null and param.idAndName != ''">
  668. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  669. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  670. </if>
  671. <if test="param.studentId != null">
  672. and mspr.student_id_ = #{param.studentId}
  673. </if>
  674. <if test="param.orderNo != null and param.orderNo != ''">
  675. and mspr.order_no_ = #{param.orderNo}
  676. </if>
  677. <if test="param.musicTagList != null and param.musicTagList.size() != 0">
  678. and
  679. <foreach collection="param.musicTagList" separator="or" item="item" open="(" close=")" >
  680. find_in_set(#{item},ms.music_tag_)
  681. </foreach>
  682. </if>
  683. <if test="param.startTime != null">
  684. and mspr.purchase_time_ &gt; #{param.startTime}
  685. </if>
  686. <if test="param.endTime != null">
  687. and mspr.purchase_time_ &lt; #{param.endTime}
  688. </if>
  689. </where>
  690. order by mspr.id_ desc
  691. </select>
  692. <select id="selectTeacherPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  693. select ms.id_ as musicSheetId
  694. ,ms.music_sheet_name_ as musicSheetName
  695. ,ms.composer_ as composer
  696. ,ms.title_img_ as titleImg
  697. ,ms.accompaniment_type_ as accompanimentType
  698. ,ms.music_tag_ as musicTag
  699. ,(select group_concat(mt.name_) from music_tag mt
  700. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  701. ,ms.play_speed_ as playSpeed
  702. ,ms.music_price_ as musicPrice
  703. ,ms.create_time_ as createTime
  704. ,ms.audit_status_ as auditStatus
  705. ,su.username_ as auditName
  706. from music_sheet ms
  707. left join music_sheet_auth_record msar on ms.id_ = msar.music_sheet_id_
  708. left join sys_user su on msar.verify_user_id_ = su.id_
  709. <where>
  710. <if test="param.idAndName != null and param.idAndName != ''">
  711. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  712. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%')
  713. or ms.composer_ like concat('%',#{param.idAndName},'%'))
  714. </if>
  715. <if test="param.teacherId != null">
  716. and ms.create_by_ = #{param.teacherId} and ms.source_type_ = 'TEACHER'
  717. </if>
  718. <if test="param.startTime != null">
  719. and ms.create_time_ &gt; #{param.startTime}
  720. </if>
  721. <if test="param.endTime != null">
  722. and ms.create_time_ &lt; #{param.endTime}
  723. </if>
  724. <if test="param.delFlag != null">
  725. and ms.del_flag_ = #{param.delFlag}
  726. </if>
  727. </where>
  728. order by ms.id_ desc
  729. </select>
  730. <select id="selectAuditPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  731. select
  732. msar.id_ as authMusicSheetId,
  733. ms.create_by_ as teacherId
  734. ,ms.exquisite_flag_ as exquisiteFlag
  735. ,ms.title_img_ as titleImg
  736. ,ms.accompaniment_type_ as accompanimentType
  737. ,su.username_ as username
  738. ,su.real_name_ as realName
  739. ,su.phone_ as phone
  740. ,ms.id_ as musicSheetId
  741. ,ms.music_sheet_name_ as musicSheetName
  742. ,ms.composer_ as composer
  743. ,ms.music_tag_ as musicTag
  744. ,(select group_concat(mt.name_) from music_tag mt
  745. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  746. ,ms.play_speed_ as playSpeed
  747. ,ms.music_price_ as musicPrice
  748. ,ms.update_time_ as createTime
  749. ,if(msar.audit_state_ is null,ms.audit_status_,msar.audit_state_) as auditStatus
  750. ,su2.username_ as auditName
  751. ,msar.first_auth_ as firstAuth
  752. from music_sheet_auth_record msar
  753. left join music_sheet ms on ms.id_ = msar.music_sheet_id_
  754. left join sys_user su on su.id_ = ms.create_by_
  755. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  756. <where>ms.source_type_ = 'TEACHER'
  757. <if test="param.idAndName != null and param.idAndName != ''">
  758. and (su.id_ like concat('%',#{param.idAndName} ,'%')
  759. or su.username_ like concat('%',#{param.idAndName},'%')
  760. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%')
  761. or su.phone_ like concat('%',#{param.idAndName},'%'))
  762. </if>
  763. <if test="param.auditName != null and param.auditName != ''">
  764. and su2.username_ like concat('%',#{param.auditName},'%')
  765. </if>
  766. <if test="param.authStatus != null">
  767. and msar.audit_state_ = #{param.authStatus} and msar.audit_state_ = msar.last_audit_state_
  768. </if>
  769. <if test="param.startTime != null">
  770. and ms.create_time_ &gt; #{param.startTime}
  771. </if>
  772. <if test="param.endTime != null">
  773. and ms.create_time_ &lt; #{param.endTime}
  774. </if>
  775. <if test="param.chargeType != null">
  776. and ms.charge_type_ = #{param.chargeType}
  777. </if>
  778. <if test="param.firstAuth != null">
  779. and msar.first_auth_ = #{param.firstAuth}
  780. </if>
  781. <if test="param.exquisiteFlag != null">
  782. and ms.exquisite_flag_ = #{param.exquisiteFlag}
  783. </if>
  784. </where>
  785. order by field(ms.audit_status_,'DOING') desc, ms.submit_audit_time_ desc
  786. </select>
  787. <select id="selectTeacherMusicSheetCount" resultType="java.lang.Integer">
  788. select count(1)
  789. from music_sheet
  790. where user_id_ = #{userId}
  791. and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0 and source_type_ = 'TEACHER'
  792. </select>
  793. <select id="selectMusicNum" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo">
  794. select
  795. sum(if(ms.source_type_ = 'PLATFORM',1,0)) as musicSheetPlatformCount,
  796. sum(if(ms.source_type_ = 'TEACHER',1,0)) as musicSheetTeacherCount,
  797. count(1) as musicSheetCount
  798. from music_sheet ms
  799. 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_)
  800. </select>
  801. <select id="selectPayMusicSheet" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo$MusicSheetSmall">
  802. SELECT
  803. ms.id_ as musicSheetId,
  804. ms.music_sheet_name_ as musicSheetName,
  805. count(DISTINCT pr.student_id_) as num
  806. FROM
  807. music_sheet ms
  808. LEFT JOIN music_sheet_purchase_record pr ON ms.id_ = pr.music_sheet_id_
  809. WHERE
  810. ms.del_flag_=0
  811. AND ms.charge_type_='CHARGE'
  812. AND ms.state_=1
  813. AND pr.order_status_='PAID'
  814. GROUP BY ms.id_
  815. ORDER BY count(DISTINCT pr.student_id_) DESC,ms.id_ desc
  816. limit 5
  817. </select>
  818. <select id="selectTeacherCount" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherAuditMusicSheetVo">
  819. select
  820. sum(if(t.audit_status_ = 'DOING',1,0)) as doing,
  821. sum(if(t.audit_status_ = 'PASS'
  822. and t.state_ = 1,1,0)) as pass,
  823. sum(if(t.audit_status_ = 'UNPASS',1,0)) as upPass
  824. from
  825. music_sheet t
  826. where t.user_id_ = #{userId}
  827. </select>
  828. <select id="queryStudentTotal" resultType="com.yonge.cooleshow.biz.dal.vo.StudentTotalVo">
  829. select
  830. t.user_id_ as userId,
  831. a.musicAlbumNum,
  832. b.musicSheetNum
  833. from student t
  834. left join (
  835. select
  836. user_id_, count(1) as musicAlbumNum
  837. from album_favorite
  838. <where>
  839. <if test="null != userId">
  840. and user_id_ = #{userId}
  841. </if>
  842. </where>
  843. group by user_id_
  844. ) a on t.user_id_ = a.user_id_
  845. left join (
  846. select
  847. user_id_, count(1) as musicSheetNum
  848. from music_favorite
  849. <where>
  850. <if test="null != userId">
  851. and user_id_ = #{userId}
  852. </if>
  853. </where>
  854. group by user_id_
  855. ) b on t.user_id_ = b.user_id_
  856. <where>
  857. <if test="null != userId">
  858. and t.user_id_ = #{userId}
  859. </if>
  860. </where>
  861. </select>
  862. <select id="queryTeacherTotal" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherTotalVo">
  863. select
  864. t.user_id_ as userId,
  865. a.musicSheetNum as musicSheetNum
  866. from teacher t
  867. left join (
  868. select
  869. user_id_, count(1) as musicSheetNum
  870. from music_sheet
  871. where source_type_ = 'TEACHER' and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0
  872. <if test="null != userId">
  873. and user_id_ = #{userId}
  874. </if>
  875. group by user_id_
  876. ) a on t.user_id_ = a.user_id_
  877. <where>
  878. <if test="null != userId">
  879. and t.user_id_ = #{userId}
  880. </if>
  881. </where>
  882. </select>
  883. <select id="auditDetail" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo">
  884. SELECT
  885. su.username_ as userName
  886. ,su.avatar_ as userAvatar
  887. ,su.real_name_ as realName
  888. ,msar.update_time_ as auditTime
  889. ,msar.create_time_ as submitAuditTime
  890. ,msar.audit_state_ as auditStatus
  891. ,su2.username_ as auditName
  892. ,msar.reason_ as auditReason
  893. ,msar.music_sheet_json_ as musicSheetJson
  894. ,msar.batch_no_ as batchNo
  895. ,msar.id_ as id
  896. from music_sheet_auth_record msar
  897. left join music_sheet t on t.id_ = msar.music_sheet_id_
  898. left join sys_user su on su.id_ = t.create_by_
  899. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  900. WHERE msar.id_ = #{recordId}
  901. </select>
  902. <select id="auditDetailList" resultType="com.yonge.cooleshow.biz.dal.wrapper.MusicSheetWrapper$MusicSheetDetailVo">
  903. SELECT
  904. su.username_ as userName
  905. ,su.avatar_ as userAvatar
  906. ,su.real_name_ as realName
  907. ,msar.update_time_ as auditTime
  908. ,msar.create_time_ as submitAuditTime
  909. ,msar.audit_state_ as auditStatus
  910. ,su2.username_ as auditName
  911. ,msar.reason_ as auditReason
  912. ,msar.music_sheet_json_ as musicSheetJson
  913. ,msar.batch_no_ as batchNo
  914. ,msar.id_ as id
  915. from music_sheet_auth_record msar
  916. left join music_sheet t on t.id_ = msar.music_sheet_id_
  917. left join sys_user su on su.id_ = t.create_by_
  918. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  919. <where>
  920. <if test="batchNo != null and batchNo != ''">
  921. and #{batchNo} = msar.batch_no_
  922. </if>
  923. </where>
  924. order by msar.id_ desc
  925. </select>
  926. <!--单曲专辑数量统计-->
  927. <select id="selectMusicAlbumStatInfo" resultType="com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper">
  928. SELECT t1.music_sheet_id_ AS id, COUNT(DISTINCT t1.id_) AS total
  929. FROM album_music_relate t1 JOIN music_sheet t2 ON (t1.music_sheet_id_ = t2.id_)
  930. <where>
  931. <if test="musicIds != null">
  932. AND t1.music_sheet_id_ IN (<foreach collection="musicIds" separator="," item="item">#{item}</foreach>)
  933. </if>
  934. </where>
  935. GROUP BY t1.music_sheet_id_
  936. </select>
  937. <update id="updateFavoriteCount">
  938. update music_sheet set favorite_count_ =
  939. <choose>
  940. <when test="state.code == 0">
  941. favorite_count_ - 1
  942. </when>
  943. <when test="state.code == 1">
  944. favorite_count_ + 1
  945. </when>
  946. <otherwise>
  947. favorite_count_
  948. </otherwise>
  949. </choose>
  950. where id_ = #{musicSheetId}
  951. </update>
  952. <update id="updateBatchByCbsId">
  953. <foreach collection="vos" item="item" index="index" separator=";">
  954. update music_sheet ms set
  955. ms.music_tag_ = #{item.musicTagIds},ms.payment_type_ = #{item.paymentType},
  956. ms.charge_type_ = #{item.paymentType},
  957. ms.music_price_ = #{item.musicPrice},ms.top_flag_ = #{item.topFlag},
  958. ms.exquisite_flag_ = #{item.exquisiteFlag},ms.sort_number_ = #{item.sortNo},ms.del_flag_ = 0,
  959. ms.audit_status_ = 'PASS',
  960. ms.score_type_ = #{item.scoreType},
  961. ms.state_ = #{item.status},
  962. ms.notation_ = #{item.isConvertibleScore},
  963. ms.provider_type_ = CASE WHEN #{item.availableType} = 'PLATFORM' THEN 'PLATFORM' ELSE 'TENANT' END
  964. <if test="item.musicSheetUpdate != null">
  965. ,ms.music_sheet_name_ = #{item.musicSheetUpdate.name},
  966. ms.music_subject_ = #{item.musicSheetUpdate.subjectIds},
  967. ms.music_svg_ = #{item.musicSheetUpdate.musicSvg},
  968. ms.composer_ = #{item.musicSheetUpdate.composer},
  969. ms.accompaniment_type_ = #{item.musicSheetUpdate.audioType},
  970. ms.play_speed_ = #{item.musicSheetUpdate.playSpeed},
  971. ms.notation_ = #{item.musicSheetUpdate.notation},
  972. ms.music_sheet_type_ = #{item.musicSheetUpdate.musicSheetType},
  973. ms.create_by_ = #{item.musicSheetUpdate.userId},
  974. ms.audio_type_ = #{item.musicSheetUpdate.playMode},
  975. ms.show_fingering_ = #{item.musicSheetUpdate.showFingering},
  976. ms.can_evaluate_ = #{item.musicSheetUpdate.canEvaluate},
  977. ms.is_all_subject_ = #{item.musicSheetUpdate.isAllSubject},
  978. ms.source_type_ = CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  979. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER' ELSE 'TENANT' END,
  980. ms.first_pass_audit_time_ = IF(#{item.musicSheetUpdate.sourceType} = 'PERSON' and ms.first_pass_audit_time_ is null, now(), ms.first_pass_audit_time_)
  981. </if>
  982. where ms.cbs_music_sheet_id_ = #{item.musicSheetId}
  983. </foreach>
  984. </update>
  985. <update id="batchEnable">
  986. update music_sheet
  987. <set>
  988. <if test="tenantFlag == 1">
  989. tenant_state_ = #{status},
  990. </if>
  991. <if test="tenantFlag == 0">
  992. client_state_ = #{status}
  993. </if>
  994. </set>
  995. where FIND_IN_SET(cbs_music_sheet_id_,#{ids})
  996. </update>
  997. <update id="batchDel">
  998. update music_sheet
  999. <set>
  1000. <if test="tenantFlag == 1">
  1001. tenant_del_flag_ = 1,
  1002. </if>
  1003. <if test="tenantFlag == 0">
  1004. del_flag_ = 1
  1005. </if>
  1006. </set>
  1007. where FIND_IN_SET(cbs_music_sheet_id_,#{ids})
  1008. </update>
  1009. <update id="updateMusicSheet">
  1010. update music_sheet
  1011. set music_sheet_name_ = #{param.name},music_subject_ = #{param.subjectIds},music_svg_ = #{param.musicSvg},
  1012. composer_ = #{param.composer},title_img_ = #{param.musicCover},music_img_ = #{param.musicCover},accompaniment_type_ = #{param.audioType},
  1013. play_speed_ = #{param.playSpeed},is_all_subject_ = #{param.isAllSubject},platform_state_ = #{param.platformStatus},
  1014. music_sheet_type_ = #{param.musicSheetType},source_type_ = CASE WHEN #{param.sourceType} = 'PLATFORM' THEN 'PLATFORM' ELSE 'TEACHER' END,
  1015. create_by_ = #{param.userId},tenant_category_id_ = #{param.musicCategoryId}
  1016. where cbs_music_sheet_id_ = #{param.id}
  1017. </update>
  1018. <select id="countByUser" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetUploadCountVo">
  1019. select user_id_ userId, count(id_) count
  1020. from music_sheet
  1021. where del_flag_ = false and state_ =1 and source_type_ = 'TEACHER' and user_id_ in
  1022. <foreach collection="userIds" open="(" close=")" separator="," item="item">
  1023. #{item}
  1024. </foreach>
  1025. group by user_id_
  1026. </select>
  1027. <select id="searchMusic" resultType="java.lang.Long">
  1028. select t.id_ from music_sheet t
  1029. <if test="param.tenantAlbumIds != null and param.tenantAlbumIds.size() != 0">
  1030. left join tenant_album_music tam on t.id_ = tam.music_sheet_id_
  1031. </if>
  1032. <where>
  1033. <if test="param.subjectId != null">
  1034. and ( t.music_subject_ = #{param.subjectId} or t.music_subject_ is null or t.music_subject_ = '' OR t.is_all_subject_)
  1035. </if>
  1036. <if test="param.name != null and param.name != ''">
  1037. and t.music_sheet_name_ like concat('%',#{param.name},'%')
  1038. </if>
  1039. <if test="param.tenantAlbumIds != null and param.tenantAlbumIds.size() != 0">
  1040. and tam.tenant_album_id_ in
  1041. <foreach collection="param.tenantAlbumIds" item="item" open="(" close=")" separator=",">
  1042. #{item}
  1043. </foreach>
  1044. and tam.del_flag_=0
  1045. and tam.subject_type_ in ('ENSEMBLE', 'MUSIC', 'SUBJECT')
  1046. </if>
  1047. <if test="param.providerType != null">
  1048. and find_in_set(#{param.providerType},t.provider_type_)
  1049. <if test="param.providerType != null">
  1050. <if test="param.providerType.code == 'TENANT'">
  1051. and t.tenant_state_ = true and t.tenant_del_flag_ = 0
  1052. </if>
  1053. <if test="param.providerType.code == 'PLATFORM'">
  1054. and t.state_=1 and t.audit_version_ = 0 and t.del_flag_ = 0 and t.audit_status_ = 'PASS'
  1055. </if>
  1056. </if>
  1057. </if>
  1058. </where>
  1059. order by t.top_flag_ desc, t.sort_number_ desc, t.favorite_count_ desc
  1060. </select>
  1061. <select id="searchAlbum" resultType="java.lang.Long">
  1062. select id_ from music_album t
  1063. <where>
  1064. t.album_status_=1 and del_flag_=0 and audit_version_ = 0
  1065. <if test="param.subjectId != null">
  1066. and ( t.subject_id_ = #{param.subjectId} or t.subject_id_ is null or t.subject_id_ = '')
  1067. </if>
  1068. <if test="param.name != null and param.name != ''">
  1069. and t.album_name_ like concat('%',#{param.name},'%')
  1070. </if>
  1071. </where>
  1072. order by t.sort_number_ desc
  1073. </select>
  1074. <select id="personOwnerList"
  1075. resultType="com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetExtendWrapper$MusicSheetExtend">
  1076. select su.id_ userId,su.username_ username
  1077. ,'TEACHER' clientType,su.phone_ phone from teacher t
  1078. left join sys_user su ON su.id_ = t.user_id_
  1079. where su.user_type_ LIKE '%TEACHER%' AND su.del_flag_ = 0 AND su.lock_flag_ = 0 AND t.lock_flag_ = 0
  1080. <if test="param.name != null and param.name != ''">
  1081. AND (su.phone_ LIKE CONCAT('%',#{param.name},'%') OR su.username_ LIKE CONCAT('%',#{param.name},'%'))
  1082. </if>
  1083. <if test="param.userIdList != null and param.userIdList.size > 0">
  1084. AND su.id_ IN
  1085. <foreach collection="param.userIdList" item="item" open="(" close=")" separator=",">
  1086. #{item}
  1087. </foreach>
  1088. </if>
  1089. </select>
  1090. <select id="orgOwnerList"
  1091. resultType="com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetExtendWrapper$MusicSheetExtend">
  1092. select id_ organizationRoleId,name_ organizationRole,'ORG' clientType,phone_ phone from tenant_info where enable_flag_ = 1
  1093. <if test="param.name != null and param.name != ''">
  1094. AND (phone_ LIKE CONCAT('%',#{param.name},'%') OR name_ LIKE CONCAT('%',#{param.name},'%'))
  1095. </if>
  1096. <if test="param.userIdList != null and param.userIdList.size > 0">
  1097. AND id_ IN
  1098. <foreach collection="param.userIdList" item="item" open="(" close=")" separator=",">
  1099. #{item}
  1100. </foreach>
  1101. </if>
  1102. </select>
  1103. <select id="get" resultType="com.yonge.cooleshow.biz.dal.entity.MusicSheet">
  1104. select <include refid="Base_Column_List"/>
  1105. from music_sheet t
  1106. where t.id_ = #{id}
  1107. </select>
  1108. <select id="selectSyncPage" resultType="com.yonge.cooleshow.biz.dal.entity.MusicSheet">
  1109. select *
  1110. from music_sheet
  1111. where del_flag_ = 0 and audit_status_ = 'PASS' and cbs_music_sheet_id_ is null
  1112. </select>
  1113. <select id="queryTenantRelatedList" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  1114. select
  1115. <include refid="Base_Column_List"/>
  1116. from music_sheet t
  1117. left join tenant_album_music t1 on t1.music_sheet_id_ = t.id_
  1118. <where>
  1119. t.tenant_del_flag_ = 0 and t.tenant_state_ =1 and t.cbs_music_sheet_id_ is not null
  1120. and t1.del_flag_=0 and t1.subject_type_ in ('ENSEMBLE', 'MUSIC', 'SUBJECT')
  1121. <if test="queryInfo.albumId != null">
  1122. and t1.tenant_album_id_ = #{queryInfo.albumId}
  1123. </if>
  1124. <if test="queryInfo.albumId == null">
  1125. and 1=2
  1126. </if>
  1127. <if test="queryInfo.musicSheetId != null">
  1128. and t.id_ != #{queryInfo.musicSheetId}
  1129. </if>
  1130. <if test="queryInfo.subjectId != null">
  1131. and find_in_set(#{queryInfo.subjectId},t.music_subject_)
  1132. </if>
  1133. <if test="queryInfo.musicSheetType != null">
  1134. and t.music_sheet_type_ = #{queryInfo.musicSheetType}
  1135. </if>
  1136. </where>
  1137. </select>
  1138. <select id="countTeacherEnable" resultType="int">
  1139. select count(1)
  1140. from music_sheet
  1141. where state_ = 1 and del_flag_ = 0 and source_type_ = 'TEACHER' and create_by_ = #{userId}
  1142. </select>
  1143. <update id="updateTenantByCbsId">
  1144. update music_sheet ms set
  1145. ms.tenant_sort_number_ = #{item.sortNo},ms.tenant_del_flag_ = 0,
  1146. ms.tenant_score_type_ = #{item.scoreType},
  1147. ms.audit_status_ = 'PASS',
  1148. ms.tenant_state_ = #{item.status},
  1149. ms.tenant_notation_ = #{item.isConvertibleScore},
  1150. ms.provider_type_ = CASE WHEN ms.provider_type_ is null or ms.provider_type_ = '' THEN 'TENANT'
  1151. when find_in_set('TENANT',ms.provider_type_) then ms.provider_type_
  1152. else concat(ms.provider_type_,',','TENANT') end
  1153. <if test="item.musicSheetUpdate != null">
  1154. ,ms.music_sheet_name_ = #{item.musicSheetUpdate.name},
  1155. ms.music_subject_ = #{item.musicSheetUpdate.subjectIds},
  1156. ms.music_svg_ = #{item.musicSheetUpdate.musicSvg},
  1157. ms.composer_ = #{item.musicSheetUpdate.composer},
  1158. ms.accompaniment_type_ = #{item.musicSheetUpdate.audioType},
  1159. ms.play_speed_ = #{item.musicSheetUpdate.playSpeed},
  1160. ms.music_sheet_type_ = #{item.musicSheetUpdate.musicSheetType},
  1161. ms.create_by_ = #{item.musicSheetUpdate.userId},
  1162. ms.audio_type_ = #{item.musicSheetUpdate.playMode},
  1163. ms.tenant_category_id_ = #{item.musicSheetUpdate.musicCategoryId},
  1164. ms.show_fingering_ = #{item.musicSheetUpdate.showFingering},
  1165. ms.can_evaluate_ = #{item.musicSheetUpdate.canEvaluate},
  1166. ms.alias_ = #{item.musicSheetUpdate.alias},
  1167. ms.sort_num_ = #{item.musicSheetUpdate.sortNum},
  1168. ms.sort_group_ = #{item.musicSheetUpdate.sortGroup},
  1169. ms.sort_num2_ = #{item.musicSheetUpdate.sortNum2},
  1170. ms.upload_time_ = #{item.musicSheetUpdate.createTime},
  1171. ms.source_type_ = CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  1172. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER' ELSE 'TENANT' END
  1173. </if>
  1174. where ms.cbs_music_sheet_id_ = #{item.musicSheetId}
  1175. </update>
  1176. <update id="updatePlatformByCbsId">
  1177. update music_sheet ms set
  1178. ms.music_tag_ = #{item.musicTagIds},ms.payment_type_ = #{item.paymentType},
  1179. 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_),
  1180. now(), ms.first_pass_audit_time_),
  1181. ms.charge_type_ = #{item.paymentType},
  1182. ms.music_price_ = #{item.musicPrice},ms.top_flag_ = #{item.topFlag},
  1183. ms.exquisite_flag_ = #{item.exquisiteFlag},ms.sort_number_ = #{item.sortNo},ms.del_flag_ = 0,
  1184. ms.audit_status_ = 'PASS',
  1185. ms.score_type_ = #{item.scoreType},
  1186. ms.state_ = #{item.status},
  1187. ms.client_state_ = #{item.clientStatus},
  1188. ms.notation_ = #{item.isConvertibleScore},
  1189. ms.provider_type_ = CASE WHEN ms.provider_type_ is null or ms.provider_type_ = '' THEN 'PLATFORM'
  1190. when find_in_set('PLATFORM',ms.provider_type_) then ms.provider_type_
  1191. else concat(ms.provider_type_,',','PLATFORM') end
  1192. <if test="item.musicSheetUpdate != null">
  1193. ,ms.music_sheet_name_ = #{item.musicSheetUpdate.name}
  1194. ,ms.platform_state_ = #{item.musicSheetUpdate.platformStatus},
  1195. ms.music_subject_ = #{item.musicSheetUpdate.subjectIds},
  1196. ms.music_svg_ = #{item.musicSheetUpdate.musicSvg},
  1197. ms.composer_ = #{item.musicSheetUpdate.composer},
  1198. ms.accompaniment_type_ = #{item.musicSheetUpdate.audioType},
  1199. ms.play_speed_ = #{item.musicSheetUpdate.playSpeed},
  1200. ms.notation_ = #{item.musicSheetUpdate.notation},
  1201. ms.music_sheet_type_ = #{item.musicSheetUpdate.musicSheetType},
  1202. ms.create_by_ = #{item.musicSheetUpdate.userId},
  1203. ms.audio_type_ = #{item.musicSheetUpdate.playMode},
  1204. ms.show_fingering_ = #{item.musicSheetUpdate.showFingering},
  1205. ms.can_evaluate_ = #{item.musicSheetUpdate.canEvaluate},
  1206. ms.alias_ = #{item.musicSheetUpdate.alias},
  1207. ms.sort_num_ = #{item.musicSheetUpdate.sortNum},
  1208. ms.sort_group_ = #{item.musicSheetUpdate.sortGroup},
  1209. ms.sort_num2_ = #{item.musicSheetUpdate.sortNum2},
  1210. ms.source_type_ = CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  1211. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER' ELSE 'TENANT' END
  1212. </if>
  1213. where ms.cbs_music_sheet_id_ = #{item.musicSheetId}
  1214. </update>
  1215. <insert id="tenantInsert">
  1216. insert into music_sheet
  1217. (cbs_music_sheet_id_,tenant_sort_number_,tenant_score_type_,tenant_state_,tenant_notation_,tenant_category_id_,tenant_del_flag_
  1218. ,music_sheet_name_,music_subject_,music_svg_,composer_,accompaniment_type_,play_speed_,
  1219. music_sheet_type_,provider_type_,audio_type_,show_fingering_,
  1220. can_evaluate_,create_by_,user_id_,audit_status_,upload_time_,source_type_
  1221. )
  1222. values
  1223. (#{item.musicSheetId},
  1224. #{item.sortNo},#{item.scoreType},#{item.status},#{item.isConvertibleScore}
  1225. ,#{item.musicSheetUpdate.musicCategoryId}
  1226. ,#{item.delFlag}
  1227. ,#{item.musicSheetUpdate.name},
  1228. #{item.musicSheetUpdate.subjectIds},
  1229. #{item.musicSheetUpdate.musicSvg},
  1230. #{item.musicSheetUpdate.composer},
  1231. #{item.musicSheetUpdate.audioType},
  1232. #{item.musicSheetUpdate.playSpeed},
  1233. #{item.musicSheetUpdate.musicSheetType},
  1234. 'TENANT',
  1235. #{item.musicSheetUpdate.playMode},
  1236. #{item.musicSheetUpdate.showFingering},
  1237. #{item.musicSheetUpdate.canEvaluate},
  1238. #{item.musicSheetUpdate.userId},
  1239. #{item.musicSheetUpdate.userId},
  1240. 'PASS',
  1241. #{item.musicSheetUpdate.createTime},
  1242. CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  1243. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER'
  1244. ELSE 'TENANT' END
  1245. )
  1246. </insert>
  1247. <insert id="platformInsert">
  1248. insert into music_sheet
  1249. (cbs_music_sheet_id_,music_tag_,payment_type_,charge_type_,top_flag_,exquisite_flag_,sort_number_,state_,audit_status_
  1250. ,music_sheet_name_,music_subject_,music_svg_,composer_,accompaniment_type_,play_speed_,
  1251. music_price_,notation_,music_sheet_type_,source_type_,provider_type_,audio_type_,show_fingering_,
  1252. can_evaluate_,create_by_,user_id_,score_type_,platform_state_,client_state_,first_pass_audit_time_
  1253. )
  1254. values
  1255. (#{item.musicSheetId},
  1256. #{item.musicTagIds},#{item.paymentType},#{item.paymentType},
  1257. #{item.topFlag},#{item.exquisiteFlag},#{item.sortNo},0
  1258. ,'PASS'
  1259. ,#{item.musicSheetUpdate.name},
  1260. #{item.musicSheetUpdate.subjectIds},
  1261. #{item.musicSheetUpdate.musicSvg},
  1262. #{item.musicSheetUpdate.composer},
  1263. #{item.musicSheetUpdate.audioType},
  1264. #{item.musicSheetUpdate.playSpeed},
  1265. #{item.musicSheetUpdate.musicPrice},
  1266. #{item.isConvertibleScore},
  1267. #{item.musicSheetUpdate.musicSheetType},
  1268. CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  1269. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER'
  1270. ELSE 'TENANT' END,
  1271. 'PLATFORM',
  1272. #{item.musicSheetUpdate.playMode},
  1273. #{item.musicSheetUpdate.showFingering},
  1274. #{item.musicSheetUpdate.canEvaluate},
  1275. #{item.musicSheetUpdate.userId},#{item.musicSheetUpdate.userId},
  1276. #{item.scoreType},
  1277. #{item.musicSheetUpdate.platformStatus},
  1278. #{item.clientStatus},
  1279. now()
  1280. )
  1281. </insert>
  1282. <update id="updateState">
  1283. update music_sheet
  1284. set state_ = client_state_ and platform_state_
  1285. where FIND_IN_SET(cbs_music_sheet_id_,#{ids})
  1286. </update>
  1287. <update id="delPractice">
  1288. update sys_music_compare_record
  1289. set hidden_flag_ = 1
  1290. where user_id_ = #{userId} and music_sheet_id_ = #{musicSheetId} and client_id_ = #{clientEnum}
  1291. </update>
  1292. <select id="cloudPage" resultType="com.yonge.cooleshow.biz.dal.wrapper.MusicSheetWrapper$MusicSheetCloud">
  1293. 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
  1294. from music_sheet t
  1295. <if test="param.recentFlag != null and param.recentFlag == 1">
  1296. left join sys_music_compare_record msar on t.id_ = msar.music_sheet_id_
  1297. </if>
  1298. <if test="param.albumId != null">
  1299. left join tenant_album_music tam on t.id_ = tam.music_sheet_id_ and tam.del_flag_ = 0
  1300. </if>
  1301. <if test="param.favoriteFlag != null and param.favoriteFlag == 1">
  1302. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mf.user_id_ = #{param.userId} and mf.client_type_ = #{param.clientType}
  1303. </if>
  1304. <where>
  1305. t.cbs_music_sheet_id_ is not null
  1306. <if test="param.name != null and param.name != ''">
  1307. and t.music_sheet_name_ like concat('%',#{param.name},'%')
  1308. </if>
  1309. <if test="param.favoriteFlag != null and param.favoriteFlag == 1">
  1310. and mf.id_ is not null
  1311. </if>
  1312. <if test="param.status != null">
  1313. <if test="param.providerType != null">
  1314. <if test="param.providerType.code == 'TENANT'">
  1315. and t.tenant_state_ = #{param.status}
  1316. </if>
  1317. <if test="param.providerType.code == 'PLATFORM'">
  1318. and t.state_ = #{param.status}
  1319. </if>
  1320. </if>
  1321. <if test="param.providerType == null">
  1322. and t.state_ = #{param.status}
  1323. </if>
  1324. </if>
  1325. <if test="param.delFlag != null">
  1326. <if test="param.providerType != null">
  1327. <if test="param.providerType.code == 'TENANT'">
  1328. and t.tenant_del_flag_ = #{param.delFlag}
  1329. </if>
  1330. <if test="param.providerType.code == 'PLATFORM'">
  1331. and t.del_flag_ = #{param.delFlag}
  1332. </if>
  1333. </if>
  1334. <if test="param.providerType == null">
  1335. and t.del_flag_ = #{param.delFlag}
  1336. </if>
  1337. </if>
  1338. <if test="param.versionFlag != null">
  1339. and t.audit_version_ = #{param.versionFlag}
  1340. </if>
  1341. <if test="param.recentFlag != null and param.recentFlag == 1">
  1342. <if test="param.userId != null">
  1343. and msar.user_id_ = #{param.userId}
  1344. </if>
  1345. <if test="param.clientType != null and param.clientType != ''">
  1346. and msar.client_id_ = #{param.clientType}
  1347. </if>
  1348. </if>
  1349. <if test="param.excludeMusicId != null">
  1350. and t.id_ != #{param.excludeMusicId}
  1351. </if>
  1352. <if test="param.ids != null and param.ids.size() != 0">
  1353. and t.id_ in
  1354. <foreach collection="param.ids" item="item" open="(" close=")" separator=",">
  1355. #{item}
  1356. </foreach>
  1357. </if>
  1358. <if test="param.providerType != null and param.providerType.code == 'TENANT'">
  1359. <if test="param.albumId != null">
  1360. and tam.tenant_album_id_ = #{param.albumId}
  1361. and tam.subject_type_ in ('ENSEMBLE', 'MUSIC', 'SUBJECT')
  1362. </if>
  1363. <if test="param.albumId == null">
  1364. and 1=2
  1365. </if>
  1366. </if>
  1367. <if test="param.providerType != null">
  1368. and find_in_set(#{param.providerType},t.provider_type_)
  1369. </if>
  1370. <if test="param.musicSheetType != null">
  1371. and t.music_sheet_type_ = #{param.musicSheetType}
  1372. </if>
  1373. <if test="param.subjectId != null">
  1374. and (find_in_set(#{param.subjectId},t.music_subject_)or t.music_subject_ is null or t.music_subject_ = '' OR t.is_all_subject_)
  1375. </if>
  1376. </where>
  1377. GROUP BY t.id_
  1378. <if test="param.recentFlag !=null and param.recentFlag == true">
  1379. order by
  1380. max(msar.create_time_) desc
  1381. </if>
  1382. <if test="param.favoriteFlag != null and param.favoriteFlag == 1">
  1383. order by mf.id_ desc
  1384. </if>
  1385. <if test="param.recentFlag == null">
  1386. order by tam.level_,tam.type_,tam.sort_number_
  1387. </if>
  1388. </select>
  1389. <select id="musicSheetTotal"
  1390. resultType="com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper$MusicSheetTotal">
  1391. select
  1392. if(t.audit_status_ = 'PASS' and t.state_ = 1,1,0) as musicSheetNum,
  1393. if(t.audit_status_ = 'DOING' ,1,0) musicSheetAuditNum,
  1394. t.exposure_num_ musicSheetExposureNum
  1395. from music_sheet t
  1396. where t.del_flag_=0 and t.user_id_ = #{teacherId}
  1397. </select>
  1398. <select id="musicSheetPage"
  1399. resultType="com.yonge.cooleshow.biz.dal.wrapper.teacher.TeacherHomeWrapper$MusicSheetTotal">
  1400. select
  1401. t.music_sheet_name_ musicSheetName,
  1402. t.create_time_ createTime,
  1403. t.exposure_num_ musicSheetExposureNum,
  1404. count(distinct t1.buy_user_) musicSheetPayNum,
  1405. sum(t1.trans_amount_) as musicSheetIncome
  1406. from music_sheet t
  1407. left join user_cash_account_record t1 on t.id_ = t1.biz_id_
  1408. where t1.account_id_ = #{param.teacherId}
  1409. and t1.biz_type_ = 'MUSIC_SHARE'
  1410. and t1.post_status_ = 'RECORDED'
  1411. and t1.in_or_out_ = 'IN'
  1412. and t.del_flag_=0 and t.user_id_ = #{param.teacherId}
  1413. group by t.id_
  1414. order by t.create_time_ desc
  1415. limit #{param.rows}
  1416. </select>
  1417. <!--单曲专辑数量统计-->
  1418. </mapper>