package com.bizzan.bitrade.dto;

import com.bizzan.bitrade.entity.StakingOrder;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

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

/**
 * 质押订单（管理端列表），含今日是否已领取空投
 */
@Data
public class StakingOrderVO {

    private Long id;
    private Long memberId;
    private Long configId;
    private String coinUnit;
    private BigDecimal amount;
    private BigDecimal releasedAmount;
    private Integer status;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date stakingTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date unlockTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date lastReleaseTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    /**
     * 今日是否已发放空投（仅质押中 status=0 时查询；其他状态为 null）
     */
    private Boolean todayAirdropDistributed;

    /**
     * 今日是否可发放空投（仅质押中且今日未发放时为 true，其余为 false）
     */
    private Boolean canDistributeAirdropToday;

    public static StakingOrderVO from(StakingOrder order, Boolean todayAirdropDistributed, Boolean canDistributeAirdropToday) {
        StakingOrderVO vo = new StakingOrderVO();
        vo.setId(order.getId());
        vo.setMemberId(order.getMemberId());
        vo.setConfigId(order.getConfigId());
        vo.setCoinUnit(order.getCoinUnit());
        vo.setAmount(order.getAmount());
        vo.setReleasedAmount(order.getReleasedAmount());
        vo.setStatus(order.getStatus());
        vo.setStakingTime(order.getStakingTime());
        vo.setUnlockTime(order.getUnlockTime());
        vo.setLastReleaseTime(order.getLastReleaseTime());
        vo.setCreateTime(order.getCreateTime());
        vo.setTodayAirdropDistributed(todayAirdropDistributed);
        vo.setCanDistributeAirdropToday(canDistributeAirdropToday);
        return vo;
    }
}
