- Implemented SubscriptionRepository with methods to get, create, and update subscriptions. - Added BalanceTXRepository for creating and retrieving balance transactions. - Introduced a test script for simulating Pally webhook for local testing.
38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
from enum import StrEnum
|
|
from typing import TYPE_CHECKING
|
|
|
|
from sqlalchemy import BIGINT, INTEGER, Enum, ForeignKey
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from db.base import Base
|
|
|
|
if TYPE_CHECKING:
|
|
from db.models.users import User
|
|
|
|
|
|
class DepositStatus(StrEnum):
|
|
PENDING = "pending"
|
|
SUCCESS = "success"
|
|
FAILED = "failed"
|
|
EXPIRED = "expired"
|
|
|
|
|
|
class Bill(Base):
|
|
__tablename__ = "bills"
|
|
|
|
id: Mapped[int] = mapped_column(
|
|
BIGINT, autoincrement=True, unique=True, nullable=False, primary_key=True
|
|
)
|
|
creator_id: Mapped[int] = mapped_column(BIGINT, ForeignKey("users.id"), nullable=False)
|
|
amount: Mapped[int] = mapped_column(INTEGER, nullable=False)
|
|
status: Mapped[DepositStatus] = mapped_column(
|
|
Enum(DepositStatus, name="depositstatus", values_callable=lambda x: [e.value for e in x]),
|
|
nullable=False,
|
|
default=DepositStatus.PENDING,
|
|
)
|
|
|
|
user: Mapped["User"] = relationship(
|
|
"User",
|
|
back_populates="bills",
|
|
)
|