feat(business): 新增业务数据七表及 V5 迁移(业务/明细/状态留痕/发货/回款/评级配置)
- businesses 五项汇总冗余列服务层事务内维护;毛利润不落库(派生值,M3 台账固化) - 行级 product_category 折算锚点(#14);回款 settlement_status 预置为 M3 防重锚点 - 评级等级种子四条(迁移+init-dev 双写);编号前缀常量 YW/SH/HK - 双轨 SQL 同步(V4/V5 重导,schema_sync+test_models 164 例全绿) Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
1 parent
ca88ee7a0b
commit
20fcf06f51
12 files changed
+2138
-138
No files matched your search
@@ -0,0 +1,46 @@
|
||||
"""客户评级等级配置模型(需求 2.2.5)。
|
||||
|
||||
评级计算器定位为「仅打分工具,不影响绩效金额」(对照表 #25):评分记录
|
||||
不落库,等级**映射关系**可配置由本表承载。判定规则:按 sort_order 升序取
|
||||
第一个 min_score ≤ 总分的等级 —— 单边判定避免区间边界(如 75 分)在
|
||||
「≥75 且 ≤89」与「>74 且 <75」两套写法间的重叠/遗漏歧义;max_score 仅展示。
|
||||
"""
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
from sqlalchemy import Integer, Numeric, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.models.base import BIGINT_UNSIGNED, Base, TimestampMixin, mysql_table_args
|
||||
|
||||
|
||||
class CustomerRatingGrade(Base, TimestampMixin):
|
||||
"""客户评级等级配置表(需求 2.2.5「等级对应关系可配置」)。
|
||||
|
||||
种子四条随迁移初始化:A 优秀 90-100 / B 良好 75-89 / C 合格 60-74 /
|
||||
D 待改进 0-59。区间不重叠与 0≤min≤max≤100 由应用层校验。
|
||||
"""
|
||||
|
||||
__tablename__ = "customer_rating_grades"
|
||||
__table_args__ = mysql_table_args(
|
||||
"客户评级等级配置表(等级映射可配置;判定按 sort_order 升序首个 min_score≤总分)"
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(
|
||||
BIGINT_UNSIGNED, primary_key=True, autoincrement=True, comment="主键ID"
|
||||
)
|
||||
grade_name: Mapped[str] = mapped_column(
|
||||
String(32), nullable=False, unique=True, comment="等级名称(如 A/优秀)"
|
||||
)
|
||||
min_score: Mapped[Decimal] = mapped_column(
|
||||
Numeric(5, 1),
|
||||
nullable=False,
|
||||
comment="总分下限(含);判定=按 sort_order 升序首个 min_score ≤ 总分",
|
||||
)
|
||||
max_score: Mapped[Decimal] = mapped_column(
|
||||
Numeric(5, 1), nullable=False, comment="总分上限(展示用)"
|
||||
)
|
||||
sort_order: Mapped[int] = mapped_column(
|
||||
Integer, nullable=False, server_default="0", comment="排序(判定顺序,升序)"
|
||||
)
|
||||
remark: Mapped[str | None] = mapped_column(String(255), comment="说明")
|
||||
Reference in new issue
Block a user