|
@@ -7,6 +7,7 @@
|
|
|
type="com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail"
|
|
|
id="MusicGroupPaymentStudentCourseDetail">
|
|
|
<result column="id_" property="id"/>
|
|
|
+ <result column="music_group_id_" property="musicGroupId"/>
|
|
|
<result column="music_group_payment_calender_id_" property="musicGroupPaymentCalenderId"/>
|
|
|
<result column="music_group_payment_calender_detail_id_"
|
|
|
property="musicGroupPaymentCalenderDetailId"/>
|
|
@@ -16,6 +17,7 @@
|
|
|
<result column="course_current_price_" property="courseCurrentPrice"/>
|
|
|
<result column="total_course_minutes_" property="totalCourseMinutes"/>
|
|
|
<result column="used_course_minutes_" property="usedCourseMinutes"/>
|
|
|
+ <result column="sub_course_minutes_" property="subCourseMinutes"/>
|
|
|
<result column="cloud_teacher_payment_flag_" property="cloudTeacherPaymentFlag"/>
|
|
|
<result column="create_time_" property="createTime"/>
|
|
|
<result column="update_time_" property="updateTime"/>
|
|
@@ -42,26 +44,26 @@
|
|
|
parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail"
|
|
|
useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
|
|
INSERT INTO music_group_payment_student_course_detail
|
|
|
- (music_group_payment_calender_id_, music_group_payment_calender_detail_id_, user_id_, course_type_,
|
|
|
- total_course_minutes_, used_course_minutes_, create_time_, update_time_, course_original_price_,
|
|
|
+ (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_, tenant_id_,cloud_teacher_payment_flag_)
|
|
|
- VALUES (#{musicGroupPaymentCalenderId}, #{musicGroupPaymentCalenderDetailId}, #{userId},
|
|
|
+ VALUES (#{musicGroupId}, #{musicGroupPaymentCalenderId}, #{musicGroupPaymentCalenderDetailId}, #{userId},
|
|
|
#{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{totalCourseMinutes},
|
|
|
- #{usedCourseMinutes},
|
|
|
+ #{usedCourseMinutes},#{subCourseMinutes},
|
|
|
NOW(), NOW(), #{courseOriginalPrice}, #{courseCurrentPrice}, #{tenantId},#{cloudTeacherPaymentFlag})
|
|
|
</insert>
|
|
|
|
|
|
<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
|
|
|
keyProperty="id">
|
|
|
INSERT INTO music_group_payment_student_course_detail
|
|
|
- (music_group_payment_calender_id_,music_group_payment_calender_detail_id_,user_id_,
|
|
|
- course_type_,total_course_minutes_,used_course_minutes_,create_time_,update_time_,course_original_price_,
|
|
|
+ (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_,tenant_id_,cloud_teacher_payment_flag_)
|
|
|
VALUES
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
- (#{item.musicGroupPaymentCalenderId},#{item.musicGroupPaymentCalenderDetailId},
|
|
|
+ (#{item.musicGroupId},#{item.musicGroupPaymentCalenderId},#{item.musicGroupPaymentCalenderDetailId},
|
|
|
#{item.userId},#{item.courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
|
|
|
- #{item.totalCourseMinutes},#{item.usedCourseMinutes},NOW(),NOW(),#{item.courseOriginalPrice},
|
|
|
+ #{item.totalCourseMinutes},#{item.usedCourseMinutes},#{item.subCourseMinutes},NOW(),NOW(),#{item.courseOriginalPrice},
|
|
|
#{item.courseCurrentPrice},#{item.tenantId},#{item.cloudTeacherPaymentFlag})
|
|
|
</foreach>
|
|
|
</insert>
|
|
@@ -77,6 +79,9 @@
|
|
|
<if test="courseCurrentPrice != null">
|
|
|
course_current_price_ = #{courseCurrentPrice},
|
|
|
</if>
|
|
|
+ <if test="subCourseMinutes != null">
|
|
|
+ used_course_minutes_ = #{subCourseMinutes},
|
|
|
+ </if>
|
|
|
<if test="usedCourseMinutes != null">
|
|
|
used_course_minutes_ = #{usedCourseMinutes},
|
|
|
</if>
|
|
@@ -111,6 +116,9 @@
|
|
|
<if test="paymentCourseDetail.courseCurrentPrice != null">
|
|
|
course_current_price_ = #{paymentCourseDetail.courseCurrentPrice},
|
|
|
</if>
|
|
|
+ <if test="paymentCourseDetail.subCourseMinutes != null">
|
|
|
+ used_course_minutes_ = #{paymentCourseDetail.subCourseMinutes},
|
|
|
+ </if>
|
|
|
<if test="paymentCourseDetail.usedCourseMinutes != null">
|
|
|
used_course_minutes_ = #{paymentCourseDetail.usedCourseMinutes},
|
|
|
</if>
|
|
@@ -196,34 +204,10 @@
|
|
|
<select id="getUnUseWithStudentAndCourseTypeAndCourseMinutes" resultMap="MusicGroupPaymentStudentCourseDetail">
|
|
|
SELECT mgpscd.*
|
|
|
FROM music_group_payment_student_course_detail mgpscd
|
|
|
- LEFT JOIN music_group_payment_calender mgpc ON mgpscd.music_group_payment_calender_id_ = mgpc.id_
|
|
|
- WHERE FIND_IN_SET(mgpc.batch_no_, #{batchNo})
|
|
|
- AND mgpscd.user_id_ = #{studentId}
|
|
|
- AND mgpscd.course_type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
|
|
|
- AND mgpscd.used_course_minutes_ <= 0
|
|
|
- ORDER BY mgpscd.id_;
|
|
|
- </select>
|
|
|
-
|
|
|
- <select id="getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes" resultType="string">
|
|
|
- SELECT
|
|
|
- mgpc.batch_no_
|
|
|
- FROM music_group_payment_calender mgpc
|
|
|
- LEFT JOIN music_group_payment_student_course_detail mgpscd ON mgpscd.music_group_payment_calender_id_ = mgpc.id_
|
|
|
- WHERE
|
|
|
- mgpc.music_group_id_ = #{musicGroupId}
|
|
|
- <if test="studentId != null">
|
|
|
- AND mgpscd.user_id_ = #{studentId}
|
|
|
- </if>
|
|
|
- <if test="batchNos != null">
|
|
|
- AND mgpc.batch_no_ NOT IN
|
|
|
- <foreach collection="batchNos" item="item" open="(" close=")" separator=",">
|
|
|
- #{item}
|
|
|
- </foreach>
|
|
|
- </if>
|
|
|
- <if test="courseType != null">
|
|
|
- AND mgpscd.course_type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
|
|
|
- </if>
|
|
|
- GROUP BY mgpc.batch_no_ HAVING min(mgpscd.used_course_minutes_) <=0 ORDER BY MIN(mgpc.id_) LIMIT 1;
|
|
|
+ WHERE mgpscd.user_id_ = #{studentId}
|
|
|
+ AND mgpscd.course_type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
|
|
|
+ AND mgpscd.sub_course_minutes_ > 0 AND mgpscd.music_group_id_ = #{musicGroupId}
|
|
|
+ ORDER BY mgpscd.id_
|
|
|
</select>
|
|
|
|
|
|
<select id="getUnUseWithStudents" resultMap="MusicGroupPaymentStudentCourseDetail">
|
|
@@ -233,16 +217,16 @@
|
|
|
mgpscd.user_id_,
|
|
|
mgpscd.course_type_,
|
|
|
SUM(mgpscd.total_course_minutes_) total_course_minutes_,
|
|
|
- SUM(mgpscd.used_course_minutes_) used_course_minutes_
|
|
|
+ SUM(mgpscd.used_course_minutes_) used_course_minutes_,
|
|
|
+ SUM(mgpscd.sub_course_minutes_) sub_course_minutes_
|
|
|
FROM music_group_payment_student_course_detail mgpscd
|
|
|
- LEFT JOIN music_group_payment_calender mgpc ON mgpscd.music_group_payment_calender_id_ = mgpc.id_
|
|
|
- WHERE mgpc.music_group_id_ = #{musicGroupId}
|
|
|
- AND user_id_ IN
|
|
|
+ WHERE mgpscd.music_group_id_ = #{musicGroupId}
|
|
|
+ AND mgpscd.user_id_ IN
|
|
|
<foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
|
|
|
#{studentId}
|
|
|
</foreach>
|
|
|
- GROUP BY mgpscd.user_id_,mgpscd.course_type_,mgpc.batch_no_
|
|
|
- HAVING used_course_minutes_ <= 0
|
|
|
+ GROUP BY mgpscd.user_id_,mgpscd.course_type_
|
|
|
+ HAVING mgpscd.sub_course_minutes_ > 0
|
|
|
</select>
|
|
|
|
|
|
<delete id="deleteByUserIdAndMusicGroupId">
|
|
@@ -276,14 +260,13 @@
|
|
|
WHEN mgpscd.used_course_minutes_ = 0 THEN mgpscd.total_course_minutes_
|
|
|
ELSE 0 END) 'value'
|
|
|
FROM music_group_payment_student_course_detail mgpscd
|
|
|
- LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpscd.music_group_payment_calender_id_
|
|
|
LEFT JOIN sys_user su ON su.id_ = mgpscd.user_id_
|
|
|
- WHERE mgpc.music_group_id_ = #{musicGroupId}
|
|
|
+ WHERE mgpscd.music_group_id_ = #{musicGroupId}
|
|
|
GROUP BY mgpscd.user_id_, mgpscd.course_type_
|
|
|
</select>
|
|
|
|
|
|
<sql id="sqlStudentSubTotalCourseTimes">
|
|
|
- WHERE mgpc.music_group_id_ = #{musicGroupId}
|
|
|
+ WHERE mgpscd.music_group_id_ = #{musicGroupId}
|
|
|
<if test="search != null and search != ''">
|
|
|
and (
|
|
|
mgpscd.user_id_ like CONCAT('%',#{search},'%')
|
|
@@ -292,10 +275,10 @@
|
|
|
)
|
|
|
</if>
|
|
|
<if test="hastimer != null and hastimer == true">
|
|
|
- and (mgpscd.used_course_minutes_ is null or mgpscd.used_course_minutes_ = 0)
|
|
|
+ and mgpscd.sub_course_minutes_ > 0
|
|
|
</if>
|
|
|
<if test="hastimer != null and hastimer == false">
|
|
|
- and mgpscd.used_course_minutes_ > 0
|
|
|
+ and mgpscd.used_course_minutes_ = 0
|
|
|
</if>
|
|
|
<if test="courseType != null and courseType != ''">
|
|
|
and mgpscd.course_type_ = #{courseType}
|
|
@@ -310,7 +293,6 @@
|
|
|
select count(*) from (
|
|
|
SELECT mgpscd.user_id_ FROM music_group_payment_student_course_detail mgpscd
|
|
|
LEFT JOIN sys_user su ON su.id_ = mgpscd.user_id_
|
|
|
- LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpscd.music_group_payment_calender_id_
|
|
|
left join (
|
|
|
SELECT
|
|
|
user_id_ ,GROUP_CONCAT(class_group_id_) as class_group_id_
|
|
@@ -331,7 +313,6 @@
|
|
|
SUM(CASE WHEN mgpscd.used_course_minutes_ = 0 THEN mgpscd.total_course_minutes_ ELSE 0 END) 'value'
|
|
|
FROM music_group_payment_student_course_detail mgpscd
|
|
|
LEFT JOIN sys_user su ON su.id_ = mgpscd.user_id_
|
|
|
- LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpscd.music_group_payment_calender_id_
|
|
|
left join (
|
|
|
SELECT
|
|
|
user_id_ ,GROUP_CONCAT(class_group_id_) as class_group_id_
|
|
@@ -353,8 +334,7 @@
|
|
|
SELECT SUM(c.a) >= SUM(c.b) FROM (
|
|
|
SELECT COUNT(DISTINCT mgpscd.course_type_) a,COUNT(DISTINCT mgpscd.total_course_minutes_) b FROM
|
|
|
music_group_payment_student_course_detail mgpscd
|
|
|
- LEFT JOIN music_group_payment_calender mgpc ON mgpscd.music_group_payment_calender_id_ = mgpc.id_
|
|
|
- WHERE mgpc.music_group_id_ = #{musicGroupId} AND mgpscd.used_course_minutes_ = 0
|
|
|
+ WHERE mgpscd.music_group_id_ = #{musicGroupId} AND mgpscd.sub_course_minutes_ > 0
|
|
|
AND mgpscd.course_type_ IN
|
|
|
<foreach collection="courseTypes" item="courseType" open="(" close=")" separator=",">
|
|
|
#{courseType}
|
|
@@ -364,10 +344,9 @@
|
|
|
#{studentId}
|
|
|
</foreach>)c
|
|
|
</select>
|
|
|
-
|
|
|
+
|
|
|
<update id="clearRemainCourseMinutesByMusicGroupId">
|
|
|
- update `music_group_payment_student_course_detail` cd LEFT JOIN `music_group_payment_calender` pc on cd.`music_group_payment_calender_id_` = pc.`id_`
|
|
|
- set cd.`used_course_minutes_` = 1
|
|
|
- WHERE cd.`used_course_minutes_` = 0 and pc.`music_group_id_` = #{musicGroupId}
|
|
|
+ update music_group_payment_student_course_detail
|
|
|
+ set sub_course_minutes_ = 0 WHERE sub_course_minutes_ > 0 and music_group_id_ = #{musicGroupId}
|
|
|
</update>
|
|
|
</mapper>
|