This commit is contained in:
wangjinlei
2024-09-09 14:14:14 +08:00
parent beb4ef6297
commit a438370d1d
2 changed files with 11 additions and 10 deletions

View File

@@ -70,14 +70,14 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
wrapper.orderByAsc(CourseToSociologyEntity::getSort);
Page<CourseEntity> courseEntityPage = this.getBaseMapper().selectJoinPage(new Page<>(param.getPage(), param.getLimit()),CourseEntity.class, wrapper);
for (CourseEntity c:courseEntityPage.getRecords()){
Integer integer = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>().eq(UserCourseBuyEntity::getCourseId, c.getId()).eq(UserCourseBuyEntity::getUserId,uId));
Integer integer = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>().eq(UserCourseBuyEntity::getCourseId, c.getId()).eq(UserCourseBuyEntity::getUserId,uId).and(i -> i.apply("end_time IS NULL OR end_time > {0}", new Date())));
c.setIsBuy(integer>0?1:0);
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())){
Integer i = userCourseBuyDao.selectCount(new LambdaQueryWrapper<UserCourseBuyEntity>().eq(UserCourseBuyEntity::getCatalogueId, cc.getId()).eq(UserCourseBuyEntity::getUserId,uId));
cc.setIsBuy(i>0?1:0);
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);
}