package com.sonic.lion.domain.entity;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * account_buff
 *
 * @author
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "account_buff", autoResultMap = true)
public class AccountBuff implements Serializable {

    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 用户id
     */
    private Long uid;

    /**
     * 可消费金额
     */
    private Long balance;

    /**
     * 可提现收入
     */
    private Long withdrawableIncome;

    /**
     * 待入账收入
     */
    private Long awaitingIncome;

    /**
     * 冻结收入
     */
    private Long frozenIncome;

    /**
     * 冻结余额
     */
    private Long frozenBalance;

    /**
     * 总充值
     */
    private long rechargeTotal;

    /**
     * 在途的 提现金额
     */
    private Long withdrawOnGoing;

    private Status status;

    private LocalDateTime createTime;

    private LocalDateTime editTime;

    private static final long serialVersionUID = 1L;

    @Getter
    public enum Status {

        ENABLE(0, "ENABLE"),

        DISABLE(1, "DISABLE"),
        ;

        private final int value;

        private final String desc;

        Status(int value, String desc) {
            this.value = value;
            this.desc = desc;
        }
    }

    /**
     * 获取总金额
     *
     * @return
     */
    public long getTotalAmount() {
        return this.getBalance() + this.getWithdrawableIncome() + this.getAwaitingIncome() + this.getFrozenIncome();
    }
}