mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
【功能完善】商城: 完善积分商城装修
This commit is contained in:
parent
dd82f13c03
commit
14d239f2de
@ -1,9 +1,9 @@
|
|||||||
package cn.iocoder.yudao.module.promotion.controller.admin.point;
|
package cn.iocoder.yudao.module.promotion.controller.admin.point;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
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.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
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.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
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.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 积分商城活动")
|
@Tag(name = "管理后台 - 积分商城活动")
|
||||||
@RestController
|
@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(
|
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, List<PointProductDO>> productsMap = convertMultiMap(products, PointProductDO::getActivityId);
|
||||||
Map<Long, ProductSpuRespDTO> spuMap = productSpuApi.getSpusMap(
|
Map<Long, ProductSpuRespDTO> spuMap = productSpuApi.getSpusMap(
|
||||||
convertSet(pageResult.getList(), PointActivityDO::getSpuId));
|
convertSet(activityList, PointActivityDO::getSpuId));
|
||||||
PageResult<PointActivityRespVO> result = BeanUtils.toBean(pageResult, PointActivityRespVO.class);
|
List<PointActivityRespVO> result = BeanUtils.toBean(activityList, PointActivityRespVO.class);
|
||||||
result.getList().forEach(activity -> {
|
result.forEach(activity -> {
|
||||||
// 设置 product 信息
|
// 设置 product 信息
|
||||||
PointProductDO minProduct = getMinPropertyObj(productsMap.get(activity.getId()), PointProductDO::getPoint);
|
PointProductDO minProduct = getMinPropertyObj(productsMap.get(activity.getId()), PointProductDO::getPoint);
|
||||||
assert minProduct != null;
|
assert minProduct != null;
|
||||||
activity.setPoint(minProduct.getPoint()).setPrice(minProduct.getPrice());
|
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()));
|
spu -> activity.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setMarketPrice(spu.getMarketPrice()));
|
||||||
|
|
||||||
});
|
});
|
||||||
return success(result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -102,7 +102,7 @@ public class SeckillActivityController {
|
|||||||
@GetMapping("/list-by-ids")
|
@GetMapping("/list-by-ids")
|
||||||
@Operation(summary = "获得秒杀活动列表,基于活动编号数组")
|
@Operation(summary = "获得秒杀活动列表,基于活动编号数组")
|
||||||
@Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]")
|
@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. 获得开启的活动列表
|
// 1. 获得开启的活动列表
|
||||||
List<SeckillActivityDO> activityList = seckillActivityService.getSeckillActivityListByIds(ids);
|
List<SeckillActivityDO> activityList = seckillActivityService.getSeckillActivityListByIds(ids);
|
||||||
activityList.removeIf(activity -> CommonStatusEnum.isDisable(activity.getStatus()));
|
activityList.removeIf(activity -> CommonStatusEnum.isDisable(activity.getStatus()));
|
||||||
|
@ -79,7 +79,7 @@ public class AppPointActivityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list-by-ids")
|
@GetMapping("/list-by-ids")
|
||||||
@Operation(summary = "获得拼团活动列表,基于活动编号数组")
|
@Operation(summary = "获得积分商城活动列表,基于活动编号数组")
|
||||||
@Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]")
|
@Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]")
|
||||||
public CommonResult<List<AppPointActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) {
|
public CommonResult<List<AppPointActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) {
|
||||||
// 1. 获得开启的活动列表
|
// 1. 获得开启的活动列表
|
||||||
|
@ -151,7 +151,7 @@ public class AppSeckillActivityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/list-by-ids")
|
@GetMapping("/list-by-ids")
|
||||||
@Operation(summary = "获得拼团活动列表,基于活动编号数组")
|
@Operation(summary = "获得秒杀活动列表,基于活动编号数组")
|
||||||
@Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]")
|
@Parameter(name = "ids", description = "活动编号数组", required = true, example = "[1024, 1025]")
|
||||||
public CommonResult<List<AppSeckillActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) {
|
public CommonResult<List<AppSeckillActivityRespVO>> getCombinationActivityListByIds(@RequestParam("ids") List<Long> ids) {
|
||||||
// 1. 获得开启的活动列表
|
// 1. 获得开启的活动列表
|
||||||
|
@ -236,7 +236,7 @@ public class PointActivityServiceImpl implements PointActivityService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PointActivityDO> getPointActivityListByIds(Collection<Long> ids) {
|
public List<PointActivityDO> getPointActivityListByIds(Collection<Long> ids) {
|
||||||
return pointActivityMapper.selectBatchIds(ids);
|
return pointActivityMapper.selectList(PointActivityDO::getId, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -330,7 +330,7 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SeckillActivityDO> getSeckillActivityListByIds(Collection<Long> ids) {
|
public List<SeckillActivityDO> getSeckillActivityListByIds(Collection<Long> ids) {
|
||||||
return seckillActivityMapper.selectBatchIds(ids);
|
return seckillActivityMapper.selectList(SeckillActivityDO::getId, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user