Commit 89742fb6 authored by liuyang's avatar liuyang

更新播放课程验证逻辑

parent d38cdb01
package com.qkdata.biz.web.service;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.qkdata.biz.enums.AccountTypeEnum;
import com.qkdata.biz.enums.CourseAllowEnum;
import com.qkdata.biz.enums.CourseChargeModelEnum;
import com.qkdata.biz.enums.CourseStatusEnum;
import com.qkdata.biz.management.entity.CoursePO;
import com.qkdata.biz.management.entity.UserCourseAuthPO;
import com.qkdata.biz.management.entity.UserFavoritesPO;
import com.qkdata.biz.management.service.CourseService;
import com.qkdata.biz.management.service.UserCourseAuthService;
import com.qkdata.biz.management.service.UserFavoritesService;
import com.qkdata.biz.management.vo.QueryFavoriteCourseModel;
import com.qkdata.biz.sys.service.SysUserService;
......@@ -30,6 +34,8 @@ public class UserCenterService {
private CourseService courseService;
@Autowired
private UserFavoritesService userFavoritesService;
@Autowired
private UserCourseAuthService userCourseAuthService;
/**
* 验证当前登陆用户是否有播放该课程和章节的权限
......@@ -63,34 +69,28 @@ public class UserCenterService {
if (!allow){
throw new BusinessException("当前课程指已定企业观看,您不符合条件,请联系客服务人员");
}
}
if (course.getChargeModel() == CourseChargeModelEnum.FREE){
return;
}else if (course.getChargeModel() == CourseChargeModelEnum.VIP_FREE){
if (userInfo.getVipStartTime() == null || userInfo.getVipEndTime() == null){
throw new BusinessException("您还不是会员,请先成为会员再观看");
}
LocalDateTime now = LocalDateTime.now();
if (!(now.isAfter(userInfo.getVipStartTime()) && now.isBefore(userInfo.getVipEndTime()))){
throw new BusinessException("您的会员已过期,请续费后再观看");
}else {
if (course.getChargeModel() == CourseChargeModelEnum.FREE){
return;
}else if (course.getChargeModel() == CourseChargeModelEnum.VIP_FREE){
if (userInfo.getType() == AccountTypeEnum.USER){
throw new BusinessException("您还不是会员,请先成为会员再观看");
}
LocalDateTime now = LocalDateTime.now();
if (!(now.isAfter(userInfo.getVipStartTime()) && now.isBefore(userInfo.getVipEndTime()))){
throw new BusinessException("您的会员已过期,请续费后再观看");
}
}else if (course.getChargeModel() == CourseChargeModelEnum.PAY){
UserCourseAuthPO authPO = userCourseAuthService.getOne(Wrappers.<UserCourseAuthPO>lambdaQuery().eq(UserCourseAuthPO::getUserId,userId).eq(UserCourseAuthPO::getCourseId,courseId));
if (authPO == null{
throw new BusinessException("当前课程为付费课程,请购买后再观看");
}
LocalDateTime now = LocalDateTime.now();
if (!(now.isAfter(authPO.getStartTime()) && now.isBefore(authPO.getEndTime()))){
throw new BusinessException("您购买的该课程已过期,请重新购买");
}
}
}else if (course.getChargeModel() == CourseChargeModelEnum.PAY){
// UserGetVipRecordPO userGetVipRecordPO = userGetVipRecordService.getOne(Wrappers.<UserGetVipRecordPO>lambdaQuery()
// .eq(UserGetVipRecordPO::getUserId,userId)
// .eq(UserGetVipRecordPO::getCourseId,courseId)
// .eq(UserGetVipRecordPO::getType,UserPayRecordTypeEnum.SINGLE_COURSE)
// .orderByDesc(BasePO::getCreateTime)
// .last("limit 1"));
// if (userGetVipRecordPO == null){
// throw new BusinessException("当前课程为付费课程,请购买后再观看");
// }
// Integer validPeriod = course.getValidPeriod();
// LocalDateTime startTime = userGetVipRecordPO.getCreateTime();
// LocalDateTime endTime = startTime.plusHours(validPeriod);
// LocalDateTime now = LocalDateTime.now();
// if (!(now.isAfter(startTime) && now.isBefore(endTime))){
// throw new BusinessException("您购买的该课程已过期,请重新购买");
// }
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment