package com.red.circle.other.infra.database.mongo.entity.game.egg;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Objects;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

/**
 * 砸金蛋配置.
 *
 * @author pengliang on 2022/8/25
 */
@Data
@Accessors(chain = true)
@Document("game_egg_stock_config")
public class GameEggStockConfig implements Serializable {

  private static final long serialVersionUID = 1L;

  /**
   * 记录ID.
   */
  @Id
  @JsonSerialize(using = ToStringSerializer.class)
  private Long id;

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

  /**
   * 排序.
   */
  private Integer sort;

  /**
   * 资源id.
   */
  @JsonSerialize(using = ToStringSerializer.class)
  private Long sourceId;

  /**
   * 资源类型.
   */
  private String sourceType;

  /**
   * 资源详细类型.
   */
  private String sourceDetailType;

  /**
   * 奖励奖数量.
   */
  private Integer prizeQuantity;

  /**
   * 资源封面.
   */
  private String sourceCover;

  /**
   * 资源地址.
   */
  private String sourceUrl;

  /**
   * 库存数量, -1无限制.
   */
  private Long stockQuantity;

  /**
   * 已消耗库存.
   */
  private Long consumeStockQuantity;

  /**
   * 兑换需要碎片.
   */
  private Integer fragmentsSize;

  /**
   * 兑换碎片价值.
   */
  private BigDecimal fragmentsAmount;

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

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

  public String content() {
    return Objects.toString(Objects.isNull(getSourceId())
        ? getPrizeQuantity()
        : getSourceId());
  }
}
