|
@@ -2564,6 +2564,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
ClassGroup classGroup = classGroupDao.findByMusicGroupAndType(vipGroupBuyParams.getVipGroupId().toString(),ClassGroupTypeEnum.VIP.getCode());
|
|
|
|
|
|
classGroup = classGroupDao.lockClassGroup(classGroup.getId());
|
|
|
+ VipGroup vipGroup = vipGroupDao.get(vipGroupBuyParams.getVipGroupId());
|
|
|
+ int courseNum = courseScheduleDao.countVipGroupCourses(vipGroup.getId().intValue(),"VIP");
|
|
|
+ if(vipGroup.getStatus() != VipGroupStatusEnum.APPLYING || classGroup.getDelFlag() != 1 || courseNum > 0){
|
|
|
+ throw new BizException("当前VIP课已无法通过购买加入,请联系教务老师");
|
|
|
+ }
|
|
|
|
|
|
if(Objects.isNull(classGroup)){
|
|
|
throw new BizException("班级信息错误");
|
|
@@ -2594,8 +2599,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
|
- VipGroup vipGroup = vipGroupDao.get(vipGroupBuyParams.getVipGroupId());
|
|
|
-
|
|
|
if(classGroup.getStudentNum() >= classGroup.getExpectStudentNum()){
|
|
|
throw new BizException("该VIP课人数已满,请联系教务老师!");
|
|
|
}
|
|
@@ -2765,59 +2768,99 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
if(classGroup.getStudentNum().equals(classGroup.getExpectStudentNum())){
|
|
|
vipGroup.setStatus(VipGroupStatusEnum.PROGRESS);
|
|
|
classGroup.setDelFlag(0);
|
|
|
+ VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice = vipGroupDefaultClassesUnitPriceDao.getByVipGroupCategory(vipGroup.getVipGroupCategoryId(), vipGroup.getOrganId());
|
|
|
+
|
|
|
//生成课表
|
|
|
List<CourseSchedule> courseSchedules = JSON.parseArray(vipGroup.getCourseSchedulesJson(),CourseSchedule.class);
|
|
|
classGroup.setTotalClassTimes(courseSchedules.size());
|
|
|
- courseScheduleService.checkNewCourseSchedules(courseSchedules, false,false);
|
|
|
- courseScheduleService.batchAddCourseSchedule(courseSchedules);
|
|
|
+ int courseNum = courseScheduleDao.countVipGroupCourses(vipGroup.getId().intValue(),"VIP");
|
|
|
+
|
|
|
+ if(courseNum == 0){
|
|
|
+ courseScheduleService.checkNewCourseSchedules(courseSchedules, false,false);
|
|
|
+ courseScheduleService.batchAddCourseSchedule(courseSchedules);
|
|
|
+
|
|
|
+ //考勤信息
|
|
|
+ List<TeacherAttendance> teacherAttendances = new ArrayList<>();
|
|
|
+ //创建课酬信息
|
|
|
+ List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaries = new ArrayList<>();
|
|
|
+ ClassGroupTeacherSalary classGroupTeacherSalary = classGroupTeacherSalaryDao.findByVipGoupAndTeacher(vipGroup.getId().intValue(), vipGroup.getUserId());
|
|
|
+ for (CourseSchedule courseSchedule : courseSchedules) {
|
|
|
+ //创建教师课程薪水记录
|
|
|
+ CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary();
|
|
|
+ courseScheduleTeacherSalary.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ courseScheduleTeacherSalary.setGroupType(courseSchedule.getGroupType());
|
|
|
+ courseScheduleTeacherSalary.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
|
+ courseScheduleTeacherSalary.setTeacherRole(TeachTypeEnum.BISHOP);
|
|
|
+ courseScheduleTeacherSalary.setUserId(courseSchedule.getActualTeacherId().intValue());
|
|
|
+ courseScheduleTeacherSalary.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
+ courseScheduleTeacherSalary.setExpectSalary(classGroupTeacherSalary.getSalary());
|
|
|
+ courseScheduleTeacherSalary.setActualSalary(null);
|
|
|
+ courseScheduleTeacherSalaries.add(courseScheduleTeacherSalary);
|
|
|
+
|
|
|
+ TeacherAttendance teacherAttendance = new TeacherAttendance();
|
|
|
+ teacherAttendance.setGroupType(courseSchedule.getGroupType());
|
|
|
+ teacherAttendance.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
+ teacherAttendance.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
|
+ teacherAttendance.setTeacherId(courseSchedule.getActualTeacherId());
|
|
|
+ teacherAttendance.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ teacherAttendances.add(teacherAttendance);
|
|
|
+ }
|
|
|
+ courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaries);
|
|
|
+ teacherAttendanceDao.batchInsert(teacherAttendances);
|
|
|
|
|
|
- //考勤信息
|
|
|
- List<TeacherAttendance> teacherAttendances = new ArrayList<>();
|
|
|
- //创建课酬信息
|
|
|
- List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaries = new ArrayList<>();
|
|
|
- ClassGroupTeacherSalary classGroupTeacherSalary = classGroupTeacherSalaryDao.findByVipGoupAndTeacher(vipGroup.getId().intValue(), vipGroup.getUserId());
|
|
|
- for (CourseSchedule courseSchedule : courseSchedules) {
|
|
|
- //创建教师课程薪水记录
|
|
|
- CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary();
|
|
|
- courseScheduleTeacherSalary.setCourseScheduleId(courseSchedule.getId());
|
|
|
- courseScheduleTeacherSalary.setGroupType(courseSchedule.getGroupType());
|
|
|
- courseScheduleTeacherSalary.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
|
- courseScheduleTeacherSalary.setTeacherRole(TeachTypeEnum.BISHOP);
|
|
|
- courseScheduleTeacherSalary.setUserId(courseSchedule.getActualTeacherId().intValue());
|
|
|
- courseScheduleTeacherSalary.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
- courseScheduleTeacherSalary.setExpectSalary(classGroupTeacherSalary.getSalary());
|
|
|
- courseScheduleTeacherSalary.setActualSalary(null);
|
|
|
- courseScheduleTeacherSalaries.add(courseScheduleTeacherSalary);
|
|
|
-
|
|
|
- TeacherAttendance teacherAttendance = new TeacherAttendance();
|
|
|
- teacherAttendance.setGroupType(courseSchedule.getGroupType());
|
|
|
- teacherAttendance.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
- teacherAttendance.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
|
- teacherAttendance.setTeacherId(courseSchedule.getActualTeacherId());
|
|
|
- teacherAttendance.setCourseScheduleId(courseSchedule.getId());
|
|
|
- teacherAttendances.add(teacherAttendance);
|
|
|
- }
|
|
|
- //群聊数据
|
|
|
- Map<Integer,String> userRoleMap = new HashMap<Integer, String>(5);
|
|
|
- if(Objects.nonNull(vipGroup.getEducationalTeacherId())){
|
|
|
- userRoleMap.put(vipGroup.getEducationalTeacherId(),"乐团主管");
|
|
|
- }
|
|
|
- userRoleMap.put(vipGroup.getUserId(),"指导老师");
|
|
|
- //生成课程学员关联
|
|
|
- List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
|
|
|
- List<ClassGroupStudentMapper> classGroupStudents = classGroupStudentMapperDao.findByClassGroup(classGroup.getId());
|
|
|
- VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice = vipGroupDefaultClassesUnitPriceDao.getByVipGroupCategory(vipGroup.getVipGroupCategoryId(), vipGroup.getOrganId());
|
|
|
- List<Integer> studentIdList = classGroupStudents.stream().map(e -> e.getUserId()).collect(Collectors.toList());
|
|
|
- for (ClassGroupStudentMapper classGroupStudent : classGroupStudents) {
|
|
|
- StudentPaymentOrder successOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroup.getId(), classGroupStudent.getUserId(), "SUCCESS");
|
|
|
+ //群聊数据
|
|
|
+ Map<Integer,String> userRoleMap = new HashMap<Integer, String>(5);
|
|
|
+ if(Objects.nonNull(vipGroup.getEducationalTeacherId())){
|
|
|
+ userRoleMap.put(vipGroup.getEducationalTeacherId(),"乐团主管");
|
|
|
+ }
|
|
|
+ userRoleMap.put(vipGroup.getUserId(),"指导老师");
|
|
|
+ //生成课程学员关联
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
|
|
|
+ List<ClassGroupStudentMapper> classGroupStudents = classGroupStudentMapperDao.findByClassGroup(classGroup.getId());
|
|
|
+
|
|
|
+ List<Integer> studentIdList = classGroupStudents.stream().map(e -> e.getUserId()).collect(Collectors.toList());
|
|
|
+ for (ClassGroupStudentMapper classGroupStudent : classGroupStudents) {
|
|
|
+ StudentPaymentOrder successOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroup.getId(), classGroupStudent.getUserId(), "SUCCESS");
|
|
|
+ //实际支付金额,去除优惠券
|
|
|
+ BigDecimal actualPrice = successOrder.getExpectAmount();
|
|
|
+ BigDecimal divide = actualPrice.divide(new BigDecimal(courseSchedules.size()), ROUND_DOWN);
|
|
|
+ BigDecimal firstAmount = actualPrice.subtract(divide.multiply(new BigDecimal(courseSchedules.size()))).add(divide);
|
|
|
+ for (int i = 0; i < courseSchedules.size(); i++) {
|
|
|
+ CourseSchedule courseSchedule = courseSchedules.get(i);
|
|
|
+ CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
+ courseScheduleStudentPayment.setUserId(classGroupStudent.getUserId());
|
|
|
+ courseScheduleStudentPayment.setGroupType(courseSchedule.getGroupType());
|
|
|
+ courseScheduleStudentPayment.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
|
+ courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ courseScheduleStudentPayment.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
+ if (i == 0) {
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(firstAmount);
|
|
|
+ }else{
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(divide);
|
|
|
+ }
|
|
|
+ courseScheduleStudentPayment.setOriginalPrice(TeachModeEnum.ONLINE.equals(courseSchedule.getTeachMode())?vipGroupDefaultClassesUnitPrice.getOnlineClassesUnitPrice():vipGroupDefaultClassesUnitPrice.getOfflineClassesUnitPrice());
|
|
|
+ courseScheduleStudentPayment.setActualPrice(courseScheduleStudentPayment.getExpectPrice());
|
|
|
+ courseScheduleStudentPayments.add(courseScheduleStudentPayment);
|
|
|
+ }
|
|
|
+ userRoleMap.put(classGroupStudent.getUserId(),null);
|
|
|
+ }
|
|
|
+ studentDao.updateStudentServiceTag(null, studentIdList, YesOrNoEnum.YES.getCode());
|
|
|
+
|
|
|
+ courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
|
|
|
+
|
|
|
+ imGroupService.create(classGroup.getId().longValue(), null, classGroup.getName(), classGroup.getName(), vipGroup.getName(), null, null, GroupType.VIP.getCode());
|
|
|
+ imGroupMemberService.join(classGroup.getId().longValue(), userRoleMap);
|
|
|
+ imUserFriendService.refreshGroupImUserFriend(classGroup.getMusicGroupId(),classGroup.getGroupType());
|
|
|
+ }else {
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
|
|
|
//实际支付金额,去除优惠券
|
|
|
- BigDecimal actualPrice = successOrder.getExpectAmount();
|
|
|
+ BigDecimal actualPrice = order.getExpectAmount();
|
|
|
BigDecimal divide = actualPrice.divide(new BigDecimal(courseSchedules.size()), ROUND_DOWN);
|
|
|
BigDecimal firstAmount = actualPrice.subtract(divide.multiply(new BigDecimal(courseSchedules.size()))).add(divide);
|
|
|
for (int i = 0; i < courseSchedules.size(); i++) {
|
|
|
CourseSchedule courseSchedule = courseSchedules.get(i);
|
|
|
CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
- courseScheduleStudentPayment.setUserId(classGroupStudent.getUserId());
|
|
|
+ courseScheduleStudentPayment.setUserId(order.getUserId());
|
|
|
courseScheduleStudentPayment.setGroupType(courseSchedule.getGroupType());
|
|
|
courseScheduleStudentPayment.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
|
courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
@@ -2831,17 +2874,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
courseScheduleStudentPayment.setActualPrice(courseScheduleStudentPayment.getExpectPrice());
|
|
|
courseScheduleStudentPayments.add(courseScheduleStudentPayment);
|
|
|
}
|
|
|
- userRoleMap.put(classGroupStudent.getUserId(),null);
|
|
|
+ courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
|
|
|
}
|
|
|
- studentDao.updateStudentServiceTag(null, studentIdList, YesOrNoEnum.YES.getCode());
|
|
|
-
|
|
|
- courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
|
|
|
- courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaries);
|
|
|
- teacherAttendanceDao.batchInsert(teacherAttendances);
|
|
|
-
|
|
|
- imGroupService.create(classGroup.getId().longValue(), null, classGroup.getName(), classGroup.getName(), vipGroup.getName(), null, null, GroupType.VIP.getCode());
|
|
|
- imGroupMemberService.join(classGroup.getId().longValue(), userRoleMap);
|
|
|
- imUserFriendService.refreshGroupImUserFriend(classGroup.getMusicGroupId(),classGroup.getGroupType());
|
|
|
}
|
|
|
SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(userId);
|
|
|
//插入缴费明细
|
|
@@ -4011,16 +4045,16 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
if(Objects.isNull(vipGroupId)){
|
|
|
throw new BizException("请指定vip课程");
|
|
|
}
|
|
|
- VipGroup vipGroup=vipGroupDao.get(vipGroupId);
|
|
|
+ VipGroup vipGroup = vipGroupDao.get(vipGroupId);
|
|
|
if(Objects.isNull(vipGroup)){
|
|
|
throw new BizException("未找到指定的vip课程");
|
|
|
}
|
|
|
|
|
|
ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null);
|
|
|
|
|
|
- if(classGroup.getStudentNum()>0&&(VipGroupStatusEnum.APPLYING.equals(vipGroup.getStatus()))){
|
|
|
+ if(classGroup.getStudentNum() > 0 && (VipGroupStatusEnum.APPLYING.equals(vipGroup.getStatus()))){
|
|
|
int i = studentPaymentOrderDao.countGroupOrderWithoutFailed(vipGroupId.toString(), GroupType.VIP);
|
|
|
- if(i>0){
|
|
|
+ if(i > 0){
|
|
|
throw new BizException("已有学员购买了该课程组,无法添加,请走学员购买流程!");
|
|
|
}
|
|
|
}
|
|
@@ -4037,12 +4071,12 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
|
|
|
Integer exitStudentNum = classGroupStudentMapperDao.countClassGroupExitStudentNum(classGroup.getId(), studentIds);
|
|
|
- if(exitStudentNum>0){
|
|
|
+ if(exitStudentNum > 0){
|
|
|
throw new BizException("选择的学生中存在此课程中已存在的学生");
|
|
|
}
|
|
|
|
|
|
Integer studentNum = classGroupStudentMapperDao.countClassGroupStudentNum(classGroup.getId());
|
|
|
- if(studentNum.compareTo(classGroup.getExpectStudentNum())>=0){
|
|
|
+ if(studentNum.compareTo(classGroup.getExpectStudentNum()) >= 0){
|
|
|
throw new BizException("该班级人数已达上限");
|
|
|
}
|
|
|
|
|
@@ -4135,9 +4169,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
|
|
|
Integer currentStudentNum = classGroupStudentMapperDao.countClassGroupStudentNum(classGroup.getId());
|
|
|
- if((!vipGroup.getStatus().equals(VipGroupStatusEnum.FINISHED)
|
|
|
- ||!vipGroup.getStatus().equals(VipGroupStatusEnum.CANCEL))
|
|
|
- &¤tStudentNum.compareTo(classGroup.getExpectStudentNum())>=0){
|
|
|
+ if((!vipGroup.getStatus().equals(VipGroupStatusEnum.FINISHED) || !vipGroup.getStatus().equals(VipGroupStatusEnum.CANCEL))
|
|
|
+ && currentStudentNum.compareTo(classGroup.getExpectStudentNum()) >= 0){
|
|
|
vipGroup.setStatus(VipGroupStatusEnum.PROGRESS);
|
|
|
vipGroupDao.update(vipGroup);
|
|
|
}
|