ソースを参照

Merge remote-tracking branch 'origin/master'

周箭河 5 年 前
コミット
bbbef75bc9
20 ファイル変更704 行追加35 行削除
  1. 28 3
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java
  2. 30 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ClassGroupStudentInfoDto.java
  3. 110 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/GroupHeadInfoDto.java
  4. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SimpleUserDto.java
  5. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dto/TeacherClassStudentDto.java
  6. 22 20
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CoursesGroup.java
  7. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/PracticeGroup.java
  8. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/VipGroup.java
  9. 1 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderTypeEnum.java
  10. 1 1
      mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java
  11. 13 0
      mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupStudentMapperService.java
  12. 23 0
      mec-biz/src/main/java/com/ym/mec/biz/service/CoursesGroupService.java
  13. 9 0
      mec-biz/src/main/java/com/ym/mec/biz/service/TeacherCourseScheduleService.java
  14. 6 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java
  15. 314 6
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CoursesGroupServiceImpl.java
  16. 34 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherCourseScheduleServiceImpl.java
  17. 43 0
      mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml
  18. 23 0
      mec-biz/src/main/resources/config/mybatis/PracticeGroupMapper.xml
  19. 4 0
      mec-biz/src/main/resources/config/mybatis/VipGroupMapper.xml
  20. 3 0
      mec-teacher/src/main/java/com/ym/mec/teacher/controller/ClassGroupController.java

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

@@ -1,8 +1,6 @@
 package com.ym.mec.biz.dal.dao;
 
-import com.ym.mec.biz.dal.dto.StudentAttendanceViewDto;
-import com.ym.mec.biz.dal.dto.StudentNameAndPhoneDto;
-import com.ym.mec.biz.dal.dto.TeacherClassStudentDto;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
@@ -192,6 +190,19 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
     List<ClassGroupStudentMapper> findByClassGroup(@Param("classGroupId") Integer classGroupId);
 
     /**
+     * @describe 获取团体或者班级上的学员
+     * @author Joburgess
+     * @date 2020/3/10
+     * @param groupId:
+     * @param groupType:
+     * @param classGroupId:
+     * @return java.util.List<com.ym.mec.biz.dal.dto.SimpleUserDto>
+     */
+    List<ClassGroupStudentInfoDto> findByGroupOrClassGroup(@Param("groupId") String groupId,
+                                               @Param("groupType") GroupType groupType,
+                                               @Param("classGroupId") Integer classGroupId);
+
+    /**
      * 查询班级某状态下所有的学生
      *
      * @param classGroupId
@@ -346,4 +357,18 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
      * @return
      */
     List<ClassGroupStudentMapper> queryNewStudentListByCourseScheduleId(Long courseScheduleId);
+
+    /**
+     * @describe 获取课程组上的学生
+     * @author Joburgess
+     * @date 2020/3/11
+     * @param groupId:
+     * @param groupType:
+     * @param userId:
+     * @return java.util.List<com.ym.mec.biz.dal.entity.ClassGroupStudentMapper>
+     */
+    List<ClassGroupStudentMapper> findGroupStudents(@Param("groupId") String groupId,
+                                                    @Param("groupType") GroupType groupType,
+                                                    @Param("userId") Integer userId,
+                                                    @Param("status") ClassGroupStudentStatusEnum status);
 }

+ 30 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/ClassGroupStudentInfoDto.java

@@ -0,0 +1,30 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/3/10
+ */
+public class ClassGroupStudentInfoDto extends ClassGroupStudentMapper {
+
+    private String avatar;
+
+    private String phone;
+
+    public String getAvatar() {
+        return avatar;
+    }
+
+    public void setAvatar(String avatar) {
+        this.avatar = avatar;
+    }
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+}

+ 110 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/GroupHeadInfoDto.java

@@ -0,0 +1,110 @@
+package com.ym.mec.biz.dal.dto;
+
+import java.util.Date;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/3/10
+ */
+public class GroupHeadInfoDto {
+
+    private String groupId;
+
+    private String groupName;
+
+    private Integer classGroupId;
+
+    private Date courseStartDate;
+
+    private Date courseExpireDate;
+
+    private Integer teacherId;
+
+    private String teacherName;
+
+    private String avatar;
+
+    private Integer lectureNum;
+
+    private String introduction;
+
+    public String getIntroduction() {
+        return introduction;
+    }
+
+    public void setIntroduction(String introduction) {
+        this.introduction = introduction;
+    }
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+
+    public String getGroupName() {
+        return groupName;
+    }
+
+    public void setGroupName(String groupName) {
+        this.groupName = groupName;
+    }
+
+    public Integer getClassGroupId() {
+        return classGroupId;
+    }
+
+    public void setClassGroupId(Integer classGroupId) {
+        this.classGroupId = classGroupId;
+    }
+
+    public Date getCourseStartDate() {
+        return courseStartDate;
+    }
+
+    public void setCourseStartDate(Date courseStartDate) {
+        this.courseStartDate = courseStartDate;
+    }
+
+    public Date getCourseExpireDate() {
+        return courseExpireDate;
+    }
+
+    public void setCourseExpireDate(Date courseExpireDate) {
+        this.courseExpireDate = courseExpireDate;
+    }
+
+    public Integer getTeacherId() {
+        return teacherId;
+    }
+
+    public void setTeacherId(Integer teacherId) {
+        this.teacherId = teacherId;
+    }
+
+    public String getTeacherName() {
+        return teacherName;
+    }
+
+    public void setTeacherName(String teacherName) {
+        this.teacherName = teacherName;
+    }
+
+    public String getAvatar() {
+        return avatar;
+    }
+
+    public void setAvatar(String avatar) {
+        this.avatar = avatar;
+    }
+
+    public Integer getLectureNum() {
+        return lectureNum;
+    }
+
+    public void setLectureNum(Integer lectureNum) {
+        this.lectureNum = lectureNum;
+    }
+}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/SimpleUserDto.java

@@ -16,6 +16,16 @@ public class SimpleUserDto {
 
     private String introduction;
 
+    private String phone;
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
     public SimpleUserDto(Integer userId, String userName) {
         this.userId = userId;
         this.userName = userName;

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/TeacherClassStudentDto.java

@@ -17,9 +17,19 @@ public class TeacherClassStudentDto {
     @ApiModelProperty(value = "头像")
     private String avatar;
 
+    private String phone;
+
     @ApiModelProperty(value = "连续旷课次数")
     private Integer continuousAbsenteeismTimes;
 
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
     public Long getUserId() {
         return userId;
     }

+ 22 - 20
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CoursesGroup.java

@@ -3,6 +3,8 @@ package com.ym.mec.biz.dal.entity;
 import com.ym.mec.biz.dal.enums.GroupStatusEnum;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 
+import java.math.BigDecimal;
+
 /**
  * 对应数据库表(courses_group):
  */
@@ -54,17 +56,33 @@ public class CoursesGroup {
 	private String teacherSalarySettlementMethod;
 	
 	/** 课程总价 */
-	private long totalCoursesPrice;
+	private BigDecimal totalCoursesPrice;
 	
 	/** 课程折扣价 */
-	private long totalCourseDiscountPrice;
+	private BigDecimal totalCourseDiscountPrice;
 	
 	/**  */
 	private java.util.Date createTime;
 	
 	/**  */
 	private java.util.Date updateTime;
-	
+
+	public BigDecimal getTotalCoursesPrice() {
+		return totalCoursesPrice;
+	}
+
+	public void setTotalCoursesPrice(BigDecimal totalCoursesPrice) {
+		this.totalCoursesPrice = totalCoursesPrice;
+	}
+
+	public BigDecimal getTotalCourseDiscountPrice() {
+		return totalCourseDiscountPrice;
+	}
+
+	public void setTotalCourseDiscountPrice(BigDecimal totalCourseDiscountPrice) {
+		this.totalCourseDiscountPrice = totalCourseDiscountPrice;
+	}
+
 	public void setId(Long id){
 		this.id = id;
 	}
@@ -184,23 +202,7 @@ public class CoursesGroup {
 	public String getTeacherSalarySettlementMethod(){
 		return this.teacherSalarySettlementMethod;
 	}
-			
-	public void setTotalCoursesPrice(long totalCoursesPrice){
-		this.totalCoursesPrice = totalCoursesPrice;
-	}
-	
-	public long getTotalCoursesPrice(){
-		return this.totalCoursesPrice;
-	}
-			
-	public void setTotalCourseDiscountPrice(long totalCourseDiscountPrice){
-		this.totalCourseDiscountPrice = totalCourseDiscountPrice;
-	}
-	
-	public long getTotalCourseDiscountPrice(){
-		return this.totalCourseDiscountPrice;
-	}
-			
+
 	public void setCreateTime(java.util.Date createTime){
 		this.createTime = createTime;
 	}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/PracticeGroup.java

@@ -59,6 +59,16 @@ public class PracticeGroup {
 
 	private Long beRenewGroupId;
 
+	private Integer educationalTeacherId;
+
+	public Integer getEducationalTeacherId() {
+		return educationalTeacherId;
+	}
+
+	public void setEducationalTeacherId(Integer educationalTeacherId) {
+		this.educationalTeacherId = educationalTeacherId;
+	}
+
 	public Long getBeRenewGroupId() {
 		return beRenewGroupId;
 	}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/VipGroup.java

@@ -124,6 +124,16 @@ public class VipGroup {
 	@ApiModelProperty(value = "指定学员列表")
 	private String studentIdList;
 
+	private Integer educationalTeacherId;
+
+	public Integer getEducationalTeacherId() {
+		return educationalTeacherId;
+	}
+
+	public void setEducationalTeacherId(Integer educationalTeacherId) {
+		this.educationalTeacherId = educationalTeacherId;
+	}
+
 	public Integer getSubClassTimes() {
 		return subClassTimes;
 	}

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderTypeEnum.java

@@ -12,6 +12,7 @@ public enum OrderTypeEnum implements BaseEnum<String, OrderTypeEnum> {
 	OTHER("OTHER", "其他"),
 	SMALL_CLASS_TO_BUY("SMALL_CLASS_TO_BUY", "小课购买"),
 	PRACTICE_GROUP_BUY("PRACTICE_GROUP_BUY", "网管课购买"),
+	COURSE_GROUP_BUY("COURSE_GROUP_BUY","对外课程购买"),
 	LUCK("LUCK", "福袋活动");
 
 	private String code;

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

@@ -12,7 +12,6 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.BaseService;
 
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -413,4 +412,5 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
      * @return
      */
     Map<String,Object> getUserInfoWithUserId(Integer groupId, Integer userId);
+
 }

+ 13 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupStudentMapperService.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service;
 
+import com.ym.mec.biz.dal.dto.ClassGroupStudentInfoDto;
 import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
@@ -65,4 +66,16 @@ public interface ClassGroupStudentMapperService extends BaseService<Long, ClassG
     List<ClassGroupStudentMapper> findMusicGroupClassGroupByType(String musicGroupId, ClassGroupTypeEnum type);
 
     void classGroupStudentsInsert(List<ClassGroupStudentMapper> classGroupStudentMappers);
+
+    /**
+     * @describe 获取团体或者班级下的学员
+     * @author Joburgess
+     * @date 2020/3/10
+     * @param groupId:
+     * @param classGroupId:
+     * @param groupType:
+     * @return java.util.List<com.ym.mec.biz.dal.dto.ClassGroupStudentInfoDto>
+     */
+    List<ClassGroupStudentInfoDto> findStudentByGroupOrClassGroup(String groupId, Integer classGroupId, GroupType groupType);
+
 }

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CoursesGroupService.java

@@ -2,7 +2,10 @@ package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.dto.CourseGroupCreateDto;
 import com.ym.mec.biz.dal.dto.CourseGroupTeacherCardDto;
+import com.ym.mec.biz.dal.dto.GroupHeadInfoDto;
 import com.ym.mec.biz.dal.entity.CoursesGroup;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.service.BaseService;
 
 import java.util.List;
@@ -27,4 +30,24 @@ public interface CoursesGroupService extends BaseService<Long, CoursesGroup> {
      */
     List<CourseGroupTeacherCardDto> findTeacherCourseGroups(Integer teacherId);
 
+    /**
+     * @describe 获取课程对应班级头部信息
+     * @author Joburgess
+     * @date 2020/3/10
+     * @param courseScheduleId: 课程编号
+     * @return com.ym.mec.biz.dal.dto.GroupHeadInfoDto
+     */
+    GroupHeadInfoDto getGroupHeadInfo(Long courseScheduleId);
+
+    /**
+     * @describe 购买课程组
+     * @author Joburgess
+     * @date 2020/3/11
+     * @param userId:
+     * @param courseGroupId:
+     * @return void
+     */
+    HttpResponseResult buyCourseGroup(Integer userId, Long courseGroupId, boolean isUseBalancePayment);
+
+    void orderCallback(StudentPaymentOrder studentPaymentOrder);
 }

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/TeacherCourseScheduleService.java

@@ -34,4 +34,13 @@ public interface TeacherCourseScheduleService {
      */
     List<CourseScheduleDto> findCourseSchedulesWithDate(Integer teacherId, Date classDate, String groupId, GroupType groupType);
 
+    /**
+     * @describe 根据课程编号获取课程所在课程组的课程
+     * @author Joburgess
+     * @date 2020/3/10
+     * @param courseScheduleId:
+     * @return java.util.List<com.ym.mec.biz.dal.dto.CourseScheduleDto>
+     */
+    List<CourseScheduleDto> findGroupClassesWithCourse(Long courseScheduleId);
+
 }

+ 6 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
+import com.ym.mec.biz.dal.dto.ClassGroupStudentInfoDto;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
@@ -20,7 +21,6 @@ import org.springframework.transaction.annotation.Transactional;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.*;
-import java.util.stream.Collectors;
 
 @Service
 public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, ClassGroupStudentMapper> implements ClassGroupStudentMapperService {
@@ -232,4 +232,9 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
     public void classGroupStudentsInsert(List<ClassGroupStudentMapper> classGroupStudentMappers) {
         classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMappers);
     }
+
+    @Override
+    public List<ClassGroupStudentInfoDto> findStudentByGroupOrClassGroup(String groupId, Integer classGroupId, GroupType groupType) {
+        return classGroupStudentMapperDao.findByGroupOrClassGroup(groupId,groupType,classGroupId);
+    }
 }

+ 314 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CoursesGroupServiceImpl.java

@@ -3,18 +3,23 @@ package com.ym.mec.biz.service.impl;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.biz.dal.dao.*;
-import com.ym.mec.biz.dal.dto.CourseGroupCreateDto;
-import com.ym.mec.biz.dal.dto.CourseGroupTeacherCardDto;
-import com.ym.mec.biz.dal.dto.CourseTimeDto;
-import com.ym.mec.biz.dal.dto.GroupCourseTimesDto;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
-import com.ym.mec.biz.service.CourseScheduleService;
-import com.ym.mec.biz.service.CoursesGroupService;
+import com.ym.mec.biz.service.*;
+import com.ym.mec.common.constant.CommonConstants;
+import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.entity.HttpResponseResult;
+import com.ym.mec.common.entity.ImGroupMember;
+import com.ym.mec.common.entity.ImGroupModel;
 import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.im.ImFeignService;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
@@ -46,6 +51,35 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
     private SubjectDao subjectDao;
     @Autowired
     private ClassGroupStudentMapperDao classGroupStudentMapperDao;
+    @Autowired
+    private TeacherDao teacherDao;
+    @Autowired
+    private IdGeneratorService idGeneratorService;
+    @Autowired
+    private StudentPaymentOrderService studentPaymentOrderService;
+    @Autowired
+    private SysUserCashAccountService sysUserCashAccountService;
+    @Autowired
+    private SysConfigDao sysConfigDao;
+    @Autowired
+    private PayService payService;
+    @Autowired
+    private StudentPaymentOrderDao studentPaymentOrderDao;
+    @Autowired
+    private GroupClassService groupService;
+    @Autowired
+    private SysUserCashAccountDetailService sysUserCashAccountDetailService;
+    @Autowired
+    private ContractService contractService;
+    @Autowired
+    private TeacherService teacherService;
+    @Autowired
+    private ImFeignService imFeignService;
+    @Autowired
+    private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
+
+    private static final Logger LOGGER = LoggerFactory
+            .getLogger(PracticeGroupService.class);
 
     @Override
     public BaseDAO<Long, CoursesGroup> getDAO() {
@@ -218,4 +252,278 @@ public class CoursesGroupServiceImpl extends BaseServiceImpl<Long, CoursesGroup>
         }
         return groupCards;
     }
+
+    @Override
+    public GroupHeadInfoDto getGroupHeadInfo(Long courseScheduleId) {
+        if(Objects.isNull(courseScheduleId)){
+            throw new BizException("请选择课程");
+        }
+        CourseSchedule courseSchedule = courseScheduleDao.get(courseScheduleId);
+        if(Objects.isNull(courseSchedule)){
+            throw new BizException("课程不存在");
+        }
+        CoursesGroup coursesGroup = coursesGroupDao.get(Long.valueOf(courseSchedule.getMusicGroupId()));
+        Teacher teacher = teacherDao.get(courseSchedule.getActualTeacherId());
+
+        GroupHeadInfoDto groupHeadInfo=new GroupHeadInfoDto();
+        groupHeadInfo.setGroupId(coursesGroup.getId().toString());
+        groupHeadInfo.setGroupName(coursesGroup.getName());
+        groupHeadInfo.setClassGroupId(courseSchedule.getClassGroupId());
+        groupHeadInfo.setCourseStartDate(coursesGroup.getCoursesStartDate());
+        groupHeadInfo.setCourseExpireDate(coursesGroup.getCoursesEndDate());
+        groupHeadInfo.setTeacherName(teacher.getRealName());
+        groupHeadInfo.setAvatar(teacher.getAvatar());
+        groupHeadInfo.setIntroduction(teacher.getIntroduction());
+        groupHeadInfo.setLectureNum(teacher.getLectureNum());
+
+        return groupHeadInfo;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
+    public HttpResponseResult buyCourseGroup(Integer userId, Long courseGroupId, boolean isUseBalancePayment) {
+        if(Objects.isNull(courseGroupId)){
+            throw new BizException("请指定课程组");
+        }
+        List<ClassGroupStudentMapper> groupStudents = classGroupStudentMapperDao.findGroupStudents(courseGroupId.toString(), GroupType.COMM, userId, null);
+        if(!CollectionUtils.isEmpty(groupStudents)){
+            throw new BizException("您已购买过此课程组");
+        }
+        CoursesGroup coursesGroup = coursesGroupDao.get(courseGroupId);
+        if(Objects.isNull(coursesGroup)){
+            throw new BizException("此课程组不存在");
+        }
+
+        Date now=new Date();
+
+        ClassGroup classGroup = classGroupDao.findByMusicGroupAndType(courseGroupId.toString(), GroupType.COMM.getCode());
+
+        BigDecimal amount = coursesGroup.getTotalCoursesPrice();
+        if(Objects.isNull(amount)){
+            amount=BigDecimal.ZERO;
+        }
+
+        StudentPaymentOrder studentPaymentOrder=new StudentPaymentOrder();
+        studentPaymentOrder.setUserId(userId);
+        studentPaymentOrder.setGroupType(GroupType.COMM);
+        String orderNo=idGeneratorService.generatorId("payment") + "";
+        studentPaymentOrder.setOrderNo(orderNo);
+        studentPaymentOrder.setStatus(DealStatusEnum.ING);
+        studentPaymentOrder.setType(OrderTypeEnum.COURSE_GROUP_BUY);
+        studentPaymentOrder.setExpectAmount(amount);
+        studentPaymentOrder.setMusicGroupId(coursesGroup.getId().toString());
+        studentPaymentOrder.setActualAmount(studentPaymentOrder.getExpectAmount());
+        studentPaymentOrder.setClassGroupId(classGroup.getId());
+        studentPaymentOrder.setVersion(0);
+
+        if(amount.compareTo(BigDecimal.ZERO)<=0){
+            this.orderCallback(studentPaymentOrder);
+            return BaseController.succeed();
+        }else{
+            studentPaymentOrderService.insert(studentPaymentOrder);
+
+            if(isUseBalancePayment || studentPaymentOrder.getExpectAmount().doubleValue() == 0){
+                SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
+                if(userCashAccount == null){
+                    throw new BizException("用户账户找不到");
+                }
+                studentPaymentOrder.setPaymentChannel("BALANCE");
+                if(userCashAccount.getBalance().subtract(studentPaymentOrder.getExpectAmount()).doubleValue() >= 0){
+                    // 更新订单信息
+                    studentPaymentOrder.setActualAmount(new BigDecimal(0));
+                    studentPaymentOrder.setBalancePaymentAmount(studentPaymentOrder.getExpectAmount());
+                    studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
+                    studentPaymentOrder.setUpdateTime(now);
+                    studentPaymentOrder.setRoutingOrganId(42);
+
+                    sysUserCashAccountService.updateBalance(userId, studentPaymentOrder.getExpectAmount().negate(),PlatformCashAccountDetailTypeEnum.PAY_FEE,"对外课程购买");
+
+                    this.orderCallback(studentPaymentOrder);
+
+                    Map<String,Object> result=new HashMap<>();
+                    result.put("orderNo",studentPaymentOrder.getOrderNo());
+
+                    return BaseController.succeed(result);
+                }else{
+                    if (userCashAccount.getBalance().doubleValue() > 0) {
+                        sysUserCashAccountService.updateBalance(userId, userCashAccount.getBalance().negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "对外课程购买");
+                        amount = studentPaymentOrder.getExpectAmount().subtract(userCashAccount.getBalance());
+                        studentPaymentOrder.setActualAmount(amount);
+                        studentPaymentOrder.setBalancePaymentAmount(userCashAccount.getBalance());
+                    } else {
+                        studentPaymentOrder.setBalancePaymentAmount(new BigDecimal(0));
+                    }
+                }
+            }
+
+            String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
+            Map<String, BigDecimal> classFee = new HashMap<>();
+            classFee.put("course",amount);
+            classFee.put("instrument",BigDecimal.ZERO);
+            classFee.put("accessories",BigDecimal.ZERO);
+            classFee.put("other",BigDecimal.ZERO);
+            try {
+                Map<String,Object> payMap = payService.getPayMap(
+                        amount,
+                        orderNo,
+                        baseApiUrl+"/api-student/studentOrder/notify",
+                        baseApiUrl+"/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
+                        "网管课购买",
+                        coursesGroup.getName(),
+                        userId,
+                        classFee,
+                        null
+                );
+
+                Map<String,BigDecimal> routingFee = (Map<String,BigDecimal>)payMap.get("routingFee");
+                studentPaymentOrder.setRoutingOrganId(42);
+                studentPaymentOrder.setComAmount(routingFee.get("COM"));
+                studentPaymentOrder.setPerAmount(routingFee.get("PER"));
+                studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
+                studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
+                studentPaymentOrder.setUpdateTime(now);
+                studentPaymentOrderService.update(studentPaymentOrder);
+
+                return BaseController.succeed(payMap);
+            } catch (Exception e) {
+                throw new BizException("订单提交超时,请尝试重新提交购买");
+            }
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
+    public void orderCallback(StudentPaymentOrder order) {
+        if(order.getExpectAmount().compareTo(BigDecimal.ZERO)>0){
+            StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.get(order.getId());
+            if(!studentPaymentOrder.getStatus().equals(DealStatusEnum.ING)){
+                return;
+            }
+            SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(order.getUserId());
+            List<StudentPaymentOrder> userGroupOrders = studentPaymentOrderDao.findUserGroupOrders(order.getUserId(), order.getMusicGroupId(), order.getGroupType(),null);
+            Map<DealStatusEnum, Long> statusOrderNumMap = userGroupOrders.stream().collect(Collectors.groupingBy(StudentPaymentOrder::getStatus, Collectors.counting()));
+            Long successOrderNum=statusOrderNumMap.get(DealStatusEnum.SUCCESS);
+            if(Objects.nonNull(successOrderNum)&&successOrderNum>0){
+                if(order.getStatus().equals(DealStatusEnum.FAILED)&&Objects.nonNull(order.getBalancePaymentAmount())&&order.getBalancePaymentAmount().compareTo(BigDecimal.ZERO)>0){
+                    sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "网管课支付失败,退还余额");
+                }
+                if(order.getStatus().equals(DealStatusEnum.SUCCESS)){
+                    sysUserCashAccountService.updateBalance(order.getUserId(), order.getExpectAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "重复支付,退还余额");
+                    order.setMemo("重复支付,进入余额");
+                }
+                studentPaymentOrderDao.update(order);
+                return;
+            }
+
+            Long ingOrderNum=statusOrderNumMap.get(DealStatusEnum.ING);
+            if(Objects.nonNull(ingOrderNum)&&ingOrderNum>1&&order.getStatus().equals(DealStatusEnum.FAILED)){
+                if(Objects.nonNull(order.getBalancePaymentAmount())&&order.getBalancePaymentAmount().compareTo(BigDecimal.ZERO)>0){
+                    sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "网管课支付失败,退还余额");
+                }
+                studentPaymentOrderDao.update(order);
+                return;
+            }
+
+            if(order.getStatus().equals(DealStatusEnum.SUCCESS)){
+                courseScheduleDao.updateGroupCourseLock(order.getMusicGroupId(),GroupType.PRACTICE,0);
+            }else{
+                if(Objects.nonNull(order.getBalancePaymentAmount())&&order.getBalancePaymentAmount().compareTo(BigDecimal.ZERO)>0){
+                    sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "网管课支付失败,退还余额");
+                }
+                studentPaymentOrderDao.update(order);
+                CoursesGroup coursesGroup = coursesGroupDao.get(Long.valueOf(order.getMusicGroupId()));
+                coursesGroup.setStatus(GroupStatusEnum.CANCEL);
+                coursesGroupDao.update(coursesGroup);
+                groupService.deleteGroupOtherInfo(order.getMusicGroupId(),GroupType.PRACTICE);
+                return;
+            }
+            studentPaymentOrderDao.update(order);
+
+            //插入缴费明细
+            //收入
+            SysUserCashAccountDetail sysUserIncomeCashAccountDetail = new SysUserCashAccountDetail();
+            sysUserIncomeCashAccountDetail.setUserId(order.getUserId());
+            sysUserIncomeCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
+            sysUserIncomeCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
+            sysUserIncomeCashAccountDetail.setAmount(order.getActualAmount());
+            sysUserIncomeCashAccountDetail.setBalance(sysUserCashAccount.getBalance().add(order.getActualAmount()));
+            sysUserIncomeCashAccountDetail.setAttribute(order.getTransNo());
+            sysUserIncomeCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+            sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount());
+            sysUserIncomeCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount());
+
+            //支出
+            SysUserCashAccountDetail sysUserExpendCashAccountDetail = new SysUserCashAccountDetail();
+            sysUserExpendCashAccountDetail.setUserId(order.getUserId());
+            sysUserExpendCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.PAY_FEE);
+            sysUserExpendCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
+            sysUserExpendCashAccountDetail.setAmount(order.getActualAmount().negate());
+            sysUserExpendCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
+            sysUserExpendCashAccountDetail.setAttribute(order.getTransNo());
+            sysUserExpendCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
+
+            if(studentPaymentOrder.getComAmount() != null){
+                sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
+            }
+            if(studentPaymentOrder.getPerAmount() != null){
+                sysUserExpendCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
+            }
+
+            sysUserCashAccountDetailService.insert(sysUserIncomeCashAccountDetail);
+            sysUserCashAccountDetailService.insert(sysUserExpendCashAccountDetail);
+
+            CoursesGroup coursesGroup = coursesGroupDao.get(Long.valueOf(order.getMusicGroupId()));
+            if(!coursesGroup.getStatus().equals(GroupStatusEnum.NORMAL)){
+                order.setVersion(order.getVersion()+1);
+                order.setMemo("支付成功,但课程组不处于正常状态");
+                studentPaymentOrderDao.update(order);
+
+                sysUserCashAccountService.updateBalance(order.getUserId(), order.getExpectAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "支付成功,但课程组不处于正常状态");
+
+                return;
+            }
+        }
+        CoursesGroup coursesGroup = coursesGroupDao.get(Long.valueOf(order.getMusicGroupId()));
+        ClassGroup classGroup = classGroupDao.findByMusicGroupAndType(order.getMusicGroupId(), GroupType.COMM.getCode());
+
+        ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
+        classGroupStudentMapper.setMusicGroupId(order.getMusicGroupId());
+        classGroupStudentMapper.setClassGroupId(classGroup.getId());
+        classGroupStudentMapper.setUserId(order.getUserId());
+        classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+        classGroupStudentMapper.setGroupType(GroupType.COMM);
+        classGroupStudentMapperDao.insert(classGroupStudentMapper);
+
+        List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
+        List<CourseSchedule> groupNotStartCourses = courseScheduleDao.findGroupNotStartCourses(order.getMusicGroupId(), GroupType.COMM);
+        if(CollectionUtils.isEmpty(groupNotStartCourses)){
+            throw new BizException("没有剩余课时");
+        }
+        BigDecimal singleCoursePrice = order.getExpectAmount().divide(new BigDecimal(groupNotStartCourses.size()), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
+        for (CourseSchedule courseSchedule : groupNotStartCourses) {
+            //学生缴费记录
+            CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
+            courseScheduleStudentPayment.setGroupType(GroupType.COMM);
+            courseScheduleStudentPayment.setMusicGroupId(order.getMusicGroupId());
+            courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
+            courseScheduleStudentPayment.setUserId(order.getUserId());
+            courseScheduleStudentPayment.setExpectPrice(singleCoursePrice);
+            courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
+            courseScheduleStudentPayments.add(courseScheduleStudentPayment);
+        }
+        courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
+
+        try {
+//            contractService.transferPracticeCoursesContract(order.getUserId(),classGroup.getTotalClassTimes(),practiceGroup.getCoursesStartDate(),practiceGroup.getCoursesExpireDate(),order.getExpectAmount());
+        } catch (Exception e) {
+            LOGGER.error("网管课[{}]购买协议错误:{}",order.getMusicGroupId(),e.getMessage(),e.getMessage());
+        }
+
+        List<ImGroupMember> imGroupMemberList = new ArrayList<>();
+        imGroupMemberList.add(new ImGroupMember(coursesGroup.getTeacherId().toString()));
+        imGroupMemberList.add(new ImGroupMember(order.getUserId().toString()));
+        ImGroupMember[] imGroupMembers = imGroupMemberList.toArray(new ImGroupMember[imGroupMemberList.size()]);
+        // 创建群组
+        imFeignService.groupCreate(new ImGroupModel(classGroup.getId().toString(), imGroupMembers, classGroup.getName()));
+    }
 }

+ 34 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherCourseScheduleServiceImpl.java

@@ -1,17 +1,16 @@
 package com.ym.mec.biz.service.impl;
 
-import com.ym.mec.biz.dal.dao.ClassGroupStudentMapperDao;
-import com.ym.mec.biz.dal.dao.CourseScheduleDao;
-import com.ym.mec.biz.dal.dao.StudentAttendanceDao;
-import com.ym.mec.biz.dal.dao.SubjectDao;
+import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.CourseScheduleDto;
 import com.ym.mec.biz.dal.dto.StudentNameAndPhoneDto;
+import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.SysConfig;
 import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 import com.ym.mec.biz.dal.enums.CourseStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.service.SysConfigService;
 import com.ym.mec.biz.service.TeacherCourseScheduleService;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.util.collection.MapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -116,4 +115,35 @@ public class TeacherCourseScheduleServiceImpl implements TeacherCourseScheduleSe
         }
         return teacherCourseSchedulesWithDate;
     }
+
+    @Override
+    public List<CourseScheduleDto> findGroupClassesWithCourse(Long courseScheduleId) {
+        if(Objects.isNull(courseScheduleId)){
+            throw new BizException("请指定课程");
+        }
+        CourseSchedule currentCourseSchedule = courseScheduleDao.get(courseScheduleId);
+        List<CourseScheduleDto> teacherCourseSchedulesWithDate = courseScheduleDao.findCourseSchedulesWithDate(null,null,currentCourseSchedule.getMusicGroupId(),currentCourseSchedule.getGroupType());
+        List<CourseScheduleDto> notStartClasses=new ArrayList<>();
+        List<CourseScheduleDto> overClasses=new ArrayList<>();
+        CourseScheduleDto currentClasses=null;
+        Date now=new Date();
+        for (CourseScheduleDto courseScheduleDto : teacherCourseSchedulesWithDate) {
+            if(currentCourseSchedule.getId().equals(courseScheduleDto.getId())){
+                currentClasses=courseScheduleDto;
+                continue;
+            }
+            if(courseScheduleDto.getEndClassTime().before(now)){
+                overClasses.add(courseScheduleDto);
+            }else{
+                notStartClasses.add(courseScheduleDto);
+            }
+        }
+
+        List<CourseScheduleDto> courseSchedules=new ArrayList<>();
+        courseSchedules.add(currentClasses);
+        courseSchedules.addAll(notStartClasses);
+        courseSchedules.addAll(overClasses);
+
+        return courseSchedules;
+    }
 }

+ 43 - 0
mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml

@@ -18,6 +18,11 @@
         <result column="status_" property="status" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
     </resultMap>
 
+    <resultMap id="ClassGroupStudentInfoDto" type="com.ym.mec.biz.dal.dto.ClassGroupStudentInfoDto" extends="ClassGroupStudentMapper">
+        <result property="avatar" column="avatar_"/>
+        <result property="phone" column="phone_"/>
+    </resultMap>
+
     <!-- 根据主键查询一条记录 -->
     <select id="get" resultMap="ClassGroupStudentMapper">
 		SELECT * FROM class_group_student_mapper WHERE id_ = #{id} 
@@ -136,6 +141,7 @@
         <result property="userId" column="user_id_"/>
         <result property="userName" column="username_"/>
         <result property="avatar" column="avatar_"/>
+        <result property="phone" column="phone_"/>
         <result property="continuousAbsenteeismTimes" column="continuous_absenteeism_times_"/>
     </resultMap>
 
@@ -144,6 +150,7 @@
             su.id_ user_id_,
             su.username_,
             su.avatar_,
+            su.phone_,
             mgsf.continuous_absenteeism_times_
         FROM
             class_group_student_mapper cgsm
@@ -407,4 +414,40 @@
               #{groupId}
           </foreach>
     </select>
+    <select id="findByGroupOrClassGroup" resultMap="ClassGroupStudentInfoDto">
+        SELECT
+            cgsm.*,
+            su.username_,
+            su.avatar_,
+            su.phone_
+        FROM class_group_student_mapper cgsm
+          LEFT JOIN sys_user su ON cgsm.user_id_ = su.id_
+        <where>
+            <if test="groupType!=null">
+                AND cgsm.group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            </if>
+            <if test="groupId!=null">
+                AND cgsm.music_group_id_ = #{groupId}
+            </if>
+            <if test="classGroupId!=null">
+                AND cgsm.class_group_id_=#{classGroupId}
+            </if>
+        </where>
+    </select>
+    <select id="findGroupStudents" resultMap="ClassGroupStudentMapper">
+        SELECT * FROM class_group_student_mapper
+        WHERE
+            <if test="groupType!=null">
+                AND cgsm.group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            </if>
+            <if test="groupId!=null">
+                AND cgsm.music_group_id_ = #{groupId}
+            </if>
+            <if test="userId!=null">
+                AND user_id_=#{userId}
+            </if>
+            <if test="status!=null">
+                AND status_=#{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+            </if>
+    </select>
 </mapper>

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

@@ -25,6 +25,7 @@
         <result column="group_status_" property="groupStatus"
                 typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
         <result column="be_renew_group_id_" property="beRenewGroupId"/>
+        <result column="educational_teacher_id_" property="educationalTeacherId" />
     </resultMap>
 
     <resultMap id="PracticeCourseDto" type="com.ym.mec.biz.dal.dto.PracticeCourseDto" extends="PracticeGroup">
@@ -76,6 +77,28 @@
         </set>
         WHERE id_ = #{id}
     </update>
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.PracticeGroup">
+		UPDATE practice_group
+		<set>
+			<if test="subjectId!=null">
+				subject_id_=#{subjectId},
+			</if>
+			<if test="memo!=null">
+				memo_=#{memo},
+			</if>
+			<if test="name!=null">
+				name_=#{name},
+			</if>
+			<if test="groupStatus!=null">
+				group_status_=#{groupStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+			</if>
+			<if test="educationalTeacherId!=null">
+				educational_teacher_id_=#{educationalTeacherId},
+			</if>
+			update_time_ = NOW()
+		</set>
+		WHERE id_ = #{id}
+	</update>
 
     <update id="batchUpdate">
         <foreach collection="groups" item="group" separator=";">

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

@@ -41,6 +41,7 @@
         <result column="organ_name_" property="organName" />
         <result column="school_name_" property="schoolName" />
         <result column="subject_name_" property="subjectName" />
+        <result column="educational_teacher_id_" property="educationalTeacherId" />
     </resultMap>
     
     <resultMap type="com.ym.mec.biz.dal.entity.School" id="School">
@@ -282,6 +283,9 @@
             <if test="studentIdList!=null">
                 student_id_list_=#{studentIdList},
             </if>
+            <if test="educationalTeacherId!=null">
+                educational_teacher_id_=#{educationalTeacherId},
+            </if>
         </set>
         WHERE id_ = #{id}
     </update>

+ 3 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/ClassGroupController.java

@@ -5,6 +5,7 @@ import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.entity.CourseScheduleEvaluate;
 import com.ym.mec.biz.dal.page.CourseScheduleQueryInfo;
 import com.ym.mec.biz.service.ClassGroupService;
+import com.ym.mec.biz.service.ClassGroupStudentMapperService;
 import com.ym.mec.biz.service.CourseScheduleEvaluateService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -32,6 +33,8 @@ public class ClassGroupController extends BaseController {
     private CourseScheduleEvaluateService courseScheduleEvaluateService;
     @Autowired
     private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private ClassGroupStudentMapperService classGroupStudentMapperService;
 
     @ApiOperation(value = "教师关联班级获取")
     @GetMapping("/findTeacherClassGroups")