瀏覽代碼

1.添加专辑相关接口 2.添加激活码列表和发放接口

yuanliang 2 年之前
父節點
當前提交
207380e08d
共有 18 個文件被更改,包括 993 次插入115 次删除
  1. 9 8
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/TenantActivationCodeMapper.java
  2. 10 8
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/TenantAlbumPurchaseMapper.java
  3. 6 2
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TenantActivationCodeService.java
  4. 14 9
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TenantAlbumPurchaseService.java
  5. 88 16
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantActivationCodeServiceImpl.java
  6. 21 13
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantAlbumPurchaseServiceImpl.java
  7. 75 12
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantActivationCodeWrapper.java
  8. 59 14
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantAlbumPurchaseWrapper.java
  9. 44 12
      cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantAlbumWrapper.java
  10. 34 12
      cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantActivationCodeMapper.xml
  11. 2 2
      cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantAlbumMapper.xml
  12. 17 7
      cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantAlbumPurchaseMapper.xml
  13. 134 0
      cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/TenantActivationCodeController.java
  14. 117 0
      cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/TenantAlbumController.java
  15. 117 0
      cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/TenantAlbumPurchaseController.java
  16. 99 0
      cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/vo/TenantActivationCodeVo.java
  17. 64 0
      cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/vo/TenantAlbumPurchaseVo.java
  18. 83 0
      cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/vo/TenantAlbumVo.java

+ 9 - 8
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/TenantActivationCodeMapper.java

@@ -16,12 +16,13 @@ import com.yonge.cooleshow.biz.dal.wrapper.TenantActivationCodeWrapper;
 @Repository
 public interface TenantActivationCodeMapper extends BaseMapper<TenantActivationCode> {
 
-	/**
-	 * 分页查询
-	 * @param page IPage<TenantActivationCodeWrapper.TenantActivationCode>
-	 * @param param TenantActivationCodeWrapper.TenantActivationCodeQuery
-	 * @return List<TenantActivationCodeWrapper.TenantActivationCode>
-	 */
-	List<TenantActivationCode> selectPage(@Param("page") IPage<TenantActivationCode> page, @Param("param") TenantActivationCodeWrapper.TenantActivationCodeQuery param);
-	
+    /**
+     * 分页查询
+     *
+     * @param page  IPage<TenantActivationCodeWrapper.TenantActivationCode>
+     * @param param TenantActivationCodeWrapper.TenantActivationCodeQuery
+     * @return List<TenantActivationCodeWrapper.TenantActivationCode>
+     */
+    List<TenantActivationCodeWrapper.TenantActivationCode> selectPage(@Param("page") IPage<TenantActivationCodeWrapper.TenantActivationCode> page, @Param("param") TenantActivationCodeWrapper.TenantActivationCodeQuery param);
+
 }

+ 10 - 8
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/mapper/TenantAlbumPurchaseMapper.java

@@ -16,12 +16,14 @@ import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumPurchaseWrapper;
 @Repository
 public interface TenantAlbumPurchaseMapper extends BaseMapper<TenantAlbumPurchase> {
 
-	/**
-	 * 分页查询
-	 * @param page IPage<TenantAlbumPurchaseWrapper.TenantAlbumPurchase>
-	 * @param param TenantAlbumPurchaseWrapper.TenantAlbumPurchaseQuery
-	 * @return List<TenantAlbumPurchaseWrapper.TenantAlbumPurchase>
-	 */
-	List<TenantAlbumPurchase> selectPage(@Param("page") IPage<TenantAlbumPurchase> page, @Param("param") TenantAlbumPurchaseWrapper.TenantAlbumPurchaseQuery param);
-	
+    /**
+     * 分页查询
+     *
+     * @param page  IPage<TenantAlbumPurchaseWrapper.TenantAlbumPurchase>
+     * @param param TenantAlbumPurchaseWrapper.TenantAlbumPurchaseQuery
+     * @return List<TenantAlbumPurchaseWrapper.TenantAlbumPurchase>
+     */
+    List<TenantAlbumPurchaseWrapper.TenantAlbumPurchase> selectPage(@Param("page") IPage<TenantAlbumPurchaseWrapper.TenantAlbumPurchase> page,
+                                                                    @Param("param") TenantAlbumPurchaseWrapper.TenantAlbumPurchaseQuery param);
+
 }

+ 6 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TenantActivationCodeService.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantActivationCodeWrapper;
 import com.yonge.cooleshow.biz.dal.entity.TenantActivationCode;
 
+import java.util.List;
+
 /**
  * 机构激活码
  * 2023-07-21 17:32:49
@@ -24,7 +26,8 @@ public interface TenantActivationCodeService extends IService<TenantActivationCo
      * @param query TenantActivationCodeWrapper.TenantActivationCodeQuery
      * @return IPage<TenantActivationCode>
      */
-    IPage<TenantActivationCode> selectPage(IPage<TenantActivationCode> page, TenantActivationCodeWrapper.TenantActivationCodeQuery query);
+    IPage<TenantActivationCodeWrapper.TenantActivationCode> selectPage(IPage<TenantActivationCodeWrapper.TenantActivationCode> page,
+                                                                       TenantActivationCodeWrapper.TenantActivationCodeQuery query);
 	
     /**
      * 添加
@@ -39,5 +42,6 @@ public interface TenantActivationCodeService extends IService<TenantActivationCo
      * @return Boolean
      */
      Boolean update(TenantActivationCodeWrapper.TenantActivationCode tenantActivationCode);
-     
+
+    void sendActivationCode(Long tenantId, Long tenantAlbumPurchaseId, List<String> activationCodeList, List<Long> studentIdList);
 }

+ 14 - 9
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TenantAlbumPurchaseService.java

@@ -9,35 +9,40 @@ import com.yonge.cooleshow.biz.dal.entity.TenantAlbumPurchase;
  * 机构专辑采购
  * 2023-07-21 17:32:49
  */
-public interface TenantAlbumPurchaseService extends IService<TenantAlbumPurchase>  {
+public interface TenantAlbumPurchaseService extends IService<TenantAlbumPurchase> {
 
-	/**
+    /**
      * 查询详情
+     *
      * @param id 详情ID
      * @return TenantAlbumPurchase
      */
-	TenantAlbumPurchase detail(Long id);
+    TenantAlbumPurchase detail(Long id);
 
     /**
      * 分页查询
-     * @param page IPage<TenantAlbumPurchase>
+     *
+     * @param page  IPage<TenantAlbumPurchase>
      * @param query TenantAlbumPurchaseWrapper.TenantAlbumPurchaseQuery
      * @return IPage<TenantAlbumPurchase>
      */
-    IPage<TenantAlbumPurchase> selectPage(IPage<TenantAlbumPurchase> page, TenantAlbumPurchaseWrapper.TenantAlbumPurchaseQuery query);
-	
+    IPage<TenantAlbumPurchaseWrapper.TenantAlbumPurchase> selectPage(IPage<TenantAlbumPurchaseWrapper.TenantAlbumPurchase> page,
+                                                                     TenantAlbumPurchaseWrapper.TenantAlbumPurchaseQuery query);
+
     /**
      * 添加
+     *
      * @param tenantAlbumPurchase TenantAlbumPurchaseWrapper.TenantAlbumPurchase
      * @return Boolean
      */
-     Boolean add(TenantAlbumPurchaseWrapper.TenantAlbumPurchase tenantAlbumPurchase);   
+    Boolean add(TenantAlbumPurchaseWrapper.TenantAlbumPurchase tenantAlbumPurchase);
 
     /**
      * 更新
+     *
      * @param tenantAlbumPurchase TenantAlbumPurchaseWrapper.TenantAlbumPurchase
      * @return Boolean
      */
-     Boolean update(TenantAlbumPurchaseWrapper.TenantAlbumPurchase tenantAlbumPurchase);
-     
+    Boolean update(TenantAlbumPurchaseWrapper.TenantAlbumPurchase tenantAlbumPurchase);
+
 }

+ 88 - 16
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantActivationCodeServiceImpl.java

@@ -1,15 +1,27 @@
 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.extension.service.impl.ServiceImpl;
-import org.springframework.stereotype.Service;
-import org.springframework.beans.BeanUtils;
-import lombok.extern.slf4j.Slf4j;
+import com.yonge.cooleshow.biz.dal.dao.StudentDao;
+import com.yonge.cooleshow.biz.dal.entity.Student;
+import com.yonge.cooleshow.biz.dal.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.entity.TenantActivationCode;
-import com.yonge.cooleshow.biz.dal.wrapper.TenantActivationCodeWrapper;
+import com.yonge.cooleshow.biz.dal.mapper.SysUserMapper;
 import com.yonge.cooleshow.biz.dal.mapper.TenantActivationCodeMapper;
 import com.yonge.cooleshow.biz.dal.service.TenantActivationCodeService;
+import com.yonge.cooleshow.biz.dal.wrapper.TenantActivationCodeWrapper;
+import com.yonge.toolset.base.exception.BizException;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 机构激活码
@@ -19,48 +31,108 @@ import com.yonge.cooleshow.biz.dal.service.TenantActivationCodeService;
 @Service
 public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivationCodeMapper, TenantActivationCode> implements TenantActivationCodeService {
 
-	/**
+    @Autowired
+    private StudentDao studentDao;
+
+    @Autowired
+    private SysUserMapper sysUserMapper;
+
+    /**
      * 查询详情
+     *
      * @param id 详情ID
      * @return TenantActivationCode
      */
-	@Override
+    @Override
     public TenantActivationCode detail(Long id) {
-        
+
         return baseMapper.selectById(id);
     }
-    
+
     /**
      * 分页查询
-     * @param page IPage<TenantActivationCode>
+     *
+     * @param page  IPage<TenantActivationCode>
      * @param query TenantActivationCodeWrapper.TenantActivationCodeQuery
      * @return IPage<TenantActivationCode>
      */
     @Override
-    public IPage<TenantActivationCode> selectPage(IPage<TenantActivationCode> page, TenantActivationCodeWrapper.TenantActivationCodeQuery query) {
-        
+    public IPage<TenantActivationCodeWrapper.TenantActivationCode> selectPage(IPage<TenantActivationCodeWrapper.TenantActivationCode> page,
+                                                                              TenantActivationCodeWrapper.TenantActivationCodeQuery query) {
+
         return page.setRecords(baseMapper.selectPage(page, query));
     }
-	
+
     /**
      * 添加
+     *
      * @param tenantActivationCode TenantActivationCodeWrapper.TenantActivationCode
      * @return Boolean
      */
     @Override
-    public Boolean add(TenantActivationCodeWrapper.TenantActivationCode tenantActivationCode) {    	
-        
+    public Boolean add(TenantActivationCodeWrapper.TenantActivationCode tenantActivationCode) {
+
         return this.save(JSON.parseObject(tenantActivationCode.jsonString(), TenantActivationCode.class));
     }
 
     /**
      * 更新
+     *
      * @param tenantActivationCode TenantActivationCodeWrapper.TenantActivationCode
      * @return Boolean
      */
     @Override
-    public Boolean update(TenantActivationCodeWrapper.TenantActivationCode tenantActivationCode){
+    public Boolean update(TenantActivationCodeWrapper.TenantActivationCode tenantActivationCode) {
+
+        return this.updateById(JSON.parseObject(tenantActivationCode.jsonString(), TenantActivationCode.class));
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void sendActivationCode(Long tenantId, Long tenantAlbumPurchaseId, List<String> activationCodeList,
+                                   List<Long> studentIdList) {
+        QueryWrapper<TenantActivationCode> queryWrapper = new QueryWrapper<>();
+        if (CollectionUtils.isEmpty(activationCodeList)) {
+            // 入参为空走批量发放方式
+            queryWrapper.lambda().eq(TenantActivationCode::getTenantId, tenantId)
+                    .eq(TenantActivationCode::getTenantAlbumPurchaseId, tenantAlbumPurchaseId)
+                    .eq(TenantActivationCode::getActivationStatus, false);
+        } else {
+            queryWrapper.lambda().eq(TenantActivationCode::getTenantId, tenantId)
+                    .eq(TenantActivationCode::getTenantAlbumPurchaseId, tenantAlbumPurchaseId)
+                    .in(TenantActivationCode::getActivationCode, activationCodeList)
+                    .eq(TenantActivationCode::getActivationStatus, false);
+        }
+
+        List<TenantActivationCode> tenantActivationCodes = baseMapper.selectList(queryWrapper);
+        if (tenantActivationCodes.isEmpty()) {
+            throw new BizException("无可发放的激活码");
+        }
+
+        QueryWrapper<Student> studentQueryWrapper = new QueryWrapper<>();
+        studentQueryWrapper.lambda().eq(Student::getTenantId, tenantId)
+                .in(Student::getUserId, studentIdList);
+        List<Student> students = studentDao.selectList(studentQueryWrapper);
+        if (tenantActivationCodes.size() < students.size()) {
+            throw new BizException("学生的数量不能大于可用的激活码数量");
+        }
+
+        List<Long> studentIds = students.stream().map(Student::getUserId).collect(Collectors.toList());
+        Map<Long, String> idPhoneMap = sysUserMapper.selectBatchIds(studentIds).stream()
+                .collect(Collectors.toMap(SysUser::getId, SysUser::getPhone));
 
-        return this.updateById(JSON.parseObject(tenantActivationCode.jsonString(), TenantActivationCode.class));       
+        for (Long studentId : studentIds) {
+            for (TenantActivationCode tenantActivationCode : tenantActivationCodes) {
+                boolean update = this.lambdaUpdate()
+                        .set(TenantActivationCode::getSendStatus, "SEND")
+                        .set(TenantActivationCode::getActivationPhone, idPhoneMap.get(studentId))
+                        .eq(TenantActivationCode::getActivationStatus, false)
+                        .eq(TenantActivationCode::getId, tenantActivationCode.getId())
+                        .update();
+                if (!update) {
+                    throw new BizException("激活码已被激活:" + tenantActivationCode.getActivationCode());
+                }
+            }
+        }
     }
 }

+ 21 - 13
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantAlbumPurchaseServiceImpl.java

@@ -11,6 +11,8 @@ import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumPurchaseWrapper;
 import com.yonge.cooleshow.biz.dal.mapper.TenantAlbumPurchaseMapper;
 import com.yonge.cooleshow.biz.dal.service.TenantAlbumPurchaseService;
 
+import java.util.List;
+
 /**
  * 机构专辑采购
  * 2023-07-21 17:32:49
@@ -19,48 +21,54 @@ import com.yonge.cooleshow.biz.dal.service.TenantAlbumPurchaseService;
 @Service
 public class TenantAlbumPurchaseServiceImpl extends ServiceImpl<TenantAlbumPurchaseMapper, TenantAlbumPurchase> implements TenantAlbumPurchaseService {
 
-	/**
+    /**
      * 查询详情
+     *
      * @param id 详情ID
      * @return TenantAlbumPurchase
      */
-	@Override
+    @Override
     public TenantAlbumPurchase detail(Long id) {
-        
+
         return baseMapper.selectById(id);
     }
-    
+
     /**
      * 分页查询
-     * @param page IPage<TenantAlbumPurchase>
+     *
+     * @param page  IPage<TenantAlbumPurchase>
      * @param query TenantAlbumPurchaseWrapper.TenantAlbumPurchaseQuery
      * @return IPage<TenantAlbumPurchase>
      */
     @Override
-    public IPage<TenantAlbumPurchase> selectPage(IPage<TenantAlbumPurchase> page, TenantAlbumPurchaseWrapper.TenantAlbumPurchaseQuery query) {
-        
-        return page.setRecords(baseMapper.selectPage(page, query));
+    public IPage<TenantAlbumPurchaseWrapper.TenantAlbumPurchase> selectPage(IPage<TenantAlbumPurchaseWrapper.TenantAlbumPurchase> page,
+                                                                            TenantAlbumPurchaseWrapper.TenantAlbumPurchaseQuery query) {
+
+        List<TenantAlbumPurchaseWrapper.TenantAlbumPurchase> selectPage = baseMapper.selectPage(page, query);
+        return page.setRecords(selectPage);
     }
-	
+
     /**
      * 添加
+     *
      * @param tenantAlbumPurchase TenantAlbumPurchaseWrapper.TenantAlbumPurchase
      * @return Boolean
      */
     @Override
-    public Boolean add(TenantAlbumPurchaseWrapper.TenantAlbumPurchase tenantAlbumPurchase) {    	
-        
+    public Boolean add(TenantAlbumPurchaseWrapper.TenantAlbumPurchase tenantAlbumPurchase) {
+
         return this.save(JSON.parseObject(tenantAlbumPurchase.jsonString(), TenantAlbumPurchase.class));
     }
 
     /**
      * 更新
+     *
      * @param tenantAlbumPurchase TenantAlbumPurchaseWrapper.TenantAlbumPurchase
      * @return Boolean
      */
     @Override
-    public Boolean update(TenantAlbumPurchaseWrapper.TenantAlbumPurchase tenantAlbumPurchase){
+    public Boolean update(TenantAlbumPurchaseWrapper.TenantAlbumPurchase tenantAlbumPurchase) {
 
-        return this.updateById(JSON.parseObject(tenantAlbumPurchase.jsonString(), TenantAlbumPurchase.class));       
+        return this.updateById(JSON.parseObject(tenantAlbumPurchase.jsonString(), TenantAlbumPurchase.class));
     }
 }

+ 75 - 12
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantActivationCodeWrapper.java

@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+
+import java.util.Date;
 import java.util.Optional;
 
 import lombok.AllArgsConstructor;
@@ -20,25 +22,40 @@ import org.apache.commons.lang3.StringUtils;
 public class TenantActivationCodeWrapper {
 
     @Data
-	@Builder
+    @Builder
     @NoArgsConstructor
     @AllArgsConstructor
     @ApiModel(" TenantActivationCodeQuery-机构激活码")
     public static class TenantActivationCodeQuery implements QueryInfo {
-    
-    	@ApiModelProperty("当前页")
+
+        @ApiModelProperty("当前页")
         private Integer page;
-        
+
         @ApiModelProperty("分页行数")
         private Integer rows;
-        
+
         @ApiModelProperty("关键字匹配")
-		private String keyword;
-        
+        private String keyword;
+
+        @ApiModelProperty("机构ID")
+        private Long tenantId;
+
+        @ApiModelProperty("专辑购买ID")
+        private Long tenantAlbumPurchaseId;
+
+        @ApiModelProperty("激活状态")
+        private Boolean activationStatus;
+
+        @ApiModelProperty("激活开始")
+        private Date activationStartTime;
+
+        @ApiModelProperty("激活结束")
+        private Date activationEndTime;
+
         public String getKeyword() {
             return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
         }
-        
+
         public String jsonString() {
             return JSON.toJSONString(this);
         }
@@ -46,11 +63,57 @@ public class TenantActivationCodeWrapper {
         public static TenantActivationCodeQuery from(String json) {
             return JSON.parseObject(json, TenantActivationCodeQuery.class);
         }
-    }  
+    }
 
-	@ApiModel(" TenantActivationCode-机构激活码")
+    @Data
+    @ApiModel(" TenantActivationCode-机构激活码")
     public static class TenantActivationCode {
-        
+
+        @ApiModelProperty("主键ID")
+        private Long id;
+
+        @ApiModelProperty("机构ID")
+        private Long tenantId;
+
+        @ApiModelProperty("机构专辑ID")
+        private Long tenantAlbumId;
+
+        @ApiModelProperty("周期")
+        private Integer purchaseCycle;
+
+        @ApiModelProperty("机构专辑采购ID")
+        private Long tenantAlbumPurchaseId;
+
+        @ApiModelProperty("激活码")
+        private String activationCode;
+
+        @ApiModelProperty("发送状态(WAIT,SEND)")
+        private String sendStatus;
+
+        @ApiModelProperty("激活状态")
+        private Boolean activationStatus;
+
+        @ApiModelProperty("激活手机号")
+        private String activationPhone;
+
+        @ApiModelProperty("激活时间")
+        private Date activationTime;
+
+        @ApiModelProperty("激活用户ID")
+        private Long activationUserId;
+
+        @ApiModelProperty("激活用户名称")
+        private String activationUserName;
+
+        @ApiModelProperty("更新时间")
+        private Date updateTime;
+
+        @ApiModelProperty("创建时间")
+        private Date createTime;
+
+        @ApiModelProperty("激活数量")
+        private Integer activeQuantity;
+
         public String jsonString() {
             return JSON.toJSONString(this);
         }
@@ -58,6 +121,6 @@ public class TenantActivationCodeWrapper {
         public static TenantActivationCode from(String json) {
             return JSON.parseObject(json, TenantActivationCode.class);
         }
-	}
+    }
 
 }

+ 59 - 14
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantAlbumPurchaseWrapper.java

@@ -4,14 +4,16 @@ import com.alibaba.fastjson.JSON;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
-import java.util.Optional;
-
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
 
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.Optional;
+
 /**
  * 机构专辑采购
  * 2023-07-21 17:32:49
@@ -20,25 +22,31 @@ import org.apache.commons.lang3.StringUtils;
 public class TenantAlbumPurchaseWrapper {
 
     @Data
-	@Builder
+    @Builder
     @NoArgsConstructor
     @AllArgsConstructor
     @ApiModel(" TenantAlbumPurchaseQuery-机构专辑采购")
     public static class TenantAlbumPurchaseQuery implements QueryInfo {
-    
-    	@ApiModelProperty("当前页")
+
+        @ApiModelProperty("当前页")
         private Integer page;
-        
+
         @ApiModelProperty("分页行数")
         private Integer rows;
-        
+
         @ApiModelProperty("关键字匹配")
-		private String keyword;
-        
+        private String keyword;
+
+        @ApiModelProperty("机构ID")
+        private Long tenantId;
+
+        @ApiModelProperty(value = "排序规则", hidden = true)
+        private String orderBy;
+
         public String getKeyword() {
             return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
         }
-        
+
         public String jsonString() {
             return JSON.toJSONString(this);
         }
@@ -46,11 +54,48 @@ public class TenantAlbumPurchaseWrapper {
         public static TenantAlbumPurchaseQuery from(String json) {
             return JSON.parseObject(json, TenantAlbumPurchaseQuery.class);
         }
-    }  
+    }
 
-	@ApiModel(" TenantAlbumPurchase-机构专辑采购")
+    @Data
+    @ApiModel(" TenantAlbumPurchase-机构专辑采购")
     public static class TenantAlbumPurchase {
-        
+
+        @ApiModelProperty("主键ID")
+        private Long id;
+
+        @ApiModelProperty("机构ID")
+        private Long tenantId;
+
+        @ApiModelProperty("机构专辑ID")
+        private Long tenantAlbumId;
+
+        @ApiModelProperty("机构专辑名称")
+        private Long tenantAlbumName;
+
+        @ApiModelProperty("采购时间")
+        private Date purchaseTime;
+
+        @ApiModelProperty("购买数量")
+        private Integer purchaseQuantity;
+
+        @ApiModelProperty("采购周期")
+        private Integer purchaseCycle;
+
+        @ApiModelProperty("激活数量")
+        private Integer activeQuantity;
+
+        @ApiModelProperty("采购价格")
+        private BigDecimal purchasePrice;
+
+        @ApiModelProperty("采购状态")
+        private String purchaseStatus;
+
+        @ApiModelProperty("更新时间")
+        private Date updateTime;
+
+        @ApiModelProperty("创建时间")
+        private Date createTime;
+
         public String jsonString() {
             return JSON.toJSONString(this);
         }
@@ -58,6 +103,6 @@ public class TenantAlbumPurchaseWrapper {
         public static TenantAlbumPurchase from(String json) {
             return JSON.parseObject(json, TenantAlbumPurchase.class);
         }
-	}
+    }
 
 }

+ 44 - 12
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantAlbumWrapper.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+
 import java.util.Optional;
 
 import lombok.AllArgsConstructor;
@@ -20,25 +21,28 @@ import org.apache.commons.lang3.StringUtils;
 public class TenantAlbumWrapper {
 
     @Data
-	@Builder
+    @Builder
     @NoArgsConstructor
     @AllArgsConstructor
     @ApiModel(" TenantAlbumQuery-机构专辑")
     public static class TenantAlbumQuery implements QueryInfo {
-    
-    	@ApiModelProperty("当前页")
+
+        @ApiModelProperty("当前页")
         private Integer page;
-        
+
         @ApiModelProperty("分页行数")
         private Integer rows;
-        
+
         @ApiModelProperty("关键字匹配")
-		private String keyword;
-        
+        private String keyword;
+
+        @ApiModelProperty("机构ID")
+        private Long tenantId;
+
         public String getKeyword() {
             return Optional.ofNullable(keyword).filter(StringUtils::isNotBlank).orElse(null);
         }
-        
+
         public String jsonString() {
             return JSON.toJSONString(this);
         }
@@ -46,11 +50,11 @@ public class TenantAlbumWrapper {
         public static TenantAlbumQuery from(String json) {
             return JSON.parseObject(json, TenantAlbumQuery.class);
         }
-    }  
+    }
 
-	@ApiModel(" TenantAlbum-机构专辑")
+    @ApiModel(" TenantAlbum-机构专辑")
     public static class TenantAlbum {
-        
+
         public String jsonString() {
             return JSON.toJSONString(this);
         }
@@ -58,6 +62,34 @@ public class TenantAlbumWrapper {
         public static TenantAlbum from(String json) {
             return JSON.parseObject(json, TenantAlbum.class);
         }
-	}
+    }
+
+    @Data
+    @Builder
+    @NoArgsConstructor
+    @AllArgsConstructor
+    @ApiModel(" TenantAlbum-机构专辑采购")
+    public static class TenantAlbumBuy {
+
+        @ApiModelProperty("专辑ID")
+        private Long tenantAlbumId;
+
+        @ApiModelProperty("采购数量")
+        private Integer buyNumber;
+
+        @ApiModelProperty("采购周期")
+        private Integer buyCycle;
+
+        public Boolean isValid() {
+            if (this.buyNumber == null || this.buyNumber < 0) {
+                return false;
+            }
+            if (this.buyCycle == null || this.buyCycle < 0 || this.buyCycle % 6 != 0) {
+                return false;
+            }
+            return true;
+        }
+
+    }
 
 }

+ 34 - 12
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantActivationCodeMapper.xml

@@ -1,12 +1,9 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE  mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
 <mapper namespace="com.yonge.cooleshow.biz.dal.mapper.TenantActivationCodeMapper">
-
-	 
-    
     <!-- 表字段 -->
     <sql id="baseColumns">
-         t.id_ AS id
+        t.id_ AS id
         , t.tenant_id_ AS tenantId
         , t.tenant_album_id_ AS tenantAlbumId
         , t.tenant_album_purchase_id_ AS tenantAlbumPurchaseId
@@ -18,12 +15,37 @@
         , t.activation_user_id_ AS activationUserId
         , t.update_time_ AS updateTime
         , t.create_time_ AS createTime
-        </sql> 
-    
-    <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.entity.TenantActivationCode">
-		SELECT         
-        	<include refid="baseColumns" />
-		FROM tenant_activation_code t
-	</select>
-    
+    </sql>
+
+    <select id="selectPage"
+            resultType="com.yonge.cooleshow.biz.dal.wrapper.TenantActivationCodeWrapper$TenantActivationCode">
+        SELECT
+        <include refid="baseColumns"/>, ta.purchase_cycle_ as purchaseCycle, su.username_ as activationUserName
+        FROM tenant_activation_code t
+        LEFT JOIN tenant_album ta on t.tenant_album_id_ = ta.id_
+        LEFT JOIN sys_user su on t.active_user_id = su.id_
+        <where>
+            <if test="param.keyword != null and param.keyword.trim() != ''">
+                AND (
+                t.activation_code_ like concat ('%',#{param.keyword},'%') or
+                su.username_ like concat ('%',#{param.keyword},'%')
+                )
+            </if>
+            <if test="param.tenantId != null">
+                AND t.tenant_id_ = #{param.tenantId}
+            </if>
+            <if test="param.tenantAlbumPurchaseId != null">
+                AND t.tenant_album_purchase_id_ = #{param.tenantAlbumPurchaseId}
+            </if>
+            <if test="param.activationStatus != null">
+                AND t.activation_status_ = #{param.activationStatus}
+            </if>
+            <if test="param.activationStartTime != null">
+                AND t.activation_time_ >= #{param.activationStartTime}
+            </if>
+            <if test="param.activationEndTime != null">
+                AND #{param.activationEndTime} >= t.activation_time_
+            </if>
+        </where>
+    </select>
 </mapper>

+ 2 - 2
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantAlbumMapper.xml

@@ -7,8 +7,8 @@
     <!-- 表字段 -->
     <sql id="baseColumns">
          t.id_ AS id
-        , t.name_ AS name
-        , t.describe_ AS describe
+        , t.name_ AS `name`
+        , t.describe_ AS `describe`
         , t.cover_img_ AS coverImg
         , t.music_num_ AS musicNum
         , t.original_price_ AS originalPrice

+ 17 - 7
cooleshow-user/user-biz/src/main/resources/config/mybatis/TenantAlbumPurchaseMapper.xml

@@ -17,12 +17,22 @@
         , t.purchase_status_ AS purchaseStatus
         , t.update_time_ AS updateTime
         , t.create_time_ AS createTime
-        </sql> 
-    
-    <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.entity.TenantAlbumPurchase">
-		SELECT         
-        	<include refid="baseColumns" />
-		FROM tenant_album_purchase t
-	</select>
+        </sql>
+
+    <select id="selectPage"
+            resultType="com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumPurchaseWrapper$TenantAlbumPurchase">
+        SELECT
+        <include refid="baseColumns"/>,ta.name_ as tenantAlbumName
+        FROM tenant_album_purchase t
+        LEFT JOIN tenant_album ta on t.tenant_album_id_ = ta.id_
+        <choose>
+            <when test="param.orderBy != null and param.orderBy.trim() != ''">
+                order by #{param.orderBy}
+            </when>
+            <otherwise>
+                order by t.id_ desc
+            </otherwise>
+        </choose>
+    </select>
     
 </mapper>

+ 134 - 0
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/TenantActivationCodeController.java

@@ -0,0 +1,134 @@
+package com.yonge.cooleshow.tenant.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.microsvc.toolkit.common.response.paging.PageInfo;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.microsvc.toolkit.common.response.template.R;
+import com.microsvc.toolkit.common.webportal.exception.BizException;
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.TenantActivationCode;
+import com.yonge.cooleshow.biz.dal.entity.TenantAlbumPurchase;
+import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
+import com.yonge.cooleshow.biz.dal.service.TenantActivationCodeService;
+import com.yonge.cooleshow.biz.dal.service.TenantAlbumPurchaseService;
+import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
+import com.yonge.cooleshow.biz.dal.wrapper.TenantActivationCodeWrapper;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.cooleshow.tenant.vo.TenantActivationCodeVo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+
+@Slf4j
+@Validated
+@RestController
+@RequestMapping("/tenantActivationCode")
+@Api(tags = "机构激活码")
+public class TenantActivationCodeController extends BaseController {
+
+    @Autowired
+    private TenantActivationCodeService tenantActivationCodeService;
+
+    @Autowired
+    private TenantAlbumPurchaseService tenantAlbumPurchaseService;
+
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+    @Autowired
+    private TenantInfoService tenantInfoService;
+
+    @ApiOperation(value = "详情", notes = "机构激活码-根据详情ID查询单条, 传入id")
+//    @GetMapping("/detail/{id}")
+    public R<TenantActivationCodeVo.TenantActivationCode> detail(@PathVariable("id") Long id) {
+
+        TenantActivationCode wrapper = tenantActivationCodeService.detail(id);
+
+        return R.from(TenantActivationCodeVo.TenantActivationCode.from(JSON.toJSONString(wrapper)));
+    }
+
+    @ApiOperation(value = "查询分页", notes = "机构激活码- 传入 TenantActivationCodeVo.TenantActivationCodeQuery")
+    @PostMapping("/page")
+    public HttpResponseResult<PageInfo<TenantActivationCodeWrapper.TenantActivationCode>> page(
+            @RequestBody TenantActivationCodeWrapper.TenantActivationCodeQuery query) {
+        TenantInfo tenantInfo = getTenantInfo();
+        query.setTenantId(tenantInfo.getId());
+        // 查询数据
+        IPage<TenantActivationCodeWrapper.TenantActivationCode> pages =
+                tenantActivationCodeService.selectPage(QueryInfo.getPage(query), query);
+        PageInfo<TenantActivationCodeWrapper.TenantActivationCode> pageInfo = QueryInfo.pageInfo(pages,
+                pages.getRecords());
+
+        if (query.getTenantAlbumPurchaseId() != null) {
+            TenantActivationCodeWrapper.TenantActivationCode extra =
+                    new TenantActivationCodeWrapper.TenantActivationCode();
+            TenantAlbumPurchase purchase = tenantAlbumPurchaseService.getById(query.getTenantAlbumPurchaseId());
+            extra.setActiveQuantity(purchase.getActiveQuantity());
+            pageInfo.setExtra(extra);
+        }
+
+        return succeed(pageInfo);
+    }
+
+    @ApiOperation(value = "激活码发放", notes = "机构激活码- 传入 TenantActivationCodeVo.TenantActivationCodeSend")
+    @PostMapping("/send")
+    public HttpResponseResult<Boolean> send(@Validated @RequestBody TenantActivationCodeVo.TenantActivationCodeSend send) {
+        TenantInfo tenantInfo = getTenantInfo();
+        tenantActivationCodeService.sendActivationCode(tenantInfo.getId(), send.getTenantAlbumPurchaseId(),
+                send.getActivationCodeList(),
+                send.getStudentIdList());
+        return succeed();
+    }
+
+    @ApiOperation(value = "新增", notes = "机构激活码- 传入 TenantActivationCodeVo.TenantActivationCode")
+//    @PostMapping("/save")
+    public R<JSONObject> add(@Validated @RequestBody TenantActivationCodeVo.TenantActivationCode tenantActivationCodeVo) {
+
+        // 新增数据
+        tenantActivationCodeService.save(JSON.parseObject(tenantActivationCodeVo.jsonString(),
+                TenantActivationCode.class));
+
+        return R.defaultR();
+    }
+
+    @ApiOperation(value = "修改", notes = "机构激活码- 传入 TenantActivationCodeVo.TenantActivationCode")
+//    @PostMapping("/update")
+    public R<JSONObject> update(@Validated @RequestBody TenantActivationCodeVo.TenantActivationCode tenantActivationCodeVo) {
+
+        // 更新数据
+        tenantActivationCodeService.updateById(JSON.parseObject(tenantActivationCodeVo.jsonString(),
+                TenantActivationCode.class));
+
+        return R.defaultR();
+    }
+
+    @ApiOperation(value = "删除", notes = "机构激活码- 传入id")
+//    @PostMapping("/remove")
+    public R<Boolean> remove(@RequestParam Long id) {
+
+        return R.from(tenantActivationCodeService.removeById(id));
+    }
+
+    private TenantInfo getTenantInfo() {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        TenantInfo tenantInfo = tenantInfoService.lambdaQuery().eq(TenantInfo::getUserId, sysUser.getId())
+                .last("limit 1").one();
+        if (tenantInfo == null) {
+            throw new BizException("非法请求");
+        }
+        return tenantInfo;
+    }
+}

+ 117 - 0
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/TenantAlbumController.java

@@ -0,0 +1,117 @@
+package com.yonge.cooleshow.tenant.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.microsvc.toolkit.common.response.paging.PageInfo;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.microsvc.toolkit.common.webportal.exception.BizException;
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.TenantAlbum;
+import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
+import com.yonge.cooleshow.biz.dal.service.TenantAlbumService;
+import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
+import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumWrapper;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.cooleshow.tenant.vo.TenantAlbumVo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@Slf4j
+@Validated
+@RestController
+@RequestMapping("/tenantAlbum")
+@Api(tags = "机构专辑")
+public class TenantAlbumController extends BaseController {
+
+    @Autowired
+    private TenantAlbumService tenantAlbumService;
+
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+    @Autowired
+    private TenantInfoService tenantInfoService;
+
+    @ApiOperation(value = "详情", notes = "机构专辑-根据详情ID查询单条, 传入id")
+//    @GetMapping("/detail/{id}")
+    public HttpResponseResult<TenantAlbumVo.TenantAlbum> detail(@PathVariable("id") Long id) {
+        TenantAlbum wrapper = tenantAlbumService.detail(id);
+        return succeed(TenantAlbumVo.TenantAlbum.from(JSON.toJSONString(wrapper)));
+    }
+
+    @ApiOperation(value = "查询分页", notes = "机构专辑- 传入 TenantAlbumVo.TenantAlbumQuery")
+    @PostMapping("/page")
+    public HttpResponseResult<PageInfo<TenantAlbumVo.TenantAlbum>> page(@RequestBody TenantAlbumWrapper.TenantAlbumQuery query) {
+        TenantInfo tenantInfo = getTenantInfo();
+        query.setTenantId(tenantInfo.getId());
+        // 查询数据
+        IPage<TenantAlbum> pages = tenantAlbumService.selectPage(QueryInfo.getPage(query), query);
+        // 数据类型转换
+        List<TenantAlbumVo.TenantAlbum> records = JSON.parseArray(JSON.toJSONString(pages.getRecords()),
+                TenantAlbumVo.TenantAlbum.class);
+        return succeed(QueryInfo.pageInfo(pages, records));
+    }
+
+    @ApiOperation(value = "采购专辑", notes = "机构专辑- 传入 TenantAlbumVo.TenantAlbumQuery")
+    @PostMapping("/buyAlbum")
+    public HttpResponseResult<Boolean> buyAlbum(@RequestBody TenantAlbumWrapper.TenantAlbumBuy buy) {
+        // todo 订单接入
+        return succeed();
+    }
+
+    @ApiOperation(value = "新增", notes = "机构专辑- 传入 TenantAlbumVo.TenantAlbum")
+//    @PostMapping("/add")
+    public HttpResponseResult<JSONObject> add(@Validated @RequestBody TenantAlbumVo.TenantAlbum tenantAlbumVo) {
+
+        // 新增数据
+        tenantAlbumService.save(JSON.parseObject(tenantAlbumVo.jsonString(), TenantAlbum.class));
+        return succeed();
+    }
+
+    @ApiOperation(value = "修改", notes = "机构专辑- 传入 TenantAlbumVo.TenantAlbum")
+//    @PostMapping("/update")
+    public HttpResponseResult<JSONObject> update(@Validated @RequestBody TenantAlbumVo.TenantAlbum tenantAlbumVo) {
+
+        // 更新数据
+        tenantAlbumService.updateById(JSON.parseObject(tenantAlbumVo.jsonString(), TenantAlbum.class));
+        return succeed();
+    }
+
+    @ApiOperation(value = "删除", notes = "机构专辑- 传入id")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "long")
+    })
+    @PreAuthorize("@auditsvc.hasPermissions('tenantAlbum/remove', {'BACKEND'})")
+//    @PostMapping("/remove")
+    public HttpResponseResult<Boolean> remove(@RequestParam Long id) {
+        return HttpResponseResult.succeed(tenantAlbumService.removeById(id));
+    }
+
+    private TenantInfo getTenantInfo() {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        TenantInfo tenantInfo = tenantInfoService.lambdaQuery().eq(TenantInfo::getUserId, sysUser.getId())
+                .last("limit 1").one();
+        if (tenantInfo == null) {
+            throw new BizException("非法请求");
+        }
+        return tenantInfo;
+    }
+
+}

+ 117 - 0
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/TenantAlbumPurchaseController.java

@@ -0,0 +1,117 @@
+package com.yonge.cooleshow.tenant.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.microsvc.toolkit.common.response.paging.PageInfo;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
+import com.microsvc.toolkit.common.webportal.exception.BizException;
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.TenantAlbumPurchase;
+import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
+import com.yonge.cooleshow.biz.dal.service.TenantAlbumPurchaseService;
+import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
+import com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumPurchaseWrapper;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.cooleshow.tenant.vo.TenantAlbumPurchaseVo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+
+@Slf4j
+@Validated
+@RestController
+@RequestMapping("/tenantAlbumPurchase")
+@Api(tags = "机构专辑采购")
+public class TenantAlbumPurchaseController extends BaseController {
+
+    @Autowired
+    private TenantAlbumPurchaseService tenantAlbumPurchaseService;
+
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+    @Autowired
+    private TenantInfoService tenantInfoService;
+
+    @ApiOperation(value = "详情", notes = "机构专辑采购-根据详情ID查询单条, 传入id")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", dataType = "long")
+    })
+    @PreAuthorize("@auditsvc.hasPermissions('tenantAlbumPurchase/detail', {'BACKEND'})")
+//    @GetMapping("/detail/{id}")
+    public HttpResponseResult<TenantAlbumPurchaseWrapper.TenantAlbumPurchase> detail(@PathVariable("id") Long id) {
+
+        TenantAlbumPurchase wrapper = tenantAlbumPurchaseService.detail(id);
+
+        return succeed(TenantAlbumPurchaseWrapper.TenantAlbumPurchase.from(JSON.toJSONString(wrapper)));
+    }
+
+    @ApiOperation(value = "查询分页", notes = "机构专辑采购- 传入 TenantAlbumPurchaseVo.TenantAlbumPurchaseQuery")
+    @PreAuthorize("@auditsvc.hasPermissions('tenantAlbumPurchase/page', {'BACKEND'})")
+    @PostMapping("/page")
+    public HttpResponseResult<PageInfo<TenantAlbumPurchaseWrapper.TenantAlbumPurchase>> page(
+            @RequestBody TenantAlbumPurchaseWrapper.TenantAlbumPurchaseQuery query) {
+        TenantInfo tenantInfo = getTenantInfo();
+        query.setTenantId(tenantInfo.getId());
+        // 查询数据
+        IPage<TenantAlbumPurchaseWrapper.TenantAlbumPurchase> pages =
+                tenantAlbumPurchaseService.selectPage(QueryInfo.getPage(query), query);
+        return succeed(QueryInfo.pageInfo(pages, pages.getRecords()));
+    }
+
+    @ApiOperation(value = "新增", notes = "机构专辑采购- 传入 TenantAlbumPurchaseVo.TenantAlbumPurchase")
+    @PreAuthorize("@auditsvc.hasPermissions('tenantAlbumPurchase/save', {'BACKEND'})")
+//    @PostMapping("/save")
+    public HttpResponseResult<JSONObject> add(
+            @Validated @RequestBody TenantAlbumPurchaseVo.TenantAlbumPurchase tenantAlbumPurchaseVo) {
+
+        // 新增数据
+        tenantAlbumPurchaseService.save(JSON.parseObject(tenantAlbumPurchaseVo.jsonString(),
+                TenantAlbumPurchase.class));
+        return succeed();
+    }
+
+    @ApiOperation(value = "修改", notes = "机构专辑采购- 传入 TenantAlbumPurchaseVo.TenantAlbumPurchase")
+    @PreAuthorize("@auditsvc.hasPermissions('tenantAlbumPurchase/update', {'BACKEND'})")
+//    @PostMapping("/update")
+    public HttpResponseResult<JSONObject> update(@Validated @RequestBody TenantAlbumPurchaseVo.TenantAlbumPurchase tenantAlbumPurchaseVo
+    ) {
+        // 更新数据
+        tenantAlbumPurchaseService.updateById(JSON.parseObject(tenantAlbumPurchaseVo.jsonString(),
+                TenantAlbumPurchase.class));
+        return succeed();
+    }
+
+    @ApiOperation(value = "删除", notes = "机构专辑采购- 传入id")
+    @PreAuthorize("@auditsvc.hasPermissions('tenantAlbumPurchase/remove', {'BACKEND'})")
+//    @PostMapping("/remove")
+    public HttpResponseResult<Boolean> remove(@RequestParam Long id) {
+
+        return succeed(tenantAlbumPurchaseService.removeById(id));
+    }
+
+    private TenantInfo getTenantInfo() {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        TenantInfo tenantInfo = tenantInfoService.lambdaQuery().eq(TenantInfo::getUserId, sysUser.getId())
+                .last("limit 1").one();
+        if (tenantInfo == null) {
+            throw new BizException("非法请求");
+        }
+        return tenantInfo;
+    }
+}

+ 99 - 0
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/vo/TenantActivationCodeVo.java

@@ -0,0 +1,99 @@
+package com.yonge.cooleshow.tenant.vo;
+
+import com.alibaba.fastjson.JSON;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 机构激活码
+ * 2023-07-25 11:45:04
+ */
+@ApiModel(value = "TenantActivationCodeVo对象", description = "机构激活码查询视图对象")
+public class TenantActivationCodeVo {
+
+    @Data
+    @ApiModel(" TenantActivationCodeSend-机构激活码发放")
+    public static class TenantActivationCodeSend {
+
+        @ApiModelProperty("专辑购买记录的ID")
+        @NotNull(message = "专辑购买记录的ID不能为空")
+        private Long tenantAlbumPurchaseId;
+
+        @ApiModelProperty("激活码列表,批量导入时为空")
+        private List<String> activationCodeList = new ArrayList<>();
+
+        @ApiModelProperty("学生ID列表")
+        @Size(min = 1, message = "未选择学生")
+        private List<Long> studentIdList = new ArrayList<>();
+    }
+
+    @Data
+    @ApiModel(" TenantActivationCode-机构激活码")
+    public static class TenantActivationCode {
+
+
+        @ApiModelProperty("主键ID")
+        private Long id;
+
+
+        @ApiModelProperty("机构ID")
+        private Long tenantId;
+
+
+        @ApiModelProperty("机构专辑ID")
+        private Long tenantAlbumId;
+
+
+        @ApiModelProperty("机构专辑采购ID")
+        private Long tenantAlbumPurchaseId;
+
+
+        @ApiModelProperty("激活码")
+        private String activationCode;
+
+
+        @ApiModelProperty("发送状态(WAIT,SEND)")
+        private String sendStatus;
+
+
+        @ApiModelProperty("激活状态")
+        private Boolean activationStatus;
+
+
+        @ApiModelProperty("激活手机号")
+        private String activationPhone;
+
+
+        @ApiModelProperty("激活时间")
+        private Date activationTime;
+
+
+        @ApiModelProperty("激活用户ID")
+        private Long activationUserId;
+
+
+        @ApiModelProperty("更新时间")
+        private Date updateTime;
+
+
+        @ApiModelProperty("创建时间")
+        private Date createTime;
+
+
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static TenantActivationCode from(String json) {
+            return JSON.parseObject(json, TenantActivationCode.class);
+        }
+    }
+
+}

+ 64 - 0
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/vo/TenantAlbumPurchaseVo.java

@@ -0,0 +1,64 @@
+package com.yonge.cooleshow.tenant.vo;
+
+import com.alibaba.fastjson.JSON;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 机构专辑采购
+ * 2023-07-25 11:05:33
+ */
+@ApiModel(value = "TenantAlbumPurchaseVo对象", description = "机构专辑采购查询视图对象")
+public class TenantAlbumPurchaseVo {
+
+    @Data
+    @ApiModel(" TenantAlbumPurchase-机构专辑采购")
+    public static class TenantAlbumPurchase {
+
+        @ApiModelProperty("主键ID")
+        private Long id;
+
+        @ApiModelProperty("机构ID")
+        private Long tenantId;
+
+        @ApiModelProperty("机构专辑ID")
+        private Long tenantAlbumId;
+
+        @ApiModelProperty("采购时间")
+        private Date purchaseTime;
+
+        @ApiModelProperty("购买数量")
+        private Integer purchaseQuantity;
+
+        @ApiModelProperty("采购周期")
+        private Integer purchaseCycle;
+
+        @ApiModelProperty("激活数量")
+        private Integer activeQuantity;
+
+        @ApiModelProperty("采购价格")
+        private BigDecimal purchasePrice;
+
+        @ApiModelProperty("采购状态")
+        private String purchaseStatus;
+
+        @ApiModelProperty("更新时间")
+        private Date updateTime;
+
+        @ApiModelProperty("创建时间")
+        private Date createTime;
+
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static TenantAlbumPurchase from(String json) {
+            return JSON.parseObject(json, TenantAlbumPurchase.class);
+        }
+    }
+
+}

+ 83 - 0
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/vo/TenantAlbumVo.java

@@ -0,0 +1,83 @@
+package com.yonge.cooleshow.tenant.vo;
+
+import com.alibaba.fastjson.JSON;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 机构专辑
+ * 2023-07-25 10:27:37
+ */
+@ApiModel(value = "TenantAlbumVo对象", description = "机构专辑查询视图对象")
+public class TenantAlbumVo {
+
+    @Data
+    @ApiModel(" TenantAlbum-机构专辑")
+    public static class TenantAlbum {
+
+
+        @ApiModelProperty("主键ID")
+        private Long id;
+
+
+        @ApiModelProperty("专辑名称")
+        private String name;
+
+
+        @ApiModelProperty("专辑介绍")
+        private String describe;
+
+
+        @ApiModelProperty("专辑封面")
+        private String coverImg;
+
+
+        @ApiModelProperty("曲目数")
+        private Integer musicNum;
+
+
+        @ApiModelProperty("平台价格")
+        private BigDecimal originalPrice;
+
+
+        @ApiModelProperty("机构价格")
+        private BigDecimal salePrice;
+
+
+        @ApiModelProperty("购买周期")
+        private Integer purchaseCycle;
+
+
+        @ApiModelProperty("曲目声部分类(多个,分隔)")
+        private String subjectTypes;
+
+
+        @ApiModelProperty("启用状态")
+        private Boolean status;
+
+
+        @ApiModelProperty("删除标识")
+        private Boolean delFlag;
+
+
+        @ApiModelProperty("更新时间")
+        private Date updateTime;
+
+
+        @ApiModelProperty("创建时间")
+        private Date createTime;
+
+
+        public String jsonString() {
+            return JSON.toJSONString(this);
+        }
+
+        public static TenantAlbum from(String json) {
+            return JSON.parseObject(json, TenantAlbum.class);
+        }
+    }
+}