浏览代码

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

zouxuan 5 年之前
父节点
当前提交
c10a11a357

+ 61 - 22
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -215,7 +215,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             LocalDateTime applyExpireDateTime=LocalDateTime.parse("2020-03-01 00:00:00", DateUtil.dateTimeFormatter);
             result.put("canApply", now.compareTo(applyExpireDateTime)<=0?1:0);
         }else{
-            LocalDateTime applyExpireDateTime=LocalDateTime.parse("2020-02-22 08:00:00", DateUtil.dateTimeFormatter);
+            LocalDateTime applyExpireDateTime=LocalDateTime.parse("2020-02-22 20:00:00", DateUtil.dateTimeFormatter);
             result.put("canApply", now.compareTo(applyExpireDateTime)<=0?1:0);
         }
 
@@ -1654,7 +1654,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             }
         }else{
             LocalDateTime nowDateTime=LocalDateTime.now();
-            LocalDateTime applyExpireDateTime=LocalDateTime.parse("2020-02-22 08:00:00", DateUtil.dateTimeFormatter);
+            LocalDateTime applyExpireDateTime=LocalDateTime.parse("2020-02-22 20:00:00", DateUtil.dateTimeFormatter);
             if(nowDateTime.compareTo(applyExpireDateTime)>0){
                 result.put("status", "APPLY_DATE_OVERFLOW");
                 result.put("info", "预约失败,超出可预约时间范围。");
@@ -2399,7 +2399,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         Date secondSunday = DateUtil.getWeekDayWithDate(applyEndDate, Calendar.SUNDAY);
 
         Map<Integer, List<String>> weekNumApplyTimesMap = getEnableApplyDatesWithWeek();
-        List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeacherCoursesWithDateRange(teacherId, applyStartDate, secondSunday);
+        List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeacherCoursesWithDateRange(teacherId, firstMonday, secondSunday);
         allTeacherCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
 
         JSONObject teacherLeaveData = null;
@@ -2439,7 +2439,15 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         } else if (checkTeacherLeaveDate) {
             for (String dateStr : teacherLeaveData.keySet()) {
                 LocalDate parse = LocalDate.parse(dateStr, ddf);
+                Date tempDate = DateUtil.stringToDate(dateStr, "yyyy-MM-dd");
+                if (tempDate.compareTo(applyStartDate)<0
+                    ||tempDate.compareTo(applyEndDate)>=0){
+                    continue;
+                }
                 List<String> applyTimeStrs = weekNumApplyTimesMap.get(parse.getDayOfWeek().getValue());
+                if(CollectionUtils.isEmpty(applyTimeStrs)){
+                    continue;
+                }
                 Iterator<String> iterator = applyTimeStrs.iterator();
                 JSONObject leaveDateData = teacherLeaveData.getJSONObject(dateStr);
                 LocalTime leaveStartTime = LocalDateTime.parse(leaveDateData.getString("leave_start_time"), ddtf).toLocalTime();
@@ -2448,13 +2456,17 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
                 while (iterator.hasNext()) {
                     defaultApplyTime = LocalTime.parse(iterator.next(), dtf);
                     LocalTime defaultApplyEndTime = defaultApplyTime.plusMinutes(practiceCourseMinutes);
-                    if (defaultApplyTime.compareTo(leaveStartTime) <= 0
-                            && defaultApplyEndTime.compareTo(leaveEndTime) >= 0) {
+                    if (defaultApplyTime.compareTo(leaveEndTime) <= 0
+                            && defaultApplyEndTime.compareTo(leaveStartTime) >= 0) {
                         iterator.remove();
                         continue;
                     }
                 }
-                weekNumApplyTimesMap.put(parse.getDayOfWeek().getValue(), applyTimeStrs);
+                if(!CollectionUtils.isEmpty(applyTimeStrs)){
+                    weekNumApplyTimesMap.put(parse.getDayOfWeek().getValue(), applyTimeStrs);
+                }else{
+                    weekNumApplyTimesMap.remove(parse.getDayOfWeek().getValue());
+                }
             }
         }
 
@@ -2464,6 +2476,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             JSONArray teacherWeekDayFreeTimes = teacherFreeTimes.getJSONArray(String.valueOf(weekNum));
             if(Objects.nonNull(teacherWeekDayFreeTimes)){
                 List<String> applyTimeStrs = weekNumApplyTimesMap.get(weekNum);
+                if(CollectionUtils.isEmpty(applyTimeStrs)){
+                    continue;
+                }
                 Iterator<String> iterator = applyTimeStrs.iterator();
                 while (iterator.hasNext()) {
                     LocalTime enableApplyStartTime=LocalTime.parse(iterator.next(), dtf);
@@ -2483,7 +2498,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
                         iterator.remove();
                     }
                 }
-                weekNumApplyTimesMap.put(weekNum,applyTimeStrs);
+                if(CollectionUtils.isEmpty(applyTimeStrs)){
+                    weekNumApplyTimeIterator.remove();
+                }else{
+                    weekNumApplyTimesMap.put(weekNum,applyTimeStrs);
+                }
             }else{
                 weekNumApplyTimeIterator.remove();
             }
@@ -2496,35 +2515,55 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 
         int courseWeekNum = 0;
         int practiceCourseNum = 0;
-        Set<Integer> disableApplyWeek = new HashSet<>();
+        Set<Integer> disableApplyWeekNum = new HashSet<>();
         LocalDateTime tempClassDateTime;
         for (int i = 0; i < allTeacherCourses.size(); i++) {
             CourseSchedule teacherCourse = allTeacherCourses.get(i);
             tempClassDateTime = LocalDateTime.ofInstant(teacherCourse.getClassDate().toInstant(), zoneId);
-            if (i == 0 && teacherCourse.getGroupType().equals(GroupType.PRACTICE)) {
-                practiceCourseNum += 1;
-                courseWeekNum = tempClassDateTime.get(weekFields.weekOfYear());
-            }
-            if (Objects.nonNull(maxTeacherCourses) && practiceCourseNum >= maxTeacherCourses) {
-                disableApplyWeek.add(courseWeekNum);
-            }
             if (tempClassDateTime.get(weekFields.weekOfYear()) != courseWeekNum) {
                 courseWeekNum = tempClassDateTime.get(weekFields.weekOfYear());
                 practiceCourseNum = 0;
-            }
-            if (teacherCourse.getGroupType().equals(GroupType.PRACTICE)) {
+                practiceCourseNum = 1;
+            }else if(teacherCourse.getGroupType().equals(GroupType.PRACTICE)){
                 practiceCourseNum += 1;
             }
+            if (Objects.nonNull(maxTeacherCourses) && practiceCourseNum >= maxTeacherCourses) {
+                disableApplyWeekNum.add(courseWeekNum);
+            }
+        }
+
+        if(disableApplyWeekNum.size()>2){
+            result.put("teacherFreeDays", new HashMap<>());
+            return result;
+        }
+
+        LocalDateTime applyStartDateTime=LocalDateTime.ofInstant(applyStartDate.toInstant(), DateUtil.zoneId);
+        int applyStartDateWeekNum = applyStartDateTime.get(weekFields.weekOfYear());
+        LocalDateTime applyEndDateTime = LocalDateTime.ofInstant(applyEndDate.toInstant(), DateUtil.zoneId);
+        int applyEndDateWeekNum = applyEndDateTime.get(weekFields.weekOfYear());
+
+        if(!CollectionUtils.isEmpty(disableApplyWeekNum)&&!disableApplyWeekNum.contains(applyStartDateWeekNum)&&!disableApplyWeekNum.contains(applyEndDateWeekNum)){
+            result.put("teacherFreeDays", new HashMap<>());
+            return result;
+        }
+
+        if(disableApplyWeekNum.contains(applyStartDateWeekNum)){
+            LocalDateTime applyStartSunDay = applyStartDateTime.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.SUNDAY.getValue());
+            while (applyStartDateTime.compareTo(applyStartSunDay)<=0){
+                weekNumApplyTimesMap.remove(applyStartDateTime.getDayOfWeek().getValue());
+                applyStartDateTime=applyStartDateTime.plusDays(1);
+            }
         }
 
-        Iterator<Integer> weekNumApplyTimeIterator2 = weekNumApplyTimesMap.keySet().iterator();
-        while (weekNumApplyTimeIterator2.hasNext()) {
-            Integer weekNum=weekNumApplyTimeIterator2.next();
-            if(disableApplyWeek.contains(weekNum)){
-                weekNumApplyTimeIterator2.remove();
+        if(disableApplyWeekNum.contains(applyEndDateWeekNum)){
+            LocalDateTime applyEndMonDay = applyEndDateTime.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
+            while (applyEndMonDay.compareTo(applyEndDateTime)<0){
+                weekNumApplyTimesMap.remove(applyEndMonDay.getDayOfWeek().getValue());
+                applyEndMonDay = applyEndMonDay.plusDays(1);
             }
         }
 
+
         for (CourseSchedule teacherCourse : allTeacherCourses) {
             if(teacherCourse.getEndClassTime().before(applyStartDate)||teacherCourse.getStartClassTime().after(applyEndDate)){
                 continue;

+ 2 - 2
mec-biz/src/main/resources/config/contracts/practice.ftl

@@ -95,9 +95,9 @@
             </tr>
             <tr>
                 <td style="text-align: center;">网管课</td>
-                <td style="text-align: center;">${courseSectionNum}</td>
+                <td style="text-align: center;">${courseSectionNum}</td>
                 <td style="text-align: center;">${startDate?string("yyyy-MM-dd")}/${endDate?string("yyyy-MM-dd")}</td>
-                <td style="text-align: center;">${fee?string("0.00")}</td>
+                <td style="text-align: center;">${fee?string("0.00")}</td>
             </tr>
         </table>
         2.2 用户购课后,需在有效期内完成所购全部课程(以课程后台有效期为准)。除本协议另有约定外,若用户未能在课程有效期内上完课程,则课程自动结束,本公司不再提供课程。<br />

+ 2 - 2
mec-biz/src/main/resources/config/mybatis/TeacherDefaultPracticeGroupSalaryMapper.xml

@@ -75,12 +75,12 @@
 	</update>
 
 	<!-- 根据主键删除一条记录 -->
-	<delete id="delete">
+	<delete id="deleteByUserId">
 		DELETE FROM
 		teacher_default_practice_group_salary WHERE user_id_ = #{userId}
 	</delete>
 
-	<delete id="deleteByUserId">
+	<delete id="delete">
 		DELETE FROM teacher_default_practice_group_salary WHERE id_ = #{id}
 	</delete>
 	

+ 1 - 1
mec-biz/src/main/resources/config/mybatis/VipGroupMapper.xml

@@ -876,7 +876,7 @@
     </update>
     
     <select id="queryRequiredOverList" resultMap="VipGroup">
-    	select vg.* from vip_group vg left join class_group cg on vg.id_ = cg.music_group_id_
+    	select vg.* from vip_group vg left join class_group cg on vg.id_ = cg.music_group_id_ AND cg.group_type_='VIP'
     	where vg.group_status_ = 2 and cg.total_class_times_ = cg.current_class_times_ and cg.total_class_times_ &gt; 0
     </select>
     <select id="queryNormalStatusList" resultMap="VipGroup">

+ 7 - 13
mec-web/src/main/java/com/ym/mec/web/controller/TeacherDefaultPracticeGroupSalaryController.java

@@ -1,22 +1,16 @@
 package com.ym.mec.web.controller;
 
+import com.ym.mec.biz.dal.entity.TeacherDefaultPracticeGroupSalary;
+import com.ym.mec.biz.service.TeacherDefaultPracticeGroupSalaryService;
+import com.ym.mec.common.controller.BaseController;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-
-import java.util.Date;
-import java.util.List;
-
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
-import com.ym.mec.biz.dal.entity.TeacherDefaultPracticeGroupSalary;
-import com.ym.mec.biz.service.TeacherDefaultPracticeGroupSalaryService;
-import com.ym.mec.common.controller.BaseController;
+import java.util.Date;
+import java.util.List;
 
 @Api(tags = "老师默认陪练课薪酬")
 @RequestMapping("teacherDefaultPracticeGroupSalary")
@@ -41,7 +35,7 @@ public class TeacherDefaultPracticeGroupSalaryController extends BaseController
 				teacherDefaultPracticeGroupSalaryTemp.getStartDate()) ? succeed() : failed();
 	}
 
-	class TeacherDefaultPracticeGroupSalaryTemp {
+	static class TeacherDefaultPracticeGroupSalaryTemp {
 
 		private List<TeacherDefaultPracticeGroupSalary> teacherDefaultPracticeGroupSalaries;