package com.ycwl.basic.model.mobile.order;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.math.BigDecimal;

@Data
public class IsBuyRespVO {
    private boolean buy;
    private boolean free;
    private boolean share = false;
    private Long orderId;
    private int goodsType;
    private Long goodsId;
    private BigDecimal origPrice = BigDecimal.ZERO;
    private Integer couponId;
    private Integer couponRecordId;
    private BigDecimal couponPrice = BigDecimal.ZERO;
    private BigDecimal slashPrice;

    @JsonProperty("price")
    public BigDecimal getPrice() {
        if (origPrice == null) {
            return BigDecimal.ZERO;
        }
        if (couponPrice == null) {
            return origPrice;
        }
        return origPrice.subtract(couponPrice);
    }
    @JsonProperty("discountPrice")
    public BigDecimal getDiscountPrice() {
        if (slashPrice == null) {
            return BigDecimal.ZERO;
        }
        if (slashPrice.compareTo(BigDecimal.ZERO) <= 0) {
            return BigDecimal.ZERO;
        }
        return slashPrice.subtract(origPrice);
    }
}
