package com.snack.server.module.coupon.dto.req;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 创建 / 更新优惠券模板
 */
@Data
@Schema(description = "创建/更新优惠券模板")
public class CouponSaveReq implements Serializable {

    @Schema(description = "优惠券 ID（更新时必填）")
    private Long id;

    @NotBlank(message = "优惠券名称不能为空")
    @Size(max = 100, message = "优惠券名称最长 100 字")
    @Schema(description = "优惠券名称", example = "满 99 减 10")
    private String name;

    @NotNull(message = "优惠券类型不能为空")
    @Schema(description = "类型：0-满减券 1-折扣券 2-无门槛券", example = "0")
    private Integer type;

    @NotNull(message = "优惠金额/折扣率不能为空")
    @DecimalMin(value = "0.01", message = "优惠金额/折扣率必须大于 0")
    @Schema(description = "满减面值 / 折扣率（0.85 表示 8.5 折）", example = "10.00")
    private BigDecimal amount;

    @Schema(description = "最低使用金额（0 表示无门槛）", example = "99.00")
    private BigDecimal minAmount = BigDecimal.ZERO;

    @Schema(description = "折扣券最高抵扣金额", example = "50.00")
    private BigDecimal maxDiscount = BigDecimal.ZERO;

    @NotNull(message = "发放总量不能为空")
    @Schema(description = "发放总量（-1 表示不限量）", example = "1000")
    private Integer total;

    @Schema(description = "每人限领数量", example = "1")
    private Integer perLimit = 1;

    @Schema(description = "状态：0-未上线 1-已上线 2-已结束", example = "1")
    private Integer status = 1;

    @NotNull(message = "领取开始时间不能为空")
    @Schema(description = "领取开始时间")
    private LocalDateTime startTime;

    @NotNull(message = "领取截止时间不能为空")
    @Schema(description = "领取截止时间")
    private LocalDateTime endTime;

    @Schema(description = "领取后有效天数（为空则使用领取截止时间）", example = "30")
    private Integer validDays;

    @Size(max = 500, message = "使用说明最长 500 字")
    @Schema(description = "使用说明")
    private String description;
}
