Forráskód Böngészése

Merge remote-tracking branch 'origin/feature/0721-tenant' into feature/0721-tenant

yuanliang 1 éve
szülő
commit
008f6913ad

+ 8 - 0
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/TenantAlbumController.java

@@ -18,6 +18,7 @@ import com.yonge.toolset.base.page.PageInfo;
 import com.yonge.toolset.mybatis.support.PageUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -181,6 +182,13 @@ public class TenantAlbumController {
     @ApiOperation(value = "新增专辑", notes = "新增专辑")
     @PreAuthorize("@pcs.hasPermissions('tenantAlbum/save')")
     public HttpResponseResult<Boolean> save(@Validated @RequestBody TenantAlbumVo.TenantAlbum album) {
+        //判断当前机构是否已经绑定机构专辑
+        Long tenantId = album.getTenantId();
+        List<TenantAlbumMusic> list = tenantAlbumMusicService.lambdaQuery().eq(TenantAlbumMusic::getTenantId, tenantId).list();
+        if (CollectionUtils.isNotEmpty(list)){
+            throw new BizException("当前机构已有专辑");
+        }
+
         TenantAlbum tenantAlbum = JSON.parseObject(album.jsonString(), TenantAlbum.class);
         List<TenantAlbumVo.MusicSheetData> musicSheetData = album.getMusicSheetData();
 

+ 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());
 

+ 5 - 0
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/open/OpenTenantController.java

@@ -108,6 +108,11 @@ public class OpenTenantController {
             if (AuthStatusEnum.DOING.equals(one.getStatus())) {
                 throw new BizException(5003, "请等待审核完成");
             }
+        } else {
+            // 判断当前账号是否已绑定
+            if (StringUtils.isNotBlank(tenantStaff.getWxOpenid()) && !openId.equals(tenantStaff.getWxOpenid())) {
+                throw new BizException("当前账号已绑定");
+            }
         }
 
         Long tenantId = tenantStaff.getTenantId();