|
@@ -2245,19 +2245,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
if (exist) {
|
|
|
throw new BizException("您已加入此课程");
|
|
|
}
|
|
|
-//
|
|
|
-// if(classGroup.getStudentNum()>0 && (VipGroupStatusEnum.APPLYING.equals(practiceGroup.getGroupStatus()))){
|
|
|
-// int i = studentPaymentOrderDao.countGroupOrderWithoutFailed(vipGroupId.toString(), GroupType.PRACTICE);
|
|
|
-// if(i<=0){
|
|
|
-// throw new BizException("该课程已经无法通过购买加入,请联系教务老师!");
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
List<CourseSchedule> courseSchedules = JSON.parseArray(practiceGroup.getCourseScheduleJson(), CourseSchedule.class);
|
|
|
courseScheduleService.checkNewCourseSchedules(courseSchedules, false, false);
|
|
|
} else {
|
|
|
VipGroup vipGroup = get(vipGroupId.longValue());
|
|
|
- if (Objects.nonNull(vipGroup.getStudentIdList())) {
|
|
|
+ if (StringUtils.isNotEmpty(vipGroup.getStudentIdList())) {
|
|
|
Set<Integer> userIds = Arrays.asList(vipGroup.getStudentIdList().split(",")).stream().mapToInt(Integer::parseInt).boxed().collect(Collectors.toSet());
|
|
|
if (!userIds.contains(userId)) {
|
|
|
throw new BizException("您无法购买此课程");
|
|
@@ -4228,28 +4220,12 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void stopVipGroupWithNoCreate(Integer tenantId) {
|
|
|
- List<VipGroup> noCreateSuccessVipGroups = vipGroupDao.findNoCreateSuccessVipGroup(tenantId,null);
|
|
|
+ List<VipGroup> noCreateSuccessVipGroups = vipGroupDao.findNoCreateSuccessVipGroup(tenantId,"VIP");
|
|
|
if (CollectionUtils.isEmpty(noCreateSuccessVipGroups)) {
|
|
|
return;
|
|
|
}
|
|
|
-// List<VipGroup> vipGroup = noCreateSuccessVipGroups.stream().filter(e -> StringUtils.equals("VIP",e.getGroupType())).collect(Collectors.toList());
|
|
|
-// List<VipGroup> liveGroup = noCreateSuccessVipGroups.stream().filter(e -> StringUtils.equals("LIVE",e.getGroupType())).collect(Collectors.toList());
|
|
|
-// List<VipGroup> noStudentGroup = vipGroups.stream().filter(e -> StringUtils.isEmpty(e.getStudentIdList())).collect(Collectors.toList());
|
|
|
-// List<VipGroup> hasStudentGroup = vipGroups.stream().filter(e -> StringUtils.isNotEmpty(e.getStudentIdList())).collect(Collectors.toList());
|
|
|
-// if(!CollectionUtils.isEmpty(noStudentGroup)){
|
|
|
-// 关闭课程组
|
|
|
-// }
|
|
|
-// if(!CollectionUtils.isEmpty(hasStudentGroup)){
|
|
|
-// 排课
|
|
|
-// }
|
|
|
//用户账户资金变动信息列表
|
|
|
List<SysUserCashAccountDetail> userCashAccountDetails = new ArrayList<>();
|
|
|
- List<Long> groupIds = noCreateSuccessVipGroups.stream().map(e -> e.getId()).collect(Collectors.toList());
|
|
|
- List<ClassGroupStudentMapper> classGroupStudentMappers = classGroupStudentMapperDao.findByVipGroups(groupIds);
|
|
|
- Map<Long, Integer> quitUserMap = new HashMap<>();
|
|
|
- if(!CollectionUtils.isEmpty(classGroupStudentMappers)){
|
|
|
- quitUserMap = classGroupStudentMappers.stream().collect(Collectors.groupingBy(e -> Long.parseLong(e.getMusicGroupId()), Collectors.collectingAndThen(Collectors.toList(), v -> v.get(0).getUserId())));
|
|
|
- }
|
|
|
for (VipGroup noCreateSuccessVipGroup : noCreateSuccessVipGroups) {
|
|
|
GroupType groupType = GroupType.VIP;
|
|
|
OrderTypeEnum orderTypeEnum = OrderTypeEnum.SMALL_CLASS_TO_BUY;
|
|
@@ -4262,13 +4238,10 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
continue;
|
|
|
}
|
|
|
noCreateSuccessVipGroup.setStatus(VipGroupStatusEnum.CANCEL);
|
|
|
- List<StudentPaymentOrder> studentPaymentOrders = studentPaymentOrderDao.queryByDealStatus(noCreateSuccessVipGroup.getId().toString(),
|
|
|
+ List<StudentPaymentOrder> studentPaymentOrders = studentPaymentOrderDao.queryVipQuitOrder(noCreateSuccessVipGroup.getId(),
|
|
|
orderTypeEnum, DealStatusEnum.SUCCESS);
|
|
|
|
|
|
for (StudentPaymentOrder studentPaymentOrder : studentPaymentOrders) {
|
|
|
- if(studentPaymentOrder.getUserId().equals(quitUserMap.get(noCreateSuccessVipGroup.getId()))){
|
|
|
-
|
|
|
- }
|
|
|
//生成账户资金明细
|
|
|
if (studentPaymentOrder.getExpectAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
if(Objects.equals("关闭订单,实际支付成功,退到用户余额",studentPaymentOrder.getMemo())){
|
|
@@ -4307,6 +4280,138 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void createLiveCourse() {
|
|
|
+ List<VipGroup> vipGroups = vipGroupDao.findNoCreateSuccessVipGroup(null,"LIVE");
|
|
|
+ if(!CollectionUtils.isEmpty(vipGroups)){
|
|
|
+ List<VipGroup> noStudentGroup = vipGroups.stream().filter(e -> StringUtils.isEmpty(e.getStudentIdList())).collect(Collectors.toList());
|
|
|
+ List<VipGroup> hasStudentGroup = vipGroups.stream().filter(e -> StringUtils.isNotEmpty(e.getStudentIdList())).collect(Collectors.toList());
|
|
|
+ if(!CollectionUtils.isEmpty(noStudentGroup)){
|
|
|
+ noStudentGroup.forEach(e->e.setStatus(VipGroupStatusEnum.CANCEL));
|
|
|
+ //关闭课程组
|
|
|
+ vipGroupDao.batchUpdate(noStudentGroup);
|
|
|
+ }
|
|
|
+ Date now = new Date();
|
|
|
+ if(!CollectionUtils.isEmpty(hasStudentGroup)){
|
|
|
+ //排课
|
|
|
+ for (VipGroup vipGroup : hasStudentGroup) {
|
|
|
+ ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroup.getId(),vipGroup.getGroupType());
|
|
|
+ vipGroup.setStatus(VipGroupStatusEnum.PROGRESS);
|
|
|
+ Integer tenantId = vipGroup.getTenantId();
|
|
|
+ for (String s : vipGroup.getStudentIdList().split(",")) {
|
|
|
+ Integer userId = Integer.parseInt(s);
|
|
|
+ //生成班级学员关联
|
|
|
+ ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
|
+ classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
|
|
|
+ classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
|
+ classGroupStudentMapper.setUserId(userId);
|
|
|
+ classGroupStudentMapper.setCreateTime(now);
|
|
|
+ classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
+ classGroupStudentMapper.setGroupType(GroupType.LIVE);
|
|
|
+ classGroupStudentMapperDao.insert(classGroupStudentMapper);
|
|
|
+
|
|
|
+ classGroup.setDelFlag(0);
|
|
|
+ VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice = vipGroupDefaultClassesUnitPriceDao.getByVipGroupCategory(vipGroup.getVipGroupCategoryId(),
|
|
|
+ vipGroup.getOrganId(), vipGroup.getGroupType());
|
|
|
+
|
|
|
+ //生成课表
|
|
|
+ List<CourseSchedule> courseSchedules = JSON.parseArray(vipGroup.getCourseSchedulesJson(), CourseSchedule.class);
|
|
|
+ classGroup.setTotalClassTimes(courseSchedules.size());
|
|
|
+
|
|
|
+ courseScheduleService.batchAddCourseSchedule1(courseSchedules);
|
|
|
+
|
|
|
+ //考勤信息
|
|
|
+ List<TeacherAttendance> teacherAttendances = new ArrayList<>();
|
|
|
+ //创建课酬信息
|
|
|
+ List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaries = new ArrayList<>();
|
|
|
+ Map<String, BigDecimal> stringBigDecimalMap = countVipGroupPredictFee1(vipGroup, vipGroup.getUserId(), null);
|
|
|
+ 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(stringBigDecimalMap.get("offlineTeacherSalary"));
|
|
|
+ courseScheduleTeacherSalary.setActualSalary(null);
|
|
|
+ courseScheduleTeacherSalary.setTenantId(tenantId);
|
|
|
+ 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());
|
|
|
+ teacherAttendance.setTenantId(tenantId);
|
|
|
+ teacherAttendances.add(teacherAttendance);
|
|
|
+ }
|
|
|
+ courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaries);
|
|
|
+ teacherAttendanceDao.batchInsert(teacherAttendances);
|
|
|
+
|
|
|
+ //群聊数据
|
|
|
+ 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","VIP".equals(vipGroup.getGroupType())?"SMALL_CLASS_TO_BUY":"LIVE_GROUP_BUY");
|
|
|
+ //实际支付金额,去除优惠券
|
|
|
+ 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().toString(), null, classGroup.getName(), classGroup.getName(),
|
|
|
+ vipGroup.getName(), null, null, vipGroup.getGroupType(), ImGroup.GroupTypeEnum.valueOf(vipGroup.getGroupType()));
|
|
|
+ imGroupMemberService.join(classGroup.getId().toString(), userRoleMap);
|
|
|
+ imUserFriendService.refreshGroupImUserFriend(classGroup.getMusicGroupId(), classGroup.getGroupType());
|
|
|
+ //更新所属分部列表
|
|
|
+ List<Integer> organIds = classGroupDao.findStudentOrganIdsByClassGroup(classGroup.getId().longValue());
|
|
|
+ organIds.add(vipGroup.getOrganId());
|
|
|
+ HashSet<Integer> hashSet = new HashSet<>(organIds);
|
|
|
+ String organIdsString = StringUtils.join(hashSet, ",");
|
|
|
+ vipGroup.setOrganIdList(organIdsString);
|
|
|
+ vipGroupDao.update(vipGroup);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
public void updateVipGroupStatusToFinished() {
|
|
@@ -4512,21 +4617,4 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
return vipGroupApplyDto;
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public void createLiveCourse() {
|
|
|
- List<VipGroup> vipGroups = vipGroupDao.findNoCreateSuccessVipGroup(null,"LIVE");
|
|
|
- if(!CollectionUtils.isEmpty(vipGroups)){
|
|
|
- List<VipGroup> noStudentGroup = vipGroups.stream().filter(e -> StringUtils.isEmpty(e.getStudentIdList())).collect(Collectors.toList());
|
|
|
- List<VipGroup> hasStudentGroup = vipGroups.stream().filter(e -> StringUtils.isNotEmpty(e.getStudentIdList())).collect(Collectors.toList());
|
|
|
- if(!CollectionUtils.isEmpty(noStudentGroup)){
|
|
|
- //关闭课程组
|
|
|
-
|
|
|
- }
|
|
|
- if(!CollectionUtils.isEmpty(hasStudentGroup)){
|
|
|
- //排课
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|