recharge_record.py 1.2 KB

1234567891011121314151617181920212223242526
  1. """
  2. 充值记录模型
  3. """
  4. from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Numeric, SmallInteger
  5. from sqlalchemy.orm import relationship
  6. from app.database import Base
  7. class RechargeRecord(Base):
  8. """充值记录表"""
  9. __tablename__ = "recharge_records"
  10. id = Column(Integer, primary_key=True, index=True, comment="主键ID")
  11. user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True, comment="用户ID")
  12. card_id = Column(Integer, ForeignKey("cards.id"), index=True, comment="使用的卡密ID")
  13. software_code = Column(String(50), nullable=False, index=True, comment="软件特征码")
  14. days = Column(Integer, nullable=False, comment="充值天数")
  15. amount = Column(Numeric(10, 2), comment="充值金额")
  16. expire_time_before = Column(DateTime, comment="充值前到期时间")
  17. expire_time_after = Column(DateTime, comment="充值后到期时间")
  18. is_deleted = Column(SmallInteger, default=0, index=True, comment="是否删除:0-否,1-是")
  19. created_at = Column(DateTime, index=True, comment="充值时间")
  20. # 关系
  21. user = relationship("User", back_populates="recharge_records")
  22. card = relationship("Card", back_populates="recharge_records")