【功能完善】商城: 完善积分商城装修

This commit is contained in:
puhui999 2024-09-28 13:44:04 +08:00
parent dd82f13c03
commit 14d239f2de
6 changed files with 33 additions and 13 deletions

View File

@ -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<PointActivityRespVO> 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<List<PointActivityRespVO>> getPointActivityListByIds(@RequestParam("ids") List<Long> ids) {
// 1. 获得开启的活动列表
List<PointActivityDO> activityList = pointActivityService.getPointActivityListByIds(ids);
activityList.removeIf(activity -> CommonStatusEnum.isDisable(activity.getStatus()));
if (CollUtil.isEmpty(activityList)) {
return success(Collections.emptyList());
}
// 2. 拼接返回
List<PointActivityRespVO> result = buildPointActivityRespVOList(activityList);
return success(result);
}
private List<PointActivityRespVO> buildPointActivityRespVOList(List<PointActivityDO> activityList) {
List<PointProductDO> products = pointActivityService.getPointProductListByActivityIds(
convertSet(pageResult.getList(), PointActivityDO::getId));
convertSet(activityList, PointActivityDO::getId));
Map<Long, List<PointProductDO>> productsMap = convertMultiMap(products, PointProductDO::getActivityId);
Map<Long, ProductSpuRespDTO> spuMap = productSpuApi.getSpusMap(
convertSet(pageResult.getList(), PointActivityDO::getSpuId));
PageResult<PointActivityRespVO> result = BeanUtils.toBean(pageResult, PointActivityRespVO.class);
result.getList().forEach(activity -> {
convertSet(activityList, PointActivityDO::getSpuId));
List<PointActivityRespVO> 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;
}
}

View File

@ -102,7 +102,7 @@ public class SeckillActivityController {
@GetMapping("/list-by-ids")
@Operation(summary = "获得秒杀活动列表,基于活动编号数组")
@Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]")
public CommonResult<List<SeckillActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) {
public CommonResult<List<SeckillActivityRespVO>> getSeckillActivityListByIds(@RequestParam("ids") List<Long> ids) {
// 1. 获得开启的活动列表
List<SeckillActivityDO> activityList = seckillActivityService.getSeckillActivityListByIds(ids);
activityList.removeIf(activity -> CommonStatusEnum.isDisable(activity.getStatus()));

View File

@ -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<List<AppPointActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) {
// 1. 获得开启的活动列表

View File

@ -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<List<AppSeckillActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) {
// 1. 获得开启的活动列表

View File

@ -236,7 +236,7 @@ public class PointActivityServiceImpl implements PointActivityService {
@Override
public List<PointActivityDO> getPointActivityListByIds(Collection<Long> ids) {
return pointActivityMapper.selectBatchIds(ids);
return pointActivityMapper.selectList(PointActivityDO::getId, ids);
}
@Override

View File

@ -330,7 +330,7 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
@Override
public List<SeckillActivityDO> getSeckillActivityListByIds(Collection<Long> ids) {
return seckillActivityMapper.selectBatchIds(ids);
return seckillActivityMapper.selectList(SeckillActivityDO::getId, ids);
}
}