Browse Source

活动排课

zouxuan 4 years ago
parent
commit
76f80b789b

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

@@ -261,7 +261,7 @@ public interface VipGroupService extends BaseService<Long, VipGroup> {
      * @param vipGroupId:
      * @return void
      */
-    void enableBuyVipGroup(Integer vipGroupId, Integer userId);
+    void enableBuyVipGroup(Long vipGroupId, Integer userId,String groupType);
 
     /**
      * @Author: Joburgess

+ 36 - 16
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -2550,29 +2550,49 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 //	}
 
 	@Override
-	public void enableBuyVipGroup(Integer vipGroupId, Integer userId) {
+	public void enableBuyVipGroup(Long vipGroupId, Integer userId,String groupType) {
 		if (Objects.isNull(vipGroupId)){
-			throw new BizException("请指定VIP课");
+			throw new BizException("请指定课程组");
 		}
-		VipGroup vipGroup = get(vipGroupId.longValue());
-		if(Objects.nonNull(vipGroup.getStudentIdList())){
-			Set<Integer> userIds = Arrays.asList(vipGroup.getStudentIdList().split(",")).stream().mapToInt(Integer::parseInt).boxed().collect(Collectors.toSet());
-			if(!userIds.contains(userId)){
-				throw new BizException("您无法购买此课程");
+		if("PRACTICE".equals(groupType)){
+			PracticeGroup practiceGroup = practiceGroupService.get(vipGroupId);
+			if(Objects.nonNull(practiceGroup.getStudentId())){
+				if(!practiceGroup.getStudentId().equals(userId)){
+					throw new BizException("您无法购买此课程");
+				}
 			}
-		}
+			ClassGroup classGroup = classGroupDao.findByGroupAndType(vipGroupId.toString(), "PRACTICE");
 
-		ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId.longValue(), null);
+			if(classGroup.getStudentNum()>0 && (VipGroupStatusEnum.APPLYING.equals(practiceGroup.getGroupStatus()))){
+				int i = studentPaymentOrderDao.countGroupOrderWithoutFailed(vipGroupId.toString(), GroupType.PRACTICE);
+				if(i<=0){
+					throw new BizException("该课程已经无法通过购买加入,请联系教务老师!");
+				}
+			}
 
-		if(classGroup.getStudentNum()>0&&(VipGroupStatusEnum.APPLYING.equals(vipGroup.getStatus()))){
-			int i = studentPaymentOrderDao.countGroupOrderWithoutFailed(vipGroupId.toString(), GroupType.VIP);
-			if(i<=0){
-				throw new BizException("该课程已经无法通过购买加入,请联系教务老师!");
+			List<CourseSchedule> courseSchedules = JSON.parseArray(practiceGroup.getCourseScheduleJson(),CourseSchedule.class);
+			courseScheduleService.checkNewCourseSchedules(courseSchedules,false,false);
+		}else {
+			VipGroup vipGroup = get(vipGroupId.longValue());
+			if(Objects.nonNull(vipGroup.getStudentIdList())){
+				Set<Integer> userIds = Arrays.asList(vipGroup.getStudentIdList().split(",")).stream().mapToInt(Integer::parseInt).boxed().collect(Collectors.toSet());
+				if(!userIds.contains(userId)){
+					throw new BizException("您无法购买此课程");
+				}
 			}
-		}
 
-		List<CourseSchedule> courseSchedules = JSON.parseArray(vipGroup.getCourseSchedulesJson(),CourseSchedule.class);
-		courseScheduleService.checkNewCourseSchedules(courseSchedules,false,false);
+			ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId.longValue(), null);
+
+			if(classGroup.getStudentNum()>0&&(VipGroupStatusEnum.APPLYING.equals(vipGroup.getStatus()))){
+				int i = studentPaymentOrderDao.countGroupOrderWithoutFailed(vipGroupId.toString(), GroupType.VIP);
+				if(i<=0){
+					throw new BizException("该课程已经无法通过购买加入,请联系教务老师!");
+				}
+			}
+
+			List<CourseSchedule> courseSchedules = JSON.parseArray(vipGroup.getCourseSchedulesJson(),CourseSchedule.class);
+			courseScheduleService.checkNewCourseSchedules(courseSchedules,false,false);
+		}
 	}
 
 	@Override

+ 2 - 2
mec-student/src/main/java/com/ym/mec/student/controller/StudentVipGroupController.java

@@ -98,12 +98,12 @@ public class StudentVipGroupController extends BaseController {
 
     @ApiOperation(value = "检测vip课成能否购买")
     @GetMapping(value = "/enableBuyGroup")
-    public Object enableBuyGroup(Integer vipGroupId){
+    public Object enableBuyGroup(Long vipGroupId,String groupType){
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if (null == sysUser) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
-        vipGroupService.enableBuyVipGroup(vipGroupId,sysUser.getId());
+        vipGroupService.enableBuyVipGroup(vipGroupId,sysUser.getId(),groupType);
         return succeed();
     }