Commit 14d239f2de76186ba75a1d0f43453bf756536987
1 parent
dd82f13c
【功能完善】商城: 完善积分商城装修
Showing
6 changed files
with
33 additions
and
13 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/point/PointActivityController.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.controller.admin.point; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | 8 | import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; |
| 9 | 9 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| ... | ... | @@ -29,6 +29,7 @@ import java.util.Map; |
| 29 | 29 | |
| 30 | 30 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 31 | 31 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; |
| 32 | +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | |
| 32 | 33 | |
| 33 | 34 | @Tag(name = "管理后台 - 积分商城活动") |
| 34 | 35 | @RestController |
| ... | ... | @@ -100,22 +101,41 @@ public class PointActivityController { |
| 100 | 101 | } |
| 101 | 102 | |
| 102 | 103 | // 拼接数据 |
| 104 | + List<PointActivityRespVO> resultList = buildPointActivityRespVOList(pageResult.getList()); | |
| 105 | + return success(new PageResult<>(resultList, pageResult.getTotal())); | |
| 106 | + } | |
| 107 | + | |
| 108 | + @GetMapping("/list-by-ids") | |
| 109 | + @Operation(summary = "获得积分商城活动列表,基于活动编号数组") | |
| 110 | + @Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]") | |
| 111 | + public CommonResult<List<PointActivityRespVO>> getPointActivityListByIds(@RequestParam("ids") List<Long> ids) { | |
| 112 | + // 1. 获得开启的活动列表 | |
| 113 | + List<PointActivityDO> activityList = pointActivityService.getPointActivityListByIds(ids); | |
| 114 | + activityList.removeIf(activity -> CommonStatusEnum.isDisable(activity.getStatus())); | |
| 115 | + if (CollUtil.isEmpty(activityList)) { | |
| 116 | + return success(Collections.emptyList()); | |
| 117 | + } | |
| 118 | + // 2. 拼接返回 | |
| 119 | + List<PointActivityRespVO> result = buildPointActivityRespVOList(activityList); | |
| 120 | + return success(result); | |
| 121 | + } | |
| 122 | + | |
| 123 | + private List<PointActivityRespVO> buildPointActivityRespVOList(List<PointActivityDO> activityList) { | |
| 103 | 124 | List<PointProductDO> products = pointActivityService.getPointProductListByActivityIds( |
| 104 | - convertSet(pageResult.getList(), PointActivityDO::getId)); | |
| 125 | + convertSet(activityList, PointActivityDO::getId)); | |
| 105 | 126 | Map<Long, List<PointProductDO>> productsMap = convertMultiMap(products, PointProductDO::getActivityId); |
| 106 | 127 | Map<Long, ProductSpuRespDTO> spuMap = productSpuApi.getSpusMap( |
| 107 | - convertSet(pageResult.getList(), PointActivityDO::getSpuId)); | |
| 108 | - PageResult<PointActivityRespVO> result = BeanUtils.toBean(pageResult, PointActivityRespVO.class); | |
| 109 | - result.getList().forEach(activity -> { | |
| 128 | + convertSet(activityList, PointActivityDO::getSpuId)); | |
| 129 | + List<PointActivityRespVO> result = BeanUtils.toBean(activityList, PointActivityRespVO.class); | |
| 130 | + result.forEach(activity -> { | |
| 110 | 131 | // 设置 product 信息 |
| 111 | 132 | PointProductDO minProduct = getMinPropertyObj(productsMap.get(activity.getId()), PointProductDO::getPoint); |
| 112 | 133 | assert minProduct != null; |
| 113 | 134 | activity.setPoint(minProduct.getPoint()).setPrice(minProduct.getPrice()); |
| 114 | - MapUtils.findAndThen(spuMap, activity.getSpuId(), | |
| 135 | + findAndThen(spuMap, activity.getSpuId(), | |
| 115 | 136 | spu -> activity.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice())); |
| 116 | - | |
| 117 | 137 | }); |
| 118 | - return success(result); | |
| 138 | + return result; | |
| 119 | 139 | } |
| 120 | 140 | |
| 121 | 141 | } |
| 122 | 142 | \ No newline at end of file | ... | ... |
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 { |
| 102 | 102 | @GetMapping("/list-by-ids") |
| 103 | 103 | @Operation(summary = "获得秒杀活动列表,基于活动编号数组") |
| 104 | 104 | @Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]") |
| 105 | - public CommonResult<List<SeckillActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) { | |
| 105 | + public CommonResult<List<SeckillActivityRespVO>> getSeckillActivityListByIds(@RequestParam("ids") List<Long> ids) { | |
| 106 | 106 | // 1. 获得开启的活动列表 |
| 107 | 107 | List<SeckillActivityDO> activityList = seckillActivityService.getSeckillActivityListByIds(ids); |
| 108 | 108 | activityList.removeIf(activity -> CommonStatusEnum.isDisable(activity.getStatus())); | ... | ... |
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 { |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | @GetMapping("/list-by-ids") |
| 82 | - @Operation(summary = "获得拼团活动列表,基于活动编号数组") | |
| 82 | + @Operation(summary = "获得积分商城活动列表,基于活动编号数组") | |
| 83 | 83 | @Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]") |
| 84 | 84 | public CommonResult<List<AppPointActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) { |
| 85 | 85 | // 1. 获得开启的活动列表 | ... | ... |
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 { |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | @GetMapping("/list-by-ids") |
| 154 | - @Operation(summary = "获得拼团活动列表,基于活动编号数组") | |
| 154 | + @Operation(summary = "获得秒杀活动列表,基于活动编号数组") | |
| 155 | 155 | @Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]") |
| 156 | 156 | public CommonResult<List<AppSeckillActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) { |
| 157 | 157 | // 1. 获得开启的活动列表 | ... | ... |
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 { |
| 236 | 236 | |
| 237 | 237 | @Override |
| 238 | 238 | public List<PointActivityDO> getPointActivityListByIds(Collection<Long> ids) { |
| 239 | - return pointActivityMapper.selectBatchIds(ids); | |
| 239 | + return pointActivityMapper.selectList(PointActivityDO::getId, ids); | |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | @Override | ... | ... |
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 { |
| 330 | 330 | |
| 331 | 331 | @Override |
| 332 | 332 | public List<SeckillActivityDO> getSeckillActivityListByIds(Collection<Long> ids) { |
| 333 | - return seckillActivityMapper.selectBatchIds(ids); | |
| 333 | + return seckillActivityMapper.selectList(SeckillActivityDO::getId, ids); | |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | } | ... | ... |