INSERT INTO music_group_payment_calender_detail
(id_,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_)
VALUES(#{id},#{musicGroupPaymentCalenderId},#{userId},#{expectAmount},#{actualAmount},#{paymentStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
#{userStatus},#{payTime},NOW(),NOW(),#{startPaymentDate},#{deadlinePaymentDate},#{paymentOrderId},#{useInCourse},#{responsibleUserId},#{responsibleRecord})
INSERT INTO music_group_payment_calender_detail
(id_,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_)
VALUES
(#{item.id},#{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})
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_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}
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_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}
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.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_
AND (mgpcd.responsible_user_id_ = #{responsibleRealName} OR tu.real_name_ LIKE CONCAT('%',#{responsibleRealName},'%') OR tu.phone_ LIKE CONCAT('%',#{responsibleRealName},'%'))
mg.status_ = 'PROGRESS'
AND DATE_FORMAT( NOW(), '%Y-%m-%d' ) >= DATE_FORMAT( mgpc.payment_valid_start_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_ > 0
AND mg.organ_id_ IN
#{organId}
AND mgpc.music_group_id_ = #{musicGroupId}
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
LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
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_ = 0
AND mgpcd.payment_status_ = 'NON_PAYMENT' AND (mgpcd.open_ = 1 OR mgpc.status_ = 'OPEN')