package com.reading.platform.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 学校套餐购买记录实体
 * 用于记录学校购买套餐的信息
 */
@Data
@TableName("t_tenant_product_bundle")
@Schema(description = "学校套餐购买记录")
public class TenantProductBundle {

    @Schema(description = "购买记录 ID", accessMode = Schema.AccessMode.READ_ONLY)
    @TableId(type = IdType.ASSIGN_ID)
    private String id;

    @Schema(description = "租户 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1234567890")
    private String tenantId;

    @Schema(description = "套餐 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "0987654321")
    private String productBundleId;

    @Schema(description = "开始日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2026-01-01 00:00:00")
    private LocalDateTime startDate;

    @Schema(description = "结束日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2026-12-31 23:59:59")
    private LocalDateTime endDate;

    @Schema(description = "状态", allowableValues = {"ACTIVE", "EXPIRED", "SUSPENDED"})
    private String status;

    @Schema(description = "实付价格（分）", example = "8900")
    private Integer pricePaid;

    @Schema(description = "购买时间")
    private LocalDateTime purchaseTime;

    @Schema(description = "续费自原套餐 ID")
    private String renewedFrom;

    @Schema(description = "创建人用户名", accessMode = Schema.AccessMode.READ_ONLY)
    @TableField(fill = FieldFill.INSERT)
    private String createdBy;

    @Schema(description = "更新人用户名", accessMode = Schema.AccessMode.READ_ONLY)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updatedBy;

    @Schema(description = "创建时间", accessMode = Schema.AccessMode.READ_ONLY)
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    @Schema(description = "更新时间", accessMode = Schema.AccessMode.READ_ONLY)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;

    @Schema(description = "是否删除 0-未删除 1-已删除", accessMode = Schema.AccessMode.READ_ONLY)
    @TableLogic
    private Integer deleted;

    // === 关联查询 ===
    @TableField(exist = false)
    private ProductBundle productBundle;
}
