From 074278c9bd5769d76bfc61fb97554dd71a448384 Mon Sep 17 00:00:00 2001 From: sonjinyon <2476687577@qq.com> Date: Tue, 29 Oct 2024 18:36:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E5=95=86=E5=93=81=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/spu/AppProductSpuController.java | 21 ++++++++++++- .../service/spu/ProductSpuService.java | 4 +++ .../service/spu/ProductSpuServiceImpl.java | 31 +++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java index c0959f5..d48bfe7 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java @@ -201,4 +201,23 @@ public class AppProductSpuController { return pageResult; } // TODO 芋艿:商品的浏览记录; -} + + + @GetMapping("/getActivityGoods") + public CommonResult> getActivityGoods(String activityType) { + List list = productSpuService.getActivityGoods(activityType); + if (CollUtil.isEmpty(list)) { + return success(Collections.emptyList()); + } + + // 拼接返回 + list.forEach(spu -> spu.setSalesCount(spu.getSalesCount() + spu.getVirtualSalesCount())); + List voList = BeanUtils.toBean(list, AppProductSpuRespVO.class); + // 处理 vip 价格 + MemberLevelRespDTO memberLevel = getMemberLevel(); + voList.forEach(vo -> vo.setVipPrice(calculateVipPrice(vo.getPrice(), memberLevel))); + return success(voList); + } + + +} \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java index 635091d..f97e3b6 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReq import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRecommendPageReqVo; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRespVO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import org.springframework.scheduling.annotation.Async; @@ -138,4 +139,7 @@ public interface ProductSpuService { * @return */ List getRecommendProductIdList(AppProductSpuRecommendPageReqVo pageVo); + + + List getActivityGoods(String activityType); } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java index 64ed2eb..abf31c5 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java @@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuSaveReq import cn.iocoder.yudao.module.product.controller.admin.spu.vo.ProductSpuUpdateStatusReqVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRecommendPageReqVo; +import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuRespVO; import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; @@ -22,6 +23,7 @@ import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.google.common.collect.Maps; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -194,6 +196,8 @@ public class ProductSpuServiceImpl implements ProductSpuService { return productSpuMapper.selectList(wrapperX); } + + @Override @Transactional(rollbackFor = Exception.class) public void deleteSpu(Long id) { @@ -308,4 +312,31 @@ public class ProductSpuServiceImpl implements ProductSpuService { return productSpuMapper.selectCount(ProductSpuDO::getCategoryId, categoryId); } + + @Override + public List getActivityGoods(String activityType) { + + String activity = ""; + if (activityType.equals("recommendHot")){ + activity = "recommend_hot"; + } + if (activityType.equals("recommendBenefit")){ + activity = "recommend_benefit"; + } + if (activityType.equals("recommendBest")){ + activity = "recommend_best"; + } + if (activityType.equals("recommendNew")){ + activity = "recommend_new"; + } + if (activityType.equals("recommendGood")){ + activity = "recommend_good"; + } + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(activity,1).eq("status",1); + + return productSpuMapper.selectList(queryWrapper); + } + }