Parcourir la source

Merge remote-tracking branch 'origin/master'

Joburgess il y a 4 ans
Parent
commit
2988b8c476

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

@@ -43,7 +43,7 @@ public interface MusicGroupPaymentStudentCourseDetailDao extends BaseDAO<Long, M
     String getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(@Param("musicGroupId") String musicGroupId,
                                                                    @Param("studentId") Integer studentId,
                                                                    @Param("courseType") CourseSchedule.CourseScheduleType courseType,
-                                                                   @Param("batchNo") String batchNo);
+                                                                   @Param("batchNos") List<String> batchNos);
 
     /**
      * @param studentIds:

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupPaymentCalenderDto.java

@@ -33,6 +33,26 @@ public class MusicGroupPaymentCalenderDto {
 	
 	private String batchNo;
 
+	private Boolean mergeClassFlag = false;
+
+	private List<String> IgnoreBatchNoList = null;
+
+	public List<String> getIgnoreBatchNoList() {
+		return IgnoreBatchNoList;
+	}
+
+	public void setIgnoreBatchNoList(List<String> ignoreBatchNoList) {
+		IgnoreBatchNoList = ignoreBatchNoList;
+	}
+
+	public Boolean getMergeClassFlag() {
+		return mergeClassFlag;
+	}
+
+	public void setMergeClassFlag(Boolean mergeClassFlag) {
+		this.mergeClassFlag = mergeClassFlag;
+	}
+
 	private MusicGroupPaymentCalender.PaymentCalenderStatusEnum status;
 
 	private List<MusicGroupPaymentDateRange> musicGroupPaymentDateRangeList = new ArrayList<MusicGroupPaymentDateRange>();

+ 13 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -3652,12 +3652,12 @@ 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){
+
                     List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = calenderDto.getMusicGroupPaymentCalenderCourseSettingsList();
                     for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
                         OrganizationCourseUnitPriceSettings defaultUnitPrice = organizationCourseUnitPriceSettingsDao.queryByOrganIdAndCourseTypeAndChargeType(
@@ -3674,20 +3674,25 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                     }
                 }
             }
-            //创建缴费项目
+            List<String> batchNoList = new ArrayList<>();
+            //创建缴费项目,  多个缴费项目分成多个批次号
             for (MusicGroupPaymentCalenderDto calenderDto : paymentCalenderDtos) {
-                if(status != null && status == AUDITING){
-                    calenderDto.setStatus(AUDITING);
+                if(batchNoList.size() > 0){
+                    calenderDto.setIgnoreBatchNoList(batchNoList);
                 }
-                //指定批次
-                calenderDto.setBatchNo(batchNo);
+                calenderDto.setMergeClassFlag(true);
                 musicGroupPaymentCalenderService.create(calenderDto);
+                if(batchNos.length() > 0){
+                    batchNos.append(",");
+                }
+                batchNoList.add(calenderDto.getBatchNo());
+                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));

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

@@ -331,6 +331,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 		for (Integer studentId : studentIds) {
 			List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = null;
 			BigDecimal typeCourseTotalOriginalPrice = new BigDecimal("0"), typeCourseTotalCurrentPrice = new BigDecimal("0");
+			int index = courseScheduleStudentPayments.size();
 			for (int i = 0; i < courseSchedules.size(); i++) {
 				CourseSchedule courseSchedule = courseSchedules.get(i);
 				//优先处理之前的剩余课程
@@ -384,14 +385,15 @@ 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);
 				cssp.setActualPrice(BigDecimal.ZERO);
 				courseScheduleStudentPayments.add(cssp);
 				if(courseSchedules.size() - 1 == i){
-					CourseScheduleStudentPayment scheduleStudentPayment = courseScheduleStudentPayments.get(0);
+					CourseScheduleStudentPayment scheduleStudentPayment = courseScheduleStudentPayments.get(index);
 					scheduleStudentPayment.setOriginalPrice(scheduleStudentPayment.getOriginalPrice().add(courseSetting.getCourseOriginalPrice().subtract(typeCourseTotalOriginalPrice)));
 					scheduleStudentPayment.setExpectPrice(scheduleStudentPayment.getExpectPrice().add(courseSetting.getCourseCurrentPrice().subtract(typeCourseTotalCurrentPrice)));
 				}

+ 11 - 9
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;
@@ -184,7 +185,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 			throw new BizException("请登录");
 		}
 		// 所有缴费项目已完成排课才能创建下一个缴费项目
-		String orignBatchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, null, null,null);
+		String orignBatchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, null, null,musicGroupPaymentCalenderDto.getIgnoreBatchNoList());
 		if (StringUtils.isNoneBlank(orignBatchNo)) {
 			if(StringUtils.isEmpty(musicGroupPaymentCalenderDto.getBatchNo()) || !musicGroupPaymentCalenderDto.getBatchNo().equals(orignBatchNo)){
 				throw new BizException("当前乐团存在未排课的缴费项目,请先完成排课再操作");
@@ -202,12 +203,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		PaymentCalenderStatusEnum status = PaymentCalenderStatusEnum.NO;
 
 		Date date = new Date();
-		String batchNo;
-		if(StringUtils.isEmpty(musicGroupPaymentCalenderDto.getBatchNo())){
-			batchNo = idGeneratorService.generatorId() + "";
-		}else {
-			batchNo = musicGroupPaymentCalenderDto.getBatchNo();
-		}
+		String batchNo = idGeneratorService.generatorId() + "";
 
 		// 获取设置的课程
 		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettingsList = musicGroupPaymentCalenderDto
@@ -381,6 +377,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 
 			// 设置批次号
 			musicGroupPaymentCalender.setBatchNo(batchNo);
+			musicGroupPaymentCalenderDto.setBatchNo(batchNo);
 			musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
 
 
@@ -403,7 +400,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 				// 如果是进行中加学生
 				if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
 					addStudent(musicGroupPaymentCalender, currentMusicGroupPaymentCalenderCourseSettings);
-				}else if(StringUtils.isNotEmpty(musicGroupPaymentCalenderDto.getBatchNo())){
+				}else if(musicGroupPaymentCalenderDto.getMergeClassFlag()){
 					//缴费项目添加学员
 					int[] ints = Arrays.stream(musicGroupPaymentCalenderDto.getStudentIds().split(",")).mapToInt(Integer::parseInt).toArray();
 					List<Integer> list2 = Arrays.stream(ints).boxed().collect(Collectors.toList());
@@ -909,9 +906,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">

+ 6 - 3
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
@@ -156,8 +156,11 @@
             <if test="studentId != null">
             AND mgpscd.user_id_ = #{studentId}
             </if>
-            <if test="batchNo != null">
-            AND mgpc.batch_no_ = #{batchNo}
+            <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}

+ 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>