""" 卡密模型 """ from datetime import datetime from sqlalchemy import Column, Integer, String, DateTime, Boolean, ForeignKey from app.database import Base from app.utils.timezone import beijing_now_naive class Card(Base): """卡密表""" __tablename__ = "cards" id = Column(Integer, primary_key=True, autoincrement=True, comment="主键ID") card_code = Column(String(50), unique=True, nullable=False, comment="卡密代码") software_code = Column(String(50), nullable=False, comment="软件特征码") days = Column(Integer, nullable=False, comment="天数") discount = Column(Integer, default=100, comment="折扣(100=原价)") user_id = Column(Integer, nullable=True, comment="激活用户ID") activated_at = Column(DateTime, nullable=True, comment="激活时间") expire_time = Column(DateTime, nullable=True, comment="到期时间") status = Column(Integer, default=0, comment="状态: 0-未激活, 1-已激活, 2-已过期") is_deleted = Column(Boolean, default=False, comment="是否删除: 0-否, 1-是") created_at = Column(DateTime, default=beijing_now_naive, comment="创建时间") updated_at = Column(DateTime, default=beijing_now_naive, onupdate=beijing_now_naive, comment="更新时间") def __repr__(self): return f""