package com.red.circle.mq.business.model.event.pay;

import com.fasterxml.jackson.annotation.JsonIgnore;
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.util.Objects;
import lombok.Data;

/**
 * 产品信息.
 *
 * @author pengliang on 2021/8/21
 */
@Data
public class PurchaseProductEvent implements Serializable {

  private static final long serialVersionUID = 1L;

  /**
   * 主键标识.
   */
  @JsonSerialize(using = ToStringSerializer.class)
  private Long id;

  /**
   * 系统归属.
   */
  private String sysOrigin;

  /**
   * 产品id.
   */
  private String productId;

  /**
   * 包名.
   */
  private String productPackage;

  /**
   * 产品类型.
   */
  private String productType;

  /**
   * 描述.
   */
  private String description;

  /**
   * 分组名称.
   */
  private String groupName;

  /**
   * 产品单价.
   */
  private BigDecimal unitPrice;

  /**
   * 获得糖果数量.
   */
  private BigDecimal obtainCandy;

  /**
   * 奖励糖果.
   */
  private BigDecimal rewardCandy;

  /**
   * 折扣率.
   */
  private Integer discountRate;

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

  @JsonIgnore
  public BigDecimal getProductConfigCandy() {
    BigDecimal rewardQuantity = Objects.nonNull(rewardCandy) ? rewardCandy : BigDecimal.ZERO;
    BigDecimal obtainQuantity = Objects.nonNull(obtainCandy) ? obtainCandy : BigDecimal.ZERO;
    return obtainQuantity.add(rewardQuantity);
  }

}
