|
@@ -33,6 +33,7 @@ import com.yonge.toolset.base.exception.BizException;
|
|
|
import com.yonge.toolset.base.page.PageInfo;
|
|
|
import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.yonge.toolset.utils.date.DateUtil;
|
|
|
+import com.yonge.toolset.utils.obj.ObjectUtil;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.redisson.api.RMap;
|
|
@@ -53,6 +54,8 @@ import java.util.function.BiFunction;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import static com.yonge.cooleshow.biz.dal.support.WrapperUtil.inInterSection;
|
|
|
+
|
|
|
/**
|
|
|
* 老师课程表(CourseSchedule)表服务实现类
|
|
|
*
|
|
@@ -881,11 +884,11 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
if (dateList.size() != courseNum) {
|
|
|
throw new BizException("课程数与课时数不符");
|
|
|
}
|
|
|
- BigDecimal price=baseMapper.selectPrice(scheduleDto.getTeacherId(), scheduleDto.getSubjectId());//老师设置声部价格
|
|
|
+ BigDecimal price = baseMapper.selectPrice(scheduleDto.getTeacherId(), scheduleDto.getSubjectId());//老师设置声部价格
|
|
|
BigDecimal decimal = new BigDecimal(courseNum);//选购课程节数
|
|
|
BigDecimal multiply = price.multiply(decimal);//预计总价
|
|
|
- if (multiply.compareTo(scheduleDto.getCoursePrice())!=0){
|
|
|
- throw new BizException("价格异常。预计价格:{},实际价格:{}",multiply,scheduleDto.getCoursePrice());
|
|
|
+ if (multiply.compareTo(scheduleDto.getCoursePrice()) != 0) {
|
|
|
+ throw new BizException("价格异常。预计价格:{},实际价格:{}", multiply, scheduleDto.getCoursePrice());
|
|
|
}
|
|
|
|
|
|
//批量检查老师课时在数据库是否重复
|
|
@@ -1039,7 +1042,52 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
* @Date: 2022/4/21
|
|
|
*/
|
|
|
@Override
|
|
|
- public void courseAdjust(CourseAdjustVo adjustVo) {
|
|
|
+ public void courseAdjust(CourseAdjustVo adjustVo, Long teacherId) {
|
|
|
+ Integer courseId = adjustVo.getCourseId();
|
|
|
+ Date classDate = adjustVo.getClassDate();
|
|
|
+ Date startTime = adjustVo.getStartTime();
|
|
|
+ Date endTime = adjustVo.getEndTime();
|
|
|
+ Date now = new Date();
|
|
|
+ //校验时间是否为未来时刻
|
|
|
+ if (classDate.before(now) || startTime.before(now) || endTime.before(now)) {
|
|
|
+ throw new BizException("时间不正确");
|
|
|
+ }
|
|
|
+
|
|
|
+ //校验课程是否存在
|
|
|
+ CourseSchedule schedule = baseMapper.selectOne(Wrappers.<CourseSchedule>lambdaQuery()
|
|
|
+ .eq(CourseSchedule::getId, courseId)
|
|
|
+ .eq(CourseSchedule::getLock, 1)
|
|
|
+ .eq(CourseSchedule::getStatus, CourseScheduleEnum.NOT_START)
|
|
|
+ .eq(CourseSchedule::getType, CourseScheduleEnum.PRACTICE));
|
|
|
+ if (ObjectUtil.isEmpty(schedule)) {
|
|
|
+ throw new BizException("课程不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询是否有人购买
|
|
|
+ CourseScheduleStudentPayment studentPayment = paymentDao.selectOne(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
|
|
|
+ .eq(CourseScheduleStudentPayment::getCourseId, courseId)
|
|
|
+ .eq(CourseScheduleStudentPayment::getCourseType, CourseScheduleEnum.PRACTICE));
|
|
|
+ if (ObjectUtil.isEmpty(studentPayment)) {
|
|
|
+ throw new BizException("课程无人购买");
|
|
|
+ }
|
|
|
+
|
|
|
+ //批量检查老师课时在数据库是否重复
|
|
|
+ List<CourseSchedule> scheduleList = this.list(Wrappers.<CourseSchedule>lambdaQuery()
|
|
|
+ .eq(CourseSchedule::getTeacherId, teacherId)
|
|
|
+ .in(CourseSchedule::getStatus, Lists.newArrayList(CourseScheduleEnum.NOT_START.getCode(), CourseScheduleEnum.ING.getCode())));
|
|
|
+ for (CourseSchedule courseSchedule : scheduleList) {
|
|
|
+ if (inInterSection(startTime, endTime, courseSchedule.getStartTime(), courseSchedule.getEndTime(), true)) {
|
|
|
+ throw new BizException("老师排课冲突,课程id:{}", courseSchedule.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //批量检查学生课时在数据库是否重复
|
|
|
+ List<CourseSchedule> studentList = baseMapper.selectSchedule(courseId);
|
|
|
+ for (CourseSchedule courseSchedule : studentList) {
|
|
|
+ if (inInterSection(startTime, endTime, courseSchedule.getStartTime(), courseSchedule.getEndTime(), true)) {
|
|
|
+ throw new BizException("学生排课冲突,课程id:{}", courseSchedule.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
baseMapper.courseAdjust(adjustVo);
|
|
|
}
|
|
|
|