t.id_ as id
, t.user_id_ as userId
, t.client_type_ as clientType
,t.music_sheet_id_ as musicSheetId
, t.create_time_ as createTime
, t.update_time_ as updateTime
SELECT
FROM course_courseware t
where t.id_ = #{id}
SELECT
,ms.cbs_music_sheet_id_ as cbsMusicSheetId
FROM course_courseware t
left join music_sheet ms on t.music_sheet_id_ = ms.id_
t.del_flag_ = 0 AND ms.cbs_music_sheet_id_ IS NOT NULL
and t.user_id_ = #{param.userId}
and t.client_type_ = #{param.clientType}
and (ms.music_sheet_name_ LIKE CONCAT('%',#{param.idAndName},'%') or ms.cbs_music_sheet_id_ = #{param.idAndName})
and
find_in_set(#{item},ms.music_tag_)
and (ms.music_subject_ is null or ms.music_subject_ = '' OR ms.music_sheet_type_ = 'CONCERT' OR
find_in_set(#{item},ms.music_subject_)
)
and (ms.payment_type_ like '%FREE%'
or EXISTS (select * from music_sheet_purchase_record mspr where mspr.music_sheet_id_ = ms.id_ and mspr.student_id_ = t.user_id_ and mspr.order_status_ = 'PAID' and mspr.purchase_type_ = 'MUSIC' and mspr.client_type_ = 'TEACHER')
or EXISTS (select mspr.music_sheet_id_ from music_sheet_purchase_record mspr
left join album_music_relate amr on amr.album_id_ = mspr.music_sheet_id_
where mspr.student_id_ = t.user_id_ and mspr.order_status_ = 'PAID' and mspr.purchase_type_ = 'ALBUM' and amr.music_sheet_id_ = ms.id_ and mspr.client_type_ = 'TEACHER' )
or (ms.payment_type_ like '%VIP%' and EXISTS(select 1 from teacher t1 where t1.user_id_ = t.user_id_ and t1.membership_end_time_ > now()))
)
select cc.id_ from course_courseware cc
where
(EXISTS (select * from music_sheet_purchase_record mspr
where mspr.music_sheet_id_ = cc.music_sheet_id_
and mspr.student_id_ = cc.user_id_
and mspr.order_status_ = 'PAID'
and mspr.purchase_type_ = 'MUSIC'
and mspr.client_type_ = 'TEACHER')
or EXISTS (select mspr.music_sheet_id_ from music_sheet_purchase_record mspr
left join album_music_relate amr on amr.album_id_ = mspr.music_sheet_id_
where mspr.student_id_ = cc.user_id_
and mspr.order_status_ = 'PAID'
and mspr.purchase_type_ = 'ALBUM'
and amr.music_sheet_id_ = cc.music_sheet_id_
and mspr.client_type_ = 'TEACHER'))
and cc.id_ in
#{item}