feat: batch update - gift card breakdown spec, backend APIs, miniprogram pages, ETL finance recharge, docs & migrations

This commit is contained in:
Neo
2026-03-20 01:43:48 +08:00
parent 075caf067f
commit 79f9a0e1da
437 changed files with 118603 additions and 976 deletions

View File

@@ -0,0 +1,122 @@
"""
小程序绩效相关 Pydantic 模型。
覆盖绩效概览PERF-1、绩效明细PERF-2响应结构。
"""
from __future__ import annotations
from app.schemas.base import CamelModel
# ---------------------------------------------------------------------------
# 绩效通用模型
# ---------------------------------------------------------------------------
class DateGroupRecord(CamelModel):
"""按日期分组的单条服务记录。"""
customer_name: str
avatar_char: str | None = None # PERF-1 返回PERF-2 不返回
avatar_color: str | None = None # PERF-1 返回PERF-2 不返回
time_range: str
hours: str
course_type: str
course_type_class: str # 'basic' | 'vip' | 'tip'
location: str
income: str
class DateGroup(CamelModel):
"""按日期分组的服务记录组。"""
date: str
total_hours: str
total_income: str
records: list[DateGroupRecord]
# ---------------------------------------------------------------------------
# PERF-1 绩效概览
# ---------------------------------------------------------------------------
class TierInfo(CamelModel):
"""档位信息(含基础/激励费率)。"""
basic_rate: float
incentive_rate: float
class IncomeItem(CamelModel):
"""收入明细项。"""
icon: str
label: str
desc: str
value: str
class CustomerSummary(CamelModel):
"""客户摘要(新客/常客基类)。"""
name: str
avatar_char: str
avatar_color: str
class NewCustomer(CustomerSummary):
"""新客户。"""
last_service: str
count: int
class RegularCustomer(CustomerSummary):
"""常客。"""
hours: float
income: str
count: int
class PerformanceOverviewResponse(CamelModel):
"""PERF-1 响应。"""
coach_name: str
coach_role: str
store_name: str
monthly_income: str
last_month_income: str
current_tier: TierInfo
next_tier: TierInfo
upgrade_hours_needed: float
upgrade_bonus: float
income_items: list[IncomeItem]
monthly_total: str
this_month_records: list[DateGroup]
new_customers: list[NewCustomer]
regular_customers: list[RegularCustomer]
# ---------------------------------------------------------------------------
# PERF-2 绩效明细
# ---------------------------------------------------------------------------
class RecordsSummary(CamelModel):
"""月度汇总。"""
total_count: int
total_hours: float
total_hours_raw: float
total_income: float
class PerformanceRecordsResponse(CamelModel):
"""PERF-2 响应。"""
summary: RecordsSummary
date_groups: list[DateGroup]
has_more: bool