feat: 新人初始礼包购买追踪功能
- 数据库:添加 has_purchased_starter_pack 字段到 register_bonus_claims - 后端:创建静态配置管理套餐信息,支持按国家/地区区分 - 后端:新增 GET /api/v1/points/packages API 返回可用套餐 - 后端:创建 utils/paths.py 统一路径管理 - 前端:动态获取套餐信息,移除硬编码 - 前端:添加 ProductCode 枚举约束,前后端类型安全 - 配置:Profile 默认国家改为 US(ISO 3166-1 alpha-2) - 文档:更新协议文档说明新 API 和字段
This commit is contained in:
@@ -10,6 +10,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from models.agent_chat_message import AgentChatMessage
|
||||
from models.points_audit_ledger import PointsAuditLedger
|
||||
from models.points_ledger import PointsLedger
|
||||
from models.profile import Profile
|
||||
from models.register_bonus_claims import RegisterBonusClaims
|
||||
from models.user_points import UserPoints
|
||||
from schemas.domain.points import (
|
||||
@@ -189,3 +190,22 @@ class PointsRepository:
|
||||
claim.balance_snapshot = int(balance_snapshot)
|
||||
await self._session.flush()
|
||||
return True
|
||||
|
||||
async def has_purchased_starter_pack(
|
||||
self,
|
||||
*,
|
||||
email_hash: str,
|
||||
) -> bool:
|
||||
claim = await self.get_register_bonus_claim(email_hash=email_hash)
|
||||
if claim is None:
|
||||
return False
|
||||
return bool(claim.has_purchased_starter_pack)
|
||||
|
||||
async def get_profile_settings(
|
||||
self,
|
||||
*,
|
||||
user_id: UUID,
|
||||
) -> dict[str, object] | None:
|
||||
stmt = select(Profile.settings).where(Profile.id == user_id).limit(1)
|
||||
row = (await self._session.execute(stmt)).scalar_one_or_none()
|
||||
return row
|
||||
|
||||
Reference in New Issue
Block a user