|  | @@ -3,6 +3,7 @@ package com.yonge.cooleshow.biz.dal.service.impl;
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSON;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
	
		
			
				|  |  | +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.auth.api.entity.SysUser;
 | 
	
	
		
			
				|  | @@ -26,12 +27,14 @@ 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.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;
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
	
		
			
				|  | @@ -63,7 +66,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |      private MusicSheetService musicSheetService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  | -    private  StudentService studentService;
 | 
	
		
			
				|  |  | +    private StudentService studentService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private TenantAlbumService tenantAlbumService;
 | 
	
	
		
			
				|  | @@ -92,12 +95,13 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查询详情
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param id 详情ID
 | 
	
		
			
				|  |  |       * @return UserTenantAlbumRecord
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public UserTenantAlbumRecord detail(Long id) {
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          return baseMapper.selectById(id);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -107,7 +111,8 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 分页查询
 | 
	
		
			
				|  |  | -     * @param page IPage<UserTenantAlbumRecord>
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param page  IPage<UserTenantAlbumRecord>
 | 
	
		
			
				|  |  |       * @param query UserTenantAlbumRecordWrapper.UserTenantAlbumRecordQuery
 | 
	
		
			
				|  |  |       * @return IPage<UserTenantAlbumRecord>
 | 
	
		
			
				|  |  |       */
 | 
	
	
		
			
				|  | @@ -119,15 +124,15 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          List<TenantAlbumWrapper.TenantAlbum> list = new ArrayList<>();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            //查询生效的机构专辑id
 | 
	
		
			
				|  |  | -        if (id != null){
 | 
	
		
			
				|  |  | +        //查询生效的机构专辑id
 | 
	
		
			
				|  |  | +        if (id != null) {
 | 
	
		
			
				|  |  |              List<Long> tenantAlbumIds = baseMapper.selectTenantIds(id);
 | 
	
		
			
				|  |  | -            if (CollectionUtils.isEmpty(tenantAlbumIds)){
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isEmpty(tenantAlbumIds)) {
 | 
	
		
			
				|  |  |                  return null;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              List<TenantAlbum> tenantAlbums = baseMapper.selectTenantAlbumInfo(tenantAlbumIds);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            tenantAlbums.stream().forEach(i->{
 | 
	
		
			
				|  |  | +            tenantAlbums.stream().forEach(i -> {
 | 
	
		
			
				|  |  |                  TenantAlbumWrapper.TenantAlbum vo = JSON.parseObject(JSON.toJSONString(i),
 | 
	
		
			
				|  |  |                          TenantAlbumWrapper.TenantAlbum.class);
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -192,26 +197,100 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |          return page.setRecords(list);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 分页查询
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param page  IPage<UserTenantAlbumRecord>
 | 
	
		
			
				|  |  | +     * @param query UserTenantAlbumRecordWrapper.UserTenantAlbumRecordQuery
 | 
	
		
			
				|  |  | +     * @return IPage<UserTenantAlbumRecord>
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public IPage<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> selectUserTenantAlbumRecordPage(IPage<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> page,
 | 
	
		
			
				|  |  | +                                                                                                     UserTenantAlbumRecordWrapper.UserTenantAlbumRecordQuery query) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        IPage<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> records = page.setRecords(baseMapper.selectUserTenantAlbumRecordPage(page, query));
 | 
	
		
			
				|  |  | +        List<UserTenantAlbumRecordWrapper.UserTenantAlbumRecord> rows = records.getRecords();
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(rows)) {
 | 
	
		
			
				|  |  | +            List<Long> collect = rows.stream().map(UserTenantAlbumRecordWrapper.UserTenantAlbumRecord::getTenantAlbumId).distinct().collect(Collectors.toList());
 | 
	
		
			
				|  |  | +            Map<Long, String> idNameMap = tenantAlbumService.lambdaQuery()
 | 
	
		
			
				|  |  | +                    .in(TenantAlbum::getId, collect)
 | 
	
		
			
				|  |  | +                    .list().stream().collect(Collectors.toMap(TenantAlbum::getId, TenantAlbum::getName));
 | 
	
		
			
				|  |  | +            rows.forEach(next -> next.setTenantAlbumName(idNameMap.getOrDefault(next.getTenantAlbumId(), "")));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return records;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 添加
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param userTenantAlbumRecord UserTenantAlbumRecordWrapper.UserTenantAlbumRecord
 | 
	
		
			
				|  |  |       * @return Boolean
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | +    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public Boolean add(UserTenantAlbumRecordWrapper.UserTenantAlbumRecord userTenantAlbumRecord) {
 | 
	
		
			
				|  |  | +    public Boolean add(UserTenantAlbumRecord userTenantAlbumRecord) {
 | 
	
		
			
				|  |  | +        Long tenantAlbumId = userTenantAlbumRecord.getTenantAlbumId();
 | 
	
		
			
				|  |  | +        TenantAlbum tenantAlbum = tenantAlbumMapper.selectById(tenantAlbumId);
 | 
	
		
			
				|  |  | +        if (tenantAlbum == null || Boolean.TRUE.equals(tenantAlbum.getDelFlag())) {
 | 
	
		
			
				|  |  | +            throw new BizException("专辑不存在");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (Boolean.FALSE.equals(tenantAlbum.getStatus())) {
 | 
	
		
			
				|  |  | +            throw new BizException("专辑已经停用");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        return this.save(JSON.parseObject(userTenantAlbumRecord.jsonString(), UserTenantAlbumRecord.class));
 | 
	
		
			
				|  |  | +        List<UserTenantAlbumRecord> userTenantAlbumRecords = this.getBaseMapper()
 | 
	
		
			
				|  |  | +                .selectList(Wrappers.<UserTenantAlbumRecord>lambdaQuery()
 | 
	
		
			
				|  |  | +                        .eq(UserTenantAlbumRecord::getTenantId, userTenantAlbumRecord.getTenantId())
 | 
	
		
			
				|  |  | +                        .eq(UserTenantAlbumRecord::getUserId, userTenantAlbumRecord.getUserId())
 | 
	
		
			
				|  |  | +                        .eq(UserTenantAlbumRecord::getTenantAlbumId, userTenantAlbumRecord.getTenantAlbumId())
 | 
	
		
			
				|  |  | +                        .eq(UserTenantAlbumRecord::getClientType, ClientEnum.STUDENT)
 | 
	
		
			
				|  |  | +                        .orderByDesc(UserTenantAlbumRecord::getEndTime));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Calendar instance = Calendar.getInstance();
 | 
	
		
			
				|  |  | +        instance.setTime(DateTime.now().withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0).toDate());
 | 
	
		
			
				|  |  | +        if (!userTenantAlbumRecords.isEmpty()) {
 | 
	
		
			
				|  |  | +            // 如果最后一次的时间的小于当前时间,则以当前时间为会员的开始时间
 | 
	
		
			
				|  |  | +            // 如果最后一次的时间的大于当前时间,则以最后一次的结束时间为记录的开始时间,相当会员续期
 | 
	
		
			
				|  |  | +            UserTenantAlbumRecord lastRecord = userTenantAlbumRecords.get(0);
 | 
	
		
			
				|  |  | +            Date lastEndTime = lastRecord.getEndTime();
 | 
	
		
			
				|  |  | +            if (lastEndTime.after(new Date())) {
 | 
	
		
			
				|  |  | +                instance.setTime(lastEndTime);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        userTenantAlbumRecord.setStartTime(instance.getTime());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String type = userTenantAlbumRecord.getType();
 | 
	
		
			
				|  |  | +        if ("DAY".equals(type)) {
 | 
	
		
			
				|  |  | +            instance.add(Calendar.DAY_OF_MONTH, userTenantAlbumRecord.getTimes());
 | 
	
		
			
				|  |  | +        } else if ("MONTH".equals(type)) {
 | 
	
		
			
				|  |  | +            instance.add(Calendar.MONTH, userTenantAlbumRecord.getTimes());
 | 
	
		
			
				|  |  | +        } else if ("YEAR".equals(type)) {
 | 
	
		
			
				|  |  | +            instance.add(Calendar.YEAR, userTenantAlbumRecord.getTimes());
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            throw new BizException("不支持的周期类型");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        instance.set(Calendar.HOUR_OF_DAY, 23);
 | 
	
		
			
				|  |  | +        instance.set(Calendar.MINUTE, 59);
 | 
	
		
			
				|  |  | +        instance.set(Calendar.SECOND, 59);
 | 
	
		
			
				|  |  | +        instance.set(Calendar.MILLISECOND, 0);
 | 
	
		
			
				|  |  | +        userTenantAlbumRecord.setEndTime(instance.getTime());
 | 
	
		
			
				|  |  | +        userTenantAlbumRecord.setCreateTime(new Date());
 | 
	
		
			
				|  |  | +        userTenantAlbumRecord.setUpdateTime(new Date());
 | 
	
		
			
				|  |  | +        return this.save(userTenantAlbumRecord);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 更新
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @param userTenantAlbumRecord UserTenantAlbumRecordWrapper.UserTenantAlbumRecord
 | 
	
		
			
				|  |  |       * @return Boolean
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public Boolean update(UserTenantAlbumRecordWrapper.UserTenantAlbumRecord userTenantAlbumRecord){
 | 
	
		
			
				|  |  | +    public Boolean update(UserTenantAlbumRecordWrapper.UserTenantAlbumRecord userTenantAlbumRecord) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        return this.updateById(JSON.parseObject(userTenantAlbumRecord.jsonString(), UserTenantAlbumRecord.class));       
 | 
	
		
			
				|  |  | +        return this.updateById(JSON.parseObject(userTenantAlbumRecord.jsonString(), UserTenantAlbumRecord.class));
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -230,6 +309,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          return recordList.get(0);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 获取最新的购买记录
 | 
	
		
			
				|  |  |       *
 | 
	
	
		
			
				|  | @@ -246,14 +326,14 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |                  .eq(UserTenantAlbumRecord::getTenantId, tenantId)
 | 
	
		
			
				|  |  |                  .eq(UserTenantAlbumRecord::getUserId, userId)
 | 
	
		
			
				|  |  |                  .eq(UserTenantAlbumRecord::getClientType, clientType)
 | 
	
		
			
				|  |  | -                .in(CollectionUtils.isNotEmpty(tenantAlbumIds),UserTenantAlbumRecord::getTenantAlbumId,tenantAlbumIds)
 | 
	
		
			
				|  |  | +                .in(CollectionUtils.isNotEmpty(tenantAlbumIds), UserTenantAlbumRecord::getTenantAlbumId, tenantAlbumIds)
 | 
	
		
			
				|  |  |                  .ge(UserTenantAlbumRecord::getEndTime, new Date())
 | 
	
		
			
				|  |  |                  .orderByDesc(UserTenantAlbumRecord::getEndTime)
 | 
	
		
			
				|  |  |                  .list();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public List<Long> getUseAlbumIdsByUserId(Long userId,ClientEnum clientType) {
 | 
	
		
			
				|  |  | +    public List<Long> getUseAlbumIdsByUserId(Long userId, ClientEnum clientType) {
 | 
	
		
			
				|  |  |          if (userId == null) {
 | 
	
		
			
				|  |  |              return new ArrayList<>();
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -281,7 +361,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |              throw new BizException("用户不存在");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          Long tenantAlbumId;
 | 
	
		
			
				|  |  | -        if (StringUtils.isEmpty(albumId)){
 | 
	
		
			
				|  |  | +        if (StringUtils.isEmpty(albumId)) {
 | 
	
		
			
				|  |  |              Long id = sysUser.getId();
 | 
	
		
			
				|  |  |              List<Student> list = studentService.lambdaQuery().eq(Student::getUserId, id).list();
 | 
	
		
			
				|  |  |              if (CollectionUtils.isEmpty(list)) {
 | 
	
	
		
			
				|  | @@ -292,7 +372,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |              Long tenantId = student.getTenantId();
 | 
	
		
			
				|  |  |              //查询对应专辑id
 | 
	
		
			
				|  |  |              List<TenantAlbumMusic> tenantAlbumMusicList = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getTenantId, tenantId)
 | 
	
		
			
				|  |  | -                    .eq(TenantAlbumMusic::getDelFlag,false).list();
 | 
	
		
			
				|  |  | +                    .eq(TenantAlbumMusic::getDelFlag, false).list();
 | 
	
		
			
				|  |  |              if (CollectionUtils.isEmpty(tenantAlbumMusicList)) {
 | 
	
		
			
				|  |  |                  return null;
 | 
	
		
			
				|  |  |              }
 | 
	
	
		
			
				|  | @@ -304,7 +384,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //获取对应机构专辑状态
 | 
	
		
			
				|  |  |          TenantAlbum one = tenantAlbumService.lambdaQuery().eq(TenantAlbum::getId, tenantAlbumId).last("limit 1").one();
 | 
	
		
			
				|  |  | -        if (!ObjectUtil.isEmpty(one)){
 | 
	
		
			
				|  |  | +        if (!ObjectUtil.isEmpty(one)) {
 | 
	
		
			
				|  |  |              album.setStatus(one.getStatus());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -321,7 +401,7 @@ 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);
 | 
	
	
		
			
				|  | @@ -341,12 +421,10 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          //查询是否已经购买专辑
 | 
	
		
			
				|  |  | -        Long buyTenantAlbumId = userTenantAlbumRecordMapper.ifBuy(tenantAlbumId,sysUser.getId());
 | 
	
		
			
				|  |  | +        Long buyTenantAlbumId = userTenantAlbumRecordMapper.ifBuy(tenantAlbumId, sysUser.getId());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        if (buyTenantAlbumId != null){
 | 
	
		
			
				|  |  | +        if (buyTenantAlbumId != null) {
 | 
	
		
			
				|  |  |              album.setIfBuy(true);
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              album.setIfBuy(false);
 | 
	
	
		
			
				|  | @@ -355,7 +433,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //查询对应专辑的详情
 | 
	
		
			
				|  |  |          List<TenantAlbum> list = tenantAlbumService.lambdaQuery().eq(TenantAlbum::getId, tenantAlbumId).list();
 | 
	
		
			
				|  |  | -        if (CollectionUtils.isEmpty(list)){
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isEmpty(list)) {
 | 
	
		
			
				|  |  |              throw new BizException("机构专辑不存在");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          TenantAlbum tenantAlbum = list.get(0);
 | 
	
	
		
			
				|  | @@ -364,10 +442,10 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |          //机构专辑封面
 | 
	
		
			
				|  |  |          String coverImg = tenantAlbum.getCoverImg();
 | 
	
		
			
				|  |  |          //机构专辑曲目数
 | 
	
		
			
				|  |  | -        List<TenantAlbumMusic> tenantAlbumMusiclist = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId).eq(TenantAlbumMusic::getDelFlag,false).list();
 | 
	
		
			
				|  |  | +        List<TenantAlbumMusic> tenantAlbumMusiclist = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId).eq(TenantAlbumMusic::getDelFlag, false).list();
 | 
	
		
			
				|  |  |          List<Long> MusicSheetIds = tenantAlbumMusiclist.stream().map(TenantAlbumMusic::getMusicSheetId).distinct().collect(Collectors.toList());
 | 
	
		
			
				|  |  |          //计算符合条件的个数
 | 
	
		
			
				|  |  | -        if (CollectionUtils.isNotEmpty(MusicSheetIds)){
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(MusicSheetIds)) {
 | 
	
		
			
				|  |  |              size = musicSheetService.lambdaQuery().in(MusicSheet::getId, MusicSheetIds).eq(MusicSheet::getState, true)
 | 
	
		
			
				|  |  |                      .eq(MusicSheet::getDelFlag, false).count();
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -376,7 +454,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |          //获取合奏曲目数量
 | 
	
		
			
				|  |  |          List<TenantAlbumMusic> ensembleLits = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getSubjectType, "ENSEMBLE")
 | 
	
		
			
				|  |  |                  .eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId)
 | 
	
		
			
				|  |  | -                .eq(TenantAlbumMusic::getDelFlag,false).list();
 | 
	
		
			
				|  |  | +                .eq(TenantAlbumMusic::getDelFlag, false).list();
 | 
	
		
			
				|  |  |          List<Long> ensembleMusicSheetIds = ensembleLits.stream().map(TenantAlbumMusic::getMusicSheetId).distinct().collect(Collectors.toList());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          album.setEnsembleCounts(ensembleMusicSheetIds.size());
 | 
	
	
		
			
				|  | @@ -384,7 +462,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |          //获取小曲目的曲目数量
 | 
	
		
			
				|  |  |          List<TenantAlbumMusic> musicLists = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getSubjectType, "MUSIC")
 | 
	
		
			
				|  |  |                  .eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId)
 | 
	
		
			
				|  |  | -                .eq(TenantAlbumMusic::getDelFlag,false).list();
 | 
	
		
			
				|  |  | +                .eq(TenantAlbumMusic::getDelFlag, false).list();
 | 
	
		
			
				|  |  |          List<Long> musicSheetIds = musicLists.stream().map(TenantAlbumMusic::getMusicSheetId).distinct().collect(Collectors.toList());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          album.setMusicCounts(musicSheetIds.size());
 | 
	
	
		
			
				|  | @@ -392,7 +470,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |          //获取声部的曲目数量
 | 
	
		
			
				|  |  |          List<TenantAlbumMusic> subjectLists = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getSubjectType, "SUBJECT")
 | 
	
		
			
				|  |  |                  .eq(TenantAlbumMusic::getTenantAlbumId, tenantAlbumId)
 | 
	
		
			
				|  |  | -                .eq(TenantAlbumMusic::getDelFlag,false).list();
 | 
	
		
			
				|  |  | +                .eq(TenantAlbumMusic::getDelFlag, false).list();
 | 
	
		
			
				|  |  |          List<Long> subjectSheetIds = subjectLists.stream().map(TenantAlbumMusic::getMusicSheetId).distinct().collect(Collectors.toList());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          album.setSubjectCounts(subjectSheetIds.size());
 | 
	
	
		
			
				|  | @@ -459,7 +537,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private void temporarySend(Long userId,Long tenantAlbumId) {
 | 
	
		
			
				|  |  | +    private void temporarySend(Long userId, Long tenantAlbumId) {
 | 
	
		
			
				|  |  |          SysUser sysUser = sysUserFeignService.queryUserById(userId);
 | 
	
		
			
				|  |  |          if (null == sysUser) {
 | 
	
		
			
				|  |  |              return;
 | 
	
	
		
			
				|  | @@ -473,7 +551,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          try {
 | 
	
		
			
				|  |  |              sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.TENANT_ALBUM_EXPIRE,
 | 
	
		
			
				|  |  | -                    receivers, null, 0, null, ClientEnum.TENANT_STUDENT.getCode(),tenantAlbum.getName());
 | 
	
		
			
				|  |  | +                    receivers, null, 0, null, ClientEnum.TENANT_STUDENT.getCode(), tenantAlbum.getName());
 | 
	
		
			
				|  |  |          } catch (Exception e) {
 | 
	
		
			
				|  |  |              log.error("机构学生训练教材过期", e);
 | 
	
		
			
				|  |  |          }
 |