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_member_coupon}，承载领取快照与使用状态。
 *
 * @author jeesharp
 * @since 2026-05-07
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("app_member_coupon")
@Schema(description = "会员优惠券")
public class MemberCoupon extends BaseEntity<MemberCoupon> {

    @Schema(description = "券唯一码")
    private String couponSn;

    @Schema(description = "会员ID")
    private String memberId;

    @Schema(description = "会员编号")
    private String memberNo;

    @Schema(description = "会员手机号")
    private String memberMobile;

    @Schema(description = "模板ID")
    private String templateId;

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

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

    @Schema(description = "优惠券类型（冗余）")
    private Integer couponType;

    @Schema(description = "优惠方式（冗余）")
    private Integer discountType;

    @Schema(description = "优惠值（冗余）")
    private BigDecimal discountValue;

    @Schema(description = "门槛（冗余）")
    private BigDecimal minConsumeAmount;

    @Schema(description = "最大优惠（冗余）")
    private BigDecimal maxDiscountAmount;

    @Schema(description = "使用场景编号（发券快照）")
    private String sceneCode;

    @Schema(description = "使用范围：1-全场 2-商品 3-分类 4-品牌（发券快照）")
    private Integer useScope;

    @Schema(description = "范围ID列表 JSON（发券快照）")
    private String scopeIds;

    @Schema(description = "排除范围 JSON（发券快照）")
    private String excludeScopeIds;

    @Schema(description = "领取方式")
    private Integer getType;

    @Schema(description = "领取时间")
    private LocalDateTime getDate;

    @Schema(description = "领取来源")
    private String getSource;

    @Schema(description = "活动ID")
    private String activityId;

    @Schema(description = "兑换消耗积分")
    private Integer exchangePoints;

    @Schema(description = "券可用开始")
    private LocalDateTime validStartDate;

    @Schema(description = "券可用结束")
    private LocalDateTime validEndDate;

    /**
     * @see com.jeesharp.business.modules.coupon.enums.MemberCouponUseStatusEnum
     */
    @Schema(description = "使用状态：0-未使用 1-已使用 2-过期 3-冻结 4-作废")
    private Integer status;

    @Schema(description = "使用时间")
    private LocalDateTime useDate;

    @Schema(description = "使用订单ID")
    private String useOrderId;

    @Schema(description = "使用订单号")
    private String useOrderNo;

    @Schema(description = "实际抵扣金额")
    private BigDecimal useAmount;

    @Schema(description = "订单金额")
    private BigDecimal orderAmount;

    @Schema(description = "退回时间")
    private LocalDateTime returnDate;

    @Schema(description = "退回原因")
    private String returnReason;

    @Schema(description = "是否已退回")
    private Integer isReturned;

    @Schema(description = "冻结时间")
    private LocalDateTime freezeDate;

    @Schema(description = "冻结原因")
    private String freezeReason;

    @Schema(description = "冻结关联订单")
    private String freezeOrderId;
}
