package com.gxwebsoft.shop.entity;

import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDate;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import java.util.List;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 优惠券
 *
 * @author 科技小王子
 * @since 2025-08-11 09:41:38
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Schema(name = "ShopCoupon对象", description = "优惠券")
public class ShopCoupon implements Serializable {
    private static final long serialVersionUID = 1L;

    @Schema(description = "id")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @Schema(description = "优惠券名称")
    private String name;

    @Schema(description = "优惠券描述")
    private String description;

    @Schema(description = "优惠券类型(10满减券 20折扣券 30免费劵)")
    private Integer type;

    @Schema(description = "满减券-减免金额")
    @JsonSerialize(using = ToStringSerializer.class)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private BigDecimal reducePrice;

    @Schema(description = "折扣券-折扣率(0-100)")
    private Integer discount;

    @Schema(description = "最低消费金额")
    @JsonSerialize(using = ToStringSerializer.class)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private BigDecimal minPrice;

    @Schema(description = "到期类型(10领取后生效 20固定时间)")
    private Integer expireType;

    @Schema(description = "领取后生效-有效天数")
    private Integer expireDay;

    @Schema(description = "有效期开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;

    @Schema(description = "有效期结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;

    @Schema(description = "适用范围(10全部商品 20指定商品 30指定分类)")
    private Integer applyRange;

    @Schema(description = "适用范围配置(json格式)")
    private String applyRangeConfig;

    @Schema(description = "是否过期(0未过期 1已过期)")
    private Integer isExpire;

    @Schema(description = "排序(数字越小越靠前)")
    private Integer sortNumber;

    @Schema(description = "状态, 0正常, 1禁用")
    private Integer status;

    @Schema(description = "是否删除, 0否, 1是")
    @TableLogic
    private Integer deleted;

    @Schema(description = "创建用户ID")
    private Integer userId;

    @Schema(description = "租户id")
    private Integer tenantId;

    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @Schema(description = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    @Schema(description = "发放总数量(-1表示无限制)")
    private Integer totalCount;

    @Schema(description = "已发放数量")
    private Integer issuedCount;

    @Schema(description = "每人限领数量(-1表示无限制)")
    private Integer limitPerUser;

    @Schema(description = "是否启用(0禁用 1启用)")
    private Integer enabled;

    @Schema(description = "发放对象(0全部用户 1仅会员 2仅非会员 3指定用户)")
    private Integer receiveTarget;

    @Schema(description = "指定用户ID列表(JSON数组格式)，receiveTarget=3时使用")
    private String receiveUserIds;

    @Schema(description = "场地使用券-场地类型")
    private Integer venueType;

    @Schema(description = "场地使用券-指定场地ID")
    private Integer venueId;

    @Schema(description = "场地使用券-可用次数(-1表示无限制)")
    private Integer useCount;

    @Schema(description = "场地使用券-使用时长(分钟)")
    private Integer useDuration;

    @TableField(exist = false)
    private List<ShopCouponApplyItem> couponApplyItemList;

    @TableField(exist = false)
    private List<ShopCouponApplyCate> couponApplyCateList;

    @TableField(exist = false)
    private Boolean hasTake;

    @TableField(exist = false)
    private Integer userTakeNum;

    @TableField(exist = false)
    private Integer userUseNum;

    @TableField(exist = false)
    private Integer receiveNum;
}
