Prechádzať zdrojové kódy

fix 机构专辑status

haonan 1 rok pred
rodič
commit
2e65afb062

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

@@ -11,7 +11,9 @@ import com.yonge.cooleshow.biz.dal.dto.search.StudentMusicSheetSearch;
 import com.yonge.cooleshow.biz.dal.entity.*;
 import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
 import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
+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.service.*;
 import com.yonge.cooleshow.biz.dal.vo.MusicSheetVo;
 import com.yonge.cooleshow.biz.dal.vo.StudentVo;
@@ -76,6 +78,13 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
     @Autowired
     private UserTenantAlbumRecordService userTenantAlbumRecordService;
 
+
+    @Autowired
+    private TenantAlbumRefMapper tenantAlbumRefMapper;
+
+    @Autowired
+    private TenantAlbumMapper tenantAlbumMapper;
+
 	/**
      * 查询详情
      * @param id 详情ID
@@ -274,11 +283,18 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
         TenantInfo tenantInfo = tenantInfoService.detail(detail.getTenantId());
         if (tenantInfo != null) {
             album.setTenantName(tenantInfo.getName());
-            QueryWrapper<TenantAlbumPurchase> queryWrapper = new QueryWrapper<>();
-            queryWrapper.lambda().eq(TenantAlbumPurchase::getTenantId, detail.getTenantId());
-            Integer count = tenantAlbumPurchaseMapper.selectCount(queryWrapper);
-            if (count > 0) {
-                album.setTenantAlbumStatus(1);
+            QueryWrapper<TenantAlbumRef> queryWrapper = new QueryWrapper<>();
+            queryWrapper.lambda().eq(TenantAlbumRef::getTenantId, detail.getTenantId());
+            List<TenantAlbumRef> albumRefs = tenantAlbumRefMapper.selectList(queryWrapper);
+            if (!albumRefs.isEmpty()) {
+                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);
+                Integer count = tenantAlbumMapper.selectCount(query);
+                if (count > 0) {
+                    album.setTenantAlbumStatus(1);
+                }
             }
             UserTenantAlbumRecord record =
                     userTenantAlbumRecordService.getNewestByTenantIdAndUserId(tenantInfo.getId(), detail.getUserId(),
@@ -291,10 +307,11 @@ public class UserTenantAlbumRecordServiceImpl extends ServiceImpl<UserTenantAlbu
                 album.setTenantAlbumStartTime(record.getStartTime());
                 album.setTenantAlbumEndTime(record.getEndTime());
             }
-
         }
 
 
+
+
         //查询是否已经购买专辑
         Long buyTenantAlbumId = userTenantAlbumRecordMapper.ifBuy(tenantAlbumId,sysUser.getId());