INSERT INTO music_group_payment_student_course_detail
(music_group_id_,music_group_payment_calender_id_, music_group_payment_calender_detail_id_, user_id_, course_type_,
total_course_minutes_, used_course_minutes_,sub_course_minutes_, create_time_, update_time_, course_original_price_,
course_current_price_, sub_course_original_price_,sub_course_current_price_, tenant_id_,cloud_teacher_payment_flag_)
VALUES (#{musicGroupId}, #{musicGroupPaymentCalenderId}, #{musicGroupPaymentCalenderDetailId}, #{userId},
#{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{totalCourseMinutes},
#{usedCourseMinutes},#{subCourseMinutes},
NOW(), NOW(), #{courseOriginalPrice}, #{courseCurrentPrice}, #{subCourseOriginalPrice}, #{subCourseCurrentPrice}, #{tenantId},#{cloudTeacherPaymentFlag})
INSERT INTO music_group_payment_student_course_detail
(music_group_id_,music_group_payment_calender_id_,music_group_payment_calender_detail_id_,user_id_,
course_type_,total_course_minutes_,used_course_minutes_,sub_course_minutes_,create_time_,update_time_,course_original_price_,
course_current_price_,sub_course_original_price_,sub_course_current_price_,tenant_id_,cloud_teacher_payment_flag_)
VALUES
(#{item.musicGroupId},#{item.musicGroupPaymentCalenderId},#{item.musicGroupPaymentCalenderDetailId},
#{item.userId},#{item.courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
#{item.totalCourseMinutes},#{item.usedCourseMinutes},#{item.subCourseMinutes},NOW(),NOW(),#{item.courseOriginalPrice},
#{item.courseCurrentPrice}, #{item.subCourseOriginalPrice}, #{item.subCourseCurrentPrice},#{item.tenantId},#{item.cloudTeacherPaymentFlag})
UPDATE music_group_payment_student_course_detail
course_original_price_ = #{courseOriginalPrice},
course_current_price_ = #{courseCurrentPrice},
sub_course_original_price_ = #{subCourseOriginalPrice},
sub_course_current_price_ = #{subCourseCurrentPrice},
sub_course_minutes_ = #{subCourseMinutes},
used_course_minutes_ = #{usedCourseMinutes},
total_course_minutes_ = #{totalCourseMinutes},
user_id_ = #{userId},
music_group_payment_calender_detail_id_ = #{musicGroupPaymentCalenderDetailId},
music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId},
course_type_ = #{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
update_time_ = NOW()
WHERE id_ = #{id} and tenant_id_ = #{tenantId}
UPDATE music_group_payment_student_course_detail
course_original_price_ = #{paymentCourseDetail.courseOriginalPrice},
course_current_price_ = #{paymentCourseDetail.courseCurrentPrice},
sub_course_original_price_ = #{paymentCourseDetail.subCourseOriginalPrice},
sub_course_current_price_ = #{paymentCourseDetail.subCourseCurrentPrice},
used_course_minutes_ = #{paymentCourseDetail.subCourseMinutes},
sub_course_minutes_ = #{paymentCourseDetail.subCourseMinutes},
used_course_minutes_ = #{paymentCourseDetail.usedCourseMinutes},
total_course_minutes_ = #{paymentCourseDetail.totalCourseMinutes},
user_id_ = #{paymentCourseDetail.userId},
music_group_payment_calender_detail_id_ = #{paymentCourseDetail.musicGroupPaymentCalenderDetailId},
music_group_payment_calender_id_ = #{paymentCourseDetail.musicGroupPaymentCalenderId},
course_type_ =
#{paymentCourseDetail.courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
update_time_ = NOW()
WHERE id_ = #{paymentCourseDetail.id} and tenant_id_ = #{paymentCourseDetail.tenantId}
UPDATE music_group_payment_student_course_detail
SET course_current_price_ = #{courseCurrentPrice},
update_time_ = NOW()
WHERE course_type_ = #{courseType}
AND FIND_IN_SET(music_group_payment_calender_detail_id_, #{musicGroupPaymentCalenderIds})
DELETE
FROM music_group_payment_student_course_detail
WHERE id_ = #{id}
DELETE
FROM music_group_payment_student_course_detail
WHERE music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId}
DELETE FROM music_group_payment_student_course_detail
music_group_payment_calender_detail_id_ IN
#{item}
DELETE
FROM music_group_payment_student_course_detail
WHERE user_id_ = #{userId}
AND music_group_payment_calender_id_ IN (
SELECT id_
FROM music_group_payment_calender
WHERE music_group_id_ = #{musicGroupId}
)
WHERE mgpscd.music_group_id_ = #{musicGroupId}
and (
mgpscd.user_id_ like CONCAT('%',#{search},'%')
or su.phone_ like CONCAT('%',#{search},'%')
or su.username_ like CONCAT('%',#{search},'%')
)
and mgpscd.sub_course_minutes_ > 0
and mgpscd.used_course_minutes_ = 0
and mgpscd.course_type_ = #{courseType}
AND find_in_set(#{classGroupId},v.class_group_id_)
update music_group_payment_student_course_detail
set sub_course_minutes_ = 0 WHERE sub_course_minutes_ > 0 and music_group_id_ = #{musicGroupId}