Browse Source

fix 退团课程费用,退团删除课程购买记录

周箭河 5 years ago
parent
commit
3fc249840c

+ 7 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderCourseSettingsDao.java

@@ -19,15 +19,15 @@ public interface MusicGroupPaymentCalenderCourseSettingsDao extends BaseDAO<Inte
 	List<MusicGroupPaymentCalenderCourseSettings> getWithPaymentCalender(@Param("calenderId") Long calenderId);
 	List<MusicGroupPaymentCalenderCourseSettings> getWithPaymentCalender(@Param("calenderId") Long calenderId);
 
 
 	/**
 	/**
-	 * @describe 根据缴费日历和课程类型获取课程价格设置
-	 * @author Joburgess
-	 * @date 2020.11.04
 	 * @param calenderId:
 	 * @param calenderId:
 	 * @param courseType:
 	 * @param courseType:
 	 * @return com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings
 	 * @return com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings
+	 * @describe 根据缴费日历和课程类型获取课程价格设置
+	 * @author Joburgess
+	 * @date 2020.11.04
 	 */
 	 */
 	MusicGroupPaymentCalenderCourseSettings getWithPaymentCalenderAndCourseType(@Param("calenderId") Long calenderId,
 	MusicGroupPaymentCalenderCourseSettings getWithPaymentCalenderAndCourseType(@Param("calenderId") Long calenderId,
-																				@Param("courseType")CourseSchedule.CourseScheduleType courseType);
+																				@Param("courseType") CourseSchedule.CourseScheduleType courseType);
 
 
 	int deleteByMusicGroupPaymentCalenderId(Long musicGroupPaymentCalenderId);
 	int deleteByMusicGroupPaymentCalenderId(Long musicGroupPaymentCalenderId);
 
 
@@ -49,19 +49,20 @@ public interface MusicGroupPaymentCalenderCourseSettingsDao extends BaseDAO<Inte
 
 
 	/**
 	/**
 	 * 批量新增
 	 * 批量新增
+	 *
 	 * @param musicGroupPaymentCalenderCourseSettingsList
 	 * @param musicGroupPaymentCalenderCourseSettingsList
 	 * @return
 	 * @return
 	 */
 	 */
 	int batchInsert(List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList);
 	int batchInsert(List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList);
 
 
 	/**
 	/**
+	 * @param calenderId:
+	 * @return java.util.List<com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings>
 	 * @describe 获取收费标准
 	 * @describe 获取收费标准
 	 * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
 	 * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
 	 * @author zouxuan
 	 * @author zouxuan
 	 * @date 2020/10/30
 	 * @date 2020/10/30
 	 * @time 16:04
 	 * @time 16:04
-	 * @param calenderId:
-	 * @return java.util.List<com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings>
 	 */
 	 */
 	List<MusicGroupPaymentCalenderCourseSettings> queryCalenderCourseSettings(Long calenderId);
 	List<MusicGroupPaymentCalenderCourseSettings> queryCalenderCourseSettings(Long calenderId);
 }
 }

+ 16 - 8
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentStudentCourseDetailDao.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.dal.dao;
 package com.ym.mec.biz.dal.dao;
 
 
 import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
+
 import java.util.List;
 import java.util.List;
 
 
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
@@ -10,27 +11,34 @@ import org.apache.ibatis.annotations.Param;
 public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, MusicGroupPaymentStudentCourseDetail> {
 public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, MusicGroupPaymentStudentCourseDetail> {
 
 
     /**
     /**
-     * @describe 获取指定学员,指定课程,指定课程时长下的可用缴费记录
-     * @author Joburgess
-     * @date 2020.11.04
      * @param studentId:
      * @param studentId:
      * @param courseType:
      * @param courseType:
      * @param courseMinutes:
      * @param courseMinutes:
      * @return com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail
      * @return com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail
+     * @describe 获取指定学员,指定课程,指定课程时长下的可用缴费记录
+     * @author Joburgess
+     * @date 2020.11.04
      */
      */
     MusicGroupPaymentStudentCourseDetail getUnUseWithStudentAndCourseTypeAndCourseMinutes(@Param("studentId") Integer studentId,
     MusicGroupPaymentStudentCourseDetail getUnUseWithStudentAndCourseTypeAndCourseMinutes(@Param("studentId") Integer studentId,
-                                                                                           @Param("courseType")CourseSchedule.CourseScheduleType courseType,
-                                                                                           @Param("courseMinutes") Integer courseMinutes);
+                                                                                          @Param("courseType") CourseSchedule.CourseScheduleType courseType,
+                                                                                          @Param("courseMinutes") Integer courseMinutes);
 
 
     /**
     /**
+     * @param studentIds:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail>
      * @describe
      * @describe
      * @author Joburgess
      * @author Joburgess
      * @date 2020.11.04
      * @date 2020.11.04
-     * @param studentIds:
-     * @return java.util.List<com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail>
      */
      */
     List<MusicGroupPaymentStudentCourseDetail> getUnUseWithStudents(@Param("musicGroupId") String musicGroupId, @Param("studentIds") List<Integer> studentIds);
     List<MusicGroupPaymentStudentCourseDetail> getUnUseWithStudents(@Param("musicGroupId") String musicGroupId, @Param("studentIds") List<Integer> studentIds);
 
 
-	int batchInsert(List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList);
+    int batchInsert(List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList);
 
 
+    /**
+     * 删除用户购买乐团课程记录
+     * @param userId
+     * @param musicGroupId
+     * @return
+     */
+    int deleteByUserIdAndMusicGroupId(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId);
 }
 }

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -157,6 +157,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
     @Autowired
     @Autowired
     private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
     private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
+    @Autowired
+    private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
 
 
     private SimpleDateFormat sdf_ymd = new SimpleDateFormat("yyyy-MM-dd");
     private SimpleDateFormat sdf_ymd = new SimpleDateFormat("yyyy-MM-dd");
 
 
@@ -1515,6 +1517,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
 
             studentRegistrationDao.update(studentRegistration);
             studentRegistrationDao.update(studentRegistration);
 
 
+            //删除用户购买的课程记录
+            musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndMusicGroupId(userId,musicGroupId);
+
             BigDecimal amount = new BigDecimal(0);
             BigDecimal amount = new BigDecimal(0);
 
 
             // 判断乐器是否是租赁
             // 判断乐器是否是租赁
@@ -1620,6 +1625,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
 
         studentRegistrationDao.update(studentRegistration);
         studentRegistrationDao.update(studentRegistration);
 
 
+        //删除用户购买的课程记录
+        musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndMusicGroupId(userId,musicGroupId);
+
         BigDecimal amount = new BigDecimal(0);
         BigDecimal amount = new BigDecimal(0);
 
 
         // 判断乐器是否是租赁
         // 判断乐器是否是租赁

+ 127 - 110
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml

@@ -3,124 +3,141 @@
 <!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
 <!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
 <mapper namespace="com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao">
 <mapper namespace="com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao">
 
 
-	<resultMap
-		type="com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail"
-		id="MusicGroupPaymentStudentCourseDetail">
-		<result column="id_" property="id" />
-		<result column="music_group_payment_calender_id_" property="musicGroupPaymentCalenderId" />
-		<result column="music_group_payment_calender_detail_id_"
-			property="musicGroupPaymentCalenderDetailId" />
-		<result column="user_id_" property="userId" />
-		<result column="course_type_" property="courseType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler" />
-		<result column="total_course_minutes_" property="totalCourseMinutes" />
-		<result column="used_course_minutes_" property="usedCourseMinutes" />
-		<result column="create_time_" property="createTime" />
-		<result column="update_time_" property="updateTime" />
-	</resultMap>
+    <resultMap
+            type="com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail"
+            id="MusicGroupPaymentStudentCourseDetail">
+        <result column="id_" property="id"/>
+        <result column="music_group_payment_calender_id_" property="musicGroupPaymentCalenderId"/>
+        <result column="music_group_payment_calender_detail_id_"
+                property="musicGroupPaymentCalenderDetailId"/>
+        <result column="user_id_" property="userId"/>
+        <result column="course_type_" property="courseType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+        <result column="total_course_minutes_" property="totalCourseMinutes"/>
+        <result column="used_course_minutes_" property="usedCourseMinutes"/>
+        <result column="create_time_" property="createTime"/>
+        <result column="update_time_" property="updateTime"/>
+    </resultMap>
 
 
-	<!-- 根据主键查询一条记录 -->
-	<select id="get" resultMap="MusicGroupPaymentStudentCourseDetail">
-		SELECT * FROM music_group_payment_student_course_detail WHERE id_ =
-		#{id}
-	</select>
+    <!-- 根据主键查询一条记录 -->
+    <select id="get" resultMap="MusicGroupPaymentStudentCourseDetail">
+        SELECT *
+        FROM music_group_payment_student_course_detail
+        WHERE id_ =
+              #{id}
+    </select>
 
 
-	<!-- 全查询 -->
-	<select id="findAll" resultMap="MusicGroupPaymentStudentCourseDetail">
-		SELECT * FROM
-		music_group_payment_student_course_detail ORDER BY id_
-	</select>
+    <!-- 全查询 -->
+    <select id="findAll" resultMap="MusicGroupPaymentStudentCourseDetail">
+        SELECT *
+        FROM music_group_payment_student_course_detail
+        ORDER BY id_
+    </select>
 
 
-	<!-- 向数据库增加一条记录 -->
-	<insert id="insert"
-		parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail"
-		useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval 
-			AS ID FROM DUAL </selectKey> -->
-		INSERT INTO music_group_payment_student_course_detail
-		(id_,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_)
-		VALUES(#{id},#{musicGroupPaymentCalenderId},#{musicGroupPaymentCalenderDetailId},#{userId},#{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{totalCourseMinutes},#{usedCourseMinutes},#{createTime},#{updateTime})
-	</insert>
-	
-	<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
+    <!-- 向数据库增加一条记录 -->
+    <insert id="insert"
+            parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail"
+            useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+        <!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval
+            AS ID FROM DUAL </selectKey> -->
+        INSERT INTO music_group_payment_student_course_detail
+        (id_,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_)
+        VALUES(#{id},#{musicGroupPaymentCalenderId},#{musicGroupPaymentCalenderDetailId},#{userId},#{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{totalCourseMinutes},#{usedCourseMinutes},#{createTime},#{updateTime})
+    </insert>
+
+    <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
             keyProperty="id">
             keyProperty="id">
-		INSERT INTO music_group_payment_student_course_detail
-		(id_,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_)
-		VALUES
-		<foreach collection="list" item="item" separator=",">
-		(#{item.id},#{item.musicGroupPaymentCalenderId},#{item.musicGroupPaymentCalenderDetailId},#{item.userId},#{item.courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.totalCourseMinutes},#{item.usedCourseMinutes},#{item.createTime},#{item.updateTime})
-		</foreach>
-	</insert>
+        INSERT INTO music_group_payment_student_course_detail
+        (id_,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_)
+        VALUES
+        <foreach collection="list" item="item" separator=",">
+            (#{item.id},#{item.musicGroupPaymentCalenderId},#{item.musicGroupPaymentCalenderDetailId},#{item.userId},#{item.courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{item.totalCourseMinutes},#{item.usedCourseMinutes},#{item.createTime},#{item.updateTime})
+        </foreach>
+    </insert>
 
 
-	<!-- 根据主键查询一条记录 -->
-	<update id="update"
-		parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail">
-		UPDATE music_group_payment_student_course_detail
-		<set>
-			<if test="usedCourseMinutes != null">
-				used_course_minutes_ = #{usedCourseMinutes},
-			</if>
-			<if test="totalCourseMinutes != null">
-				total_course_minutes_ = #{totalCourseMinutes},
-			</if>
-			<if test="userId != null">
-				user_id_ = #{userId},
-			</if>
-			<if test="musicGroupPaymentCalenderDetailId != null">
-				music_group_payment_calender_detail_id_ = #{musicGroupPaymentCalenderDetailId},
-			</if>
-			<if test="id != null">
-				id_ = #{id},
-			</if>
-			<if test="updateTime != null">
-				update_time_ = #{updateTime},
-			</if>
-			<if test="musicGroupPaymentCalenderId != null">
-				music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId},
-			</if>
-			<if test="courseType != null">
-				course_type_ = #{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-			</if>
-			<if test="createTime != null">
-				create_time_ = #{createTime},
-			</if>
-		</set>
-		WHERE id_ = #{id}
-	</update>
+    <!-- 根据主键查询一条记录 -->
+    <update id="update"
+            parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail">
+        UPDATE music_group_payment_student_course_detail
+        <set>
+            <if test="usedCourseMinutes != null">
+                used_course_minutes_ = #{usedCourseMinutes},
+            </if>
+            <if test="totalCourseMinutes != null">
+                total_course_minutes_ = #{totalCourseMinutes},
+            </if>
+            <if test="userId != null">
+                user_id_ = #{userId},
+            </if>
+            <if test="musicGroupPaymentCalenderDetailId != null">
+                music_group_payment_calender_detail_id_ = #{musicGroupPaymentCalenderDetailId},
+            </if>
+            <if test="id != null">
+                id_ = #{id},
+            </if>
+            <if test="updateTime != null">
+                update_time_ = #{updateTime},
+            </if>
+            <if test="musicGroupPaymentCalenderId != null">
+                music_group_payment_calender_id_ = #{musicGroupPaymentCalenderId},
+            </if>
+            <if test="courseType != null">
+                course_type_ = #{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+            </if>
+            <if test="createTime != null">
+                create_time_ = #{createTime},
+            </if>
+        </set>
+        WHERE id_ = #{id}
+    </update>
 
 
-	<!-- 根据主键删除一条记录 -->
-	<delete id="delete">
-		DELETE FROM
-		music_group_payment_student_course_detail WHERE id_ = #{id}
-	</delete>
+    <!-- 根据主键删除一条记录 -->
+    <delete id="delete">
+        DELETE
+        FROM music_group_payment_student_course_detail
+        WHERE id_ = #{id}
+    </delete>
 
 
-	<!-- 分页查询 -->
-	<select id="queryPage" resultMap="MusicGroupPaymentStudentCourseDetail"
-		parameterType="map">
-		SELECT * FROM music_group_payment_student_course_detail ORDER BY id_
-		<include refid="global.limit" />
-	</select>
+    <!-- 分页查询 -->
+    <select id="queryPage" resultMap="MusicGroupPaymentStudentCourseDetail"
+            parameterType="map">
+        SELECT * FROM music_group_payment_student_course_detail ORDER BY id_
+        <include refid="global.limit"/>
+    </select>
 
 
-	<!-- 查询当前表的总记录数 -->
-	<select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM
-		music_group_payment_student_course_detail
-	</select>
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryCount" resultType="int">
+        SELECT COUNT(*)
+        FROM music_group_payment_student_course_detail
+    </select>
     <select id="getUnUseWithStudentAndCourseTypeAndCourseMinutes" resultMap="MusicGroupPaymentStudentCourseDetail">
     <select id="getUnUseWithStudentAndCourseTypeAndCourseMinutes" resultMap="MusicGroupPaymentStudentCourseDetail">
-		SELECT * FROM music_group_payment_student_course_detail
-		WHERE user_id_=#{studentId}
-		AND course_type_=#{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
-		AND total_course_minutes_ &gt;= #{courseMinutes}
-		AND used_course_minutes_ &lt;= 0
-		ORDER BY id_ DESC LIMIT 1;
-	</select>
+        SELECT *
+        FROM music_group_payment_student_course_detail
+        WHERE user_id_ = #{studentId}
+          AND course_type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+          AND total_course_minutes_ &gt;= #{courseMinutes}
+          AND used_course_minutes_ &lt;= 0
+        ORDER BY id_ DESC
+        LIMIT 1;
+    </select>
     <select id="getUnUseWithStudents" resultMap="MusicGroupPaymentStudentCourseDetail">
     <select id="getUnUseWithStudents" resultMap="MusicGroupPaymentStudentCourseDetail">
-		SELECT * 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 used_course_minutes_ &lt;= 0
-		AND mgpc.music_group_id_ = #{musicGroupId}
-		AND user_id_ IN
-		<foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
-			#{studentId}
-		</foreach>
-	</select>
+        SELECT * 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 used_course_minutes_ &lt;= 0
+        AND mgpc.music_group_id_ = #{musicGroupId}
+        AND user_id_ IN
+        <foreach collection="studentIds" item="studentId" open="(" close=")" separator=",">
+            #{studentId}
+        </foreach>
+    </select>
+
+    <delete id="deleteByUserIdAndMusicGroupId">
+        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}
+        )
+    </delete>
 </mapper>
 </mapper>