package com.bizzan.bitrade.entity;

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

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

/**
 * 质押钱包，独立存储用户各币种的质押余额，与资金账户 member_wallet 完全隔离
 *
 * @author auto
 * @date 2026-05-20
 */
@Entity
@Data
@Table(name = "staking_wallet",
        uniqueConstraints = {@UniqueConstraint(columnNames = {"member_id", "coin_unit"})})
public class StakingWallet {

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

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

    /** 质押币种 */
    @Column(name = "coin_unit", nullable = false, length = 50, columnDefinition = "varchar(50) comment '质押币种'")
    private String coinUnit;

    /**
     * 锁定余额（质押中，锁定期内不可提取，解锁后直接归还资金账户）
     */
    @Column(columnDefinition = "decimal(26,8) not null default 0 comment '锁定余额，质押中不可用'")
    private BigDecimal lockedBalance = BigDecimal.ZERO;

    /** 创建时间 */
    @CreationTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(name = "create_time", columnDefinition = "datetime comment '创建时间'")
    private Date createTime;

    /** 最后更新时间 */
    @UpdateTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(name = "update_time", columnDefinition = "datetime comment '最后更新时间'")
    private Date updateTime;
}
