From 57407a39d22b38b9e6631a7d061c65c92db575ca Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 9 Oct 2023 16:18:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=90=A5=E9=94=80=E6=B4=BB=E5=8A=A8=EF=BC=9A?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20selectListBySpuIdsAndStatus=20=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=20sql=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/activity/AppActivityController.http | 5 +++++ .../dal/mysql/bargain/BargainActivityMapper.java | 16 +++++++++++----- .../combination/CombinationActivityMapper.java | 16 +++++++++++----- .../seckillactivity/SeckillActivityMapper.java | 16 +++++++++++----- .../bargain/BargainActivityServiceImpl.java | 2 +- .../CombinationActivityServiceImpl.java | 2 +- .../seckill/SeckillActivityServiceImpl.java | 2 +- 7 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.http diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.http b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.http new file mode 100644 index 000000000..0dda88c7d --- /dev/null +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/activity/AppActivityController.http @@ -0,0 +1,5 @@ +### /promotion/activity/list-by-spu-ids 获得多个商品,近期参与的每个活动 +GET {{appApi}}/promotion/activity/list-by-spu-ids?spuIds=222&spuIds=633 +Authorization: Bearer {{appToken}} +Content-Type: application/json +tenant-id: {{appTenentId}} diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java index d12056d56..bfaed212e 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.activity.Ba import cn.iocoder.yudao.module.promotion.dal.dataobject.bargain.BargainActivityDO; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import java.time.LocalDateTime; @@ -87,6 +88,7 @@ public interface BargainActivityMapper extends BaseMapperX { // TODO @puhui999:一个商品,在统一时间,不会参与多个活动;so 是不是不用 inner join 哈? // PS:如果可以参与多个,其实可以这样写 select * from promotion_bargain_activity group by spu_id ORDER BY create_time DESC;通过 group 来过滤 + /** * 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录 * @@ -94,16 +96,20 @@ public interface BargainActivityMapper extends BaseMapperX { * @param status 状态 * @return 砍价活动列表 */ - @Select("SELECT p1.* " + + @Select("") + List selectListBySpuIdsAndStatus(@Param("spuIds") Collection spuIds, @Param("status") Integer status); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java index 1af92b538..14dfcb395 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/combination/CombinationActivityMapper.java @@ -44,6 +44,7 @@ public interface CombinationActivityMapper extends BaseMapperX " + "SELECT p1.* " + "FROM promotion_combination_activity p1 " + "INNER JOIN ( " + - " SELECT spu_id, MAX(DISTINCT(create_time)) AS max_create_time " + + " SELECT spu_id, MAX(DISTINCT create_time) AS max_create_time " + " FROM promotion_combination_activity " + - " WHERE spu_id IN #{spuIds} " + + " WHERE spu_id IN " + + "" + + " #{spuId}" + + "" + " GROUP BY spu_id " + ") p2 " + "ON p1.spu_id = p2.spu_id AND p1.create_time = p2.max_create_time AND p1.status = #{status} " + - "ORDER BY p1.create_time DESC;") - List selectListBySpuIds(@Param("spuIds") Collection spuIds, @Param("status") Integer status); + "ORDER BY p1.create_time DESC;" + + " ") + List selectListBySpuIdsAndStatus(@Param("spuIds") Collection spuIds, @Param("status") Integer status); + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java index b3b75d36b..b82e4e3d5 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java @@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.promotion.controller.app.seckill.vo.activity.AppS import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.SeckillActivityDO; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import java.util.Collection; @@ -59,6 +60,7 @@ public interface SeckillActivityMapper extends BaseMapperX { } // TODO @puhui999:类似 BargainActivityMapper + /** * 获取指定 spu 编号最近参加的活动,每个 spuId 只返回一条记录 * @@ -66,16 +68,20 @@ public interface SeckillActivityMapper extends BaseMapperX { * @param status 状态 * @return 秒杀活动列表 */ - @Select("SELECT p1.* " + + @Select("") + List selectListBySpuIdsAndStatus(@Param("spuIds") Collection spuIds, @Param("status") Integer status); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java index 0905a09a7..5cf387956 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java @@ -178,7 +178,7 @@ public class BargainActivityServiceImpl implements BargainActivityService { @Override public List getBargainActivityBySpuIdsAndStatus(Collection spuIds, Integer status) { - return bargainActivityMapper.selectListBySpuIds(spuIds, status); + return bargainActivityMapper.selectListBySpuIdsAndStatus(spuIds, status); } } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java index db907ba36..c488bdc03 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java @@ -228,7 +228,7 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic @Override public List getCombinationActivityBySpuIdsAndStatus(Collection spuIds, Integer status) { - return combinationActivityMapper.selectListBySpuIds(spuIds, status); + return combinationActivityMapper.selectListBySpuIdsAndStatus(spuIds, status); } } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java index d2bbc7466..425610a50 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/SeckillActivityServiceImpl.java @@ -312,7 +312,7 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { @Override public List getSeckillActivityBySpuIdsAndStatus(Collection spuIds, Integer status) { - return seckillActivityMapper.selectListBySpuIds(spuIds, status); + return seckillActivityMapper.selectListBySpuIdsAndStatus(spuIds, status); } }