Commit 1d2a6ad065a5459a4321a51c13dc316b6ebd8d5f
1 parent
04a391cd
拼团活动: 完善 app 端获取活动分页、列表、详情接口
Showing
9 changed files
with
139 additions
and
95 deletions
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
| ... | ... | @@ -56,7 +56,7 @@ public interface ErrorCodeConstants { |
| 56 | 56 | ErrorCode SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013008004, "秒杀活动未关闭或未结束,不能删除"); |
| 57 | 57 | ErrorCode SECKILL_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1013008005, "秒杀活动已关闭,不能重复关闭"); |
| 58 | 58 | ErrorCode SECKILL_ACTIVITY_UPDATE_STOCK_FAIL = new ErrorCode(1013008006, "秒杀失败,原因秒杀库存不足"); |
| 59 | - ErrorCode SECKILL_ACTIVITY_FAIL_STATUS_CLOSED = new ErrorCode(1013008007, "秒杀活动已关闭"); | |
| 59 | + ErrorCode SECKILL_ACTIVITY_APP_STATUS_CLOSED = new ErrorCode(1013008007, "秒杀活动已关闭"); | |
| 60 | 60 | |
| 61 | 61 | // ========== 秒杀时段 1013009000 ========== |
| 62 | 62 | ErrorCode SECKILL_CONFIG_NOT_EXISTS = new ErrorCode(1013009000, "秒杀时段不存在"); |
| ... | ... | @@ -69,6 +69,7 @@ public interface ErrorCodeConstants { |
| 69 | 69 | ErrorCode COMBINATION_ACTIVITY_STATUS_DISABLE_NOT_UPDATE = new ErrorCode(1013010002, "拼团活动已关闭不能修改"); |
| 70 | 70 | ErrorCode COMBINATION_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END = new ErrorCode(1013010003, "拼团活动未关闭或未结束,不能删除"); |
| 71 | 71 | ErrorCode COMBINATION_ACTIVITY_STATUS_DISABLE = new ErrorCode(1013010004, "拼团失败,原因:拼团活动已关闭"); |
| 72 | + ErrorCode COMBINATION_ACTIVITY_APP_STATUS_DISABLE = new ErrorCode(1013010005, "拼团活动已关闭"); | |
| 72 | 73 | |
| 73 | 74 | // ========== 拼团记录 1013011000 ========== |
| 74 | 75 | ErrorCode COMBINATION_RECORD_NOT_EXISTS = new ErrorCode(1013011000, "拼团不存在"); | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/AppCombinationActivityController.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.controller.app.combination; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 4 | +import cn.hutool.core.util.ObjectUtil; | |
| 5 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 3 | 6 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 5 | 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 9 | +import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; | |
| 10 | +import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; | |
| 6 | 11 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO; |
| 7 | 12 | import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO; |
| 13 | +import cn.iocoder.yudao.module.promotion.convert.combination.CombinationActivityConvert; | |
| 14 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; | |
| 15 | +import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; | |
| 16 | +import cn.iocoder.yudao.module.promotion.service.combination.CombinationActivityService; | |
| 8 | 17 | import io.swagger.v3.oas.annotations.Operation; |
| 9 | 18 | import io.swagger.v3.oas.annotations.Parameter; |
| 10 | 19 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -14,11 +23,14 @@ import org.springframework.web.bind.annotation.RequestMapping; |
| 14 | 23 | import org.springframework.web.bind.annotation.RequestParam; |
| 15 | 24 | import org.springframework.web.bind.annotation.RestController; |
| 16 | 25 | |
| 17 | -import java.time.LocalDateTime; | |
| 18 | -import java.util.ArrayList; | |
| 26 | +import javax.annotation.Resource; | |
| 27 | +import java.util.Arrays; | |
| 19 | 28 | import java.util.List; |
| 20 | 29 | |
| 30 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 21 | 31 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 32 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | |
| 33 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COMBINATION_ACTIVITY_APP_STATUS_DISABLE; | |
| 22 | 34 | |
| 23 | 35 | @Tag(name = "用户 APP - 拼团活动") |
| 24 | 36 | @RestController |
| ... | ... | @@ -26,104 +38,55 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 26 | 38 | @Validated |
| 27 | 39 | public class AppCombinationActivityController { |
| 28 | 40 | |
| 41 | + @Resource | |
| 42 | + private CombinationActivityService activityService; | |
| 43 | + @Resource | |
| 44 | + private ProductSpuApi spuApi; | |
| 45 | + | |
| 46 | + | |
| 29 | 47 | @GetMapping("/list") |
| 30 | 48 | @Operation(summary = "获得拼团活动列表", description = "用于小程序首页") |
| 31 | - // TODO 芋艿:增加 Spring Cache | |
| 32 | - // TODO 芋艿:缺少 swagger 注解 | |
| 49 | + @Parameter(name = "count", description = "需要展示的数量", example = "6") | |
| 33 | 50 | public CommonResult<List<AppCombinationActivityRespVO>> getCombinationActivityList( |
| 34 | 51 | @RequestParam(name = "count", defaultValue = "6") Integer count) { |
| 35 | - List<AppCombinationActivityRespVO> activityList = new ArrayList<>(); | |
| 36 | - AppCombinationActivityRespVO activity1 = new AppCombinationActivityRespVO(); | |
| 37 | - activity1.setId(1L); | |
| 38 | - activity1.setName("618 大拼团"); | |
| 39 | - activity1.setUserSize(3); | |
| 40 | - activity1.setSpuId(2048L); | |
| 41 | - activity1.setPicUrl("https://static.iocoder.cn/mall/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg"); | |
| 42 | - activity1.setMarketPrice(50); | |
| 43 | - activity1.setCombinationPrice(100); | |
| 44 | - activityList.add(activity1); | |
| 52 | + List<CombinationActivityDO> list = activityService.getCombinationActivityAppList(count); | |
| 53 | + if (CollUtil.isEmpty(list)) { | |
| 54 | + return success(CombinationActivityConvert.INSTANCE.convertAppList(list)); | |
| 55 | + } | |
| 45 | 56 | |
| 46 | - AppCombinationActivityRespVO activity2 = new AppCombinationActivityRespVO(); | |
| 47 | - activity2.setId(2L); | |
| 48 | - activity2.setName("双十一拼团"); | |
| 49 | - activity2.setUserSize(5); | |
| 50 | - activity2.setSpuId(4096L); | |
| 51 | - activity2.setPicUrl("https://static.iocoder.cn/mall/132.jpeg"); | |
| 52 | - activity2.setMarketPrice(100); | |
| 53 | - activity2.setCombinationPrice(200); | |
| 54 | - activityList.add(activity2); | |
| 55 | - | |
| 56 | - return success(activityList); | |
| 57 | + List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(list, CombinationActivityDO::getSpuId)); | |
| 58 | + // TODO 芋艿:增加 Spring Cache | |
| 59 | + return success(CombinationActivityConvert.INSTANCE.convertAppList(list, spuList)); | |
| 57 | 60 | } |
| 58 | 61 | |
| 59 | 62 | @GetMapping("/page") |
| 60 | 63 | @Operation(summary = "获得拼团活动分页") |
| 61 | 64 | public CommonResult<PageResult<AppCombinationActivityRespVO>> getCombinationActivityPage(PageParam pageParam) { |
| 62 | - List<AppCombinationActivityRespVO> activityList = new ArrayList<>(); | |
| 63 | - AppCombinationActivityRespVO activity1 = new AppCombinationActivityRespVO(); | |
| 64 | - activity1.setId(1L); | |
| 65 | - activity1.setName("618 大拼团"); | |
| 66 | - activity1.setUserSize(3); | |
| 67 | - activity1.setSpuId(2048L); | |
| 68 | - activity1.setPicUrl("商品图片地址"); | |
| 69 | - activity1.setMarketPrice(50); | |
| 70 | - activity1.setCombinationPrice(100); | |
| 71 | - activityList.add(activity1); | |
| 72 | - | |
| 73 | - AppCombinationActivityRespVO activity2 = new AppCombinationActivityRespVO(); | |
| 74 | - activity2.setId(2L); | |
| 75 | - activity2.setName("双十一拼团"); | |
| 76 | - activity2.setUserSize(5); | |
| 77 | - activity2.setSpuId(4096L); | |
| 78 | - activity2.setPicUrl("商品图片地址"); | |
| 79 | - activity2.setMarketPrice(100); | |
| 80 | - activity2.setCombinationPrice(200); | |
| 81 | - activityList.add(activity2); | |
| 65 | + PageResult<CombinationActivityDO> result = activityService.getCombinationActivityAppPage(pageParam); | |
| 66 | + if (CollUtil.isEmpty(result.getList())) { | |
| 67 | + return success(PageResult.empty(result.getTotal())); | |
| 68 | + } | |
| 82 | 69 | |
| 83 | - return success(new PageResult<>(activityList, 2L)); | |
| 70 | + List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(result.getList(), CombinationActivityDO::getSpuId)); | |
| 71 | + return success(CombinationActivityConvert.INSTANCE.convertAppPage(result, spuList)); | |
| 84 | 72 | } |
| 85 | 73 | |
| 86 | 74 | @GetMapping("/get-detail") |
| 87 | 75 | @Operation(summary = "获得拼团活动明细") |
| 88 | 76 | @Parameter(name = "id", description = "活动编号", required = true, example = "1024") |
| 89 | 77 | public CommonResult<AppCombinationActivityDetailRespVO> getCombinationActivityDetail(@RequestParam("id") Long id) { |
| 90 | - // TODO 芋艿:如果禁用的时候,需要抛出异常; | |
| 91 | - AppCombinationActivityDetailRespVO obj = new AppCombinationActivityDetailRespVO(); | |
| 92 | - // 设置其属性的值 | |
| 93 | - obj.setId(id); | |
| 94 | - obj.setName("晚九点限时秒杀"); | |
| 95 | - obj.setStatus(1); | |
| 96 | - obj.setStartTime(LocalDateTime.of(2023, 6, 15, 0, 0, 0)); | |
| 97 | - obj.setEndTime(LocalDateTime.of(2023, 6, 20, 23, 59, 0)); | |
| 98 | - obj.setUserSize(2); | |
| 99 | - obj.setSuccessCount(100); | |
| 100 | - obj.setSpuId(633L); | |
| 101 | - obj.setSingleLimitCount(2); | |
| 102 | - obj.setTotalLimitCount(3); | |
| 78 | + // 1、获取活动 | |
| 79 | + CombinationActivityDO combinationActivity = activityService.getCombinationActivity(id); | |
| 80 | + if (combinationActivity == null) { | |
| 81 | + return success(null); | |
| 82 | + } | |
| 83 | + if (ObjectUtil.equal(combinationActivity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { | |
| 84 | + throw exception(COMBINATION_ACTIVITY_APP_STATUS_DISABLE); | |
| 85 | + } | |
| 103 | 86 | |
| 104 | - // 创建一个Product对象的列表 | |
| 105 | - List<AppCombinationActivityDetailRespVO.Product> productList = new ArrayList<>(); | |
| 106 | - // 创建三个新的Product对象并设置其属性的值 | |
| 107 | - AppCombinationActivityDetailRespVO.Product product1 = new AppCombinationActivityDetailRespVO.Product(); | |
| 108 | - product1.setSkuId(1L); | |
| 109 | - product1.setCombinationPrice(100); | |
| 110 | - // 将第一个Product对象添加到列表中 | |
| 111 | - productList.add(product1); | |
| 112 | - // 创建第二个Product对象并设置其属性的值 | |
| 113 | - AppCombinationActivityDetailRespVO.Product product2 = new AppCombinationActivityDetailRespVO.Product(); | |
| 114 | - product2.setSkuId(2L); | |
| 115 | - product2.setCombinationPrice(200); | |
| 116 | - // 将第二个Product对象添加到列表中 | |
| 117 | - productList.add(product2); | |
| 118 | - // 创建第三个Product对象并设置其属性的值 | |
| 119 | - AppCombinationActivityDetailRespVO.Product product3 = new AppCombinationActivityDetailRespVO.Product(); | |
| 120 | - product3.setSkuId(3L); | |
| 121 | - product3.setCombinationPrice(300); | |
| 122 | - // 将第三个Product对象添加到列表中 | |
| 123 | - productList.add(product3); | |
| 124 | - // 将Product列表设置为对象的属性值 | |
| 125 | - obj.setProducts(productList); | |
| 126 | - return success(obj); | |
| 87 | + // 2、获取活动商品 | |
| 88 | + List<CombinationProductDO> products = activityService.getCombinationProductsByActivityIds(Arrays.asList(combinationActivity.getId())); | |
| 89 | + return success(CombinationActivityConvert.INSTANCE.convert3(combinationActivity, products)); | |
| 127 | 90 | } |
| 128 | 91 | |
| 129 | 92 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/combination/vo/activity/AppCombinationActivityRespVO.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java
| ... | ... | @@ -4,7 +4,6 @@ import cn.hutool.core.util.ObjectUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 8 | 7 | import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; |
| 9 | 8 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 10 | 9 | import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppSeckillActivityDetailRespVO; |
| ... | ... | @@ -33,10 +32,9 @@ import java.util.List; |
| 33 | 32 | |
| 34 | 33 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 35 | 34 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 36 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList; | |
| 37 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.findFirst; | |
| 35 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | |
| 38 | 36 | import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.isBetween; |
| 39 | -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.SECKILL_ACTIVITY_FAIL_STATUS_CLOSED; | |
| 37 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.SECKILL_ACTIVITY_APP_STATUS_CLOSED; | |
| 40 | 38 | |
| 41 | 39 | @Tag(name = "用户 App - 秒杀活动") |
| 42 | 40 | @RestController |
| ... | ... | @@ -53,8 +51,7 @@ public class AppSeckillActivityController { |
| 53 | 51 | private ProductSpuApi spuApi; |
| 54 | 52 | |
| 55 | 53 | @GetMapping("/get-now") |
| 56 | - @Operation(summary = "获得当前秒杀活动") // 提供给首页使用 | |
| 57 | - // TODO 芋艿:需要增加 spring cache | |
| 54 | + @Operation(summary = "获得当前秒杀活动", description = "获取当前正在进行的活动,提供给首页使用") | |
| 58 | 55 | public CommonResult<AppSeckillActivityNowRespVO> getNowSeckillActivity() { |
| 59 | 56 | // 1、获取当前时间处在哪个秒杀阶段 |
| 60 | 57 | List<SeckillConfigDO> configList = configService.getSeckillConfigList(); |
| ... | ... | @@ -69,7 +66,8 @@ public class AppSeckillActivityController { |
| 69 | 66 | List<SeckillActivityDO> activityList = activityService.getSeckillActivityListByConfigIds(Arrays.asList(filteredConfig.getId())); |
| 70 | 67 | List<SeckillActivityDO> filteredList = filterList(activityList, item -> ObjectUtil.equal(item.getStatus(), CommonStatusEnum.ENABLE.getStatus())); |
| 71 | 68 | // 2、1 获取 spu 信息 |
| 72 | - List<ProductSpuRespDTO> spuList = spuApi.getSpuList(CollectionUtils.convertList(filteredList, SeckillActivityDO::getSpuId)); | |
| 69 | + List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(filteredList, SeckillActivityDO::getSpuId)); | |
| 70 | + // TODO 芋艿:需要增加 spring cache | |
| 73 | 71 | return success(SeckillActivityConvert.INSTANCE.convert(filteredConfig, filteredList, spuList)); |
| 74 | 72 | } |
| 75 | 73 | |
| ... | ... | @@ -79,7 +77,7 @@ public class AppSeckillActivityController { |
| 79 | 77 | // 1、查询满足当前阶段的活动 |
| 80 | 78 | PageResult<SeckillActivityDO> pageResult = activityService.getSeckillActivityAppPageByConfigId(pageReqVO); |
| 81 | 79 | // 1、1 获取 spu 信息 |
| 82 | - List<ProductSpuRespDTO> spuList = spuApi.getSpuList(CollectionUtils.convertList(pageResult.getList(), SeckillActivityDO::getSpuId)); | |
| 80 | + List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(pageResult.getList(), SeckillActivityDO::getSpuId)); | |
| 83 | 81 | return success(SeckillActivityConvert.INSTANCE.convertPage(pageResult, spuList)); |
| 84 | 82 | } |
| 85 | 83 | |
| ... | ... | @@ -101,9 +99,8 @@ public class AppSeckillActivityController { |
| 101 | 99 | if (seckillActivity == null) { |
| 102 | 100 | return success(null); |
| 103 | 101 | } |
| 104 | - // TODO 芋艿:如果禁用的时候,需要抛出异常; | |
| 105 | 102 | if (ObjectUtil.equal(seckillActivity.getStatus(), CommonStatusEnum.DISABLE.getStatus())) { |
| 106 | - throw exception(SECKILL_ACTIVITY_FAIL_STATUS_CLOSED); | |
| 103 | + throw exception(SECKILL_ACTIVITY_APP_STATUS_CLOSED); | |
| 107 | 104 | } |
| 108 | 105 | |
| 109 | 106 | // 3、获取活动商品 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java
| ... | ... | @@ -13,6 +13,8 @@ import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activit |
| 13 | 13 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityUpdateReqVO; |
| 14 | 14 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductBaseVO; |
| 15 | 15 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.product.CombinationProductRespVO; |
| 16 | +import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityDetailRespVO; | |
| 17 | +import cn.iocoder.yudao.module.promotion.controller.app.combination.vo.activity.AppCombinationActivityRespVO; | |
| 16 | 18 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationActivityDO; |
| 17 | 19 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationProductDO; |
| 18 | 20 | import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO; |
| ... | ... | @@ -25,6 +27,7 @@ import java.util.List; |
| 25 | 27 | import java.util.Map; |
| 26 | 28 | |
| 27 | 29 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; |
| 30 | +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; | |
| 28 | 31 | |
| 29 | 32 | /** |
| 30 | 33 | * 拼团活动 Convert |
| ... | ... | @@ -109,4 +112,44 @@ public interface CombinationActivityConvert { |
| 109 | 112 | |
| 110 | 113 | List<CombinationRecordRespDTO> convert(List<CombinationRecordDO> bean); |
| 111 | 114 | |
| 115 | + List<AppCombinationActivityRespVO> convertAppList(List<CombinationActivityDO> list); | |
| 116 | + | |
| 117 | + default List<AppCombinationActivityRespVO> convertAppList(List<CombinationActivityDO> list, List<ProductSpuRespDTO> spuList) { | |
| 118 | + List<AppCombinationActivityRespVO> activityList = convertAppList(list); | |
| 119 | + Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId); | |
| 120 | + return CollectionUtils.convertList(activityList, item -> { | |
| 121 | + findAndThen(spuMap, item.getSpuId(), spu -> { | |
| 122 | + item.setPicUrl(spu.getPicUrl()); | |
| 123 | + item.setMarketPrice(spu.getMarketPrice()); | |
| 124 | + }); | |
| 125 | + return item; | |
| 126 | + }); | |
| 127 | + } | |
| 128 | + | |
| 129 | + PageResult<AppCombinationActivityRespVO> convertAppPage(PageResult<CombinationActivityDO> result); | |
| 130 | + | |
| 131 | + default PageResult<AppCombinationActivityRespVO> convertAppPage(PageResult<CombinationActivityDO> result, List<ProductSpuRespDTO> spuList) { | |
| 132 | + PageResult<AppCombinationActivityRespVO> appPage = convertAppPage(result); | |
| 133 | + Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId); | |
| 134 | + List<AppCombinationActivityRespVO> list = CollectionUtils.convertList(appPage.getList(), item -> { | |
| 135 | + findAndThen(spuMap, item.getSpuId(), spu -> { | |
| 136 | + item.setPicUrl(spu.getPicUrl()); | |
| 137 | + item.setMarketPrice(spu.getMarketPrice()); | |
| 138 | + }); | |
| 139 | + return item; | |
| 140 | + }); | |
| 141 | + appPage.setList(list); | |
| 142 | + return appPage; | |
| 143 | + } | |
| 144 | + | |
| 145 | + AppCombinationActivityDetailRespVO convert2(CombinationActivityDO combinationActivity); | |
| 146 | + | |
| 147 | + List<AppCombinationActivityDetailRespVO.Product> convertList1(List<CombinationProductDO> products); | |
| 148 | + | |
| 149 | + default AppCombinationActivityDetailRespVO convert3(CombinationActivityDO combinationActivity, List<CombinationProductDO> products) { | |
| 150 | + AppCombinationActivityDetailRespVO detailRespVO = convert2(combinationActivity); | |
| 151 | + detailRespVO.setProducts(convertList1(products)); | |
| 152 | + return detailRespVO; | |
| 153 | + } | |
| 154 | + | |
| 112 | 155 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.dal.mysql.combination; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| ... | ... | @@ -28,4 +29,9 @@ public interface CombinationActivityMapper extends BaseMapperX<CombinationActivi |
| 28 | 29 | return selectList(CombinationActivityDO::getStatus, status); |
| 29 | 30 | } |
| 30 | 31 | |
| 32 | + default PageResult<CombinationActivityDO> selectAppPage(PageParam pageParam, Integer status) { | |
| 33 | + return selectPage(pageParam, new LambdaQueryWrapperX<CombinationActivityDO>() | |
| 34 | + .eq(CombinationActivityDO::getStatus, status)); | |
| 35 | + } | |
| 36 | + | |
| 31 | 37 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.service.combination; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityCreateReqVO; |
| 5 | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.combination.vo.activity.CombinationActivityPageReqVO; |
| ... | ... | @@ -82,4 +83,20 @@ public interface CombinationActivityService { |
| 82 | 83 | */ |
| 83 | 84 | void validateCombination(Long activityId, Long userId, Long skuId, Integer count); |
| 84 | 85 | |
| 86 | + /** | |
| 87 | + * 获取 APP 端活动展示数据 | |
| 88 | + * | |
| 89 | + * @param count 需要的数量 | |
| 90 | + * @return 活动列表 | |
| 91 | + */ | |
| 92 | + List<CombinationActivityDO> getCombinationActivityAppList(Integer count); | |
| 93 | + | |
| 94 | + /** | |
| 95 | + * 获取 APP 端活动分页数据 | |
| 96 | + * | |
| 97 | + * @param pageParam 分页参数 | |
| 98 | + * @return 活动分页数据 | |
| 99 | + */ | |
| 100 | + PageResult<CombinationActivityDO> getCombinationActivityAppPage(PageParam pageParam); | |
| 101 | + | |
| 85 | 102 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java
| ... | ... | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.promotion.service.combination; |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.util.ObjectUtil; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 6 | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 8 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 8 | 9 | import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; |
| ... | ... | @@ -245,4 +246,20 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic |
| 245 | 246 | |
| 246 | 247 | } |
| 247 | 248 | |
| 249 | + @Override | |
| 250 | + public List<CombinationActivityDO> getCombinationActivityAppList(Integer count) { | |
| 251 | + if (count == null) { | |
| 252 | + count = 6; | |
| 253 | + } | |
| 254 | + | |
| 255 | + PageResult<CombinationActivityDO> result = combinationActivityMapper.selectAppPage(new PageParam().setPageSize(count), | |
| 256 | + CommonStatusEnum.ENABLE.getStatus()); | |
| 257 | + return result.getList(); | |
| 258 | + } | |
| 259 | + | |
| 260 | + @Override | |
| 261 | + public PageResult<CombinationActivityDO> getCombinationActivityAppPage(PageParam pageParam) { | |
| 262 | + return combinationActivityMapper.selectAppPage(pageParam, CommonStatusEnum.ENABLE.getStatus()); | |
| 263 | + } | |
| 264 | + | |
| 248 | 265 | } | ... | ... |