|
@@ -3,9 +3,12 @@ package com.ym.mec.teacher.controller;
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.TeacherDao;
|
|
|
+import com.ym.mec.biz.dal.dao.VipGroupCategoryDao;
|
|
|
+import com.ym.mec.biz.dal.dto.StudentVipDouble11Dto;
|
|
|
import com.ym.mec.biz.dal.dto.VipGroupApplyDto;
|
|
|
import com.ym.mec.biz.dal.dto.VipGroupCostCountParamsDto;
|
|
|
import com.ym.mec.biz.dal.entity.Teacher;
|
|
|
+import com.ym.mec.biz.dal.entity.VipGroupCategory;
|
|
|
import com.ym.mec.biz.dal.page.StudentManageQueryInfo;
|
|
|
import com.ym.mec.biz.service.StudentManageService;
|
|
|
import com.ym.mec.biz.service.VipGroupService;
|
|
@@ -19,11 +22,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -43,6 +45,8 @@ public class TeacherVipGroupController extends BaseController {
|
|
|
private TeacherDao teacherDao;
|
|
|
@Autowired
|
|
|
private StudentManageService studentManageService;
|
|
|
+ @Autowired
|
|
|
+ private VipGroupCategoryDao vipGroupCategoryDao;
|
|
|
|
|
|
@ApiOperation("vip课申请")
|
|
|
@PostMapping("/vipGroupApply")
|
|
@@ -78,8 +82,42 @@ public class TeacherVipGroupController extends BaseController {
|
|
|
vipGroupApplyDto.getVipGroupApplyBaseInfo().setRegistrationStartTime(new Date());
|
|
|
vipGroupApplyDto.getVipGroupApplyBaseInfo().setPaymentExpireDate(DateUtil.addDays(vipGroupApplyDto.getVipGroupApplyBaseInfo().getRegistrationStartTime(),1));
|
|
|
vipGroupApplyDto.setOnlyProgress(true);
|
|
|
+
|
|
|
+ VipGroupCategory vipGroupCategory = vipGroupCategoryDao.get(vipGroupApplyDto.getVipGroupApplyBaseInfo().getVipGroupCategoryId());
|
|
|
+ if(Objects.isNull(vipGroupCategory)){
|
|
|
+ return failed("课程形式错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> studentIds = Arrays.stream(vipGroupApplyDto.getVipGroupApplyBaseInfo().getStudentIdList().split(",")).map(Integer::valueOf).collect(Collectors.toList());
|
|
|
+ List<StudentVipDouble11Dto> studentDouble11Info = studentManageService.getStudentDouble11Info(studentIds);
|
|
|
+ Map<Integer, StudentVipDouble11Dto> idStudentInfoMap = new HashMap<>();
|
|
|
+ if(!CollectionUtils.isEmpty(studentDouble11Info)){
|
|
|
+ idStudentInfoMap = studentDouble11Info.stream().collect(Collectors.toMap(StudentVipDouble11Dto::getUserId, s->s, (s1, s2)->s1));
|
|
|
+ }
|
|
|
+ for (Integer studentId : studentIds) {
|
|
|
+ StudentVipDouble11Dto studentVipDouble11Dto = idStudentInfoMap.get(studentId);
|
|
|
+ if(Objects.isNull(studentVipDouble11Dto)){
|
|
|
+ return failed("部分学员可排课次不足");
|
|
|
+ }
|
|
|
+ boolean enableApply = false;
|
|
|
+ switch (vipGroupCategory.getStudentNum()){
|
|
|
+ case 1:
|
|
|
+ enableApply = studentVipDouble11Dto.getCourseOneToOneTime()>=vipGroupApplyDto.getVipGroupApplyBaseInfo().getTotalClassTimes();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ enableApply = studentVipDouble11Dto.getCourseOneToTwoTime()>=vipGroupApplyDto.getVipGroupApplyBaseInfo().getTotalClassTimes();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if(!enableApply){
|
|
|
+ return failed("部分学员可排课次不足");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
vipGroupService.createVipGroup(vipGroupApplyDto);
|
|
|
- vipGroupService.addVipGroupStudents(vipGroupApplyDto.getVipGroupApplyBaseInfo().getId(), Arrays.stream(vipGroupApplyDto.getVipGroupApplyBaseInfo().getStudentIdList().split(",")).map(Integer::valueOf).collect(Collectors.toList()));
|
|
|
+ vipGroupService.addVipGroupStudents(vipGroupApplyDto.getVipGroupApplyBaseInfo().getId(), studentIds);
|
|
|
return succeed();
|
|
|
}
|
|
|
|