package com.bizzan.bitrade.entity;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.Table;

import org.hibernate.annotations.CreationTimestamp;

import lombok.Data;

/**
 * 现货账户每日持仓快照
 * 每天零点记录各用户各币种的持仓数量和当时价格，用于计算今日盈亏
 */
@Entity
@Data
@Table(name = "spot_wallet_snapshot", indexes = {
    @Index(name = "idx_sws_member_date", columnList = "memberId,snapshotDate")
})
public class SpotWalletSnapshot {

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

    private Long memberId;

    /** 币种单位，如 "BTC"、"ETH"、"USDT" */
    private String coinUnit;

    /** 快照时的持仓数量（balance + frozenBalance） */
    private BigDecimal quantity;

    /** 快照时的 USDT 单价（USDT 本身为 1） */
    private BigDecimal price;

    @CreationTimestamp
    private Date snapshotDate;
}
