Ver Fonte

Merge branch 'feature/0826_music' into test

liujc há 10 meses atrás
pai
commit
93cbd17f2f
20 ficheiros alterados com 274 adições e 69 exclusões
  1. 25 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/MusicSheetController.java
  2. 28 0
      cooleshow-app/src/main/java/com/yonge/cooleshow/student/controller/MusicSheetController.java
  3. 15 10
      cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/MusicSheetController.java
  4. 2 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/MusicSheetDao.java
  5. 7 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/MusicSheetSearch.java
  6. 2 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/StudentMusicSheetSearch.java
  7. 2 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/SysMusicCompareRecord.java
  8. 3 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/TenantAlbumMusicMapper.java
  9. 2 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/MusicSheetService.java
  10. 89 37
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/MusicSheetServiceImpl.java
  11. 12 1
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherTotalServiceImpl.java
  12. 2 8
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantAlbumMusicServiceImpl.java
  13. 6 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/MusicSheetDetailVo.java
  14. 3 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/MusicSheetVo.java
  15. 6 0
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/TeacherMusicSheetListVo.java
  16. 1 1
      cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseCoursewareMapper.xml
  17. 3 2
      cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicAlbumMapper.xml
  18. 42 7
      cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetMapper.xml
  19. 4 0
      cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetPracticeRecordMapper.xml
  20. 20 1
      cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantAlbumMusicMapper.xml

+ 25 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/MusicSheetController.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.admin.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.dayaedu.cbs.openfeign.client.MusicFeignClientService;
 import com.microsvc.toolkit.common.response.template.R;
 import com.yonge.cooleshow.biz.dal.dto.ReasonDto;
 import com.yonge.cooleshow.biz.dal.dto.search.MusicSheetSearch;
@@ -8,11 +9,15 @@ import com.yonge.cooleshow.biz.dal.dto.search.StudentMusicSheetOrderSearch;
 import com.yonge.cooleshow.biz.dal.dto.search.TeacherMusicSheetSearch;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.enums.OrderTypeEnum;
+import com.yonge.cooleshow.biz.dal.enums.SourceTypeEnum;
+import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
 import com.yonge.cooleshow.biz.dal.service.MusicSheetService;
+import com.yonge.cooleshow.biz.dal.service.SysConfigService;
 import com.yonge.cooleshow.biz.dal.service.SysUserService;
 import com.yonge.cooleshow.biz.dal.service.cbs.CbsMusicScoreService;
 import com.yonge.cooleshow.biz.dal.vo.*;
 import com.yonge.cooleshow.biz.dal.wrapper.MusicSheetApplicationExtendWrapper;
+import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.cooleshow.common.enums.YesOrNoEnum;
@@ -22,11 +27,13 @@ import com.yonge.toolset.mybatis.support.PageUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.validation.Valid;
+import java.util.List;
 import java.util.concurrent.CompletableFuture;
 
 @RestController
@@ -40,6 +47,12 @@ public class MusicSheetController extends BaseController {
 	@Resource
 	private CbsMusicScoreService cbsMusicScoreService;
 
+    @Autowired
+    private SysConfigService sysConfigService;
+
+    @Autowired
+    private MusicFeignClientService musicFeignClientService;
+
     @GetMapping("/detail/{id}")
     @ApiOperation(value = "详情", notes = "传入id")
     @PreAuthorize("@pcs.hasPermissions('music/sheet/detail')")
@@ -51,6 +64,18 @@ public class MusicSheetController extends BaseController {
     @PostMapping(value="/list", consumes="application/json", produces="application/json")
     @PreAuthorize("@pcs.hasPermissions('music/sheet/list')")
     public HttpResponseResult<PageInfo<MusicSheetVoResult>> list(@RequestBody MusicSheetSearch query) {
+        if (query.getSourceType() == SourceTypeEnum.TENANT &&  !StringUtil.isEmpty(query.getSubjectType())) {
+            Long categoryId = null;
+            if (SubjectTypeEnum.SUBJECT.name().equals(query.getSubjectType())) {
+                categoryId= Long.parseLong(sysConfigService.findConfigValue(SysConfigConstant.TENANT_ALBUM_SUBJECT_TYPE_CATEGORY));
+            } else if (SubjectTypeEnum.ENSEMBLE.name().equals(query.getSubjectType())) {
+                categoryId= Long.parseLong(sysConfigService.findConfigValue(SysConfigConstant.TENANT_ALBUM_ENSEMBLE_TYPE_CATEGORY));
+            } if (SubjectTypeEnum.MUSIC.name().equals(query.getSubjectType())) {
+                categoryId = Long.parseLong(sysConfigService.findConfigValue(SysConfigConstant.TENANT_ALBUM_MUSIC_TYPE_CATEGORY));
+            }
+            List<Integer> integers = musicFeignClientService.getAllCategoryIdList(String.valueOf(categoryId)).feignData();
+            query.setTenantCategoryIds(integers);
+        }
         return succeed(PageUtil.pageInfo(musicSheetService.selectCbsPage(PageUtil.getPage(query), query)));
     }
 

+ 28 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/student/controller/MusicSheetController.java

@@ -267,6 +267,11 @@ public class MusicSheetController extends BaseController {
         }
         StudentMusicSheetSearch search = new StudentMusicSheetSearch();
         search.setStudentId(sysUser.getId());
+        // 查询学生时机构还是平台
+        Student student = studentService.getById(search.getStudentId());
+        if (student != null && student.getTenantId() != null && student.getTenantId()>0) {
+            search.setProviderType(SourceTypeEnum.TENANT);
+        }
         search.setState(YesOrNoEnum.YES);
         search.setAuditStatus(null);
         IPage<MusicSheetVo> sheetVoIPage = musicSheetService.favoriteMusic(PageUtil.getPage(query),search, ClientEnum.STUDENT);
@@ -288,10 +293,31 @@ public class MusicSheetController extends BaseController {
         search.setStudentId(sysUser.getId());
         search.setState(YesOrNoEnum.YES);
         search.setAuditStatus(null);
+        search.setClientType(ClientEnum.STUDENT);
+        // 查询学生时机构还是平台
+        Student student = studentService.getById(search.getStudentId());
+        if (student != null && student.getTenantId() != null && student.getTenantId()>0) {
+            search.setProviderType(SourceTypeEnum.TENANT);
+        }
         IPage<MusicSheetVo> sheetVoIPage = musicSheetService.practiceMusic(PageUtil.getPage(query),search);
         return succeed(PageUtil.pageInfo(sheetVoIPage));
     }
 
+    /**
+     * 最近练习
+     */
+    @GetMapping("/practice/del/{id}")
+    @ApiOperation(value = "删除最近练习记录")
+    public HttpResponseResult<Boolean> delPracticeMusic(@PathVariable Long id) {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null  || sysUser.getId() == null) {
+            return failed("用户信息获取失败");
+        }
+
+        musicSheetService.delPractice(id,sysUser.getId(),ClientEnum.STUDENT);
+        return succeed();
+    }
+
 
 
     /**
@@ -314,6 +340,7 @@ public class MusicSheetController extends BaseController {
             search.setProviderType(SourceTypeEnum.TENANT);
         }
         search.setStudentId(userId);
+        search.setClientType(ClientEnum.STUDENT);
         search.setState(YesOrNoEnum.YES);
         search.setAuditStatus(null);
         search.setRows(3);
@@ -459,6 +486,7 @@ public class MusicSheetController extends BaseController {
             throw new BizException("用户信息获取失败");
         }
         queryInfo.setSubjectId(Integer.parseInt(student.getSubjectId()));
+        queryInfo.setProviderType(SourceTypeEnum.TENANT);
         return succeed(musicSheetService.searchTenant(queryInfo));
     }
 

+ 15 - 10
cooleshow-app/src/main/java/com/yonge/cooleshow/teacher/controller/MusicSheetController.java

@@ -1,17 +1,13 @@
 package com.yonge.cooleshow.teacher.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.dayaedu.cbs.common.enums.music.EMusicSourceType;
-import com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetWrapper;
-import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dto.AppMusicSheetVo;
 import com.yonge.cooleshow.biz.dal.dto.MusicSheetRenderDto;
-import com.yonge.cooleshow.biz.dal.dto.ReasonDto;
 import com.yonge.cooleshow.biz.dal.dto.search.MusicSheetRelatedQueryInfo;
 import com.yonge.cooleshow.biz.dal.dto.search.StudentMusicSheetSearch;
 import com.yonge.cooleshow.biz.dal.entity.MusicSheet;
-import com.yonge.cooleshow.biz.dal.entity.MusicSheetAuthRecord;
+import com.yonge.cooleshow.biz.dal.entity.Student;
 import com.yonge.cooleshow.biz.dal.entity.Teacher;
 import com.yonge.cooleshow.biz.dal.enums.AuthStatusEnum;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
@@ -19,7 +15,6 @@ import com.yonge.cooleshow.biz.dal.enums.MusicSortType;
 import com.yonge.cooleshow.biz.dal.enums.SourceTypeEnum;
 import com.yonge.cooleshow.biz.dal.enums.album.PurchaseRecordTypeEnum;
 import com.yonge.cooleshow.biz.dal.service.*;
-import com.yonge.cooleshow.biz.dal.service.cbs.CbsMusicScoreService;
 import com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo;
 import com.yonge.cooleshow.biz.dal.vo.MusicSheetShareVo;
 import com.yonge.cooleshow.biz.dal.vo.MusicSheetVo;
@@ -35,19 +30,15 @@ import com.yonge.toolset.mybatis.support.PageUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
-import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.validation.Valid;
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.List;
 import java.util.Optional;
-import java.util.stream.Collectors;
 
 /**
  * 曲谱表 web 控制层
@@ -70,6 +61,9 @@ public class MusicSheetController extends BaseController {
     @Resource
     private TeacherService teacherService;
 
+    @Autowired
+    private StudentService studentService;
+
     /**
      * 查询单条
      */
@@ -233,9 +227,14 @@ public class MusicSheetController extends BaseController {
     public HttpResponseResult<PageInfo<MusicSheetVo>> favoriteMusic(QueryInfo query) {
         SysUser sysUser = sysUserService.getUser();
         StudentMusicSheetSearch search = new StudentMusicSheetSearch();
+        Teacher teacher = teacherService.getById(sysUser.getId());
+        if (teacher.getTenantId() !=null && teacher.getTenantId() >0) {
+            search.setTenantId(teacher.getTenantId());
+        }
         search.setStudentId(sysUser.getId());
         search.setState(YesOrNoEnum.YES);
         search.setAuditStatus(null);
+        search.setProviderType(null);
         IPage<MusicSheetVo> sheetVoIPage = musicSheetService.favoriteMusic(PageUtil.getPage(query),search, ClientEnum.TEACHER);
         return succeed(PageUtil.pageInfo(sheetVoIPage));
     }
@@ -323,9 +322,15 @@ public class MusicSheetController extends BaseController {
         }
         StudentMusicSheetSearch search = new StudentMusicSheetSearch();
         search.setStudentId(userId);
+        search.setClientType(ClientEnum.STUDENT);
         search.setState(YesOrNoEnum.YES);
         search.setAuditStatus(null);
         search.setRows(3);
+        // 查询学生时机构还是平台
+        Student student = studentService.getById(search.getStudentId());
+        if (student != null && student.getTenantId() != null && student.getTenantId()>0) {
+            search.setProviderType(SourceTypeEnum.TENANT);
+        }
         IPage<MusicSheetVo> sheetVoIPage = musicSheetService.practiceMusic(PageUtil.getPage(search),search);
         return succeed(PageUtil.pageInfo(sheetVoIPage));
     }

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/MusicSheetDao.java

@@ -225,4 +225,6 @@ public interface MusicSheetDao extends BaseMapper<MusicSheet> {
     void platformInsert(@Param("item") CbsMusicSheetApplicationExtendWrapper.MusicSheetApplicationExtend extend);
 
     void updateState(@Param("ids") String ids);
+
+    void delPractice(@Param("musicSheetId") Long musicSheetId, @Param("userId") Long userId, @Param("clientEnum") ClientEnum clientEnum);
 }

+ 7 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/MusicSheetSearch.java

@@ -123,6 +123,13 @@ public class MusicSheetSearch  extends QueryInfo{
     @ApiModelProperty(value = "必须要匹配声部ID")
     private List<Long> mustMatchSubjectIds;
 
+    @ApiModelProperty("机构专辑分类")
+    private String subjectType;
+
+
+    @ApiModelProperty("机构专辑分类")
+    private List<Integer> tenantCategoryIds;
+
     public List<Long> getExcludeMusicIds() {
         return excludeMusicIds;
     }

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/search/StudentMusicSheetSearch.java

@@ -5,8 +5,6 @@ import com.yonge.cooleshow.biz.dal.enums.album.PurchaseRecordTypeEnum;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
-import java.util.List;
-
 /**
  * Description 学生查询乐谱
  *
@@ -45,6 +43,8 @@ public class StudentMusicSheetSearch  extends MusicSheetSearch{
     // 客户端类型
     private ClientEnum clientType;
 
+    private Long tenantId;
+
 
     public ClientEnum getUserType() {
         return userType;

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/SysMusicCompareRecord.java

@@ -90,6 +90,8 @@ public class SysMusicCompareRecord extends BaseEntity {
 
 	private Long tenantId = -1L;
 
+    private Boolean hiddenFlag;
+
 	public SysMusicCompareRecord(FeatureType feature) {
 		this.feature = feature;
 	}

+ 3 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/TenantAlbumMusicMapper.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 import com.yonge.cooleshow.biz.dal.entity.TenantAlbumMusic;
@@ -39,4 +40,6 @@ public interface TenantAlbumMusicMapper extends BaseMapper<TenantAlbumMusic> {
     List<TenantAlbumMusic> getByAlbumAndEnable(@Param("tenantAlbumIds") List<Long> tenantAlbumIds);
 
     List<TenantAlbumMusic> getList(@Param("param") TenantAlbumMusicWrapper.TenantAlbumMusicSelect query, @Param("albumIds") List<Long> albumIds);
+
+    List<Long> getTenantAlbumMusicIdsByIds(@Param("tenantAlbumIds") List<Long> tenantAlbumIds, @Param("subjectTypes") List<SubjectTypeEnum> subjectTypes);
 }

+ 2 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/MusicSheetService.java

@@ -419,4 +419,6 @@ public interface MusicSheetService extends IService<MusicSheet> {
     IPage<MusicSheetVo> queryTenantRelatedList(IPage<Object> page, MusicSheetRelatedQueryInfo queryInfo);
 
     com.microsvc.toolkit.common.response.paging.PageInfo<MusicSheetWrapper.MusicSheetApplication> tenantPage(CbsMusicSheetWrapper.MusicSheetApplicationQuery query);
+
+    void delPractice(Long musicSheetId,Long userId,ClientEnum clientEnum);
 }

+ 89 - 37
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/MusicSheetServiceImpl.java

@@ -199,7 +199,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
     @Override
     public IPage<MusicSheetVoResult> selectCbsPage(IPage<MusicSheetVo> page, MusicSheetSearch query) {
         List<MusicSheetVo> musicSheets = baseMapper.selectPage(page, query);
-        IPage<MusicSheetVo> info = page.setRecords(musicDataFormat(musicSheets));
+        IPage<MusicSheetVo> info = page.setRecords(musicDataFormat(musicSheets,query.getSourceType()));
         List<MusicSheetVo> rows = info.getRecords();
         List<MusicSheetVoResult> musicSheetVoResults = new ArrayList<>();
         for (MusicSheetVo row : rows) {
@@ -210,7 +210,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         return com.yonge.cooleshow.biz.dal.dto.PageUtil.transPageInfo(info, musicSheetVoResults);
     }
 
-    public List<MusicSheetVo> musicDataFormat(List<MusicSheetVo> musicSheets) {
+    public List<MusicSheetVo> musicDataFormat(List<MusicSheetVo> musicSheets,SourceTypeEnum sourceType) {
         if (CollectionUtils.isEmpty(musicSheets)) {
             return musicSheets;
         }
@@ -218,11 +218,15 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         if (CollectionUtils.isEmpty(cbsMusicSheetIds)) {
             return new ArrayList<>();
         }
+        Long appId = Long.parseLong(openFeignClientConfigProperties.getAppId());
+        if (sourceType!=null && sourceType==SourceTypeEnum.TENANT) {
+            appId = Long.parseLong(sysConfigService.findConfigValue(SysConfigConstant.CBS_TENANT_APP_ID));
+        }
         // 调用内容平台查询曲目信息
         R<PageInfo<CbsMusicSheetWrapper.MusicSheetApplication>> pageInfoR = musicFeignClientService
                 .musicSheetPageByApplication(CbsMusicSheetWrapper.MusicSheetApplicationQuery.builder()
                         .musicSheetIds(cbsMusicSheetIds).detailFlag(false).rows(-1).delFlag(true)
-                        .applicationId(Long.parseLong(openFeignClientConfigProperties.getAppId())).build());
+                        .applicationId(appId).build());
         List<CbsMusicSheetWrapper.MusicSheetApplication> rows;
         try {
             PageInfo<CbsMusicSheetWrapper.MusicSheetApplication> musicSheetApplicationPageInfo = pageInfoR.feignData();
@@ -442,6 +446,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
                 detailVo.setUserAvatar(sysUser.getAvatar());
             }
         }
+        detailVo.setCategoryId(musicSheet1.getMusicCategoryId()!=null?musicSheet1.getMusicCategoryId().toString():"");
         detailVo.setMusicPrice(musicSheet1.getMusicPrice());
         detailVo.setSubjectNames(musicSheet1.getSubjectNames());
         detailVo.setCode(musicSheet1.getSubjectCodes());
@@ -549,6 +554,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         if (musicSheetApplication.getAudioType() != null) {
             sheet.setAccompanimentType(AccompanimentTypeEnum.valueOf(musicSheetApplication.getAudioType().getCode()));
         }
+        sheet.setCategoryName(musicSheetApplication.getMusicSheetCategoryName());
         sheet.setMusicTagNames(musicSheetApplication.getMusicTagNames());
         sheet.setSubjectNames(musicSheetApplication.getSubjectNames());
         sheet.setPaymentType(musicSheetApplication.getPaymentType());
@@ -611,6 +617,8 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
             }
         }
         MusicSheetDetailVo detail = this.getCbsDetail(Long.parseLong(id));
+
+        detail.setTenantFlag(false);
         //兼容审批数据
         MusicSheetAuthRecord one = musicSheetAuthRecordService.lambdaQuery().eq(MusicSheetAuthRecord::getMusicSheetId, detail.getId()).last("limit 1").one();
         if (one != null) {
@@ -646,20 +654,64 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
             detail.setReason(reason);
         }
         if (StringUtil.isEmpty(tenantAlbumId)) {
-            if (detail.getPaymentType().contains(ChargeTypeEnum.FREE.getCode())) {
-                detail.setPlay(YesOrNoEnum.YES);
-            } else if (ClientEnum.STUDENT.getCode().equals(userType.getCode())
-                || ClientEnum.TEACHER.getCode().equals(userType.getCode())) {
-                // 2022 7 20  老师也能购买曲目
-                if (ClientEnum.TEACHER.getCode().equals(userType.getCode()) && sysUser.getId().equals(detail.getUserId())) {
+
+            // 如果是机构用户,判断机构专辑
+
+            // 机构学生,查询购买过的机构专辑,是否存在当前曲目
+            Long tenantId = userTenantId(sysUser.getId(), userType);
+
+            if (tenantId >0L) {
+                detail.setTenantFlag(true);
+
+                if (detail.getProviderType().contains(SourceTypeEnum.TENANT.getCode())) {
+                    if (userType == ClientEnum.STUDENT) {
+
+                        // 机构学生
+                        List<Long> tenantAlbumIds = userTenantAlbumRecordMapper.selectTenantIds(sysUser.getId());
+                        if (CollectionUtils.isNotEmpty(tenantAlbumIds)) {
+                            List<Long> musicSheetIds = tenantAlbumMusicService.getMusicIdsByIds(tenantAlbumIds);
+                            if (musicSheetIds.contains(detail.getId())) {
+                                detail.setPlay(YesOrNoEnum.YES);
+                                detail.setBuyed(true);
+                                return detail;
+                            }
+                        }
+                    } else {
+                        // 老师所在机构启用的专辑
+                        Teacher teacher = teacherService.getById(sysUser.getId());
+                        if (teacher.getTenantId() != null) {
+                            List<Long> musicSheetIds = tenantAlbumMusicService.getMusicIdsByTenantIds(teacher.getTenantId());
+                            if (musicSheetIds.contains(detail.getId())) {
+                                detail.setPlay(YesOrNoEnum.YES);
+                                detail.setBuyed(true);
+                                return detail;
+                            }
+                        }
+                    }
+                }
+            } else {
+                if (!detail.getProviderType().contains(SourceTypeEnum.PLATFORM.getCode())) {
+                    return detail;
+                }
+                if (detail.getPaymentType().contains(ChargeTypeEnum.FREE.getCode())) {
                     detail.setPlay(YesOrNoEnum.YES);
+                } else if (ClientEnum.STUDENT.getCode().equals(userType.getCode())
+                    || ClientEnum.TEACHER.getCode().equals(userType.getCode())) {
+                    // 2022 7 20  老师也能购买曲目
+                    if (ClientEnum.TEACHER.getCode().equals(userType.getCode()) && sysUser.getId().equals(detail.getUserId())) {
+                        detail.setPlay(YesOrNoEnum.YES);
+                    } else {
+                        setMusicSheetPlay(sysUser.getId(), detail, userType);
+                    }
                 } else {
-                    setMusicSheetPlay(sysUser.getId(), detail, userType);
+                    detail.setPlay(YesOrNoEnum.YES);
                 }
-            } else {
-                detail.setPlay(YesOrNoEnum.YES);
             }
         } else {
+            detail.setTenantFlag(true);
+            if (!detail.getProviderType().contains(SourceTypeEnum.TENANT.getCode())) {
+                return detail;
+            }
             // 机构专辑购买
             detail.setPlay(YesOrNoEnum.NO);
             List<Long> collected = Arrays.stream(tenantAlbumId.split(",")).map(Long::parseLong).collect(Collectors.toList());
@@ -693,6 +745,22 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         return detail;
     }
 
+    private Long userTenantId(Long userId, ClientEnum userType) {
+        if (ClientEnum.STUDENT == userType) {
+            Student student = studentService.getById(userId);
+            if (student != null&& student.getTenantId() !=null && student.getTenantId() >0) {
+                return student.getTenantId();
+            }
+        } else if (ClientEnum.TEACHER == userType) {
+            Teacher teacher = teacherService.getById(userId);
+            if (teacher != null && teacher.getTenantId() !=null && teacher.getTenantId() >0) {
+                return teacher.getTenantId();
+            }
+        }
+        return -1L;
+
+    }
+
     /**
      * 设置学生曲目信息
      * <p>
@@ -769,31 +837,6 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
             if (count > 0) {
                 detail.setPlay(YesOrNoEnum.YES);
                 detail.setBuyed(true);
-                return;
-            }
-        }
-
-        // 机构专辑购买
-
-        // 学生生效中的机构专辑
-        if (ClientEnum.STUDENT == userType) {
-            List<Long> tenantAlbumIds = userTenantAlbumRecordMapper.selectTenantIds(studentId);
-            if (CollectionUtils.isNotEmpty(tenantAlbumIds)) {
-                List<Long> musicSheetIds = tenantAlbumMusicService.getMusicIdsByIds(tenantAlbumIds);
-                if (musicSheetIds.contains(detail.getId())) {
-                    detail.setPlay(YesOrNoEnum.YES);
-                    detail.setBuyed(true);
-                }
-            }
-        } else if (ClientEnum.TEACHER == userType) {
-            // 老师所在机构启用的专辑
-            Teacher teacher = teacherService.getById(studentId);
-            if (teacher.getTenantId() !=null) {
-                List<Long> musicSheetIds = tenantAlbumMusicService.getMusicIdsByTenantIds(teacher.getTenantId());
-                if (musicSheetIds.contains(detail.getId())) {
-                    detail.setPlay(YesOrNoEnum.YES);
-                    detail.setBuyed(true);
-                }
             }
         }
     }
@@ -986,6 +1029,9 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
             // 更新曲目专辑数量
             musicSheetService.updateMusicAlbumNumInfo(page.getRecords());
         }
+        for (MusicSheetVo record : page.getRecords()) {
+            record.setPlay(detail(record.getId(), sysUserFeignService.queryUserById(query.getStudentId()), ClientEnum.STUDENT).getPlay());
+        }
         return page;
     }
 
@@ -1373,6 +1419,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         teacherMusicSheetListVo.setEntryFlag(teacherVo.getEntryFlag());
         teacherMusicSheetListVo.setMusicianFlag(teacherVo.getMusicianFlag());
         teacherMusicSheetListVo.setTag(teacherVo.getTag());
+        teacherMusicSheetListVo.setVipType(teacherVo.getVipType());
 
         TeacherTotal total = totalService.getTotalById(detail.getUserId());
         if (total != null) {
@@ -2413,6 +2460,11 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet
         }
     }
 
+    @Override
+    public void delPractice(Long musicSheetId,Long userId,ClientEnum clientEnum) {
+        baseMapper.delPractice(musicSheetId,userId,clientEnum);
+    }
+
     private Map<Long,MusicSheet> getMapByCbsIds(List<Long> cbsMusicSheetIds) {
         if (CollectionUtils.isEmpty(cbsMusicSheetIds)) {
             return new HashMap<>();

+ 12 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TeacherTotalServiceImpl.java

@@ -186,7 +186,18 @@ public class TeacherTotalServiceImpl extends ServiceImpl<TeacherTotalDao, Teache
     public TeacherTotal getTotalById(Long id) {
         RBucket<Object> bucket = redissonClient.getBucket(CacheNameEnum.TEACHER_TOTAL.getRedisKey(id));
         if (bucket.isExists()) {
-            return (TeacherTotal) bucket.get();
+            try {
+
+                return (TeacherTotal) bucket.get();
+            }catch (Exception e) {
+                log.error("getTotalById error", e);
+            }
+            //去数据库查询
+            TeacherTotal total = totalTeacherTotalById(id);
+            if(null != total){
+                bucket.set(total);
+            }
+            return total;
         } else {
             //去数据库查询
             TeacherTotal total = totalTeacherTotalById(id);

+ 2 - 8
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantAlbumMusicServiceImpl.java

@@ -468,14 +468,8 @@ public class TenantAlbumMusicServiceImpl extends ServiceImpl<TenantAlbumMusicMap
         if (CollectionUtils.isEmpty(tenantAlbumIds)) {
             return Collections.emptyList();
         }
-        List<TenantAlbumMusic> list = this.lambdaQuery()
-            .in(TenantAlbumMusic::getTenantAlbumId, tenantAlbumIds)
-            .in(CollectionUtils.isNotEmpty(subjectTypes),TenantAlbumMusic::getSubjectType,subjectTypes)
-            .list();
-        if (CollectionUtils.isEmpty(list)) {
-            return Collections.emptyList();
-        }
-        return list.stream().map(TenantAlbumMusic::getMusicSheetId).collect(Collectors.toList());
+
+        return baseMapper.getTenantAlbumMusicIdsByIds(tenantAlbumIds, subjectTypes);
     }
 
     @Override

+ 6 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/MusicSheetDetailVo.java

@@ -31,6 +31,9 @@ public class MusicSheetDetailVo extends MusicSheet {
     @ApiModelProperty("是否购买(0:否,1:是)")
     private Boolean buyed = false;
 
+
+    private Boolean tenantFlag = false;
+
     @ApiModelProperty("收藏0:否,1:是")
     private YesOrNoEnum favorite;
 
@@ -87,5 +90,8 @@ public class MusicSheetDetailVo extends MusicSheet {
 
     @ApiModelProperty("曲目json文件")
     private String musicSheetJson;
+
+    @ApiModelProperty("内容平台分类ID")
+    private String categoryId;
 }
 

+ 3 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/MusicSheetVo.java

@@ -47,6 +47,9 @@ public class MusicSheetVo extends MusicSheet {
     @ApiModelProperty("机构专辑ID,逗号隔开")
     private String tenantAlbumId;
 
+    @ApiModelProperty("分类")
+    private String categoryName;
+
     @ApiModelProperty("所属人信息")
     private CbsMusicSheetWrapper.MusicSheetExtend musicSheetExtend;
 

+ 6 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/TeacherMusicSheetListVo.java

@@ -1,8 +1,10 @@
 package com.yonge.cooleshow.biz.dal.vo;
 
+import com.yonge.cooleshow.biz.dal.enums.EUserVipType;
 import com.yonge.cooleshow.common.enums.YesOrNoEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 
 import java.util.List;
 
@@ -12,6 +14,7 @@ import java.util.List;
  * @author liujunchi
  * @date 2022-06-14
  */
+@Data
 @ApiModel("官网曲目详情老师和老师拥有的曲目信息")
 public class TeacherMusicSheetListVo {
 
@@ -46,6 +49,9 @@ public class TeacherMusicSheetListVo {
     private List<MusicSheetVo> musicSheetList;
 
 
+    @ApiModelProperty(value = "用户会员类型,普通用户:NORMAL,会员:VIP,SVIP:SVIP")
+    private EUserVipType vipType;
+
     public String getTag() {
         return tag;
     }

+ 1 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseCoursewareMapper.xml

@@ -34,7 +34,7 @@
 		FROM course_courseware t
         left join music_sheet ms on t.music_sheet_id_ = ms.id_
         <where>
-            t.del_flag_ = 0 AND ms.cbs_music_sheet_id_ IS NOT NULL
+            t.del_flag_ = 0 AND ms.cbs_music_sheet_id_ IS NOT NULL and find_in_set('PLATFORM',ms.provider_type_)
             <if test="param.userId != null">
                 and t.user_id_ = #{param.userId}
             </if>

+ 3 - 2
cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicAlbumMapper.xml

@@ -189,7 +189,7 @@
         left join (select count(1) as num,amr.album_id_
             from album_music_relate amr
             join music_sheet ms on amr.music_sheet_id_ = ms.id_
-            where ms.del_flag_ = 0 and ms.state_ = 1 and ms.audit_status_ = 'PASS'
+            where ms.del_flag_ = 0 and ms.state_ = 1 and ms.audit_status_ = 'PASS' and find_in_set('PLATFORM',ms.provider_type_)
             group by amr.album_id_) t1 on t1.album_id_ = t.id_
         left join (select count(1) as num,af.album_id_ from album_favorite af
               group by af.album_id_
@@ -241,7 +241,7 @@
         ,(select count(1) as num
             from album_music_relate amr
             join music_sheet ms on amr.music_sheet_id_ = ms.id_
-            where ms.del_flag_ = 0 and ms.state_ = 1 and ms.audit_status_ = 'PASS'
+            where ms.del_flag_ = 0 and ms.state_ = 1 and ms.audit_status_ = 'PASS' and find_in_set('PLATFORM',ms.provider_type_)
            and amr.album_id_ = t.id_) as musicSheetCount
         ,if(t2.num >0,t2.num,0) as albumFavoriteCount
         from music_album t
@@ -308,6 +308,7 @@
             </if>
             <if test="paymentType != null">
                 AND t2.payment_type_ = #{paymentType}
+                and find_in_set('PLATFORM',t2.provider_type_)
             </if>
         </where>
         GROUP BY t1.album_id_

+ 42 - 7
cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetMapper.xml

@@ -179,6 +179,12 @@
             <if test="param.auditStatus == null">
                 AND t.cbs_music_sheet_id_ IS NOT NULL
             </if>
+            <if test="param.tenantCategoryIds != null and param.tenantCategoryIds.size() != 0">
+                and t.tenant_category_id_ in
+                <foreach collection="param.tenantCategoryIds" separator="," item="item" open="(" close=")">
+                    #{item}
+                </foreach>
+            </if>
             <if test="param.auditVersion != null ">
                 and #{param.auditVersion} = t.audit_version_
             </if>
@@ -596,11 +602,25 @@
             left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
         </if>
         <where>
-            1=1
-            <include refid="QueryInfo"/>
-            <if test="clientType != null">
-                AND mf.client_type_ = #{clientType}
+
+            mf.client_type_ = #{clientType}
+            <if test="clientType.code == 'STUDENT'">
+                and t.del_flag_=0 and t.state_ =1 and find_in_set('PLATFORM',t.provider_type_)
+            </if>
+            <if test="clientType.code == 'TEACHER'">
+                and ((t.del_flag_=0 and t.state_ =1 and find_in_set('PLATFORM',t.provider_type_))
+                    <if test="param.tenantId !=null">
+                        or (t.tenant_del_flag_=0 and t.tenant_state_ =1 and find_in_set('TENANT',t.provider_type_)
+                            and t.id_ in (select s.music_sheet_id_ from tenant_album_music s
+                                left join tenant_album s1 on s.tenant_album_id_ = s1.id_ where s.tenant_id_ = #{param.tenantId}
+                                        and s.del_flag_ = 0 and s.subject_type_ in ('ENSEMBLE','MUSIC','SUBJECT') and s1.del_flag_= 0 and s1.status_ = 1
+
+                            )
+                        )
+                    </if>
+                )
             </if>
+
             <if test="param.studentId != null">
                 and mf.user_id_ = #{param.studentId}
             </if>
@@ -799,7 +819,7 @@
             sum(if(ms.source_type_ = 'TEACHER',1,0)) as musicSheetTeacherCount,
             count(1) as musicSheetCount
         from music_sheet ms
-        where ms.state_ = 1 and ms.del_flag_ = 0 and ms.audit_status_ = 'PASS' and find_in_set('CHARGE',ms.payment_type_)
+        where ms.state_ = 1 and ms.del_flag_ = 0 and ms.audit_status_ = 'PASS' and find_in_set('CHARGE',ms.payment_type_) and find_in_set('PLATFORM',ms.provider_type_)
     </select>
 
     <select id="selectPayMusicSheet" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo$MusicSheetSmall">
@@ -1043,7 +1063,6 @@
             left join tenant_album_music tam on t.id_ = tam.music_sheet_id_
         </if>
             <where>
-                t.state_=1 and t.audit_version_ = 0 and t.del_flag_ = 0 and t.audit_status_ = 'PASS'
                 <if test="param.subjectId != null">
                     and ( t.music_subject_ = #{param.subjectId} or t.music_subject_ is null or t.music_subject_ = '' OR t.is_all_subject_)
                 </if>
@@ -1060,6 +1079,15 @@
                 </if>
                 <if test="param.providerType != null">
                     and find_in_set(#{param.providerType},t.provider_type_)
+                    <if test="param.providerType != null">
+                        <if test="param.providerType.code == 'TENANT'">
+                            and t.tenant_state_ = true and t.tenant_del_flag_ = 0
+                        </if>
+
+                        <if test="param.providerType.code == 'PLATFORM'">
+                            and t.state_=1 and t.audit_version_ = 0 and t.del_flag_ = 0 and t.audit_status_ = 'PASS'
+                        </if>
+                    </if>
                 </if>
             </where>
         order by t.top_flag_ desc, t.sort_number_ desc, t.favorite_count_ desc
@@ -1219,7 +1247,7 @@
 
     <insert id="tenantInsert">
         insert into music_sheet
-        (cbs_music_sheet_id_,tenant_sort_number_,tenant_score_type_,tenant_state_,tenant_notation_,tenant_category_id_
+        (cbs_music_sheet_id_,tenant_sort_number_,tenant_score_type_,tenant_state_,tenant_notation_,tenant_category_id_,tenant_del_flag_
         ,music_sheet_name_,music_subject_,music_svg_,composer_,accompaniment_type_,play_speed_,
         music_sheet_type_,provider_type_,audio_type_,show_fingering_,
         can_evaluate_,create_by_,user_id_,audit_status_,upload_time_,source_type_
@@ -1228,6 +1256,7 @@
             (#{item.musicSheetId},
         #{item.sortNo},#{item.scoreType},#{item.status},#{item.isConvertibleScore}
         ,#{item.musicSheetUpdate.musicCategoryId}
+            ,#{item.delFlag}
             ,#{item.musicSheetUpdate.name},
             #{item.musicSheetUpdate.subjectIds},
             #{item.musicSheetUpdate.musicSvg},
@@ -1291,5 +1320,11 @@
         set state_ = client_state_ and platform_state_
         where FIND_IN_SET(cbs_music_sheet_id_,#{ids})
     </update>
+
+    <update id="delPractice">
+        update sys_music_compare_record
+        set hidden_flag_ = 1
+        where user_id_ = #{userId} and music_sheet_id_ = #{musicSheetId} and client_id_ = #{clientEnum}
+    </update>
     <!--单曲专辑数量统计-->
 </mapper>

+ 4 - 0
cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetPracticeRecordMapper.xml

@@ -25,9 +25,13 @@
             left join music_sheet_auth_record msar ON msar.music_sheet_id_ = ms.id_
         </if>
         <where>
+            mspr.hidden_flag_ = 0
             <if test="param.auditStatus != null">
                 and msar.last_audit_state_ = #{param.auditStatus}
             </if>
+            <if test="param.clientType != null">
+                and mspr.client_id_ = #{param.clientType}
+            </if>
             <if test="param.providerType.code == 'TENANT'">
                 and find_in_set('TENANT',ms.provider_type_)
 

+ 20 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantAlbumMusicMapper.xml

@@ -84,8 +84,10 @@
         distinct t.music_sheet_id_
         FROM tenant_album_music t
         left join tenant_album_ref t1 on t1.tenant_album_id_ = t.tenant_album_id_
+        left join tenant_album t3 on t3.id_ = t1.tenant_album_id_
         left join music_sheet t2 on t2.id_ = t.music_sheet_id_  and find_in_set('TENANT',t2.provider_type_)
-        where t2.tenant_state_ = 1 and t2.tenant_del_flag_ = 0 and t2.audit_version_ = 0 and t1.tenant_id_ = #{tenantId} and t.del_flag_ = 0
+        where t2.tenant_state_ = 1 and t2.tenant_del_flag_ = 0 and t1.tenant_id_ = #{tenantId} and t.del_flag_ = 0
+         and t3.del_flag_=0 and t3.status_ = 1
     </select>
 
     <select id="getByAlbumAndEnable" resultType="com.yonge.cooleshow.biz.dal.entity.TenantAlbumMusic">
@@ -126,4 +128,21 @@
             or t.subject_type_ not in  ('ENSEMBLE', 'MUSIC', 'SUBJECT') OR m.is_all_subject_)
         </if>
     </select>
+
+    <select id="getTenantAlbumMusicIdsByIds" resultType="java.lang.Long">
+        select
+        distinct t.music_sheet_id_
+        from tenant_album_music t
+        left join music_sheet t1 on t1.id_ = t.music_sheet_id_ and find_in_set('TENANT',t1.provider_type_)
+        where t.del_flag_ = 0
+        and t.id_ in
+        <foreach collection="tenantAlbumIds" item="item" index="index" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+        and ( t.subject_type_ in  ('ENSEMBLE', 'MUSIC', 'SUBJECT') and t1.tenant_del_flag_ =0 and t1.tenant_state_ = 1)
+        and t.subject_type_ in
+        <foreach collection="subjectTypes" item="item" index="index" open="(" close=")" separator=",">
+            #{item.code}
+        </foreach>
+    </select>
 </mapper>