|  | @@ -5,9 +5,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.dao.UserOrderDao;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.entity.Student;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.entity.TenantAlbumMusic;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.entity.TenantStaff;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMusicMapper;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.StudentService;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.service.TenantAlbumMusicService;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.TenantStaffService;
 | 
	
		
			
				|  |  |  import com.yonge.toolset.base.exception.BizException;
 | 
	
		
			
				|  |  |  import org.apache.commons.collections.CollectionUtils;
 | 
	
	
		
			
				|  | @@ -20,6 +24,7 @@ import com.yonge.cooleshow.biz.dal.mapper.TenantGroupAlbumMapper;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.TenantGroupAlbumService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  | +import java.util.Map;
 | 
	
		
			
				|  |  |  import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
	
		
			
				|  | @@ -39,6 +44,9 @@ public class TenantGroupAlbumServiceImpl extends ServiceImpl<TenantGroupAlbumMap
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private UserOrderDao userOrderDao;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private TenantAlbumMusicMapper tenantAlbumMusicMapper;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  	/**
 | 
	
		
			
				|  |  |       * 查询详情
 | 
	
		
			
				|  |  |       * @param id 详情ID
 | 
	
	
		
			
				|  | @@ -111,6 +119,28 @@ public class TenantGroupAlbumServiceImpl extends ServiceImpl<TenantGroupAlbumMap
 | 
	
		
			
				|  |  |          if (CollectionUtils.isEmpty(buyAlbumInfo)) {
 | 
	
		
			
				|  |  |              return buyAlbumInfo;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        // 查询专辑可用的分类的曲目数量
 | 
	
		
			
				|  |  | +        // 机构专辑ID集合
 | 
	
		
			
				|  |  | +        List<Long> tenantAlbumIds = buyAlbumInfo.stream().map(TenantGroupAlbumWrapper.BuyTenantAlbum::getId).collect(Collectors.toList());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        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())));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        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 (clientType == ClientEnum.STUDENT) {
 |