INSERT INTO music_group_payment_calender_detail
(music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,payment_status_,
user_status_,pay_time_,update_time_,create_time_,start_payment_date_,deadline_payment_date_,
payment_order_id_,use_in_course_,responsible_user_id_,responsible_record_,expect_member_amount_,tenant_id_)
VALUES(#{musicGroupPaymentCalenderId},#{userId},#{expectAmount},#{actualAmount},
#{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
#{userStatus},#{payTime},NOW(),NOW(),#{startPaymentDate},#{deadlinePaymentDate},
#{paymentOrderId},#{useInCourse},#{responsibleUserId},#{responsibleRecord},#{expectMemberAmount},#{tenantId})
INSERT INTO music_group_payment_calender_detail
(music_group_payment_calender_id_,user_id_,expect_amount_,actual_amount_,
payment_status_,user_status_,pay_time_,update_time_,create_time_,start_payment_date_,
deadline_payment_date_,payment_order_id_,use_in_course_,responsible_user_id_,responsible_record_,expect_member_amount_,tenant_id_)
VALUES
(#{item.musicGroupPaymentCalenderId},#{item.userId},#{item.expectAmount},
#{item.actualAmount},#{item.paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.userStatus},#{item.payTime},
#{item.updateTime},#{item.createTime},#{item.startPaymentDate},#{item.deadlinePaymentDate},
#{item.paymentOrderId},#{item.useInCourse},#{item.responsibleUserId},#{item.responsibleRecord},#{item.expectMemberAmount},#{item.tenantId})
UPDATE music_group_payment_calender_detail
start_payment_date_ = #{startPaymentDate},
deadline_payment_date_ = #{deadlinePaymentDate},
open_ = #{open},
user_id_ = #{userId},
user_status_ = #{userStatus},
payment_status_ = #{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
expect_member_amount_ = #{expectMemberAmount},
expect_amount_ = #{expectAmount},
update_time_ = #{updateTime},
music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId},
actual_amount_ = #{actualAmount},
pay_time_ = #{payTime},
payment_order_id_ = #{paymentOrderId},
use_in_course_ = #{useInCourse},
responsible_user_id_ = #{responsibleUserId},
responsible_record_ = #{responsibleRecord},
WHERE id_ = #{id} and tenant_id_ = #{tenantId}
UPDATE music_group_payment_calender_detail
start_payment_date_ = #{item.startPaymentDate},
deadline_payment_date_ = #{item.deadlinePaymentDate},
open_ = #{item.open},
user_id_ = #{item.userId},
user_status_ = #{item.userStatus},
payment_status_ = #{item.paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
expect_member_amount_ = #{item.expectMemberAmount},
expect_amount_ = #{item.expectAmount},
update_time_ = #{item.updateTime},
music_group_payment_calender_id_ = #{item.musicGroupPaymentCalenderId},
actual_amount_ = #{item.actualAmount},
pay_time_ = #{item.payTime},
payment_order_id_ = #{item.paymentOrderId},
use_in_course_ = #{item.useInCourse},
responsible_user_id_ = #{item.responsibleUserId},
responsible_record_ = #{item.responsibleRecord},
WHERE id_ = #{item.id} and tenant_id_ = #{item.tenantId}
UPDATE music_group_payment_calender_detail mgpcd
SET mgpcd.open_ = 0,mgpcd.start_payment_date_ = NULL,mgpcd.deadline_payment_date_ = NULL
WHERE mgpcd.deadline_payment_date_ < DATE_FORMAT(NOW(),'%Y-%m-%d')
DELETE FROM music_group_payment_calender_detail WHERE id_ = #{id}
DELETE FROM music_group_payment_calender_detail WHERE FIND_IN_SET(id_,#{musicGroupPaymentCalenderIdDetails})
DELETE FROM music_group_payment_calender_detail WHERE music_group_payment_calender_id_ = #{id}
mgpc.music_group_id_ = sr.music_group_id_ AND mgpcd.tenant_id_ = #{tenantId}
AND (mgpcd.user_id_ = #{search} OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
AND mgpcd.music_group_payment_calender_id_ = #{id}
AND mgpcd.payment_status_ = #{paymentStatus}
AND mgpc.music_group_id_ = #{musicGroupId}
AND mgpcd.user_id_ = #{userId}
AND sr.music_group_status_ = #{musicGroupStatus}
AND #{subjectId} = sr.actual_subject_id_
mg.status_ = 'PROGRESS' and mg.tenant_id_ = #{tenantId}
AND ((mgpc.member_rank_setting_id_ IS NOT NULL AND (sr.membership_end_time_ < NOW() OR sr.membership_end_time_ IS NULL)) OR mgpc.member_rank_setting_id_ IS NULL)
AND DATE_FORMAT(NOW(),'%Y-%m-%d') > DATE_FORMAT(mgpc.deadline_payment_date_,'%Y-%m-%d')
AND DATE_FORMAT(NOW(),'%Y-%m-%d') BETWEEN DATE_FORMAT(mgpc.start_payment_date_,'%Y-%m-%d') AND DATE_FORMAT(mgpc.deadline_payment_date_,'%Y-%m-%d')
AND mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpc.batch_no_ IS NOT NULL AND mgpc.pay_user_type_ = 'STUDENT'
AND (mgpcd.expect_amount_ + mgpcd.expect_member_amount_) > 0
AND mg.organ_id_ IN
#{organId}
AND mgpc.music_group_id_ = #{musicGroupId}
AND mg.course_view_type_ = #{courseViewType}
AND mg.cooperation_organ_id_ = #{cooperationOrganId}
AND mg.educational_teacher_id_=#{eduTeacherId}
AND (mgpcd.user_id_=#{search} OR su.username_ LIKE CONCAT('%', #{search}, '%'))
UPDATE music_group_payment_calender_detail mgpcd
SET mgpcd.payment_status_ = 'PAID_COMPLETED',mgpcd.actual_amount_ = 0,mgpcd.update_time_ = NOW()
WHERE mgpcd.music_group_payment_calender_id_ = #{calenderId} AND (mgpcd.expect_amount_ + mgpcd.expect_member_amount_) = 0
AND mgpcd.payment_status_ = 'NON_PAYMENT'