yonge 6 days ago
parent
commit
c80a7be575

+ 2 - 1
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/UserTenantAlbumRecordController.java

@@ -2,6 +2,7 @@ package com.yonge.cooleshow.admin.controller;
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.dayaedu.cbs.common.enums.EClientType;
 import com.microsvc.toolkit.common.response.paging.PageInfo;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.microsvc.toolkit.common.response.template.R;
@@ -70,7 +71,7 @@ public class UserTenantAlbumRecordController extends BaseController {
         userTenantAlbumRecord.setType(userTenantAlbumRecordVo.getType());
         userTenantAlbumRecord.setReason(userTenantAlbumRecordVo.getReason());
         userTenantAlbumRecord.setUserId(userTenantAlbumRecordVo.getUserId());
-        //userTenantAlbumRecord.setClientType(ClientEnum.STUDENT);
+        userTenantAlbumRecord.setClientType(ClientEnum.valueOf(userTenantAlbumRecordVo.getClientType()));
         userTenantAlbumRecord.setSourceType(SourceTypeEnum.BACKEND_GIVE);
 
         SysUser sysUser = sysUserService.getUser();

+ 2 - 1
cooleshow-app/src/main/java/com/yonge/cooleshow/student/controller/UserTenantAlbumRecordController.java

@@ -9,6 +9,7 @@ import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.entity.Student;
 import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
 import com.yonge.cooleshow.biz.dal.entity.UserTenantAlbumRecord;
+import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.service.StudentService;
 import com.yonge.cooleshow.biz.dal.service.SysUserService;
 import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
@@ -137,6 +138,6 @@ public class UserTenantAlbumRecordController {
     @GetMapping("/lastRecord")
     public HttpResponseResult<UserTenantAlbumRecordWrapper.LastUserTenantAlbumRecord> last() {
         SysUser user = sysUserService.getUser();
-        return HttpResponseResult.succeed(userTenantAlbumRecordService.last(user.getId(),user.getTenantId(),null));
+        return HttpResponseResult.succeed(userTenantAlbumRecordService.last(user.getId(),user.getTenantId(),null, ClientEnum.STUDENT));
     }
 }

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/UserTenantAlbumRecordService.java

@@ -96,5 +96,5 @@ public interface UserTenantAlbumRecordService extends IService<UserTenantAlbumRe
 
     List<UserTenantAlbumRecordWrapper.Info> info(UserTenantAlbumRecordWrapper.InfoQuery infoQuery);
 
-    UserTenantAlbumRecordWrapper.LastUserTenantAlbumRecord last(Long userId,Long tenantId, Long tenantAlbumId);
+    UserTenantAlbumRecordWrapper.LastUserTenantAlbumRecord last(Long userId,Long tenantId, Long tenantAlbumId, ClientEnum clientType);
 }

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantGroupAlbumServiceImpl.java

@@ -226,7 +226,7 @@ public class TenantGroupAlbumServiceImpl extends ServiceImpl<TenantGroupAlbumMap
                     item.setExpireTime(userTenantAlbumRecord.getEndTime());
                 }
                 item.setSort(sortMap.getOrDefault(item.getId(),0L));
-                UserTenantAlbumRecordWrapper.LastUserTenantAlbumRecord albumRecord = userTenantAlbumRecordService.last(query.getUserId(),query.getTenantId(), item.getId());
+                UserTenantAlbumRecordWrapper.LastUserTenantAlbumRecord albumRecord = userTenantAlbumRecordService.last(query.getUserId(),query.getTenantId(), item.getId(), query.getClientType());
                 if (albumRecord != null) {
                     item.setEndTime(albumRecord.getEndTime());
                 }

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

@@ -214,7 +214,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
                         .eq(UserTenantAlbumRecord::getTenantId, userTenantAlbumRecord.getTenantId())
                         .eq(UserTenantAlbumRecord::getUserId, userTenantAlbumRecord.getUserId())
                         .eq(UserTenantAlbumRecord::getTenantAlbumId, userTenantAlbumRecord.getTenantAlbumId())
-                        .eq(UserTenantAlbumRecord::getClientType, ClientEnum.STUDENT)
+                        .eq(UserTenantAlbumRecord::getClientType, userTenantAlbumRecord.getClientType())
                         .orderByDesc(UserTenantAlbumRecord::getEndTime));
 
         Calendar instance = Calendar.getInstance();
@@ -909,19 +909,20 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
     }
 
     @Override
-    public UserTenantAlbumRecordWrapper.LastUserTenantAlbumRecord last(Long userId,Long tenantId,Long albumId) {
+    public UserTenantAlbumRecordWrapper.LastUserTenantAlbumRecord last(Long userId,Long tenantId,Long albumId, ClientEnum clientType) {
         //获取最近有效期最近的一条记录,(没过期)
         List<UserTenantAlbumRecord> albumRecords = this.lambdaQuery()
                 .eq(UserTenantAlbumRecord::getUserId, userId)
                 .eq(UserTenantAlbumRecord::getTenantId, tenantId)
                 .eq(UserTenantAlbumRecord::getEfficientFlag, true)
                 .eq(UserTenantAlbumRecord::getDeductionStatus, EDeductionStatus.EFFECTIVE)
+                .eq(UserTenantAlbumRecord::getClientType, clientType)
                 .eq(albumId != null, UserTenantAlbumRecord::getTenantAlbumId, albumId).list();
         UserTenantAlbumRecordWrapper.LastUserTenantAlbumRecord lastUserTenantAlbumRecord = new UserTenantAlbumRecordWrapper.LastUserTenantAlbumRecord();
         Long tenantAlbumId = null;
         Date endTime = null;
         //忽略已删除的专辑
-        albumRecords = this.ignoreTenantAlbumIds(albumRecords,userId);
+        albumRecords = this.ignoreTenantAlbumIds(albumRecords, userId, clientType);
         if (CollectionUtils.isNotEmpty(albumRecords)) {
             //按专辑编号分组,然后找出截止时间最大的记录
             Map<Long, UserTenantAlbumRecord> recordMap = albumRecords.stream()
@@ -938,12 +939,13 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
                     .eq(UserTenantAlbumRecord::getUserId, userId)
                     .eq(UserTenantAlbumRecord::getEfficientFlag, true)
                     .eq(UserTenantAlbumRecord::getTenantId, tenantId)
+                    .eq(UserTenantAlbumRecord::getClientType, clientType)
                     .lt(UserTenantAlbumRecord::getEndTime, new Date())
                     .eq(albumId != null, UserTenantAlbumRecord::getTenantAlbumId, albumId)
                     .orderByDesc(UserTenantAlbumRecord::getEndTime)
                     .orderByAsc(UserTenantAlbumRecord::getId).list();
             //忽略已删除的专辑
-            tenantAlbumRecords = this.ignoreTenantAlbumIds(tenantAlbumRecords,userId);
+            tenantAlbumRecords = this.ignoreTenantAlbumIds(tenantAlbumRecords, userId, clientType);
             if (CollectionUtils.isNotEmpty(tenantAlbumRecords)) {
                 UserTenantAlbumRecord record = tenantAlbumRecords.get(0);
                 tenantAlbumId = record.getTenantAlbumId();
@@ -962,7 +964,7 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
     }
 
     //忽略已删除的专辑
-    private List<UserTenantAlbumRecord> ignoreTenantAlbumIds(List<UserTenantAlbumRecord> albumRecords,Long userId) {
+    private List<UserTenantAlbumRecord> ignoreTenantAlbumIds(List<UserTenantAlbumRecord> albumRecords,Long userId, ClientEnum clientType) {
         if(CollectionUtils.isNotEmpty(albumRecords)){
             //获取所有专辑列表
             List<Long> tenantAlbumIds = albumRecords.stream().map(UserTenantAlbumRecord::getTenantAlbumId).distinct().collect(Collectors.toList());
@@ -972,13 +974,16 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
             if (CollectionUtils.isNotEmpty(list)){
                 ignoreTenantAlbumIds = list.stream().map(TenantAlbum::getId).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())
-                        .and(x -> x.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()));
+            
+            if(clientType == ClientEnum.STUDENT) {
+                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())
+                            .and(x -> x.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;