@@ -9,6 +9,7 @@ import com.peanut.common.utils.ShiroUtils;
import com.peanut.modules.common.dao.* ;
import com.peanut.modules.common.entity.* ;
import com.peanut.modules.common.service.MyUserService ;
import com.peanut.modules.common.service.UserVipService ;
import com.peanut.modules.common.to.ParamTo ;
import com.peanut.modules.sociology.service.CourseService ;
import lombok.extern.slf4j.Slf4j ;
@@ -24,6 +25,8 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
@Autowired
private MyUserService userService ;
@Autowired
private UserVipService userVipService ;
@Autowired
private CourseToSociologyDao courseToSociologyDao ;
@Autowired
private CourseToMedicineDao courseToMedicineDao ;
@@ -62,7 +65,6 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
@Override
public Page getSociologyCourseList ( ParamTo param ) {
Integer uId = ShiroUtils . getUId ( ) ;
MyUserEntity user = userDao . selectOne ( new LambdaQueryWrapper < MyUserEntity > ( ) . eq ( MyUserEntity : : getId , uId ) ) ;
MPJLambdaWrapper < CourseEntity > wrapper = new MPJLambdaWrapper < > ( ) ;
wrapper . selectAll ( CourseEntity . class ) ;
wrapper . leftJoin ( CourseToSociologyEntity . class , CourseToSociologyEntity : : getCourseId , CourseEntity : : getId ) ;
@@ -75,11 +77,12 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
List < CourseCatalogueEntity > courseCatalogueEntities = courseCatalogueDao . selectList ( new LambdaQueryWrapper < CourseCatalogueEntity > ( ) . eq ( CourseCatalogueEntity : : getCourseId , c . getId ( ) ) ) ;
if ( courseCatalogueEntities ! = null & & courseCatalogueEntities . size ( ) > 0 ) {
for ( CourseCatalogueEntity cc : courseCatalogueEntities ) {
if ( " 0 " . equals ( user . getVip ( ) ) | | " 2 " . equals ( user . getVip ( ) ) ) {
UserVip userVip = userVipService . ownCourseCatalogueByVip ( cc . getCourseId ( ) ) ;
if ( userVip ! = null ) {
cc . setIsBuy ( 1 ) ;
} else {
Integer cou = userCourseBuyDao . selectCount ( new LambdaQueryWrapper < UserCourseBuyEntity > ( ) . eq ( UserCourseBuyEntity : : getCatalogueId , cc . getId ( ) ) . eq ( UserCourseBuyEntity : : getUserId , uId ) . and ( i - > i . apply ( " end_time IS NULL OR end_time > {0} " , new Date ( ) ) ) ) ;
cc . setIsBuy ( cou > 0 ? 1 : 0 ) ;
} else {
cc . setIsBuy ( 1 ) ;
}
}
}
@@ -123,6 +126,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
if ( StringUtils . isNotEmpty ( course . getRelationProductIds ( ) ) ) {
String [ ] ids = course . getRelationProductIds ( ) . split ( " , " ) ;
List < ShopProduct > shopProductList = shopProductDao . selectList ( new LambdaQueryWrapper < ShopProduct > ( )
. select ( ShopProduct : : getProductId , ShopProduct : : getProductImages , ShopProduct : : getProductName , ShopProduct : : getActivityPrice , ShopProduct : : getPrice )
. in ( ShopProduct : : getProductId , ids )
. orderByAsc ( ShopProduct : : getSort ) ) ;
flag . put ( " shopProductList " , shopProductList ) ;
@@ -132,8 +136,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
Integer uId = ShiroUtils . getUId ( ) ;
for ( CourseCatalogueEntity c : courseCatalogueEntities ) {
List < UserCourseBuyEntity > userCourseBuyList = userCourseBuyDao . selectList ( new LambdaQueryWrapper < UserCourseBuyEntity > ( ) . eq ( UserCourseBuyEntity : : getUserId , uId ) . eq ( UserCourseBuyEntity : : getCatalogueId , c . getId ( ) ) ) ;
//完成度、上次学习时间
catalogueCompletion ( c ) ;
catalogueCompletion ( c ) ; //完成度、上次学习时间
if ( userCourseBuyList . size ( ) > 0 ) {
c . setIsBuy ( 1 ) ;
c . setStartTime ( userCourseBuyList . get ( 0 ) . getStartTime ( ) ) ;
@@ -152,27 +155,32 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
//获取所有国学标签
List < CourseSociologyEntity > courseSociologyEntities = courseSociologyDao . selectList ( null ) ;
MyUserEntity userEntity = userService . getById ( uId ) ;
List < Integer > collect = userCourseBuyDao . selectList ( new LambdaQueryWrapper < UserCourseBuyEntity > ( ) . eq ( UserCourseBuyEntity : : getUserId , userEntity . getId ( ) ) ) . stream ( ) . map ( UserCourseBuyEntity : : getCourseId ) . collect ( Collectors . toList ( ) ) ;
if ( u serEntity . getVip ( ) . equals ( " 0 " ) & & collect . size ( ) = = 0 ) {
return new ArrayList < > ( ) ;
boolean flag = true ;
List < U serVip > userVipList = userVipDao . selectList ( new LambdaQueryWrapper < UserVip > ( )
. eq ( UserVip : : getUserId , ShiroUtils . getUId ( ) )
. eq ( UserVip : : getState , 0 )
. eq ( UserVip : : getType , 6 ) ) ;
if ( userVipList . size ( ) > 0 ) {
flag = false ;
}
Array List< Map > flag = new ArrayList < > ( ) ;
List < Integer > collect = userCourseBuyDao . selectList ( new LambdaQueryWrapper < UserCourseBuyEntity > ( ) . eq ( UserCourseBuyEntity : : getUserId , userEntity . getId ( ) ) ) . stream ( ) . map ( UserCourseBuyEntity : : getCourseId ) . collect ( Collectors . toList ( ) ) ;
ArrayList < Map > resList = new ArrayList < > ( ) ;
for ( CourseSociologyEntity c : courseSociologyEntities ) {
HashMap < String , Object > stringObjectHashMap = new HashMap < > ( ) ;
MPJLambdaWrapper < CourseToSociologyEntity > courseToSociologyEntityMPJLambdaWrapper = new MPJLambdaWrapper < > ( ) ;
courseToSociologyEntityMPJLambdaWrapper . selectAll ( CourseEntity . class ) ;
courseToSociologyEntityMPJLambdaWrapper . leftJoin ( CourseEntity . class , CourseEntity : : getId , CourseToSociologyEntity : : getCourseId ) ;
courseToSociologyEntityMPJLambdaWrapper . eq ( CourseToSociologyEntity : : getSociologyId , c . getId ( ) ) ;
courseToSociologyEntityMPJLambdaWrapper . in ( userEntity . getVip ( ) . equals ( " 0 " ) , CourseToSociologyEntity : : getCourseId , collect ) ;
courseToSociologyEntityMPJLambdaWrapper . in ( flag , CourseToSociologyEntity : : getCourseId , collect ) ;
List < CourseEntity > courseEntities = courseToSociologyDao . selectJoinList ( CourseEntity . class , courseToSociologyEntityMPJLambdaWrapper ) ;
if ( courseEntities . size ( ) = = 0 ) {
continue ;
}
stringObjectHashMap . put ( " sociology " , c ) ;
stringObjectHashMap . put ( " courseList " , courseEntities ) ;
flag . add ( stringObjectHashMap ) ;
resList . add ( stringObjectHashMap ) ;
}
return flag ;
return resList ;
}
@Override
@@ -232,28 +240,26 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
}
private void catalogueCompletion ( CourseCatalogueEntity c ) {
List < CourseCatalogueChapterEntity > courseCatalogueChapterEntities = courseCatalogueChapterDao . selectList ( new LambdaQueryWrapper < CourseCatalogueChapterEntity > ( ) . eq ( CourseCatalogueChapterEntity : : getCatalogueId , c . getId ( ) ) ) ;
Integer act = 0 ;
Date date = null ;
for ( CourseCatalogueChapterEntity cc : courseCatalogueChapterEntities ) {
List < CourseCatalogueChapterVideoEntity > courseCatalogueChapterVideoEntities = courseCatalogueChapterVideoDao . selectList ( new LambdaQueryWrapper < CourseCatalogueChapterVideoEntity > ( ) . eq ( CourseCatalogueChapterVideoEntity : : getChapterId , cc . getId ( ) ) ) ;
List < Integer > collect = courseCatalogueChapterVideoEntities . stream ( ) . map ( CourseCatalogueChapterVideoEntity : : getId ) . collect ( C ollectors . toList ( ) ) ;
if ( collec t. size ( ) = = 0 ) {
continue ;
}
List < UserCourseVideoPositionEntity > videoPositionList = userCourseVideoPositionDao . selectList ( new LambdaQueryWrapper < UserCourseVideoPositionEntity > ( ) . eq ( UserCourseVideoPositionEntity : : getUserId , ShiroUtils . getUId ( ) ) . in ( UserCourseVideoPositionEntity : : getVideoId , collect ) . orderByDesc ( UserCourseVideoPositionEntity : : getCreateTime ) ) ;
if ( videoPositionList . size ( ) > 0 ) {
act + + ;
if ( date ! = null ) {
date = date . getTime ( ) > videoPositionList . get ( 0 ) . getCreateTime ( ) . getTime ( ) ? date : videoPositionList . get ( 0 ) . getCreateTime ( ) ;
} else {
date = videoPositionList . get ( 0 ) . getCreateTime ( ) ;
List < CourseCatalogueChapterEntity > chapterList = courseCatalogueChapterDao . selectList ( new LambdaQueryWrapper < CourseCatalogueChapterEntity > ( ) . eq ( CourseCatalogueChapterEntity : : getCatalogueId , c . getId ( ) ) ) ;
if ( chapterList . size ( ) > 0 ) {
List < Integer > collect = chapterList . stream ( ) . map ( CourseCatalogueChapterEntity : : getId ) . collect ( Collectors . toList ( ) ) ;
List < CourseCatalogueChapterVideo Entity > videoList = courseCatalogueChapterVideoDao
. selectList ( new LambdaQueryWrapper < CourseCatalogueChapterVideoEntity > ( )
. in ( CourseCatalogueChapterVideoEntity : : getChapterId , c ollect) ) ;
if ( videoLis t. size ( ) > 0 ) {
List < Integer > videoCollect = videoList . stream ( ) . map ( CourseCatalogueChapterVideoEntity : : getId ) . collect ( Collectors . toList ( ) ) ;
List < UserCourseVideoPositionEntity > videoPositionList = userCourseVideoPositionDao
. selectList ( new LambdaQueryWrapper < UserCourseVideoPositionEntity > ( )
. eq ( UserCourseVideoPositionEntity : : getUserId , ShiroUtils . getUId ( ) )
. in ( UserCourseVideoPositionEntity : : getVideoId , videoCollect )
. orderByDesc ( UserCourseVideoPositionEntity : : getCreateTime ) ) ;
if ( videoPositionList . size ( ) > 0 ) {
int completion = videoPositionList . size ( ) * 100 / videoList . size ( ) ;
c . setCompletion ( completion ) ;
c . setLastStudyTime ( videoPositionList . get ( 0 ) . getCreateTime ( ) ) ;
}
}
}
int completion = courseCatalogueChapterEntities . size ( ) = = 0 ? 0 : act * 100 / courseCatalogueChapterEntities . size ( ) ;
c . setCompletion ( completion ) ;
c . setLastStudyTime ( date ) ;
}
@Override
@@ -276,7 +282,6 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
@Override
public List getUserCourseStudying ( ) {
MyUserEntity user = ShiroUtils . getUser ( ) ;
MPJLambdaWrapper < CourseEntity > wrapper = new MPJLambdaWrapper < > ( ) ;
wrapper . leftJoin ( CourseToSociologyEntity . class , CourseToSociologyEntity : : getCourseId , CourseEntity : : getId ) ;
wrapper . leftJoin ( UserCourseStudying . class , UserCourseStudying : : getCourseId , CourseEntity : : getId ) ;
@@ -290,19 +295,17 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
if ( courseCatalogueEntities . size ( ) > 0 ) {
//查询目录添加,购买的课程目录详细信息
for ( CourseCatalogueEntity courseCatalogueEntity : courseCatalogueEntities ) {
List < UserVip > userVipList = userVipDao . selectList ( new LambdaQueryWrapper < UserVip > ( ) . eq ( UserVip : : getUserId , user . getId ( ) ) ) ;
List < UserCourseBuyEntity > userCourseBuyList = userCourseBuyDao . selectList ( new LambdaQueryWrapper < UserCourseBuyEntity > ( ) . eq ( UserCourseBuyEntity : : getUserId , ShiroUtils . getUId ( ) ) . eq ( UserCourseBuyEntity : : getCatalogueId , courseCatalogueEntity . getId ( ) ) ) ;
//完成度、上次学习时间
// catalogueCompletion( courseCatalogueEntity) ;
catalogueCompletion( courseCatalogueEntity) ;
//是否购买,生效时间
if ( " 1 " . equals ( user . getVip ( ) ) | | " 3 " . equals ( user . getVip ( ) ) ) {
//是超级会员或者国学会员
if ( userVipList . size ( ) > 0 ) {
courseCatalogueEntity . setStartTime ( userVipList . get ( 0 ) . getStartTime ( ) ) ;
courseCatalogueEntity . setEndTime ( userVipList . get ( 0 ) . getEndTime ( ) ) ;
}
UserVip userVip = userVipService . ownCourseCatalogueByVip ( courseCatalogueEntity . getCourseId ( ) ) ;
if ( userVip ! = null ) {
//是会员
courseCatalogueEntity . setStartTime ( userVip . getStartTime ( ) ) ;
courseCatalogueEntity . setEndTime ( userVip . getEndTime ( ) ) ;
courseCatalogueEntity . setIsBuy ( 1 ) ;
} else if ( " 0 " . equals ( user . getVip ( ) ) ) {
} else {
//普通用户
if ( userCourseBuyList . size ( ) > 0 ) {
courseCatalogueEntity . setIsBuy ( 1 ) ;
@@ -311,24 +314,6 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
} else {
courseCatalogueEntity . setIsBuy ( 0 ) ;
}
} else if ( " 2 " . equals ( user . getVip ( ) ) ) {
//医学会员
//买的国学课程
if ( userCourseBuyList . size ( ) > 0 ) {
courseCatalogueEntity . setIsBuy ( 1 ) ;
courseCatalogueEntity . setStartTime ( userCourseBuyList . get ( 0 ) . getStartTime ( ) ) ;
courseCatalogueEntity . setEndTime ( userCourseBuyList . get ( 0 ) . getEndTime ( ) ) ;
} else {
//医学课程会员免费
List < CourseToMedicine > courseToMedicineList = courseToMedicineDao . selectList ( new LambdaQueryWrapper < CourseToMedicine > ( ) . eq ( CourseToMedicine : : getCourseId , courseCatalogueEntity . getCourseId ( ) ) ) ;
if ( courseToMedicineList . size ( ) > 0 ) {
courseCatalogueEntity . setIsBuy ( 1 ) ;
courseCatalogueEntity . setStartTime ( userVipList . get ( 0 ) . getStartTime ( ) ) ;
courseCatalogueEntity . setEndTime ( userVipList . get ( 0 ) . getEndTime ( ) ) ;
} else {
courseCatalogueEntity . setIsBuy ( 0 ) ;
}
}
}
}
}
@@ -353,26 +338,27 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
@Override
public List getCourseExpire ( Map < String , Object > param ) {
String vip = ShiroUtils . getUser ( ) . getVip ( ) ;
if ( " 0 " . equals ( vip ) | | " 2 " . equals ( vip ) ) {
MPJLambdaWrapper < CourseEntity > wrapper = new MPJLambdaWrapper < > ( ) ;
wrapper . distinct ( ) ;
wrapper . leftJoin ( CourseCatalogueEntity . class , CourseCatalogueEntity : : getCourseId , CourseEntity : : getId ) ;
//关掉本次查询del_flg = 0的条件, 查询过期课程
wrapper . disableSubLogicDel ( ) . rightJoin( User CourseBu yEntity. class , User CourseBu yEntity: : getCatalogu eId , CourseCatalogue Entity : : getId ) ;
wrapper . rightJoin ( CourseToSociologyEntity . class , CourseToSociolog yEntity: : getCour seId , CourseEntity : : getId ) ;
wrapper . eq ( UserCourseBuyEntity : : getUserId , param . get ( " userId " ) ) ;
wrapper . eq ( User CourseBuy Entity: : getDelFlag , - 1 ) ;
wrapper . selectAll ( CourseEntity . class ) ;
wrapper . selectAs ( CourseCatalogueEntity : : getId , " catalogueId " ) ;
wrapper . select As( CourseCatalogue Entity : : getTitle , " catalogueTitle " ) ;
wrapper . orderByAsc ( CourseEntity : : getSort ) ;
wrapper . orderByAsc ( C ourseCatalogueEntity : : getSort ) ;
List courseEntities = this . getBaseMapper ( ) . selectM aps ( wrapper ) ;
return courseEntities ;
} else {
return null ;
List < Map < String , Object > > courseEntities = null ;
MPJLambdaWrapper < CourseEntity > wrapper = new MPJLambdaWrapper < > ( ) ;
wrapper . distinct ( ) ;
wrapper . leftJoin ( CourseCatalogueEntity . class , CourseCatalogueEntity : : getCourseId , CourseEntity : : getId ) ;
//关掉本次查询del_flg = 0的条件, 查询过期课程
wrapper . disableSubLogicDel ( ) . rightJoin ( UserCourseBuyEntity . class , UserCourseBuyEntity : : getCatalogueId , CourseCatalogueEntity : : getId ) ;
wrapper . rightJoin ( CourseToSociolog yEntity . class , CourseToSociolog yEntity : : getCours eId , CourseEntity : : getId ) ;
wrapper . eq ( UserCourseBu yEntity: : getU ser Id , param . get ( " userId " ) ) ;
wrapper . eq ( UserCourseBuyEntity : : getDelFlag , - 1 ) ;
wrapper . selectAll ( CourseEntity . class ) ;
wrapper . selectAs ( CourseCatalogueEntity : : getId , " catalogueId " ) ;
wrapper . selectAs ( CourseCatalogueEntity : : getTitle , " catalogueTitle " ) ;
wrapper . orderBy Asc ( CourseEntity : : getSort ) ;
wrapper . orderByAsc ( CourseCatalogue Entity : : getSort ) ;
List < Map < String , Object > > c ourseList = this . getBaseMapper ( ) . selectMaps ( wrapper ) ;
for ( Map < String , Object > m ap : courseList ) {
if ( ! userVipService . isSociologyVip ( ) ) {
courseEntities . add ( map ) ;
}
}
return courseEntities ;
}
@@ -383,15 +369,14 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
}
}
List < CourseEntity > courseEntities = null ;
//0-普通 1超级vip 2医学vip 3国学vip
if ( " 1 " . equals ( user . getVip ( ) ) | | " 3 " . equals ( user . getVip ( ) ) ) {
if ( userVipService . isSociologyVip ( ) ) {
MPJLambdaWrapper < CourseToSociologyEntity > wrapper = new MPJLambdaWrapper < > ( ) ;
wrapper . leftJoin ( CourseEntity . class , CourseEntity : : getId , CourseToSociologyEntity : : getCourseId ) ;
wrapper . selectAll ( CourseEntity . class ) ;
wrapper . eq ( CourseToSociologyEntity : : getSociologyId , c . getId ( ) ) ;
wrapper . orderByAsc ( CourseEntity : : getSort ) ;
courseEntities = courseToSociologyDao . selectJoinList ( CourseEntity . class , wrapper ) ;
} else if ( " 0 " . equals ( user . getVip ( ) ) ) {
} else {
MPJLambdaWrapper < UserCourseBuyEntity > wrapper = new MPJLambdaWrapper < > ( ) ;
wrapper . leftJoin ( CourseCatalogueEntity . class , CourseCatalogueEntity : : getId , UserCourseBuyEntity : : getCatalogueId ) ;
wrapper . leftJoin ( CourseEntity . class , CourseEntity : : getId , CourseCatalogueEntity : : getCourseId ) ;
@@ -401,23 +386,6 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
wrapper . eq ( CourseToSociologyEntity : : getSociologyId , c . getId ( ) ) ;
wrapper . orderByAsc ( CourseEntity : : getSort ) ;
courseEntities = userCourseBuyDao . selectJoinList ( CourseEntity . class , wrapper ) ;
} else if ( " 2 " . equals ( user . getVip ( ) ) ) {
MPJLambdaWrapper < UserCourseBuyEntity > wrapper = new MPJLambdaWrapper < > ( ) ;
wrapper . leftJoin ( CourseCatalogueEntity . class , CourseCatalogueEntity : : getId , UserCourseBuyEntity : : getCatalogueId ) ;
wrapper . leftJoin ( CourseEntity . class , CourseEntity : : getId , CourseCatalogueEntity : : getCourseId ) ;
wrapper . leftJoin ( CourseToSociologyEntity . class , CourseToSociologyEntity : : getCourseId , UserCourseBuyEntity : : getCourseId ) ;
wrapper . selectAll ( CourseEntity . class ) ;
wrapper . eq ( UserCourseBuyEntity : : getUserId , user . getId ( ) ) ;
wrapper . eq ( CourseToSociologyEntity : : getSociologyId , c . getId ( ) ) ;
wrapper . orderByAsc ( CourseEntity : : getSort ) ;
courseEntities = userCourseBuyDao . selectJoinList ( CourseEntity . class , wrapper ) ;
//添加 国学医学都有的课程
MPJLambdaWrapper < CourseEntity > vipWrapper = new MPJLambdaWrapper < > ( ) ;
vipWrapper . leftJoin ( CourseToSociologyEntity . class , CourseToSociologyEntity : : getCourseId , CourseEntity : : getId ) ;
vipWrapper . exists ( " select * from course_to_medicine where del_flag = 0 and course_id = t.id " ) ;
vipWrapper . eq ( CourseToSociologyEntity : : getSociologyId , c . getId ( ) ) ;
vipWrapper . selectAll ( CourseEntity . class ) ;
courseEntities . addAll ( this . getBaseMapper ( ) . selectList ( vipWrapper ) ) ;
}
if ( courseEntities ! = null & & courseEntities . size ( ) > 0 ) {
for ( CourseEntity co : courseEntities ) {
@@ -428,20 +396,15 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
if ( courseCatalogueEntities . size ( ) > 0 ) {
//查询目录添加,购买的课程目录详细信息
for ( CourseCatalogueEntity courseCatalogueEntity : courseCatalogueEntities ) {
List < UserCourseBuyEntity > userCourseBuyList = userCourseBuyDao . selectList ( new LambdaQueryWrapper < UserCourseBuyEntity > ( ) . eq ( UserCourseBuyEntity : : getUserId , user . getId ( ) ) . eq ( UserCourseBuyEntity : : getCatalogueId , courseCatalogueEntity . getId ( ) ) ) ;
List < UserVip > userVipList = userVipDao . selectList ( new LambdaQueryWrapper < UserVip > ( ) . eq ( UserVip : : getUserId , user . getId ( ) ) ) ;
//完成度、上次学习时间
// catalogueCompletion(courseCatalogueEntity);
//是否购买,生效时间
if ( " 1 " . equals ( user . getVip ( ) ) | | " 3 " . equals ( user . getVip ( ) ) ) {
//是超级会员或者国学会员
if ( userVipList . size ( ) > 0 ) {
courseCatalogueEntity . setStart Time ( userVipList . get( 0 ) . getStart Time ( ) ) ;
courseCatalogueEntity . setEndTime ( userVipList . get ( 0 ) . getEndTime ( ) ) ;
}
UserVip userVip = userVipService . ownCourseCatalogueByVip ( user , courseCatalogueEntity . getCourseId ( ) ) ;
if ( userVip ! = null ) {
courseCatalogueEntity . setStartTime ( userVip . getStartTime ( ) ) ;
courseCatalogueEntity . setEnd Time ( userVip . getEnd Time ( ) ) ;
courseCatalogueEntity . setIsBuy ( 1 ) ;
} else if ( " 0 " . equals ( user . getVip ( ) ) ) {
} else {
//普通用户
List < UserCourseBuyEntity > userCourseBuyList = userCourseBuyDao . selectList ( new LambdaQueryWrapper < UserCourseBuyEntity > ( ) . eq ( UserCourseBuyEntity : : getUserId , user . getId ( ) ) . eq ( UserCourseBuyEntity : : getCatalogueId , courseCatalogueEntity . getId ( ) ) ) ;
if ( userCourseBuyList . size ( ) > 0 ) {
courseCatalogueEntity . setIsBuy ( 1 ) ;
courseCatalogueEntity . setStartTime ( userCourseBuyList . get ( 0 ) . getStartTime ( ) ) ;
@@ -449,24 +412,6 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
} else {
courseCatalogueEntity . setIsBuy ( 0 ) ;
}
} else if ( " 2 " . equals ( user . getVip ( ) ) ) {
//医学会员
//买的国学课程
if ( userCourseBuyList . size ( ) > 0 ) {
courseCatalogueEntity . setIsBuy ( 1 ) ;
courseCatalogueEntity . setStartTime ( userCourseBuyList . get ( 0 ) . getStartTime ( ) ) ;
courseCatalogueEntity . setEndTime ( userCourseBuyList . get ( 0 ) . getEndTime ( ) ) ;
} else {
//医学课程会员免费
List < CourseToMedicine > courseToMedicineList = courseToMedicineDao . selectList ( new LambdaQueryWrapper < CourseToMedicine > ( ) . eq ( CourseToMedicine : : getCourseId , courseCatalogueEntity . getCourseId ( ) ) ) ;
if ( courseToMedicineList . size ( ) > 0 ) {
courseCatalogueEntity . setIsBuy ( 1 ) ;
courseCatalogueEntity . setStartTime ( userVipList . get ( 0 ) . getStartTime ( ) ) ;
courseCatalogueEntity . setEndTime ( userVipList . get ( 0 ) . getEndTime ( ) ) ;
} else {
courseCatalogueEntity . setIsBuy ( 0 ) ;
}
}
}
}
}