From 6808d3c163fca5c699d21b50ec0c4d112b319df3 Mon Sep 17 00:00:00 2001 From: halfninety <690534687@qq.com> Date: Sat, 3 Dec 2022 15:42:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=A7=92=E6=9D=80=E6=97=B6?= =?UTF-8?q?=E6=AE=B5todo=EF=BC=8C=E7=A7=92=E6=9D=80=E6=97=B6=E6=AE=B5?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=B7=BB=E5=8A=A0timeIds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activity/SeckillActivityCreateReqVO.java | 2 -- .../SeckillActivityConvert.java | 5 +-- .../seckillactivity/SeckillActivityDO.java | 17 +++++----- .../seckillactivity/SeckillProductDO.java | 22 ++++++------- .../seckill/seckilltime/SeckillTimeDO.java | 7 ++-- .../SeckillActivityMapper.java | 4 +-- .../seckillactivity/SeckillProductMapper.java | 9 ++++++ .../seckilltime/SeckillTimeMapper.java | 24 +++----------- .../SeckillActivityServiceImpl.java | 32 +++++++++---------- .../seckilltime/SeckillTimeService.java | 4 +-- .../seckilltime/SeckillTimeServiceImpl.java | 11 +++---- .../seckill/seckillActivity/index.vue | 24 +++++++------- 12 files changed, 75 insertions(+), 86 deletions(-) diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java index 7324e767a..8ed5a3119 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java @@ -7,7 +7,6 @@ import lombok.EqualsAndHashCode; import lombok.ToString; import javax.validation.Valid; -import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import java.util.List; @@ -26,7 +25,6 @@ public class SeckillActivityCreateReqVO extends SeckillActivityBaseVO { @NotNull(message = "排序不能为空") private Integer sort; - // TODO halfninety:直接使用数组接口。timeIds, @ApiModelProperty(value = "秒杀时段id", required = true) @NotEmpty(message = "参与场次不能为空") private List timeIds; diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java index cf376c20f..1a00fdeb6 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java @@ -75,8 +75,9 @@ public interface SeckillActivityConvert { } - default List convertList(List products, Long seckillActivityId, List timeIds) { + default List convertList(List products, SeckillActivityDO seckillActivity) { return CollectionUtils.convertList(products, product -> convert(product) - .setActivityId(seckillActivityId).setTimeIds(timeIds)); + .setActivityId(seckillActivity.getId()).setTimeIds(seckillActivity.getTimeIds())); } + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillActivityDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillActivityDO.java index c0f79bc48..1d3b6da27 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillActivityDO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillActivityDO.java @@ -1,13 +1,16 @@ package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; +import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; -import lombok.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; -import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; @@ -16,14 +19,11 @@ import java.util.List; * * @author halfninety */ -@TableName("promotion_seckill_activity") +@TableName(value = "promotion_seckill_activity", autoResultMap = true) @KeySequence("promotion_seckill_activity_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor public class SeckillActivityDO extends BaseDO { /** @@ -37,7 +37,7 @@ public class SeckillActivityDO extends BaseDO { private String name; /** * 活动状态 - * + *

* 枚举 {@link PromotionActivityStatusEnum 对应的类} */ private Integer status; @@ -60,6 +60,7 @@ public class SeckillActivityDO extends BaseDO { /** * 秒杀时段 id */ + @TableField(typeHandler = LongListTypeHandler.class) private List timeIds; /** * 付款订单数 diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillProductDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillProductDO.java index 28a4f5e78..3783d6dda 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillProductDO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillProductDO.java @@ -1,17 +1,13 @@ package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; - -import java.io.Serializable; -import java.math.BigDecimal; -import java.util.Date; -import java.util.List; - +import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; +import com.baomidou.mybatisplus.annotation.*; import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.List; /** * 秒杀参与商品 @@ -19,8 +15,11 @@ import lombok.Data; * @author halfninety * @TableName promotion_seckill_product */ -@TableName(value = "promotion_seckill_product") +@TableName(value = "promotion_seckill_product", autoResultMap = true) +@KeySequence("promotion_seckill_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) public class SeckillProductDO extends BaseDO { /** * 秒杀参与商品编号 @@ -36,6 +35,7 @@ public class SeckillProductDO extends BaseDO { /** * 秒杀时段id */ + @TableField(typeHandler = LongListTypeHandler.class) private List timeIds; /** diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckilltime/SeckillTimeDO.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckilltime/SeckillTimeDO.java index 56dc0eb93..df338c0e6 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckilltime/SeckillTimeDO.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckilltime/SeckillTimeDO.java @@ -4,7 +4,9 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; import java.time.LocalTime; @@ -18,9 +20,6 @@ import java.time.LocalTime; @Data @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor public class SeckillTimeDO extends BaseDO { /** 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 640578746..c01676c2a 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 @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; @@ -19,8 +20,7 @@ public interface SeckillActivityMapper extends BaseMapperX { .likeIfPresent(SeckillActivityDO::getName, reqVO.getName()) .eqIfPresent(SeckillActivityDO::getStatus, reqVO.getStatus()) .betweenIfPresent(SeckillActivityDO::getCreateTime, reqVO.getCreateTime()) - .apply("FIND_IN_SET(" + reqVO.getTimeId() + ",time_id) > 0") + .apply(ObjectUtil.isNotNull(reqVO.getTimeId()),"FIND_IN_SET(" + reqVO.getTimeId() + ",time_ids) > 0") .orderByDesc(SeckillActivityDO::getId)); } - } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java index d434154d6..a590de1a5 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillProductMapper.java @@ -1,7 +1,9 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckillactivity; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; +import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; import org.apache.ibatis.annotations.Mapper; import java.util.Collection; @@ -23,4 +25,11 @@ public interface SeckillProductMapper extends BaseMapperX { return selectList(SeckillProductDO::getSkuId, skuIds); } + default void updateTimeIdsByActivityId(Long id, List timeIds) { + new LambdaUpdateChainWrapper<>(this) + .set(SeckillProductDO::getTimeIds, CollUtil.join(timeIds, ",")) + .eq(SeckillProductDO::getActivityId, id) + .update(); + } + } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckilltime/SeckillTimeMapper.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckilltime/SeckillTimeMapper.java index 19ada3356..c34484e8c 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckilltime/SeckillTimeMapper.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckilltime/SeckillTimeMapper.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.promotion.dal.mysql.seckill.seckilltime; -import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckilltime.SeckillTimeDO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -20,7 +19,7 @@ import java.util.List; public interface SeckillTimeMapper extends BaseMapperX { default List selectListByTime(LocalTime time) { - return selectList(SeckillTimeDO::getStartTime,SeckillTimeDO::getEndTime,time); + return selectList(SeckillTimeDO::getStartTime, SeckillTimeDO::getEndTime, time); } default List selectListByTime(LocalTime startTime, LocalTime endTime) { @@ -29,25 +28,10 @@ public interface SeckillTimeMapper extends BaseMapperX { .le(SeckillTimeDO::getEndTime, endTime)); } - // TODO @halfninety:updateActivityCount + 和 -,可以执使用一个方法实现哈。多传递一个参数 - default void sekillActivityCountAdd(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return; - } - new LambdaUpdateChainWrapper(this) + default void updateActivityCount(Collection ids, String type, Integer count) { + new LambdaUpdateChainWrapper<>(this) .in(SeckillTimeDO::getId, ids) - .setSql("`seckill_activity_count` = `seckill_activity_count` + 1 ") + .setSql("`seckill_activity_count` = `seckill_activity_count` " + type + count) .update(); } - - default void sekillActivityCountReduce(Collection ids) { - if (CollUtil.isEmpty(ids)) { - return; - } - new LambdaUpdateChainWrapper(this) - .in(SeckillTimeDO::getId, ids) - .setSql("`seckill_activity_count` = `seckill_activity_count` - 1 ") - .update(); - } - } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java index 025bf942d..45581d825 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.promotion.service.seckill.seckillactivity; import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; -import cn.iocoder.yudao.framework.common.util.string.StrUtils; import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityBaseVO; import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; @@ -35,13 +34,10 @@ import static java.util.Arrays.asList; @Service @Validated public class SeckillActivityServiceImpl implements SeckillActivityService { - // TODO: 2022/12/2 halfninety 当前修改时忘记秒杀商品中的秒杀时段id的设置了;需要全部修改 - // TODO: 2022/12/2 halfninety 将活动数量改为原来的商品数量 @Resource private SeckillActivityMapper seckillActivityMapper; @Resource private SeckillProductMapper seckillProductMapper; - @Resource private SeckillTimeService seckillTimeService; @@ -49,20 +45,18 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { public Long createSeckillActivity(SeckillActivityCreateReqVO createReqVO) { // 校验商品是否冲突 validateSeckillActivityProductConflicts(null, createReqVO.getProducts()); - // 校验秒杀时段是否存在 seckillTimeService.validateSeckillTimeExists(createReqVO.getTimeIds()); + // 插入秒杀活动 SeckillActivityDO seckillActivity = SeckillActivityConvert.INSTANCE.convert(createReqVO) .setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getStartTime(), createReqVO.getEndTime())); seckillActivityMapper.insert(seckillActivity); // 插入商品 - List productDOS = SeckillActivityConvert.INSTANCE - .convertList(createReqVO.getProducts(),seckillActivity.getId(),seckillActivity.getTimeIds()); + List productDOS = SeckillActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), seckillActivity); seckillProductMapper.insertBatch(productDOS); - // 更新秒杀时段的秒杀活动数量 - seckillTimeService.sekillActivityCountAdd(createReqVO.getTimeIds()); + seckillTimeService.sekillActivityCountIncr(createReqVO.getTimeIds()); return seckillActivity.getId(); } @@ -76,38 +70,36 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { // 校验商品是否冲突 validateSeckillActivityProductConflicts(updateReqVO.getId(), updateReqVO.getProducts()); - // 更新秒杀时段的秒杀活动数量 - updateSeckillTimeActivityCount(seckillActivity, updateReqVO.getTimeIds()); // 更新活动 SeckillActivityDO updateObj = SeckillActivityConvert.INSTANCE.convert(updateReqVO) .setStatus(PromotionUtils.calculateActivityStatus(updateReqVO.getStartTime(), updateReqVO.getEndTime())); seckillActivityMapper.updateById(updateObj); // 更新商品 updateSeckillProduct(updateReqVO); + // 更新秒杀时段的秒杀活动数量 + updateSeckillTimeActivityCount(seckillActivity, updateReqVO.getTimeIds()); } - // TODO @halfninety:注释写全哈; /** * 更新秒杀时段的秒杀活动数量 * * @param seckillActivity 查询出的秒杀活动 - * @param updateTimeIds 更新后的秒杀时段id列表 + * @param updateTimeIds 更新后的秒杀时段id列表 */ private void updateSeckillTimeActivityCount(SeckillActivityDO seckillActivity, List updateTimeIds) { // 查询出 timeIds List existsTimeIds = seckillActivity.getTimeIds(); // 需要减少的时间段 - // TODO @halfninety:可以使用 CollUtil.filterNew() Collection reduceIds = CollUtil.filterNew(existsTimeIds, existsTimeId -> !updateTimeIds.contains(existsTimeId)); // 需要添加的时间段 updateTimeIds.removeIf(existsTimeIds::contains); // 更新减少时间段和增加时间段 if (CollUtil.isNotEmpty(updateTimeIds)) { - seckillTimeService.sekillActivityCountAdd(updateTimeIds); + seckillTimeService.sekillActivityCountIncr(updateTimeIds); } if (CollUtil.isNotEmpty(reduceIds)) { - seckillTimeService.sekillActivityCountReduce(reduceIds); + seckillTimeService.sekillActivityCountDecr(reduceIds); } } @@ -116,6 +108,9 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { * 后台查出的数据和前台查出的数据进行遍历, * 1. 对前台数据进行遍历:如果不存在于后台的 sku 中需要新增 * 2. 对后台数据进行遍历:如果不存在于前台的 sku 中需要删除 + * 3. 最后对当前活动商品全部更新,更新秒杀时段id列表 + * + * @param updateReqVO 更新的请求VO */ private void updateSeckillProduct(SeckillActivityUpdateReqVO updateReqVO) { List seckillProductDOS = seckillProductMapper.selectListByActivityId(updateReqVO.getId()); @@ -137,6 +132,9 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { if (CollUtil.isNotEmpty(newSeckillProductDOs)) { seckillProductMapper.insertBatch(newSeckillProductDOs); } + + //全量更新当前活动商品的秒杀时段id列表(timeIds) + seckillProductMapper.updateTimeIdsByActivityId(updateReqVO.getId(), updateReqVO.getTimeIds()); } /** @@ -192,7 +190,7 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { throw exception(SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END); } // 更新秒杀时段的秒杀活动数量 - seckillTimeService.sekillActivityCountReduce(seckillActivity.getTimeIds()); + seckillTimeService.sekillActivityCountDecr(seckillActivity.getTimeIds()); // 删除 seckillActivityMapper.deleteById(id); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeService.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeService.java index 0762444f6..2e9c21249 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeService.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeService.java @@ -64,7 +64,7 @@ public interface SeckillTimeService { * * @param ids 秒杀时段id列表 */ - void sekillActivityCountAdd(Collection ids); + void sekillActivityCountIncr(Collection ids); /** @@ -72,5 +72,5 @@ public interface SeckillTimeService { * * @param ids 秒杀时段id列表 */ - void sekillActivityCountReduce(Collection ids); + void sekillActivityCountDecr(Collection ids); } diff --git a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeServiceImpl.java b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeServiceImpl.java index 70dd521f3..d38183860 100644 --- a/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeServiceImpl.java +++ b/yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckilltime/SeckillTimeServiceImpl.java @@ -104,22 +104,21 @@ public class SeckillTimeServiceImpl implements SeckillTimeService { @Override public void validateSeckillTimeExists(Collection timeIds) { if (CollUtil.isEmpty(timeIds)) { - return; + throw exception(SECKILL_TIME_NOT_EXISTS); } if (seckillTimeMapper.selectBatchIds(timeIds).size() != timeIds.size()) { throw exception(SECKILL_TIME_NOT_EXISTS); } } - // TODO @halfninety:updateActivityCount + 和 -,可以执使用一个方法实现哈。多传递一个参数 @Override - public void sekillActivityCountAdd(Collection ids) { - seckillTimeMapper.sekillActivityCountAdd(ids); + public void sekillActivityCountIncr(Collection ids) { + seckillTimeMapper.updateActivityCount(ids, "+", 1); } @Override - public void sekillActivityCountReduce(Collection ids) { - seckillTimeMapper.sekillActivityCountReduce(ids); + public void sekillActivityCountDecr(Collection ids) { + seckillTimeMapper.updateActivityCount(ids, "-", 1); } } diff --git a/yudao-ui-admin/src/views/mall/promotion/seckill/seckillActivity/index.vue b/yudao-ui-admin/src/views/mall/promotion/seckill/seckillActivity/index.vue index 3805def34..265c54749 100644 --- a/yudao-ui-admin/src/views/mall/promotion/seckill/seckillActivity/index.vue +++ b/yudao-ui-admin/src/views/mall/promotion/seckill/seckillActivity/index.vue @@ -51,10 +51,10 @@ - + @@ -107,7 +107,7 @@ - {{ item.name + ': { ' }} {{ item.startTime }} -- {{ item.endTime + @@ -186,7 +186,7 @@