package com.ycwl.basic.model.pc.coupon.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;

@Data
@TableName("coupon")
public class CouponEntity {
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    private Long scenicId;
    
    // 新增优惠券名称字段
    private String name;
    
    /**
     * 优惠券类别，0：普通优惠券；1：第一次推送；2：第二次；3：第三次
     */
    private Integer type;
    /**
     * 价格配置ID，逗号分隔字符串
     */
    private String configIds;
    /**
     * 0降价，1打折
     */
    private Integer discountType;
    private BigDecimal discountPrice;
    /**
     * 状态：0不开启；1开启
     */
    private Integer status;
    private Date createAt;

    public BigDecimal calculateDiscountPrice(BigDecimal originalPrice) {
        if (discountType == 0) {
            return discountPrice;
        } else {
            return originalPrice.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN).multiply(discountPrice);
        }
    }
}