瀏覽代碼

feat:六一活动排课

Joburgess 4 年之前
父節點
當前提交
5e3fd0bb40

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/VipGroupApplyBaseInfoDto.java

@@ -40,6 +40,17 @@ public class VipGroupApplyBaseInfoDto extends VipGroup {
     @ApiModelProperty(value = "第一个选择的学员")
     private Integer firstStudentId;
 
+    @ApiModelProperty(value = "是否为赠送课程")
+    private Boolean freeCourse=false;
+
+    public Boolean getFreeCourse() {
+        return freeCourse;
+    }
+
+    public void setFreeCourse(Boolean freeCourse) {
+        this.freeCourse = freeCourse;
+    }
+
     public Integer getFirstStudentId() {
         return firstStudentId;
     }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/Student.java

@@ -56,11 +56,22 @@ public class Student extends SysUser {
 
 	private Integer cooperationOrganId;
 
+	@ApiModelProperty(value = "活动排课信息")
+	private String activityCourseDetail;
+
 	public Student(Integer userId, String subjectIdList) {
 		this.userId = userId;
 		this.subjectIdList = subjectIdList;
 	}
 
+	public String getActivityCourseDetail() {
+		return activityCourseDetail;
+	}
+
+	public void setActivityCourseDetail(String activityCourseDetail) {
+		this.activityCourseDetail = activityCourseDetail;
+	}
+
 	public Boolean getIsNewUser() {
 		return isNewUser;
 	}

+ 39 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/ActivityCourseType.java

@@ -0,0 +1,39 @@
+package com.ym.mec.biz.dal.enums;
+
+import com.ym.mec.common.enums.BaseEnum;
+
+/**
+ * @Author Joburgess
+ * @Date 2021/6/10 0010
+ **/
+public enum ActivityCourseType implements BaseEnum<String, ComplaintsStatusEnum> {
+    FREE_VIP("free_vip", "考级活动赠送课"),
+    VIP("free_vip", "考级活动VIP课"),
+    MUSIC_THEORY("music_theory", "考级活动乐理课");
+
+    private String code;
+
+    private String msg;
+
+    ActivityCourseType(String code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+
+    @Override
+    public String getCode() {
+        return null;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentManageQueryInfo.java

@@ -44,6 +44,16 @@ public class StudentManageQueryInfo extends QueryInfo {
 
     private Integer comeOnPackage;
 
+    private String activityCourseType;
+
+    public String getActivityCourseType() {
+        return activityCourseType;
+    }
+
+    public void setActivityCourseType(String activityCourseType) {
+        this.activityCourseType = activityCourseType;
+    }
+
     public Integer getCarePackage() {
         return carePackage;
     }

+ 0 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java

@@ -109,13 +109,6 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
                                                      List<CourseSchedule> vipCourseSchedules,
                                                      BigDecimal onlineTeacherSalary,
                                                      BigDecimal offlineTeacherSalary) {
-
-        School school = schoolService.get(vipGroup.getTeacherSchoolId());
-        BigDecimal subsidy = new BigDecimal(0);
-        if (Objects.nonNull(school)) {
-            subsidy=school.getSubsidy();
-        }
-
         //获取活动信息
         VipGroupActivity vipGroupActivity = null;
         if(vipGroup.getVipGroupActivityId() != null){

+ 110 - 57
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -157,6 +157,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 	private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
 	@Autowired
 	private VipGroupStudentCoursePriceDao vipGroupStudentCoursePriceDao;
+	@Autowired
+	private SysConfigService sysConfigService;
 
 	private static final Logger LOGGER = LoggerFactory
 			.getLogger(VipGroup.class);
@@ -503,11 +505,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			throw new BizException("请设置教学点");
 		}
 
-		String studentIds=vipGroup.getStudentIds();
-		List<String> studentIdList=new ArrayList<>();
-		if(StringUtils.isNotBlank(studentIds)){
-			studentIdList = Arrays.asList(studentIds.split(","));
+		String studentIds=vipGroup.getVipGroupApplyBaseInfo().getStudentIdList();
+		if(StringUtils.isBlank(studentIds)){
+			throw new BizException("请选择学员");
 		}
+		List<Integer> studentIdList = Arrays.stream(studentIds.split(",")).map(id->Integer.valueOf(id)).collect(Collectors.toList());
 
 		Date now=new Date();
 
@@ -604,7 +606,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		//生成vip课信息
 		List<String> bySubIds = subjectDao.findBySubIds(vipGroupApplyBaseInfoDto.getSubjectIdList());
 		StringBuffer className=new StringBuffer();
-		if(Objects.isNull(vipGroupCategory.getMusicTheory())||!vipGroupCategory.getMusicTheory()){
+		if(vipGroupApplyBaseInfoDto.getFreeCourse()){
+			className.append("考前辅导课•");
+		}else if(Objects.isNull(vipGroupCategory.getMusicTheory())||!vipGroupCategory.getMusicTheory()){
 			className.append(StringUtils.join(bySubIds,","));
 			className.append(vipGroupCategory.getName());
 		}else{
@@ -619,19 +623,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 		vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.PASS);
 
-		//如果默认课酬与实际课酬不匹配则需要审批
-		if(costInfo.get("offlineTeacherSalary").compareTo(vipGroupApplyBaseInfoDto.getOfflineTeacherSalary())<0||
-				costInfo.get("onlineTeacherSalary").compareTo(vipGroupApplyBaseInfoDto.getOnlineTeacherSalary())<0
-						&&StringUtils.isBlank(studentIds)){
-			vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.ING);
-		}
-
 		vipGroupApplyBaseInfoDto.setTotalPrice(costInfo.get("totalPrice"));
-		if(StringUtils.isNotBlank(studentIds)){
-			vipGroupApplyBaseInfoDto.setStatus(VipGroupStatusEnum.PROGRESS);
-		}else{
-			vipGroupApplyBaseInfoDto.setStatus(VipGroupStatusEnum.APPLYING);
-		}
+		vipGroupApplyBaseInfoDto.setStatus(VipGroupStatusEnum.PROGRESS);
+
 		if(CollectionUtils.isEmpty(vscps)){
 			vscps = new ArrayList<>();
 			for (Integer canBuyStudentId : canBuyStudentIds) {
@@ -642,10 +636,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		if(Objects.isNull(teacher)){
 			throw new BizException("教师不存在");
 		}
-		if(Objects.isNull(teacher.getTeacherOrganId())){
-			throw new BizException("教师部门异常");
-		}
-//        vipGroupApplyBaseInfoDto.setOrganId(Integer.parseInt(teacher.getOrganId()));
+
 		//开课时间为排课的第一节课的开始时间
 		vipGroupApplyBaseInfoDto.setCourseStartDate(firstCourseSchedule.getStartClassTime());
 		//课程结束时间为排课的最后一节课的结束时间
@@ -653,29 +644,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 		vipGroupApplyBaseInfoDto.setPaymentExpireDate(DateUtil.getLastSecondWithDay(vipGroupApplyBaseInfoDto.getPaymentExpireDate()));
 
-		VipGroupDefaultClassesUnitPrice vipGroupDefaultClassesUnitPrice = vipGroupDefaultClassesUnitPriceDao.getByVipGroupCategory(vipGroup.getVipGroupApplyBaseInfo().getVipGroupCategoryId(), vipGroup.getVipGroupApplyBaseInfo().getOrganId());
-
-		if(Objects.isNull(vipGroupDefaultClassesUnitPrice)){
-			vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.ING);
-		}else{
-			if(Objects.nonNull(vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice())
-					&&vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice().compareTo(vipGroupDefaultClassesUnitPrice.getOfflineClassesUnitPrice())!=0){
-				vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.ING);
-			}
-			if(Objects.nonNull(vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice())
-					&&vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice().compareTo(vipGroupDefaultClassesUnitPrice.getOnlineClassesUnitPrice())!=0){
-				vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.ING);
-			}
-		}
-
-		if(StringUtils.isBlank(vipGroupApplyBaseInfoDto.getStudentIdList())){
-			vipGroupApplyBaseInfoDto.setStudentIdList(StringUtils.join(vscps.stream().map(VipGroupStudentCoursePrice::getStudentId).collect(Collectors.toList()), ","));
-		}
-
-		if(vipGroup.getOnlyProgress()){
-			vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.PASS);
-		}
-
 		vipGroupDao.insert(vipGroupApplyBaseInfoDto);
 
 		vscps.forEach(e->e.setVipGroupId(vipGroupApplyBaseInfoDto.getId()));
@@ -687,9 +655,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		ClassGroup classGroup=new ClassGroup();
 		classGroup.setSubjectIdList(vipGroupApplyBaseInfoDto.getSubjectIdList());
 		classGroup.setExpectStudentNum(vipGroupCategory.getStudentNum());
-		if(StringUtils.isNotBlank(studentIds)){
-			classGroup.setStudentNum(studentIdList.size());
-		}
+		classGroup.setStudentNum(studentIdList.size());
 		classGroup.setName(vipGroupApplyBaseInfoDto.getName());
 		classGroup.setExpectStudentNum(vipGroupApplyBaseInfoDto.getStudentNum());
 		classGroup.setTotalClassTimes(totalClassTimes);
@@ -725,6 +691,20 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		classGroupTeacherSalary.setUpdateTime(now);
 		classGroupTeacherSalaryDao.insert(classGroupTeacherSalary);
 
+		//班级学员关联记录
+		List<ClassGroupStudentMapper> classGroupStudentMapperList = new ArrayList<>();
+		for (Integer studentId : studentIdList) {
+			ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
+			classGroupStudentMapper.setMusicGroupId(vipGroupApplyBaseInfoDto.getId().toString());
+			classGroupStudentMapper.setClassGroupId(classGroup.getId());
+			classGroupStudentMapper.setUserId(studentId);
+			classGroupStudentMapper.setCreateTime(now);
+			classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+			classGroupStudentMapper.setGroupType(GroupType.MUSIC);
+			classGroupStudentMapperList.add(classGroupStudentMapper);
+		}
+		classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMapperList);
+
 		//课程信息调整
 		vipGroup.getCourseSchedules().forEach(courseSchedule -> {
 			courseSchedule.setGroupType(GroupType.VIP);
@@ -740,21 +720,96 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			courseSchedule.setName(vipGroupApplyBaseInfoDto.getName());
 			courseSchedule.setOrganId(vipGroupApplyBaseInfoDto.getOrganId());
 		});
-		courseScheduleService.checkNewCourseSchedules(vipGroup.getCourseSchedules(),false,false);
+
 		vipGroupApplyBaseInfoDto.setCourseSchedulesJson(JSON.toJSONString(vipGroup.getCourseSchedules()));
 		vipGroupDao.update(vipGroupApplyBaseInfoDto);
 
-		if(StringUtils.isNotBlank(studentIds)){
-			List<Integer> collect = studentIdList.stream().mapToInt(Integer::parseInt).boxed().collect(Collectors.toList());
-			classGroupService.addStudentIntoClassGroup(vipGroupApplyBaseInfoDto.getId().toString(),classGroup.getId(),collect);
-			createVipGroupCourseScheInfo(vipGroupApplyBaseInfoDto.getId(),classGroup);
+		//创建课程
+		List<CourseSchedule> courseSchedules = vipGroup.getCourseSchedules();
+		courseScheduleService.batchAddCourseSchedule(courseSchedules);
+		//创建老师单节课课酬信息
+		if(vipGroupApplyBaseInfoDto.getFreeCourse()){
+			List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaries = new ArrayList<>();
+			BigDecimal teacherDefaultSalary = new BigDecimal("16.67");
+			SysConfig practiceCourseSalaryConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_SALARY);
+			if(Objects.nonNull(practiceCourseSalaryConfig)&&StringUtils.isNotBlank(practiceCourseSalaryConfig.getParanValue())){
+				teacherDefaultSalary = new BigDecimal(practiceCourseSalaryConfig.getParanValue());
+			}
+			for (CourseSchedule courseSchedule : courseSchedules) {
+				CourseScheduleTeacherSalary courseScheduleTeacherSalary = new CourseScheduleTeacherSalary();
+				courseScheduleTeacherSalary.setCourseScheduleId(courseSchedule.getId());
+				courseScheduleTeacherSalary.setGroupType(GroupType.MUSIC);
+				courseScheduleTeacherSalary.setMusicGroupId(classGroup.getMusicGroupId());
+				courseScheduleTeacherSalary.setTeacherRole(classGroupTeacherMapper.getTeacherRole());
+				courseScheduleTeacherSalary.setUserId(vipGroupApplyBaseInfoDto.getTeacherId().intValue());
+				courseScheduleTeacherSalary.setExpectSalary(teacherDefaultSalary);
+				courseScheduleTeacherSalary.setCreateTime(now);
+				courseScheduleTeacherSalary.setUpdateTime(now);
+				courseScheduleTeacherSalary.setClassGroupId(classGroup.getId());
+				courseScheduleTeacherSalaries.add(courseScheduleTeacherSalary);
+			}
+			courseScheduleTeacherSalaryDao.batchInsert(courseScheduleTeacherSalaries);
+		}else{
+			courseScheduleTeacherSalaryService.createCourseScheduleTeacherVipSalary(vipGroupApplyBaseInfoDto,
+					courseSchedules,
+					classGroupTeacherSalary.getOnlineClassesSalary(),
+					classGroupTeacherSalary.getSalary());
+		}
+
+		SysUser sysUser = sysUserFeignService.queryUserById(vipGroupApplyBaseInfoDto.getUserId());
+
+		List<ClassGroupStudentMapper> classGroupStudents = classGroupStudentMapperDao.findByClassGroup(classGroup.getId());
+
+		Map<Integer,String> userRoleMap = new HashMap<>();
+		if(Objects.nonNull(vipGroupApplyBaseInfoDto.getEducationalTeacherId())){
+			userRoleMap.put(vipGroupApplyBaseInfoDto.getEducationalTeacherId(),"乐团主管");
+		}
+		userRoleMap.put(vipGroupApplyBaseInfoDto.getUserId(),"指导老师");
+		//生成学生单课缴费信息
+		for (ClassGroupStudentMapper classGroupStudent : classGroupStudents) {
+			if(vipGroupApplyBaseInfoDto.getFreeCourse()){
+				List<CourseScheduleStudentPayment> courseScheduleStudentPayments=new ArrayList<>();
+				for (Integer studentId : studentIdList) {
+					for (CourseSchedule courseSchedule : courseSchedules) {
+						CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
+						courseScheduleStudentPayment.setUserId(studentId);
+						courseScheduleStudentPayment.setGroupType(courseSchedule.getGroupType());
+						courseScheduleStudentPayment.setMusicGroupId(courseSchedule.getMusicGroupId());
+						courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
+						courseScheduleStudentPayment.setClassGroupId(courseSchedule.getClassGroupId());
+						courseScheduleStudentPayment.setExpectPrice(BigDecimal.ZERO);
+						courseScheduleStudentPayment.setOriginalPrice(BigDecimal.ZERO);
+						courseScheduleStudentPayment.setActualPrice(courseScheduleStudentPayment.getExpectPrice());
+						courseScheduleStudentPayments.add(courseScheduleStudentPayment);
+					}
+				}
+				courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
+			}else{
+				courseScheduleStudentPaymentService.createCourseScheduleStudentPaymentForVipGroup(vipGroupApplyBaseInfoDto.getId(),classGroupStudent.getUserId());
+			}
+			userRoleMap.put(classGroupStudent.getUserId(),null);
+			studentDao.updateStudentServiceTag(classGroupStudent.getUserId(), null, YesOrNoEnum.YES.getCode());
+		}
+
+		courseScheduleService.checkNewCourseSchedules(courseSchedules, false,false);
+
+		try {
+			imGroupService.create(classGroup.getId().longValue(), null, classGroup.getName(), classGroup.getName(), vipGroupApplyBaseInfoDto.getName(), null, null, GroupType.VIP.getCode());
+			imGroupMemberService.join(classGroup.getId().longValue(), userRoleMap);
+			imUserFriendService.refreshGroupImUserFriend(classGroup.getMusicGroupId(),classGroup.getGroupType());
+			//发送推送短信
+			Map<Integer,String> map = new HashMap<>(1);
+			map.put(vipGroupApplyBaseInfoDto.getUserId(),sysUser.getPhone());
+			sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.AWSMS,MessageTypeEnum.TEACHER_SMS_VIP_COURSE_ADD,
+					map,null,0,"","",vipGroupApplyBaseInfoDto.getName());
+		} catch (Exception e) {
+			e.printStackTrace();
 		}
 
 		Set<Integer> roleIds = new HashSet<>(1);
 		roleIds.add(SysUserRole.SECTION_MANAGER);
 		Map<String,Long> memo = new HashMap<>(1);
 		memo.put("vipGroupId",vipGroupApplyBaseInfoDto.getId());
-//		SysUser sysUser = sysUserFeignService.queryUserById(vipGroup.getVipGroupApplyBaseInfo().getUserId());
 		if(Objects.isNull(teacher)){
 			throw new BizException("该用户不存在");
 		}
@@ -765,11 +820,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		if(vipGroupApplyBaseInfoDto.getEducationalTeacherId() != null){
 			userIds.add(vipGroupApplyBaseInfoDto.getEducationalTeacherId());
 		}
-//		if (vipGroup.getVipGroupApplyBaseInfo().getUserId() != null){
-//			sysMessageService.batchSeoMessage(userIds,MessageTypeEnum.BACKSTAGE_VIP_COURSE_APPLY, JSONObject.toJSONString(memo),sysUser.getUsername(),sysUser.getUsername());
-//		}else {
+
 		sysMessageService.batchSeoMessage(userIds,MessageTypeEnum.BACKSTAGE_TEACHER_APPLY_VIP, JSONObject.toJSONString(memo),teacher.getRealName());
-//		}
+
 		return BaseController.succeed(vipGroupApplyBaseInfoDto.getAuditStatus().getCode());
 	}
 

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/StudentManageDao.xml

@@ -216,6 +216,9 @@
             <if test="comeOnPackage != null">
                 AND s.come_on_package_ = #{comeOnPackage}
             </if>
+            <if test="activityCourseType!=null and activityCourseType!=''">
+                AND JSON_EXTRACT(activity_course_detail_, CONCAT('$.', #{activityCourseType}))>0
+            </if>
         </where>
     </sql>
 

+ 7 - 0
mec-biz/src/main/resources/config/mybatis/StudentMapper.xml

@@ -22,6 +22,7 @@
         <result column="current_grade_num_" property="currentGradeNum"/>
         <result column="current_class_" property="currentClass"/>
         <result column="cooperation_organ_id_" property="cooperationOrganId"/>
+        <result column="activity_course_detail_" property="activityCourseDetail"/>
     </resultMap>
 
     <!-- 根据主键查询一条记录 -->
@@ -120,6 +121,9 @@
             <if test="currentClass != null">
                 current_class_=#{currentClass},
             </if>
+            <if test="activityCourseDetail != null">
+                activity_course_detail_=#{activityCourseDetail},
+            </if>
                 cooperation_organ_id_=#{cooperationOrganId},
                 update_time_ = NOW()
         </set>
@@ -199,6 +203,9 @@
                 <if test="item.cooperationOrganId != null">
                     cooperation_organ_id_=#{item.cooperationOrganId},
                 </if>
+                <if test="item.activityCourseDetail != null">
+                    activity_course_detail_=#{item.activityCourseDetail},
+                </if>
                 update_time_ = NOW()
             </set>
             WHERE user_id_ = #{item.userId}

+ 24 - 0
mec-web/src/main/java/com/ym/mec/web/controller/VipGroupManageController.java

@@ -167,6 +167,30 @@ public class VipGroupManageController extends BaseController {
         return vipGroupService.createVipGroup(vipGroupApplyDto);
     }
 
+    @ApiOperation(value = "创建六一活动vip课")
+    @PostMapping("/createActivityVipGroup")
+    @PreAuthorize("@pcs.hasPermissions('vipGroupManage/createActivityVipGroup')")
+    public Object createActivityVipGroup(@RequestBody VipGroupApplyDto vipGroupApplyDto){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        Integer userId = vipGroupApplyDto.getVipGroupApplyBaseInfo().getUserId();
+        Teacher teacher = teacherDao.get(userId);
+        if(Objects.isNull(teacher)){
+            return failed("请指定指导老师!");
+        }
+        if(Objects.isNull(vipGroupApplyDto.getVipGroupApplyBaseInfo().getOrganId())){
+            Integer firstStudentId = vipGroupApplyDto.getVipGroupApplyBaseInfo().getFirstStudentId();
+            SysUser student = teacherDao.getUser(firstStudentId);
+            if(Objects.isNull(student)||Objects.isNull(student.getOrganId())){
+                return failed("学员信息异常");
+            }
+            vipGroupApplyDto.getVipGroupApplyBaseInfo().setOrganId(student.getOrganId());
+        }
+        return vipGroupService.createVipGroup(vipGroupApplyDto);
+    }
+
     @ApiOperation(value = "获取教务与指导老师公共分部")
     @GetMapping("/getPublicOrgans")
     @PreAuthorize("@pcs.hasPermissions('vipGroupManage/getPublicOrgans')")

+ 37 - 0
mec-web/src/main/java/com/ym/mec/web/controller/education/EduStudentStudentController.java

@@ -1,11 +1,18 @@
 package com.ym.mec.web.controller.education;
 
+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.entity.Employee;
+import com.ym.mec.biz.dal.page.StudentManageQueryInfo;
 import com.ym.mec.biz.dal.page.StudentQueryInfo;
 import com.ym.mec.biz.service.StudentManageService;
 import com.ym.mec.common.page.QueryInfo;
 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.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -15,6 +22,9 @@ import com.ym.mec.biz.service.StudentAttendanceService;
 import com.ym.mec.biz.service.StudentRegistrationService;
 import com.ym.mec.common.controller.BaseController;
 
+import java.util.Arrays;
+import java.util.List;
+
 /**
  * @Author Joburgess
  * @Date 2020.09.14
@@ -28,6 +38,10 @@ public class EduStudentStudentController extends BaseController {
     private StudentRegistrationService studentRegistrationService;
     @Autowired
     private StudentManageService studentManageService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private EmployeeDao employeeDao;
 
     @ApiOperation(value = "获取某节课学生签到列表")
     @GetMapping("eduStudentAttendance/findStudentAttendance")
@@ -53,4 +67,27 @@ public class EduStudentStudentController extends BaseController {
         return succeed(studentManageService.queryStudentNoStartCourse(queryInfo));
     }
 
+    @ApiOperation(value = "获取学生列表")
+    @GetMapping("/queryStudentList")
+    @PreAuthorize("@pcs.hasPermissions('studentManage/queryStudentList')")
+    public Object queryStudentList(StudentManageQueryInfo queryInfo){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        Employee employee = employeeDao.get(sysUser.getId());
+        if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+            queryInfo.setOrganId(employee.getOrganIdList());
+        }else if(StringUtils.isEmpty(employee.getOrganIdList())){
+            return failed("用户所在分部异常");
+        }else {
+            List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+            if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
+                return failed("非法请求");
+            }
+        }
+        queryInfo.setIsExport(false);
+        return succeed(studentManageService.findStudentsByOrganId(queryInfo));
+    }
+
 }