Commit 34bf360da67f22e0d7f61ae218de621c4c412545
1 parent
a76760c4
trade:调整拼团活动列表接口
Showing
15 changed files
with
165 additions
and
61 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/CombinationActivityController.java
| ... | ... | @@ -5,14 +5,14 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 6 | import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; |
| 7 | 7 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 8 | -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; | |
| 9 | -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO; | |
| 10 | -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO; | |
| 11 | -import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; | |
| 8 | +import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.*; | |
| 12 | 9 | import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; |
| 13 | 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; |
| 14 | 11 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; |
| 12 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; | |
| 13 | +import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; | |
| 15 | 14 | import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; |
| 15 | +import cn.iocoder.yudao.module.promotion.service.combination.CombinationRecordService; | |
| 16 | 16 | import io.swagger.v3.oas.annotations.Operation; |
| 17 | 17 | import io.swagger.v3.oas.annotations.Parameter; |
| 18 | 18 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -23,6 +23,8 @@ import org.springframework.web.bind.annotation.*; |
| 23 | 23 | import javax.annotation.Resource; |
| 24 | 24 | import javax.validation.Valid; |
| 25 | 25 | import java.util.List; |
| 26 | +import java.util.Map; | |
| 27 | +import java.util.Set; | |
| 26 | 28 | |
| 27 | 29 | import static cn.hutool.core.collection.CollectionUtil.newArrayList; |
| 28 | 30 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| ... | ... | @@ -36,6 +38,8 @@ public class CombinationActivityController { |
| 36 | 38 | |
| 37 | 39 | @Resource |
| 38 | 40 | private CombinationActivityService combinationActivityService; |
| 41 | + @Resource | |
| 42 | + private CombinationRecordService combinationRecordService; | |
| 39 | 43 | |
| 40 | 44 | @Resource |
| 41 | 45 | private ProductSpuApi productSpuApi; |
| ... | ... | @@ -77,7 +81,7 @@ public class CombinationActivityController { |
| 77 | 81 | @GetMapping("/page") |
| 78 | 82 | @Operation(summary = "获得拼团活动分页") |
| 79 | 83 | @PreAuthorize("@ss.hasPermission('promotion:combination-activity:query')") |
| 80 | - public CommonResult<PageResult<CombinationActivityRespVO>> getCombinationActivityPage( | |
| 84 | + public CommonResult<PageResult<CombinationActivityPageItemRespVO>> getCombinationActivityPage( | |
| 81 | 85 | @Valid CombinationActivityPageReqVO pageVO) { |
| 82 | 86 | // 查询拼团活动 |
| 83 | 87 | PageResult<CombinationActivityDO> pageResult = combinationActivityService.getCombinationActivityPage(pageVO); |
| ... | ... | @@ -85,12 +89,21 @@ public class CombinationActivityController { |
| 85 | 89 | return success(PageResult.empty(pageResult.getTotal())); |
| 86 | 90 | } |
| 87 | 91 | |
| 92 | + // 统计数据 | |
| 93 | + Set<Long> activityIds = convertSet(pageResult.getList(), CombinationActivityDO::getId); | |
| 94 | + Map<Long, Integer> groupCountMap = combinationRecordService.getCombinationRecordCountMapByActivity( | |
| 95 | + activityIds, null, CombinationRecordDO.HEAD_ID_GROUP); | |
| 96 | + Map<Long, Integer> groupSuccessCountMap = combinationRecordService.getCombinationRecordCountMapByActivity( | |
| 97 | + activityIds, CombinationRecordStatusEnum.SUCCESS.getStatus(), CombinationRecordDO.HEAD_ID_GROUP); | |
| 98 | + Map<Long, Integer> recordCountMap = combinationRecordService.getCombinationRecordCountMapByActivity( | |
| 99 | + activityIds, null, null); | |
| 88 | 100 | // 拼接数据 |
| 89 | 101 | List<CombinationProductDO> products = combinationActivityService.getCombinationProductsByActivityIds( |
| 90 | 102 | convertSet(pageResult.getList(), CombinationActivityDO::getId)); |
| 91 | 103 | List<ProductSpuRespDTO> spus = productSpuApi.getSpuList( |
| 92 | 104 | convertSet(pageResult.getList(), CombinationActivityDO::getSpuId)); |
| 93 | - return success(CombinationActivityConvert.INSTANCE.convertPage(pageResult, products, spus)); | |
| 105 | + return success(CombinationActivityConvert.INSTANCE.convertPage(pageResult, products, | |
| 106 | + groupCountMap, groupSuccessCountMap, recordCountMap, spus)); | |
| 94 | 107 | } |
| 95 | 108 | |
| 96 | 109 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityBaseVO.java
| ... | ... | @@ -48,6 +48,9 @@ public class CombinationActivityBaseVO { |
| 48 | 48 | @NotNull(message = "开团人数不能为空") |
| 49 | 49 | private Integer userSize; |
| 50 | 50 | |
| 51 | + @Schema(description = "虚拟成团", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | |
| 52 | + private Boolean virtualGroup = false; // TODO @puhui999:这个字段界面没做呀。 | |
| 53 | + | |
| 51 | 54 | @Schema(description = "限制时长(小时)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 52 | 55 | @NotNull(message = "限制时长不能为空") |
| 53 | 56 | private Integer limitDuration; | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageItemRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO; | |
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | + | |
| 9 | +import java.time.LocalDateTime; | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 12 | +@Schema(description = "管理后台 - 拼团活动的分页项 Response VO") | |
| 13 | +@Data | |
| 14 | +@EqualsAndHashCode(callSuper = true) | |
| 15 | +@ToString(callSuper = true) | |
| 16 | +public class CombinationActivityPageItemRespVO extends CombinationActivityBaseVO { | |
| 17 | + | |
| 18 | + @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") | |
| 19 | + private Long id; | |
| 20 | + | |
| 21 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 22 | + private LocalDateTime createTime; | |
| 23 | + | |
| 24 | + @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | |
| 25 | + private Integer status; | |
| 26 | + | |
| 27 | + @Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 28 | + private List<CombinationProductRespVO> products; | |
| 29 | + | |
| 30 | + // ========== 商品字段 ========== | |
| 31 | + | |
| 32 | + @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 | |
| 33 | + example = "618大促") | |
| 34 | + private String spuName; | |
| 35 | + @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 | |
| 36 | + example = "https://www.iocoder.cn/xx.png") | |
| 37 | + private String picUrl; | |
| 38 | + @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 | |
| 39 | + example = "50") | |
| 40 | + private Integer marketPrice; | |
| 41 | + | |
| 42 | + // ========== 统计字段 ========== | |
| 43 | + | |
| 44 | + @Schema(description = "开团组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "33") | |
| 45 | + private Integer groupCount; | |
| 46 | + | |
| 47 | + @Schema(description = "成团组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") | |
| 48 | + private Integer groupSuccessCount; | |
| 49 | + | |
| 50 | + @Schema(description = "购买次数", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | |
| 51 | + private Integer recordCount; | |
| 52 | + | |
| 53 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityPageReqVO.java
| ... | ... | @@ -15,8 +15,7 @@ public class CombinationActivityPageReqVO extends PageParam { |
| 15 | 15 | @Schema(description = "拼团名称", example = "赵六") |
| 16 | 16 | private String name; |
| 17 | 17 | |
| 18 | - @Schema(description = "活动状态:0开启 1关闭", example = "0") | |
| 18 | + @Schema(description = "活动状态", example = "0") | |
| 19 | 19 | private Integer status; |
| 20 | 20 | |
| 21 | - | |
| 22 | 21 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/combination/vo/activity/CombinationActivityRespVO.java
| ... | ... | @@ -6,8 +6,6 @@ import lombok.Data; |
| 6 | 6 | import lombok.EqualsAndHashCode; |
| 7 | 7 | import lombok.ToString; |
| 8 | 8 | |
| 9 | -import javax.validation.Valid; | |
| 10 | -import javax.validation.constraints.NotNull; | |
| 11 | 9 | import java.time.LocalDateTime; |
| 12 | 10 | import java.util.List; |
| 13 | 11 | |
| ... | ... | @@ -20,30 +18,12 @@ public class CombinationActivityRespVO extends CombinationActivityBaseVO { |
| 20 | 18 | @Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "22901") |
| 21 | 19 | private Long id; |
| 22 | 20 | |
| 23 | - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618 大促") | |
| 24 | - private String spuName; | |
| 25 | - | |
| 26 | - @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/xx.png") | |
| 27 | - private String picUrl; | |
| 28 | - | |
| 29 | 21 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 30 | 22 | private LocalDateTime createTime; |
| 31 | 23 | |
| 32 | 24 | @Schema(description = "开团人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "666") |
| 33 | 25 | private Integer userSize; |
| 34 | 26 | |
| 35 | - @Schema(description = "开团组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "33") | |
| 36 | - private Integer totalCount; | |
| 37 | - | |
| 38 | - @Schema(description = "成团组数", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") | |
| 39 | - private Integer successCount; | |
| 40 | - | |
| 41 | - @Schema(description = "虚拟成团", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | |
| 42 | - private Integer virtualGroup; | |
| 43 | - | |
| 44 | - @Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | |
| 45 | - private Integer status; | |
| 46 | - | |
| 47 | 27 | @Schema(description = "拼团商品", requiredMode = Schema.RequiredMode.REQUIRED) |
| 48 | 28 | private List<CombinationProductRespVO> products; |
| 49 | 29 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java
| ... | ... | @@ -18,16 +18,6 @@ public class SeckillActivityRespVO extends SeckillActivityBaseVO { |
| 18 | 18 | @Schema(description = "秒杀活动 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 19 | 19 | private Long id; |
| 20 | 20 | |
| 21 | - @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 | |
| 22 | - example = "618大促") | |
| 23 | - private String spuName; | |
| 24 | - @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 | |
| 25 | - example = "https://www.iocoder.cn/xx.png") | |
| 26 | - private String picUrl; | |
| 27 | - @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 | |
| 28 | - example = "50") | |
| 29 | - private Integer marketPrice; | |
| 30 | - | |
| 31 | 21 | @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) |
| 32 | 22 | private List<SeckillProductRespVO> products; |
| 33 | 23 | |
| ... | ... | @@ -52,4 +42,16 @@ public class SeckillActivityRespVO extends SeckillActivityBaseVO { |
| 52 | 42 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 53 | 43 | private LocalDateTime createTime; |
| 54 | 44 | |
| 45 | + // ========== 商品字段 ========== | |
| 46 | + | |
| 47 | + @Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 name 读取 | |
| 48 | + example = "618大促") | |
| 49 | + private String spuName; | |
| 50 | + @Schema(description = "商品主图", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 picUrl 读取 | |
| 51 | + example = "https://www.iocoder.cn/xx.png") | |
| 52 | + private String picUrl; | |
| 53 | + @Schema(description = "商品市场价,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, // 从 SPU 的 marketPrice 读取 | |
| 54 | + example = "50") | |
| 55 | + private Integer marketPrice; | |
| 56 | + | |
| 55 | 57 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java
| ... | ... | @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; |
| 8 | 8 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 9 | 9 | import cn.iocoder.yudao.module.promotion.api.combination.dto.CombinationRecordCreateReqDTO; |
| 10 | 10 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; |
| 11 | +import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageItemRespVO; | |
| 11 | 12 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityRespVO; |
| 12 | 13 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; |
| 13 | 14 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO; |
| ... | ... | @@ -53,19 +54,27 @@ public interface CombinationActivityConvert { |
| 53 | 54 | |
| 54 | 55 | List<CombinationActivityRespVO> convertList(List<CombinationActivityDO> list); |
| 55 | 56 | |
| 56 | - PageResult<CombinationActivityRespVO> convertPage(PageResult<CombinationActivityDO> page); | |
| 57 | 57 | |
| 58 | - default PageResult<CombinationActivityRespVO> convertPage(PageResult<CombinationActivityDO> page, | |
| 59 | - List<CombinationProductDO> productList, | |
| 60 | - List<ProductSpuRespDTO> spuList) { | |
| 58 | + default PageResult<CombinationActivityPageItemRespVO> convertPage(PageResult<CombinationActivityDO> page, | |
| 59 | + List<CombinationProductDO> productList, | |
| 60 | + Map<Long, Integer> groupCountMap, | |
| 61 | + Map<Long, Integer> groupSuccessCountMap, | |
| 62 | + Map<Long, Integer> recordCountMap, | |
| 63 | + List<ProductSpuRespDTO> spuList) { | |
| 64 | + PageResult<CombinationActivityPageItemRespVO> pageResult = convertPage(page); | |
| 61 | 65 | Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId); |
| 62 | - PageResult<CombinationActivityRespVO> pageResult = convertPage(page); | |
| 63 | 66 | pageResult.getList().forEach(item -> { |
| 64 | - MapUtils.findAndThen(spuMap, item.getSpuId(), spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl())); | |
| 67 | + MapUtils.findAndThen(spuMap, item.getSpuId(), spu -> item.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()) | |
| 68 | + .setMarketPrice(spu.getMarketPrice())); | |
| 65 | 69 | item.setProducts(convertList2(productList)); |
| 70 | + // 设置统计字段 | |
| 71 | + item.setGroupCount(groupCountMap.getOrDefault(item.getId(), 0)) | |
| 72 | + .setGroupSuccessCount(groupSuccessCountMap.getOrDefault(item.getId(), 0)) | |
| 73 | + .setRecordCount(recordCountMap.getOrDefault(item.getId(), 0)); | |
| 66 | 74 | }); |
| 67 | 75 | return pageResult; |
| 68 | 76 | } |
| 77 | + PageResult<CombinationActivityPageItemRespVO> convertPage(PageResult<CombinationActivityDO> page); | |
| 69 | 78 | |
| 70 | 79 | List<CombinationProductRespVO> convertList2(List<CombinationProductDO> productDOs); |
| 71 | 80 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationActivityDO.java
| ... | ... | @@ -60,21 +60,9 @@ public class CombinationActivityDO extends BaseDO { |
| 60 | 60 | */ |
| 61 | 61 | private Integer userSize; |
| 62 | 62 | /** |
| 63 | - * 开团组数 | |
| 64 | - */ | |
| 65 | - private Integer totalCount; | |
| 66 | - /** | |
| 67 | - * 成团组数 | |
| 68 | - */ | |
| 69 | - private Integer successCount; | |
| 70 | - /** | |
| 71 | - * 参与人数 | |
| 72 | - */ | |
| 73 | - private Integer orderUserCount; | |
| 74 | - /** | |
| 75 | 63 | * 虚拟成团 |
| 76 | 64 | */ |
| 77 | - private Integer virtualGroup; | |
| 65 | + private Boolean virtualGroup; | |
| 78 | 66 | /** |
| 79 | 67 | * 活动状态 |
| 80 | 68 | * | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/combination/CombinationRecordDO.java
| ... | ... | @@ -29,6 +29,11 @@ import java.time.LocalDateTime; |
| 29 | 29 | public class CombinationRecordDO extends BaseDO { |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | + * 团长编号 - 团长 | |
| 33 | + */ | |
| 34 | + public static final Integer HEAD_ID_GROUP = 0; | |
| 35 | + | |
| 36 | + /** | |
| 32 | 37 | * 编号,主键自增 |
| 33 | 38 | */ |
| 34 | 39 | @TableId |
| ... | ... | @@ -84,6 +89,8 @@ public class CombinationRecordDO extends BaseDO { |
| 84 | 89 | * 团长编号 |
| 85 | 90 | * |
| 86 | 91 | * 关联 {@link CombinationRecordDO#getId()} |
| 92 | + * | |
| 93 | + * 如果是团长,则它的值是 {@link #HEAD_ID_GROUP} | |
| 87 | 94 | */ |
| 88 | 95 | private Long headId; |
| 89 | 96 | /** | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationRecordMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.dal.mysql.combination; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.hutool.core.map.MapUtil; | |
| 5 | +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 3 | 6 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | 7 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 5 | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; |
| 9 | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |
| 6 | 10 | import org.apache.ibatis.annotations.Mapper; |
| 7 | 11 | |
| 12 | +import java.util.Collection; | |
| 13 | +import java.util.Collections; | |
| 8 | 14 | import java.util.List; |
| 15 | +import java.util.Map; | |
| 9 | 16 | |
| 10 | 17 | /** |
| 11 | 18 | * 拼团记录 Mapper |
| ... | ... | @@ -90,4 +97,22 @@ public interface CombinationRecordMapper extends BaseMapperX<CombinationRecordDO |
| 90 | 97 | .last("LIMIT " + count)); |
| 91 | 98 | } |
| 92 | 99 | |
| 100 | + default Map<Long, Integer> selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(Collection<Long> activityIds, | |
| 101 | + Integer status, Integer headId) { | |
| 102 | + // SQL count 查询 | |
| 103 | + List<Map<String, Object>> result = selectMaps(new QueryWrapper<CombinationRecordDO>() | |
| 104 | + .select("COUNT(DISTINCT(user_id)) AS recordCount, activity_id AS activityId") | |
| 105 | + .in("activity_id", activityIds) | |
| 106 | + .eq(status != null, "status", status) | |
| 107 | + .eq(headId != null, "head_id", headId) | |
| 108 | + .groupBy("activity_id")); | |
| 109 | + if (CollUtil.isEmpty(result)) { | |
| 110 | + return Collections.emptyMap(); | |
| 111 | + } | |
| 112 | + // 转换数据 | |
| 113 | + return CollectionUtils.convertMap(result, | |
| 114 | + record -> MapUtil.getLong(record, "activityId"), | |
| 115 | + record -> MapUtil.getInt(record, "recordCount" )); | |
| 116 | + } | |
| 117 | + | |
| 93 | 118 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java
| ... | ... | @@ -101,7 +101,7 @@ public interface CombinationActivityService { |
| 101 | 101 | PageResult<CombinationActivityDO> getCombinationActivityPage(PageParam pageParam); |
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | - * 获取指定活动指定 sku 编号的商品 | |
| 104 | + * 获取指定活动、指定 sku 编号的商品 | |
| 105 | 105 | * |
| 106 | 106 | * @param activityId 活动编号 |
| 107 | 107 | * @param skuId sku 编号 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java
| ... | ... | @@ -65,13 +65,11 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic |
| 65 | 65 | |
| 66 | 66 | // 插入拼团活动 |
| 67 | 67 | CombinationActivityDO activity = CombinationActivityConvert.INSTANCE.convert(createReqVO) |
| 68 | - .setStatus(CommonStatusEnum.ENABLE.getStatus()) | |
| 69 | - .setTotalCount(0).setSuccessCount(0).setOrderUserCount(0).setVirtualGroup(0); | |
| 68 | + .setStatus(CommonStatusEnum.ENABLE.getStatus()); | |
| 70 | 69 | combinationActivityMapper.insert(activity); |
| 71 | 70 | // 插入商品 |
| 72 | 71 | List<CombinationProductDO> products = CombinationActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), activity); |
| 73 | 72 | combinationProductMapper.insertBatch(products); |
| 74 | - // 返回 | |
| 75 | 73 | return activity.getId(); |
| 76 | 74 | } |
| 77 | 75 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordService.java
| ... | ... | @@ -7,9 +7,13 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationA |
| 7 | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; |
| 8 | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; |
| 9 | 9 | |
| 10 | +import javax.annotation.Nullable; | |
| 10 | 11 | import java.time.LocalDateTime; |
| 12 | +import java.util.Collection; | |
| 11 | 13 | import java.util.List; |
| 14 | +import java.util.Map; | |
| 12 | 15 | |
| 16 | +// todo @PUHUI:方法名,还是带下 Combination 哈 | |
| 13 | 17 | /** |
| 14 | 18 | * 拼团记录 Service 接口 |
| 15 | 19 | * |
| ... | ... | @@ -127,4 +131,16 @@ public interface CombinationRecordService { |
| 127 | 131 | */ |
| 128 | 132 | List<CombinationRecordDO> getRecordListByHeadId(Long headId); |
| 129 | 133 | |
| 134 | + /** | |
| 135 | + * 【拼团活动】获得拼团记录数量 Map | |
| 136 | + * | |
| 137 | + * @param activityIds 活动记录编号数组 | |
| 138 | + * @param status 拼团状态,允许空 | |
| 139 | + * @param headId 团长编号,允许空。目的 headId 设置为 {@link CombinationRecordDO#HEAD_ID_GROUP} 时,可以设置 | |
| 140 | + * @return 拼团记录数量 Map | |
| 141 | + */ | |
| 142 | + Map<Long, Integer> getCombinationRecordCountMapByActivity(Collection<Long> activityIds, | |
| 143 | + @Nullable Integer status, | |
| 144 | + @Nullable Integer headId); | |
| 145 | + | |
| 130 | 146 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| ... | ... | @@ -25,9 +25,12 @@ import org.springframework.stereotype.Service; |
| 25 | 25 | import org.springframework.transaction.annotation.Transactional; |
| 26 | 26 | import org.springframework.validation.annotation.Validated; |
| 27 | 27 | |
| 28 | +import javax.annotation.Nullable; | |
| 28 | 29 | import javax.annotation.Resource; |
| 29 | 30 | import java.time.LocalDateTime; |
| 31 | +import java.util.Collection; | |
| 30 | 32 | import java.util.List; |
| 33 | +import java.util.Map; | |
| 31 | 34 | |
| 32 | 35 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 33 | 36 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; |
| ... | ... | @@ -203,6 +206,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 203 | 206 | |
| 204 | 207 | @Override |
| 205 | 208 | public CombinationRecordDO getCombinationRecord(Long userId, Long orderId) { |
| 209 | + // TODO puhui999:这里直接获得,不适合调用校验的接口; | |
| 206 | 210 | return validateCombinationRecord(userId, orderId); |
| 207 | 211 | } |
| 208 | 212 | |
| ... | ... | @@ -245,4 +249,10 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 245 | 249 | return recordMapper.selectList(CombinationRecordDO::getHeadId, headId); |
| 246 | 250 | } |
| 247 | 251 | |
| 252 | + @Override | |
| 253 | + public Map<Long, Integer> getCombinationRecordCountMapByActivity(Collection<Long> activityIds, | |
| 254 | + @Nullable Integer status, @Nullable Integer headId) { | |
| 255 | + return recordMapper.selectCombinationRecordCountMapByActivityIdAndStatusAndHeadId(activityIds, status, headId); | |
| 256 | + } | |
| 257 | + | |
| 248 | 258 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCombinationActivityPriceCalculator.java