package com.red.circle.order.infra.database.rds.entity.pay;

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 com.red.circle.tool.core.text.StringUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 应用商品.
 * </p>
 *
 * @author pengshigang
 * @since 2021-12-08
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("sys_pay_application_commodity")
public class PayApplicationCommodity extends TimestampBaseEntity {

  private static final long serialVersionUID = 1L;

  /**
   * 主键标识.
   */
  @TableId("id")
  private Long id;

  /**
   * 区域id.
   */
  @TableField("region_id")
  private String regionId;

  /**
   * 应用id.
   */
  @TableField("application_id")
  private Long applicationId;

  /**
   * 开通支付国家.
   */
  @TableField("pay_country_id")
  private Long payCountryId;

  /**
   * 类型.
   */
  @TableField("type")
  private String type;

  /**
   * 内容.
   */
  @TableField("content")
  private String content;

  /**
   * 奖励内容.
   */
  @TableField("award_content")
  private String awardContent;

  /**
   * 美元金额.
   */
  @TableField("amount_usd")
  private BigDecimal amountUsd;

  /**
   * 0.下架 1.上架.
   */
  @TableField("is_shelf")
  private Boolean shelf;

  public BigDecimal getObtainGoldsQuantity() {
    return new BigDecimal(StringUtils.isBlankOrElse(this.content, "0")).add(
        new BigDecimal(StringUtils.isBlankOrElse(this.awardContent, "0"))
            .setScale(0, RoundingMode.DOWN));
  }
}
