|
@@ -13,6 +13,8 @@ import com.ym.mec.util.date.DateUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
@@ -67,10 +69,12 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
result.put("subjects", subjects);
|
|
|
result.put("practiceApplyStartTime",practiceApplyStartTimeConfig.getParanValue());
|
|
|
result.put("practiceApplyEndTime",practiceApplyEndTimeConfig.getParanValue());
|
|
|
+ result.put("userDefaultSubjectIds",null);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Map practiceApply(PracticeGroup practiceGroup) {
|
|
|
Integer practiceCourseMinutes=25;
|
|
|
SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
@@ -86,7 +90,18 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
&&!DateUtil.isSameDay(practiceGroup.getCoursesStartDate(),nextWeekFriday))){
|
|
|
throw new BizException("预约时间超过范围");
|
|
|
}
|
|
|
- practiceGroup.setCoursesExpireDate(DateUtil.addMinutes(practiceGroup.getCoursesStartDate(),practiceCourseMinutes));
|
|
|
+
|
|
|
+ Integer applyTimes=0;
|
|
|
+ List<PracticeGroup> userPracticeCoursesWithDateRange = practiceGroupDao.getUserPracticeCoursesWithDateRange(practiceGroup.getUserId(), nextWeekMonday, nextWeekFriday);
|
|
|
+ if(!CollectionUtils.isEmpty(userPracticeCoursesWithDateRange)){
|
|
|
+ applyTimes=userPracticeCoursesWithDateRange.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ if(applyTimes>=2){
|
|
|
+ throw new BizException("您的预约次数已经达到限制");
|
|
|
+ }
|
|
|
+
|
|
|
+ practiceGroup.setCoursesExpireDate(DateUtil.addMinutes(practiceGroup.getCoursesStartDate(),practiceCourseMinutes));
|
|
|
Integer teacherId = searchTeacherId(practiceGroup.getUserId(),practiceGroup.getSubjectId(),practiceGroup.getCoursesStartDate(),practiceGroup.getCoursesExpireDate());
|
|
|
if(Objects.isNull(teacherId)){
|
|
|
throw new BizException("教师指派错误");
|
|
@@ -199,6 +214,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
|
|
|
Map result=new HashMap();
|
|
|
result.put("teacherName",teacher.getRealName());
|
|
|
+ result.put("enableApply",applyTimes<2?1:0);
|
|
|
return result;
|
|
|
}
|
|
|
}
|