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.music_sheet_name_ as musicSheetName
,ms.state_ as musicStatus
,ms.payment_type_ as paymentType
,ms.music_img_ as musicImg
FROM course_courseware t
left join music_sheet ms on t.music_sheet_id_ = ms.id_
t.del_flag_ = 0
and t.user_id_ = #{param.userId}
and t.client_type_ = #{param.clientType}
and (ms.music_sheet_name_ like '%${param.idAndName}%' or ms.id_ like '%${param.idAndName}%')
and
find_in_set(#{item},ms.music_tag_)
and
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}