浏览代码

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

Joburgess 5 年之前
父节点
当前提交
242d8232c2

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/PracticeGroupService.java

@@ -22,9 +22,10 @@ public interface PracticeGroupService extends BaseService<Long, PracticeGroup> {
      * @describe 获取陪练课预约参数
      * @author Joburgess
      * @date 2020/1/31
+     * @param userId: 用户编号
      * @return java.util.Map
      */
-    Map getPracticeApplyParams();
+    Map getPracticeApplyParams(Integer userId);
 
     /**
      * @describe 陪练课预约

+ 41 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -46,6 +46,10 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
     private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
 	@Autowired
     private TeacherAttendanceDao teacherAttendanceDao;
+	@Autowired
+    private StudentDao studentDao;
+	@Autowired
+    private ClassGroupStudentMapperDao classGroupStudentMapperDao;
 
 	@Override
 	public BaseDAO<Long, PracticeGroup> getDAO() {
@@ -60,16 +64,17 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
 
 
 	@Override
-	public Map getPracticeApplyParams() {
+	public Map getPracticeApplyParams(Integer userId) {
 		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());
+        Student student = studentDao.get(userId);
+        List<Subject> subjects = subjectDao.findBySubjectByIdList(practiceSubjectIdListConfig.getParanValue());
 		result.put("subjects", subjects);
 		result.put("practiceApplyStartTime",practiceApplyStartTimeConfig.getParanValue());
 		result.put("practiceApplyEndTime",practiceApplyEndTimeConfig.getParanValue());
-		result.put("userDefaultSubjectIds",null);
+		result.put("userDefaultSubjectIds",Objects.isNull(student)?null:student.getSubjectIdList());
 		return result;
 	}
 
@@ -100,11 +105,13 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         if(applyTimes>=2){
             throw new BizException("您的预约次数已经达到限制");
         }
+        applyTimes+=1;
 
         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("教师指派错误");
+//            throw new BizException("教师指派错误");
+            teacherId=100001;
         }
 		Teacher teacher = teacherService.getDetail(teacherId);
         Employee employee = employeeDao.get(teacherId);
@@ -159,6 +166,16 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         classGroupTeacherSalary.setUpdateTime(now);
         classGroupTeacherSalaryDao.insert(classGroupTeacherSalary);
 
+        //班级学生关联表
+        ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
+        classGroupStudentMapper.setMusicGroupId(practiceGroup.getId().toString());
+        classGroupStudentMapper.setClassGroupId(classGroup.getId());
+        classGroupStudentMapper.setUserId(practiceGroup.getUserId());
+        classGroupStudentMapper.setCreateTime(now);
+        classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+        classGroupStudentMapper.setGroupType(GroupType.PRACTICE);
+        classGroupStudentMapperDao.insert(classGroupStudentMapper);
+
         //课表
         CourseSchedule courseSchedule = new CourseSchedule();
         courseSchedule.setMusicGroupId(practiceGroup.getId().toString());
@@ -212,6 +229,26 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         teacherAttendance.setCreateTime(now);
         teacherAttendanceDao.insert(teacherAttendance);
 
+        Student student = studentDao.get(practiceGroup.getUserId());
+        if(Objects.isNull(student)){
+            student=new Student();
+            student.setUserId(practiceGroup.getUserId());
+            student.setSubjectIdList(practiceGroup.getSubjectId().toString());
+            studentDao.insert(student);
+        }else{
+            if(Objects.isNull(student.getSubjectIdList())){
+                student.setSubjectIdList(practiceGroup.getSubjectId().toString());
+            }else{
+                String[] studentIdStrings = student.getSubjectIdList().split(",");
+                List<String> studentIds = new ArrayList<>(Arrays.asList(studentIdStrings));
+                if(!studentIds.contains(practiceGroup.getSubjectId().toString())){
+                    studentIds.add(practiceGroup.getSubjectId().toString());
+                }
+                student.setSubjectIdList(StringUtils.join(studentIds.toArray(),","));
+            }
+            studentDao.update(student);
+        }
+
         Map result=new HashMap();
         result.put("teacherName",teacher.getRealName());
         result.put("enableApply",applyTimes<2?1:0);

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

@@ -19,7 +19,11 @@
 		<result column="update_time_" property="updateTime" />
 		<result column="memo_" property="memo" />
 	</resultMap>
-	
+
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="PracticeGroup">
+		SELECT * FROM practice_group WHERE id_ = #{id}
+	</select>
 	
 	<!-- 全查询 -->
 	<select id="findAll" resultMap="PracticeGroup">

+ 10 - 4
mec-biz/src/main/resources/config/mybatis/StudentMapper.xml

@@ -12,8 +12,12 @@
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
 	</resultMap>
-	
-	
+
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="Student">
+		SELECT * FROM student WHERE user_id_ = #{id}
+	</select>
+
 	<!-- 全查询 -->
 	<select id="findAll" resultMap="Student">
 		SELECT * FROM student
@@ -26,10 +30,12 @@
 		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL 
 		</selectKey>
 		-->
-		INSERT INTO student (user_id_,subject_id_list_,create_time_,update_time_) VALUES(#{userId},#{subjectIdList},#{createTime},#{updateTime})
+		INSERT INTO student (user_id_,subject_id_list_,create_time_,update_time_) VALUES(#{userId},#{subjectIdList},NOW(),NOW())
 	</insert>
 	
-	
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.Student">
+		UPDATE student SET subject_id_list_=#{subjectIdList},update_time_=NOW() WHERE user_id_=#{userId}
+	</update>
 	
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="Student" parameterType="map">

+ 17 - 2
mec-student/src/main/java/com/ym/mec/student/controller/PracticeGroupController.java

@@ -1,12 +1,16 @@
 package com.ym.mec.student.controller;
 
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
 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;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -21,16 +25,27 @@ public class PracticeGroupController extends BaseController {
 
     @Autowired
     private PracticeGroupService practiceGroupService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
 
     @ApiOperation("获取陪练课预约参数")
     @GetMapping(value = "/getPracticeApplyParams")
     public Object getPracticeApplyParams(){
-        return succeed(practiceGroupService.getPracticeApplyParams());
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        return succeed(practiceGroupService.getPracticeApplyParams(sysUser.getId()));
     }
 
     @ApiOperation("陪练课预约")
-    @GetMapping(value = "/practiceApply")
+    @PostMapping(value = "/practiceApply")
     public Object practiceApply(PracticeGroup practiceGroup){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        practiceGroup.setUserId(sysUser.getId());
         return succeed(practiceGroupService.practiceApply(practiceGroup));
     }