Bläddra i källkod

合班拆班多个缴费项目,拆分成多个批次号,改动最小。

zouxuan 4 år sedan
förälder
incheckning
e1d66d4a7d

+ 7 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -3652,12 +3652,11 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         MusicGroup musicGroup = musicGroupDao.findByClassGroupId(classGroupIds.get(0));
         //生成缴费记录,同一个批次
         MusicGroupPaymentCalender.PaymentCalenderStatusEnum status = null;
-        String batchNo = null;
         List<MusicGroupPaymentCalenderDto> paymentCalenderDtos = mergeClassSplitClassAffirmDto.getMusicGroupPaymentCalenderDtos();
+        StringBuffer batchNos = new StringBuffer();
         if(paymentCalenderDtos != null && paymentCalenderDtos.size() > 0){
-            batchNo = idGeneratorService.generatorId() + "";
             for (MusicGroupPaymentCalenderDto calenderDto : paymentCalenderDtos) {
-                if(status == null || status != AUDITING){
+                if(status != null && status != AUDITING){
                     List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = calenderDto.getMusicGroupPaymentCalenderCourseSettingsList();
                     for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
                         OrganizationCourseUnitPriceSettings defaultUnitPrice = organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(
@@ -3676,18 +3675,17 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             }
             //创建缴费项目
             for (MusicGroupPaymentCalenderDto calenderDto : paymentCalenderDtos) {
-                if(status != null && status == AUDITING){
-                    calenderDto.setStatus(AUDITING);
-                }
-                //指定批次
-                calenderDto.setBatchNo(batchNo);
                 musicGroupPaymentCalenderService.create(calenderDto);
+                if(batchNos.length() > 0){
+                    batchNos.append(",");
+                }
+                batchNos.append(calenderDto.getBatchNo());
             }
         }
 
         //记录申请信息
         MusicGroupStudentClassAdjust musicGroupStudentClassAdjust = new MusicGroupStudentClassAdjust();
-        musicGroupStudentClassAdjust.setBatchNo(batchNo);
+        musicGroupStudentClassAdjust.setBatchNo(batchNos.toString());
         musicGroupStudentClassAdjust.setMusicGroupId(musicGroup.getId());
         musicGroupStudentClassAdjust.setOperatorId(sysUser.getId());
         musicGroupStudentClassAdjust.setNewClassGroupJson(JSON.toJSONString(classGroup4MixDtos));

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

@@ -384,7 +384,8 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				cssp.setMusicGroupId(courseSchedule.getMusicGroupId());
 				cssp.setCourseScheduleId(courseSchedule.getId());
 				cssp.setClassGroupId(courseSchedule.getClassGroupId());
-				cssp.setBatchNo(batchNo);
+				MusicGroupPaymentCalender musicGroupPaymentCalender = musicGroupPaymentCalenderDao.get(calenderIds.iterator().next());
+				cssp.setBatchNo(musicGroupPaymentCalender.getBatchNo());
 				cssp.setUserId(studentId);
 				cssp.setOriginalPrice(courseOriginalPrice);
 				cssp.setExpectPrice(courseCurrentPrice);

+ 7 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.service.impl;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.SCHOOL;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PayUserType.STUDENT;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum.AUDITING;
+import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentCalenderStatusEnum.REJECT;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.ADD_STUDENT;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_APPLY;
 import static com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender.PaymentType.MUSIC_RENEW;
@@ -909,9 +910,14 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		if(musicGroupStudentClassAdjust == null){
 			return;
 		}
+		List<MusicGroupPaymentCalender> musicGroupPaymentCalenders = musicGroupPaymentCalenderDao.findByBatchNo(musicGroupStudentClassAdjust.getBatchNo());
+		for (MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenders) {
+			if(musicGroupPaymentCalender.getStatus() == AUDITING || musicGroupPaymentCalender.getStatus() == REJECT){
+				return;
+			}
+		}
 		List<ClassGroup4MixDto> classGroup4MixDtos = JSON.parseArray(musicGroupStudentClassAdjust.getNewClassGroupJson(), ClassGroup4MixDto.class);
 
-		List<MusicGroupPaymentCalender> musicGroupPaymentCalenders = musicGroupPaymentCalenderDao.findByBatchNo(batchNo);
 		for (MusicGroupPaymentCalender calender : musicGroupPaymentCalenders) {
 			//缴费项目添加学员
 			int[] ints = Arrays.stream(calender.getStudentIds().split(",")).mapToInt(Integer::parseInt).toArray();

+ 10 - 1
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -3426,13 +3426,22 @@
         GROUP BY cssp.course_schedule_id_,cs.id_  HAVING COUNT(cssp.id_) = 0
     </select>
     <select id="findNoStartMasterCourseNum" resultType="int">
-        SELECT count(new_course_id_) FROM course_schedule
+        SELECT COUNT(a.course_id_) FROM (
+        SELECT new_course_id_ course_id_ FROM course_schedule
         WHERE new_course_id_ IN (SELECT id_ FROM course_schedule
         WHERE class_group_id_ IN
         <foreach collection="classGroupIds" open="(" close=")" separator="," item="item">
             #{item}
         </foreach>
         AND CONCAT(class_date_,' ',start_class_time_) > NOW())
+        UNION ALL
+        SELECT id_ course_id_ FROM course_schedule
+        WHERE class_group_id_ IN
+        <foreach collection="classGroupIds" open="(" close=")" separator="," item="item">
+            #{item}
+        </foreach>
+        AND new_course_id_ > 0
+        AND CONCAT(class_date_,' ',start_class_time_) > NOW()) a
     </select>
     <select id="getLock" resultMap="CourseSchedule">
         SELECT * FROM course_schedule WHERE id_ = #{courseId} FOR UPDATE

+ 2 - 2
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml

@@ -401,7 +401,7 @@
     </select>
 
 	<select id="findByBatchNo" resultMap="MusicGroupPaymentCalender">
-        SELECT * FROM music_group_payment_calender WHERE batch_no_=#{batchNo}
+        SELECT * FROM music_group_payment_calender WHERE FIND_IN_SET(batch_no_,#{batchNo})
     </select>
 
     <resultMap id="MusicGroupPaymentCalenderAuditDtoMap" type="com.ym.mec.biz.dal.dto.MusicGroupPaymentCalenderAuditDto">
@@ -540,7 +540,7 @@
     <select id="findByBatchNoAndStudentId" resultType="Long">
         SELECT DISTINCT mgpc.id_ FROM music_group_payment_calender mgpc
         LEFT JOIN music_group_payment_calender_detail mgpcd ON mgpcd.music_group_payment_calender_id_ = mgpc.id_
-        WHERE batch_no_ = #{batchNo} AND mgpcd.user_id_ = #{studentId}
+        WHERE FIND_IN_SET(batch_no_,#{batchNo}) AND mgpcd.user_id_ = #{studentId}
     </select>
 
     <select id="getPaymentCalenderWithCalenderIdsAndPayUserType" resultMap="MusicGroupPaymentCalender">

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

@@ -139,7 +139,7 @@
             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.batch_no_ = #{batchNo}
+          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

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/MusicGroupStudentClassAdjustMapper.xml

@@ -98,6 +98,6 @@
 		SELECT COUNT(*) FROM music_group_student_class_adjust
 	</select>
     <select id="findByBatchNo" resultMap="MusicGroupStudentClassAdjust">
-		SELECT * FROM music_group_student_class_adjust WHERE batch_no_ = #{batchNo}
+		SELECT * FROM music_group_student_class_adjust WHERE FIND_IN_SET(#{batchNo},batch_no_)
 	</select>
 </mapper>