package com.jeesharp.business.modules.coupon.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.jeesharp.framework.mybatis.core.dataobject.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 优惠券模板实体，映射表 {@code app_coupon_template}，定义券规则与发放配额。
 *
 * @author jeesharp
 * @since 2026-05-07
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("app_coupon_template")
@Schema(description = "优惠券模板")
public class CouponTemplate extends BaseEntity<CouponTemplate> {

    @Schema(description = "优惠券编码")
    private String couponCode;

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

    /**
     * @see com.jeesharp.business.modules.coupon.enums.CouponTemplateTypeEnum
     */
    @Schema(description = "优惠券类型：1-满减 2-折扣 3-无门槛 4-兑换")
    private Integer couponType;

    @Schema(description = "优惠券图片")
    private String couponImage;

    /**
     * @see com.jeesharp.business.modules.coupon.enums.CouponDiscountTypeEnum
     */
    @Schema(description = "优惠方式：1-金额 2-折扣")
    private Integer discountType;

    @Schema(description = "优惠值")
    private BigDecimal discountValue;

    @Schema(description = "最低消费金额")
    private BigDecimal minConsumeAmount;

    @Schema(description = "最大优惠金额（折扣券）")
    private BigDecimal maxDiscountAmount;

    /**
     * @see com.jeesharp.business.modules.coupon.enums.CouponUseScopeEnum
     */
    @Schema(description = "使用范围：1-全场 2-商品 3-分类 4-品牌")
    private Integer useScope;

    @Schema(description = "使用场景编号")
    private String sceneCode;

    @Schema(description = "范围ID列表 JSON")
    private String scopeIds;

    @Schema(description = "排除范围 JSON")
    private String excludeScopeIds;

    @Schema(description = "发行总量，-1 不限")
    private Integer totalCount;

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

    @Schema(description = "已使用数量")
    private Integer usedCount;

    @Schema(description = "每人限领")
    private Integer perMemberLimit;

    /**
     * @see com.jeesharp.business.modules.coupon.enums.CouponGetTypeEnum
     */
    @Schema(description = "领取方式：1-手动 2-自动 3-兑换")
    private Integer getType;

    @Schema(description = "兑换所需积分")
    private Integer exchangePoints;

    /**
     * @see com.jeesharp.business.modules.coupon.enums.CouponValidityTypeEnum
     */
    @Schema(description = "有效期类型：1-固定段 2-领后N天")
    private Integer validityType;

    @Schema(description = "固定有效期开始")
    private LocalDateTime validStartDate;

    @Schema(description = "固定有效期结束")
    private LocalDateTime validEndDate;

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

    @Schema(description = "可领取开始时间")
    private LocalDateTime getStartDate;

    @Schema(description = "可领取结束时间")
    private LocalDateTime getEndDate;

    @Schema(description = "可用平台 JSON")
    private String usePlatforms;

    @Schema(description = "可用会员等级 JSON")
    private String memberLevels;

    @Schema(description = "是否可叠加：0-否 1-是")
    private Integer canOverlay;

    /**
     * @see com.jeesharp.business.modules.coupon.enums.CouponTemplateStatusEnum
     */
    @Schema(description = "模板状态：0-下架 1-进行中 2-结束 3-待开始")
    private Integer status;

    @Schema(description = "使用说明")
    private String description;

    @Schema(description = "领券小程序 scene")
    private String claimWxScene;

    @Schema(description = "领券太阳码图片 URL")
    private String claimQrcodeUrl;
}
