zouxuan 2 лет назад
Родитель
Сommit
39276d870a

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

@@ -31,9 +31,9 @@ public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, M
      * @author Joburgess
      * @date 2020.11.04
      */
-    List<MusicGroupPaymentStudentCourseDetail> getUnUseWithStudentAndCourseTypeAndCourseMinutes(@Param("batchNo") String batchNo,
-                                                                                                @Param("studentId") Integer studentId,
-                                                                                                @Param("courseType") CourseSchedule.CourseScheduleType courseType);
+    List<MusicGroupPaymentStudentCourseDetail> getUnUseWithStudentAndCourseTypeAndCourseMinutes(@Param("studentId") Integer studentId,
+                                                                                                @Param("courseType") CourseSchedule.CourseScheduleType courseType,
+                                                                                                @Param("musicGroupId") String musicGroupId);
 
     /**
      * @param studentId:

+ 22 - 11
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentCourseDetail.java

@@ -13,36 +13,47 @@ import java.math.BigDecimal;
  */
 public class MusicGroupPaymentStudentCourseDetail extends BaseEntity {
 
+	@ApiModelProperty(value = "乐团编号,改版后每个乐团每个学员只有一条记录", required = false)
+	private String musicGroupId;
+
 	/**  */
 	private Long id;
-	
-	/**  */
+
+	@ApiModelProperty(value = "缴费项目编号", required = false)
 	private Long musicGroupPaymentCalenderId;
-	
-	/**  */
+
+	@ApiModelProperty(value = "缴费项目详情编号", required = false)
 	private Long musicGroupPaymentCalenderDetailId;
 	
 	/**  */
 	private Integer userId;
-	
-	/**  */
+
+	@ApiModelProperty(value = "课程类型", required = false)
 	private CourseScheduleType courseType;
-	
-	/**  */
+
+	@ApiModelProperty(value = "总课时数", required = false)
 	private Integer totalCourseMinutes;
 
-	/**  */
+	@ApiModelProperty(value = "课程原价", required = false)
 	private BigDecimal courseOriginalPrice;
 
-	/**  */
+	@ApiModelProperty(value = "课程现价", required = false)
 	private BigDecimal courseCurrentPrice;
 
-	/**  已消耗时长*/
+	@ApiModelProperty(value = "已消耗时长", required = false)
 	private Integer usedCourseMinutes;
 
 	@ApiModelProperty(value = "标记是否云教练缴费项目",required = false)
 	private Boolean cloudTeacherPaymentFlag = false;
 
+	public String getMusicGroupId() {
+		return musicGroupId;
+	}
+
+	public void setMusicGroupId(String musicGroupId) {
+		this.musicGroupId = musicGroupId;
+	}
+
 	public Boolean getCloudTeacherPaymentFlag() {
 		return cloudTeacherPaymentFlag;
 	}

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -326,7 +326,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				}
 				//处理缴费的排课信息
 				if(musicGroupPaymentStudentCourseDetails == null){
-					musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(batchNo, studentId,courseSchedule.getType());
+					musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(studentId,courseSchedule.getType(),courseSchedule.getMusicGroupId());
 				}
 				if(musicGroupPaymentStudentCourseDetails == null || musicGroupPaymentStudentCourseDetails.size() == 0){
 					throw new BizException("学员缴费详情获取失败");
@@ -439,7 +439,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 
 							String batchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, studentId, courseScheduleTypeListEntry.getKey(),null);
 
-							List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(batchNo, studentId, courseScheduleTypeListEntry.getKey());
+							List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(studentId, courseScheduleTypeListEntry.getKey(),musicGroupId);
 							int totalCourseMinutes = musicGroupPaymentStudentCourseDetails.stream().mapToInt(MusicGroupPaymentStudentCourseDetail::getTotalCourseMinutes).reduce(0, Integer::sum);
 							if(CollectionUtils.isEmpty(musicGroupPaymentStudentCourseDetails) || totalCourseMinutes < typeCourseDuration){
 								SysUser user = teacherDao.getUser(studentId);

+ 3 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -322,6 +322,9 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         PaymentCalenderStatusEnum status;
         if (musicGroupPaymentBaseCalender.getPaymentType() == MUSIC_APPLY || musicGroupPaymentBaseCalender.getPayUserType() == SCHOOL) {
             status = AUDITING;
+            if(musicGroupPaymentBaseCalender.getPaymentType() == MUSIC_APPLY){
+                status = DRAFT;
+            }
         } else {
             //计算项目原现价
             BigDecimal courseCurrentAmount = musicGroupPaymentCalenderCourseSettingsService.getCurrentAmount(musicGroupPaymentBaseCalender);

+ 3 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -1438,9 +1438,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 //当前课程类型总课程时长
                 Integer typeCourseDuration = courseTypeCourseDurationMap.get(courseScheduleTypeListEntry.getKey());
 
-                String batchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, student.getUserId(), courseScheduleTypeListEntry.getKey(), null);
+//                String batchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, student.getUserId(), courseScheduleTypeListEntry.getKey(), null);
 
-                List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(batchNo, student.getUserId(), courseScheduleTypeListEntry.getKey());
+                List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails =
+                        musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(student.getUserId(), courseScheduleTypeListEntry.getKey(),musicGroupId);
                 int totalCourseMinutes = musicGroupPaymentStudentCourseDetails.stream().mapToInt(MusicGroupPaymentStudentCourseDetail::getTotalCourseMinutes).reduce(0, Integer::sum);
                 if (CollectionUtils.isEmpty(musicGroupPaymentStudentCourseDetails) || totalCourseMinutes < typeCourseDuration) {
                     iterator.remove();

+ 10 - 12
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentStudentCourseDetailMapper.xml

@@ -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"/>
@@ -42,10 +43,10 @@
             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_,
+        (music_group_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_, 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},
                 NOW(), NOW(), #{courseOriginalPrice}, #{courseCurrentPrice}, #{tenantId},#{cloudTeacherPaymentFlag})
@@ -54,12 +55,12 @@
     <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_,
+        (music_group_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_,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.courseCurrentPrice},#{item.tenantId},#{item.cloudTeacherPaymentFlag})
@@ -196,12 +197,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_ &lt;= 0
-        ORDER BY mgpscd.id_;
+        WHERE mgpscd.user_id_ = #{studentId}
+        AND mgpscd.course_type_ = #{courseType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        AND mgpscd.total_course_minutes_ > mgpscd.used_course_minutes_ AND mgpscd.music_group_id_ = #{musicGroupId}
+        ORDER BY mgpscd.id_
     </select>
 
     <select id="getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes" resultType="string">
@@ -209,8 +208,7 @@
         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}
+        WHERE mgpc.music_group_id_ = #{musicGroupId}
         <if test="studentId != null">
             AND mgpscd.user_id_ = #{studentId}
         </if>