Bladeren bron

获取最近过期的专辑

zouxuan 2 maanden geleden
bovenliggende
commit
948d105add

+ 11 - 7
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserTenantAlbumRecordServiceImpl.java

@@ -921,7 +921,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
         Long tenantAlbumId = null;
         Date endTime = null;
         //忽略已删除的专辑
-        this.ignoreTenantAlbumIds(albumRecords);
+        this.ignoreTenantAlbumIds(albumRecords,userId);
         if (CollectionUtils.isNotEmpty(albumRecords)) {
             //按专辑编号分组,然后找出截止时间最大的记录
             Map<Long, UserTenantAlbumRecord> recordMap = albumRecords.stream()
@@ -962,7 +962,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
     }
 
     //忽略已删除的专辑
-    private void ignoreTenantAlbumIds(List<UserTenantAlbumRecord> albumRecords) {
+    private void ignoreTenantAlbumIds(List<UserTenantAlbumRecord> albumRecords,Long userId) {
         if(CollectionUtils.isNotEmpty(albumRecords)){
             //获取所有专辑列表
             List<Long> tenantAlbumIds = albumRecords.stream().map(UserTenantAlbumRecord::getTenantAlbumId).distinct().collect(Collectors.toList());
@@ -972,13 +972,17 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
             if (CollectionUtils.isNotEmpty(list)){
                 ignoreTenantAlbumIds = list.stream().map(TenantAlbum::getId).collect(Collectors.toList());
             }
-            List<TenantGroupAlbum> groupAlbums = tenantGroupAlbumService.lambdaQuery().in(TenantGroupAlbum::getTenantAlbumId, tenantAlbumIds)
-                    .eq(TenantGroupAlbum::getDelFlag, true).or().eq(TenantGroupAlbum::getStatus, false).list();
-            if (CollectionUtils.isNotEmpty(groupAlbums)){
-                ignoreTenantAlbumIds.addAll(groupAlbums.stream().map(TenantGroupAlbum::getTenantAlbumId).collect(Collectors.toList()));
+            Student student = studentDao.selectById(userId);
+            if(student != null && student.getTenantGroupId() != null){
+                List<TenantGroupAlbum> groupAlbums = tenantGroupAlbumService.lambdaQuery().in(TenantGroupAlbum::getTenantAlbumId, tenantAlbumIds)
+                        .eq(TenantGroupAlbum::getTenantGroupId, student.getTenantGroupId())
+                        .eq(TenantGroupAlbum::getDelFlag, true).or().eq(TenantGroupAlbum::getStatus, false).list();
+                if (CollectionUtils.isNotEmpty(groupAlbums)){
+                    ignoreTenantAlbumIds.addAll(groupAlbums.stream().map(TenantGroupAlbum::getTenantAlbumId).distinct().collect(Collectors.toList()));
+                }
             }
             List<Long> finalIgnoreTenantAlbumIds = ignoreTenantAlbumIds;
-            albumRecords = albumRecords.stream().filter(x -> !finalIgnoreTenantAlbumIds.contains(x.getTenantAlbumId())).collect(Collectors.toList());
+            albumRecords = albumRecords.stream().filter(x -> finalIgnoreTenantAlbumIds.contains(x.getTenantAlbumId())).collect(Collectors.toList());
         }
     }