Commit 8dfb2983763798da60479fdfedaabbcbefcb0854
1 parent
9517ffdf
fix:完善 mall seckill 相关 ①
Showing
17 changed files
with
331 additions
and
173 deletions
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/SeckillConfigController.java
| ... | ... | @@ -48,6 +48,14 @@ public class SeckillConfigController { |
| 48 | 48 | return success(true); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | + @PutMapping("/update-status") | |
| 52 | + @Operation(summary = "修改时段配置状态") | |
| 53 | + @PreAuthorize("@ss.hasPermission('system:seckill-config:update')") | |
| 54 | + public CommonResult<Boolean> updateSeckillConfigStatus(@Valid @RequestBody SeckillConfigUpdateStatusReqVo reqVO) { | |
| 55 | + seckillConfigService.updateSeckillConfigStatus(reqVO.getId(), reqVO.getStatus()); | |
| 56 | + return success(true); | |
| 57 | + } | |
| 58 | + | |
| 51 | 59 | @DeleteMapping("/delete") |
| 52 | 60 | @Operation(summary = "删除秒杀时段") |
| 53 | 61 | @Parameter(name = "id", description = "编号", required = true) | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityBaseVO.java
| ... | ... | @@ -8,58 +8,61 @@ import org.springframework.format.annotation.DateTimeFormat; |
| 8 | 8 | import javax.validation.constraints.Min; |
| 9 | 9 | import javax.validation.constraints.NotNull; |
| 10 | 10 | import java.time.LocalDateTime; |
| 11 | +import java.util.List; | |
| 11 | 12 | |
| 12 | 13 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 13 | 14 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT; |
| 14 | 15 | |
| 15 | 16 | /** |
| 17 | + * 秒杀活动基地签证官 | |
| 16 | 18 | * 秒杀活动 Base VO,提供给添加、修改、详细的子 VO 使用 |
| 17 | 19 | * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 |
| 20 | + * | |
| 21 | + * @author HUIHUI | |
| 18 | 22 | */ |
| 19 | 23 | @Data |
| 20 | 24 | public class SeckillActivityBaseVO { |
| 21 | 25 | |
| 22 | - @Schema(description = "秒杀活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晚九点限时秒杀") | |
| 26 | + @Schema(description = "秒杀活动商品", requiredMode = Schema.RequiredMode.REQUIRED, example = "121") | |
| 27 | + @NotNull(message = "秒杀活动商品不能为空") | |
| 28 | + private Long spuId; | |
| 29 | + | |
| 30 | + @Schema(description = "秒杀活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618大促") | |
| 23 | 31 | @NotNull(message = "秒杀活动名称不能为空") |
| 24 | 32 | private String name; |
| 25 | 33 | |
| 34 | + @Schema(description = "活动状态 开启:0 禁用:1", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | |
| 35 | + @NotNull(message = "活动状态 开启:0 禁用:1不能为空") | |
| 36 | + private Integer status; | |
| 37 | + | |
| 38 | + @Schema(description = "备注", example = "清仓大甩卖割韭菜") | |
| 39 | + private String remark; | |
| 40 | + | |
| 26 | 41 | @Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 27 | 42 | @NotNull(message = "活动开始时间不能为空") |
| 28 | 43 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 29 | - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) | |
| 30 | 44 | private LocalDateTime startTime; |
| 31 | 45 | |
| 32 | 46 | @Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 33 | 47 | @NotNull(message = "活动结束时间不能为空") |
| 34 | 48 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 35 | - @JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT) | |
| 36 | 49 | private LocalDateTime endTime; |
| 37 | 50 | |
| 51 | + @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 52 | + @NotNull(message = "排序不能为空") | |
| 53 | + private Integer sort; | |
| 38 | 54 | |
| 39 | - @Schema(description = "商品") | |
| 40 | - @Data | |
| 41 | - public static class Product { | |
| 42 | - | |
| 43 | - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 44 | - @NotNull(message = "商品 SPU 编号不能为空") | |
| 45 | - private Long spuId; | |
| 46 | - | |
| 47 | - @Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 48 | - @NotNull(message = "商品 SKU 编号不能为空") | |
| 49 | - private Long skuId; | |
| 50 | - | |
| 51 | - @Schema(description = "秒杀金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "12.00") | |
| 52 | - @NotNull(message = "秒杀金额不能为空") | |
| 53 | - private Integer seckillPrice; | |
| 55 | + @Schema(description = "秒杀时段id", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 56 | + @NotNull(message = "秒杀时段id不能为空") | |
| 57 | + private List<Long> configIds; | |
| 54 | 58 | |
| 55 | - @Schema(description = "秒杀库存", example = "80") | |
| 56 | - @Min(value = 0, message = "秒杀库存需要大于等于 0") | |
| 57 | - private Integer quota; | |
| 59 | + @Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "12877") | |
| 60 | + private Integer totalLimitCount; | |
| 58 | 61 | |
| 59 | - @Schema(description = "每人限购", example = "10") // 如果为 0 则不限购 | |
| 60 | - @Min(value = 0, message = "每人限购需要大于等于 0") | |
| 61 | - private Integer limitCount; | |
| 62 | + @Schema(description = "单次限够数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "31683") | |
| 63 | + private Integer singleLimitCount; | |
| 62 | 64 | |
| 63 | - } | |
| 65 | + @Schema(description = "秒杀总库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") | |
| 66 | + private Integer totalStock; | |
| 64 | 67 | |
| 65 | 68 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityCreateReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; |
| 2 | 2 | |
| 3 | + | |
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductCreateReqVO; | |
| 3 | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 6 | import lombok.Data; |
| 5 | 7 | import lombok.EqualsAndHashCode; |
| 6 | 8 | import lombok.ToString; |
| 7 | 9 | |
| 8 | -import javax.validation.Valid; | |
| 9 | -import javax.validation.constraints.NotEmpty; | |
| 10 | -import javax.validation.constraints.NotNull; | |
| 11 | 10 | import java.util.List; |
| 12 | 11 | |
| 12 | +/** | |
| 13 | + * 管理后台 - 秒杀活动创建 Request VO | |
| 14 | + * | |
| 15 | + * @author HUIHUI | |
| 16 | + */ | |
| 13 | 17 | @Schema(description = "管理后台 - 秒杀活动创建 Request VO") |
| 14 | 18 | @Data |
| 15 | 19 | @EqualsAndHashCode(callSuper = true) |
| 16 | 20 | @ToString(callSuper = true) |
| 17 | 21 | public class SeckillActivityCreateReqVO extends SeckillActivityBaseVO { |
| 18 | 22 | |
| 19 | - /** | |
| 20 | - * 秒杀活动商品 | |
| 21 | - */ | |
| 22 | - @Schema(description = "秒杀活动商品", example = "1") | |
| 23 | - @NotNull(message = "秒杀活动商品不能为空") | |
| 24 | - private Long spuId; | |
| 25 | - | |
| 26 | - @Schema(description = "备注", example = "限时秒杀活动") | |
| 27 | - private String remark; | |
| 28 | - | |
| 29 | - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 30 | - @NotNull(message = "排序不能为空") | |
| 31 | - private Integer sort; | |
| 32 | - | |
| 33 | - @Schema(description = "秒杀时段id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,3") | |
| 34 | - @NotEmpty(message = "参与场次不能为空") | |
| 35 | - private List<Long> configIds; | |
| 36 | - | |
| 37 | - /** | |
| 38 | - * 商品列表 | |
| 39 | - */ | |
| 40 | - @NotEmpty(message = "商品列表不能为空") | |
| 41 | - @Valid | |
| 42 | - private List<Product> products; | |
| 23 | + @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 24 | + private List<SeckillProductCreateReqVO> products; | |
| 43 | 25 | |
| 44 | 26 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityDetailRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductRespVO; | |
| 3 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 5 | import lombok.Data; |
| 5 | -import lombok.EqualsAndHashCode; | |
| 6 | 6 | import lombok.ToString; |
| 7 | 7 | |
| 8 | 8 | import java.util.List; |
| 9 | 9 | |
| 10 | +/** | |
| 11 | + * 管理后台 - 秒杀活动的详细 Response VO | |
| 12 | + * | |
| 13 | + * @author HUIHUI | |
| 14 | + */ | |
| 10 | 15 | @Schema(description = "管理后台 - 秒杀活动的详细 Response VO") |
| 11 | 16 | @Data |
| 12 | -@EqualsAndHashCode(callSuper = true) | |
| 13 | 17 | @ToString(callSuper = true) |
| 14 | -public class SeckillActivityDetailRespVO extends SeckillActivityRespVO { | |
| 18 | +public class SeckillActivityDetailRespVO extends SeckillActivityBaseVO{ | |
| 15 | 19 | |
| 16 | - /** | |
| 17 | - * 商品列表 | |
| 18 | - */ | |
| 19 | - private List<Product> products; | |
| 20 | + @Schema(description = "秒杀活动id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 21 | + private Long id; | |
| 22 | + | |
| 23 | + @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 24 | + private List<SeckillProductRespVO> products; | |
| 20 | 25 | |
| 21 | 26 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductRespVO; | |
| 3 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 5 | import lombok.Data; |
| 5 | 6 | import lombok.EqualsAndHashCode; |
| ... | ... | @@ -8,6 +9,11 @@ import lombok.ToString; |
| 8 | 9 | import java.time.LocalDateTime; |
| 9 | 10 | import java.util.List; |
| 10 | 11 | |
| 12 | +/** | |
| 13 | + * 管理后台 - 秒杀活动 Response VO | |
| 14 | + * | |
| 15 | + * @author HUIHUI | |
| 16 | + */ | |
| 11 | 17 | @Schema(description = "管理后台 - 秒杀活动 Response VO") |
| 12 | 18 | @Data |
| 13 | 19 | @EqualsAndHashCode(callSuper = true) |
| ... | ... | @@ -17,25 +23,9 @@ public class SeckillActivityRespVO extends SeckillActivityBaseVO { |
| 17 | 23 | @Schema(description = "秒杀活动id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 18 | 24 | private Long id; |
| 19 | 25 | |
| 20 | - @Schema(description = "新增订单数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 21 | - private Integer orderCount; | |
| 26 | + @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 27 | + private List<SeckillProductRespVO> products; | |
| 22 | 28 | |
| 23 | - @Schema(description = "付款人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 24 | - private Integer userCount; | |
| 25 | 29 | |
| 26 | - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 27 | - private LocalDateTime createTime; | |
| 28 | - | |
| 29 | - @Schema(description = "秒杀时段id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,3") | |
| 30 | - private List<Long> configIds; | |
| 31 | - | |
| 32 | - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 33 | - private Integer sort; | |
| 34 | - | |
| 35 | - @Schema(description = "备注", example = "限时秒杀活动") | |
| 36 | - private String remark; | |
| 37 | - | |
| 38 | - @Schema(description = "活动状态", example = "进行中") | |
| 39 | - private Integer status; | |
| 40 | 30 | |
| 41 | 31 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/activity/SeckillActivityUpdateReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductRespVO; | |
| 4 | +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductUpdateReqVO; | |
| 3 | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 6 | import lombok.Data; |
| 5 | 7 | import lombok.EqualsAndHashCode; |
| ... | ... | @@ -10,32 +12,22 @@ import javax.validation.constraints.NotEmpty; |
| 10 | 12 | import javax.validation.constraints.NotNull; |
| 11 | 13 | import java.util.List; |
| 12 | 14 | |
| 15 | +/** | |
| 16 | + * 管理后台 - 秒杀活动更新 Request VO | |
| 17 | + * | |
| 18 | + * @author HUIHUI | |
| 19 | + */ | |
| 13 | 20 | @Schema(description = "管理后台 - 秒杀活动更新 Request VO") |
| 14 | 21 | @Data |
| 15 | 22 | @EqualsAndHashCode(callSuper = true) |
| 16 | 23 | @ToString(callSuper = true) |
| 17 | 24 | public class SeckillActivityUpdateReqVO extends SeckillActivityBaseVO { |
| 18 | 25 | |
| 19 | - @Schema(description = "秒杀活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "224") | |
| 20 | - @NotNull(message = "秒杀活动编号不能为空") | |
| 26 | + @Schema(description = "秒杀活动id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 21 | 27 | private Long id; |
| 22 | 28 | |
| 23 | - @Schema(description = "备注", example = "限时秒杀活动") | |
| 24 | - private String remark; | |
| 29 | + @Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 30 | + private List<SeckillProductUpdateReqVO> products; | |
| 25 | 31 | |
| 26 | - @Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 27 | - @NotNull(message = "排序不能为空") | |
| 28 | - private Integer sort; | |
| 29 | - | |
| 30 | - @Schema(description = "秒杀时段id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,3") | |
| 31 | - @NotEmpty(message = "秒杀时段id不能为空") | |
| 32 | - private List<Long> configIds; | |
| 33 | - | |
| 34 | - /** | |
| 35 | - * 商品列表 | |
| 36 | - */ | |
| 37 | - @NotEmpty(message = "商品列表不能为空") | |
| 38 | - @Valid | |
| 39 | - private List<Product> products; | |
| 40 | 32 | |
| 41 | 33 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/config/SeckillConfigUpdateStatusReqVo.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 5 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 管理后台 - 修改时段配置状态 Request VO | |
| 12 | + * | |
| 13 | + * @author HUIHUI | |
| 14 | + */ | |
| 15 | +@Schema(description = "管理后台 - 修改时段配置状态 Request VO") | |
| 16 | +@Data | |
| 17 | +public class SeckillConfigUpdateStatusReqVo { | |
| 18 | + | |
| 19 | + @Schema(description = "时段配置编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 20 | + @NotNull(message = "时段配置编号不能为空") | |
| 21 | + private Long id; | |
| 22 | + | |
| 23 | + @Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 24 | + @NotNull(message = "状态不能为空") | |
| 25 | + @InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}") | |
| 26 | + private Integer status; | |
| 27 | + | |
| 28 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.*; | |
| 5 | +import java.time.LocalDateTime; | |
| 6 | +import javax.validation.constraints.*; | |
| 7 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 8 | + | |
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 秒杀参与商品 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 13 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 14 | + * | |
| 15 | + * @author HUIHUI | |
| 16 | + */ | |
| 17 | +@Data | |
| 18 | +public class SeckillProductBaseVO { | |
| 19 | + | |
| 20 | + @Schema(description = "秒杀活动id", requiredMode = Schema.RequiredMode.REQUIRED, example = "20173") | |
| 21 | + @NotNull(message = "秒杀活动id不能为空") | |
| 22 | + private Long activityId; | |
| 23 | + | |
| 24 | + @Schema(description = "秒杀时段id", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 25 | + @NotNull(message = "秒杀时段id不能为空") | |
| 26 | + private String configIds; | |
| 27 | + | |
| 28 | + @Schema(description = "商品spu_id", requiredMode = Schema.RequiredMode.REQUIRED, example = "10290") | |
| 29 | + @NotNull(message = "商品spu_id不能为空") | |
| 30 | + private Long spuId; | |
| 31 | + | |
| 32 | + @Schema(description = "商品sku_id", requiredMode = Schema.RequiredMode.REQUIRED, example = "30563") | |
| 33 | + @NotNull(message = "商品sku_id不能为空") | |
| 34 | + private Long skuId; | |
| 35 | + | |
| 36 | + @Schema(description = "秒杀金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "6689") | |
| 37 | + @NotNull(message = "秒杀金额,单位:分不能为空") | |
| 38 | + private Integer seckillPrice; | |
| 39 | + | |
| 40 | + @Schema(description = "秒杀库存", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 41 | + @NotNull(message = "秒杀库存不能为空") | |
| 42 | + private Integer stock; | |
| 43 | + | |
| 44 | + @Schema(description = "秒杀商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 45 | + @NotNull(message = "秒杀商品状态不能为空") | |
| 46 | + private Integer activityStatus; | |
| 47 | + | |
| 48 | + @Schema(description = "活动开始时间点", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 49 | + @NotNull(message = "活动开始时间点不能为空") | |
| 50 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 51 | + private LocalDateTime activityStartTime; | |
| 52 | + | |
| 53 | + @Schema(description = "活动结束时间点", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 54 | + @NotNull(message = "活动结束时间点不能为空") | |
| 55 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 56 | + private LocalDateTime activityEndTime; | |
| 57 | + | |
| 58 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductCreateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO; | |
| 4 | +import lombok.*; | |
| 5 | +import java.util.*; | |
| 6 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 7 | +import javax.validation.constraints.*; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * 管理后台 - 秒杀参与商品创建 Request VO | |
| 11 | + * | |
| 12 | + * @author HUIHUI | |
| 13 | + */ | |
| 14 | +@Schema(description = "管理后台 - 秒杀参与商品创建 Request VO") | |
| 15 | +@Data | |
| 16 | +@EqualsAndHashCode(callSuper = true) | |
| 17 | +@ToString(callSuper = true) | |
| 18 | +public class SeckillProductCreateReqVO extends SeckillProductBaseVO { | |
| 19 | + | |
| 20 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.*; | |
| 5 | +import java.time.LocalDateTime; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 管理后台 - 秒杀参与商品 Response VO | |
| 9 | + * | |
| 10 | + * @author HUIHUI | |
| 11 | + */ | |
| 12 | +@Schema(description = "管理后台 - 秒杀参与商品 Response VO") | |
| 13 | +@Data | |
| 14 | +@EqualsAndHashCode(callSuper = true) | |
| 15 | +@ToString(callSuper = true) | |
| 16 | +public class SeckillProductRespVO extends SeckillProductBaseVO { | |
| 17 | + | |
| 18 | + @Schema(description = "秒杀参与商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "256") | |
| 19 | + private Long id; | |
| 20 | + | |
| 21 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 22 | + private LocalDateTime createTime; | |
| 23 | + | |
| 24 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/seckill/vo/product/SeckillProductUpdateReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.*; | |
| 5 | +import javax.validation.constraints.*; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 管理后台 - 秒杀参与商品更新 Request VO | |
| 9 | + * | |
| 10 | + * @author HUIHUI | |
| 11 | + */ | |
| 12 | +@Schema(description = "管理后台 - 秒杀参与商品更新 Request VO") | |
| 13 | +@Data | |
| 14 | +@EqualsAndHashCode(callSuper = true) | |
| 15 | +@ToString(callSuper = true) | |
| 16 | +public class SeckillProductUpdateReqVO extends SeckillProductBaseVO { | |
| 17 | + | |
| 18 | + @Schema(description = "秒杀参与商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "256") | |
| 19 | + @NotNull(message = "秒杀参与商品编号不能为空") | |
| 20 | + private Long id; | |
| 21 | + | |
| 22 | +} | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java
| ... | ... | @@ -2,13 +2,10 @@ package cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.util.ObjectUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 6 | 5 | import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.*; |
| 7 | 6 | import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; |
| 8 | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; |
| 9 | 8 | import org.mapstruct.Mapper; |
| 10 | -import org.mapstruct.Mapping; | |
| 11 | -import org.mapstruct.Mappings; | |
| 12 | 9 | import org.mapstruct.factory.Mappers; |
| 13 | 10 | |
| 14 | 11 | import java.util.List; |
| ... | ... | @@ -25,13 +22,8 @@ public interface SeckillActivityConvert { |
| 25 | 22 | |
| 26 | 23 | SeckillProductDO convert(SeckillActivityBaseVO.Product product); |
| 27 | 24 | |
| 28 | - | |
| 29 | 25 | SeckillActivityDO convert(SeckillActivityCreateReqVO bean); |
| 30 | 26 | |
| 31 | - default String map(Long[] value) { | |
| 32 | - return value.toString(); | |
| 33 | - } | |
| 34 | - | |
| 35 | 27 | SeckillActivityDO convert(SeckillActivityUpdateReqVO bean); |
| 36 | 28 | |
| 37 | 29 | SeckillActivityRespVO convert(SeckillActivityDO bean); |
| ... | ... | @@ -40,7 +32,6 @@ public interface SeckillActivityConvert { |
| 40 | 32 | |
| 41 | 33 | PageResult<SeckillActivityRespVO> convertPage(PageResult<SeckillActivityDO> page); |
| 42 | 34 | |
| 43 | - @Mappings({@Mapping(target = "products", source = "seckillProducts")}) | |
| 44 | 35 | SeckillActivityDetailRespVO convert(SeckillActivityDO seckillActivity, List<SeckillProductDO> seckillProducts); |
| 45 | 36 | |
| 46 | 37 | |
| ... | ... | @@ -54,9 +45,9 @@ public interface SeckillActivityConvert { |
| 54 | 45 | default boolean isEquals(SeckillProductDO productDO, SeckillActivityBaseVO.Product productVO) { |
| 55 | 46 | return ObjectUtil.equals(productDO.getSpuId(), productVO.getSpuId()) |
| 56 | 47 | && ObjectUtil.equals(productDO.getSkuId(), productVO.getSkuId()) |
| 57 | - && ObjectUtil.equals(productDO.getSeckillPrice(), productVO.getSeckillPrice()) | |
| 58 | - && ObjectUtil.equals(productDO.getQuota(), productVO.getQuota()) | |
| 59 | - && ObjectUtil.equals(productDO.getLimitCount(), productVO.getLimitCount()); | |
| 48 | + && ObjectUtil.equals(productDO.getSeckillPrice(), productVO.getSeckillPrice()); | |
| 49 | + //&& ObjectUtil.equals(productDO.getQuota(), productVO.getQuota()) | |
| 50 | + //&& ObjectUtil.equals(productDO.getLimitCount(), productVO.getLimitCount()); | |
| 60 | 51 | } |
| 61 | 52 | |
| 62 | 53 | /** |
| ... | ... | @@ -69,15 +60,10 @@ public interface SeckillActivityConvert { |
| 69 | 60 | default boolean isEquals(SeckillProductDO productDO, SeckillProductDO productVO) { |
| 70 | 61 | return ObjectUtil.equals(productDO.getSpuId(), productVO.getSpuId()) |
| 71 | 62 | && ObjectUtil.equals(productDO.getSkuId(), productVO.getSkuId()) |
| 72 | - && ObjectUtil.equals(productDO.getSeckillPrice(), productVO.getSeckillPrice()) | |
| 73 | - && ObjectUtil.equals(productDO.getQuota(), productVO.getQuota()) | |
| 74 | - && ObjectUtil.equals(productDO.getLimitCount(), productVO.getLimitCount()); | |
| 75 | - | |
| 76 | - } | |
| 63 | + && ObjectUtil.equals(productDO.getSeckillPrice(), productVO.getSeckillPrice()); | |
| 64 | + //&& ObjectUtil.equals(productDO.getQuota(), productVO.getQuota()) | |
| 65 | + //&& ObjectUtil.equals(productDO.getLimitCount(), productVO.getLimitCount()); | |
| 77 | 66 | |
| 78 | - default List<SeckillProductDO> convertList(List<SeckillActivityBaseVO.Product> products, SeckillActivityDO seckillActivity) { | |
| 79 | - return CollectionUtils.convertList(products, product -> convert(product) | |
| 80 | - .setActivityId(seckillActivity.getId()).setConfigIds(seckillActivity.getConfigIds())); | |
| 81 | 67 | } |
| 82 | 68 | |
| 83 | 69 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillActivityDO.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 3 | 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | 5 | import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; |
| 5 | 6 | import cn.iocoder.yudao.module.promotion.enums.common.PromotionActivityStatusEnum; |
| ... | ... | @@ -42,7 +43,7 @@ public class SeckillActivityDO extends BaseDO { |
| 42 | 43 | /** |
| 43 | 44 | * 活动状态 |
| 44 | 45 | * |
| 45 | - * 枚举 {@link PromotionActivityStatusEnum 对应的类} | |
| 46 | + * 枚举 {@link CommonStatusEnum 对应的类} | |
| 46 | 47 | */ |
| 47 | 48 | private Integer status; |
| 48 | 49 | /** |
| ... | ... | @@ -78,5 +79,21 @@ public class SeckillActivityDO extends BaseDO { |
| 78 | 79 | * 订单实付金额,单位:分 |
| 79 | 80 | */ |
| 80 | 81 | private Long totalPrice; |
| 82 | + /** | |
| 83 | + * 总限购数量 | |
| 84 | + */ | |
| 85 | + private Integer totalLimitCount; | |
| 86 | + /** | |
| 87 | + * 单次限够数量 | |
| 88 | + */ | |
| 89 | + private Integer singleLimitCount; | |
| 90 | + /** | |
| 91 | + * 秒杀库存 | |
| 92 | + */ | |
| 93 | + private Integer stock; | |
| 94 | + /** | |
| 95 | + * 秒杀总库存 | |
| 96 | + */ | |
| 97 | + private Integer totalStock; | |
| 81 | 98 | |
| 82 | 99 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/seckill/seckillactivity/SeckillProductDO.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | -import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; | |
| 3 | +import lombok.*; | |
| 4 | +import java.time.LocalDateTime; | |
| 5 | 5 | import com.baomidou.mybatisplus.annotation.*; |
| 6 | -import lombok.Data; | |
| 7 | -import lombok.EqualsAndHashCode; | |
| 8 | -import lombok.ToString; | |
| 9 | - | |
| 10 | -import java.util.List; | |
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 11 | 7 | |
| 12 | 8 | /** |
| 13 | - * 秒杀参与商品 | |
| 9 | + * 秒杀参与商品 DO | |
| 14 | 10 | * |
| 15 | - * @author halfninety | |
| 16 | - * @TableName promotion_seckill_product | |
| 11 | + * @author HUIHUI | |
| 17 | 12 | */ |
| 18 | -@TableName(value = "promotion_seckill_product", autoResultMap = true) | |
| 13 | +@TableName("promotion_seckill_product") | |
| 19 | 14 | @KeySequence("promotion_seckill_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 |
| 20 | 15 | @Data |
| 21 | 16 | @EqualsAndHashCode(callSuper = true) |
| 22 | 17 | @ToString(callSuper = true) |
| 18 | +@Builder | |
| 19 | +@NoArgsConstructor | |
| 20 | +@AllArgsConstructor | |
| 23 | 21 | public class SeckillProductDO extends BaseDO { |
| 24 | 22 | |
| 25 | 23 | /** |
| 26 | 24 | * 秒杀参与商品编号 |
| 27 | 25 | */ |
| 28 | - @TableId(type = IdType.AUTO) | |
| 26 | + @TableId | |
| 29 | 27 | private Long id; |
| 30 | - | |
| 31 | 28 | /** |
| 32 | - * 秒杀活动id | |
| 29 | + * 秒杀活动 id | |
| 33 | 30 | */ |
| 34 | 31 | private Long activityId; |
| 35 | - | |
| 36 | 32 | /** |
| 37 | - * 秒杀时段id | |
| 33 | + * 秒杀时段 id | |
| 38 | 34 | */ |
| 39 | - @TableField(typeHandler = LongListTypeHandler.class) | |
| 40 | - private List<Long> configIds; | |
| 41 | - | |
| 35 | + private String configIds; | |
| 42 | 36 | /** |
| 43 | - * 商品id | |
| 37 | + * 商品 spu_id | |
| 44 | 38 | */ |
| 45 | 39 | private Long spuId; |
| 46 | - | |
| 47 | 40 | /** |
| 48 | - * 商品sku_id | |
| 41 | + * 商品 sku_id | |
| 49 | 42 | */ |
| 50 | 43 | private Long skuId; |
| 51 | - | |
| 52 | 44 | /** |
| 53 | - * 秒杀金额 | |
| 45 | + * 秒杀金额,单位:分 | |
| 54 | 46 | */ |
| 55 | 47 | private Integer seckillPrice; |
| 56 | - | |
| 57 | 48 | /** |
| 58 | - * 秒杀库存 限量库存;每次购买时,需要减小; | |
| 49 | + * 秒杀库存 | |
| 59 | 50 | */ |
| 60 | - private Integer quota; | |
| 61 | - | |
| 51 | + private Integer stock; | |
| 52 | + /** | |
| 53 | + * 秒杀商品状态 | |
| 54 | + */ | |
| 55 | + private Integer activityStatus; | |
| 56 | + /** | |
| 57 | + * 活动开始时间点 | |
| 58 | + */ | |
| 59 | + private LocalDateTime activityStartTime; | |
| 62 | 60 | /** |
| 63 | - * 每人限购 | |
| 61 | + * 活动结束时间点 | |
| 64 | 62 | */ |
| 65 | - private Integer limitCount; | |
| 63 | + private LocalDateTime activityEndTime; | |
| 66 | 64 | |
| 67 | 65 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillactivity/SeckillActivityServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.service.seckill.seckillactivity; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.hutool.core.util.ObjectUtil; | |
| 5 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 4 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 7 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 6 | 8 | import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityBaseVO; |
| 7 | 9 | import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityCreateReqVO; |
| 8 | 10 | import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityPageReqVO; |
| 9 | 11 | import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO; |
| 12 | +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO; | |
| 13 | +import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductCreateReqVO; | |
| 10 | 14 | import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert; |
| 11 | 15 | import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO; |
| 12 | 16 | import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO; |
| ... | ... | @@ -49,13 +53,13 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { |
| 49 | 53 | // 校验秒杀时段是否存在 |
| 50 | 54 | seckillConfigService.validateSeckillConfigExists(createReqVO.getConfigIds()); |
| 51 | 55 | |
| 52 | - // 插入秒杀活动 | |
| 56 | + // 插入秒杀活动 TODO 活动日期拼接上秒杀时段 -> 2023-06-08 09:00:00 | |
| 53 | 57 | SeckillActivityDO seckillActivity = SeckillActivityConvert.INSTANCE.convert(createReqVO) |
| 54 | 58 | .setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getStartTime(), createReqVO.getEndTime())); |
| 55 | 59 | seckillActivityMapper.insert(seckillActivity); |
| 56 | 60 | // 插入商品 |
| 57 | - List<SeckillProductDO> productDOs = SeckillActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), seckillActivity); | |
| 58 | - seckillProductMapper.insertBatch(productDOs); | |
| 61 | + //List<SeckillProductDO> productDOs = SeckillActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), seckillActivity); | |
| 62 | + //seckillProductMapper.insertBatch(productDOs); | |
| 59 | 63 | return seckillActivity.getId(); |
| 60 | 64 | } |
| 61 | 65 | |
| ... | ... | @@ -89,24 +93,24 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { |
| 89 | 93 | */ |
| 90 | 94 | private void updateSeckillProduct(SeckillActivityUpdateReqVO updateReqVO) { |
| 91 | 95 | List<SeckillProductDO> seckillProductDOs = seckillProductMapper.selectListByActivityId(updateReqVO.getId()); |
| 92 | - List<SeckillActivityBaseVO.Product> products = updateReqVO.getProducts(); | |
| 96 | + //List<SeckillActivityBaseVO.Product> products = updateReqVO.getProducts(); | |
| 93 | 97 | |
| 94 | 98 | // 计算需要删除的数据 |
| 95 | - List<Long> deleteIds = CollectionUtils.convertList(seckillProductDOs, SeckillProductDO::getId, | |
| 96 | - seckillProductDO -> products.stream() | |
| 97 | - .noneMatch(product -> SeckillActivityConvert.INSTANCE.isEquals(seckillProductDO, product))); | |
| 98 | - if (CollUtil.isNotEmpty(deleteIds)) { | |
| 99 | - seckillProductMapper.deleteBatchIds(deleteIds); | |
| 100 | - } | |
| 101 | - | |
| 102 | - // 计算需要新增的数据 | |
| 103 | - List<SeckillProductDO> newSeckillProductDOs = CollectionUtils.convertList(products, | |
| 104 | - product -> SeckillActivityConvert.INSTANCE.convert(product).setActivityId(updateReqVO.getId())); | |
| 105 | - newSeckillProductDOs.removeIf(product -> seckillProductDOs.stream() | |
| 106 | - .anyMatch(seckillProduct -> SeckillActivityConvert.INSTANCE.isEquals(seckillProduct, product))); | |
| 107 | - if (CollUtil.isNotEmpty(newSeckillProductDOs)) { | |
| 108 | - seckillProductMapper.insertBatch(newSeckillProductDOs); | |
| 109 | - } | |
| 99 | + //List<Long> deleteIds = CollectionUtils.convertList(seckillProductDOs, SeckillProductDO::getId, | |
| 100 | + // seckillProductDO -> products.stream() | |
| 101 | + // .noneMatch(product -> SeckillActivityConvert.INSTANCE.isEquals(seckillProductDO, product))); | |
| 102 | + //if (CollUtil.isNotEmpty(deleteIds)) { | |
| 103 | + // seckillProductMapper.deleteBatchIds(deleteIds); | |
| 104 | + //} | |
| 105 | + // | |
| 106 | + //// 计算需要新增的数据 | |
| 107 | + //List<SeckillProductDO> newSeckillProductDOs = CollectionUtils.convertList(products, | |
| 108 | + // product -> SeckillActivityConvert.INSTANCE.convert(product).setActivityId(updateReqVO.getId())); | |
| 109 | + //newSeckillProductDOs.removeIf(product -> seckillProductDOs.stream() | |
| 110 | + // .anyMatch(seckillProduct -> SeckillActivityConvert.INSTANCE.isEquals(seckillProduct, product))); | |
| 111 | + //if (CollUtil.isNotEmpty(newSeckillProductDOs)) { | |
| 112 | + // seckillProductMapper.insertBatch(newSeckillProductDOs); | |
| 113 | + //} | |
| 110 | 114 | |
| 111 | 115 | //全量更新当前活动商品的秒杀时段id列表(timeIds) |
| 112 | 116 | seckillProductMapper.updateTimeIdsByActivityId(updateReqVO.getId(), updateReqVO.getConfigIds()); |
| ... | ... | @@ -118,23 +122,25 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { |
| 118 | 122 | * @param id 秒杀活动编号 |
| 119 | 123 | * @param products 商品列表 |
| 120 | 124 | */ |
| 121 | - private void validateSeckillActivityProductConflicts(Long id, List<SeckillActivityBaseVO.Product> products) { | |
| 125 | + private <T extends SeckillProductBaseVO> void validateSeckillActivityProductConflicts(Long id, List<T> products) { | |
| 122 | 126 | if (CollUtil.isEmpty(products)) { |
| 123 | 127 | return; |
| 124 | 128 | } |
| 129 | + // 校验秒杀商品是否存在 | |
| 125 | 130 | List<SeckillProductDO> seckillProductDOs = seckillProductMapper |
| 126 | - .selectListBySkuIds(CollectionUtils.convertSet(products, SeckillActivityBaseVO.Product::getSkuId)); | |
| 131 | + .selectListBySkuIds(CollectionUtils.convertSet(products, T::getSkuId)); | |
| 127 | 132 | if (CollUtil.isEmpty(seckillProductDOs)) { |
| 128 | 133 | return; |
| 129 | 134 | } |
| 135 | + // 获取秒杀商品所在活动 | |
| 130 | 136 | List<SeckillActivityDO> seckillActivityDOs = seckillActivityMapper |
| 131 | 137 | .selectBatchIds(CollectionUtils.convertSet(seckillProductDOs, SeckillProductDO::getActivityId)); |
| 132 | - if (id != null) { // 排除自己这个活动 | |
| 138 | + if (id != null) { | |
| 139 | + // 排除自己这个活动 | |
| 133 | 140 | seckillActivityDOs.removeIf(item -> id.equals(item.getId())); |
| 134 | 141 | } |
| 135 | - // 排除不满足 status 的活动 | |
| 136 | - List<Integer> statuses = asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus()); | |
| 137 | - seckillActivityDOs.removeIf(item -> !statuses.contains(item.getStatus())); | |
| 142 | + // 排除关闭了的活动 | |
| 143 | + seckillActivityDOs.removeIf(item -> ObjectUtil.equal(item.getStatus(), CommonStatusEnum.DISABLE.getStatus())); | |
| 138 | 144 | // 如果非空,则说明冲突 |
| 139 | 145 | if (CollUtil.isNotEmpty(seckillActivityDOs)) { |
| 140 | 146 | throw exception(SECKILL_ACTIVITY_SPU_CONFLICTS); |
| ... | ... | @@ -164,8 +170,7 @@ public class SeckillActivityServiceImpl implements SeckillActivityService { |
| 164 | 170 | if (!statuses.contains(seckillActivity.getStatus())) { |
| 165 | 171 | throw exception(SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END); |
| 166 | 172 | } |
| 167 | - // 更新秒杀时段的秒杀活动数量 | |
| 168 | - seckillConfigService.seckillActivityCountDecr(seckillActivity.getConfigIds()); | |
| 173 | + | |
| 169 | 174 | // 删除 |
| 170 | 175 | seckillActivityMapper.deleteById(id); |
| 171 | 176 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillconfig/SeckillConfigService.java
| ... | ... | @@ -76,4 +76,12 @@ public interface SeckillConfigService { |
| 76 | 76 | * @return 秒杀时段列表 |
| 77 | 77 | */ |
| 78 | 78 | List<SeckillConfigDO> getListAllSimple(); |
| 79 | + | |
| 80 | + /** | |
| 81 | + * 更新秒杀时段配置状态 | |
| 82 | + * | |
| 83 | + * @param id id | |
| 84 | + * @param status 状态 | |
| 85 | + */ | |
| 86 | + void updateSeckillConfigStatus(Long id, Integer status); | |
| 79 | 87 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/seckill/seckillconfig/SeckillConfigServiceImpl.java
| ... | ... | @@ -139,4 +139,16 @@ public class SeckillConfigServiceImpl implements SeckillConfigService { |
| 139 | 139 | return seckillConfigMapper.selectList(SeckillConfigDO::getStatus, CommonStatusEnum.ENABLE.getStatus()); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | + @Override | |
| 143 | + public void updateSeckillConfigStatus(Long id, Integer status) { | |
| 144 | + // 校验秒杀时段是否存在 | |
| 145 | + validateSeckillConfigExists(id); | |
| 146 | + | |
| 147 | + SeckillConfigDO seckillConfigDO = new SeckillConfigDO(); | |
| 148 | + seckillConfigDO.setId(id); | |
| 149 | + seckillConfigDO.setStatus(status); | |
| 150 | + // 更新状态 | |
| 151 | + seckillConfigMapper.updateById(seckillConfigDO); | |
| 152 | + } | |
| 153 | + | |
| 142 | 154 | } | ... | ... |