package com.red.circle.other.app.dto.cmd.game;


import com.red.circle.common.business.dto.cmd.AppExtCommand;
import com.red.circle.other.inner.enums.game.RedPacketEnum;
import com.red.circle.other.inner.enums.game.RedPacketScopeEnum;
import java.math.BigDecimal;
import java.math.RoundingMode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 发送红包.
 *
 * @author pengshigang on 2022/10/14
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class SendRedPacketCmd extends AppExtCommand {

  /**
   * 红包类型:USER / ROOM
   */
  private RedPacketEnum type;

  /**
   * 关联id.
   */
  private Long relationId;

  /**
   * 金额.
   */
  private BigDecimal amount;

  /**
   * 数量(type是USER则填1).
   */
  private Integer quantity;

  /**
   * 领取人用户id(type是USER时,领取人字段才需要传值).
   */
  private Long receiverId;

  /**
   * 红包范围类型
   */
  @Deprecated
  private RedPacketScopeEnum redPacketScopeEnum;

  /**
   * 红包所属国家编码(红包范围类型为国家时才有值)
   */
  @Deprecated
  private String countryCode;


  public Integer getAfterTaxPrice(double taxRate) {
    return amount
        .subtract(amount.multiply(BigDecimal.valueOf(taxRate)))
        .setScale(0, RoundingMode.DOWN)
        .intValue();
  }

}
