feat:新增基金产品列表接口,历史业绩接口,客户注册提交接口,问卷提交接口

This commit is contained in:
2026-09-10 23:19:25 +08:00
parent 0a2f0cb146
commit 9cb0747303
15 changed files with 656 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
"""fin_customer_profile 客户画像主表 ORM 模型。"""
from __future__ import annotations
from datetime import datetime
from decimal import Decimal
from typing import Any
from sqlalchemy import BigInteger, DateTime, Integer, JSON, Numeric, String, func
from sqlalchemy.orm import Mapped, mapped_column
from model.base import Base
class FinCustomerProfile(Base):
__tablename__ = "fin_customer_profile"
__table_args__ = {"comment": "客户画像主表(RAG/GraphRAG 个性化推荐核心上下文)"}
# 主键为 customer_id(一对一关联 sys_user.id),非自增 id
customer_id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
risk_level: Mapped[str | None] = mapped_column(String(16))
risk_score: Mapped[int | None] = mapped_column(Integer)
investment_experience: Mapped[str | None] = mapped_column(String(16))
annual_income_range: Mapped[str | None] = mapped_column(String(32))
total_assets: Mapped[Decimal | None] = mapped_column(Numeric(18, 2))
asset_allocation: Mapped[dict[str, Any] | None] = mapped_column(JSON)
product_preference: Mapped[dict[str, Any] | None] = mapped_column(JSON)
customer_level: Mapped[str | None] = mapped_column(String(16))
confidence_score: Mapped[Decimal] = mapped_column(Numeric(5, 2), server_default="0.50")
profile_version: Mapped[int] = mapped_column(Integer, server_default="1")
update_time: Mapped[datetime] = mapped_column(
DateTime, server_default=func.now(), onupdate=func.now()
)
+32
View File
@@ -0,0 +1,32 @@
"""fin_product 公募基金产品表 ORM 模型。"""
from __future__ import annotations
from datetime import date, datetime
from decimal import Decimal
from sqlalchemy import BigInteger, Date, DateTime, Integer, Numeric, String, func
from sqlalchemy.orm import Mapped, mapped_column
from model.base import Base
class FinProduct(Base):
__tablename__ = "fin_product"
__table_args__ = {"comment": "公募基金产品表"}
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
product_code: Mapped[str] = mapped_column(String(32), unique=True)
product_name: Mapped[str] = mapped_column(String(128))
product_type: Mapped[str] = mapped_column(String(32))
risk_level: Mapped[str] = mapped_column(String(8))
expected_return: Mapped[Decimal | None] = mapped_column(Numeric(7, 4))
nav: Mapped[Decimal | None] = mapped_column(Numeric(12, 6))
nav_date: Mapped[date | None] = mapped_column(Date)
fee_rate: Mapped[Decimal] = mapped_column(Numeric(6, 4), server_default="0.0000")
term_days: Mapped[int] = mapped_column(Integer, server_default="0")
fund_manager: Mapped[str | None] = mapped_column(String(64))
status: Mapped[str] = mapped_column(String(16), server_default="在售")
create_time: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
update_time: Mapped[datetime] = mapped_column(
DateTime, server_default=func.now(), onupdate=func.now()
)
+26
View File
@@ -0,0 +1,26 @@
"""fin_risk_assessment 风险评估记录表 ORM 模型。"""
from __future__ import annotations
from datetime import date, datetime
from typing import Any
from sqlalchemy import BigInteger, Date, DateTime, Integer, JSON, String, func
from sqlalchemy.orm import Mapped, mapped_column
from model.base import Base
class FinRiskAssessment(Base):
__tablename__ = "fin_risk_assessment"
__table_args__ = {"comment": "风险评估记录表(购买前问卷确认客户等级)"}
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
customer_id: Mapped[int] = mapped_column(BigInteger)
assessment_date: Mapped[date] = mapped_column(Date)
question_version: Mapped[str | None] = mapped_column(String(16))
total_score: Mapped[int] = mapped_column(Integer)
risk_level: Mapped[str] = mapped_column(String(16))
answers: Mapped[list[Any] | None] = mapped_column(JSON)
assessor_type: Mapped[str] = mapped_column(String(16), server_default="AI评估")
valid_until: Mapped[date] = mapped_column(Date)
create_time: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
+23
View File
@@ -0,0 +1,23 @@
"""fund_nav_history 基金净值历史表 ORM 模型。"""
from __future__ import annotations
from datetime import date, datetime
from decimal import Decimal
from sqlalchemy import BigInteger, Date, DateTime, Numeric, func
from sqlalchemy.orm import Mapped, mapped_column
from model.base import Base
class FundNavHistory(Base):
__tablename__ = "fund_nav_history"
__table_args__ = {"comment": "基金净值历史(业绩指标/走势图数据源)"}
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
product_id: Mapped[int] = mapped_column(BigInteger)
nav_date: Mapped[date] = mapped_column(Date)
unit_nav: Mapped[Decimal] = mapped_column(Numeric(12, 6))
accumulated_nav: Mapped[Decimal | None] = mapped_column(Numeric(12, 6))
daily_growth: Mapped[Decimal | None] = mapped_column(Numeric(8, 4))
create_time: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
+22
View File
@@ -0,0 +1,22 @@
"""ops_question 问卷题目表 ORM 模型。"""
from __future__ import annotations
from typing import Any
from sqlalchemy import BigInteger, Integer, JSON, String
from sqlalchemy.orm import Mapped, mapped_column
from model.base import Base
class OpsQuestion(Base):
__tablename__ = "ops_question"
__table_args__ = {"comment": "问卷题目表(题目/选项/分值可运营配置)"}
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
questionnaire_id: Mapped[int] = mapped_column(BigInteger)
question_no: Mapped[int] = mapped_column(Integer)
content: Mapped[str] = mapped_column(String(512))
option_json: Mapped[list[Any] | None] = mapped_column(JSON)
score_json: Mapped[dict[str, Any] | None] = mapped_column(JSON)
sort: Mapped[int] = mapped_column(Integer, server_default="0")
+24
View File
@@ -0,0 +1,24 @@
"""ops_questionnaire 问卷模板表 ORM 模型。"""
from __future__ import annotations
from datetime import datetime
from sqlalchemy import BigInteger, DateTime, String, func
from sqlalchemy.orm import Mapped, mapped_column
from model.base import Base
class OpsQuestionnaire(Base):
__tablename__ = "ops_questionnaire"
__table_args__ = {"comment": "问卷模板表"}
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
name: Mapped[str] = mapped_column(String(64))
q_type: Mapped[str] = mapped_column(String(16))
version: Mapped[str] = mapped_column(String(16), server_default="v1")
status: Mapped[str] = mapped_column(String(16), server_default="启用")
create_time: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
update_time: Mapped[datetime] = mapped_column(
DateTime, server_default=func.now(), onupdate=func.now()
)