Browse Source

Merge branch 'active_course_2021-09-26~29' of http://git.dayaedu.com/yonge/mec

zouxuan 4 years ago
parent
commit
34d305d12f

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ActivityUserMapperDao.java

@@ -52,7 +52,7 @@ public interface ActivityUserMapperDao extends BaseDAO<Integer, ActivityUserMapp
      * @author zx
      * @date 2021/10/15 15:53
      */
-    int use(@Param("activityUserMapperIds") String activityUserMapperIds,
+    Integer use(@Param("activityUserMapperIds") String activityUserMapperIds,
             @Param("studentIds") String studentIds,
             @Param("type") String type,
             @Param("groupId") Long groupId);

+ 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

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

@@ -4833,7 +4833,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         practiceGroupDao.insert(applyBaseInfo);
         //消耗排课资格
         List<Integer> activityUserMapperIds = activityUserMappers.stream().map(e -> e.getId()).collect(Collectors.toList());
-        int use = activityUserMapperService.use(StringUtils.join(activityUserMapperIds), studentId.toString(), giveFlag ? "GIVE_PRACTICE" : "PRACTICE", applyBaseInfo.getId());
+        int use = activityUserMapperService.use(StringUtils.join(activityUserMapperIds,","), studentId.toString(), giveFlag ? "GIVE_PRACTICE" : "PRACTICE", applyBaseInfo.getId());
         if(use != 1){
             throw new BizException("网管课创建失败,请联系管理员");
         }

+ 37 - 17
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -1038,7 +1038,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 		//消耗排课资格
 		List<Integer> activityUserMapperIds = activityUserMappers.stream().map(e -> e.getId()).collect(Collectors.toList());
-		int use = activityUserMapperService.use(StringUtils.join(activityUserMapperIds), studentIds, giveFlag?"GIVE_VIP":"VIP", applyBaseInfo.getId());
+		int use = activityUserMapperService.use(StringUtils.join(activityUserMapperIds,","), studentIds, giveFlag?"GIVE_VIP":"VIP", applyBaseInfo.getId());
 		if(use != studentIdList.size()){
 			throw new BizException("VIP课创建失败,请联系管理员");
 		}
@@ -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

+ 10 - 8
mec-biz/src/main/resources/config/mybatis/ActivityUserMapperMapper.xml

@@ -104,22 +104,24 @@
 		</set>WHERE id_ = #{id}
 	</update>
 	<update id="use">
+		UPDATE activity_user_mapper SET
 		<if test="type == 'VIP'">
-			UPDATE activity_user_mapper SET vip_flag_ = 2,vip_group_id_ = #{groupId},update_time_ = NOW()
-			WHERE FIND_IN_SET(id_,#{activityUserMapperIds}) AND FIND_IN_SET(user_id_,#{studentIds}) AND return_fee_ = 0 AND vip_flag_ = 1;
+			vip_flag_ = 2,vip_group_id_ = #{groupId},update_time_ = NOW()
+			WHERE vip_flag_ = 1
 		</if>
 		<if test="type == 'GIVE_VIP'">
-			UPDATE activity_user_mapper SET give_vip_flag_ = 2,give_vip_group_id_ = #{groupId},update_time_ = NOW()
-			WHERE FIND_IN_SET(id_,#{activityUserMapperIds}) AND FIND_IN_SET(user_id_,#{studentIds}) AND return_fee_ = 0 AND give_vip_flag_ = 1;
+			give_vip_flag_ = 2,give_vip_group_id_ = #{groupId},update_time_ = NOW()
+			WHERE give_vip_flag_ = 1
 		</if>
 		<if test="type == 'PRACTICE'">
-			UPDATE activity_user_mapper SET practice_flag_ = 2,practice_group_id_ = #{groupId},update_time_ = NOW()
-			WHERE FIND_IN_SET(id_,#{activityUserMapperIds}) AND FIND_IN_SET(user_id_,#{studentIds}) AND return_fee_ = 0 AND practice_flag_ = 1;
+			practice_flag_ = 2,practice_group_id_ = #{groupId},update_time_ = NOW()
+			WHERE practice_flag_ = 1
 		</if>
 		<if test="type == 'GIVE_PRACTICE'">
-			UPDATE activity_user_mapper SET give_practice_flag_ = 2,give_practice_group_id_ = #{groupId},update_time_ = NOW()
-			WHERE FIND_IN_SET(id_,#{activityUserMapperIds}) AND FIND_IN_SET(user_id_,#{studentIds}) AND return_fee_ = 0 AND give_practice_flag_ = 1;
+			give_practice_flag_ = 2,give_practice_group_id_ = #{groupId},update_time_ = NOW()
+			WHERE give_practice_flag_ = 1
 		</if>
+		AND FIND_IN_SET(id_,#{activityUserMapperIds}) AND FIND_IN_SET(user_id_,#{studentIds}) AND return_fee_ = 0
 	</update>
 
 	<!-- 根据主键删除一条记录 -->

+ 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();
     }