package com.red.circle.console.app.dto.clienobject.user;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Timestamp;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * <p>
 * 用户货运账户.
 * </p>
 *
 * @author pengliang
 * @since 2021-07-07
 */
@Data
@Accessors(chain = true)
public class UserFreightBalanceCO implements Serializable {

  @Serial
  private static final long serialVersionUID = 1L;

  /**
   * 主键标识.
   */
  @JsonSerialize(using = ToStringSerializer.class)
  private Long id;

  /**
   * 归属平台.
   */
  private String sysOrigin;

  /**
   * 用户id.
   */
  @JsonSerialize(using = ToStringSerializer.class)
  private Long userId;

  /**
   * 获得糖果.
   */
  private BigDecimal earnPoints;

  /**
   * 消费糖果.
   */
  private BigDecimal consumptionPoints;

  /**
   * 创建时间.
   */
  private Timestamp createTime;

  /**
   * 修改时间.
   */
  private Timestamp updateTime;

  /**
   * 0.未关闭 1.已关闭.
   */
  private Boolean close;

  /**
   * 0.显示 1.不显示.
   */
  private Boolean display;

  /**
   * H5显示开关：0-不显示，1-显示.
   */
  private Boolean h5Display;


  /**
   * 是否经销商 0.否 1.是.
   */
  private Boolean dealer;

  /**
   * 是否超级经销商 0.否 1.是.
   */
  private Boolean superDealer;

  /**
   * 授权卖家数量.
   */
  private Integer sellerQuantity;

  /**
   * 已授权卖家数量.
   */
  private Long realSellerQuantity;

  /**
   * 支持的国家（多个用逗号分隔）.
   */
  private String supportedCountries;

  /**
   * 联系方式.
   */
  private String contactInfo;

  /**
   * 用户资料信息.
   */
  private UserProfileDTO userBaseInfo;

  public BigDecimal getBalance() {
    return earnPoints.subtract(consumptionPoints).setScale(2, RoundingMode.DOWN);
  }
}
