fix:完善 mall seckill 相关 ①
This commit is contained in:
parent
9517ffdfb8
commit
8dfb298376
@ -48,6 +48,14 @@ public class SeckillConfigController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/update-status")
|
||||
@Operation(summary = "修改时段配置状态")
|
||||
@PreAuthorize("@ss.hasPermission('system:seckill-config:update')")
|
||||
public CommonResult<Boolean> updateSeckillConfigStatus(@Valid @RequestBody SeckillConfigUpdateStatusReqVo reqVO) {
|
||||
seckillConfigService.updateSeckillConfigStatus(reqVO.getId(), reqVO.getStatus());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除秒杀时段")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
|
@ -8,58 +8,61 @@ import org.springframework.format.annotation.DateTimeFormat;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.TIME_ZONE_DEFAULT;
|
||||
|
||||
/**
|
||||
* 秒杀活动基地签证官
|
||||
* 秒杀活动 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Data
|
||||
public class SeckillActivityBaseVO {
|
||||
|
||||
@Schema(description = "秒杀活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "晚九点限时秒杀")
|
||||
@Schema(description = "秒杀活动商品", requiredMode = Schema.RequiredMode.REQUIRED, example = "121")
|
||||
@NotNull(message = "秒杀活动商品不能为空")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "秒杀活动名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "618大促")
|
||||
@NotNull(message = "秒杀活动名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "活动状态 开启:0 禁用:1", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
@NotNull(message = "活动状态 开启:0 禁用:1不能为空")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "备注", example = "清仓大甩卖割韭菜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "活动开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "活动开始时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "活动结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "活动结束时间不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@JsonFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND, timezone = TIME_ZONE_DEFAULT)
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "商品")
|
||||
@Data
|
||||
public static class Product {
|
||||
@Schema(description = "秒杀时段id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "秒杀时段id不能为空")
|
||||
private List<Long> configIds;
|
||||
|
||||
@Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "商品 SPU 编号不能为空")
|
||||
private Long spuId;
|
||||
@Schema(description = "总限购数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "12877")
|
||||
private Integer totalLimitCount;
|
||||
|
||||
@Schema(description = "商品 SKU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "商品 SKU 编号不能为空")
|
||||
private Long skuId;
|
||||
@Schema(description = "单次限够数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "31683")
|
||||
private Integer singleLimitCount;
|
||||
|
||||
@Schema(description = "秒杀金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "12.00")
|
||||
@NotNull(message = "秒杀金额不能为空")
|
||||
private Integer seckillPrice;
|
||||
|
||||
@Schema(description = "秒杀库存", example = "80")
|
||||
@Min(value = 0, message = "秒杀库存需要大于等于 0")
|
||||
private Integer quota;
|
||||
|
||||
@Schema(description = "每人限购", example = "10") // 如果为 0 则不限购
|
||||
@Min(value = 0, message = "每人限购需要大于等于 0")
|
||||
private Integer limitCount;
|
||||
|
||||
}
|
||||
@Schema(description = "秒杀总库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
|
||||
private Integer totalStock;
|
||||
|
||||
}
|
||||
|
@ -1,44 +1,26 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductCreateReqVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 管理后台 - 秒杀活动创建 Request VO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Schema(description = "管理后台 - 秒杀活动创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillActivityCreateReqVO extends SeckillActivityBaseVO {
|
||||
|
||||
/**
|
||||
* 秒杀活动商品
|
||||
*/
|
||||
@Schema(description = "秒杀活动商品", example = "1")
|
||||
@NotNull(message = "秒杀活动商品不能为空")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "备注", example = "限时秒杀活动")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "秒杀时段id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,3")
|
||||
@NotEmpty(message = "参与场次不能为空")
|
||||
private List<Long> configIds;
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
@NotEmpty(message = "商品列表不能为空")
|
||||
@Valid
|
||||
private List<Product> products;
|
||||
@Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<SeckillProductCreateReqVO> products;
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,26 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductRespVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 管理后台 - 秒杀活动的详细 Response VO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Schema(description = "管理后台 - 秒杀活动的详细 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillActivityDetailRespVO extends SeckillActivityRespVO {
|
||||
public class SeckillActivityDetailRespVO extends SeckillActivityBaseVO{
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
private List<Product> products;
|
||||
@Schema(description = "秒杀活动id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<SeckillProductRespVO> products;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductRespVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -8,6 +9,11 @@ import lombok.ToString;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 管理后台 - 秒杀活动 Response VO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Schema(description = "管理后台 - 秒杀活动 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ -17,25 +23,9 @@ public class SeckillActivityRespVO extends SeckillActivityBaseVO {
|
||||
@Schema(description = "秒杀活动id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "新增订单数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer orderCount;
|
||||
@Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<SeckillProductRespVO> products;
|
||||
|
||||
@Schema(description = "付款人数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer userCount;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "秒杀时段id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,3")
|
||||
private List<Long> configIds;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "备注", example = "限时秒杀活动")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "活动状态", example = "进行中")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductUpdateReqVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -10,32 +12,22 @@ import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 管理后台 - 秒杀活动更新 Request VO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Schema(description = "管理后台 - 秒杀活动更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillActivityUpdateReqVO extends SeckillActivityBaseVO {
|
||||
|
||||
@Schema(description = "秒杀活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "224")
|
||||
@NotNull(message = "秒杀活动编号不能为空")
|
||||
@Schema(description = "秒杀活动id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "备注", example = "限时秒杀活动")
|
||||
private String remark;
|
||||
@Schema(description = "秒杀商品", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<SeckillProductUpdateReqVO> products;
|
||||
|
||||
@Schema(description = "排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "秒杀时段id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,3")
|
||||
@NotEmpty(message = "秒杀时段id不能为空")
|
||||
private List<Long> configIds;
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
@NotEmpty(message = "商品列表不能为空")
|
||||
@Valid
|
||||
private List<Product> products;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 管理后台 - 修改时段配置状态 Request VO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Schema(description = "管理后台 - 修改时段配置状态 Request VO")
|
||||
@Data
|
||||
public class SeckillConfigUpdateStatusReqVo {
|
||||
|
||||
@Schema(description = "时段配置编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "时段配置编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "状态,见 CommonStatusEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "状态不能为空")
|
||||
@InEnum(value = CommonStatusEnum.class, message = "修改状态必须是 {value}")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.time.LocalDateTime;
|
||||
import javax.validation.constraints.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 秒杀参与商品 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Data
|
||||
public class SeckillProductBaseVO {
|
||||
|
||||
@Schema(description = "秒杀活动id", requiredMode = Schema.RequiredMode.REQUIRED, example = "20173")
|
||||
@NotNull(message = "秒杀活动id不能为空")
|
||||
private Long activityId;
|
||||
|
||||
@Schema(description = "秒杀时段id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "秒杀时段id不能为空")
|
||||
private String configIds;
|
||||
|
||||
@Schema(description = "商品spu_id", requiredMode = Schema.RequiredMode.REQUIRED, example = "10290")
|
||||
@NotNull(message = "商品spu_id不能为空")
|
||||
private Long spuId;
|
||||
|
||||
@Schema(description = "商品sku_id", requiredMode = Schema.RequiredMode.REQUIRED, example = "30563")
|
||||
@NotNull(message = "商品sku_id不能为空")
|
||||
private Long skuId;
|
||||
|
||||
@Schema(description = "秒杀金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "6689")
|
||||
@NotNull(message = "秒杀金额,单位:分不能为空")
|
||||
private Integer seckillPrice;
|
||||
|
||||
@Schema(description = "秒杀库存", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "秒杀库存不能为空")
|
||||
private Integer stock;
|
||||
|
||||
@Schema(description = "秒杀商品状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "秒杀商品状态不能为空")
|
||||
private Integer activityStatus;
|
||||
|
||||
@Schema(description = "活动开始时间点", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "活动开始时间点不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime activityStartTime;
|
||||
|
||||
@Schema(description = "活动结束时间点", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "活动结束时间点不能为空")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime activityEndTime;
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 管理后台 - 秒杀参与商品创建 Request VO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Schema(description = "管理后台 - 秒杀参与商品创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillProductCreateReqVO extends SeckillProductBaseVO {
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 管理后台 - 秒杀参与商品 Response VO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Schema(description = "管理后台 - 秒杀参与商品 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillProductRespVO extends SeckillProductBaseVO {
|
||||
|
||||
@Schema(description = "秒杀参与商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "256")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 管理后台 - 秒杀参与商品更新 Request VO
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Schema(description = "管理后台 - 秒杀参与商品更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SeckillProductUpdateReqVO extends SeckillProductBaseVO {
|
||||
|
||||
@Schema(description = "秒杀参与商品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "256")
|
||||
@NotNull(message = "秒杀参与商品编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -2,13 +2,10 @@ package cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.*;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
@ -25,13 +22,8 @@ public interface SeckillActivityConvert {
|
||||
|
||||
SeckillProductDO convert(SeckillActivityBaseVO.Product product);
|
||||
|
||||
|
||||
SeckillActivityDO convert(SeckillActivityCreateReqVO bean);
|
||||
|
||||
default String map(Long[] value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
SeckillActivityDO convert(SeckillActivityUpdateReqVO bean);
|
||||
|
||||
SeckillActivityRespVO convert(SeckillActivityDO bean);
|
||||
@ -40,7 +32,6 @@ public interface SeckillActivityConvert {
|
||||
|
||||
PageResult<SeckillActivityRespVO> convertPage(PageResult<SeckillActivityDO> page);
|
||||
|
||||
@Mappings({@Mapping(target = "products", source = "seckillProducts")})
|
||||
SeckillActivityDetailRespVO convert(SeckillActivityDO seckillActivity, List<SeckillProductDO> seckillProducts);
|
||||
|
||||
|
||||
@ -54,9 +45,9 @@ public interface SeckillActivityConvert {
|
||||
default boolean isEquals(SeckillProductDO productDO, SeckillActivityBaseVO.Product productVO) {
|
||||
return ObjectUtil.equals(productDO.getSpuId(), productVO.getSpuId())
|
||||
&& ObjectUtil.equals(productDO.getSkuId(), productVO.getSkuId())
|
||||
&& ObjectUtil.equals(productDO.getSeckillPrice(), productVO.getSeckillPrice())
|
||||
&& ObjectUtil.equals(productDO.getQuota(), productVO.getQuota())
|
||||
&& ObjectUtil.equals(productDO.getLimitCount(), productVO.getLimitCount());
|
||||
&& ObjectUtil.equals(productDO.getSeckillPrice(), productVO.getSeckillPrice());
|
||||
//&& ObjectUtil.equals(productDO.getQuota(), productVO.getQuota())
|
||||
//&& ObjectUtil.equals(productDO.getLimitCount(), productVO.getLimitCount());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,15 +60,10 @@ public interface SeckillActivityConvert {
|
||||
default boolean isEquals(SeckillProductDO productDO, SeckillProductDO productVO) {
|
||||
return ObjectUtil.equals(productDO.getSpuId(), productVO.getSpuId())
|
||||
&& ObjectUtil.equals(productDO.getSkuId(), productVO.getSkuId())
|
||||
&& ObjectUtil.equals(productDO.getSeckillPrice(), productVO.getSeckillPrice())
|
||||
&& ObjectUtil.equals(productDO.getQuota(), productVO.getQuota())
|
||||
&& ObjectUtil.equals(productDO.getLimitCount(), productVO.getLimitCount());
|
||||
&& ObjectUtil.equals(productDO.getSeckillPrice(), productVO.getSeckillPrice());
|
||||
//&& ObjectUtil.equals(productDO.getQuota(), productVO.getQuota())
|
||||
//&& ObjectUtil.equals(productDO.getLimitCount(), productVO.getLimitCount());
|
||||
|
||||
}
|
||||
|
||||
default List<SeckillProductDO> convertList(List<SeckillActivityBaseVO.Product> products, SeckillActivityDO seckillActivity) {
|
||||
return CollectionUtils.convertList(products, product -> convert(product)
|
||||
.setActivityId(seckillActivity.getId()).setConfigIds(seckillActivity.getConfigIds()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
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;
|
||||
@ -42,7 +43,7 @@ public class SeckillActivityDO extends BaseDO {
|
||||
/**
|
||||
* 活动状态
|
||||
*
|
||||
* 枚举 {@link PromotionActivityStatusEnum 对应的类}
|
||||
* 枚举 {@link CommonStatusEnum 对应的类}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
@ -78,5 +79,21 @@ public class SeckillActivityDO extends BaseDO {
|
||||
* 订单实付金额,单位:分
|
||||
*/
|
||||
private Long totalPrice;
|
||||
/**
|
||||
* 总限购数量
|
||||
*/
|
||||
private Integer totalLimitCount;
|
||||
/**
|
||||
* 单次限够数量
|
||||
*/
|
||||
private Integer singleLimitCount;
|
||||
/**
|
||||
* 秒杀库存
|
||||
*/
|
||||
private Integer stock;
|
||||
/**
|
||||
* 秒杀总库存
|
||||
*/
|
||||
private Integer totalStock;
|
||||
|
||||
}
|
||||
|
@ -1,67 +1,65 @@
|
||||
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 lombok.*;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 秒杀参与商品
|
||||
* 秒杀参与商品 DO
|
||||
*
|
||||
* @author halfninety
|
||||
* @TableName promotion_seckill_product
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@TableName(value = "promotion_seckill_product", autoResultMap = true)
|
||||
@TableName("promotion_seckill_product")
|
||||
@KeySequence("promotion_seckill_product_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SeckillProductDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 秒杀参与商品编号
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 秒杀活动id
|
||||
* 秒杀活动 id
|
||||
*/
|
||||
private Long activityId;
|
||||
|
||||
/**
|
||||
* 秒杀时段id
|
||||
* 秒杀时段 id
|
||||
*/
|
||||
@TableField(typeHandler = LongListTypeHandler.class)
|
||||
private List<Long> configIds;
|
||||
|
||||
private String configIds;
|
||||
/**
|
||||
* 商品id
|
||||
* 商品 spu_id
|
||||
*/
|
||||
private Long spuId;
|
||||
|
||||
/**
|
||||
* 商品sku_id
|
||||
* 商品 sku_id
|
||||
*/
|
||||
private Long skuId;
|
||||
|
||||
/**
|
||||
* 秒杀金额
|
||||
* 秒杀金额,单位:分
|
||||
*/
|
||||
private Integer seckillPrice;
|
||||
|
||||
/**
|
||||
* 秒杀库存 限量库存;每次购买时,需要减小;
|
||||
* 秒杀库存
|
||||
*/
|
||||
private Integer quota;
|
||||
|
||||
private Integer stock;
|
||||
/**
|
||||
* 每人限购
|
||||
* 秒杀商品状态
|
||||
*/
|
||||
private Integer limitCount;
|
||||
private Integer activityStatus;
|
||||
/**
|
||||
* 活动开始时间点
|
||||
*/
|
||||
private LocalDateTime activityStartTime;
|
||||
/**
|
||||
* 活动结束时间点
|
||||
*/
|
||||
private LocalDateTime activityEndTime;
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,16 @@
|
||||
package cn.iocoder.yudao.module.promotion.service.seckill.seckillactivity;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
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;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.activity.SeckillActivityUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductBaseVO;
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.seckill.vo.product.SeckillProductCreateReqVO;
|
||||
import cn.iocoder.yudao.module.promotion.convert.seckill.seckillactivity.SeckillActivityConvert;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.seckill.seckillactivity.SeckillProductDO;
|
||||
@ -49,13 +53,13 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
||||
// 校验秒杀时段是否存在
|
||||
seckillConfigService.validateSeckillConfigExists(createReqVO.getConfigIds());
|
||||
|
||||
// 插入秒杀活动
|
||||
// 插入秒杀活动 TODO 活动日期拼接上秒杀时段 -> 2023-06-08 09:00:00
|
||||
SeckillActivityDO seckillActivity = SeckillActivityConvert.INSTANCE.convert(createReqVO)
|
||||
.setStatus(PromotionUtils.calculateActivityStatus(createReqVO.getStartTime(), createReqVO.getEndTime()));
|
||||
seckillActivityMapper.insert(seckillActivity);
|
||||
// 插入商品
|
||||
List<SeckillProductDO> productDOs = SeckillActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), seckillActivity);
|
||||
seckillProductMapper.insertBatch(productDOs);
|
||||
//List<SeckillProductDO> productDOs = SeckillActivityConvert.INSTANCE.convertList(createReqVO.getProducts(), seckillActivity);
|
||||
//seckillProductMapper.insertBatch(productDOs);
|
||||
return seckillActivity.getId();
|
||||
}
|
||||
|
||||
@ -89,24 +93,24 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
||||
*/
|
||||
private void updateSeckillProduct(SeckillActivityUpdateReqVO updateReqVO) {
|
||||
List<SeckillProductDO> seckillProductDOs = seckillProductMapper.selectListByActivityId(updateReqVO.getId());
|
||||
List<SeckillActivityBaseVO.Product> products = updateReqVO.getProducts();
|
||||
//List<SeckillActivityBaseVO.Product> products = updateReqVO.getProducts();
|
||||
|
||||
// 计算需要删除的数据
|
||||
List<Long> deleteIds = CollectionUtils.convertList(seckillProductDOs, SeckillProductDO::getId,
|
||||
seckillProductDO -> products.stream()
|
||||
.noneMatch(product -> SeckillActivityConvert.INSTANCE.isEquals(seckillProductDO, product)));
|
||||
if (CollUtil.isNotEmpty(deleteIds)) {
|
||||
seckillProductMapper.deleteBatchIds(deleteIds);
|
||||
}
|
||||
|
||||
// 计算需要新增的数据
|
||||
List<SeckillProductDO> newSeckillProductDOs = CollectionUtils.convertList(products,
|
||||
product -> SeckillActivityConvert.INSTANCE.convert(product).setActivityId(updateReqVO.getId()));
|
||||
newSeckillProductDOs.removeIf(product -> seckillProductDOs.stream()
|
||||
.anyMatch(seckillProduct -> SeckillActivityConvert.INSTANCE.isEquals(seckillProduct, product)));
|
||||
if (CollUtil.isNotEmpty(newSeckillProductDOs)) {
|
||||
seckillProductMapper.insertBatch(newSeckillProductDOs);
|
||||
}
|
||||
//List<Long> deleteIds = CollectionUtils.convertList(seckillProductDOs, SeckillProductDO::getId,
|
||||
// seckillProductDO -> products.stream()
|
||||
// .noneMatch(product -> SeckillActivityConvert.INSTANCE.isEquals(seckillProductDO, product)));
|
||||
//if (CollUtil.isNotEmpty(deleteIds)) {
|
||||
// seckillProductMapper.deleteBatchIds(deleteIds);
|
||||
//}
|
||||
//
|
||||
//// 计算需要新增的数据
|
||||
//List<SeckillProductDO> newSeckillProductDOs = CollectionUtils.convertList(products,
|
||||
// product -> SeckillActivityConvert.INSTANCE.convert(product).setActivityId(updateReqVO.getId()));
|
||||
//newSeckillProductDOs.removeIf(product -> seckillProductDOs.stream()
|
||||
// .anyMatch(seckillProduct -> SeckillActivityConvert.INSTANCE.isEquals(seckillProduct, product)));
|
||||
//if (CollUtil.isNotEmpty(newSeckillProductDOs)) {
|
||||
// seckillProductMapper.insertBatch(newSeckillProductDOs);
|
||||
//}
|
||||
|
||||
//全量更新当前活动商品的秒杀时段id列表(timeIds)
|
||||
seckillProductMapper.updateTimeIdsByActivityId(updateReqVO.getId(), updateReqVO.getConfigIds());
|
||||
@ -118,23 +122,25 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
||||
* @param id 秒杀活动编号
|
||||
* @param products 商品列表
|
||||
*/
|
||||
private void validateSeckillActivityProductConflicts(Long id, List<SeckillActivityBaseVO.Product> products) {
|
||||
private <T extends SeckillProductBaseVO> void validateSeckillActivityProductConflicts(Long id, List<T> products) {
|
||||
if (CollUtil.isEmpty(products)) {
|
||||
return;
|
||||
}
|
||||
// 校验秒杀商品是否存在
|
||||
List<SeckillProductDO> seckillProductDOs = seckillProductMapper
|
||||
.selectListBySkuIds(CollectionUtils.convertSet(products, SeckillActivityBaseVO.Product::getSkuId));
|
||||
.selectListBySkuIds(CollectionUtils.convertSet(products, T::getSkuId));
|
||||
if (CollUtil.isEmpty(seckillProductDOs)) {
|
||||
return;
|
||||
}
|
||||
// 获取秒杀商品所在活动
|
||||
List<SeckillActivityDO> seckillActivityDOs = seckillActivityMapper
|
||||
.selectBatchIds(CollectionUtils.convertSet(seckillProductDOs, SeckillProductDO::getActivityId));
|
||||
if (id != null) { // 排除自己这个活动
|
||||
if (id != null) {
|
||||
// 排除自己这个活动
|
||||
seckillActivityDOs.removeIf(item -> id.equals(item.getId()));
|
||||
}
|
||||
// 排除不满足 status 的活动
|
||||
List<Integer> statuses = asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus());
|
||||
seckillActivityDOs.removeIf(item -> !statuses.contains(item.getStatus()));
|
||||
// 排除关闭了的活动
|
||||
seckillActivityDOs.removeIf(item -> ObjectUtil.equal(item.getStatus(), CommonStatusEnum.DISABLE.getStatus()));
|
||||
// 如果非空,则说明冲突
|
||||
if (CollUtil.isNotEmpty(seckillActivityDOs)) {
|
||||
throw exception(SECKILL_ACTIVITY_SPU_CONFLICTS);
|
||||
@ -164,8 +170,7 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
||||
if (!statuses.contains(seckillActivity.getStatus())) {
|
||||
throw exception(SECKILL_ACTIVITY_DELETE_FAIL_STATUS_NOT_CLOSED_OR_END);
|
||||
}
|
||||
// 更新秒杀时段的秒杀活动数量
|
||||
seckillConfigService.seckillActivityCountDecr(seckillActivity.getConfigIds());
|
||||
|
||||
// 删除
|
||||
seckillActivityMapper.deleteById(id);
|
||||
}
|
||||
|
@ -76,4 +76,12 @@ public interface SeckillConfigService {
|
||||
* @return 秒杀时段列表
|
||||
*/
|
||||
List<SeckillConfigDO> getListAllSimple();
|
||||
|
||||
/**
|
||||
* 更新秒杀时段配置状态
|
||||
*
|
||||
* @param id id
|
||||
* @param status 状态
|
||||
*/
|
||||
void updateSeckillConfigStatus(Long id, Integer status);
|
||||
}
|
||||
|
@ -139,4 +139,16 @@ public class SeckillConfigServiceImpl implements SeckillConfigService {
|
||||
return seckillConfigMapper.selectList(SeckillConfigDO::getStatus, CommonStatusEnum.ENABLE.getStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSeckillConfigStatus(Long id, Integer status) {
|
||||
// 校验秒杀时段是否存在
|
||||
validateSeckillConfigExists(id);
|
||||
|
||||
SeckillConfigDO seckillConfigDO = new SeckillConfigDO();
|
||||
seckillConfigDO.setId(id);
|
||||
seckillConfigDO.setStatus(status);
|
||||
// 更新状态
|
||||
seckillConfigMapper.updateById(seckillConfigDO);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user