周箭河 пре 5 година
родитељ
комит
a95c3b2f8b

+ 10 - 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.entity.ClassGroup;
 import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
@@ -35,4 +36,13 @@ public interface ClassGroupStudentMapperService extends BaseService<Long, ClassG
      * @return
      */
     List<StudentRegistration> findClassStudentList(Integer classGroupId, ClassGroupStudentStatusEnum status);
+
+    /**
+     * 调整班级
+     * @param userId
+     * @param oldClassGroupId
+     * @param classGroupId
+     * @return
+     */
+    boolean adjustClassGroup(Integer userId,Integer oldClassGroupId,Integer classGroupId) throws Exception;
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleStudentPaymentService.java

@@ -35,4 +35,14 @@ public interface CourseScheduleStudentPaymentService extends BaseService<Long, C
 	 */
 	void createCourseScheduleStudentPaymentByCourseSchedules(List<CourseSchedule> courseSchedules);
 
+
+	/**
+	 * @return int
+	 * @Author: Joburgess
+	 * @Date: 2019/10/10
+	 * @params [courseScheduleStudentPayments]
+	 * @describe 批量插入
+	 */
+	int batchInsert(List<CourseScheduleStudentPayment> courseScheduleStudentPayments);
+
 }

+ 39 - 0
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.entity.CourseSchedule;
+import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 import com.ym.mec.biz.service.CourseScheduleService;
@@ -16,6 +17,9 @@ import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 @Service
@@ -65,4 +69,39 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
     public List<StudentRegistration> findClassStudentList(Integer classGroupId, ClassGroupStudentStatusEnum status) {
         return classGroupStudentMapperDao.findClassStudentList(classGroupId,status);
     }
+
+    @Override
+    public boolean adjustClassGroup(Integer userId, Integer oldClassGroupId, Integer classGroupId) throws Exception {
+        ClassGroupStudentMapper classStudentMapper = findClassStudentMapperByUserIdAndClassGroupId(userId, oldClassGroupId);
+        if (classStudentMapper == null) {
+            throw new Exception("原班级学生不存在");
+        }
+        Date date = new Date();
+        //1、更新学生对应班级关系
+        classStudentMapper.setClassGroupId(classGroupId);
+        update(classStudentMapper);
+
+        //2、删除学生对应原班级未开始课程
+        List<CourseSchedule> courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(oldClassGroupId);
+        courseScheduleStudentPaymentService.deleteStudentCourseSchedule(userId, courseScheduleList);
+
+        //3、学生加入新班级未开始课程
+        courseScheduleList = courseScheduleService.findNoStartCoursesByClassGroupId(classGroupId);
+
+        BigDecimal coursePrice = new BigDecimal("0");
+        List<CourseScheduleStudentPayment> courseScheduleStudentPayments = new ArrayList<>();
+        for (CourseSchedule courseSchedule : courseScheduleList) {
+            CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
+            courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
+            courseScheduleStudentPayment.setUserId(userId);
+            courseScheduleStudentPayment.setExpectPrice(coursePrice);
+            courseScheduleStudentPayment.setClassGroupId(classGroupId);
+            courseScheduleStudentPayment.setCreateTime(date);
+            courseScheduleStudentPayment.setUpdateTime(date);
+            courseScheduleStudentPayments.add(courseScheduleStudentPayment);
+        }
+
+        courseScheduleStudentPaymentService.batchInsert(courseScheduleStudentPayments);
+        return true;
+    }
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -159,4 +159,9 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 		});
 		courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
 	}
+
+	@Override
+	public int batchInsert(List<CourseScheduleStudentPayment> courseScheduleStudentPayments) {
+		return courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
+	}
 }

+ 12 - 0
mec-web/src/main/java/com/ym/mec/web/controller/ClassGroupStudentController.java

@@ -40,4 +40,16 @@ public class ClassGroupStudentController extends BaseController {
         return succeed(classGroupStudentMapperService.findClassStudentList(classGroupId, ClassGroupStudentStatusEnum.NORMAL));
     }
 
+    @ApiOperation(value = "调整班级(小班课)")
+    @PostMapping("/adjustClassGroup")
+    @PreAuthorize("@pcs.hasPermissions('classGroupStudent/adjustClassGroup')")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "userId", value = "学生userId", required = true, dataType = "int"),
+            @ApiImplicitParam(name = "oldClassGroupId", value = "原班级id", required = true, dataType = "int"),
+            @ApiImplicitParam(name = "classGroupId", value = "新班级id", required = true, dataType = "int")
+    })
+    public HttpResponseResult adjustClassGroup(Integer userId, Integer oldClassGroupId, Integer classGroupId) throws Exception {
+        return succeed(classGroupStudentMapperService.adjustClassGroup(userId, oldClassGroupId, classGroupId));
+    }
+
 }