|
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
|
|
+import com.ym.mec.auth.api.entity.SysUserRole;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.dto.*;
|
|
import com.ym.mec.biz.dal.dto.*;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
@@ -4309,13 +4310,239 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
//课程购买费用计算
|
|
//课程购买费用计算
|
|
|
BigDecimal totalPrice = onlineVipGroupCharge.add(onlineVipGroupCharge);
|
|
BigDecimal totalPrice = onlineVipGroupCharge.add(onlineVipGroupCharge);
|
|
|
totalPrice = totalPrice.multiply(vipGroupActivity.getDiscount()).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
totalPrice = totalPrice.multiply(vipGroupActivity.getDiscount()).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
|
|
|
- results.put("totalPrice",totalPrice.setScale(0,BigDecimal.ROUND_CEILING));
|
|
|
|
|
|
|
+ results.put("onlineTeacherSalary",totalPrice.setScale(0,BigDecimal.ROUND_CEILING));
|
|
|
return results;
|
|
return results;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Object createPracticeGroup(PracticeGroupApplyDto practiceGroupApplyDto) {
|
|
|
|
|
|
|
+ public Object createPracticeGroup(PracticeGroupApplyDto practice) {
|
|
|
|
|
+ PracticeGroupApplyBaseInfoDto applyBaseInfoDto = practice.getPracticeGroupApplyBaseInfoDto();
|
|
|
|
|
+ if (Objects.isNull(applyBaseInfoDto.getUserId())){
|
|
|
|
|
+ throw new BizException("请选择指导老师");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<CourseSchedule> courseSchedules = practice.getCourseSchedules();
|
|
|
|
|
+ if(courseSchedules.size() != applyBaseInfoDto.getAllCourseNum()){
|
|
|
|
|
+ throw new BizException("建课失败,当前课程存在未排课课程,请调整相关设置");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Integer studentId = applyBaseInfoDto.getStudentId();
|
|
|
|
|
+
|
|
|
|
|
+ Date now = new Date();
|
|
|
|
|
+
|
|
|
|
|
+ if(studentId == null){
|
|
|
|
|
+ throw new BizException("请选择学员");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Integer totalClassTimes = applyBaseInfoDto.getAllCourseNum();
|
|
|
|
|
+ //获取第一节课
|
|
|
|
|
+ CourseSchedule firstCourseSchedule = courseSchedules.stream().min(Comparator.comparing(CourseSchedule::getStartClassTime)).get();
|
|
|
|
|
+ //获取最后一节课
|
|
|
|
|
+ CourseSchedule latestCourseSchedule = courseSchedules.stream().max(Comparator.comparing(CourseSchedule::getEndClassTime)).get();
|
|
|
|
|
+
|
|
|
|
|
+ if(firstCourseSchedule.getStartClassTime().before(now)){
|
|
|
|
|
+ throw new BizException("开课时间不能小于当前时间");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(applyBaseInfoDto.getRegistrationStartTime().after(applyBaseInfoDto.getPaymentExpireDate())){
|
|
|
|
|
+ throw new BizException("报名开始时间必须在报名截至时间之前");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(applyBaseInfoDto.getPaymentExpireDate().after(firstCourseSchedule.getStartClassTime())
|
|
|
|
|
+ ||DateUtil.isSameDay(applyBaseInfoDto.getPaymentExpireDate(),firstCourseSchedule.getEndClassTime())){
|
|
|
|
|
+ throw new BizException("创建失败,报名截止时间必须在开课时间前一天");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<VipGroupStudentCoursePrice> vscps = applyBaseInfoDto.getVipGroupStudentCoursePrices();
|
|
|
|
|
+
|
|
|
|
|
+ SysUser user = teacherDao.getUser(studentId);
|
|
|
|
|
+ String userName = StringUtils.isEmpty(user.getUsername()) ? user.getRealName() : user.getUsername();
|
|
|
|
|
+ //获取活动信息
|
|
|
|
|
+ VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(applyBaseInfoDto.getVipGroupActivityId());
|
|
|
|
|
+ if(Objects.nonNull(vipGroupActivity) && !practice.getAllowOverstepActivityStudentNum() &&
|
|
|
|
|
+ Objects.nonNull(vipGroupActivity.getStudentMaxUsedTimes())&&vipGroupActivity.getStudentMaxUsedTimes() != -1){
|
|
|
|
|
+ int useNum = practiceGroupDao.countStudentUserActivityNum(applyBaseInfoDto.getVipGroupActivityId(), studentId);
|
|
|
|
|
+ if(useNum >= vipGroupActivity.getStudentMaxUsedTimes()){
|
|
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
|
|
+ return BaseController.failed(HttpStatus.PARTIAL_CONTENT,"该活动 "+userName+" 学员创建及成课之和已达上限,是否继续创建该课程?");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //判断课程安排是否超出范围
|
|
|
|
|
+ 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("课时安排时间超出范围!");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(Objects.nonNull(vipGroupActivity)&&Objects.nonNull(vipGroupActivity.getMinCourseNum())&&vipGroupActivity.getMinCourseNum()!=-1&&Objects.nonNull(vipGroupActivity.getMaxCourseNum())&&vipGroupActivity.getMaxCourseNum()!=-1){
|
|
|
|
|
+ if(totalClassTimes.compareTo(vipGroupActivity.getMinCourseNum())<0||totalClassTimes.compareTo(vipGroupActivity.getMaxCourseNum())>0){
|
|
|
|
|
+ throw new BizException("该活动课时数为{}节~{}节", vipGroupActivity.getMinCourseNum(), vipGroupActivity.getMaxCourseNum());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int repeatVipGroups = practiceGroupDao.countUserRepeatPracticeGroupInCourseStartEndTime(studentId, firstCourseSchedule.getStartClassTime(), latestCourseSchedule.getEndClassTime());
|
|
|
|
|
+ if(repeatVipGroups>0){
|
|
|
|
|
+ throw new BizException("请勿重复提交");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //生成网管课信息
|
|
|
|
|
+ List<String> bySubIds = subjectDao.findBySubIds(applyBaseInfoDto.getSubjectIdList());
|
|
|
|
|
+ StringBuffer className = new StringBuffer(StringUtils.join(bySubIds,","));
|
|
|
|
|
+ className.append("•").append(userName);
|
|
|
|
|
+ applyBaseInfoDto.setName(className.toString());
|
|
|
|
|
+
|
|
|
|
|
+ //计算课程相关费用信息
|
|
|
|
|
+ Map<String, BigDecimal> costInfo = countPracticeGroupPredictFee(applyBaseInfoDto,studentId, null);
|
|
|
|
|
+
|
|
|
|
|
+ applyBaseInfoDto.setAuditStatus(AuditStatusEnum.PASS);
|
|
|
|
|
+
|
|
|
|
|
+ //如果默认课酬与实际课酬不匹配则需要审批
|
|
|
|
|
+ if(costInfo.get("onlineTeacherSalary").compareTo(applyBaseInfoDto.getOnlineTeacherSalary()) < 0){
|
|
|
|
|
+ applyBaseInfoDto.setAuditStatus(AuditStatusEnum.ING);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ applyBaseInfoDto.setOnlineTeacherSalary(costInfo.get("onlineTeacherSalary"));
|
|
|
|
|
+ applyBaseInfoDto.setGroupStatus(GroupStatusEnum.APPLYING);
|
|
|
|
|
+// if(CollectionUtils.isEmpty(vscps)){
|
|
|
|
|
+// vscps = new ArrayList<>();
|
|
|
|
|
+// vscps.add(new VipGroupStudentCoursePrice(studentId, applyBaseInfoDto.getOfflineClassesUnitPrice(),
|
|
|
|
|
+// vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice(), vipGroupApplyBaseInfoDto.getTotalPrice()));
|
|
|
|
|
+// }
|
|
|
|
|
+ Teacher teacher = teacherService.get(applyBaseInfoDto.getUserId());
|
|
|
|
|
+ if(Objects.isNull(teacher)){
|
|
|
|
|
+ throw new BizException("教师不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(Objects.isNull(teacher.getTeacherOrganId())){
|
|
|
|
|
+ throw new BizException("教师部门异常");
|
|
|
|
|
+ }
|
|
|
return null;
|
|
return null;
|
|
|
|
|
+// vipGroupApplyBaseInfoDto.setOrganId(Integer.parseInt(teacher.getOrganId()));
|
|
|
|
|
+ //开课时间为排课的第一节课的开始时间
|
|
|
|
|
+// vipGroupApplyBaseInfoDto.setCourseStartDate(firstCourseSchedule.getStartClassTime());
|
|
|
|
|
+// //课程结束时间为排课的最后一节课的结束时间
|
|
|
|
|
+// vipGroupApplyBaseInfoDto.setCoursesExpireDate(latestCourseSchedule.getEndClassTime());
|
|
|
|
|
+//
|
|
|
|
|
+// vipGroupApplyBaseInfoDto.setPaymentExpireDate(DateUtil.getLastSecondWithDay(vipGroupApplyBaseInfoDto.getPaymentExpireDate()));
|
|
|
|
|
+//
|
|
|
|
|
+// VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice = vipGroupDefaultClassesUnitPriceDao.getByVipGroupCategory(vipGroup.getVipGroupApplyBaseInfo().getVipGroupCategoryId(), vipGroup.getVipGroupApplyBaseInfo().getOrganId());
|
|
|
|
|
+//
|
|
|
|
|
+// if(Objects.isNull(vipGroupDefaultClassesUnitPrice)){
|
|
|
|
|
+// vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.ING);
|
|
|
|
|
+// }else{
|
|
|
|
|
+// if(Objects.nonNull(vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice())
|
|
|
|
|
+// &&vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice().compareTo(vipGroupDefaultClassesUnitPrice.getOfflineClassesUnitPrice())!=0){
|
|
|
|
|
+// vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.ING);
|
|
|
|
|
+// }
|
|
|
|
|
+// if(Objects.nonNull(vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice())
|
|
|
|
|
+// &&vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice().compareTo(vipGroupDefaultClassesUnitPrice.getOnlineClassesUnitPrice())!=0){
|
|
|
|
|
+// vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.ING);
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// if(StringUtils.isBlank(vipGroupApplyBaseInfoDto.getStudentIdList())){
|
|
|
|
|
+// vipGroupApplyBaseInfoDto.setStudentIdList(StringUtils.join(vscps.stream().map(VipGroupStudentCoursePrice::getStudentId).collect(Collectors.toList()), ","));
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// 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());
|
|
|
|
|
+// classGroup.setExpectStudentNum(vipGroupCategory.getStudentNum());
|
|
|
|
|
+// if(StringUtils.isNotBlank(studentIds)){
|
|
|
|
|
+// classGroup.setStudentNum(studentIdList.size());
|
|
|
|
|
+// }
|
|
|
|
|
+// classGroup.setName(vipGroupApplyBaseInfoDto.getName());
|
|
|
|
|
+// classGroup.setExpectStudentNum(vipGroupApplyBaseInfoDto.getStudentNum());
|
|
|
|
|
+// 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.getOnlineTeacherSalary());
|
|
|
|
|
+// classGroupTeacherSalary.setGroupType(GroupType.VIP);
|
|
|
|
|
+// classGroupTeacherSalary.setCreateTime(now);
|
|
|
|
|
+// classGroupTeacherSalary.setUpdateTime(now);
|
|
|
|
|
+// classGroupTeacherSalaryDao.insert(classGroupTeacherSalary);
|
|
|
|
|
+//
|
|
|
|
|
+// //课程信息调整
|
|
|
|
|
+// vipGroup.getCourseSchedules().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(vipGroup.getCourseSchedules(),false,false);
|
|
|
|
|
+// vipGroupApplyBaseInfoDto.setCourseSchedulesJson(JSON.toJSONString(vipGroup.getCourseSchedules()));
|
|
|
|
|
+// vipGroupDao.update(vipGroupApplyBaseInfoDto);
|
|
|
|
|
+//
|
|
|
|
|
+// if(StringUtils.isNotBlank(studentIds)){
|
|
|
|
|
+// List<Integer> collect = studentIdList.stream().mapToInt(Integer::parseInt).boxed().collect(Collectors.toList());
|
|
|
|
|
+// classGroupService.addStudentIntoClassGroup(vipGroupApplyBaseInfoDto.getId().toString(),classGroup.getId(),collect);
|
|
|
|
|
+// createVipGroupCourseScheInfo(vipGroupApplyBaseInfoDto.getId(),classGroup);
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// 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());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|