package com.red.circle.other.app.dto.clientobject.room;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author pengliang on 2021/3/2
 */
@Data
@Accessors(chain = true)
public class RoomRewardMappingCO implements Serializable {

  @Serial
  private static final long serialVersionUID = -1L;

  /**
   * 阶梯.
   */
  private String ladder;

  /**
   * 提成率.
   */
  private Integer radio;

  /**
   * 奖励房间阶梯.
   */
  public static List<RoomRewardMappingCO> newRewardLadder() {
    return Arrays.asList(
        new RoomRewardMappingCO().setLadder("/").setRadio(5),
        new RoomRewardMappingCO().setLadder("10M").setRadio(6),
        new RoomRewardMappingCO().setLadder("30M").setRadio(7),
        new RoomRewardMappingCO().setLadder("100M").setRadio(8),
        new RoomRewardMappingCO().setLadder("500M").setRadio(9)
    );
  }

  /**
   * 计算当前比率.
   *
   * @param totalQuantity 数额
   * @return 比率
   */
  public static Integer calculateCurrentRatio(BigDecimal totalQuantity) {
    if (totalQuantity.compareTo(BigDecimal.valueOf(1000000 * 10)) < 0) {
      return 5;
    }
    if (totalQuantity.compareTo(BigDecimal.valueOf(1000000 * 30)) < 0) {
      return 6;
    }
    if (totalQuantity.compareTo(BigDecimal.valueOf(1000000 * 100)) < 0) {
      return 7;
    }

    if (totalQuantity.compareTo(BigDecimal.valueOf(1000000 * 500)) < 0) {
      return 8;
    }
    return 9;
  }

}
