| 
					
				 | 
			
			
				@@ -57,12 +57,15 @@ import com.yonge.cooleshow.biz.dal.entity.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.entity.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.enums.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.enums.album.PurchaseRecordTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMusicMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.mapper.TenantGroupAlbumMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.mapper.UserTenantAlbumRecordMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.service.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.support.WrapperUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.vo.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.vo.res.OrderCreateRes; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.wrapper.TenantGroupAlbumWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.wrapper.UserPaymentOrderWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.wrapper.music.MusicCompareWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.common.constant.SysConfigConstant; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -206,6 +209,12 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private UserTenantAlbumRecordService userTenantAlbumRecordService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private TenantGroupAlbumMapper tenantGroupAlbumMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private TenantAlbumMusicMapper tenantAlbumMusicMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public MusicSheetDao getDao() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return musicSheetDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -405,7 +414,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public MusicSheetDetailVo detail(Long id, SysUser sysUser, ClientEnum userType,Long tenantAlbumId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public MusicSheetDetailVo detail(Long id, SysUser sysUser, ClientEnum userType,String tenantAlbumId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         MusicSheetDetailVo detail = baseMapper.detail(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (detail == null) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -441,7 +450,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             String reason = musicSheetAuthRecordService.selectAuditReason(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             detail.setReason(reason); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (tenantAlbumId == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (StringUtil.isEmpty(tenantAlbumId)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (detail.getPaymentType().contains(ChargeTypeEnum.FREE.getCode())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 detail.setPlay(YesOrNoEnum.YES); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } else if (ClientEnum.STUDENT.getCode().equals(userType.getCode()) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -458,12 +467,15 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 机构专辑购买 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             detail.setPlay(YesOrNoEnum.NO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<Long> collected = Arrays.stream(tenantAlbumId.split(",")).map(Long::parseLong).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 学生生效中的机构专辑 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (ClientEnum.STUDENT == userType) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 List<Long> tenantAlbumIds = userTenantAlbumRecordMapper.selectTenantIds(sysUser.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (CollectionUtils.isNotEmpty(tenantAlbumIds) && tenantAlbumIds.contains(tenantAlbumId)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    List<Long> musicSheetIds = tenantAlbumMusicService.getMusicIdsByIds(Lists.newArrayList(tenantAlbumId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (CollectionUtils.isNotEmpty(tenantAlbumIds)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // tenantAlbumIds collected 取交集到 新的集合 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    List<Long> collect = tenantAlbumIds.stream().filter(collected::contains).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    List<Long> musicSheetIds = tenantAlbumMusicService.getMusicIdsByIds(collect); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     if (CollectionUtils.isNotEmpty(musicSheetIds) && musicSheetIds.contains(detail.getId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         detail.setPlay(YesOrNoEnum.YES); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1906,26 +1918,26 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (student == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             throw new BizException("学生不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (student.getTenantId() == null || student.getTenantId() == -1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new BizException("学生未绑定机构"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (student.getTenantId() == null || student.getTenantId() == -1 || student.getTenantGroupId() == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return searchData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 查询机构下的专辑 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<TenantAlbum> albumList = tenantAlbumService.getByTenantId(student.getTenantId(), true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<Long> albumIds = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (CollectionUtils.isNotEmpty(albumList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            albumIds = albumList.stream().map(TenantAlbum::getId).distinct().collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 查询机构 小组下的专辑 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        TenantGroupAlbumWrapper.BuyTenantAlbumQuery query = new TenantGroupAlbumWrapper.BuyTenantAlbumQuery(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        query.setTenantGroupId(student.getTenantGroupId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<TenantGroupAlbumWrapper.BuyTenantAlbum> buyAlbumInfo = tenantGroupAlbumMapper.getBuyAlbumInfo(query); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Long> albumIds; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (CollectionUtils.isNotEmpty(buyAlbumInfo)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            albumIds = buyAlbumInfo.stream().map(TenantGroupAlbumWrapper.BuyTenantAlbum::getId).distinct().collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return searchData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        List<UserTenantAlbumRecord> recordList = userTenantAlbumRecordService 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                .getNewestByTenantIdAndUserId(student.getTenantId(), queryInfo.getUserId(), ClientEnum.STUDENT, albumIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        if (CollectionUtils.isNotEmpty(recordList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            albumIds = recordList.stream().map(UserTenantAlbumRecord::getTenantAlbumId).distinct().collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            return searchData; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<TenantAlbumMusic> list = tenantAlbumMusicMapper.getByAlbumAndEnable(albumIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 根据曲目ID分组 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Long, List<Long>> map = list.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .collect(Collectors.groupingBy(TenantAlbumMusic::getMusicSheetId, Collectors.mapping(TenantAlbumMusic::getTenantAlbumId, Collectors.toList()))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         queryInfo.setTenantAlbumIds(albumIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // 查询曲目列表 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1945,8 +1957,12 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao, MusicSheet 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     musicName.setType("MUSIC"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     musicName.setHotFlag(record.getHotFlag() != null?record.getHotFlag():YesOrNoEnum.NO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     musicName.setSort(Optional.ofNullable(record.getFavoriteCount()).orElse(0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    musicName.setTenantAlbumId(Optional.ofNullable(map.get(record.getId())).orElse(new ArrayList<>()).stream().map(String::valueOf).collect(Collectors.joining(","))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     musicNames.add(musicName); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    record.setTenantAlbumId(Optional.ofNullable(map.get(record.getId())).orElse(new ArrayList<>()).stream().map(String::valueOf).collect(Collectors.joining(","))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                musicSheetVoIPage.setRecords(records); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 searchData.setMusic(PageUtil.pageInfo(musicSheetVoIPage)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 |