Browse Source

1、乐团课新增排课教师课酬计算逻辑调整
2、陪练课配置
3、陪练课接口

Joburgess 5 years ago
parent
commit
31e02d58e5

+ 17 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/PracticeGroupDao.java

@@ -1,8 +1,24 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.PracticeGroup;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Date;
+import java.util.List;
 
 public interface PracticeGroupDao extends com.ym.mec.common.dal.BaseDAO<Long, PracticeGroup> {
 
+    /**
+     * @describe 获取学生指定日期内预约的陪练课
+     * @author Joburgess
+     * @date 2020/1/31
+     * @param userId: 用户编号
+     * @param startDate: 开始时间
+     * @param endDate: 结束时间
+     * @return java.util.List<com.ym.mec.biz.dal.entity.PracticeGroup>
+     */
+    List<PracticeGroup> getUserPracticeCoursesWithDateRange(@Param("userId") Integer userId,
+                                                            @Param("startDate") Date startDate,
+                                                            @Param("endDate") Date endDate);
 	
-}
+}

+ 17 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -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;
 	}
 }

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/PracticeGroupMapper.xml

@@ -47,4 +47,7 @@
 	<select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM practice_group
 	</select>
+    <select id="getUserPracticeCoursesWithDateRange" resultMap="PracticeGroup">
+		SELECT * FROM practice_group WHERE user_id_=#{userId} AND (courses_start_date_ BETWEEN DATE_FORMAT(#{startDate},'%Y-%m-%d') AND DATE_FORMAT(#{endDate},'%Y-%m-%d'))
+	</select>
 </mapper>

+ 7 - 0
mec-student/src/main/java/com/ym/mec/student/controller/PracticeGroupController.java

@@ -1,5 +1,6 @@
 package com.ym.mec.student.controller;
 
+import com.ym.mec.biz.dal.entity.PracticeGroup;
 import com.ym.mec.biz.service.PracticeGroupService;
 import com.ym.mec.common.controller.BaseController;
 import io.swagger.annotations.Api;
@@ -27,4 +28,10 @@ public class PracticeGroupController extends BaseController {
         return succeed(practiceGroupService.getPracticeApplyParams());
     }
 
+    @ApiOperation("陪练课预约")
+    @GetMapping(value = "/practiceApply")
+    public Object practiceApply(PracticeGroup practiceGroup){
+        return succeed(practiceGroupService.practiceApply(practiceGroup));
+    }
+
 }