我的课程-修改
This commit is contained in:
@@ -3,6 +3,7 @@ package com.peanut.modules.medical.service.impl;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.github.yulichang.toolkit.JoinWrappers;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import com.peanut.common.utils.ShiroUtils;
|
import com.peanut.common.utils.ShiroUtils;
|
||||||
import com.peanut.modules.common.dao.*;
|
import com.peanut.modules.common.dao.*;
|
||||||
@@ -27,11 +28,13 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
|||||||
@Autowired
|
@Autowired
|
||||||
MyUserDao userDao;
|
MyUserDao userDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private CourseToMedicineDao toMedicineDao;
|
private CourseToSociologyDao courseToSociologyDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private CourseCatalogueDao courseCatalogueDao;
|
private CourseCatalogueDao courseCatalogueDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserCourseBuyDao courseBuyDao;
|
private UserCourseBuyDao userCourseBuyDao;
|
||||||
|
@Autowired
|
||||||
|
private UserVipDao userVipDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<CourseEntity> getMedicalCourseList(ParamTo param) {
|
public Page<CourseEntity> getMedicalCourseList(ParamTo param) {
|
||||||
@@ -107,13 +110,24 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
|||||||
@Override
|
@Override
|
||||||
public Page<CourseEntity> getUserCourseBuy(Map<String, Object> param) {
|
public Page<CourseEntity> getUserCourseBuy(Map<String, Object> param) {
|
||||||
MyUserEntity user =ShiroUtils.getUser();
|
MyUserEntity user =ShiroUtils.getUser();
|
||||||
MPJLambdaWrapper<CourseToMedicine> wrapper = new MPJLambdaWrapper<>();
|
MPJLambdaWrapper<CourseEntity> wrapper = new MPJLambdaWrapper<>();
|
||||||
wrapper.leftJoin(CourseEntity.class,CourseEntity::getId,CourseToMedicine::getCourseId);
|
wrapper.leftJoin(CourseToMedicine.class,CourseToMedicine::getCourseId,CourseEntity::getId);
|
||||||
//0-普通 1超级vip 2医学vip 3国学vip
|
//0-普通 1超级vip 2医学vip 3国学vip
|
||||||
if ("0".equals(user.getVip())||"3".equals(user.getVip())){
|
if ("0".equals(user.getVip())||"3".equals(user.getVip())){
|
||||||
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getCourseId,CourseEntity::getId);
|
wrapper.leftJoin(CourseCatalogueEntity.class,CourseCatalogueEntity::getCourseId,CourseEntity::getId);
|
||||||
wrapper.leftJoin(UserCourseBuyEntity.class,UserCourseBuyEntity::getCatalogueId,CourseCatalogueEntity::getId);
|
wrapper.leftJoin(UserCourseBuyEntity.class,UserCourseBuyEntity::getCatalogueId,CourseCatalogueEntity::getId);
|
||||||
wrapper.eq(UserCourseBuyEntity::getUserId,user.getId());
|
wrapper.eq(UserCourseBuyEntity::getUserId,user.getId());
|
||||||
|
if ("3".equals(user.getVip())){
|
||||||
|
MPJLambdaWrapper<CourseEntity> vipWrapper = new MPJLambdaWrapper<>(CourseEntity.class);
|
||||||
|
vipWrapper.leftJoin(CourseToMedicine.class,CourseToMedicine::getCourseId,CourseEntity::getId);
|
||||||
|
vipWrapper.exists("select * from course_to_sociology where del_flag = 0 and course_id = t.id");
|
||||||
|
vipWrapper.selectAll(CourseEntity.class);
|
||||||
|
vipWrapper.first("(");
|
||||||
|
vipWrapper.last(")");
|
||||||
|
wrapper.first("(");
|
||||||
|
wrapper.last(")");
|
||||||
|
wrapper.union(vipWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(param.get("medicalId").toString())){
|
if (StringUtils.isNotEmpty(param.get("medicalId").toString())){
|
||||||
wrapper.eq(CourseToMedicine::getMedicalId,param.get("medicalId"));
|
wrapper.eq(CourseToMedicine::getMedicalId,param.get("medicalId"));
|
||||||
@@ -124,21 +138,61 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, CourseEntity> impl
|
|||||||
wrapper.distinct();
|
wrapper.distinct();
|
||||||
wrapper.selectAll(CourseEntity.class);
|
wrapper.selectAll(CourseEntity.class);
|
||||||
wrapper.orderByAsc(CourseEntity::getSort);
|
wrapper.orderByAsc(CourseEntity::getSort);
|
||||||
Page<CourseEntity> courseEntityPage = toMedicineDao.selectJoinPage(new Page<>(Long.parseLong(param.get("page").toString()), Long.parseLong(param.get("limit").toString())), CourseEntity.class, wrapper);
|
Page<CourseEntity> courseEntityPage = this.getBaseMapper().selectJoinPage(new Page<>(Long.parseLong(param.get("page").toString()), Long.parseLong(param.get("limit").toString())), CourseEntity.class, wrapper);
|
||||||
List<CourseEntity> courseEntities = courseEntityPage.getRecords();
|
List<CourseEntity> courseEntities = courseEntityPage.getRecords();
|
||||||
if(courseEntities!=null&&courseEntities.size()>0){
|
if(courseEntities!=null&&courseEntities.size()>0){
|
||||||
for (CourseEntity co:courseEntities){
|
for (CourseEntity co:courseEntities){
|
||||||
int i = studyingDao.selectCount(new LambdaQueryWrapper<UserCourseStudying>().eq(UserCourseStudying::getCourseId,co.getId()).eq(UserCourseStudying::getUserId,user.getId()));
|
int i = studyingDao.selectCount(new LambdaQueryWrapper<UserCourseStudying>().eq(UserCourseStudying::getCourseId,co.getId()).eq(UserCourseStudying::getUserId,user.getId()));
|
||||||
co.setIsStudying(i>0?1:0);
|
co.setIsStudying(i>0?1:0);
|
||||||
MPJLambdaWrapper<CourseCatalogueEntity> catalogueWrapper = new MPJLambdaWrapper();
|
MPJLambdaWrapper<CourseCatalogueEntity> catalogueWrapper = new MPJLambdaWrapper();
|
||||||
catalogueWrapper.selectAll(CourseCatalogueEntity.class);
|
|
||||||
catalogueWrapper.eq(CourseCatalogueEntity::getCourseId, co.getId());
|
catalogueWrapper.eq(CourseCatalogueEntity::getCourseId, co.getId());
|
||||||
if ("0".equals(user.getVip())||"3".equals(user.getVip())){
|
|
||||||
catalogueWrapper.leftJoin(UserCourseBuyEntity.class, UserCourseBuyEntity::getCatalogueId,CourseCatalogueEntity::getId);
|
|
||||||
catalogueWrapper.eq(UserCourseBuyEntity::getUserId, user.getId());
|
|
||||||
}
|
|
||||||
catalogueWrapper.orderByAsc(CourseCatalogueEntity::getSort);
|
catalogueWrapper.orderByAsc(CourseCatalogueEntity::getSort);
|
||||||
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueDao.selectList(catalogueWrapper);
|
List<CourseCatalogueEntity> courseCatalogueEntities = courseCatalogueDao.selectList(catalogueWrapper);
|
||||||
|
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())||"2".equals(user.getVip())){
|
||||||
|
//是超级会员或者医学学会员
|
||||||
|
if (userVipList.size() > 0) {
|
||||||
|
courseCatalogueEntity.setStartTime(userVipList.get(0).getStartTime());
|
||||||
|
courseCatalogueEntity.setEndTime(userVipList.get(0).getEndTime());
|
||||||
|
}
|
||||||
|
courseCatalogueEntity.setIsBuy(1);
|
||||||
|
}else if ("0".equals(user.getVip())){
|
||||||
|
//普通用户
|
||||||
|
if (userCourseBuyList.size() > 0) {
|
||||||
|
courseCatalogueEntity.setIsBuy(1);
|
||||||
|
courseCatalogueEntity.setStartTime(userCourseBuyList.get(0).getStartTime());
|
||||||
|
courseCatalogueEntity.setEndTime(userCourseBuyList.get(0).getEndTime());
|
||||||
|
}else {
|
||||||
|
courseCatalogueEntity.setIsBuy(0);
|
||||||
|
}
|
||||||
|
}else if ("3".equals(user.getVip())){
|
||||||
|
//国学会员
|
||||||
|
//买的医学课程
|
||||||
|
if (userCourseBuyList.size() > 0) {
|
||||||
|
courseCatalogueEntity.setIsBuy(1);
|
||||||
|
courseCatalogueEntity.setStartTime(userCourseBuyList.get(0).getStartTime());
|
||||||
|
courseCatalogueEntity.setEndTime(userCourseBuyList.get(0).getEndTime());
|
||||||
|
}else {
|
||||||
|
//国学课程会员免费
|
||||||
|
List<CourseToSociologyEntity> courseToSociologyList = courseToSociologyDao.selectList(new LambdaQueryWrapper<CourseToSociologyEntity>().eq(CourseToSociologyEntity::getCourseId, courseCatalogueEntity.getCourseId()));
|
||||||
|
if (courseToSociologyList.size() > 0) {
|
||||||
|
courseCatalogueEntity.setIsBuy(1);
|
||||||
|
courseCatalogueEntity.setStartTime(userVipList.get(0).getStartTime());
|
||||||
|
courseCatalogueEntity.setEndTime(userVipList.get(0).getEndTime());
|
||||||
|
}else {
|
||||||
|
courseCatalogueEntity.setIsBuy(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
co.setCourseCatalogueEntityList(courseCatalogueEntities);
|
co.setCourseCatalogueEntityList(courseCatalogueEntities);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user