zouxuan 2 роки тому
батько
коміт
c01980c9e2

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupOrganizationCourseSettingsDao.java

@@ -3,6 +3,8 @@ package com.ym.mec.biz.dal.dao;
 import com.ym.mec.biz.dal.entity.MusicGroupOrganizationCourseSettings;
 import com.ym.mec.common.dal.BaseDAO;
 
+import java.util.List;
+
 public interface MusicGroupOrganizationCourseSettingsDao extends BaseDAO<Integer, MusicGroupOrganizationCourseSettings> {
 
 }

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

@@ -1,13 +1,12 @@
 package com.ym.mec.biz.dal.dao;
 
-import java.util.List;
-import java.util.Map;
-
-import org.apache.ibatis.annotations.Param;
-
-import com.ym.mec.biz.dal.entity.OrganizationCourseUnitPriceSettings;
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
+import com.ym.mec.biz.dal.entity.OrganizationCourseUnitPriceSettings;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
 
 public interface OrganizationCourseUnitPriceSettingsDao extends BaseDAO<Integer, OrganizationCourseUnitPriceSettings> {
 
@@ -38,4 +37,6 @@ public interface OrganizationCourseUnitPriceSettingsDao extends BaseDAO<Integer,
     List<Map<String, Integer>> queryMapByOrganIdAndChargeTypeId(@Param("chargeTypeId") Integer chargeTypeId, @Param("organId") Integer organId);
 
     List<OrganizationCourseUnitPriceSettings> querySingle(@Param("organId")Integer organId, @Param("courseType") String courseType, @Param("tenantId") Integer tenantId);
+
+	List<OrganizationCourseUnitPriceSettings> queryByMusicGroupId(@Param("musicGroupId") String musicGroupId);
 }

+ 9 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderCourseSettings.java

@@ -1,10 +1,13 @@
 package com.ym.mec.biz.dal.entity;
 
+import io.swagger.annotations.ApiModelProperty;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType;
 import com.ym.mec.common.entity.BaseEntity;
 
+import java.math.BigDecimal;
+
 /**
  * 对应数据库表(music_group_payment_calender_course_settings):
  */
@@ -19,22 +22,22 @@ public class MusicGroupPaymentCalenderCourseSettings extends BaseEntity {
 	/**  */
 	private String name;
 	
-	/** 课程类型 */
+	@ApiModelProperty(value = "课程类型", required = false)
 	private CourseSchedule.CourseScheduleType courseType;
 
-	/** 课程总时间 */
+	@ApiModelProperty(value = "课程总时间", required = false)
 	private Integer courseTotalMinuties;
 	
-	/** 单价 */
+	@ApiModelProperty(value = "单价", required = false)
 	private java.math.BigDecimal unitPrice;
 	
-	/** 课程原价 */
+	@ApiModelProperty(value = "课程原价", required = false)
 	private java.math.BigDecimal courseOriginalPrice;
 	
-	/** 课程现价 */
+	@ApiModelProperty(value = "课程现价", required = false)
 	private java.math.BigDecimal courseCurrentPrice;
 	
-	/** 是否学生可选 */
+	@ApiModelProperty(value = "是否学生可选", required = false)
 	private boolean isStudentOptional = true;
 	
 	/**  */

+ 23 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentStudentCourseDetail.java

@@ -12,7 +12,7 @@ import java.math.BigDecimal;
  */
 public class MusicGroupPaymentStudentCourseDetail extends BaseEntity {
 
-	@ApiModelProperty(value = "乐团编号,改版后每个乐团每个学员只有一条记录", required = false)
+	@ApiModelProperty(value = "乐团编号", required = false)
 	private String musicGroupId;
 
 	private Long id;
@@ -37,6 +37,12 @@ public class MusicGroupPaymentStudentCourseDetail extends BaseEntity {
 	@ApiModelProperty(value = "课程现价", required = false)
 	private BigDecimal courseCurrentPrice;
 
+	@ApiModelProperty(value = "剩余可排课课程原价", required = false)
+	private java.math.BigDecimal subCourseOriginalPrice;
+
+	@ApiModelProperty(value = "剩余可排课课程现价", required = false)
+	private java.math.BigDecimal subCourseCurrentPrice;
+
 	@ApiModelProperty(value = "已消耗时长", required = false)
 	private Integer usedCourseMinutes;
 
@@ -46,6 +52,22 @@ public class MusicGroupPaymentStudentCourseDetail extends BaseEntity {
 	@ApiModelProperty(value = "标记是否云教练缴费项目",required = false)
 	private Boolean cloudTeacherPaymentFlag = false;
 
+	public BigDecimal getSubCourseOriginalPrice() {
+		return subCourseOriginalPrice;
+	}
+
+	public void setSubCourseOriginalPrice(BigDecimal subCourseOriginalPrice) {
+		this.subCourseOriginalPrice = subCourseOriginalPrice;
+	}
+
+	public BigDecimal getSubCourseCurrentPrice() {
+		return subCourseCurrentPrice;
+	}
+
+	public void setSubCourseCurrentPrice(BigDecimal subCourseCurrentPrice) {
+		this.subCourseCurrentPrice = subCourseCurrentPrice;
+	}
+
 	public Integer getSubCourseMinutes() {
 		return subCourseMinutes;
 	}

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleStudentPaymentService.java

@@ -153,4 +153,6 @@ public interface CourseScheduleStudentPaymentService extends BaseService<Long, C
 	* @date 2022/9/26 18:08
 	*/
     void splitStudentPayment(List<CourseScheduleStudentPayment> courseScheduleStudentPayments,List<CourseScheduleStudentPayment> studentPayments);
+
+    CourseScheduleStudentPayment init(CourseSchedule courseSchedule);
 }

+ 0 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java

@@ -89,17 +89,6 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
 	boolean deleteByBatchNo(String batchNo);
 
 	/**
-	 * @describe 更新乐团学员缴费状态
-	 * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
-	 * @author zouxuan
-	 * @date 2020/9/21
-	 * @time 13:56
-	 * @param :
-	 * @return void
-	 */
-	void autoUpdateMusicGroupStudentFeeStatus();
-
-	/**
 	 * @describe 乐团缴费日历审核列表
 	 * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
 	 * @author zouxuan

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

@@ -73,6 +73,8 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	private MusicGroupStudentClassAdjustDao musicGroupStudentClassAdjustDao;
 	@Autowired
 	private StudentPaymentOrderDao studentPaymentOrderDaop;
+	@Autowired
+	private OrganizationCourseUnitPriceSettingsDao organizationCourseUnitPriceSettingsDao;
 
 	@Override
 	public BaseDAO<Long, CourseScheduleStudentPayment> getDAO() {
@@ -389,8 +391,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 	public void createForMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds) {
 		Map<Integer, List<CourseSchedule>> memberCourseMap = courseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getMemberFlag));
-		//课程是否需要标记为云教练赠送
-		Boolean cloudTeacherPaymentFlag = false;
+		List<Long> operatingCourse = new ArrayList<>();
 		Long calenderId = null;
 		for (Integer memberFlag : memberCourseMap.keySet()) {
 			List<CourseSchedule> courseScheduleList = memberCourseMap.get(memberFlag);
@@ -426,8 +427,6 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 
 					List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
 
-					List<String> allBatchNos = new ArrayList<>();
-
 					for (Integer studentId : studentIds) {
 						Set<Long> existCourseIds = new HashSet<>();
 						if(studentCourseIdsMap.containsKey(studentId)){
@@ -437,8 +436,6 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 							//当前课程类型总课程时长
 							Integer typeCourseDuration = courseTypeCourseDurationMap.get(courseScheduleTypeListEntry.getKey()).get(studentId);
 
-							String batchNo = musicGroupPaymentStudentCourseDetailDao.getUnUseBatchNoWithStudentAndCourseTypeAndCourseMinutes(musicGroupId, studentId, courseScheduleTypeListEntry.getKey(),null);
-
 							List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(studentId, courseScheduleTypeListEntry.getKey(),musicGroupId);
 							int subCourseMinutes = musicGroupPaymentStudentCourseDetails.stream().mapToInt(MusicGroupPaymentStudentCourseDetail::getSubCourseMinutes).reduce(0, Integer::sum);
 							if(CollectionUtils.isEmpty(musicGroupPaymentStudentCourseDetails) || subCourseMinutes < typeCourseDuration){
@@ -453,29 +450,8 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 								throw new BizException("缴费设置异常");
 							}
 
-							List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalendersAndCourseType(calenderIds, courseScheduleTypeListEntry.getKey());
-							int originalCourseTotalMinutes = musicGroupPaymentCalenderCourseSettings.stream().mapToInt(MusicGroupPaymentCalenderCourseSettings::getCourseTotalMinuties).reduce(0, Integer::sum);
-							if(Objects.isNull(musicGroupPaymentCalenderCourseSettings) || originalCourseTotalMinutes != subCourseMinutes){
-								throw new BizException("缴费设置异常");
-							}
-
-							allBatchNos.add(batchNo);
-
-							BigDecimal totalCourseOriginalPrice = musicGroupPaymentCalenderCourseSettings.stream().map(MusicGroupPaymentCalenderCourseSettings::getCourseOriginalPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
-							BigDecimal totalCourseCurrentPrice = musicGroupPaymentCalenderCourseSettings.stream().map(MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
-
-							//课程每分钟原价
-							BigDecimal unitMinuteOriginalPrice = totalCourseOriginalPrice.divide(new BigDecimal(originalCourseTotalMinutes), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
-							//课程每分钟现价
-							BigDecimal unitMinuteCurrentPrice = totalCourseCurrentPrice.divide(new BigDecimal(originalCourseTotalMinutes), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
-
-							if(MusicGroupPaymentCalender.PayUserType.SCHOOL.equals(musicGroupPaymentCalenders.get(0).getPayUserType())){
-								unitMinuteCurrentPrice = new BigDecimal("0");
-							}
-
 							List<CourseScheduleStudentPayment> typeCourseStudentPayments = new ArrayList<>();
 							courseScheduleTypeListEntry.getValue().sort(Comparator.comparing(CourseSchedule::getStartClassTime));
-							BigDecimal typeCourseTotalOriginalPrice = new BigDecimal("0"), typeCourseTotalCurrentPrice = new BigDecimal("0");
 							List<CourseSchedule> scheduleList = courseScheduleTypeListEntry.getValue();
 							for (CourseSchedule courseSchedule : scheduleList) {
 								if(existCourseIds.contains(courseSchedule.getId())){
@@ -483,48 +459,16 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 								}
 								//课程时长
 								int courseDuration = DateUtil.minutesBetween(courseSchedule.getStartClassTime(), courseSchedule.getEndClassTime());
-
-								//课程原价
-								BigDecimal courseOriginalPrice = unitMinuteOriginalPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
-								typeCourseTotalOriginalPrice = typeCourseTotalOriginalPrice.add(courseOriginalPrice);
-
-								//课程现价
-								BigDecimal courseCurrentPrice = unitMinuteCurrentPrice.multiply(new BigDecimal(courseDuration)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_DOWN);
-								typeCourseTotalCurrentPrice = typeCourseTotalCurrentPrice.add(courseCurrentPrice);
-
-								CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
-								cssp.setGroupType(courseSchedule.getGroupType());
-								cssp.setMusicGroupId(courseSchedule.getMusicGroupId());
-								cssp.setCourseScheduleId(courseSchedule.getId());
-								cssp.setClassGroupId(courseSchedule.getClassGroupId());
-								cssp.setBatchNo(batchNo);
+								CourseScheduleStudentPayment cssp = this.init(courseSchedule);
 								cssp.setUserId(studentId);
-								cssp.setOriginalPrice(courseOriginalPrice);
-								cssp.setExpectPrice(courseCurrentPrice);
-								cssp.setActualPrice(BigDecimal.ZERO);
-								cssp.setBeMerged(false);
+								//扣除可排课时长
+								if(this.calcCourseMinutes(musicGroupPaymentStudentCourseDetails,courseDuration,cssp,musicGroupPaymentCalenders)){
+									//课程是否需要标记为云教练赠送
+									operatingCourse.add(courseSchedule.getId());
+								}
 								typeCourseStudentPayments.add(cssp);
 							}
-
-							typeCourseStudentPayments.get(0).setOriginalPrice(typeCourseStudentPayments.get(0).getOriginalPrice().add(totalCourseOriginalPrice.subtract(typeCourseTotalOriginalPrice)));
-							if(MusicGroupPaymentCalender.PayUserType.STUDENT.equals(musicGroupPaymentCalenders.get(0).getPayUserType())) {
-								typeCourseStudentPayments.get(0).setExpectPrice(typeCourseStudentPayments.get(0).getExpectPrice().add(totalCourseCurrentPrice.subtract(typeCourseTotalCurrentPrice)));
-							}
 							courseScheduleStudentPayments.addAll(typeCourseStudentPayments);
-							for (MusicGroupPaymentStudentCourseDetail detail : musicGroupPaymentStudentCourseDetails) {
-								if(typeCourseDuration>detail.getTotalCourseMinutes()){
-									detail.setUsedCourseMinutes(detail.getTotalCourseMinutes());
-									typeCourseDuration = typeCourseDuration-detail.getTotalCourseMinutes();
-								}else{
-									detail.setUsedCourseMinutes(typeCourseDuration);
-									typeCourseDuration = 0;
-								}
-								//如果是免费的云教练课程
-								if(detail.getCloudTeacherPaymentFlag() && !cloudTeacherPaymentFlag){
-									cloudTeacherPaymentFlag = true;
-									calenderId = detail.getMusicGroupPaymentCalenderId();
-								}
-							}
 							musicGroupPaymentStudentCourseDetailDao.batchUpdate(musicGroupPaymentStudentCourseDetails);
 						}
 					}
@@ -532,11 +476,61 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				}
 			}
 		}
-		if(cloudTeacherPaymentFlag){
-			operatingReportCloudService.updateSet(calenderId,courseSchedules.stream().map(e->e.getId()).collect(Collectors.toList()));
+		if(!CollectionUtils.isEmpty(operatingCourse)){
+			operatingReportCloudService.updateSet(calenderId,operatingCourse);
+		}
+	}
+
+	private Boolean calcCourseMinutes(List<MusicGroupPaymentStudentCourseDetail> courseDetails,
+									  Integer courseDuration,
+									  CourseScheduleStudentPayment studentPayment,
+									  List<MusicGroupPaymentCalender> musicGroupPaymentCalenders){
+		Boolean result = true;
+		Integer courseMinutes = courseDuration;
+		Map<Long, List<MusicGroupPaymentCalender>> calenderMap = musicGroupPaymentCalenders.stream().collect(Collectors.groupingBy(MusicGroupPaymentCalender::getId));
+		for (int i = 0; i < courseDetails.size(); i++) {
+			MusicGroupPaymentStudentCourseDetail detail = courseDetails.get(i);
+			if(detail.getSubCourseMinutes() > 0){
+				if(!detail.getCloudTeacherPaymentFlag()){
+					result = false;
+				}
+				if(courseMinutes >= detail.getSubCourseMinutes()){
+					detail.setUsedCourseMinutes(detail.getUsedCourseMinutes() + detail.getSubCourseMinutes());
+					detail.setSubCourseMinutes(0);
+					courseMinutes = courseMinutes - detail.getSubCourseMinutes();
+					studentPayment.setOriginalPrice(detail.getSubCourseOriginalPrice());
+					studentPayment.setExpectPrice(detail.getSubCourseCurrentPrice());
+					detail.setSubCourseCurrentPrice(BigDecimal.ZERO);
+					detail.setSubCourseOriginalPrice(BigDecimal.ZERO);
+				}else{
+					detail.setUsedCourseMinutes(detail.getUsedCourseMinutes() + courseDuration);
+					detail.setSubCourseMinutes(detail.getSubCourseMinutes() - courseDuration);
+					//课程每分钟现价
+					BigDecimal unitMinuteCurrentPrice = detail.getCourseCurrentPrice().divide(new BigDecimal(detail.getTotalCourseMinutes()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
+					BigDecimal unitMinuteOriginalPrice = detail.getCourseOriginalPrice().divide(new BigDecimal(detail.getTotalCourseMinutes()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
+					BigDecimal originalPrice = unitMinuteOriginalPrice.multiply(new BigDecimal(courseMinutes)).setScale(2, BigDecimal.ROUND_DOWN);
+					BigDecimal expectPrice = unitMinuteCurrentPrice.multiply(new BigDecimal(courseMinutes)).setScale(2, BigDecimal.ROUND_DOWN);
+					studentPayment.setOriginalPrice(originalPrice);
+					studentPayment.setExpectPrice(expectPrice);
+					detail.setSubCourseCurrentPrice(detail.getSubCourseOriginalPrice().subtract(originalPrice));
+					detail.setSubCourseOriginalPrice(detail.getSubCourseCurrentPrice().subtract(expectPrice));
+					courseMinutes = 0;
+				}
+				if(MusicGroupPaymentCalender.PayUserType.SCHOOL.equals(calenderMap.get(detail.getMusicGroupPaymentCalenderId()).get(0).getPayUserType())){
+					studentPayment.setExpectPrice(BigDecimal.ZERO);
+				}
+				if(courseMinutes == 0){
+					return result;
+				}
+			}
+			if(i == courseDetails.size() - 1 && courseMinutes > 0){
+				throw new BizException("操作失败:学员可排课时长不足");
+			}
 		}
+		return result;
 	}
 
+
 	@Override
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 	public void createForMemberMusicGroup(String musicGroupId, List<CourseSchedule> courseSchedules, List<Integer> studentIds) {
@@ -762,7 +756,19 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 		courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
     }
 
-    @Override
+	@Override
+	public CourseScheduleStudentPayment init(CourseSchedule courseSchedule) {
+		CourseScheduleStudentPayment cssp = new CourseScheduleStudentPayment();
+		cssp.setGroupType(courseSchedule.getGroupType());
+		cssp.setMusicGroupId(courseSchedule.getMusicGroupId());
+		cssp.setCourseScheduleId(courseSchedule.getId());
+		cssp.setClassGroupId(courseSchedule.getClassGroupId());
+		cssp.setActualPrice(BigDecimal.ZERO);
+		cssp.setBeMerged(false);
+		return cssp;
+	}
+
+	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void updateCourseActualPrice(List<String> groupIds, List<Integer> userIds, GroupType groupType) {
 		studentDao.lockUser(1);

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

@@ -333,13 +333,17 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
                         continue;
                     }
                     musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+                    musicGroupPaymentStudentCourseDetail.setMusicGroupId(musicGroupId);
                     musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
                     musicGroupPaymentStudentCourseDetail.setCreateTime(date);
                     musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalenderId);
                     musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(userMap.get(studentId));
                     musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
+                    musicGroupPaymentStudentCourseDetail.setSubCourseMinutes(courseSettings.getCourseTotalMinuties());
                     musicGroupPaymentStudentCourseDetail.setCourseOriginalPrice(courseSettings.getCourseOriginalPrice());
                     musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(courseSettings.getCourseCurrentPrice());
+                    musicGroupPaymentStudentCourseDetail.setSubCourseOriginalPrice(courseSettings.getCourseOriginalPrice());
+                    musicGroupPaymentStudentCourseDetail.setSubCourseCurrentPrice(courseSettings.getCourseCurrentPrice());
                     musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
                     musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
                     musicGroupPaymentStudentCourseDetail.setUserId(studentId);
@@ -578,13 +582,17 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
                     continue;
                 }
                 MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+                musicGroupPaymentStudentCourseDetail.setMusicGroupId(musicGroupPaymentCalender.getMusicGroupId());
                 musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
                 musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
                 musicGroupPaymentStudentCourseDetail.setUserId(studentPaymentOrder.getUserId());
                 musicGroupPaymentStudentCourseDetail.setCourseType(courseSetting.getCourseType());
                 musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSetting.getCourseTotalMinuties());
+                musicGroupPaymentStudentCourseDetail.setSubCourseMinutes(courseSetting.getCourseTotalMinuties());
                 musicGroupPaymentStudentCourseDetail.setCourseOriginalPrice(courseSetting.getCourseOriginalPrice());
                 musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(courseSetting.getCourseCurrentPrice());
+                musicGroupPaymentStudentCourseDetail.setSubCourseOriginalPrice(courseSetting.getCourseOriginalPrice());
+                musicGroupPaymentStudentCourseDetail.setSubCourseCurrentPrice(courseSetting.getCourseCurrentPrice());
                 musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
                 musicGroupPaymentStudentCourseDetail.setCreateTime(nowDate);
                 musicGroupPaymentStudentCourseDetail.setUpdateTime(nowDate);

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

@@ -26,16 +26,13 @@ import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
-import com.ym.mec.util.date.DateUtil;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.ui.ModelMap;
 
 import java.math.BigDecimal;
@@ -634,8 +631,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         musicGroupPaymentCalender.setBatchNo(batchNo);
         musicGroupPaymentCalenderDto.setBatchNo(batchNo);
         musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
-//        List<MusicGroupPaymentCalenderCourseSettings> currentMusicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalender
-//                .getMusicGroupPaymentCalenderCourseSettingsList();
 
         if (musicGroupPaymentCalender.getStatus() != AUDITING) {
             // 如果是进行中加学生
@@ -708,8 +703,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         if (StringUtils.isNoneBlank(studentIdStr)) {
             //当前乐团是否有预排课计划
             MusicGroupSchoolTermCourseDetail termCourseDetail = musicGroupSchoolTermCourseDetailDao.findByCourseDateAndMusicGroupId(musicGroup.getId(), null, 0);
-//            List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetailList = new ArrayList<MusicGroupPaymentStudentCourseDetail>();
-//            MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = null;
 
             List<MusicGroupPaymentCalenderActivity> calenderActivities = musicGroupPaymentCalenderActivityService.findByCalenderId(musicGroupPaymentCalender.getId());
             Map<Integer, VipGroupActivity> collect = new HashMap<>();
@@ -792,92 +785,10 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
                     //统计变更学员数
                     groupEventSource.musicGroupStudentChangeEvent(musicGroupPaymentCalender.getMusicGroupId(), StudentMusicGroupStatusEnum.NORMAL, new ArrayList<>(Arrays.asList(Integer.parseInt(studentId))));
                 }
-                /*if (musicGroupPaymentCalenderCourseSettingsList != null && musicGroupPaymentCalenderCourseSettingsList.size() > 0) {
-                    // 学生加课程明细
-                    for (MusicGroupPaymentCalenderCourseSettings courseSettings : musicGroupPaymentCalenderCourseSettingsList) {
-                        if (courseSettings.getIsStudentOptional() == true) {
-                            continue;
-                        }
-                        musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
-                        musicGroupPaymentStudentCourseDetail.setCourseType(courseSettings.getCourseType());
-                        musicGroupPaymentStudentCourseDetail.setCreateTime(date);
-                        musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
-                        musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
-                        musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSettings.getCourseTotalMinuties());
-                        musicGroupPaymentStudentCourseDetail.setCourseOriginalPrice(courseSettings.getCourseOriginalPrice());
-                        musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(courseSettings.getCourseCurrentPrice());
-                        musicGroupPaymentStudentCourseDetail.setUpdateTime(date);
-                        musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(courseSettings.getCourseTotalMinuties());
-                        musicGroupPaymentStudentCourseDetail.setUserId(Integer.parseInt(studentId));
-                        musicGroupPaymentStudentCourseDetailList.add(musicGroupPaymentStudentCourseDetail);
-                    }
-                }
-                if (musicGroupPaymentStudentCourseDetailList.size() > 0) {
-                    musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetailList);
-                }*/
             }
         }
     }
 
-    @Override
-    public void autoUpdateMusicGroupStudentFeeStatus() {
-        Date date = new Date();
-        String format = DateUtil.format(date, DateUtil.DEFAULT_PATTERN);
-        // 获取距离缴费开启指定天数后的缴费明细
-        String configValue = sysConfigDao.findConfigValue("push_payment_detail");
-        Map<Long, Long> maps = MapUtil.convertIntegerMap(musicGroupPaymentCalenderDao.queryCalenderByDay(configValue, format));
-        if (maps != null && maps.size() > 0) {
-            Set<Long> calenderId = maps.keySet();
-            List<CalenderPushDto> calenderPushDtos = musicGroupPaymentCalenderDao.getCalenderPushDto(calenderId);
-            Map<Long, List<CalenderPushDto>> collect = calenderPushDtos.stream().collect(Collectors.groupingBy(CalenderPushDto::getCalenderId));
-            calenderId.forEach(e -> {
-                CalenderPushDto calenderPushDto = collect.get(e).get(0);
-                Map<Integer, String> receivers = new HashMap<>(1);
-                receivers.put(calenderPushDto.getTeacherId(), calenderPushDto.getTeacherPhone());
-                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.SYSTEM_SMS_PUSH_PAYMENT_DETAIL, receivers, null, 0,
-                        null, null, calenderPushDto.getMusicGroupName(), calenderPushDto.getPaymentValidStartDate(), calenderPushDto.getPaymentValidEndDate(),
-                        maps.get(e));
-                Map<Integer, String> receivers1 = new HashMap<>(1);
-                receivers1.put(calenderPushDto.getTeacherId(), calenderPushDto.getTeacherId().toString());
-                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.SYSTEM_SMS_PUSH_PAYMENT_DETAIL, receivers1, null, 0,
-                        null, "SYSTEM", calenderPushDto.getMusicGroupName(), calenderPushDto.getPaymentValidStartDate(), calenderPushDto.getPaymentValidEndDate(),
-                        maps.get(e));
-            });
-        }
-        // 获取离截止还有指定时间的缴费项,并发送推送消息给指定老师
-        String configValue1 = sysConfigDao.findConfigValue("push_create_payment_calender");
-        List<Long> calenderIds = musicGroupPaymentCalenderDao.queryEndIds(configValue1, format, null);
-        if (calenderIds != null && calenderIds.size() > 0) {
-            List<CalenderPushDto> calenderPushDtos = musicGroupPaymentCalenderDao.getCalenderPushDto(calenderIds);
-            Map<Long, List<CalenderPushDto>> collect = calenderPushDtos.stream().collect(Collectors.groupingBy(CalenderPushDto::getCalenderId));
-            calenderIds.forEach(e -> {
-                CalenderPushDto calenderPushDto = collect.get(e).get(0);
-                Map<Integer, String> receivers = new HashMap<>(1);
-                receivers.put(calenderPushDto.getTeacherId(), calenderPushDto.getTeacherPhone());
-                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.SYSTEM_SMS_PUSH_PAYMENT_CREATE, receivers, null, 0,
-                        null, null, calenderPushDto.getMusicGroupName(), calenderPushDto.getPaymentValidStartDate(), calenderPushDto.getPaymentValidEndDate());
-                Map<Integer, String> receivers1 = new HashMap<>(1);
-                receivers1.put(calenderPushDto.getTeacherId(), calenderPushDto.getTeacherId().toString());
-                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.SYSTEM_SMS_PUSH_PAYMENT_CREATE, receivers1, null, 0,
-                        null, "SYSTEM", calenderPushDto.getMusicGroupName(), calenderPushDto.getPaymentValidStartDate(), calenderPushDto.getPaymentValidEndDate());
-            });
-        }
-
-        // 乐团报名到期,提醒教务老师创建缴费
-        List<CalenderPushDto> calenderPushDtos = musicGroupPaymentCalenderDao.getMusicCalenderPushDto(configValue1, format);
-        if (calenderPushDtos != null && calenderPushDtos.size() > 0) {
-            calenderPushDtos.forEach(e -> {
-                Map<Integer, String> receivers = new HashMap<>(1);
-                receivers.put(e.getTeacherId(), e.getTeacherPhone());
-                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS, MessageTypeEnum.SYSTEM_SMS_PUSH_PAYMENT_CREATE, receivers, null, 0,
-                        null, null, e.getMusicGroupName(), e.getPaymentValidStartDate(), e.getPaymentValidEndDate());
-                Map<Integer, String> receivers1 = new HashMap<>(1);
-                receivers1.put(e.getTeacherId(), e.getTeacherId().toString());
-                sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.SYSTEM_SMS_PUSH_PAYMENT_CREATE, receivers1, null, 0,
-                        null, "SYSTEM", e.getMusicGroupName(), e.getPaymentValidStartDate(), e.getPaymentValidEndDate());
-            });
-        }
-    }
 
     @Override
     public PageInfo<MusicGroupPaymentCalenderAuditDto> auditList(MusicGroupPaymentCalenderQueryInfo queryInfo) {
@@ -1029,11 +940,6 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
                     classGroupService.addStudentToClassGroupAndCourseArranging(Integer.parseInt(calender.getStudentIds()), classGroupIdStr, batchNo,
                             musicGroupPaymentCalenderCourseSettingsService.queryCalenderCourseSettingsByBatchNo(batchNo), musicGroup);
                 }
-//                MusicGroupStudentClassAdjust musicGroupStudentClassAdjust = musicGroupStudentClassAdjustDao.findByBatchNo(batchNo);
-//                if (musicGroupStudentClassAdjust != null) {
-//                    如果是合班缴费
-//                    autoClassGroupAdjust(musicGroupStudentClassAdjust);
-//                }
             } else if (calender.getPaymentType() == SPAN_GROUP_CLASS_ADJUST) {
                 List<MusicGroupPaymentCalenderStudentDetail> calenderStudentDetails = musicGroupPaymentCalenderStudentDetailDao.findByBatchNo(batchNo);
                 //将学员加入新乐团、扣除原乐团剩余课程余额、补充到现有乐团

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

@@ -584,13 +584,17 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 						continue;
 					}
 					MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
+					musicGroupPaymentStudentCourseDetail.setMusicGroupId(musicGroupPaymentCalender.getMusicGroupId());
 					musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupPaymentCalender.getId());
 					//musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
 					musicGroupPaymentStudentCourseDetail.setUserId(si.getUserId());
 					musicGroupPaymentStudentCourseDetail.setCourseType(courseSetting.getCourseType());
 					musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSetting.getCourseTotalMinuties());
+					musicGroupPaymentStudentCourseDetail.setSubCourseMinutes(courseSetting.getCourseTotalMinuties());
 					musicGroupPaymentStudentCourseDetail.setCourseOriginalPrice(courseSetting.getCourseOriginalPrice());
 					musicGroupPaymentStudentCourseDetail.setCourseCurrentPrice(courseSetting.getCourseCurrentPrice());
+					musicGroupPaymentStudentCourseDetail.setSubCourseOriginalPrice(courseSetting.getCourseOriginalPrice());
+					musicGroupPaymentStudentCourseDetail.setSubCourseCurrentPrice(courseSetting.getCourseCurrentPrice());
 					musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
 					musicGroupPaymentStudentCourseDetail.setCreateTime(nowDate);
 					musicGroupPaymentStudentCourseDetail.setUpdateTime(nowDate);

+ 6 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupOrganizationCourseSettingsMapper.xml

@@ -71,6 +71,12 @@
     </update>
 
     <!-- 分页查询 -->
+    <select id="findAll" resultMap="MusicGroupOrganizationCourseSettings" parameterType="map">
+        SELECT mgocs.* FROM music_group_organization_course_settings mgocs
+        <include refid="queryCondition"/>
+    </select>
+
+    <!-- 分页查询 -->
     <select id="queryPage" resultMap="MusicGroupOrganizationCourseSettings" parameterType="map">
         SELECT mgocs.* FROM music_group_organization_course_settings mgocs
         <include refid="queryCondition"/>

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

@@ -15,6 +15,8 @@
         <result column="course_type_" property="courseType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="course_original_price_" property="courseOriginalPrice"/>
         <result column="course_current_price_" property="courseCurrentPrice"/>
+        <result column="sub_course_original_price_" property="subCourseOriginalPrice"/>
+        <result column="sub_course_current_price_" property="subCourseCurrentPrice"/>
         <result column="total_course_minutes_" property="totalCourseMinutes"/>
         <result column="used_course_minutes_" property="usedCourseMinutes"/>
         <result column="sub_course_minutes_" property="subCourseMinutes"/>
@@ -46,11 +48,11 @@
         INSERT INTO music_group_payment_student_course_detail
         (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_)
+         course_current_price_, sub_course_original_price_,sub_course_current_price_, tenant_id_,cloud_teacher_payment_flag_)
         VALUES (#{musicGroupId}, #{musicGroupPaymentCalenderId}, #{musicGroupPaymentCalenderDetailId}, #{userId},
                 #{courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{totalCourseMinutes},
                 #{usedCourseMinutes},#{subCourseMinutes},
-                NOW(), NOW(), #{courseOriginalPrice}, #{courseCurrentPrice}, #{tenantId},#{cloudTeacherPaymentFlag})
+                NOW(), NOW(), #{courseOriginalPrice}, #{courseCurrentPrice}, #{subCourseOriginalPrice}, #{subCourseCurrentPrice}, #{tenantId},#{cloudTeacherPaymentFlag})
     </insert>
 
     <insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id"
@@ -58,13 +60,13 @@
         INSERT INTO music_group_payment_student_course_detail
         (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_)
+         course_current_price_,sub_course_original_price_,sub_course_current_price_,tenant_id_,cloud_teacher_payment_flag_)
         VALUES
         <foreach collection="list" item="item" separator=",">
             (#{item.musicGroupId},#{item.musicGroupPaymentCalenderId},#{item.musicGroupPaymentCalenderDetailId},
             #{item.userId},#{item.courseType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
             #{item.totalCourseMinutes},#{item.usedCourseMinutes},#{item.subCourseMinutes},NOW(),NOW(),#{item.courseOriginalPrice},
-             #{item.courseCurrentPrice},#{item.tenantId},#{item.cloudTeacherPaymentFlag})
+             #{item.courseCurrentPrice}, #{item.subCourseOriginalPrice}, #{item.subCourseCurrentPrice},#{item.tenantId},#{item.cloudTeacherPaymentFlag})
         </foreach>
     </insert>
 
@@ -79,6 +81,12 @@
             <if test="courseCurrentPrice != null">
                 course_current_price_ = #{courseCurrentPrice},
             </if>
+            <if test="subCourseOriginalPrice != null">
+                sub_course_original_price_ = #{subCourseOriginalPrice},
+            </if>
+            <if test="subCcourseCurrentPrice != null">
+                sub_course_current_price_ = #{subCcourseCurrentPrice},
+            </if>
             <if test="subCourseMinutes != null">
                 used_course_minutes_ = #{subCourseMinutes},
             </if>
@@ -226,7 +234,7 @@
             #{studentId}
         </foreach>
         GROUP BY mgpscd.user_id_,mgpscd.course_type_
-        HAVING mgpscd.sub_course_minutes_ > 0
+        HAVING SUM(mgpscd.sub_course_minutes_) > 0
     </select>
 
     <delete id="deleteByUserIdAndMusicGroupId">

+ 5 - 0
mec-biz/src/main/resources/config/mybatis/OrganizationCourseUnitPriceSettingsMapper.xml

@@ -129,4 +129,9 @@
 			and tenant_id_ = #{tenantId}
 		</if>
 	</select>
+    <select id="queryByMusicGroupId" resultMap="OrganizationCourseUnitPriceSettings">
+		select ocups.* from organization_course_unit_price_settings ocups
+		LEFT JOIN music_group mg ON mg.organ_id_ = ocups.organ_id_ AND mg.charge_type_id_ = ocups.charge_type_id_
+		where mg.id_ = #{musicGroupId}
+	</select>
 </mapper>