Kaynağa Gözat

1.问题修改

yuanliang 1 yıl önce
ebeveyn
işleme
5f7a66f6dd

+ 2 - 1
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/TenantAlbumController.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.admin.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.yonge.cooleshow.admin.io.request.TenantAlbumVo;
 import com.yonge.cooleshow.api.feign.dto.TenantWrapper;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
@@ -64,7 +65,7 @@ public class TenantAlbumController {
     //@PreAuthorize("@pcs.hasPermissions('tenantAlbum/page')")
     public HttpResponseResult<PageInfo<TenantAlbumWrapper.TenantAlbum>> page(@RequestBody TenantAlbumWrapper.TenantAlbumQuery query) {
 
-        IPage<TenantAlbumWrapper.TenantAlbum> pages = tenantAlbumService.selectPage(PageUtil.getPage(query), query);
+        IPage<TenantAlbumWrapper.TenantAlbum> pages = tenantAlbumService.selectPage(QueryInfo.getPage(query), query);
         return HttpResponseResult.succeed(PageUtil.pageInfo(pages));
     }
 

+ 20 - 14
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/TenantActivationCodeService.java

@@ -14,58 +14,64 @@ import java.util.List;
  * 机构激活码
  * 2023-07-21 17:32:49
  */
-public interface TenantActivationCodeService extends IService<TenantActivationCode>  {
+public interface TenantActivationCodeService extends IService<TenantActivationCode> {
 
-	/**
+    /**
      * 查询详情
+     *
      * @param id 详情ID
      * @return TenantActivationCode
      */
-	TenantActivationCode detail(Long id);
+    TenantActivationCode detail(Long id);
 
     /**
      * 分页查询
-     * @param page IPage<TenantActivationCode>
+     *
+     * @param page  IPage<TenantActivationCode>
      * @param query TenantActivationCodeWrapper.TenantActivationCodeQuery
      * @return IPage<TenantActivationCode>
      */
     IPage<TenantActivationCodeWrapper.TenantActivationCode> selectPage(IPage<TenantActivationCodeWrapper.TenantActivationCode> page,
                                                                        TenantActivationCodeWrapper.TenantActivationCodeQuery query);
-	
+
     /**
      * 添加
+     *
      * @param tenantActivationCode TenantActivationCodeWrapper.TenantActivationCode
      * @return Boolean
      */
-     Boolean add(TenantActivationCodeWrapper.TenantActivationCode tenantActivationCode);   
+    Boolean add(TenantActivationCodeWrapper.TenantActivationCode tenantActivationCode);
 
     /**
      * 更新
+     *
      * @param tenantActivationCode TenantActivationCodeWrapper.TenantActivationCode
      * @return Boolean
      */
-     Boolean update(TenantActivationCodeWrapper.TenantActivationCode tenantActivationCode);
+    Boolean update(TenantActivationCodeWrapper.TenantActivationCode tenantActivationCode);
 
-    void sendActivationCode(Long tenantId, Long tenantAlbumPurchaseId, List<String> activationCodeList, List<Long> studentIdList);
+    void sendActivationCode(Long tenantId, Long tenantAlbumPurchaseId, List<String> activationCodeList,
+                            List<Long> studentIdList);
 
     void active(String activationCode, Long studentId);
 
 
-
     /**
      * 添加用户机构专辑激活记录
      *
-     * @param studentId 学生ID
+     * @param studentId         学生ID
      * @param userOrderDetailVo 订单详情
      */
     void addUserTenantAlbumRecord(Long studentId, UserOrderDetailVo userOrderDetailVo);
 
     /**
      * 导入激活码
-     * @param dataList 数据列表
-     * @param tenantId 机构ID
-     * @param id 机构管理员用户ID
+     *
+     * @param dataList              数据列表
+     * @param tenantId              机构ID
+     * @param userId                机构管理员用户ID
+     * @param tenantAlbumPurchaseId 专辑购买的ID
      */
     void importActiveCode(List<ExcelDataReaderProperty<TenantActivationCodeWrapper.ImportTemplate>> dataList,
-                          Long tenantId, Long userId);
+                          Long tenantId, Long userId, Long tenantAlbumPurchaseId);
 }

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

@@ -26,7 +26,7 @@ public interface TenantAlbumService extends IService<TenantAlbum>  {
      * @param query TenantAlbumWrapper.TenantAlbumQuery
      * @return IPage<TenantAlbum>
      */
-    IPage<TenantAlbumWrapper.TenantAlbumQuery> selectPage(IPage<TenantAlbumWrapper.TenantAlbumQuery> page, TenantAlbumWrapper.TenantAlbumQuery query);
+    IPage<TenantAlbumWrapper.TenantAlbum> selectPage(IPage<TenantAlbumWrapper.TenantAlbum> page, TenantAlbumWrapper.TenantAlbumQuery query);
 	
     /**
      * 添加

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

@@ -232,7 +232,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
     @Transactional(rollbackFor = Exception.class)
     @Override
     public void importActiveCode(List<ExcelDataReaderProperty<TenantActivationCodeWrapper.ImportTemplate>> dataList,
-                                 Long tenantId, Long userId) {
+                                 Long tenantId, Long userId, Long tenantAlbumPurchaseId) {
         if (dataList.isEmpty()) {
             return;
         }
@@ -241,6 +241,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
         List<String> errMsg = new ArrayList<>();
         Set<String> codeSet = new HashSet<>();
         Map<String, Integer> codeRowMap = new HashMap<>();
+        Map<String, String> codePhoneMap = new HashMap<>();
         // 校验数据格式是否错误
         for (ExcelDataReaderProperty<TenantActivationCodeWrapper.ImportTemplate> next : dataList) {
             Integer rowIndex = next.getRowIndex();
@@ -254,6 +255,7 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
                 codeSet.add(code.getCode());
             }
             codeRowMap.put(code.getCode().trim(), msgRowNo);
+            codePhoneMap.put(code.getCode().trim(), code.getPhone().trim());
 
             if (errMsg.size() > 100) {
                 break;
@@ -265,9 +267,11 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
         }
         // 校验激活码是否被使用
         List<List<String>> codePartition = Lists.partition(new ArrayList<>(codeRowMap.keySet()), 50);
+
+        List<TenantActivationCode> tenantActivationCodes = new ArrayList<>();
         for (List<String> codes : codePartition) {
             List<TenantActivationCode> activationCodes = this.lambdaQuery()
-                    .eq(TenantActivationCode::getTenantId,tenantId)
+                    .eq(TenantActivationCode::getTenantId, tenantId)
                     .in(TenantActivationCode::getActivationCode, codes).list();
 
             // 存在无效码或者已经使用过的码
@@ -284,20 +288,19 @@ public class TenantActivationCodeServiceImpl extends ServiceImpl<TenantActivatio
                     }
                 }
             }
+
+            activationCodes.forEach(next -> {
+                next.setActivationPhone(codePhoneMap.get(next.getActivationCode()));
+                next.setSendStatus(EActivationCode.SEND);
+            });
+            tenantActivationCodes.addAll(activationCodes);
         }
         if (!errMsg.isEmpty()) {
             throw new BizException(String.join(",", errMsg));
         }
-
-        for (List<String> codes : codePartition) {
-//            this.lambdaUpdate()
-//                    .set(TenantActivationCode::getSendStatus,EActivationCode.SEND)
-//                    .set(TenantActivationCode::getActivationStatus,true)
-//                    .set(TenantActivationCode)
-
+        if (tenantActivationCodes.isEmpty()) {
+            this.updateBatchById(tenantActivationCodes, 50);
         }
-
-
     }
 
     private void addUserTenantAlbumRecord(Long studentId, TenantAlbumPurchase purchase,

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

@@ -3,8 +3,8 @@ package com.yonge.cooleshow.biz.dal.wrapper;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.yonge.cooleshow.biz.dal.enums.SubjectTypeEnum;
-import com.yonge.toolset.base.page.QueryInfo;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -32,7 +32,7 @@ public class TenantAlbumWrapper {
     @NoArgsConstructor
     @AllArgsConstructor
     @ApiModel(" TenantAlbumQuery-机构专辑")
-    public static class   TenantAlbumQuery extends QueryInfo {
+    public static class TenantAlbumQuery implements QueryInfo {
 
         @ApiModelProperty("主键ID")
         private Long id;
@@ -75,41 +75,41 @@ public class TenantAlbumWrapper {
     @ApiModel(" TenantAlbum-机构专辑返回")
     public static class TenantAlbum {
 
-            @ApiModelProperty("主键ID")
-            private Long id;
+        @ApiModelProperty("主键ID")
+        private Long id;
 
-            @ApiModelProperty("机构ID")
-            private Long tenantId;
+        @ApiModelProperty("机构ID")
+        private Long tenantId;
 
-            @ApiModelProperty("专辑名称")
-            private String name;
+        @ApiModelProperty("专辑名称")
+        private String name;
 
-            @ApiModelProperty("机构名称")
-            private String tenantName;
+        @ApiModelProperty("机构名称")
+        private String tenantName;
 
-            @ApiModelProperty("专辑介绍")
-            private String describe;
+        @ApiModelProperty("专辑介绍")
+        private String describe;
 
-            @ApiModelProperty("专辑封面")
-            private String coverImg;
+        @ApiModelProperty("专辑封面")
+        private String coverImg;
 
-            @ApiModelProperty("曲目数")
-            private Integer musicNum;
+        @ApiModelProperty("曲目数")
+        private Integer musicNum;
 
-            @ApiModelProperty("平台价格")
-            private BigDecimal originalPrice;
+        @ApiModelProperty("平台价格")
+        private BigDecimal originalPrice;
 
-            @ApiModelProperty("机构价格")
-            private BigDecimal salePrice;
+        @ApiModelProperty("机构价格")
+        private BigDecimal salePrice;
 
-            @ApiModelProperty("购买周期")
-            private Integer purchaseCycle;
+        @ApiModelProperty("购买周期")
+        private Integer purchaseCycle;
 
-            @ApiModelProperty("曲目声部分类(多个,分隔)")
-            private String subjectTypes;
+        @ApiModelProperty("曲目声部分类(多个,分隔)")
+        private String subjectTypes;
 
-            @ApiModelProperty("启用状态")
-            private Boolean status;
+        @ApiModelProperty("启用状态")
+        private Boolean status;
 
         @ApiModelProperty("删除标识")
         private Boolean delFlag;
@@ -132,7 +132,7 @@ public class TenantAlbumWrapper {
         }
 
         @Data
-        public static class MusicSheetData{
+        public static class MusicSheetData {
             private SubjectTypeEnum subjectType;
 
             private List<Long> musicSheetIdList = new ArrayList<>();
@@ -184,10 +184,10 @@ public class TenantAlbumWrapper {
         @ApiModelProperty("采购倍数")
         private Integer buyMultiple;
 
-        @ApiModelProperty(value = "采购周期",hidden = true)
+        @ApiModelProperty(value = "采购周期", hidden = true)
         private Integer buyCycle;
 
-        @ApiModelProperty(value = "采购机构",hidden = true)
+        @ApiModelProperty(value = "采购机构", hidden = true)
         private Long tenantId;
 
     }

+ 4 - 2
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/TenantActivationCodeController.java

@@ -160,7 +160,9 @@ public class TenantActivationCodeController extends BaseController {
 
     @PostMapping("/importActiveCode")
     @ApiOperation(value = "导入", notes = "传入file")
-    public HttpResponseResult<List<ErrMsg>> importActiveCode(@RequestParam("file") MultipartFile file) {
+    public HttpResponseResult<List<ErrMsg>> importActiveCode(
+            @RequestParam("file") MultipartFile file,
+            @RequestParam("tenantAlbumPurchaseId") Long tenantAlbumPurchaseId) {
         if (null == file) {
             return HttpResponseResult.failed("请上传文件");
         }
@@ -176,7 +178,7 @@ public class TenantActivationCodeController extends BaseController {
         try {
             ExcelDataReader<TenantActivationCodeWrapper.ImportTemplate> reader =
                     ExcelUtils.getReader(TenantActivationCodeWrapper.ImportTemplate.class, file);
-            tenantActivationCodeService.importActiveCode(reader.getDataList(), user.getTenantId(), user.getId());
+            tenantActivationCodeService.importActiveCode(reader.getDataList(), user.getTenantId(), user.getId(), tenantAlbumPurchaseId);
             return HttpResponseResult.succeed();
         } catch (ExcelException e) {
             return HttpResponseResult.failed(BizHttpStatus.IMPORT.getCode(), e.getErrMsgList(),

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

@@ -63,7 +63,7 @@ public class TenantAlbumController extends BaseController {
         TenantInfo tenantInfo = getTenantInfo();
         query.setTenantId(tenantInfo.getId());
         // 查询数据
-        IPage<TenantAlbumWrapper.TenantAlbumQuery> pages = tenantAlbumService.selectPage(QueryInfo.getPage(query), query);
+        IPage<TenantAlbumWrapper.TenantAlbum> pages = tenantAlbumService.selectPage(QueryInfo.getPage(query), query);
         // 数据类型转换
         List<TenantAlbumVo.TenantAlbum> records = JSON.parseArray(JSON.toJSONString(pages.getRecords()),
                 TenantAlbumVo.TenantAlbum.class);