package com.qs.mp.admin.domain.vo;

import com.qs.mp.admin.domain.TicketBox;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import java.util.Objects;

import com.qs.mp.channel.domain.Channel;
import com.qs.mp.channel.domain.vo.ChannelVO;
import com.qs.mp.user.domain.vo.TicketAwardsLabelVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 票组出参类
 * @author zhongcp
 * @Date 2022/3/5
 */
@Data
@ApiModel(value = "票组出参类")
public class TicketBoxVO extends TicketBox {

  @ApiModelProperty("经销商信息")
  List<Channel> channelList;

  @ApiModelProperty("奖级标签信息列表")
  List<TicketAwardsLabelVO> ticketAwardsLabelList;

  // 奖品列表（小程序端显示）
  @ApiModelProperty("奖品列表（小程序端显示）")
  List<TicketAwardsPrizeVO> prizeList;

  // 奖级列表（后台显示）
  @ApiModelProperty("奖级列表（后台显示）")
  List<TicketAwardsVO> awardsList;

  @ApiModelProperty("经销商分佣百分比")
  private BigDecimal channelCommRate;

  @ApiModelProperty("分佣金额")
  public Integer getSaleCommPrice() {
    if (Objects.isNull(super.getSaleCommRate()) || Objects.isNull(super.getSalePrice()) || Objects.isNull(this.channelCommRate)) {
      return 0;
    }
    return BigDecimal.valueOf(super.getSalePrice()).multiply(super.getSaleCommRate()).multiply(this.channelCommRate).divide(BigDecimal.valueOf(10000), 0).intValue();

  }
}
