package com.red.circle.other.infra.database.rds.entity.live;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.red.circle.framework.mybatis.entity.TimestampBaseEntity;
import java.io.Serial;
import java.math.BigDecimal;
import java.math.RoundingMode;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 房间贡献余额.
 * </p>
 *
 * @author pengliang
 * @since 2021-03-01
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("room_contribution_balance")
public class RoomContributionBalance extends TimestampBaseEntity {

  @Serial
  private static final long serialVersionUID = 1L;

  /**
   * 主键标识.
   */
  @TableId(value = "id", type = IdType.ASSIGN_ID)
  private Long id;

  /**
   * 用户id.
   */
  @TableField("user_id")
  private Long userId;

  /**
   * 房间id.
   */
  @TableField("room_id")
  private Long roomId;

  /**
   * 总额数量.
   */
  @TableField("total_quantity")
  private BigDecimal totalQuantity;

  /**
   * 提取数量.
   */
  @TableField("withdraw_quantity")
  private BigDecimal withdrawQuantity;

  /**
   * 计算余额.
   */
  public BigDecimal calculationBalance() {
    return totalQuantity.subtract(withdrawQuantity).setScale(2, RoundingMode.DOWN);
  }

}
