Browse Source

回调地址开放访问

周箭河 5 years ago
parent
commit
b584f7cddd

+ 3 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -353,14 +353,14 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
     void updateByMusicGroupId(@Param("musicGroupId") String musicGroupId, @Param("schoolId") Integer schoolId);
 
     /**
-     * 获取班级时间段内的课程
+     * 获取班级某时间后相应节数的课程
      *
      * @param classGroupId
      * @param startDate
-     * @param endDate
+     * @param times
      * @return
      */
-    List<CourseSchedule> findCourseScheduleByClassGroupIdAndDate(@Param("classGroupId") Integer classGroupId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
+    List<CourseSchedule> findCourseScheduleByClassGroupIdAndDate(@Param("classGroupId") Integer classGroupId, @Param("startDate") String startDate, @Param("times") int times);
     
     /**
      * 根据时间范围查询老师指定类型的课程列表

+ 46 - 16
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ClassGroupAdjustDto.java

@@ -1,12 +1,9 @@
 package com.ym.mec.biz.dal.dto;
 
-import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
 import com.ym.mec.biz.dal.entity.ClassGroupTeacherMapper;
 import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import io.swagger.annotations.ApiModelProperty;
 
-import java.time.LocalDateTime;
-import java.util.Date;
 import java.util.List;
 
 /**
@@ -30,10 +27,19 @@ public class ClassGroupAdjustDto {
     private YesOrNoEnum type;
 
     @ApiModelProperty(value = "开始时间", required = true)
-    private Date startDate;
+    private String startDate;
 
-    @ApiModelProperty(value = "结束时间", required = true)
-    private Date endDate;
+    @ApiModelProperty(value = "排课星期几",required = true)
+    private Integer dayOfWeek;
+
+    @ApiModelProperty(value = "上课开始时间",required = true)
+    private String startClassTime;
+
+    @ApiModelProperty(value = "上课结束时间",required = true)
+    private String endClassTime;
+
+    @ApiModelProperty(value = "排课次数", required = true)
+    private Integer courseTimes;
 
     public String getClassGroupName() {
         return classGroupName;
@@ -51,22 +57,14 @@ public class ClassGroupAdjustDto {
         this.type = type;
     }
 
-    public Date getStartDate() {
+    public String getStartDate() {
         return startDate;
     }
 
-    public void setStartDate(Date startDate) {
+    public void setStartDate(String startDate) {
         this.startDate = startDate;
     }
 
-    public Date getEndDate() {
-        return endDate;
-    }
-
-    public void setEndDate(Date endDate) {
-        this.endDate = endDate;
-    }
-
     public List<ClassGroupTeacherMapper> getClassGroupTeacherMapperList() {
         return classGroupTeacherMapperList;
     }
@@ -90,4 +88,36 @@ public class ClassGroupAdjustDto {
     public void setMusicGroupId(String musicGroupId) {
         this.musicGroupId = musicGroupId;
     }
+
+    public Integer getDayOfWeek() {
+        return dayOfWeek;
+    }
+
+    public void setDayOfWeek(Integer dayOfWeek) {
+        this.dayOfWeek = dayOfWeek;
+    }
+
+    public String getStartClassTime() {
+        return startClassTime;
+    }
+
+    public void setStartClassTime(String startClassTime) {
+        this.startClassTime = startClassTime;
+    }
+
+    public String getEndClassTime() {
+        return endClassTime;
+    }
+
+    public void setEndClassTime(String endClassTime) {
+        this.endClassTime = endClassTime;
+    }
+
+    public Integer getCourseTimes() {
+        return courseTimes;
+    }
+
+    public void setCourseTimes(Integer courseTimes) {
+        this.courseTimes = courseTimes;
+    }
 }

+ 17 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ClassGroupStudentMapperDto.java

@@ -4,14 +4,25 @@ import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
 import io.swagger.annotations.ApiModelProperty;
 
 public class ClassGroupStudentMapperDto extends ClassGroupStudentMapper {
-    @ApiModelProperty(value = "科目编号",required = true)
-    private Integer actual_subject_id_;
+    @ApiModelProperty(value = "科目编号(声部编号)",required = true)
+    private Integer actualSubjectId;
 
-    public Integer getActual_subject_id_() {
-        return actual_subject_id_;
+    @ApiModelProperty(value = "科目名称(声部名称)",required = true)
+    private String subjectName;
+
+    public Integer actualSubjectId() {
+        return actualSubjectId;
+    }
+
+    public void actualSubjectId(Integer actualSubjectId) {
+        this.actualSubjectId = actualSubjectId;
+    }
+
+    public String getSubjectName() {
+        return subjectName;
     }
 
-    public void setActual_subject_id_(Integer actual_subject_id_) {
-        this.actual_subject_id_ = actual_subject_id_;
+    public void setSubjectName(String subjectName) {
+        this.subjectName = subjectName;
     }
 }

+ 93 - 13
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -21,18 +21,13 @@ import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.format.datetime.DateFormatter;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
-import java.text.DateFormat;
-import java.time.Instant;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
+import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -76,6 +71,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     private CourseScheduleDao courseScheduleDao;
     @Autowired
     private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
+    @Autowired
+    private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
 
     @Override
     public BaseDAO<Integer, ClassGroup> getDAO() {
@@ -716,29 +713,36 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     @Transactional(rollbackFor = Exception.class)
     public ClassGroup classGroupAdjust(ClassGroupAdjustDto classGroupAdjustDto) throws Exception {
         Date date = new Date();
+        MusicGroup musicGroup = musicGroupDao.get(classGroupAdjustDto.getMusicGroupId());
+        if (musicGroup != null) {
+            throw new Exception("乐团不存在");
+        }
+        Integer schoolId = musicGroup.getSchoolId();
 
         List<ClassGroupStudentMapperDto> classGroupStudentMapperDtoList = classGroupAdjustDto.getClassGroupStudentMapperDtoList();
-        String subject_id_list_ = "";
-        for (ClassGroupStudentMapper classGroupStudentMapperDto : classGroupStudentMapperDtoList) {
+        String subjectIdList = "";
+        String subjectNameList = "";
+        for (ClassGroupStudentMapperDto classGroupStudentMapperDto : classGroupStudentMapperDtoList) {
             //1、永久调整,删除学生班级关联关系
             if (classGroupAdjustDto.getType().equals(YesOrNoEnum.YES)) {
                 ClassGroupStudentMapper classStudentMapper = classGroupStudentMapperDao.query(classGroupStudentMapperDto.getClassGroupId(), classGroupStudentMapperDto.getUserId());
                 classStudentMapper.setStatus(ClassGroupStudentStatusEnum.QUIT);
                 classGroupStudentMapperDao.update(classStudentMapper);
             } else { //临时删除学生对应时间段的课程
-                List<CourseSchedule> courseScheduleList = courseScheduleDao.findCourseScheduleByClassGroupIdAndDate(classGroupStudentMapperDto.getClassGroupId(), classGroupAdjustDto.getStartDate(), classGroupAdjustDto.getEndDate());
+                List<CourseSchedule> courseScheduleList = courseScheduleDao.findCourseScheduleByClassGroupIdAndDate(classGroupStudentMapperDto.getClassGroupId(), classGroupAdjustDto.getStartDate(), classGroupAdjustDto.getCourseTimes());
                 courseScheduleStudentPaymentDao.deleteStudentCourseSchedule(classGroupStudentMapperDto.getUserId(), courseScheduleList);
             }
-            subject_id_list_ += classGroupStudentMapperDto.getUserId() + ",";
+            subjectIdList += classGroupStudentMapperDto.actualSubjectId() + ",";
+            subjectNameList += classGroupStudentMapperDto.getSubjectName() + "/";
         }
 
 
-        subject_id_list_ = subject_id_list_.substring(0, subject_id_list_.length() - 1);
+        subjectIdList = subjectIdList.substring(0, subjectIdList.length() - 1);
 
         //2、新建班级
         ClassGroup classGroup = new ClassGroup();
         classGroup.setMusicGroupId(classGroupAdjustDto.getMusicGroupId());
-        classGroup.setSubjectIdList(subject_id_list_);
+        classGroup.setSubjectIdList(subjectIdList);
         classGroup.setName(classGroupAdjustDto.getClassGroupName());
         classGroup.setExpectStudentNum(classGroupStudentMapperDtoList.size());
         classGroup.setStudentNum(classGroupStudentMapperDtoList.size());
@@ -748,7 +752,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         classGroup.setUpdateTime(date);
         classGroupDao.insert(classGroup);
 
-        //3、将学生加入新班级(学生注册表,关联表
+        //3、将学生加入新班级(学生注册表,关联表
         List<ClassGroupStudentMapper> classGroupStudentMapperList = new ArrayList<>();
         for (ClassGroupStudentMapperDto classGroupStudentMapperDto : classGroupStudentMapperDtoList) {
             classGroupStudentMapperDto.setClassGroupId(classGroup.getId());
@@ -759,11 +763,87 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
         //4、将老师加入关联关系
         List<ClassGroupTeacherMapper> classGroupTeacherMapperList = classGroupAdjustDto.getClassGroupTeacherMapperList();
+
+        //课时长度
+        long classCourseDuration = Duration.between(LocalDateTime.parse(classGroupAdjustDto.getStartDate() + " " + classGroupAdjustDto.getStartClassTime() + ":00"),
+                LocalDateTime.parse(classGroupAdjustDto.getStartDate() + " " + classGroupAdjustDto.getEndClassTime() + ":00"))
+                .toMinutes();
+
         for (ClassGroupTeacherMapper classGroupTeacherMapper : classGroupTeacherMapperList) {
             classGroupTeacherMapper.setClassGroupId(classGroup.getId());
             classGroupTeacherMapper.setMusicGroupId(classGroupAdjustDto.getMusicGroupId());
+
+            List<TeacherDefaultMusicGroupSalary> teacherSalaryList = teacherDefaultMusicGroupSalaryService.getTeacherSalaryByUserIdAndType(classGroupTeacherMapper.getUserId(), "SINGLE", musicGroup.getSettlementType());
+            BigDecimal salary = new BigDecimal("0");
+            for (TeacherDefaultMusicGroupSalary teacherDefaultMusicGroupSalary : teacherSalaryList) {
+                //对应基准课酬
+                BigDecimal baseSalary = classGroupTeacherMapper.getTeacherRole().equals(TeachTypeEnum.BISHOP) ? teacherDefaultMusicGroupSalary.getMainTeacherSalary() : teacherDefaultMusicGroupSalary.getAssistantTeacherSalary();
+                //基准课酬
+                if (teacherDefaultMusicGroupSalary.getSettlementType().equals(SalarySettlementTypeEnum.TEACHER_DEFAULT)) {
+                    salary = new BigDecimal(classCourseDuration).divide(new BigDecimal(30)).multiply(baseSalary).setScale(2, BigDecimal.ROUND_HALF_UP);
+                    break;
+                }
+                //阶梯课酬
+                if (classCourseDuration >= teacherDefaultMusicGroupSalary.getDurationMin() && classCourseDuration <= teacherDefaultMusicGroupSalary.getDurationMin()) {
+                    salary = baseSalary;
+                    break;
+                }
+            }
+            classGroupTeacherMapper.setSalary(salary);
         }
         classGroupTeacherMapperDao.classGroupTeachersInsert(classGroupTeacherMapperList);
+
+        //5、插入班级排课信息
+        LocalDateTime now = LocalDate.parse(classGroupAdjustDto.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
+
+        //计算每节课的课酬
+        List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaryList = new ArrayList<>();
+
+        int times = 0;
+        while (true) {
+            int dayOfWeek = now.getDayOfWeek().getValue();
+            if (classGroupAdjustDto.getDayOfWeek().equals(dayOfWeek)) {
+                Instant instant = now.atZone(ZoneId.systemDefault()).toInstant();
+                Date classDate = Date.from(instant);
+                String startClassTime = DateUtil.getDate(classDate) + " " + classGroupAdjustDto.getStartClassTime() + ":00";
+                String endClassTime = DateUtil.getDate(classDate) + " " + classGroupAdjustDto.getEndClassTime() + ":00";
+
+                CourseSchedule courseSchedule = new CourseSchedule();
+                courseSchedule.setSchoolId(schoolId);
+                courseSchedule.setClassGroupId(classGroup.getId());
+                courseSchedule.setStatus(CourseStatusEnum.NOT_START);
+                courseSchedule.setClassDate(classDate);
+                courseSchedule.setStartClassTime(DateUtil.stringToDate(startClassTime));
+                courseSchedule.setEndClassTime(DateUtil.stringToDate(endClassTime));
+                courseSchedule.setCreateTime(date);
+                courseSchedule.setUpdateTime(date);
+                courseSchedule.setTeachMode(TeachModeEnum.OFFLINE);
+                courseSchedule.setType(CourseSchedule.CourseScheduleType.SINGLE);
+                courseSchedule.setName(subjectNameList + "-" + CourseSchedule.CourseScheduleType.SINGLE.getMsg());
+
+                courseScheduleDao.insert(courseSchedule);
+
+                times++;
+
+                for (ClassGroupTeacherMapper classGroupTeacherMapper : classGroupTeacherMapperList) {
+                    CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary();
+                    courseScheduleTeacherSalary.setCourseScheduleId(courseSchedule.getId());
+                    courseScheduleTeacherSalary.setTeacherRole(classGroupTeacherMapper.getTeacherRole());
+                    courseScheduleTeacherSalary.setUserId(classGroupTeacherMapper.getUserId());
+                    courseScheduleTeacherSalary.setExpectSalary(classGroupTeacherMapper.getSalary());
+                    courseScheduleTeacherSalary.setClassGroupId(classGroup.getId());
+                    courseScheduleTeacherSalary.setCreateTime(date);
+                    courseScheduleTeacherSalary.setUpdateTime(date);
+                    courseScheduleTeacherSalaryList.add(courseScheduleTeacherSalary);
+                }
+
+            }
+            now = now.plusDays(1);
+            if (classGroupAdjustDto.getCourseTimes().equals(times)) {
+                break;
+            }
+        }
+        courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaryList);
         return classGroup;
     }
 }

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

@@ -890,9 +890,9 @@
         GROUP BY course_schedule_id_
     </select>
 
-    <!-- 获取班级某时间的课程 -->
+    <!-- 获取班级某时间后对应节数的课程 -->
     <select id="findCourseScheduleByClassGroupIdAndDate" resultMap="CourseSchedule">
-        <![CDATA[ SELECT * FROM course_schedule WHERE class_group_id_=#{classGroupId} AND class_date_ >= #{startDate} AND  class_date_ <=#{endDate} ]]>
+        SELECT * FROM course_schedule WHERE class_group_id_=#{classGroupId} AND class_date_ >= #{startDate} ORDER BY class_date_ ASC LIMIT #{times}
     </select>
     
     <select id="queryTeacherCourseScheduleListByTimeRangeAndType" resultMap="CourseSchedule" parameterType="map">

+ 1 - 1
mec-student/src/main/java/com/ym/mec/student/config/ResourceServerConfig.java

@@ -25,7 +25,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
 	@Override
 	public void configure(HttpSecurity http) throws Exception {
 		http.csrf().disable().exceptionHandling().accessDeniedHandler(baseAccessDeniedHandler).authenticationEntryPoint(baseAuthenticationEntryPoint).and()
-				.authorizeRequests().antMatchers("/v2/api-docs","/studentOrder/notify").permitAll().anyRequest().authenticated().and().httpBasic();
+				.authorizeRequests().antMatchers("/v2/api-docs","/studentOrder/notify","/musicGroup/test").permitAll().anyRequest().authenticated().and().httpBasic();
 	}
 
 	@Override

+ 3 - 1
mec-student/src/main/resources/application.yml

@@ -53,7 +53,9 @@ spring:
 
 mybatis:
     mapperLocations: classpath:config/mybatis/*.xml
-    
+  #   configuration:
+  #      log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+
 swagger:
   base-package: com.ym.mec.student.controller
  

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/config/ResourceServerConfig.java

@@ -24,7 +24,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
 
 	@Override
 	public void configure(HttpSecurity http) throws Exception {
-		http.csrf().disable().exceptionHandling().accessDeniedHandler(baseAccessDeniedHandler).authenticationEntryPoint(baseAuthenticationEntryPoint).and().authorizeRequests().antMatchers("/v2/api-docs","/classGroup/revisionClassGroup").permitAll().anyRequest().authenticated().and().httpBasic();
+		http.csrf().disable().exceptionHandling().accessDeniedHandler(baseAccessDeniedHandler).authenticationEntryPoint(baseAuthenticationEntryPoint).and().authorizeRequests().antMatchers("/v2/api-docs").permitAll().anyRequest().authenticated().and().httpBasic();
 	}
 
 	@Override