package com.bizzan.bitrade.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;

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

/**
 * 质押流水，记录质押和解冻释放的每笔流水明细
 *
 * @author auto
 * @date 2026-05-17
 */
@Entity
@Data
@Table(name = "staking_record")
public class StakingRecord {

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

    /** 用户ID */
    @Column(nullable = false, columnDefinition = "bigint comment '用户ID'")
    private Long memberId;

    /** 关联质押订单ID */
    @Column(columnDefinition = "bigint comment '质押订单ID'")
    private Long orderId;

    /** 流水币种 */
    @Column(length = 50, columnDefinition = "varchar(50) comment '币种'")
    private String coinUnit;

    /** 流水金额 */
    @Column(columnDefinition = "decimal(26,8) default 0 comment '金额'")
    private BigDecimal amount = BigDecimal.ZERO;

    /**
     * 流水类型
     * 0=质押（用户主动质押，余额转入冻结）
     * 1=解冻释放（定时任务自动将冻结释放到余额）
     */
    @Column(columnDefinition = "int default 0 comment '流水类型：0质押 1解冻释放'")
    private Integer type = 0;

    /** 备注 */
    @Column(length = 500, columnDefinition = "varchar(500) comment '备注'")
    private String remark;

    /** 创建时间 */
    @CreationTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
}
