diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/PointActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/PointActivityController.java index f645e4a41..cd43b2164 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/PointActivityController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/PointActivityController.java @@ -1,9 +1,9 @@ package cn.iocoder.yudao.module.promotion.controller.admin.point; import cn.hutool.core.collection.CollUtil; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; @@ -29,6 +29,7 @@ import java.util.Map; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; @Tag(name = "管理后台 - 积分商城活动") @RestController @@ -100,22 +101,41 @@ public class PointActivityController { } // 拼接数据 + List resultList = buildPointActivityRespVOList(pageResult.getList()); + return success(new PageResult<>(resultList, pageResult.getTotal())); + } + + @GetMapping("/list-by-ids") + @Operation(summary = "获得积分商城活动列表,基于活动编号数组") + @Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]") + public CommonResult> getPointActivityListByIds(@RequestParam("ids") List ids) { + // 1. 获得开启的活动列表 + List activityList = pointActivityService.getPointActivityListByIds(ids); + activityList.removeIf(activity -> CommonStatusEnum.isDisable(activity.getStatus())); + if (CollUtil.isEmpty(activityList)) { + return success(Collections.emptyList()); + } + // 2. 拼接返回 + List result = buildPointActivityRespVOList(activityList); + return success(result); + } + + private List buildPointActivityRespVOList(List activityList) { List products = pointActivityService.getPointProductListByActivityIds( - convertSet(pageResult.getList(), PointActivityDO::getId)); + convertSet(activityList, PointActivityDO::getId)); Map> productsMap = convertMultiMap(products, PointProductDO::getActivityId); Map spuMap = productSpuApi.getSpusMap( - convertSet(pageResult.getList(), PointActivityDO::getSpuId)); - PageResult result = BeanUtils.toBean(pageResult, PointActivityRespVO.class); - result.getList().forEach(activity -> { + convertSet(activityList, PointActivityDO::getSpuId)); + List result = BeanUtils.toBean(activityList, PointActivityRespVO.class); + result.forEach(activity -> { // 设置 product 信息 PointProductDO minProduct = getMinPropertyObj(productsMap.get(activity.getId()), PointProductDO::getPoint); assert minProduct != null; activity.setPoint(minProduct.getPoint()).setPrice(minProduct.getPrice()); - MapUtils.findAndThen(spuMap, activity.getSpuId(), + findAndThen(spuMap, activity.getSpuId(), spu -> activity.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); - }); - return success(result); + return result; } } \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java index de90c0977..349624c57 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillActivityController.java @@ -102,7 +102,7 @@ public class SeckillActivityController { @GetMapping("/list-by-ids") @Operation(summary = "获得秒杀活动列表,基于活动编号数组") @Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]") - public CommonResult> getCombinationActivityListByIds(@RequestParam("ids") List ids) { + public CommonResult> getSeckillActivityListByIds(@RequestParam("ids") List ids) { // 1. 获得开启的活动列表 List activityList = seckillActivityService.getSeckillActivityListByIds(ids); activityList.removeIf(activity -> CommonStatusEnum.isDisable(activity.getStatus())); diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/AppPointActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/AppPointActivityController.java index 997ab563f..20cc8b6c3 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/AppPointActivityController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/point/AppPointActivityController.java @@ -79,7 +79,7 @@ public class AppPointActivityController { } @GetMapping("/list-by-ids") - @Operation(summary = "获得拼团活动列表,基于活动编号数组") + @Operation(summary = "获得积分商城活动列表,基于活动编号数组") @Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]") public CommonResult> getCombinationActivityListByIds(@RequestParam("ids") List ids) { // 1. 获得开启的活动列表 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java index 6105f9516..93820551d 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java @@ -151,7 +151,7 @@ public class AppSeckillActivityController { } @GetMapping("/list-by-ids") - @Operation(summary = "获得拼团活动列表,基于活动编号数组") + @Operation(summary = "获得秒杀活动列表,基于活动编号数组") @Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]") public CommonResult> getCombinationActivityListByIds(@RequestParam("ids") List ids) { // 1. 获得开启的活动列表 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/point/PointActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/point/PointActivityServiceImpl.java index cefb4a150..bfce27e1c 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/point/PointActivityServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/point/PointActivityServiceImpl.java @@ -236,7 +236,7 @@ public class PointActivityServiceImpl implements PointActivityService { @Override public List getPointActivityListByIds(Collection ids) { - return pointActivityMapper.selectBatchIds(ids); + return pointActivityMapper.selectList(PointActivityDO::getId, ids); } @Override diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java index bdb199455..3b7ab3d64 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java @@ -330,7 +330,7 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { @Override public List getSeckillActivityListByIds(Collection ids) { - return seckillActivityMapper.selectBatchIds(ids); + return seckillActivityMapper.selectList(SeckillActivityDO::getId, ids); } }