package com.bizzan.bitrade.entity;

import lombok.Data;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

@Data
@Entity
@Table(name = "experience_gift_product")
public class ExperienceGiftProduct {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /** 产品名称（前端展示，如"注册体验金50U"） */
    @Column(name = "name", nullable = false, length = 64)
    private String name;

    /** 体验金面额（USDT） */
    @Column(name = "amount", nullable = false)
    private BigDecimal amount;

    /** 有效期（天），从发放时刻起算 */
    @Column(name = "validity_days", nullable = false)
    private Integer validityDays;

    /** 发放总量（张），0=不限 */
    @Column(name = "total_quantity", nullable = false)
    private Integer totalQuantity = 0;

    /** 单人领取上限（张） */
    @Column(name = "per_user_limit", nullable = false)
    private Integer perUserLimit = 1;

    /** 单张体验金盈利上限（USDT） */
    @Column(name = "max_profit_per_card", nullable = false)
    private BigDecimal maxProfitPerCard;

    /** 领取方式 */
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "grant_type", nullable = false)
    private ExperienceGiftGrantType grantType;

    /** 触发规则（grant_type=SYSTEM_TRIGGER 时有效） */
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "trigger_type")
    private ExperienceGiftTriggerType triggerType;

    /** 注册触发：最小首充金额（USDT），NULL=不限 */
    @Column(name = "min_recharge_amount")
    private BigDecimal minRechargeAmount;

    /** 邀请触发：被邀请人最小开仓价值（USDT） */
    @Column(name = "min_open_value")
    private BigDecimal minOpenValue;

    /** 邀请触发：被邀请人最短持仓时长（分钟） */
    @Column(name = "min_hold_minutes")
    private Integer minHoldMinutes;

    /** 活动生效开始时间，NULL=立即生效 */
    @Column(name = "activity_start_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date activityStartTime;

    /** 活动结束时间，NULL=永久有效 */
    @Column(name = "activity_end_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Date activityEndTime;

    /** 已发放张数（实时统计） */
    @Column(name = "issued_count", nullable = false)
    private Integer issuedCount = 0;

    /** 产品状态 */
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "status", nullable = false)
    private ExperienceGiftProductStatus status = ExperienceGiftProductStatus.DISABLED;

    /** 创建管理员ID */
    @Column(name = "created_by", nullable = false)
    private Long createdBy;

    @Column(name = "remark", length = 255)
    private String remark;

    @Column(name = "created_at", nullable = false, updatable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdAt;

    @Column(name = "updated_at", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date updatedAt;
}
