package shop.alien.entity.store;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;

/**
 * <p>
 * 优惠券表
 * </p>
 *
 * @author ssk
 * @since 2025-02-07
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "LifeDiscountCoupon对象", description = "优惠券表")
public class LifeDiscountCoupon extends Model<LifeDiscountCoupon> {

    private static final long serialVersionUID = 1L;

    /** 优惠券状态：草稿 */
    public static final int COUPON_STATUS_DRAFT = 0;
    /** 优惠券状态：正式 */
    public static final int COUPON_STATUS_FORMAL = 1;
    /** 优惠券状态：已失效（如店铺注销冷静期结束） */
    public static final int COUPON_STATUS_INVALID = 2;

    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty(value = "商铺id")
    @TableField("store_id")
    private String storeId;

    @ApiModelProperty(value = "券名称")
    @TableField("name")
    private String name;

    @ApiModelProperty(value = "面值")
    @TableField(value = "nominal_value", insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
    private BigDecimal nominalValue;

    @ApiModelProperty(value = "有效期（天）")
    @TableField("expiration_date")
    private Integer expirationDate;

    @ApiModelProperty(value = "领取后是否长期有效：0-否，1-是")
    @TableField("long_term_valid")
    private Integer longTermValid;

    @ApiModelProperty(value = "开始日期")
    @TableField(value = "start_date", updateStrategy = FieldStrategy.IGNORED)
    private LocalDate startDate;

    @ApiModelProperty(value = "结束日期")
    @TableField(value = "end_date", updateStrategy = FieldStrategy.IGNORED)
    private LocalDate endDate;

    @ApiModelProperty(value = "库存（优惠券数量）")
    @TableField(value = "single_qty")
    private Integer singleQty;

    @ApiModelProperty(value = "发行数量是否不限：0-否，1-是")
    @TableField("unlimited_qty")
    private Integer unlimitedQty;

    @ApiModelProperty(value = "补充说明")
    @TableField("supplementary_instruction")
    private String supplementaryInstruction;

    @ApiModelProperty(value = "领取状态：0：关闭领取，1：开启领取")
    @TableField("get_status")
    private Integer getStatus;

    @ApiModelProperty(value = "限制领取数量")
    @TableField("restricted_quantity")
    private Integer restrictedQuantity;

    @ApiModelProperty(value = "最低消费")
    @TableField(value = "minimum_spending_amount", insertStrategy = FieldStrategy.IGNORED, updateStrategy = FieldStrategy.IGNORED)
    private BigDecimal minimumSpendingAmount;

    @ApiModelProperty(value = "类型   1-优惠券  2-红包 3-平台优惠券 4代金券")
    @TableField("type")
    private Integer type;

    @ApiModelProperty(value = "收藏可领（0：否，1：是）")
    @TableField("attention_can_received")
    private Integer attentionCanReceived;

    @ApiModelProperty(value = "删除状态")
    @TableField("delete_flag")
    @TableLogic
    private Integer deleteFlag;

    @ApiModelProperty(value = "创建时间")
    @TableField(value = "created_time", fill = FieldFill.INSERT)
    private Date createdTime;

    @ApiModelProperty(value = "更新时间")
    @TableField(value = "updated_time", fill = FieldFill.INSERT_UPDATE)
    private Date updatedTime;

    @ApiModelProperty(value = "创建人ID")
    @TableField(value = "created_user_id", fill = FieldFill.INSERT)
    private Integer createdUserId;

    @ApiModelProperty(value = "修改人ID")
    @TableField(value = "updated_user_id", fill = FieldFill.INSERT_UPDATE)
    private Integer updatedUserId;

    @ApiModelProperty(value = "指定天数")
    @TableField("specified_day")
    private String specifiedDay;

    @ApiModelProperty(value = "是否可以叠加其他优惠券使用")
    @TableField("is_overlay")
    private Integer isOverlay;

    @ApiModelProperty(value = "是否通用")
    @TableField("is_common")
    private Integer isCommon;

    @ApiModelProperty(value = "适用范围，0，适用，1不适用")
    @TableField("application_scope")
    private Integer applicationScope;

    @ApiModelProperty(value = "适用范围内容")
    @TableField("application_scope_value")
    private String applicationScopeValue;

    @ApiModelProperty(value = "开始领取时间")
    @TableField(value = "begin_get_date", fill = FieldFill.INSERT_UPDATE)
    private LocalDate beginGetDate;

    @ApiModelProperty(value = "结束领取时间")
    @TableField(value = "end_get_date", fill = FieldFill.INSERT_UPDATE)
    private LocalDate endGetDate;

    @ApiModelProperty(value = "自定义领取规则数量")
    @TableField("claim_rule_customize_value")
    private Integer claimRuleCustomizeValue;

    @ApiModelProperty(value = "优惠券状态：0-草稿，1-正式，2-已失效")
    @TableField("coupon_status")
    private Integer couponStatus;

    @ApiModelProperty(value = "有效期")
    @TableField("valid_date")
    private LocalDate validDate;

    @ApiModelProperty(value = "优惠券类型：1-满减券，2-折扣券")
    @TableField("coupon_type")
    private Integer couponType;

    @ApiModelProperty(value = "折扣率（0-100，用于折扣券，例如80表示8折）")
    @TableField("discount_rate")
    private BigDecimal discountRate;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}
