165 lines
4.4 KiB
Java
165 lines
4.4 KiB
Java
package com.org.flashsalesystem.dto;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.Data;
|
|
import lombok.NoArgsConstructor;
|
|
|
|
import javax.validation.constraints.DecimalMin;
|
|
import javax.validation.constraints.Max;
|
|
import javax.validation.constraints.Min;
|
|
import javax.validation.constraints.NotNull;
|
|
import java.math.BigDecimal;
|
|
import java.time.LocalDateTime;
|
|
|
|
/**
|
|
* 限时活动数据传输对象
|
|
*/
|
|
@Data
|
|
@NoArgsConstructor
|
|
@AllArgsConstructor
|
|
public class FlashSaleDTO {
|
|
|
|
private Long id;
|
|
private Long productId;
|
|
private String productName;
|
|
private String productImageUrl;
|
|
private BigDecimal originalPrice;
|
|
private BigDecimal flashPrice;
|
|
private Integer flashStock;
|
|
private Integer remainingStock;
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
private LocalDateTime startTime;
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
private LocalDateTime endTime;
|
|
|
|
private Integer status;
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
private LocalDateTime createdAt;
|
|
|
|
// 活动状态描述
|
|
private String statusDescription;
|
|
// 是否可以参与限时活动
|
|
private Boolean canParticipate;
|
|
// 距离开始时间(毫秒)
|
|
private Long timeToStart;
|
|
// 距离结束时间(毫秒)
|
|
private Long timeToEnd;
|
|
|
|
/**
|
|
* 创建限时活动DTO
|
|
*/
|
|
@Data
|
|
@NoArgsConstructor
|
|
@AllArgsConstructor
|
|
public static class CreateDTO {
|
|
@NotNull(message = "商品ID不能为空")
|
|
private Long productId;
|
|
|
|
@NotNull(message = "活动价格不能为空")
|
|
@DecimalMin(value = "0.01", message = "活动价格必须大于0")
|
|
private BigDecimal flashPrice;
|
|
|
|
@Min(value = 1, message = "活动库存必须大于0")
|
|
private Integer flashStock;
|
|
|
|
@NotNull(message = "开始时间不能为空")
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
private LocalDateTime startTime;
|
|
|
|
@NotNull(message = "结束时间不能为空")
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
private LocalDateTime endTime;
|
|
}
|
|
|
|
/**
|
|
* 更新限时活动DTO
|
|
*/
|
|
@Data
|
|
@NoArgsConstructor
|
|
@AllArgsConstructor
|
|
public static class UpdateDTO {
|
|
@DecimalMin(value = "0.01", message = "活动价格必须大于0")
|
|
private BigDecimal flashPrice;
|
|
|
|
@Min(value = 1, message = "活动库存必须大于0")
|
|
private Integer flashStock;
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
private LocalDateTime startTime;
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
private LocalDateTime endTime;
|
|
|
|
@Min(value = 1, message = "状态值无效")
|
|
@Max(value = 3, message = "状态值无效")
|
|
private Integer status;
|
|
}
|
|
|
|
/**
|
|
* 限时活动参与DTO
|
|
*/
|
|
@Data
|
|
@NoArgsConstructor
|
|
@AllArgsConstructor
|
|
public static class ParticipateDTO {
|
|
@NotNull(message = "限时活动ID不能为空")
|
|
private Long flashSaleId;
|
|
|
|
@Min(value = 1, message = "购买数量必须大于0")
|
|
private Integer quantity = 1;
|
|
|
|
// 用户地址信息(可选)
|
|
private String address;
|
|
private String phone;
|
|
}
|
|
|
|
/**
|
|
* 限时活动查询DTO
|
|
*/
|
|
@Data
|
|
@NoArgsConstructor
|
|
@AllArgsConstructor
|
|
public static class QueryDTO {
|
|
private Integer status; // 活动状态
|
|
private Long productId; // 商品ID
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
private LocalDateTime startTime;
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
private LocalDateTime endTime;
|
|
private Integer page = 0;
|
|
private Integer size = 10;
|
|
private String sortBy = "startTime";
|
|
private String sortDirection = "asc";
|
|
}
|
|
|
|
/**
|
|
* 限时活动结果DTO
|
|
*/
|
|
@Data
|
|
@NoArgsConstructor
|
|
@AllArgsConstructor
|
|
public static class ResultDTO {
|
|
private Boolean success;
|
|
private String message;
|
|
private Long orderId;
|
|
private Long flashSaleId;
|
|
private Long productId;
|
|
private String productName;
|
|
private Integer quantity;
|
|
private BigDecimal totalPrice;
|
|
|
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
private LocalDateTime orderTime;
|
|
|
|
// 排队信息(如果需要排队)
|
|
private Integer queuePosition;
|
|
private Long estimatedWaitTime;
|
|
}
|
|
}
|