|
@@ -203,6 +203,276 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("请设置教学点");
|
|
|
}
|
|
|
|
|
|
+ Date now = new Date();
|
|
|
+
|
|
|
+ VipGroupApplyBaseInfoDto vipGroupApplyBaseInfoDto = vipGroup.getVipGroupApplyBaseInfo();
|
|
|
+
|
|
|
+ if(Objects.isNull(vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice())
|
|
|
+ &&Objects.isNull(vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice())){
|
|
|
+ throw new BizException("请设置课程单价");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StringUtils.isBlank(vipGroupApplyBaseInfoDto.getStudentIdList())){
|
|
|
+ throw new BizException("请选择学员");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(Objects.isNull(vipGroupApplyBaseInfoDto.getOfflineTeacherSalary())){
|
|
|
+ throw new BizException("请设置教师课酬");
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer totalClassTimes=vipGroupApplyBaseInfoDto.getOnlineClassesNum()+vipGroupApplyBaseInfoDto.getOfflineClassesNum();
|
|
|
+ //获取第一节课
|
|
|
+ CourseSchedule firstCourseSchedule = vipGroup.getCourseSchedules().stream().min(Comparator.comparing(CourseSchedule::getStartClassTime)).get();
|
|
|
+ //获取最后一节课
|
|
|
+ CourseSchedule latestCourseSchedule = vipGroup.getCourseSchedules().stream().max(Comparator.comparing(CourseSchedule::getEndClassTime)).get();
|
|
|
+
|
|
|
+ if(firstCourseSchedule.getStartClassTime().before(now)){
|
|
|
+ throw new BizException("开课时间不能小于当前时间");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(vipGroupApplyBaseInfoDto.getRegistrationStartTime().after(vipGroupApplyBaseInfoDto.getPaymentExpireDate())){
|
|
|
+ throw new BizException("报名开始时间必须在报名截至时间之前");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(vipGroupApplyBaseInfoDto.getPaymentExpireDate().after(firstCourseSchedule.getStartClassTime())
|
|
|
+ ||DateUtil.isSameDay(vipGroupApplyBaseInfoDto.getPaymentExpireDate(),firstCourseSchedule.getEndClassTime())){
|
|
|
+ throw new BizException("创建失败,报名截止时间必须在开课时间前一天");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> canBuyStudentIds = Arrays.stream(vipGroupApplyBaseInfoDto.getStudentIdList().split(",")).map(e -> Integer.valueOf(e)).collect(Collectors.toList());
|
|
|
+ List<VipGroupStudentCoursePrice> vscps = vipGroup.getVipGroupApplyBaseInfo().getVipGroupStudentCoursePrices();
|
|
|
+
|
|
|
+ //获取活动信息
|
|
|
+ VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupApplyBaseInfo().getVipGroupActivityId());
|
|
|
+ if(!vipGroup.getAllowOverstepActivityStudentNum()&&Objects.nonNull(vipGroupActivity)&&Objects.nonNull(vipGroupActivity.getStudentMaxUsedTimes())&&vipGroupActivity.getStudentMaxUsedTimes()!=-1&&StringUtils.isNotBlank(vipGroupApplyBaseInfoDto.getStudentIdList())){
|
|
|
+ List<String> tempStudentIds = Arrays.asList(vipGroupApplyBaseInfoDto.getStudentIdList().split(","));
|
|
|
+ List<Integer> errStudentIds = new ArrayList<>();
|
|
|
+ for (String studentIdStr : tempStudentIds) {
|
|
|
+ int useNum = vipGroupDao.countStudentUserActivityNum(vipGroup.getVipGroupApplyBaseInfo().getVipGroupActivityId(), Integer.valueOf(studentIdStr));
|
|
|
+ if(useNum>=vipGroupActivity.getStudentMaxUsedTimes()){
|
|
|
+ errStudentIds.add(Integer.valueOf(studentIdStr));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(errStudentIds.size() > 0){
|
|
|
+ List<SimpleUserDto> students = teacherDao.getUsersSimpleInfo(errStudentIds);
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ String studentNames = StringUtils.join(students.stream().map(SimpleUserDto::getNickName).collect(Collectors.toList()), "、");
|
|
|
+ return BaseController.failed(HttpStatus.PARTIAL_CONTENT,"该活动"+studentNames+"学员创建及成课之和已达上限,是否继续创建该课程?");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //判断课程安排是否超出范围
|
|
|
+ if(Objects.nonNull(vipGroupActivity)&&(Objects.nonNull(vipGroupActivity.getCoursesEndTime())||Objects.nonNull(vipGroupActivity.getCoursesStartTime()))){
|
|
|
+ if(latestCourseSchedule.getEndClassTime().after(vipGroupActivity.getCoursesEndTime())
|
|
|
+ ||firstCourseSchedule.getStartClassTime().before(vipGroupActivity.getCoursesStartTime())){
|
|
|
+ throw new BizException("课时安排时间超出范围!");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ VipGroupDefaultClassesCycle vipGroupDefaultClassesCycle = vipGroupDefaultClassesCycleDao.findByOrganAndClassTimes(totalClassTimes);
|
|
|
+
|
|
|
+ if (vipGroupDefaultClassesCycle != null) {
|
|
|
+ int month = DateUtil.monthsBetween(firstCourseSchedule.getStartClassTime(), latestCourseSchedule.getEndClassTime());
|
|
|
+ if (month > vipGroupDefaultClassesCycle.getMonth()) {
|
|
|
+ throw new BizException("课时安排时间超出范围!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(Objects.nonNull(vipGroupActivity)&&Objects.nonNull(vipGroupActivity.getMinCourseNum())&&vipGroupActivity.getMinCourseNum()!=-1&&Objects.nonNull(vipGroupActivity.getMaxCourseNum())&&vipGroupActivity.getMaxCourseNum()!=-1){
|
|
|
+ Integer requestCourseNum = vipGroupApplyBaseInfoDto.getOnlineClassesNum() + vipGroupApplyBaseInfoDto.getOfflineClassesNum();
|
|
|
+ if(requestCourseNum.compareTo(vipGroupActivity.getMinCourseNum())<0||requestCourseNum.compareTo(vipGroupActivity.getMaxCourseNum())>0){
|
|
|
+ throw new BizException("该活动课时数为{}节~{}节", vipGroupActivity.getMinCourseNum(), vipGroupActivity.getMaxCourseNum());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ int repeatVipGroups = vipGroupDao.countUserRepeatVipGroupInCourseStartEndTime(vipGroupApplyBaseInfoDto.getUserId(), firstCourseSchedule.getStartClassTime(), latestCourseSchedule.getEndClassTime());
|
|
|
+ if(repeatVipGroups > 0){
|
|
|
+ throw new BizException("请勿重复提交");
|
|
|
+ }
|
|
|
+
|
|
|
+ VipGroupCategory vipGroupCategory = vipGroupCategoryDao.get(vipGroupApplyBaseInfoDto.getVipGroupCategoryId());
|
|
|
+ if(Objects.isNull(vipGroupCategory)){
|
|
|
+ throw new BizException("课程形式不存在");
|
|
|
+ }
|
|
|
+ List<String> studentNames = studentDao.getStudentNames(canBuyStudentIds);
|
|
|
+
|
|
|
+ //生成vip课信息
|
|
|
+ List<String> bySubIds = subjectDao.findBySubIds(vipGroupApplyBaseInfoDto.getSubjectIdList());
|
|
|
+ StringBuffer className = new StringBuffer();
|
|
|
+ if(Objects.isNull(vipGroupCategory.getMusicTheory())||!vipGroupCategory.getMusicTheory()){
|
|
|
+ className.append(StringUtils.join(bySubIds,","));
|
|
|
+ className.append(vipGroupCategory.getName());
|
|
|
+ }else{
|
|
|
+ className.append("乐理课•");
|
|
|
+ }
|
|
|
+ className.append(StringUtils.join(studentNames, ","));
|
|
|
+ vipGroupApplyBaseInfoDto.setName(className.toString());
|
|
|
+
|
|
|
+ //计算课程相关费用信息
|
|
|
+ Map<String, BigDecimal> costInfo = countVipGroupPredictFee1(vipGroupApplyBaseInfoDto,
|
|
|
+ vipGroupApplyBaseInfoDto.getUserId(), null);
|
|
|
+
|
|
|
+ vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.PASS);
|
|
|
+
|
|
|
+ vipGroupApplyBaseInfoDto.setStatus(VipGroupStatusEnum.APPLYING);
|
|
|
+ //如果默认课酬与实际课酬不匹配则需要审批
|
|
|
+ if(costInfo.get("offlineTeacherSalary").compareTo(vipGroupApplyBaseInfoDto.getOfflineTeacherSalary()) < 0){
|
|
|
+ vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.ING);
|
|
|
+ }
|
|
|
+
|
|
|
+ vipGroupApplyBaseInfoDto.setTotalPrice(costInfo.get("totalPrice"));
|
|
|
+ if(CollectionUtils.isEmpty(vscps)){
|
|
|
+ vscps = new ArrayList<>();
|
|
|
+ for (Integer canBuyStudentId : canBuyStudentIds) {
|
|
|
+ vscps.add(new VipGroupStudentCoursePrice(canBuyStudentId, vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice(), vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice(), vipGroupApplyBaseInfoDto.getTotalPrice()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Teacher teacher = teacherService.get(vipGroupApplyBaseInfoDto.getUserId());
|
|
|
+ if(Objects.isNull(teacher)){
|
|
|
+ throw new BizException("教师不存在");
|
|
|
+ }
|
|
|
+ if(Objects.isNull(teacher.getTeacherOrganId())){
|
|
|
+ throw new BizException("教师部门异常");
|
|
|
+ }
|
|
|
+// vipGroupApplyBaseInfoDto.setOrganId(Integer.parseInt(teacher.getOrganId()));
|
|
|
+ //开课时间为排课的第一节课的开始时间
|
|
|
+ vipGroupApplyBaseInfoDto.setCourseStartDate(firstCourseSchedule.getStartClassTime());
|
|
|
+ //课程结束时间为排课的最后一节课的结束时间
|
|
|
+ vipGroupApplyBaseInfoDto.setCoursesExpireDate(latestCourseSchedule.getEndClassTime());
|
|
|
+
|
|
|
+ vipGroupApplyBaseInfoDto.setPaymentExpireDate(DateUtil.getLastSecondWithDay(vipGroupApplyBaseInfoDto.getPaymentExpireDate()));
|
|
|
+
|
|
|
+ if(vipGroup.getOnlyProgress()){
|
|
|
+ vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.PASS);
|
|
|
+ }
|
|
|
+
|
|
|
+ vipGroupDao.insert(vipGroupApplyBaseInfoDto);
|
|
|
+
|
|
|
+ vscps.forEach(e->e.setVipGroupId(vipGroupApplyBaseInfoDto.getId()));
|
|
|
+ vipGroupStudentCoursePriceDao.batchInsert(vscps);
|
|
|
+
|
|
|
+ vipGroup.getVipGroupApplyBaseInfo().setId(vipGroupApplyBaseInfoDto.getId());
|
|
|
+
|
|
|
+ //创建班级信息
|
|
|
+ ClassGroup classGroup = new ClassGroup();
|
|
|
+ classGroup.setSubjectIdList(vipGroupApplyBaseInfoDto.getSubjectIdList());
|
|
|
+ //如果是乐理课实际人数为所选学员数量
|
|
|
+ if(vipGroupCategory.getMusicTheory()){
|
|
|
+ classGroup.setExpectStudentNum(canBuyStudentIds.size());
|
|
|
+ }else {
|
|
|
+ classGroup.setExpectStudentNum(vipGroupCategory.getStudentNum());
|
|
|
+ }
|
|
|
+ classGroup.setStudentNum(0);
|
|
|
+ classGroup.setName(vipGroupApplyBaseInfoDto.getName());
|
|
|
+ classGroup.setTotalClassTimes(totalClassTimes);
|
|
|
+ classGroup.setType(ClassGroupTypeEnum.VIP);
|
|
|
+ classGroup.setDelFlag(1);
|
|
|
+ classGroup.setGroupType(GroupType.VIP);
|
|
|
+ classGroup.setMusicGroupId(vipGroupApplyBaseInfoDto.getId().toString());
|
|
|
+ classGroup.setCreateTime(now);
|
|
|
+ classGroup.setUpdateTime(now);
|
|
|
+ classGroupDao.insert(classGroup);
|
|
|
+
|
|
|
+ //创建班级老师关联记录
|
|
|
+ ClassGroupTeacherMapper classGroupTeacherMapper = new ClassGroupTeacherMapper();
|
|
|
+ classGroupTeacherMapper.setMusicGroupId(vipGroupApplyBaseInfoDto.getId().toString());
|
|
|
+ classGroupTeacherMapper.setClassGroupId(classGroup.getId());
|
|
|
+ classGroupTeacherMapper.setTeacherRole(TeachTypeEnum.BISHOP);
|
|
|
+ classGroupTeacherMapper.setUserId(vipGroupApplyBaseInfoDto.getUserId());
|
|
|
+ classGroupTeacherMapper.setGroupType(GroupType.VIP);
|
|
|
+ classGroupTeacherMapper.setCreateTime(now);
|
|
|
+ classGroupTeacherMapper.setUpdateTime(now);
|
|
|
+ classGroupTeacherMapperDao.insert(classGroupTeacherMapper);
|
|
|
+
|
|
|
+ //创建班级与老师课酬记录
|
|
|
+ ClassGroupTeacherSalary classGroupTeacherSalary=new ClassGroupTeacherSalary();
|
|
|
+ classGroupTeacherSalary.setMusicGroupId(vipGroupApplyBaseInfoDto.getId().toString());
|
|
|
+ classGroupTeacherSalary.setClassGroupId(classGroup.getId());
|
|
|
+ classGroupTeacherSalary.setTeacherRole(TeachTypeEnum.BISHOP);
|
|
|
+ classGroupTeacherSalary.setUserId(vipGroupApplyBaseInfoDto.getUserId());
|
|
|
+ classGroupTeacherSalary.setSalary(vipGroupApplyBaseInfoDto.getOfflineTeacherSalary());
|
|
|
+ classGroupTeacherSalary.setOnlineClassesSalary(vipGroupApplyBaseInfoDto.getOfflineTeacherSalary());
|
|
|
+ classGroupTeacherSalary.setGroupType(GroupType.VIP);
|
|
|
+ classGroupTeacherSalary.setCreateTime(now);
|
|
|
+ classGroupTeacherSalary.setUpdateTime(now);
|
|
|
+ classGroupTeacherSalaryDao.insert(classGroupTeacherSalary);
|
|
|
+
|
|
|
+ //课程信息调整
|
|
|
+ List<CourseSchedule> courseSchedules = vipGroup.getCourseSchedules();
|
|
|
+ courseSchedules.forEach(courseSchedule -> {
|
|
|
+ courseSchedule.setGroupType(GroupType.VIP);
|
|
|
+ courseSchedule.setMusicGroupId(vipGroupApplyBaseInfoDto.getId().toString());
|
|
|
+ if(courseSchedule.getTeachMode().equals(TeachModeEnum.OFFLINE)){
|
|
|
+ courseSchedule.setSchoolId(vipGroup.getVipGroupApplyBaseInfo().getTeacherSchoolId());
|
|
|
+ }
|
|
|
+ courseSchedule.setTeacherId(vipGroupApplyBaseInfoDto.getUserId());
|
|
|
+ courseSchedule.setActualTeacherId(vipGroupApplyBaseInfoDto.getUserId());
|
|
|
+ courseSchedule.setStatus(CourseStatusEnum.NOT_START);
|
|
|
+ courseSchedule.setType(CourseSchedule.CourseScheduleType.VIP);
|
|
|
+ courseSchedule.setClassGroupId(classGroup.getId());
|
|
|
+ courseSchedule.setName(vipGroupApplyBaseInfoDto.getName());
|
|
|
+ courseSchedule.setOrganId(vipGroupApplyBaseInfoDto.getOrganId());
|
|
|
+ });
|
|
|
+ courseScheduleService.checkNewCourseSchedules(courseSchedules,false,false);
|
|
|
+ vipGroupApplyBaseInfoDto.setCourseSchedulesJson(JSON.toJSONString(courseSchedules));
|
|
|
+ vipGroupDao.update(vipGroupApplyBaseInfoDto);
|
|
|
+
|
|
|
+ Set<Integer> roleIds = new HashSet<>(1);
|
|
|
+ roleIds.add(SysUserRole.SECTION_MANAGER);
|
|
|
+ Map<String,Long> memo = new HashMap<>(1);
|
|
|
+ memo.put("vipGroupId",vipGroupApplyBaseInfoDto.getId());
|
|
|
+// SysUser sysUser = sysUserFeignService.queryUserById(vipGroup.getVipGroupApplyBaseInfo().getUserId());
|
|
|
+ if(Objects.isNull(teacher)){
|
|
|
+ throw new BizException("该用户不存在");
|
|
|
+ }
|
|
|
+ Set<Integer> userIds = musicGroupDao.queryUserIdByRoleId(roleIds,teacher.getTeacherOrganId());
|
|
|
+ if(CollectionUtils.isEmpty(userIds)){
|
|
|
+ throw new BizException("当前分部没有运营主管,无法创建,请联系总部工作人员!");
|
|
|
+ }
|
|
|
+ if(vipGroupApplyBaseInfoDto.getEducationalTeacherId() != null){
|
|
|
+ userIds.add(vipGroupApplyBaseInfoDto.getEducationalTeacherId());
|
|
|
+ }
|
|
|
+// if (vipGroup.getVipGroupApplyBaseInfo().getUserId() != null){
|
|
|
+// sysMessageService.batchSeoMessage(userIds,MessageTypeEnum.BACKSTAGE_VIP_COURSE_APPLY, JSONObject.toJSONString(memo),sysUser.getUsername(),sysUser.getUsername());
|
|
|
+// }else {
|
|
|
+ sysMessageService.batchSeoMessage(userIds,MessageTypeEnum.BACKSTAGE_TEACHER_APPLY_VIP, JSONObject.toJSONString(memo),teacher.getRealName());
|
|
|
+// }
|
|
|
+ return BaseController.succeed(vipGroupApplyBaseInfoDto.getAuditStatus().getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
+ @Override
|
|
|
+ public HttpResponseResult createVipGroup1(VipGroupApplyDto vipGroup) {
|
|
|
+
|
|
|
+ if (Objects.isNull(vipGroup.getVipGroupApplyBaseInfo().getUserId())){
|
|
|
+ throw new BizException("请选择指导老师");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(vipGroup.getCourseSchedules().size()!=(vipGroup.getVipGroupApplyBaseInfo().getOfflineClassesNum()+vipGroup.getVipGroupApplyBaseInfo().getOnlineClassesNum())){
|
|
|
+ throw new BizException("建课失败,当前课程存在未排课课程,请调整相关设置");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<TeachModeEnum, List<CourseSchedule>> courseScheduleGroup;
|
|
|
+ try {
|
|
|
+ courseScheduleGroup = vipGroup.getCourseSchedules().stream().collect(Collectors.groupingBy(CourseSchedule::getTeachMode));
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BizException("教学模式错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ if((Objects.isNull(courseScheduleGroup.get(TeachModeEnum.OFFLINE))&&vipGroup.getVipGroupApplyBaseInfo().getOfflineClassesNum()!=0)
|
|
|
+ ||(!Objects.isNull(courseScheduleGroup.get(TeachModeEnum.OFFLINE))&&(courseScheduleGroup.get(TeachModeEnum.OFFLINE).size()<vipGroup.getVipGroupApplyBaseInfo().getOfflineClassesNum()))){
|
|
|
+ throw new BizException("线下课课时数量安排有误");
|
|
|
+ }
|
|
|
+
|
|
|
+ if((Objects.isNull(courseScheduleGroup.get(TeachModeEnum.ONLINE))&&vipGroup.getVipGroupApplyBaseInfo().getOnlineClassesNum()!=0)
|
|
|
+ ||(!Objects.isNull(courseScheduleGroup.get(TeachModeEnum.ONLINE))&&(courseScheduleGroup.get(TeachModeEnum.ONLINE).size()<vipGroup.getVipGroupApplyBaseInfo().getOnlineClassesNum()))){
|
|
|
+ throw new BizException("线上课课时数量安排有误");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(vipGroup.getVipGroupApplyBaseInfo().getOfflineClassesNum()>0
|
|
|
+ &&Objects.isNull(vipGroup.getVipGroupApplyBaseInfo().getTeacherSchoolId())){
|
|
|
+ throw new BizException("请设置教学点");
|
|
|
+ }
|
|
|
+
|
|
|
String studentIds=vipGroup.getStudentIds();
|
|
|
List<String> studentIdList=new ArrayList<>();
|
|
|
if(StringUtils.isNotBlank(studentIds)){
|
|
@@ -1064,10 +1334,10 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
vipGroup.getVipGroupApplyBaseInfo().setId(applyBaseInfo.getId());
|
|
|
|
|
|
//创建班级信息
|
|
|
- ClassGroup classGroup=new ClassGroup();
|
|
|
+ ClassGroup classGroup = new ClassGroup();
|
|
|
classGroup.setSubjectIdList(applyBaseInfo.getSubjectIdList());
|
|
|
classGroup.setExpectStudentNum(vipGroupCategory.getStudentNum());
|
|
|
- classGroup.setStudentNum(studentIdList.size());
|
|
|
+ classGroup.setStudentNum(0);
|
|
|
classGroup.setName(applyBaseInfo.getName());
|
|
|
classGroup.setTotalClassTimes(totalClassTimes);
|
|
|
classGroup.setType(ClassGroupTypeEnum.VIP);
|
|
@@ -1077,12 +1347,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
classGroup.setCreateTime(now);
|
|
|
classGroup.setUpdateTime(now);
|
|
|
classGroupDao.insert(classGroup);
|
|
|
- if(!vipGroup.getGiveFlag()){
|
|
|
- StudentPaymentOrder order = studentPaymentOrderDao.get(activityUserMappers.get(0).getPaymentOrderId());
|
|
|
- order.setMusicGroupId(applyBaseInfo.getId().toString());
|
|
|
- order.setClassGroupId(classGroup.getId());
|
|
|
- studentPaymentOrderDao.update(order);
|
|
|
- }
|
|
|
|
|
|
//班级学员关联记录
|
|
|
List<ClassGroupStudentMapper> classGroupStudentMapperList = new ArrayList<>();
|
|
@@ -1132,8 +1396,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
classGroupTeacherSalary.setUpdateTime(now);
|
|
|
classGroupTeacherSalaryDao.insert(classGroupTeacherSalary);
|
|
|
|
|
|
+ //创建课程
|
|
|
+ List<CourseSchedule> courseSchedules = vipGroup.getCourseSchedules();
|
|
|
+
|
|
|
+ //创建老师单节课课酬信息
|
|
|
+ List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaries = new ArrayList<>();
|
|
|
//课程信息调整
|
|
|
- vipGroup.getCourseSchedules().forEach(courseSchedule -> {
|
|
|
+ for (CourseSchedule courseSchedule : courseSchedules) {
|
|
|
courseSchedule.setGroupType(GroupType.VIP);
|
|
|
courseSchedule.setMusicGroupId(applyBaseInfo.getId().toString());
|
|
|
if(courseSchedule.getTeachMode().equals(TeachModeEnum.OFFLINE)){
|
|
@@ -1146,20 +1415,27 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
courseSchedule.setClassGroupId(classGroup.getId());
|
|
|
courseSchedule.setName(applyBaseInfo.getName());
|
|
|
courseSchedule.setOrganId(applyBaseInfo.getOrganId());
|
|
|
- });
|
|
|
|
|
|
- applyBaseInfo.setCourseSchedulesJson(JSON.toJSONString(vipGroup.getCourseSchedules()));
|
|
|
- vipGroupDao.update(applyBaseInfo);
|
|
|
-
|
|
|
- //创建课程
|
|
|
- List<CourseSchedule> courseSchedules = vipGroup.getCourseSchedules();
|
|
|
+ //创建教师课程薪水记录
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ if (courseScheduleTeacherSalaries.size() > 0) {
|
|
|
+ courseScheduleTeacherSalaryService.batchInsert(courseScheduleTeacherSalaries);
|
|
|
+ }
|
|
|
+ courseScheduleService.checkNewCourseSchedules(courseSchedules, false,false);
|
|
|
courseScheduleService.batchAddCourseSchedule(courseSchedules);
|
|
|
- //创建老师单节课课酬信息
|
|
|
- courseScheduleTeacherSalaryService.createCourseScheduleTeacherVipSalary(applyBaseInfo,
|
|
|
- courseSchedules,
|
|
|
- classGroupTeacherSalary.getSalary());
|
|
|
|
|
|
- SysUser sysUser = sysUserFeignService.queryUserById(applyBaseInfo.getUserId());
|
|
|
+ applyBaseInfo.setCourseSchedulesJson(JSON.toJSONString(vipGroup.getCourseSchedules()));
|
|
|
+ vipGroupDao.update(applyBaseInfo);
|
|
|
|
|
|
List<ClassGroupStudentMapper> classGroupStudents = classGroupStudentMapperDao.findByClassGroup(classGroup.getId());
|
|
|
|
|
@@ -1181,8 +1457,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
studentPaymentOrderDao.update(studentPaymentOrder);
|
|
|
}
|
|
|
//生成学生单课缴费信息
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPayments=new ArrayList<>();
|
|
|
+ Map<Integer, List<ActivityUserMapper>> collect = activityUserMappers.stream().collect(Collectors.groupingBy(ActivityUserMapper::getUserId));
|
|
|
for (ClassGroupStudentMapper classGroupStudent : classGroupStudents) {
|
|
|
- List<CourseScheduleStudentPayment> courseScheduleStudentPayments=new ArrayList<>();
|
|
|
if(vipGroup.getGiveFlag()){
|
|
|
for (CourseSchedule courseSchedule : courseSchedules) {
|
|
|
CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
@@ -1197,10 +1474,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
courseScheduleStudentPayments.add(courseScheduleStudentPayment);
|
|
|
}
|
|
|
}else{
|
|
|
+ ActivityUserMapper activityUserMapper = collect.get(classGroupStudent.getUserId()).get(0);
|
|
|
//实际支付金额,去除优惠券
|
|
|
- BigDecimal actualPrice = studentPaymentOrder.getExpectAmount().subtract(studentPaymentOrder.getCouponRemitFee());
|
|
|
- BigDecimal divide = actualPrice.divide(new BigDecimal(courseSchedules.size()), ROUND_DOWN);
|
|
|
- BigDecimal firstAmount = actualPrice.subtract(divide.multiply(new BigDecimal(courseSchedules.size()))).add(divide);
|
|
|
+ BigDecimal totalAmount = activityUserMapper.getActualPrice();
|
|
|
+ BigDecimal singleAmount = totalAmount.divide(new BigDecimal(courseSchedules.size()), ROUND_DOWN);
|
|
|
+ BigDecimal firstSingleAmount = totalAmount.subtract(singleAmount.multiply(new BigDecimal(courseSchedules.size()))).add(singleAmount);
|
|
|
for (int i = 0; i < courseSchedules.size(); i++) {
|
|
|
CourseSchedule courseSchedule = courseSchedules.get(i);
|
|
|
CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
@@ -1210,36 +1488,37 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
|
courseScheduleStudentPayment.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
if (i == 0) {
|
|
|
- courseScheduleStudentPayment.setExpectPrice(firstAmount);
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(firstSingleAmount);
|
|
|
}else{
|
|
|
- courseScheduleStudentPayment.setExpectPrice(actualPrice);
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(singleAmount);
|
|
|
}
|
|
|
courseScheduleStudentPayment.setOriginalPrice(TeachModeEnum.ONLINE.equals(courseSchedule.getTeachMode())?vipGroupDefaultClassesUnitPrice.getOnlineClassesUnitPrice():vipGroupDefaultClassesUnitPrice.getOfflineClassesUnitPrice());
|
|
|
courseScheduleStudentPayment.setActualPrice(courseScheduleStudentPayment.getExpectPrice());
|
|
|
courseScheduleStudentPayments.add(courseScheduleStudentPayment);
|
|
|
}
|
|
|
}
|
|
|
- courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
|
|
|
userRoleMap.put(classGroupStudent.getUserId(),null);
|
|
|
- studentDao.updateStudentServiceTag(classGroupStudent.getUserId(), null, YesOrNoEnum.YES.getCode());
|
|
|
}
|
|
|
-
|
|
|
- courseScheduleService.checkNewCourseSchedules(courseSchedules, false,false);
|
|
|
+ if(courseScheduleStudentPayments.size() > 0){
|
|
|
+ courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
|
|
|
+ studentDao.updateStudentServiceTag(null,studentIdList, YesOrNoEnum.YES.getCode());
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
imGroupService.create(classGroup.getId().longValue(), null, classGroup.getName(), classGroup.getName(), applyBaseInfo.getName(), null, null, GroupType.VIP.getCode());
|
|
|
imGroupMemberService.join(classGroup.getId().longValue(), userRoleMap);
|
|
|
imUserFriendService.refreshGroupImUserFriend(classGroup.getMusicGroupId(),classGroup.getGroupType());
|
|
|
- //发送推送
|
|
|
- Map<Integer,String> map = new HashMap<>(1);
|
|
|
- map.put(applyBaseInfo.getUserId(),sysUser.getPhone());
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG,MessageTypeEnum.CHILDREN_DAY_VIP_COURSE_TEACHER_PUSH,
|
|
|
- map,null,0,"","TEACHER", StringUtils.join(studentNames, ","),applyBaseInfo.getName());
|
|
|
-
|
|
|
- Map<Integer,String> studentIdStrMap = new HashMap<>(1);
|
|
|
- studentIdList.forEach(id->studentIdStrMap.put(id, id.toString()));
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.CHILDREN_DAY_VIP_COURSE_STUDENT_PUSH, studentIdStrMap, null, 0, "","STUDENT",
|
|
|
- applyBaseInfo.getName());
|
|
|
+// SysUser sysUser = teacherDao.getUser(applyBaseInfo.getUserId());
|
|
|
+// //发送推送
|
|
|
+// Map<Integer,String> map = new HashMap<>(1);
|
|
|
+// map.put(applyBaseInfo.getUserId(),sysUser.getPhone());
|
|
|
+// sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG,MessageTypeEnum.CHILDREN_DAY_VIP_COURSE_TEACHER_PUSH,
|
|
|
+// map,null,0,"","TEACHER", StringUtils.join(studentNames, ","),applyBaseInfo.getName());
|
|
|
+//
|
|
|
+// Map<Integer,String> studentIdStrMap = new HashMap<>(1);
|
|
|
+// studentIdList.forEach(id->studentIdStrMap.put(id, id.toString()));
|
|
|
+// sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.CHILDREN_DAY_VIP_COURSE_STUDENT_PUSH, studentIdStrMap, null, 0, "","STUDENT",
|
|
|
+// applyBaseInfo.getName());
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
LOGGER.error("消息发送失败:{}", e);
|
|
@@ -2279,6 +2558,14 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
vipGroupBuyParams.getUserId(),
|
|
|
DealStatusEnum.ING,
|
|
|
OrderTypeEnum.SMALL_CLASS_TO_BUY);
|
|
|
+
|
|
|
+ ClassGroup classGroup = classGroupDao.findByMusicGroupAndType(vipGroupBuyParams.getVipGroupId().toString(),ClassGroupTypeEnum.VIP.getCode());
|
|
|
+
|
|
|
+ classGroup = classGroupDao.lockClassGroup(classGroup.getId());
|
|
|
+
|
|
|
+ if(Objects.isNull(classGroup)){
|
|
|
+ throw new BizException("班级信息错误");
|
|
|
+ }
|
|
|
if (list.size() > 0) {
|
|
|
StudentPaymentOrder applyOrder = list.get(list.size() - 1);
|
|
|
// 查询订单状态
|
|
@@ -2300,25 +2587,15 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
studentPaymentOrderService.update(applyOrder);
|
|
|
sysCouponCodeService.quit(applyOrder.getCouponCodeId());
|
|
|
+ classGroup.setStudentNum(classGroup.getStudentNum() - 1);
|
|
|
}
|
|
|
|
|
|
- ClassGroup classGroup =classGroupDao.findByMusicGroupAndType(vipGroupBuyParams.getVipGroupId().toString(),ClassGroupTypeEnum.VIP.getCode());
|
|
|
-
|
|
|
- classGroup= classGroupDao.lockClassGroup(classGroup.getId());
|
|
|
-
|
|
|
- if(Objects.isNull(classGroup)){
|
|
|
- throw new BizException("课程信息错误");
|
|
|
- }
|
|
|
-
|
|
|
- Date date=new Date();
|
|
|
+ Date date = new Date();
|
|
|
|
|
|
VipGroup vipGroup = vipGroupDao.get(vipGroupBuyParams.getVipGroupId());
|
|
|
|
|
|
- if(classGroup.getStudentNum()>0&&(VipGroupStatusEnum.APPLYING.equals(vipGroup.getStatus()))){
|
|
|
- int i = studentPaymentOrderDao.countGroupOrderWithoutFailed(vipGroupBuyParams.getVipGroupId().toString(), GroupType.VIP);
|
|
|
- if(i<=0){
|
|
|
- throw new BizException("该课程已经无法通过购买加入,请联系教务老师!");
|
|
|
- }
|
|
|
+ if(classGroup.getStudentNum() >= classGroup.getExpectStudentNum()){
|
|
|
+ throw new BizException("该VIP课人数已满,请联系教务老师!");
|
|
|
}
|
|
|
|
|
|
VipGroupActivity vipGroupActivity = null;
|
|
@@ -2326,9 +2603,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId().intValue());
|
|
|
}
|
|
|
|
|
|
- if(Objects.nonNull(vipGroupActivity)&&Objects.nonNull(vipGroupActivity.getStudentMaxUsedTimes())&&vipGroupActivity.getStudentMaxUsedTimes()!=-1){
|
|
|
+ if(Objects.nonNull(vipGroupActivity) && Objects.nonNull(vipGroupActivity.getStudentMaxUsedTimes()) && vipGroupActivity.getStudentMaxUsedTimes() != -1){
|
|
|
int useNum = vipGroupDao.countStudentUseingActivityNum(vipGroup.getVipGroupActivityId(), Integer.valueOf(user.getId()));
|
|
|
- if(useNum>=vipGroupActivity.getStudentMaxUsedTimes()){
|
|
|
+ if(useNum >= vipGroupActivity.getStudentMaxUsedTimes()){
|
|
|
throw new BizException("您已超过该活动购买次数限制", vipGroupActivity.getStudentMaxUsedTimes());
|
|
|
}
|
|
|
}
|
|
@@ -2343,33 +2620,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("您无法购买此课程");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- List<StudentPaymentOrder> oldOrders = studentPaymentOrderDao.findNotFailedOrderByStudentVipGroup(vipGroupBuyParams.getVipGroupId(),
|
|
|
- user.getId());
|
|
|
- Map<DealStatusEnum, Long> statusCountMap = oldOrders.stream().collect(Collectors.groupingBy(StudentPaymentOrder::getStatus, Collectors.counting()));
|
|
|
-
|
|
|
- if(Objects.nonNull(statusCountMap.get(DealStatusEnum.SUCCESS))&&statusCountMap.get(DealStatusEnum.SUCCESS)>0){
|
|
|
- if("36".equals(user.getOrganId())){
|
|
|
- throw new BizException("您已预约过此课程");
|
|
|
- }
|
|
|
- throw new BizException("您已购买过此课程");
|
|
|
- }else if(CollectionUtils.isEmpty(oldOrders)){
|
|
|
- if(classGroup.getStudentNum()>=classGroup.getExpectStudentNum()){
|
|
|
- throw new BizException("该课程人数已达上限");
|
|
|
- }
|
|
|
- //更新班级人数,如果订单支付失败则减少
|
|
|
- this.updateVipGroupStudentNumAndStatus(vipGroup.getId(),classGroup,1,false);
|
|
|
-
|
|
|
- ClassGroupStudentMapper classGroupStudentMapper = classGroupStudentMapperDao.query(classGroup.getId(),user.getId());
|
|
|
- if(Objects.isNull(classGroupStudentMapper)){
|
|
|
- classGroupStudentMapper=new ClassGroupStudentMapper(classGroup.getId(),user.getId().intValue());
|
|
|
- classGroupStudentMapper.setGroupType(GroupType.VIP);
|
|
|
- classGroupStudentMapper.setMusicGroupId(vipGroup.getId().toString());
|
|
|
- classGroupStudentMapperDao.insert(classGroupStudentMapper);
|
|
|
- }else{
|
|
|
- classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
- }
|
|
|
- }
|
|
|
+ //增加学员数
|
|
|
+ classGroup.setStudentNum(classGroup.getStudentNum() + 1);
|
|
|
+ classGroupDao.update(classGroup);
|
|
|
|
|
|
List<CourseSchedule> courseSchedules = JSON.parseArray(vipGroup.getCourseSchedulesJson(),CourseSchedule.class);
|
|
|
courseScheduleService.checkNewCourseSchedules(courseSchedules,false,false);
|
|
@@ -2477,80 +2730,76 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
@Override
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
- public void orderCallback(StudentPaymentOrder order) {
|
|
|
- /*
|
|
|
- 根据回调信息调整订单状态及vip课程状态等相关信息
|
|
|
- */
|
|
|
- Long vipGroupId = Long.parseLong(order.getMusicGroupId());
|
|
|
- Integer userId = order.getUserId();
|
|
|
- boolean isOk = order.getStatus().equals(DealStatusEnum.SUCCESS);
|
|
|
-
|
|
|
- StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.lockOrder(order.getId());
|
|
|
-
|
|
|
- List<StudentPaymentOrder> userOrders = studentPaymentOrderDao.findUserBuyVipGroupOrder(userId, vipGroupId.intValue());
|
|
|
- Map<DealStatusEnum, List<StudentPaymentOrder>> statusOrdersMap = userOrders.stream().collect(Collectors.groupingBy(StudentPaymentOrder::getStatus));
|
|
|
- if(!CollectionUtils.isEmpty(statusOrdersMap.get(DealStatusEnum.SUCCESS))){
|
|
|
- studentPaymentOrderDao.update(order);
|
|
|
+ public void orderCallback(StudentPaymentOrder studentPaymentOrder) {
|
|
|
+ Integer userId = studentPaymentOrder.getUserId();
|
|
|
+ StudentPaymentOrder order = studentPaymentOrderDao.lockOrder(studentPaymentOrder.getId());
|
|
|
+ if(!order.getStatus().equals(DealStatusEnum.ING)){
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- if(!studentPaymentOrder.getStatus().equals(DealStatusEnum.ING)){
|
|
|
- return;
|
|
|
+ //更新订单状态
|
|
|
+ int updateCount = studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
+ if (updateCount <= 0) {
|
|
|
+ throw new BizException("订单更新失败");
|
|
|
}
|
|
|
- studentPaymentOrderDao.update(order);
|
|
|
-
|
|
|
+ Date date = new Date();
|
|
|
ClassGroup classGroup = classGroupDao.get(order.getClassGroupId());
|
|
|
+ if(studentPaymentOrder.getStatus() == DealStatusEnum.SUCCESS){
|
|
|
+ VipGroup vipGroup = vipGroupDao.get(Long.parseLong(classGroup.getMusicGroupId()));
|
|
|
+ //活动赠送
|
|
|
+ Integer activityUserMapperId = studentPaymentOrderService.activityGive(vipGroup.getVipGroupActivityId(),studentPaymentOrder,
|
|
|
+ vipGroup.getId(),null,vipGroup.getUserId());
|
|
|
|
|
|
- //将学生加入到班级,更新班级报名状态及人数信息
|
|
|
- if(!isOk){
|
|
|
- if(CollectionUtils.isEmpty(statusOrdersMap.get(DealStatusEnum.ING)) || (!CollectionUtils.isEmpty(statusOrdersMap.get(DealStatusEnum.ING)) && statusOrdersMap.get(DealStatusEnum.ING).size() <= 1)){
|
|
|
- updateVipGroupStudentNumAndStatus(vipGroupId,classGroup,-1,false);
|
|
|
- classGroupStudentMapperDao.deleteClassGroupStudent(classGroup.getId().longValue(),userId);
|
|
|
- }
|
|
|
- if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().doubleValue() > 0) {
|
|
|
- sysUserCashAccountService.updateBalance(userId, studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS,
|
|
|
- "VIP课购买失败");
|
|
|
- }
|
|
|
- sysCouponCodeService.quit(order.getCouponCodeId());
|
|
|
- return;
|
|
|
- }
|
|
|
- VipGroup vipGroup = vipGroupDao.get(vipGroupId);
|
|
|
- try {
|
|
|
- Integer activityUserMapperId = studentPaymentOrderService.activityGive(vipGroup.getVipGroupActivityId(),
|
|
|
- userId,
|
|
|
- studentPaymentOrder.getId(),
|
|
|
- vipGroupId,
|
|
|
- null,studentPaymentOrder.getActivityBuyNum(),studentPaymentOrder.getOrganId(),vipGroup.getUserId());
|
|
|
- classGroup.setStudentNum(classGroup.getStudentNum() + 1);
|
|
|
- if(classGroup.getStudentNum().equals(classGroup.getExpectStudentNum()) && classGroup.getDelFlag() == 1){
|
|
|
+ //生成班级学员关联
|
|
|
+ ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
|
+ classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
|
|
|
+ classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
|
+ classGroupStudentMapper.setUserId(userId);
|
|
|
+ classGroupStudentMapper.setCreateTime(date);
|
|
|
+ classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
+ classGroupStudentMapper.setGroupType(GroupType.VIP);
|
|
|
+ classGroupStudentMapperDao.insert(classGroupStudentMapper);
|
|
|
+
|
|
|
+ //课程组人数已满,变更状态
|
|
|
+ if(classGroup.getStudentNum().equals(classGroup.getExpectStudentNum())){
|
|
|
+ vipGroup.setStatus(VipGroupStatusEnum.PROGRESS);
|
|
|
classGroup.setDelFlag(0);
|
|
|
+ //生成课表
|
|
|
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(vipGroupId.intValue(),"VIP");
|
|
|
- if(courseNum == 0){
|
|
|
- courseScheduleService.checkNewCourseSchedules(courseSchedules, false,false);
|
|
|
- courseScheduleService.batchAddCourseSchedule(courseSchedules);
|
|
|
- ClassGroupTeacherSalary classGroupTeacherSalary = classGroupTeacherSalaryDao.findByVipGoupAndTeacher(vipGroupId.intValue(), vipGroup.getUserId());
|
|
|
- //创建老师单节课课酬信息
|
|
|
- courseScheduleTeacherSalaryService.createCourseScheduleTeacherVipSalary(vipGroup,
|
|
|
- courseSchedules,
|
|
|
- classGroupTeacherSalary.getSalary());
|
|
|
+ //创建课酬信息
|
|
|
+ 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);
|
|
|
}
|
|
|
-
|
|
|
- List<ClassGroupStudentMapper> classGroupStudents = classGroupStudentMapperDao.findByClassGroup(classGroup.getId());
|
|
|
- Map<Integer,BigDecimal> courseAmountMap = MapUtil.convertIntegerMap(studentPaymentOrderDao.queryStudentCourseAmountMap(vipGroupId));
|
|
|
- VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice = vipGroupDefaultClassesUnitPriceDao.getByVipGroupCategory(vipGroup.getVipGroupCategoryId(), vipGroup.getOrganId());
|
|
|
- List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
|
|
|
-
|
|
|
- Map<Integer,String> userRoleMap = new HashMap<Integer, String>();
|
|
|
+ //群聊数据
|
|
|
+ Map<Integer,String> userRoleMap = new HashMap<Integer, String>(5);
|
|
|
if(Objects.nonNull(vipGroup.getEducationalTeacherId())){
|
|
|
userRoleMap.put(vipGroup.getEducationalTeacherId(),"乐团主管");
|
|
|
}
|
|
|
userRoleMap.put(vipGroup.getUserId(),"指导老师");
|
|
|
- for (ClassGroupStudentMapper classGroupStudent : classGroupStudents) {
|
|
|
+ //生成课程学员关联
|
|
|
+ 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");
|
|
|
//实际支付金额,去除优惠券
|
|
|
- BigDecimal actualPrice = courseAmountMap.get(classGroupStudent.getUserId());
|
|
|
+ BigDecimal actualPrice = successOrder.getExpectAmount().subtract(successOrder.getCouponRemitFee());
|
|
|
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++) {
|
|
@@ -2570,22 +2819,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
courseScheduleStudentPayment.setActualPrice(courseScheduleStudentPayment.getExpectPrice());
|
|
|
courseScheduleStudentPayments.add(courseScheduleStudentPayment);
|
|
|
}
|
|
|
- studentDao.updateStudentServiceTag(classGroupStudent.getUserId(), null, YesOrNoEnum.YES.getCode());
|
|
|
userRoleMap.put(classGroupStudent.getUserId(),null);
|
|
|
}
|
|
|
+ studentDao.updateStudentServiceTag(null, studentIdList, YesOrNoEnum.YES.getCode());
|
|
|
+ courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaries);
|
|
|
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());
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- LOGGER.error("小课[{}]开课失败:{}",vipGroupId,e.getCause());
|
|
|
- }
|
|
|
- classGroupDao.update(classGroup);
|
|
|
- SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(userId);
|
|
|
-
|
|
|
- //插入缴费明细
|
|
|
- //收入
|
|
|
- if(Objects.nonNull(order.getActualAmount()) && order.getActualAmount().compareTo(BigDecimal.ZERO)!=0){
|
|
|
+ SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(userId);
|
|
|
+ //插入缴费明细
|
|
|
+ //收入
|
|
|
SysUserCashAccountDetail sysUserIncomeCashAccountDetail = new SysUserCashAccountDetail();
|
|
|
sysUserIncomeCashAccountDetail.setUserId(userId);
|
|
|
sysUserIncomeCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
|
|
@@ -2615,28 +2859,33 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
sysUserCashAccountDetailService.insert(sysUserIncomeCashAccountDetail);
|
|
|
sysUserCashAccountDetailService.insert(sysUserExpendCashAccountDetail);
|
|
|
- }
|
|
|
- Map<Integer,String> map = new HashMap<>(1);
|
|
|
- map.put(userId,userId.toString());
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_VIP_BUY, map, null, 0, "2","STUDENT",
|
|
|
- vipGroup.getName());
|
|
|
-
|
|
|
- //更新所属分部列表
|
|
|
- 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);
|
|
|
- if(classGroup.getDelFlag()==0 && classGroup.getExpectStudentNum().equals(classGroup.getStudentNum())){
|
|
|
- vipGroup.setStatus(VipGroupStatusEnum.PROGRESS);
|
|
|
- }
|
|
|
- vipGroupDao.update(vipGroup);
|
|
|
|
|
|
- try {
|
|
|
- contractService.transferVipGroupCoursesContract(userId,vipGroupId);
|
|
|
- } catch (Exception e) {
|
|
|
- LOGGER.error(MessageFormatter.arrayFormat("小课[{}]购买协议错误:{}", vipGroupId, e.getMessage()), e);
|
|
|
+ Map<Integer,String> map = new HashMap<>(1);
|
|
|
+ map.put(userId,userId.toString());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_VIP_BUY, map, null, 0, "2","STUDENT",
|
|
|
+ vipGroup.getName());
|
|
|
+
|
|
|
+ //更新所属分部列表
|
|
|
+ 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);
|
|
|
+ try {
|
|
|
+ contractService.transferVipGroupCoursesContract(userId,vipGroup.getId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOGGER.error(MessageFormatter.arrayFormat("小课[{}]购买协议错误:{}", vipGroup.getId(), e.getMessage()), e);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ classGroup.setStudentNum(classGroup.getStudentNum() - 1);
|
|
|
+ if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().doubleValue() > 0) {
|
|
|
+ sysUserCashAccountService.updateBalance(userId, studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS,
|
|
|
+ "VIP课购买失败");
|
|
|
+ }
|
|
|
+ sysCouponCodeService.quit(order.getCouponCodeId());
|
|
|
}
|
|
|
+ classGroupDao.update(classGroup);
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -3897,22 +4146,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
onlineCourseTotalTimes=0,
|
|
|
offlineCourseTotalTimes=0,
|
|
|
giveClassTimes=0;
|
|
|
-// if(vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING) && Objects.nonNull(vipGroupActivity)
|
|
|
-// && vipGroupActivity.getType().equals(VipGroupActivityTypeEnum.GIVE_CLASS)
|
|
|
-// &&surplusCourses.size()>=Integer.parseInt(vipGroupActivity.getAttribute1())){
|
|
|
-// hasGiveClass=true;
|
|
|
-// giveClassTimes=Integer.parseInt(vipGroupActivity.getAttribute2());
|
|
|
-// Map<TeachModeEnum, List<CourseSchedule>> teachModeCourseMap = surplusCourses.stream()
|
|
|
-// .collect(Collectors.groupingBy(CourseSchedule::getTeachMode));
|
|
|
-// List<CourseSchedule> onlineCourses=teachModeCourseMap.get(TeachModeEnum.ONLINE);
|
|
|
-// if(!CollectionUtils.isEmpty(onlineCourses)){
|
|
|
-// onlineCourseTotalTimes=onlineCourses.size();
|
|
|
-// }
|
|
|
-// List<CourseSchedule> offlineCourses=teachModeCourseMap.get(TeachModeEnum.OFFLINE);
|
|
|
-// if(!CollectionUtils.isEmpty(offlineCourses)){
|
|
|
-// offlineCourseTotalTimes=offlineCourses.size();
|
|
|
-// }
|
|
|
-// }
|
|
|
|
|
|
//生成学生单课缴费信息
|
|
|
for (Integer studentId:studentIds) {
|