Ver Fonte

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

zouxuan há 5 anos atrás
pai
commit
b396cab2cf

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

+ 33 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -430,6 +430,39 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
 
         List<Long> courseIds = classGroupNotStartCourse.stream().map(CourseSchedule::getId).collect(Collectors.toList());
 
+        //4、调整未上课课酬
+        List<ClassGroupTeacherMapper> classGroupTeachers = classGroupTeacherMapperService.getClassGroupTeachers(classGroupId.intValue());
+        if (classGroup.getType().equals(ClassGroupTypeEnum.HIGH_ONLINE) && classGroupNotStartCourse.size() > 0) {
+            Date nowDate = new Date();
+            List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaryList = new ArrayList<>();
+            List<Long> courseScheduleIds = classGroupNotStartCourse.stream().map(CourseSchedule::getId).collect(Collectors.toList());
+            courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(courseScheduleIds);
+            for (CourseSchedule courseSchedule : classGroupNotStartCourse) {
+                for (ClassGroupTeacherMapper classGroupTeacher : classGroupTeachers) {
+                    List<TeacherDefaultMusicGroupSalary> teacherSalaryList = teacherDefaultMusicGroupSalaryService.getTeacherSalaryByUserIdAndType(classGroupTeacher.getUserId(), ClassGroupTypeEnum.HIGH_ONLINE.getCode(), null);
+                    if (teacherSalaryList == null || teacherSalaryList.size() == 0) {
+                        throw new BizException("请设置老师线上网管课课酬");
+                    }
+                    Map<CourseSchedule.CourseScheduleType, TeacherDefaultMusicGroupSalary> collect = teacherSalaryList.stream().collect(Collectors.toMap(TeacherDefaultMusicGroupSalary::getCourseScheduleType, teacherDefaultMusicGroupSalary -> teacherDefaultMusicGroupSalary));
+                    TeacherDefaultMusicGroupSalary teacherDefaultMusicGroupSalary = collect.get(courseSchedule.getType());
+                    BigDecimal salary = JSON.parseObject(teacherDefaultMusicGroupSalary.getSalaryRuleJson()).getBigDecimal(studentIds.size()+"");
+
+                    CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary();
+                    courseScheduleTeacherSalary.setCourseScheduleId(courseSchedule.getId());
+                    courseScheduleTeacherSalary.setGroupType(courseSchedule.getGroupType());
+                    courseScheduleTeacherSalary.setMusicGroupId(courseSchedule.getMusicGroupId());
+                    courseScheduleTeacherSalary.setTeacherRole(classGroupTeacher.getTeacherRole());
+                    courseScheduleTeacherSalary.setUserId(classGroupTeacher.getUserId());
+                    courseScheduleTeacherSalary.setExpectSalary(salary);
+                    courseScheduleTeacherSalary.setClassGroupId(classGroup.getId());
+                    courseScheduleTeacherSalary.setCreateTime(nowDate);
+                    courseScheduleTeacherSalary.setUpdateTime(nowDate);
+                    courseScheduleTeacherSalaryList.add(courseScheduleTeacherSalary);
+                }
+            }
+            courseScheduleTeacherSalaryService.batchInsert(courseScheduleTeacherSalaryList);
+        }
+
         if(!CollectionUtils.isEmpty(removeStudentIds)){
             courseScheduleDao.deleteMusicGroupCourseSchedulesWithStudents(courseIds, new ArrayList<>(removeStudentIds));
             List<ImGroupMember> imGroupMemberList = new ArrayList<>();

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

@@ -46,7 +46,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 	@Autowired
 	private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
 	@Autowired
-	private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
+	private VipGroupDefaultClassesUnitPriceDao vipGroupDefaultClassesUnitPriceDao;
 	@Autowired
 	private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
 	@Autowired
@@ -65,6 +65,11 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 			throw new BizException("未找到相关vip课程");
 		}
 
+		VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice = vipGroupDefaultClassesUnitPriceDao.getByVipGroup(vipGroupId);
+		if(Objects.isNull(vipGroupDefaultClassesUnitPrice)){
+			throw new BizException("课程单价设置错误");
+		}
+
 		//获取活动信息
 		VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroupApplyBaseInfoDto.getVipGroupActivityId().intValue());
 
@@ -121,7 +126,6 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 						default:
 							throw new BizException("活动类型错误!");
 					}
-                    courseScheduleStudentPayment.setOriginalPrice(vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice());
 				}else{
 					//学生线下单节课应缴费计算
 					switch (vipGroupActivity.getType()) {
@@ -147,7 +151,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 							throw new BizException("活动类型错误!");
 					}
 				}
-                courseScheduleStudentPayment.setOriginalPrice(vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice());
+                courseScheduleStudentPayment.setOriginalPrice(TeachModeEnum.ONLINE.equals(teachModeEnum)?vipGroupDefaultClassesUnitPrice.getOnlineClassesUnitPrice():vipGroupDefaultClassesUnitPrice.getOfflineClassesUnitPrice());
 				courseScheduleStudentPayment.setActualPrice(courseScheduleStudentPayment.getExpectPrice());
 				courseScheduleStudentPayments.add(courseScheduleStudentPayment);
 			}

+ 49 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -157,6 +157,10 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
     @Autowired
     private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
+    @Autowired
+    private MusicGroupPaymentStudentCourseDetailDao musicGroupPaymentStudentCourseDetailDao;
+    @Autowired
+    private SubjectChangeDao subjectChangeDao;
 
     private SimpleDateFormat sdf_ymd = new SimpleDateFormat("yyyy-MM-dd");
 
@@ -447,7 +451,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         //乐器及打包辅件
         List<MusicGroupSubjectGoodsGroup> goodsGroups = new ArrayList<>();
         if (studentRegistration.getTemporaryCourseFee() != null) {
-            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.findUserApplyOrder(studentRegistration.getUserId(),studentRegistration.getMusicGroupId(), DealStatusEnum.WAIT_PAY);
+            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.findUserApplyOrder(studentRegistration.getUserId(), studentRegistration.getMusicGroupId(), DealStatusEnum.WAIT_PAY);
             for (StudentPaymentOrderDetail orderDetail : orderDetails) {
                 if (orderDetail == null || orderDetail.getPrice() == null || orderDetail.getGoodsIdList() == null) {
                     continue;
@@ -665,7 +669,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         //乐器及打包辅件
         List<MusicGroupSubjectGoodsGroup> goodsGroups = new ArrayList<>();
         if (studentRegistration.getTemporaryCourseFee() != null) {
-            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.findUserApplyOrder(studentRegistration.getUserId(),studentRegistration.getMusicGroupId(), DealStatusEnum.WAIT_PAY);
+            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.findUserApplyOrder(studentRegistration.getUserId(), studentRegistration.getMusicGroupId(), DealStatusEnum.WAIT_PAY);
             for (StudentPaymentOrderDetail orderDetail : orderDetails) {
                 if (orderDetail == null || orderDetail.getPrice() == null || orderDetail.getGoodsIdList() == null) {
                     continue;
@@ -1501,6 +1505,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
             studentRegistrationDao.update(studentRegistration);
 
+            //删除用户购买的课程记录
+            musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
+
             BigDecimal amount = new BigDecimal(0);
 
             // 判断乐器是否是租赁
@@ -1515,6 +1522,17 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
             List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
 
+            Set<String> courseTypeSet = new HashSet<>();
+            if (isRefundCourseFee) {
+                List<MusicGroupPaymentCalenderCourseSettings> courseSettings = musicGroupPaymentCalenderCourseSettingsDao.getMusicGroupRegCalenderCourseSettings(studentRegistration.getMusicGroupId());
+                courseTypeSet = courseSettings.stream().map(e -> e.getCourseType().getCode()).collect(Collectors.toSet());
+            }
+
+            SubjectChange studentLastChange = null;
+            if (isRefundInstrumentFee || isRefundTeachingAssistantsFee) {
+                studentLastChange = subjectChangeDao.getStudentLastChange(userId, musicGroupId);
+            }
+
             BigDecimal remitFee = studentPaymentOrder.getRemitFee() == null ? BigDecimal.ZERO : studentPaymentOrder.getRemitFee();
             for (StudentPaymentOrderDetail detail : orderDetailList) {
                 if (remitFee.compareTo(detail.getPrice()) >= 0) {
@@ -1527,24 +1545,27 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
                 if (isRefundCourseFee) {
                     // 退课程费用
-                    if (detail.getType() == OrderDetailTypeEnum.COURSE) {
+                    if (courseTypeSet.contains(detail.getType().getCode())) {
                         amount = amount.add(detail.getPrice());
                     }
                 }
-                if (isRefundInstrumentFee) {
+                if (isRefundInstrumentFee && studentLastChange == null) {
                     // 退乐器费用
                     if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
                         amount = amount.add(detail.getPrice());
                     }
 
                 }
-                if (isRefundTeachingAssistantsFee) {
+                if (isRefundTeachingAssistantsFee && studentLastChange == null) {
                     // 退教辅费用
                     if (detail.getType() == OrderDetailTypeEnum.ACCESSORIES || detail.getType() == OrderDetailTypeEnum.TEACHING) {
                         amount = amount.add(detail.getPrice());
                     }
                 }
             }
+            if (studentLastChange != null) {
+                amount = amount.add(studentLastChange.getChangeMusicalPrice()).add(studentLastChange.getChangeAccessoriesPrice());
+            }
             if (amount.doubleValue() > 0) {
                 // 增加交易流水
                 sysUserCashAccountDetailService.addCashAccountDetail(userId, amount, SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "",
@@ -1604,6 +1625,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         studentRegistrationDao.update(studentRegistration);
 
+        //删除用户购买的课程记录
+        musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
+
         BigDecimal amount = new BigDecimal(0);
 
         // 判断乐器是否是租赁
@@ -1616,6 +1640,18 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
 
         List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
+
+        Set<String> courseTypeSet = new HashSet<>();
+        if (isRefundCourseFee) {
+            List<MusicGroupPaymentCalenderCourseSettings> courseSettings = musicGroupPaymentCalenderCourseSettingsDao.getMusicGroupRegCalenderCourseSettings(studentRegistration.getMusicGroupId());
+            courseTypeSet = courseSettings.stream().map(e -> e.getCourseType().getCode()).collect(Collectors.toSet());
+        }
+
+        SubjectChange studentLastChange = null;
+        if (isRefundInstrumentFee || isRefundTeachingAssistantsFee) {
+            studentLastChange = subjectChangeDao.getStudentLastChange(userId, musicGroupId);
+        }
+
         BigDecimal remitFee = studentPaymentOrder.getRemitFee() == null ? BigDecimal.ZERO : studentPaymentOrder.getRemitFee();
 
         for (StudentPaymentOrderDetail detail : orderDetailList) {
@@ -1628,24 +1664,27 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             }
             if (isRefundCourseFee) {
                 // 退课程费用
-                if (detail.getType() == OrderDetailTypeEnum.COURSE) {
+                if (courseTypeSet.contains(detail.getType().getCode())) {
                     amount = amount.add(detail.getPrice());
                 }
             }
-            if (isRefundInstrumentFee) {
+            if (isRefundInstrumentFee && studentLastChange == null) {
                 // 退乐器费用
                 if (detail.getType() == OrderDetailTypeEnum.MUSICAL) {
                     amount = amount.add(detail.getPrice());
                 }
 
             }
-            if (isRefundTeachingAssistantsFee) {
+            if (isRefundTeachingAssistantsFee && studentLastChange == null) {
                 // 退教辅费用
                 if (detail.getType() == OrderDetailTypeEnum.ACCESSORIES || detail.getType() == OrderDetailTypeEnum.TEACHING) {
                     amount = amount.add(detail.getPrice());
                 }
             }
         }
+        if (studentLastChange != null) {
+            amount = amount.add(studentLastChange.getChangeMusicalPrice()).add(studentLastChange.getChangeAccessoriesPrice());
+        }
         if (amount.doubleValue() > 0) {
             // 增加交易流水
             sysUserCashAccountDetailService.addCashAccountDetail(userId, amount, SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "",
@@ -1830,7 +1869,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
             List<MusicGroupPaymentCalenderCourseSettings> courseSettings = musicGroupPaymentCalenderCourseSettingsDao.queryCalenderCourseSettings(calenderDetail.getMusicGroupPaymentCalenderId());
             List<StudentPaymentOrderDetail> paymentOrderDetails = new ArrayList<>();
-            courseSettings.forEach(e->{
+            courseSettings.forEach(e -> {
                 StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
                 studentPaymentOrderDetail.setType(OrderDetailTypeEnum.valueOf(e.getCourseType().getCode()));
                 studentPaymentOrderDetail.setPrice(e.getCourseCurrentPrice());
@@ -2207,6 +2246,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         MusicGroupPaymentCalender regCalender = musicGroupPaymentCalenderDao.findByMusicGroupRegCalender(musicGroupId);
         if (regCalender != null && regCalender.getPayUserType().equals(MusicGroupPaymentCalender.PayUserType.STUDENT)) {
             regCalender.setStatus(MusicGroupPaymentCalender.PaymentCalenderStatusEnum.OPEN);
+            regCalender.setDeadlinePaymentDate(DateUtil.toDate(expireDate));
             regCalender.setUpdateTime(new Date());
             musicGroupPaymentCalenderDao.update(regCalender);
         }

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

@@ -225,7 +225,7 @@ public class SysUserCashAccountServiceImpl extends BaseServiceImpl<Integer, SysU
 
         BigDecimal balance = cashAccount.getCourseBalance().add(decimal);
         if (balance.doubleValue() < 0) {
-            throw new BizException("现金账户[{}]课程余额不足,可用余额剩{}元", userId, cashAccount.getBalance().doubleValue());
+            throw new BizException("现金账户[{}]课程余额不足,可用余额剩{}元", userId, cashAccount.getCourseBalance().doubleValue());
         }
 
         Date date = new Date();

+ 20 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -1845,6 +1845,10 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		if(!CollectionUtils.isEmpty(studentApplyRefunds)){
 			throw new BizException("此学生存在退课申请,请到系统日志中查看");
 		}
+		VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice = vipGroupDefaultClassesUnitPriceDao.getByVipGroup(vipGroup.getId());
+		if(Objects.isNull(vipGroupDefaultClassesUnitPrice)){
+			throw new BizException("课程单价设置错误");
+		}
 
 		ClassGroup classGroup = classGroupDao.findByVipGroup(studentRecoverInfo.getVipGroupId().longValue(), null);
 
@@ -1956,7 +1960,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			courseScheduleStudentPayment.setUserId(studentRecoverInfo.getUserId());
 			courseScheduleStudentPayment.setExpectPrice(coursePrices.get(i));
 			courseScheduleStudentPayment.setActualPrice(coursePrices.get(i));
-			courseScheduleStudentPayment.setOriginalPrice(TeachModeEnum.ONLINE.equals(surplusCourseWithGroup.get(i))?vipGroup.getOnlineClassesUnitPrice():vipGroup.getOfflineClassesUnitPrice());
+			courseScheduleStudentPayment.setOriginalPrice(TeachModeEnum.ONLINE.equals(surplusCourseWithGroup.get(i))?vipGroupDefaultClassesUnitPrice.getOnlineClassesUnitPrice():vipGroupDefaultClassesUnitPrice.getOfflineClassesUnitPrice());
 			courseScheduleStudentPayment.setCreateTime(now);
 			courseScheduleStudentPayment.setUpdateTime(now);
 			courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
@@ -2525,6 +2529,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			throw new BizException("此状态的vip课程不支持加课");
 		}
 
+		VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice = vipGroupDefaultClassesUnitPriceDao.getByVipGroup(vipGroup.getId());
+		if(Objects.isNull(vipGroupDefaultClassesUnitPrice)){
+			throw new BizException("课程单价设置错误");
+		}
+
 		Date now=new Date();
 
 //		BigDecimal onlineCoursePrice = courseScheduleStudentPaymentDao.findVipGroupCoursePrice(vipGroup.getId().intValue(),TeachModeEnum.ONLINE.getCode());
@@ -2539,6 +2548,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		BigDecimal surplusCourseTotalPrice = new BigDecimal(0);
 		BigDecimal singleClassPrice=vipGroupApplyDto.getSingleClassPrice();
 
+
 		//课程信息调整
 		for (CourseSchedule courseSchedule : vipGroupApplyDto.getCourseSchedules()) {
 			if(courseSchedule.getTeachMode().equals(TeachModeEnum.OFFLINE)){
@@ -2611,7 +2621,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 //				}else if(vipGroupCourseSchedule.getTeachMode().equals(TeachModeEnum.OFFLINE)){
 //					courseScheduleStudentPayment.setExpectPrice(offlineCoursePrice);
 //				}
+				courseScheduleStudentPayment.setOriginalPrice(TeachModeEnum.ONLINE.equals(vipGroupCourseSchedule.getTeachMode())?vipGroupDefaultClassesUnitPrice.getOnlineClassesUnitPrice():vipGroupDefaultClassesUnitPrice.getOfflineClassesUnitPrice());
 				courseScheduleStudentPayment.setExpectPrice(singleClassPrice);
+				courseScheduleStudentPayment.setActualPrice(singleClassPrice);
 				courseScheduleStudentPayment.setCreateTime(now);
 				courseScheduleStudentPayment.setUpdateTime(now);
 				courseScheduleStudentPayments.add(courseScheduleStudentPayment);
@@ -2654,6 +2666,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			}
 		}
 
+		VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice = vipGroupDefaultClassesUnitPriceDao.getByVipGroup(vipGroup.getId());
+		if(Objects.isNull(vipGroupDefaultClassesUnitPrice)){
+			throw new BizException("课程单价设置错误");
+		}
+
 		if(VipGroupStatusEnum.PAUSE.equals(vipGroup.getStatus())
 				||VipGroupStatusEnum.FINISHED.equals(vipGroup.getStatus())
 				||VipGroupStatusEnum.CANCEL.equals(vipGroup.getStatus())){
@@ -2838,10 +2855,10 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 				courseScheduleStudentPayment.setUserId(studentId);
                 if(vipGroupCourseSchedule.getTeachMode().equals(TeachModeEnum.OFFLINE)){
 					courseScheduleStudentPayment.setExpectPrice(vipGroup.getOfflineClassesUnitPrice());
-					courseScheduleStudentPayment.setOriginalPrice(vipGroup.getOfflineClassesUnitPrice());
+					courseScheduleStudentPayment.setOriginalPrice(vipGroupDefaultClassesUnitPrice.getOfflineClassesUnitPrice());
                 }else if(vipGroupCourseSchedule.getTeachMode().equals(TeachModeEnum.ONLINE)){
 					courseScheduleStudentPayment.setExpectPrice(vipGroup.getOnlineClassesUnitPrice());
-					courseScheduleStudentPayment.setOriginalPrice(vipGroup.getOnlineClassesUnitPrice());
+					courseScheduleStudentPayment.setOriginalPrice(vipGroupDefaultClassesUnitPrice.getOnlineClassesUnitPrice());
                 }
 				if(hasGiveClass
 						&&vipGroup.getGiveTeachMode() == vipGroupCourseSchedule.getTeachMode()){

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

@@ -125,7 +125,6 @@
 		WHERE mgpc.music_group_id_ = #{musicGroupId}
 		AND mgpc.payment_type_ = 'MUSIC_APPLY'
 		AND mgpc.pay_user_type_='STUDENT'
-		AND mgpc.status_='OPEN'
 	</select>
 
     <select id="getCalenderCourseSettings" resultMap="MusicGroupPaymentCalenderCourseSettings">

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

@@ -3,124 +3,141 @@
 <!-- 这个文件是自动生成的。 不要修改此文件。所有改动将在下次重新自动生成时丢失。 -->
 <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">
-		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 * 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 * 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>