Browse Source

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

zouxuan 5 years ago
parent
commit
d69690be64
17 changed files with 225 additions and 37 deletions
  1. 12 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentPaymentDao.java
  2. 13 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/VipGroupClassGroupMapperDao.java
  3. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleService.java
  4. 20 0
      mec-biz/src/main/java/com/ym/mec/biz/service/VipGroupService.java
  5. 6 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java
  6. 12 6
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  7. 7 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupDefaultClassesUnitPriceServiceImpl.java
  8. 78 9
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java
  9. 18 1
      mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml
  10. 12 1
      mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml
  11. 2 1
      mec-biz/src/main/resources/config/mybatis/VipGroupActivityMapper.xml
  12. 11 0
      mec-biz/src/main/resources/config/mybatis/VipGroupClassGroupMapperMapper.xml
  13. 2 7
      mec-biz/src/main/resources/config/mybatis/VipGroupMapper.xml
  14. 1 0
      mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java
  15. 9 2
      mec-web/src/main/java/com/ym/mec/web/controller/CourseScheduleController.java
  16. 12 2
      mec-web/src/main/java/com/ym/mec/web/controller/VipGroupDefaultClassesUnitPriceController.java
  17. 8 2
      mec-web/src/main/java/com/ym/mec/web/controller/VipGroupManageController.java

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentPaymentDao.java

@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
@@ -55,4 +56,15 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
      */
     List<StudentAttendanceStatisticsResponse> findStudentByClassGroup(Map<String,Object> params);
     int countStudentByClassGroup(Map<String,Object> params);
+
+    /**
+     * @describe 统计学生剩余课时的费用
+     * @author Joburgess
+     * @date 2019/11/15
+     * @param classGroupId: 班级编号
+     * @param userId: 学生编号
+     * @return java.math.BigDecimal
+     */
+    BigDecimal countSurplusCourseFee(@Param("classGroupId") Integer classGroupId,
+                                     @Param("userId") Integer userId);
 }

+ 13 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/VipGroupClassGroupMapperDao.java

@@ -3,6 +3,9 @@ package com.ym.mec.biz.dal.dao;
 import com.ym.mec.biz.dal.entity.ClassGroup;
 import com.ym.mec.biz.dal.entity.VipGroupClassGroupMapper;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface VipGroupClassGroupMapperDao extends BaseDAO<Long, VipGroupClassGroupMapper> {
 
@@ -22,4 +25,13 @@ public interface VipGroupClassGroupMapperDao extends BaseDAO<Long, VipGroupClass
 	 */
 	ClassGroup findClassGroupByVipGroup(Long vipGroupId);
 
-}
+	/**
+	 * @describe 根据vip课获取关联的班级
+	 * @author Joburgess
+	 * @date 2019/11/15
+	 * @param vipGroupIds: VIP课编号列表
+	 * @return java.util.List<com.ym.mec.biz.dal.entity.ClassGroup>
+	 */
+	List<ClassGroup> findClassGroupsByVipGroups(@Param("vipGroupIds") List<Long> vipGroupIds);
+
+}

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

@@ -13,6 +13,7 @@ import com.ym.mec.biz.dal.page.StudentCourseScheduleRecordQueryInfo;
 import com.ym.mec.biz.dal.page.VipGroupQueryInfo;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
+import org.apache.commons.collections.iterators.ObjectGraphIterator;
 
 import java.util.Date;
 import java.util.List;
@@ -293,5 +294,5 @@ public interface CourseScheduleService extends BaseService<Long, CourseSchedule>
 	 * @param queryInfo:
 	 * @return com.ym.mec.common.page.PageInfo
 	 */
-	PageInfo findVipGroupCourseSchedules(VipGroupQueryInfo queryInfo);
+	Object findVipGroupCourseSchedules(VipGroupQueryInfo queryInfo);
 }

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/VipGroupService.java

@@ -199,6 +199,26 @@ public interface VipGroupService extends BaseService<Long, VipGroup> {
 	 */
 	void applyRefund(Long vipGroupId, Integer studentId);
 
+	/**
+	 * @describe 给指定学生退课
+	 * @author Joburgess
+	 * @date 2019/11/15
+	 * @param vipGroupId: vip课程
+	 * @param studentId: 学生编号
+	 * @return void
+	 */
+	void applyRefundForStudent(Long vipGroupId, Integer studentId, BigDecimal amount);
+
+	/**
+	 * @describe 获取指定学生的剩余课时费用
+	 * @author Joburgess
+	 * @date 2019/11/15
+	 * @param vipGroupId: VIP课编号
+	 * @param studentId: 学生编号
+	 * @return java.util.Map<java.lang.String,java.math.BigDecimal>
+	 */
+	Map<String,BigDecimal> getStudentSurplusCourseFee(Long vipGroupId, Integer studentId);
+
     /**
      * @Author: Joburgess
      * @Date: 2019/10/3

+ 6 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -1105,7 +1105,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 	}
 
 	@Override
-	public PageInfo findVipGroupCourseSchedules(VipGroupQueryInfo queryInfo) {
+	public Object findVipGroupCourseSchedules(VipGroupQueryInfo queryInfo) {
 		PageInfo pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
 
 		if(Objects.isNull(queryInfo.getVipGroupId())){
@@ -1121,7 +1121,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		}
 
 		List<CourseSchedule> dataList;
-		if(StringUtils.isNotEmpty(vipGroup.getCourseSchedulesJson())){
+		if(vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)){
 			dataList=JSON.parseArray(vipGroup.getCourseSchedulesJson(),CourseSchedule.class);
 		}else{
 			dataList=courseScheduleDao.findVipGroupCourseSchedules(vipGroup.getId());
@@ -1133,6 +1133,9 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 			dataList=dataList.stream().skip(pageInfo.getOffset()).limit(pageInfo.getLimit()).collect(Collectors.toList());
 		}
 		pageInfo.setRows(dataList);
-		return pageInfo;
+		Map<String,Object> result=new HashMap<>();
+		result.put("pageInfo",pageInfo);
+		result.put("singleClassMinutes",vipGroup.getSingleClassMinutes());
+		return result;
 	}
 }

+ 12 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -471,10 +471,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                     throw new Exception("班级不存在");
                 }
                 //新增班级学生关系(单技班)
-                classGroupStudentMapperDao.insert(new ClassGroupStudentMapper(classGroupId, userId));
-                //新增班级学生关系(合奏班)
-                ClassGroupRelation classGroupRelation = classGroupRelationDao.findClassGroupRelation(classGroupId);
-                classGroupStudentMapperDao.insert(new ClassGroupStudentMapper(classGroupRelation.getClassGroupId(), userId));
+//                classGroupStudentMapperDao.insert(new ClassGroupStudentMapper(classGroupId, userId));
+//                //新增班级学生关系(合奏班)
+//                ClassGroupRelation classGroupRelation = classGroupRelationDao.findClassGroupRelation(classGroupId);
+//                classGroupStudentMapperDao.insert(new ClassGroupStudentMapper(classGroupRelation.getClassGroupId(), userId));
 
                 //获取当前月
                 Integer month = Integer.parseInt(DateUtil.getMonth(new Date()));
@@ -544,8 +544,14 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getSubjectId());
 
         if (studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS)) {
-
             if (studentRegistration.getTemporaryCourseFee() != null) {
+                //关闭订单
+                StudentPaymentOrder waitPayOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(studentRegistration.getUserId(), studentRegistration.getMusicGroupId(), DealStatusEnum.WAIT_PAY);
+                waitPayOrder.setStatus(DealStatusEnum.CLOSE);
+                studentPaymentOrderService.update(waitPayOrder);
+            }
+
+            if (studentRegistration.getTemporaryCourseFee() == null) {
                 //获取当前月
                 Integer month = Integer.parseInt(DateUtil.getMonth(nowDate));
                 //获取下次缴费月份
@@ -571,11 +577,11 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 musicGroupStudentFee.setSubjectId(studentRegistration.getActualSubjectId());
                 musicGroupStudentFee.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED);
                 musicGroupStudentFeeDao.insert(musicGroupStudentFee);
+                studentRegistration.setTemporaryCourseFee(new BigDecimal(0));
             }
 
             studentRegistration.setPaymentStatus(PaymentStatusEnum.YES);
             studentRegistration.setMusicGroupStatus(ClassGroupStudentStatusEnum.NORMAL);
-            studentRegistration.setTemporaryCourseFee(new BigDecimal(0));
             studentRegistrationDao.update(studentRegistration);
 
             //插入交易明细

+ 7 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupDefaultClassesUnitPriceServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.common.exception.BizException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -9,6 +10,8 @@ import com.ym.mec.biz.service.VipGroupDefaultClassesUnitPriceService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 
+import java.util.Objects;
+
 @Service
 public class VipGroupDefaultClassesUnitPriceServiceImpl extends BaseServiceImpl<Integer, VipGroupDefaultClassesUnitPrice>  implements VipGroupDefaultClassesUnitPriceService {
 	
@@ -22,6 +25,9 @@ public class VipGroupDefaultClassesUnitPriceServiceImpl extends BaseServiceImpl<
 
 	@Override
 	public long insert(VipGroupDefaultClassesUnitPrice bean) {
+		if(Objects.isNull(bean.getOrganId())){
+			throw new BizException("请选择分部");
+		}
 		VipGroupDefaultClassesUnitPrice byVipGroupCategory = vipGroupDefaultClassesUnitPriceDao.getByVipGroupCategory( bean.getVipGroupCategoryId().longValue(),bean.getOrganId().longValue());
 		if(null!=byVipGroupCategory){
 			return vipGroupDefaultClassesUnitPriceDao.updateByVipGroupCategory(bean);
@@ -29,4 +35,4 @@ public class VipGroupDefaultClassesUnitPriceServiceImpl extends BaseServiceImpl<
 			return super.insert(bean);
 		}
 	}
-}
+}

+ 78 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -395,9 +395,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			pageInfo.setTotal(count);
 			params.put("offset", pageInfo.getOffset());
 			dataList = vipGroupDao.findAllByOrgan(params);
-			List<Long> vipGroupIds = dataList.stream().map(vipGroup -> vipGroup.getId()).collect(Collectors.toList());
+			List<Long> vipGroupIds = dataList.stream().map(vipGroup -> vipGroup.getId()).distinct().collect(Collectors.toList());
 			List<Map<Long, Integer>> vipGroupOverCourses = vipGroupDao.countVipGroupOverCourse(vipGroupIds);
 			Map<Long,Integer> vipGroupOverCourseMaps = MapUtil.convertIntegerMap(vipGroupOverCourses);
+			List<ClassGroup> classGroupsByVipGroups = vipGroupClassGroupMapperDao.findClassGroupsByVipGroups(vipGroupIds);
+			Map<String, ClassGroup> vipGroupClassGroupMap = classGroupsByVipGroups.stream().collect(Collectors.toMap(ClassGroup::getMusicGroupId, classGroup -> classGroup));
 			dataList.forEach(vipGroup -> {
 				Integer overCourses = vipGroupOverCourseMaps.get(vipGroup.getId());
 				if(Objects.isNull(overCourses)){
@@ -416,7 +418,12 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 						vipGroup.setMonthConsumeRate(monthConsumeRate);
 					}
 
-
+				}
+				ClassGroup classGroup = vipGroupClassGroupMap.get(vipGroup.getId().toString());
+				if(Objects.nonNull(classGroup)){
+					vipGroup.setStudentNum(classGroup.getStudentNum());
+					vipGroup.setTotalClassTimes(classGroup.getTotalClassTimes());
+					vipGroup.setCurrentClassTimes(classGroup.getCurrentClassTimes());
 				}
 
 			});
@@ -749,12 +756,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		}
 
 		Integer studentPaymentNum=studentPaymentOrderDao.countStudentPaymentNum(vipGroupId.toString());
-
 		if(studentPaymentNum.equals(classGroup.getExpectStudentNum())&&updateVipStatus){
+			classGroup.setDelFlag(YesOrNoEnum.NO);
 			vipGroup.setStatus(VipGroupStatusEnum.FINISH);
 			vipGroupDao.update(vipGroup);
 			createVipGroupCourseScheInfo(vipGroupId);
 		}
+		System.out.println(studentPaymentNum+"------"+JSON.toJSONString(classGroup));
 		classGroupDao.update(classGroup);
 	}
 
@@ -768,8 +776,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		SysUser sysUser = sysUserFeignService.queryUserById(vipGroupApplyBaseInfoDto.getUserId());
 
 		ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId,null);
-        classGroup.setDelFlag(YesOrNoEnum.NO);
-        classGroupDao.update(classGroup);
 
 		ClassGroupTeacherSalary classGroupTeacherSalary = classGroupTeacherSalaryDao.findByVipGoupAndTeacher(vipGroupId.intValue(), vipGroupApplyBaseInfoDto.getUserId());
 
@@ -871,6 +877,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		studentPaymentOrder.setMusicGroupId(vipGroup.getId().toString());
 		studentPaymentOrder.setClassGroupId(vipGroupClassGroupMapper.getClassGroupId());
 
+		contractService.register(user.getId(),user.getRealName(),user.getIdCardNo(),user.getPhone());
+
 		//生成回调地址
 		Map<String,Object> payMap = payService.getPayMap(
 				vipGroup.getTotalPrice(),
@@ -983,6 +991,65 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		studentApplyRefundsDao.insert(studentApplyRefunds);
 	}
 
+	@Override
+	public void applyRefundForStudent(Long vipGroupId, Integer studentId, BigDecimal amount) {
+		if(Objects.isNull(vipGroupId)||Objects.isNull(studentId)){
+			throw new BizException("请指定小课与学生");
+		}
+		if(Objects.isNull(amount)){
+			throw new BizException("请确定退费金额");
+		}
+		VipGroup vipGroup=vipGroupDao.get(vipGroupId);
+		if(Objects.isNull(vipGroup)){
+			throw new BizException("指定的课程不存在");
+		}
+		ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null);
+		sysUserCashAccountService.updateBalance(studentId, amount);
+		SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(studentId);
+		SysUserCashAccountDetail sysUserCashAccountDetail = new SysUserCashAccountDetail();
+		sysUserCashAccountDetail.setUserId(studentId);
+		sysUserCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.REFUNDS);
+		sysUserCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
+		sysUserCashAccountDetail.setAmount(amount);
+		sysUserCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
+		sysUserCashAccountDetail.setAttribute(studentId.toString());
+		sysUserCashAccountDetailDao.insert(sysUserCashAccountDetail);
+
+		ClassGroupStudentMapper classStudentMapperByUserIdAndClassGroupId = classGroupStudentMapperDao.query(classGroup.getId(),
+				studentId);
+
+		classStudentMapperByUserIdAndClassGroupId.setStatus(ClassGroupStudentStatusEnum.QUIT);
+		classGroupStudentMapperDao.update(classStudentMapperByUserIdAndClassGroupId);
+
+		//学员退出班级群
+		ImGroupMember[] imGroupMembers = new ImGroupMember[]{new ImGroupMember(studentId.toString())};
+		imFeignService.groupJoin(new ImGroupModel(classGroup.getId().toString(), imGroupMembers, null));
+	}
+
+	@Override
+	public Map<String, BigDecimal> getStudentSurplusCourseFee(Long vipGroupId, Integer studentId) {
+		if(Objects.isNull(vipGroupId)||Objects.isNull(studentId)){
+			throw new BizException("请指定课程和学生");
+		}
+		VipGroup vipGroup = vipGroupDao.get(vipGroupId);
+		if(Objects.isNull(vipGroup)){
+			throw new BizException("未找到指定vip课");
+		}
+		Map<String,BigDecimal> result=new HashMap<>();
+		if(vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)){
+			StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, studentId, DealStatusEnum.SUCCESS.getCode());
+			result.put("suplusCourseFee",studentPaymentOrder.getActualAmount());
+			return result;
+		}
+		ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null);
+		if(Objects.isNull(classGroup)){
+			throw new BizException("为找到对应班级");
+		}
+		BigDecimal bigDecimal = courseScheduleStudentPaymentDao.countSurplusCourseFee(classGroup.getId(), studentId);
+		result.put("suplusCourseFee",Objects.isNull(bigDecimal)?new BigDecimal(0):bigDecimal);
+		return result;
+	}
+
 	@Transactional(rollbackFor = Exception.class)
 	@Override
 	public void applyRefundAudit(Long id, StudentApplyRefundsStatus status, String remark,BigDecimal amount) {
@@ -1147,7 +1214,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
     	if(Objects.isNull(vipGroup)){
     		throw new BizException("该课程不存在");
 		}
-    	if(vipGroup.getStatus()==VipGroupStatusEnum.FINISH||vipGroup.getStatus()==VipGroupStatusEnum.CANCEL){
+    	if(vipGroup.getStatus()==VipGroupStatusEnum.CANCEL){
     		throw new BizException("该课程已结束或者已被停止,无法进行此操作");
 		}
 		List<CourseSchedule> vipGroupCourseSchedules = courseScheduleDao.findVipGroupCourseSchedules(vipGroupId);
@@ -1163,13 +1230,15 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
     	if(CollectionUtils.isEmpty(maps)||(maps.size()==1&&Objects.isNull(maps.get(0)))){
 			vipGroup.setStatus(VipGroupStatusEnum.CANCEL);
 			vipGroupDao.update(vipGroup);
-			courseScheduleDao.batchDeleteCourseSchedules(courseScheduleIds);
-			courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(courseScheduleIds);
+			if(vipGroup.getStatus().equals(VipGroupStatusEnum.FINISH)){
+				courseScheduleDao.batchDeleteCourseSchedules(courseScheduleIds);
+				courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(courseScheduleIds);
+			}
 			return;
 		}
 		Map<Integer, BigDecimal> studentSurplusClassFees = MapUtil.convertIntegerMap(maps);
     	for(Integer userId:studentSurplusClassFees.keySet()){
-			StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId,userId,DealStatusEnum.SUCCESS.getMsg());
+			StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId,userId,DealStatusEnum.SUCCESS.getCode());
 			if(null==studentPaymentOrder){
 				throw new BizException("未找到相关订单信息!");
 			}

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

@@ -761,7 +761,24 @@
     </select>
     <select id="findVipGroupCourseSchedules" resultMap="CourseSchedule">
         SELECT
-          cs.*
+            cs.id_,
+            cs.class_group_id_,
+            cs.status_,
+            cs.subsidy_,
+            cs.class_date_,
+            CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
+            CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
+            cs.start_class_time_ start_class_time_str_,
+            cs.end_class_time_ end_class_time_str_,
+            cs.teacher_id_,
+            cs.create_time_,
+            cs.update_time_,
+            cs.teach_mode_,
+            cs.type_,
+            cs.name_,
+            cs.student_num_,
+            cs.leave_student_num_,
+            cs.schoole_id_
         FROM
         	course_schedule cs
             LEFT JOIN vip_group_class_group_mapper vgcgm ON vgcgm.class_group_id_ = cs.class_group_id_

+ 12 - 1
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -132,8 +132,19 @@
 		WHERE
 			cs.class_group_id_ = #{classGroupId}
 	</select>
+    <select id="countSurplusCourseFee" resultType="java.math.BigDecimal">
+		SELECT
+			SUM(expect_price_)
+		FROM
+			course_schedule_student_payment cssp
+			LEFT JOIN course_schedule cs ON cssp.course_schedule_id_ = cs.id_
+		WHERE
+			cssp.user_id_ = #{userId}
+			AND cs.status_ = 'NOT_START'
+			AND cs.class_group_id_ = #{classGroupId}
+    </select>
 
-	<delete id="deleteStudentCourseSchedule">
+    <delete id="deleteStudentCourseSchedule">
 		DELETE FROM course_schedule_student_payment WHERE user_id_ = #{userId} AND course_schedule_id_ IN
 		<foreach collection="courseScheduleList" item="courseSchedule" index="index" open="(" close=")" separator=",">
 			#{courseSchedule.id}

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

@@ -131,7 +131,8 @@
 		LEFT JOIN vip_group_category vgc ON FIND_IN_SET(vgc.id_,vga.vip_group_category_id_list_)
 		<include refid="queryCondition"/>
 		GROUP BY vga.id_
-		ORDER BY id_ <include refid="global.limit"/>
+		ORDER BY id_ DESC
+		<include refid="global.limit"/>
 	</select>
 	
 	<!-- 查询当前表的总记录数 -->

+ 11 - 0
mec-biz/src/main/resources/config/mybatis/VipGroupClassGroupMapperMapper.xml

@@ -78,4 +78,15 @@
             LEFT JOIN class_group cg ON vgcgm.class_group_id_=cg.id_
             WHERE vgcgm.vip_group_id_=#{vipGroupId} FOR UPDATE
     </select>
+    <select id="findClassGroupsByVipGroups" resultMap="com.ym.mec.biz.dal.dao.ClassGroupDao.ClassGroup">
+        SELECT
+            cg.*
+        FROM
+            vip_group_class_group_mapper vgcgm
+            LEFT JOIN class_group cg ON vgcgm.class_group_id_=cg.id_
+            WHERE vgcgm.vip_group_id_ IN
+            <foreach collection="vipGroupIds" item="vipGroupId" open="(" close=")" separator=",">
+                #{vipGroupIds}
+            </foreach>
+    </select>
 </mapper>

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

@@ -141,15 +141,10 @@
 		SELECT
             vg.*,
             vga.name_ vip_group_activity_name_,
-            su.username_,
-            cg.student_num_,
-            cg.total_class_times_,
-            cg.current_class_times_
+            su.username_
         FROM
             vip_group vg
             LEFT JOIN sys_user su ON vg.user_id_=su.id_
-            LEFT JOIN vip_group_class_group_mapper vgcgm ON vg.id_=vgcgm.vip_group_id_
-            LEFT JOIN class_group cg ON vgcgm.class_group_id_=cg.id_
             LEFT JOIN vip_group_activity vga ON vg.vip_group_activity_id_=vga.id_
         <include refid="vipGroupQueryCondition"/>
         ORDER BY vg.id_ DESC
@@ -579,7 +574,7 @@
         WHERE vg.id_=#{vipGroupId} AND cs.id_!=NULL AND csts.settlement_time_!=NULL AND csts.actual_salary_&lt;csts.expect_salary_
     </select>
 
-    <select id="countSurplusCourseFee" resultType="java.math.BigDecimal">
+    <select id="countSurplusCourseFee" resultType="map">
         SELECT
             cssp.user_id_ as 'key',
             SUM(cssp.expect_price_) as 'value'

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

@@ -26,6 +26,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;

+ 9 - 2
mec-web/src/main/java/com/ym/mec/web/controller/CourseScheduleController.java

@@ -20,11 +20,13 @@ import com.ym.mec.common.exception.BizException;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import org.apache.commons.lang.ArrayUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.ui.ModelMap;
 import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
@@ -98,8 +100,13 @@ public class CourseScheduleController extends BaseController {
     @ApiOperation(value = "批量删除课程")
     @PostMapping(value = "/bathDelete")
     @PreAuthorize("@pcs.hasPermissions('courseSchedule/bathDelete')")
-    public Object bathDelete(List<Long> courseScheduleIds){
-        scheduleService.deleteCourseSchedules(courseScheduleIds);
+    public Object bathDelete(String courseScheduleIds){
+        if(StringUtils.isEmpty(courseScheduleIds)){
+            throw new BizException("请指定课程编号");
+        }
+        long[] ints = Arrays.asList(courseScheduleIds.split(",")).stream().mapToLong(Long::parseLong).toArray();
+        Long[] longs = ArrayUtils.toObject(ints);
+        scheduleService.deleteCourseSchedules(Arrays.asList(longs));
         return succeed();
     }
 

+ 12 - 2
mec-web/src/main/java/com/ym/mec/web/controller/VipGroupDefaultClassesUnitPriceController.java

@@ -1,12 +1,12 @@
 package com.ym.mec.web.controller;
 
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.entity.VipGroupDefaultClassesUnitPrice;
 import com.ym.mec.biz.service.VipGroupDefaultClassesUnitPriceService;
 import com.ym.mec.common.controller.BaseController;
-
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.Date;
+import java.util.Objects;
 
 @Api(tags = "vip课默认单价")
 @RequestMapping("vipGroupDefaultClassesUnitPrice")
@@ -23,6 +24,8 @@ public class VipGroupDefaultClassesUnitPriceController extends BaseController {
 
 	@Autowired
 	private VipGroupDefaultClassesUnitPriceService vipGroupDefaultClassesUnitPriceService;
+	@Autowired
+	private SysUserFeignService sysUserFeignService;
 
 	@ApiOperation("单查询")
 	@GetMapping(value = "/query")
@@ -42,9 +45,16 @@ public class VipGroupDefaultClassesUnitPriceController extends BaseController {
 	@PostMapping(value = "/add")
     @PreAuthorize("@pcs.hasPermissions('vipGroupDefaultClassesUnitPrice/add')")
 	public Object add(VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice) {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if(sysUser == null){
+			return failed("获取用户信息失败");
+		}
 		Date date = new Date();
 		vipGroupDefaultClassesUnitPrice.setCreateTime(date);
 		vipGroupDefaultClassesUnitPrice.setUpdateTime(date);
+		if(Objects.isNull(vipGroupDefaultClassesUnitPrice.getOrganId())){
+			vipGroupDefaultClassesUnitPrice.setOrganId(sysUser.getOrganId());
+		}
 		vipGroupDefaultClassesUnitPriceService.insert(vipGroupDefaultClassesUnitPrice);
 		return succeed();
 	}

+ 8 - 2
mec-web/src/main/java/com/ym/mec/web/controller/VipGroupManageController.java

@@ -112,8 +112,8 @@ public class VipGroupManageController extends BaseController {
     @ApiOperation(value = "退课申请")
     @PostMapping("/applyRefundForStudent")
     @PreAuthorize("@pcs.hasPermissions('vipGroupManage/applyRefundForStudent')")
-    public Object applyRefundForStudent(Long vipGroupId,Integer studentId){
-        vipGroupService.applyRefund(vipGroupId,studentId);
+    public Object applyRefundForStudent(Long vipGroupId,Integer studentId, BigDecimal amount){
+        vipGroupService.applyRefundForStudent(vipGroupId,studentId,amount);
         return succeed();
     }
 
@@ -245,4 +245,10 @@ public class VipGroupManageController extends BaseController {
         vipGroupService.appendVipGroupCourseSchedules(vipGroupApplyDto);
         return succeed();
     }
+
+    @ApiOperation(value = "获取学生指定vip课的剩余课时费用")
+    @GetMapping(value = "/getStudentSurplusCourseFee")
+    public Object getStudentSurplusCourseFee(Long vipGroupId, Integer studentId){
+        return succeed(vipGroupService.getStudentSurplusCourseFee(vipGroupId,studentId));
+    }
 }