Browse Source

Merge remote-tracking branch 'origin/feature/1022_vip' into feature/1022_vip

zouxuan 4 days ago
parent
commit
82bd73c4fb

+ 10 - 0
mec-application/src/main/java/com/ym/mec/student/controller/LessonCoursewareController.java

@@ -10,6 +10,8 @@ import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.CloudTeacherOrderDao;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.ClientEnum;
+import com.ym.mec.biz.dal.entity.Subject;
+import com.ym.mec.biz.dal.enums.ClientEnum;
 import com.ym.mec.biz.dal.wrapper.LessonCoursewareWrapper;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
@@ -170,4 +172,12 @@ public class LessonCoursewareController extends BaseController {
 	public HttpResponseResult<List<Subject>> getLessonCoursewareSubjectList(){
 		return succeed(lessonCoursewareService.getDao().getLessonCoursewareSubjectList());
 	}
+
+    @ApiOperation(value = "关联课程类型")
+    @PostMapping("/refLevel")
+    public HttpResponseResult<List<LessonCoursewareWrapper.RefLevelDetailInfo>> refLevel(@RequestBody LessonCoursewareWrapper.RefLevelQuery query) {
+        query.setTeacherId(sysUserService.getUserId());
+        query.setClient(ClientEnum.STUDENT);
+        return succeed(lessonCoursewareService.refLevel(query));
+    }
 }

+ 1 - 1
mec-application/src/main/java/com/ym/mec/student/controller/MusicSheetController.java

@@ -130,7 +130,7 @@ public class MusicSheetController {
                 queryInfo.setSubjectId(instrument.getSubjectId());
             }
         } else if (StringUtils.isNotBlank(student.getSubjectIdList())){
-            queryInfo.setSubjectId(Integer.parseInt(student.getSubjectIdList()));
+//            queryInfo.setSubjectId(Integer.parseInt(student.getSubjectIdList()));
         }
         queryInfo.setPage(query.getPage());
         queryInfo.setRows(query.getRows());

+ 1 - 0
mec-application/src/main/java/com/ym/mec/teacher/controller/LessonCoursewareController.java

@@ -112,6 +112,7 @@ public class LessonCoursewareController extends BaseController {
 	@PostMapping("/refLevel")
 	public HttpResponseResult<List<LessonCoursewareWrapper.RefLevelDetailInfo>> refLevel(@RequestBody LessonCoursewareWrapper.RefLevelQuery query) {
 		query.setTeacherId(sysUserService.getUserId());
+        query.setClient(ClientEnum.TEACHER);
 		return succeed(lessonCoursewareService.refLevel(query));
 	}
 }

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/wrapper/LessonCoursewareWrapper.java

@@ -219,6 +219,8 @@ public class LessonCoursewareWrapper {
         @ApiModelProperty("是否当前使用")
         private Boolean useFlag;
 
+        @ApiModelProperty("使用状态 锁定: LOCK 解锁:UNLOCK")
+        private String useStatus;
     }
 
     @Data
@@ -229,6 +231,8 @@ public class LessonCoursewareWrapper {
 
         @ApiModelProperty(value = "老师ID",hidden = true)
         private Integer teacherId;
+
+        private ClientEnum client;
     }
 
     @Data

+ 48 - 16
mec-biz/src/main/java/com/ym/mec/biz/service/impl/LessonCoursewareServiceImpl.java

@@ -7,27 +7,24 @@ import com.dayaedu.cbs.openfeign.client.CoursewareFeignService;
 import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareDetailWrapper;
 import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsLessonCoursewareWrapper;
 import com.dayaedu.cbs.openfeign.wrapper.courseware.CbsMaterialRefWrapper;
+import com.google.common.collect.Lists;
 import com.microsvc.toolkit.common.response.template.R;
+import com.ym.mec.biz.dal.dao.CloudTeacherOrderDao;
 import com.ym.mec.biz.dal.dao.SubjectDao;
 import com.ym.mec.biz.dal.dao.TeacherDao;
 import com.ym.mec.biz.dal.dto.SimpleUserDto;
-import com.ym.mec.biz.dal.entity.LessonCourseware;
-import com.ym.mec.biz.dal.entity.LessonCoursewareUserMapper;
-import com.ym.mec.biz.dal.entity.SysMusicScore;
-import com.ym.mec.biz.dal.entity.Teacher;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.ClientEnum;
 import com.ym.mec.biz.dal.mapper.LessonCoursewareMapper;
 import com.ym.mec.biz.dal.wrapper.LessonCoursewareWrapper;
-import com.ym.mec.biz.service.LessonCoursewareService;
-import com.ym.mec.biz.service.LessonCoursewareUserMapperService;
-import com.ym.mec.biz.service.SysMusicScoreService;
-import com.ym.mec.biz.service.SysUserService;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.util.collection.MapUtil;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -58,6 +55,12 @@ public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMap
     @Resource
     private SysMusicScoreService sysMusicScoreService;
 
+    @Autowired
+    private CloudTeacherOrderDao cloudTeacherOrderDao;
+
+    @Autowired
+    private MemberRankCourseTypeMapperService memberRankCourseTypeMapperService;
+
     @Override
     public IPage<LessonCoursewareWrapper.LessonCoursewareDto> selectPage(IPage<LessonCoursewareWrapper.LessonCoursewareDto> page, LessonCoursewareWrapper.LessonCoursewareQuery query) {
         if(StringUtils.isNotEmpty(query.getSearch())){
@@ -219,18 +222,29 @@ public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMap
         if (lessonCourseware == null) {
             throw new BizException("课件未找到");
         }
-        Teacher teacher = teacherDao.get(query.getTeacherId());
-        if (teacher == null) {
-            throw new BizException("老师信息不存在");
-        }
-        if (lessonCoursewareDetail.getLevel() == null || teacher.getCoursewareFlag()) {
-            result.add(this.initRefLevelDetailInfo(lessonCoursewareDetail,lessonCourseware));
-            return result;
+        if (query.getClient() == ClientEnum.TEACHER) {
+            Teacher teacher = teacherDao.get(query.getTeacherId());
+            if (teacher == null) {
+                throw new BizException("老师信息不存在");
+            }
+            if (lessonCoursewareDetail.getLevel() == null || teacher.getCoursewareFlag()) {
+                result.add(this.initRefLevelDetailInfo(lessonCoursewareDetail, lessonCourseware));
+                return result;
+            }
+        } else {
+            if (lessonCoursewareDetail.getLevel() == null) {
+                result.add(this.initRefLevelDetailInfo(lessonCoursewareDetail, lessonCourseware));
+                return result;
+            }
         }
         LessonCoursewareWrapper.LessonCoursewareQuery query1 = new LessonCoursewareWrapper.LessonCoursewareQuery();
         query1.setPage(1);
         query1.setRows(9999);
-        query1.setTeacherId(query.getTeacherId());
+        if (query.getClient() == ClientEnum.STUDENT) {
+            query1.setStudentId(query.getTeacherId());
+        } else {
+            query1.setTeacherId(query.getTeacherId());
+        }
         query1.setEnable(true);
         List<LessonCoursewareWrapper.LessonCoursewareDto> dtos = baseMapper.list(query1);
         if(CollectionUtils.isEmpty(dtos)){
@@ -264,6 +278,21 @@ public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMap
             result.add(this.initRefLevelDetailInfo(lessonCoursewareDetail,lessonCourseware));
             return result;
         }
+        List<Long> lessonIds = new ArrayList<>();
+        if (query.getClient() == ClientEnum.STUDENT) {
+            List<Integer> activationVipIds = cloudTeacherOrderDao.getActivationVipIds(query.getTeacherId());
+
+            // 获取会员的曲目分类
+
+            List<MemberRankCourseTypeMapper> courseTypeMapperList = memberRankCourseTypeMapperService.getByMemberRankId(activationVipIds);
+            if (CollectionUtils.isEmpty(courseTypeMapperList)) {
+                courseTypeMapperList = Lists.newArrayList();
+            }
+            List<Integer> categoryIds = courseTypeMapperList.stream().map(MemberRankCourseTypeMapper::getCourseType)
+                .distinct().map(Integer::parseInt).collect(Collectors.toList());
+            // 本地的课件ID 换远程ID
+            lessonIds = getByLessonCoursewareIds(categoryIds).stream().map(LessonCourseware::getLessonCourseId).distinct().collect(Collectors.toList());
+        }
         for (CbsLessonCoursewareDetailWrapper.LessonCoursewareDetail coursewareDetail : lessonCoursewareDetails) {
             LessonCoursewareWrapper.RefLevelDetailInfo refLevelDetailInfo = new LessonCoursewareWrapper.RefLevelDetailInfo();
             refLevelDetailInfo.setId(coursewareDetail.getId());
@@ -277,6 +306,9 @@ public class LessonCoursewareServiceImpl extends ServiceImpl<LessonCoursewareMap
             refLevelDetailInfo.setLockFlag(false);
             refLevelDetailInfo.setLessonCoursewareName(lessonCourseware1.getName());
             refLevelDetailInfo.setUseFlag(coursewareDetail.getId().equals(query.getLessonCoursewareDetailId()));
+            if (lessonIds.contains(lessonCourseware1.getId()) || query.getClient() == ClientEnum.TEACHER) {
+                refLevelDetailInfo.setUseStatus("UNLOCK");
+            } else refLevelDetailInfo.setUseStatus("LOCK");
             result.add(refLevelDetailInfo);
         }
         return result;