| 
					
				 | 
			
			
				@@ -15,15 +15,12 @@ import com.yonge.cooleshow.biz.dal.enums.ClientEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.enums.MessageTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.enums.PeriodEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumPurchaseMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumRefMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.yonge.cooleshow.biz.dal.mapper.TenantInfoMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.mapper.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.service.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.vo.MusicSheetVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.vo.StudentVo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.yonge.cooleshow.biz.dal.wrapper.TenantGroupAlbumWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.common.enums.YesOrNoEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.toolset.base.exception.BizException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.toolset.mybatis.support.PageUtil; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -31,13 +28,13 @@ import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.toolset.utils.obj.ObjectUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.collections.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.jetbrains.annotations.Nullable; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.joda.time.DateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.BeanUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.yonge.cooleshow.biz.dal.wrapper.UserTenantAlbumRecordWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.yonge.cooleshow.biz.dal.mapper.UserTenantAlbumRecordMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.math.BigDecimal; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -103,6 +100,15 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private TenantInfoMapper tenantInfoMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private TenantGroupAlbumService tenantGroupAlbumService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private TenantGroupAlbumMapper tenantGroupAlbumMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private TenantAlbumMusicMapper tenantAlbumMusicMapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 查询详情 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -386,26 +392,35 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (sysUser == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             throw new BizException("用户不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Long>  tenantAlbumIds = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Long tenantAlbumId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (StringUtils.isEmpty(albumId)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Long id = sysUser.getId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            List<Student> list = studentService.lambdaQuery().eq(Student::getUserId, id).list(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (CollectionUtils.isEmpty(list)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                throw new BizException("学生账号未找到"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Student student = list.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Student student = studentService.getById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //获取机构Id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             Long tenantId = student.getTenantId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //查询对应专辑id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            List<TenantAlbumMusic> tenantAlbumMusicList = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getTenantId, tenantId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .eq(TenantAlbumMusic::getDelFlag, false).list(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (CollectionUtils.isEmpty(tenantAlbumMusicList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            // 如果没有小组, 就没有专辑 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (student.getTenantGroupId() == null || tenantId ==null || tenantId <=0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                album.setTenantAlbumStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                album.setTenantAlbumFlag(YesOrNoEnum.NO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return album; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //查询对应小组专辑id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                List<TenantGroupAlbum> list = tenantGroupAlbumService.lambdaQuery() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .eq(TenantGroupAlbum::getTenantGroupId, student.getTenantGroupId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .eq(TenantGroupAlbum::getDelFlag, false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .eq(TenantGroupAlbum::getStatus, true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .list(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                // 专辑ID集合 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                tenantAlbumIds = list.stream().map(TenantGroupAlbum::getTenantAlbumId).distinct().collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return getTenantAlbum(sysUser, album, tenantAlbumIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            TenantAlbumMusic tenantAlbumMusic = tenantAlbumMusicList.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            tenantAlbumId = tenantAlbumMusic.getTenantAlbumId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //如果传专辑id   则查询这个专辑的详情 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            tenantAlbumIds.add(Long.parseLong(albumId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             tenantAlbumId = Long.parseLong(albumId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //获取对应机构专辑状态 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -427,15 +442,15 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 List<Long> albIds = albumRefs.stream().map(TenantAlbumRef::getTenantAlbumId).distinct().collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 QueryWrapper<TenantAlbum> query = new QueryWrapper<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 query.lambda().in(TenantAlbum::getId, albIds) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        .eq(TenantAlbum::getStatus, true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .eq(TenantAlbum::getStatus, true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 Integer count = tenantAlbumMapper.selectCount(query); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (count > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     album.setTenantAlbumStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             UserTenantAlbumRecord record = 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    userTenantAlbumRecordService.getNewestByTenantIdAndUserId(tenantInfo.getId(), detail.getUserId(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            ClientEnum.STUDENT); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                userTenantAlbumRecordService.getNewestByTenantIdAndUserId(tenantInfo.getId(), detail.getUserId(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    ClientEnum.STUDENT); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (record == null || record.getEndTime().getTime() < System.currentTimeMillis()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 album.setTenantAlbumFlag(YesOrNoEnum.NO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } else { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -448,13 +463,9 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //查询是否已经购买专辑 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        Long buyTenantAlbumId = userTenantAlbumRecordMapper.ifBuy(tenantAlbumId, sysUser.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Long> buyTenantAlbumId = userTenantAlbumRecordMapper.ifBuy(Lists.newArrayList(tenantAlbumId), sysUser.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (buyTenantAlbumId != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            album.setIfBuy(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            album.setIfBuy(false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        album.setIfBuy(CollectionUtils.isNotEmpty(buyTenantAlbumId)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //查询对应专辑的详情 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -473,30 +484,30 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //计算符合条件的个数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (CollectionUtils.isNotEmpty(MusicSheetIds)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             size = musicSheetService.lambdaQuery().in(MusicSheet::getId, MusicSheetIds).eq(MusicSheet::getState, true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .eq(MusicSheet::getDelFlag, false).count(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .eq(MusicSheet::getDelFlag, false).count(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //Integer musicNum = tenantAlbum.getMusicNum(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //获取合奏曲目数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<TenantAlbumMusic> ensembleLits = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getSubjectType, "ENSEMBLE") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .eq(TenantAlbumMusic::getDelFlag, false).list(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .eq(TenantAlbumMusic::getDelFlag, false).list(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<Long> ensembleMusicSheetIds = ensembleLits.stream().map(TenantAlbumMusic::getMusicSheetId).distinct().collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         album.setEnsembleCounts(ensembleMusicSheetIds.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //获取小曲目的曲目数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<TenantAlbumMusic> musicLists = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getSubjectType, "MUSIC") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .eq(TenantAlbumMusic::getDelFlag, false).list(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .eq(TenantAlbumMusic::getDelFlag, false).list(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<Long> musicSheetIds = musicLists.stream().map(TenantAlbumMusic::getMusicSheetId).distinct().collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         album.setMusicCounts(musicSheetIds.size()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //获取声部的曲目数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<TenantAlbumMusic> subjectLists = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getSubjectType, "SUBJECT") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                .eq(TenantAlbumMusic::getDelFlag, false).list(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .eq(TenantAlbumMusic::getDelFlag, false).list(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<Long> subjectSheetIds = subjectLists.stream().map(TenantAlbumMusic::getMusicSheetId).distinct().collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         album.setSubjectCounts(subjectSheetIds.size()); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -525,6 +536,106 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return album; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Nullable 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private TenantAlbumWrapper.TenantAlbum getTenantAlbum(SysUser sysUser, TenantAlbumWrapper.TenantAlbum album, List<Long> tenantAlbumIds) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StudentVo detail = detailStudent(sysUser.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 判断是否是机构学生 机构学生 检测机构专辑购买记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        TenantInfo tenantInfo = tenantInfoService.detail(detail.getTenantId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (tenantInfo == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return album; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 判断小组有没有曲目 ,小组有曲目有专辑 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        TenantGroupAlbumWrapper.BuyTenantAlbumQuery query = new TenantGroupAlbumWrapper.BuyTenantAlbumQuery(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        query.setTenantAlbumIds(tenantAlbumIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<TenantGroupAlbumWrapper.BuyTenantAlbum> buyAlbumInfo = tenantGroupAlbumMapper.getBuyAlbumInfo(query); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (CollectionUtils.isNotEmpty(buyAlbumInfo)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            album.setTenantAlbumStatus(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }  else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            album.setTenantAlbumStatus(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return album; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        tenantAlbumIds = buyAlbumInfo.stream().map(TenantGroupAlbumWrapper.BuyTenantAlbum::getId).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //获取对应机构专辑状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<TenantAlbum> albumList = tenantAlbumService.lambdaQuery() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .in(TenantAlbum::getId, tenantAlbumIds) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .list(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (CollectionUtils.isEmpty(albumList)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new BizException("专辑不存在"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //查询是否已经购买专辑 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Long> ifedBuy = userTenantAlbumRecordMapper.ifBuy(tenantAlbumIds, sysUser.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (CollectionUtils.isNotEmpty(ifedBuy)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            album.setIfBuy(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            album.setTenantAlbumStatus(2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            album.setIfBuy(false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //查询对应专辑的详情 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        TenantAlbum tenantAlbum = albumList.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //机构专辑曲目数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<TenantAlbumMusic> list = tenantAlbumMusicMapper.getByAlbumAndEnable(tenantAlbumIds); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 根据专辑ID分组 在根据声部分类 分组 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<Long, Map<SubjectTypeEnum, Long>> map = list.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            .collect(Collectors.groupingBy(TenantAlbumMusic::getTenantAlbumId, Collectors.groupingBy(TenantAlbumMusic::getSubjectType,Collectors.counting()))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Set<String> subjectTypes = new HashSet<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int size = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int musicSize = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int ensembleSize = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int subjectSize = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (TenantGroupAlbumWrapper.BuyTenantAlbum buyTenantAlbum : buyAlbumInfo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<SubjectTypeEnum, Long> subjectTypeEnumLongMap = map.get(buyTenantAlbum.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (subjectTypeEnumLongMap != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                buyTenantAlbum.setMusicCounts(subjectTypeEnumLongMap.getOrDefault(SubjectTypeEnum.MUSIC,0L).intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                buyTenantAlbum.setEnsembleCounts(subjectTypeEnumLongMap.getOrDefault(SubjectTypeEnum.ENSEMBLE,0L).intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                buyTenantAlbum.setSubjectCounts(subjectTypeEnumLongMap.getOrDefault(SubjectTypeEnum.SUBJECT,0L).intValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                buyTenantAlbum.setMusicCounts(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                buyTenantAlbum.setEnsembleCounts(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                buyTenantAlbum.setSubjectCounts(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            buyTenantAlbum.setMusicNum(buyTenantAlbum.getMusicCounts() + buyTenantAlbum.getEnsembleCounts()+buyTenantAlbum.getSubjectCounts()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (buyTenantAlbum.getMusicNum() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                subjectTypes.add(SubjectTypeEnum.MUSIC.name()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (buyTenantAlbum.getEnsembleCounts() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                subjectTypes.add(SubjectTypeEnum.ENSEMBLE.name()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (buyTenantAlbum.getSubjectCounts() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                subjectTypes.add(SubjectTypeEnum.SUBJECT.name()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            size += buyTenantAlbum.getMusicNum(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            musicSize += buyTenantAlbum.getMusicCounts(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ensembleSize += buyTenantAlbum.getEnsembleCounts(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            subjectSize += buyTenantAlbum.getSubjectCounts(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //机构专辑简介 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        album.setEnsembleCounts(ensembleSize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        album.setMusicCounts(musicSize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        album.setSubjectCounts(subjectSize); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        album.setId(String.valueOf(tenantAlbum.getId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        album.setName(tenantAlbum.getName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        album.setCoverImg(tenantAlbum.getCoverImg()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        album.setMusicNum(size); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        album.setDescribe(tenantAlbum.getDescribe()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        album.setSubjectTypes(subjectTypes.stream().collect(Collectors.joining(","))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        album.setCostPrice(tenantAlbum.getCostPrice()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        album.setPurchaseCycle(tenantAlbum.getPurchaseCycle()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        album.setSalePrice(tenantAlbum.getSalePrice()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return album; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void sendTenantAlbumMessage() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> userTenantAlbumRecords = baseMapper.selectTemporaryRecord(); 
			 |