|
@@ -3,9 +3,11 @@ 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.dao.EmployeeDao;
|
|
|
+import com.ym.mec.biz.dal.dao.StudentDao;
|
|
|
import com.ym.mec.biz.dal.dao.TeacherDao;
|
|
|
import com.ym.mec.biz.dal.dto.VipGroupActivityAddDto;
|
|
|
import com.ym.mec.biz.dal.entity.Employee;
|
|
|
+import com.ym.mec.biz.dal.entity.Student;
|
|
|
import com.ym.mec.biz.dal.page.VipGroupActivityQueryInfo;
|
|
|
import com.ym.mec.biz.service.VipGroupActivityService;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
@@ -17,11 +19,13 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Author Joburgess
|
|
@@ -41,6 +45,8 @@ public class VipGroupActivityController extends BaseController {
|
|
|
private EmployeeDao employeeDao;
|
|
|
@Autowired
|
|
|
private TeacherDao teacherDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentDao studentDao;
|
|
|
|
|
|
@ApiOperation(value = "新增vip课活动方案")
|
|
|
@PostMapping("/addVipGroupActivity")
|
|
@@ -98,16 +104,28 @@ public class VipGroupActivityController extends BaseController {
|
|
|
@ApiOperation(value = "根据课程类型获取对应课程活动方案")
|
|
|
@GetMapping("/findByVipGroupCategory")
|
|
|
@PreAuthorize("@pcs.hasPermissions('vipGroupActivity/findByVipGroupCategory')")
|
|
|
- public Object findByVipGroupCategory(Long categoryId, Integer firstStudentId, Integer teacherId){
|
|
|
- String organIds = new String();
|
|
|
- if(Objects.nonNull(firstStudentId)){
|
|
|
- SysUser student = teacherDao.getUser(firstStudentId);
|
|
|
- if(Objects.isNull(student)){
|
|
|
- return failed("学员信息不存在");
|
|
|
- }
|
|
|
- organIds = student.getOrganId().toString();
|
|
|
+ public Object findByVipGroupCategory(Long categoryId, String studentIds, Integer teacherId){
|
|
|
+ if(StringUtils.isBlank(studentIds)){
|
|
|
+ return failed("请选择学员");
|
|
|
+ }
|
|
|
+ List<Integer> userIds = Arrays.stream(studentIds.split(",")).map(id -> Integer.valueOf(id)).collect(Collectors.toList());
|
|
|
+ List<Student> students = studentDao.findByStudentIds(userIds);
|
|
|
+ if(CollectionUtils.isEmpty(students)||students.size()!=userIds.size()){
|
|
|
+ return failed("学员信息不存在");
|
|
|
+ }
|
|
|
+ long newStudentNum = students.stream().filter(s -> s.getIsNewUser()).count();
|
|
|
+
|
|
|
+ Integer applyToStudentType = null;
|
|
|
+ if(newStudentNum!=userIds.size()){
|
|
|
+ applyToStudentType = -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ SysUser student = teacherDao.getUser(userIds.get(0));
|
|
|
+ if(Objects.isNull(student)){
|
|
|
+ return failed("学员信息不存在");
|
|
|
}
|
|
|
- return succeed(vipGroupActivityService.findByVipGroupCategory(categoryId, organIds, teacherId));
|
|
|
+ String organIds = student.getOrganId().toString();
|
|
|
+ return succeed(vipGroupActivityService.findByVipGroupCategory(categoryId, organIds, teacherId, applyToStudentType));
|
|
|
}
|
|
|
|
|
|
}
|