Files
smart-project-pricing/后端服务/app/models/benchmark_price.py
2026-01-31 21:33:06 +08:00

73 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""标杆价格模型
维护行业标杆机构的价格参考
"""
from typing import Optional, TYPE_CHECKING
from decimal import Decimal
from datetime import date
from sqlalchemy import BigInteger, String, Date, DECIMAL, ForeignKey
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.models.base import BaseModel
if TYPE_CHECKING:
from app.models.category import Category
class BenchmarkPrice(BaseModel):
"""标杆价格表"""
__tablename__ = "benchmark_prices"
benchmark_name: Mapped[str] = mapped_column(
String(100),
nullable=False,
comment="标杆机构名称"
)
category_id: Mapped[Optional[int]] = mapped_column(
BigInteger,
ForeignKey("categories.id"),
nullable=True,
index=True,
comment="项目分类ID"
)
min_price: Mapped[Decimal] = mapped_column(
DECIMAL(12, 2),
nullable=False,
comment="最低价"
)
max_price: Mapped[Decimal] = mapped_column(
DECIMAL(12, 2),
nullable=False,
comment="最高价"
)
avg_price: Mapped[Decimal] = mapped_column(
DECIMAL(12, 2),
nullable=False,
comment="均价"
)
price_tier: Mapped[str] = mapped_column(
String(20),
nullable=False,
default="medium",
comment="价格带low-低端, medium-中端, high-高端, premium-奢华"
)
effective_date: Mapped[date] = mapped_column(
Date,
nullable=False,
index=True,
comment="生效日期"
)
remark: Mapped[Optional[str]] = mapped_column(
String(200),
nullable=True,
comment="备注"
)
# 关系
category: Mapped[Optional["Category"]] = relationship(
"Category"
)