|
@@ -1,5 +1,12 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
+import com.ym.mec.biz.dal.dao.SubjectDao;
|
|
|
+import com.ym.mec.biz.dal.entity.Subject;
|
|
|
+import com.ym.mec.biz.dal.entity.SysConfig;
|
|
|
+import com.ym.mec.biz.service.PracticeGroupService;
|
|
|
+import com.ym.mec.biz.service.SysConfigService;
|
|
|
+import com.ym.mec.common.exception.BizException;
|
|
|
+import com.ym.mec.util.date.DateUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -8,15 +15,52 @@ import com.ym.mec.biz.dal.entity.PracticeGroup;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
@Service
|
|
|
-public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGroup>{
|
|
|
+public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGroup> implements PracticeGroupService {
|
|
|
|
|
|
@Autowired
|
|
|
private PracticeGroupDao practiceGroupDao;
|
|
|
+ @Autowired
|
|
|
+ private SysConfigService sysConfigService;
|
|
|
+ @Autowired
|
|
|
+ private SubjectDao subjectDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, PracticeGroup> getDAO() {
|
|
|
return practiceGroupDao;
|
|
|
}
|
|
|
-
|
|
|
-}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map getPracticeApplyParams() {
|
|
|
+ Map result=new HashMap();
|
|
|
+ SysConfig practiceSubjectIdListConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_SUBJECT_ID_LIST);
|
|
|
+ SysConfig practiceApplyStartTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_START_TIME);
|
|
|
+ SysConfig practiceApplyEndTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_END_TIME);
|
|
|
+ List<Subject> subjects = subjectDao.findBySubjectByIdList(practiceSubjectIdListConfig.getParanValue());
|
|
|
+ result.put("subjects", subjects);
|
|
|
+ result.put("practiceApplyStartTime",practiceApplyStartTimeConfig.getParanValue());
|
|
|
+ result.put("practiceApplyEndTime",practiceApplyEndTimeConfig.getParanValue());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map practiceApply(PracticeGroup practiceGroup) {
|
|
|
+ Integer practiceCourseMinutes=25;
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ if(Objects.nonNull(practiceCourseMinutesConfig)){
|
|
|
+ practiceCourseMinutes=practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
+ }
|
|
|
+ Date now=new Date();
|
|
|
+ Date nextWeekMonday = DateUtil.getNextWeekMonday(now);
|
|
|
+ Date nextWeekFriday = DateUtil.getNextWeekDay(now,11);
|
|
|
+ if(practiceGroup.getCoursesStartDate().before(nextWeekMonday)
|
|
|
+ ||(practiceGroup.getCoursesStartDate().after(nextWeekFriday)
|
|
|
+ &&!DateUtil.isSameDay(practiceGroup.getCoursesStartDate(),nextWeekFriday))){
|
|
|
+ throw new BizException("预约时间超过范围");
|
|
|
+ }
|
|
|
+ practiceGroup.setCoursesExpireDate(DateUtil.addMinutes(practiceGroup.getCoursesStartDate(),practiceCourseMinutes));
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|