package cn.novalon.gym.manage.member.entity;

import cn.novalon.gym.manage.member.enums.MemberCardRecordStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;

import java.time.LocalDateTime;

/**
 * 会员卡记录实体（会员持有的卡）- 对应 member_card_record 表
 * 
 * @author 付嘉
 * @date 2026-05-27
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Table("member_card_record")
public class MemberCardRecord extends BaseEntity {

    // 会员持有卡ID
    @Column("member_card_record_id")
    private Long memberCardRecordId;

    // 会员ID
    @Column("member_id")
    private Long memberId;

    // 关联会员卡ID
    @Column("member_card_id")
    private Long memberCardId;

    // 状态：ACTIVE-有效, USED_UP-用完, EXPIRED-过期, REFUNDED-已退款
    @Column("status")
    private MemberCardRecordStatus status;

    // 剩余次数
    @Column("remaining_times")
    private Integer remainingTimes;

    // 剩余金额
    @Column("remaining_amount")
    private Double remainingAmount;

    // 到期时间
    @Column("expire_time")
    private LocalDateTime expireTime;

    // 来源订单ID
    @Column("source_order_id")
    private Long sourceOrderId;

    // 购买时间
    @Column("purchase_time")
    private LocalDateTime purchaseTime;

    // 乐观锁版本号
    @Column("version")
    private Integer version;

    // 卡片组成（JSON格式，用于组合卡）
    @Column("card_composition")
    private String cardComposition;

}
