Добавлено новое поле promocode в модель StatReferralsItem и модель Ref. Обновлены функции в fill_db.py для генерации уникальных промокодов при создании реферальных ссылок. Обновлены эндпоинты в integration_api.py для возврата промокодов вместе с реферальными ссылками. Удалены устаревшие функции работы с промокодами из кода. Обновлены SQL-скрипты и модели для учета новых полей.
This commit is contained in:
@@ -37,13 +37,13 @@ class TgAgent(SQLModel, table=True):
|
||||
refs: List["Ref"] = Relationship(back_populates="tg_agent")
|
||||
agent_transactions: List["AgentTransaction"] = Relationship(back_populates="tg_agent")
|
||||
agent_balance: Optional["AgentBalance"] = Relationship(back_populates="tg_agent")
|
||||
promocodes: List["PromoCode"] = Relationship(back_populates="agent")
|
||||
|
||||
class Ref(SQLModel, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
tg_agent_id: int = Field(foreign_key="tgagent.id")
|
||||
ref: str
|
||||
description: Optional[str] = None
|
||||
promocode: str = Field(index=True, unique=True, max_length=8)
|
||||
create_dttm: datetime = Field(default_factory=datetime.utcnow)
|
||||
update_dttm: datetime = Field(default_factory=datetime.utcnow)
|
||||
|
||||
@@ -137,15 +137,4 @@ class IntegrationToken(SQLModel, table=True):
|
||||
update_dttm: datetime = Field(default_factory=datetime.utcnow, nullable=False)
|
||||
use_dttm: Optional[datetime] = None
|
||||
|
||||
company: "Company" = Relationship(back_populates="integration_tokens")
|
||||
|
||||
class PromoCode(SQLModel, table=True):
|
||||
id: Optional[int] = Field(default=None, primary_key=True)
|
||||
promocode: str = Field(index=True, unique=True)
|
||||
perc: float = Field(default=10.0)
|
||||
agent_id: int = Field(foreign_key="tgagent.id")
|
||||
description: Optional[str] = None
|
||||
create_dttm: datetime = Field(default_factory=datetime.utcnow)
|
||||
update_dttm: datetime = Field(default_factory=datetime.utcnow)
|
||||
|
||||
agent: "TgAgent" = Relationship(back_populates="promocodes")
|
||||
company: "Company" = Relationship(back_populates="integration_tokens")
|
||||
Reference in New Issue
Block a user