Browse Source

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

zouxuan 5 years ago
parent
commit
10ddd0842d
20 changed files with 376 additions and 90 deletions
  1. 3 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java
  2. 46 16
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ClassGroupAdjustDto.java
  3. 17 6
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ClassGroupStudentMapperDto.java
  4. 23 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentApplyRefunds.java
  5. 17 6
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrder.java
  6. 28 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentApplyrefundsQueryInfo.java
  7. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java
  8. 0 3
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java
  9. 93 11
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java
  10. 24 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  11. 27 22
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  12. 2 2
      mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  13. 24 4
      mec-biz/src/main/resources/config/mybatis/StudentApplyRefundsMapper.xml
  14. 8 3
      mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml
  15. 1 1
      mec-student/src/main/java/com/ym/mec/student/config/ResourceServerConfig.java
  16. 8 0
      mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java
  17. 3 1
      mec-student/src/main/resources/application.yml
  18. 1 1
      mec-web/src/main/java/com/ym/mec/web/config/ResourceServerConfig.java
  19. 31 0
      mec-web/src/main/java/com/ym/mec/web/controller/StudentApplyRefundsController.java
  20. 12 9
      mec-web/src/main/java/com/ym/mec/web/controller/StudentPaymentOrderController.java

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

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentApplyRefunds.java

@@ -1,7 +1,10 @@
 package com.ym.mec.biz.dal.entity;
 
+import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.enums.AuditStatusEnum;
+
 import io.swagger.annotations.ApiModelProperty;
+
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
 import java.math.BigDecimal;
@@ -45,6 +48,10 @@ public class StudentApplyRefunds {
 	@ApiModelProperty(value = "原订单编号",required = true)
 	private Long origPaymentOrderId;
 	
+	private StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
+	
+	private SysUser user = new SysUser();
+	
 	public void setId(Long id){
 		this.id = id;
 	}
@@ -125,6 +132,22 @@ public class StudentApplyRefunds {
 		this.remark = remark;
 	}
 
+	public StudentPaymentOrder getStudentPaymentOrder() {
+		return studentPaymentOrder;
+	}
+
+	public void setStudentPaymentOrder(StudentPaymentOrder studentPaymentOrder) {
+		this.studentPaymentOrder = studentPaymentOrder;
+	}
+
+	public SysUser getUser() {
+		return user;
+	}
+
+	public void setUser(SysUser user) {
+		this.user = user;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 17 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentOrder.java

@@ -1,16 +1,17 @@
 package com.ym.mec.biz.dal.entity;
 
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
-import com.ym.mec.biz.dal.enums.OrderTypeEnum;
-
-import com.ym.mec.biz.dal.enums.PaymentChannelTypeEnum;
 import io.swagger.annotations.ApiModelProperty;
 
-import org.apache.commons.lang3.builder.ToStringBuilder;
-
 import java.math.BigDecimal;
 import java.util.Date;
 
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.enums.PaymentChannelTypeEnum;
+
 /**
  * 对应数据库表(student_payment_order):
  */
@@ -85,6 +86,8 @@ public class StudentPaymentOrder {
 
 	private PaymentChannelTypeEnum paymentChannelType;
 	
+	private SysUser user = new SysUser();
+	
 	public void setId(Long id){
 		this.id = id;
 	}
@@ -244,6 +247,14 @@ public class StudentPaymentOrder {
         this.paymentChannelType = paymentChannelType;
     }
 
+	public SysUser getUser() {
+		return user;
+	}
+
+	public void setUser(SysUser user) {
+		this.user = user;
+	}
+
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);

+ 28 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentApplyrefundsQueryInfo.java

@@ -0,0 +1,28 @@
+package com.ym.mec.biz.dal.page;
+
+import java.util.Date;
+
+import com.ym.mec.common.page.QueryInfo;
+
+public class StudentApplyrefundsQueryInfo extends QueryInfo {
+
+	private Date startTime;
+
+	private Date endTime;
+
+	public Date getStartTime() {
+		return startTime;
+	}
+
+	public void setStartTime(Date startTime) {
+		this.startTime = startTime;
+	}
+
+	public Date getEndTime() {
+		return endTime;
+	}
+
+	public void setEndTime(Date endTime) {
+		this.endTime = endTime;
+	}
+}

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderService.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.service;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 import com.ym.mec.common.service.BaseService;
 
+import java.util.Date;
 import java.util.List;
 
 public interface MusicGroupPaymentCalenderService extends BaseService<Long, MusicGroupPaymentCalender> {
@@ -12,4 +13,11 @@ public interface MusicGroupPaymentCalenderService extends BaseService<Long, Musi
      * @param musicGroupPaymentCalenders
      */
     void batchInsert(List<MusicGroupPaymentCalender> musicGroupPaymentCalenders);
+
+	/**
+	 * 获取下次缴费时间
+	 * @param musicGroupId
+	 * @return
+	 */
+	Date getNextPaymentDate(String musicGroupId);
 }

+ 0 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java

@@ -6,9 +6,6 @@ import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
-import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
-import com.ym.mec.common.page.PageInfo;
-import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.BaseService;
 
 public interface StudentPaymentOrderService extends BaseService<Long, StudentPaymentOrder> {

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

@@ -28,10 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
-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;
@@ -73,6 +70,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() {
@@ -712,29 +711,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());
@@ -744,7 +750,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());
@@ -755,11 +761,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;
     }
 

+ 24 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -10,11 +10,14 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 
 @Service
 public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalender> implements MusicGroupPaymentCalenderService {
-	
+
 	@Autowired
 	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
 
@@ -26,11 +29,30 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void batchInsert(List<MusicGroupPaymentCalender> musicGroupPaymentCalenders) {
-		if(musicGroupPaymentCalenders != null && musicGroupPaymentCalenders.size() > 0){
+		if (musicGroupPaymentCalenders != null && musicGroupPaymentCalenders.size() > 0) {
 			musicGroupPaymentCalenderDao.delByGroupId(musicGroupPaymentCalenders.get(0).getMusicGroupId());
 			musicGroupPaymentCalenders.forEach(e -> {
 				musicGroupPaymentCalenderDao.insert(e);
 			});
 		}
 	}
+
+	@Override
+	public Date getNextPaymentDate(String musicGroupId) {
+		List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
+		if (musicGroupPaymentCalenderList != null && musicGroupPaymentCalenderList.size() > 0) {
+
+			Collections.sort(musicGroupPaymentCalenderList);
+
+			Calendar cale = Calendar.getInstance();
+			int month = cale.get(Calendar.MONTH) + 1;
+
+			for (MusicGroupPaymentCalender cal : musicGroupPaymentCalenderList) {
+				if (cal.getPaymentMonth() >= month) {
+					return cal.getStartPaymentDate();
+				}
+			}
+		}
+		return null;
+	}
 }

+ 27 - 22
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -45,6 +45,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 	@Autowired
 	private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
 	@Autowired
+	private MusicGroupPaymentCalenderService musicGroupPaymentCalenderService;
+	@Autowired
 	private MusicGroupPaymentEntitiesDao musicGroupPaymentEntitiesDao;
 	@Autowired
 	private MusicGroupSubjectGoodsGroupDao musicGroupSubjectGoodsGroupDao;
@@ -240,27 +242,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 		musicGroup.setUpdateTime(new Date());
 		musicGroupDao.update(musicGroup);
 
-		// 查询下次缴费时间
-		List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.findByMusicGroupId(musicGroupId);
-		if (musicGroupPaymentCalenderList != null && musicGroupPaymentCalenderList.size() > 0) {
-
-			Collections.sort(musicGroupPaymentCalenderList);
-
-			Calendar cale = Calendar.getInstance();
-			int month = cale.get(Calendar.MONTH) + 1;
-
-			MusicGroupPaymentCalender calender = null;
-
-			for (MusicGroupPaymentCalender cal : musicGroupPaymentCalenderList) {
-				if (cal.getPaymentMonth() >= month) {
-					calender = cal;
-					break;
-				}
-			}
-
-			// 重新设置下次缴费时间
-			musicGroupStudentFeeDao.updateNextPaymentDate(musicGroupId, calender.getStartPaymentDate());
-		}
+		// 重新设置下次缴费时间
+		musicGroupStudentFeeDao.updateNextPaymentDate(musicGroupId, musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId));
 
 		return true;
 	}
@@ -411,7 +394,29 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 	public boolean renewForCallback(StudentPaymentOrder studentPaymentOrder) {
 		
-		return false;
+		studentPaymentOrderDao.update(studentPaymentOrder);
+		
+		Integer userId = studentPaymentOrder.getUserId();
+		String musicGroupId = studentPaymentOrder.getMusicGroupId();
+		
+		//更新下次续费时间
+		MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(userId, musicGroupId);
+		
+		if(musicGroupStudentFee == null){
+			throw new BizException("系统数据异常,找不到学员预缴费信息");
+		}
+		
+		Date date = new Date();
+		
+		musicGroupStudentFee.setUpdateTime(date);
+		musicGroupStudentFee.setLatestPaidTime(date);
+		musicGroupStudentFee.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
+		musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
+		musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId));
+		
+		musicGroupStudentFeeDao.update(musicGroupStudentFee);
+		
+		return true;
 	}
 
 	@Override

+ 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">

+ 24 - 4
mec-biz/src/main/resources/config/mybatis/StudentApplyRefundsMapper.xml

@@ -18,6 +18,12 @@
         <result column="orig_payment_order_id_" property="origPaymentOrderId"/>
         <result column="remark_" property="remark"/>
     </resultMap>
+    
+    <resultMap type="com.ym.mec.biz.dal.entity.StudentApplyRefunds" extends="StudentApplyRefunds" id="StudentApplyRefundsListDTO">
+    	<result column="spo.expect_amount_" property="studentPaymentOrder.expectAmount"/>
+    	<result column="spo.actual_amount_" property="studentPaymentOrder.actualAmount"/>
+    	<result column="u.username_" property="user.username"/>
+    </resultMap>
 
     <!-- 根据主键查询一条记录 -->
     <select id="get" resultMap="StudentApplyRefunds">
@@ -80,13 +86,27 @@
 	</delete>
 
     <!-- 分页查询 -->
-    <select id="queryPage" resultMap="StudentApplyRefunds" parameterType="map">
-        SELECT * FROM student_apply_refunds ORDER BY id_
-        <include refid="global.limit"/>
+    <select id="queryPage" resultMap="StudentApplyRefundsListDTO" parameterType="map">
+        SELECT sar.*,spo.expect_amount_,spo.actual_amount_,u.username_ FROM student_apply_refunds sar left join student_payment_order spo on sar.orig_payment_order_id_ = spo.id_ left join sys_user u on sar.user_id_ = u.id_
+        where 1=1 
+        <if test="startTime != null">
+            and sar.create_time_ &gt;= #{startTime}
+        </if>
+        <if test="endTime != null">
+            and sar.create_time_ &lt;= #{endTime}
+        </if>
+        ORDER BY sar.id_ <include refid="global.limit"/>
     </select>
 
     <!-- 查询当前表的总记录数 -->
     <select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM student_apply_refunds
+		SELECT count(1) FROM student_apply_refunds sar left join student_payment_order spo on sar.orig_payment_order_id_ = spo.id_ 
+		where 1=1 
+        <if test="startTime != null">
+            and sar.create_time_ = #{startTime}
+        </if>
+        <if test="endTime != null">
+            and sar.create_time_ = #{endTime}
+        </if>
 	</select>
 </mapper>

+ 8 - 3
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderMapper.xml

@@ -26,6 +26,10 @@
         <result column="pay_time_" property="payTime"/>
         <result column="version_" property="version"/>
     </resultMap>
+    
+    <resultMap type="com.ym.mec.biz.dal.entity.StudentPaymentOrder" extends="StudentPaymentOrder" id="PaymentOrderAndStudentInfo">
+    	<result column="username_" property="user.username"/>
+    </resultMap>
 
     <resultMap type="com.ym.mec.biz.dal.entity.Goods" id="Goods">
         <result column="id_" property="id"/>
@@ -139,8 +143,8 @@
     </delete>
 
     <!-- 分页查询 -->
-    <select id="queryPage" resultMap="StudentPaymentOrder" parameterType="map">
-        SELECT * FROM student_payment_order spo
+    <select id="queryPage" resultMap="PaymentOrderAndStudentInfo" parameterType="map">
+        SELECT spo.*,u.username_ FROM student_payment_order spo left join sys_user u on spo.user_id_ = u.id_
         <include refid="queryPaymentOrder"/>
         ORDER BY spo.id_
         <include refid="global.limit"/>
@@ -187,7 +191,7 @@
         FROM
         student_vip_group_payment svgp
         LEFT JOIN student_payment_order spo ON svgp.student_payment_order_id_=spo.id_
-        WHERE svgp.user_id_=#{userId} AND svgp.vip_group_id_=#{vipGroupId} AND spo.status_='ING'
+        WHERE svgp.user_id_=#{userId} AND svgp.vip_group_id_=#{vipGroupId} AND spo.status_='ING' and spo.type_ = 'SMALL_CLASS_TO_BUY'
     </select>
     <!-- 查询报名订单 -->
     <select id="findMusicGroupApplyOrderByStatus" resultMap="StudentPaymentOrder">
@@ -220,6 +224,7 @@
             <result column="goods_name_"/>
         </collection>
     </resultMap>
+    
     <select id="findGoodsIds" resultMap="userGoodsDto">
         SELECT g.id_ goods_id_,g.name_ goods_name_ FROM student_payment_order spo
         LEFT JOIN student_payment_order_detail spod ON spo.id_ = spod.payment_order_id_

+ 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

+ 8 - 0
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -4,11 +4,14 @@ import com.ym.mec.biz.dal.dao.SysAccountDao;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.service.MusicGroupService;
 import com.ym.mec.biz.service.StudentPaymentOrderService;
 import com.ym.mec.biz.service.StudentRegistrationService;
 import com.ym.mec.biz.service.VipGroupService;
 import com.ym.mec.thirdparty.union.NotifyMsg;
+
 import io.swagger.annotations.Api;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -30,6 +33,9 @@ public class StudentOrderController {
     private StudentRegistrationService studentRegistrationService;
     @Autowired
     private VipGroupService vipGroupService;
+    
+    @Autowired
+    private MusicGroupService musicGroupService;
 
 
     @PostMapping("/notify")
@@ -66,6 +72,8 @@ public class StudentOrderController {
             studentRegistrationService.updateApplyOrder(order);
         }else if (order.getType().equals(OrderTypeEnum.SMALL_CLASS_TO_BUY)){
             vipGroupService.orderCallback(order);
+        }else if(order.getType().equals(OrderTypeEnum.RENEW)){
+        	musicGroupService.renewForCallback(order);
         }
 
         return "SUCCESS";

+ 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

+ 31 - 0
mec-web/src/main/java/com/ym/mec/web/controller/StudentApplyRefundsController.java

@@ -0,0 +1,31 @@
+package com.ym.mec.web.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+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.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.ym.mec.biz.dal.page.StudentApplyrefundsQueryInfo;
+import com.ym.mec.biz.service.StudentApplyRefundsService;
+import com.ym.mec.common.controller.BaseController;
+
+@RequestMapping("studentRefunds")
+@Api(tags = "退费服务")
+@RestController
+public class StudentApplyRefundsController extends BaseController {
+	
+	@Autowired
+	private StudentApplyRefundsService studentApplyRefundsService;
+
+	@ApiOperation(value = "查询退费列表")
+    @GetMapping("/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('studentRefunds/queryPage')")
+    public Object queryPage(StudentApplyrefundsQueryInfo queryInfo){
+		
+        return succeed(studentApplyRefundsService.queryPage(queryInfo));
+    }
+}

+ 12 - 9
mec-web/src/main/java/com/ym/mec/web/controller/student/StudentPaymentOrderController.java → mec-web/src/main/java/com/ym/mec/web/controller/StudentPaymentOrderController.java

@@ -1,26 +1,29 @@
-package com.ym.mec.web.controller.student;
+package com.ym.mec.web.controller;
 
-import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
-import com.ym.mec.biz.service.StudentPaymentOrderService;
-import com.ym.mec.common.controller.BaseController;
-import com.ym.mec.common.page.QueryInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+
 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.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-@RequestMapping("studentPaymentOrder")
-@Api(tags = "学生缴费订单服务")
+import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
+import com.ym.mec.biz.service.StudentPaymentOrderService;
+import com.ym.mec.common.controller.BaseController;
+
+@RequestMapping("order")
+@Api(tags = "订单服务")
 @RestController
 public class StudentPaymentOrderController extends BaseController {
 
     @Autowired
     private StudentPaymentOrderService studentPaymentOrderService;
 
-    @ApiOperation(value = "获取学员订单列表")
-    @GetMapping("/queryOrderPage")
+    @ApiOperation(value = "获取订单列表")
+    @GetMapping("/queryPage")
+    @PreAuthorize("@pcs.hasPermissions('order/queryPage')")
     public Object queryOrderPage(StudentPaymentOrderQueryInfo queryInfo){
         return succeed(studentPaymentOrderService.queryPage(queryInfo));
     }