Compare commits

..

7 Commits

Author SHA1 Message Date
Neo
076f5755ca 数据库 数据校验写入等逻辑更新。 2026-02-01 03:46:16 +08:00
Neo
9948000b71 更新1 2026-01-28 20:23:54 +08:00
Neo
4fafc80254 提交 2026-01-28 00:04:30 +08:00
Neo
1a76108209 修复脚本 2026-01-28 00:02:15 +08:00
Neo
7e67bc4218 更新 2026-01-27 23:45:36 +08:00
Neo
64a3159f9e 移除依赖 2026-01-27 23:22:21 +08:00
Neo
ba00654ac5 exe 依赖添加 2026-01-27 23:19:54 +08:00
213 changed files with 494631 additions and 12314 deletions

60
collect_env_report.ps1 Normal file
View File

@@ -0,0 +1,60 @@
$ErrorActionPreference = "Stop"
Write-Host "[1/6] Collecting environment info..." -ForegroundColor Cyan
$report = @()
$report += "# ETL Manager Environment Report"
$report += "Timestamp: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"
$report += ""
Write-Host "[2/6] Resolving python/pip..." -ForegroundColor Cyan
$report += "## Executables"
$py = (Get-Command python -ErrorAction SilentlyContinue)
$pip = (Get-Command pip -ErrorAction SilentlyContinue)
if ($py) { $report += "python: $($py.Source)" } else { $report += "python: NOT FOUND" }
if ($pip) { $report += "pip: $($pip.Source)" } else { $report += "pip: NOT FOUND" }
$report += ""
Write-Host "[3/6] Python details..." -ForegroundColor Cyan
$report += "## Python info"
$report += (python -c "import sys, platform; print('version='+sys.version.replace('\n',' ')); print('executable='+sys.executable); print('prefix='+sys.prefix); print('base_prefix='+sys.base_prefix); print('arch='+platform.architecture()[0]); print('platform='+platform.platform())" 2>&1)
$report += ""
Write-Host "[4/6] pip details..." -ForegroundColor Cyan
$report += "## pip"
$report += (python -m pip --version 2>&1)
$report += ""
Write-Host "[5/6] PySide6 details..." -ForegroundColor Cyan
$report += "## PySide6"
$pyside = @'
try:
import PySide6
from PySide6 import QtCore
print('PySide6='+PySide6.__version__)
print('Qt='+QtCore.qVersion())
print('PySide6_path='+PySide6.__file__)
print('Qt_plugins_path='+QtCore.QLibraryInfo.path(QtCore.QLibraryInfo.PluginsPath))
except Exception as e:
print('PySide6_import_error='+repr(e))
'@
$report += ($pyside | python - 2>&1)
$report += ""
Write-Host "[6/6] Installed packages..." -ForegroundColor Cyan
$report += "## Installed packages (freeze)"
$report += (python -m pip list --format=freeze 2>&1)
$reportPath = "D:\env_report_local.txt"
if (-not (Test-Path "D:\")) {
Write-Host "[WARN] D: not found, fallback to current directory." -ForegroundColor Yellow
$reportPath = ".\env_report_local.txt"
}
$reportDir = Split-Path $reportPath
if ($reportDir -and -not (Test-Path $reportDir)) {
New-Item -ItemType Directory -Path $reportDir -Force | Out-Null
}
Write-Host "[WRITE] $reportPath" -ForegroundColor Green
$report -join "`n" | Set-Content -Path $reportPath -Encoding UTF8
Write-Host "[DONE]" -ForegroundColor Green
Write-Output $reportPath

121
env_report_local.txt Normal file
View File

@@ -0,0 +1,121 @@
# ETL Manager Environment Report
Timestamp: 2026-01-28 00:56:34
## Executables
python: C:\ProgramData\miniconda3\python.exe
pip: C:\ProgramData\miniconda3\Scripts\pip.exe
## Python info
version=3.13.9 | packaged by Anaconda, Inc. | (main, Oct 21 2025, 19:09:58) [MSC v.1929 64 bit (AMD64)]
executable=C:\ProgramData\miniconda3\python.exe
prefix=C:\ProgramData\miniconda3
base_prefix=C:\ProgramData\miniconda3
arch=64bit
platform=Windows-10-10.0.17763-SP0
## pip
pip 25.3 from C:\ProgramData\miniconda3\Lib\site-packages\pip (python 3.13)
## PySide6
PySide6=6.10.1
Qt=6.10.1
PySide6_path=C:\ProgramData\miniconda3\Lib\site-packages\PySide6\__init__.py
Qt_plugins_path=C:/ProgramData/miniconda3/Lib/site-packages/PySide6/plugins
## Installed packages (freeze)
altgraph==0.17.5
anaconda-anon-usage==0.7.4
annotated-types==0.6.0
archspec==0.2.5
beautifulsoup4==4.13.4
boltons==25.0.0
brotlicffi==1.1.0.0
certifi==2025.11.12
cffi==2.0.0
chardet==3.0.4
charset-normalizer==3.4.4
colorama==0.4.6
conda==25.9.1
conda-anaconda-telemetry==0.3.0
conda-anaconda-tos==0.2.2
conda-content-trust==0.2.0
conda-libmamba-solver==25.4.0
conda-package-handling==2.4.0
conda_package_streaming==0.12.0
coverage==7.12.0
cryptography==46.0.3
distro==1.9.0
et_xmlfile==2.0.0
frozendict==2.4.6
ftfy==6.3.1
googletrans==4.0.0rc1
h11==0.9.0
h2==3.2.0
hpack==3.0.0
hstspreload==2025.1.1
httpcore==0.9.1
httpx==0.13.3
hyperframe==5.2.0
idna==2.10
iniconfig==2.3.0
jsonpatch==1.33
jsonpointer==3.0.0
libmambapy==2.3.2
lxml==6.0.2
markdown-it-py==4.0.0
mdurl==0.1.2
menuinst==2.4.1
numpy==2.3.2
openpyxl==3.1.5
packaging==25.0
pandas==2.3.1
pefile==2024.8.26
pip==25.2
platformdirs==4.5.0
pluggy==1.5.0
psycopg2==2.9.10
psycopg2-binary==2.9.11
pyaes==1.6.1
pyasn1==0.6.1
pycosat==0.6.6
pycparser==2.23
pydantic==2.12.3
pydantic_core==2.41.4
Pygments==2.19.2
pyinstaller==6.18.0
pyinstaller-hooks-contrib==2025.11
PySide6==6.10.1
PySide6_Addons==6.10.1
PySide6_Essentials==6.10.1
PySocks==1.7.1
pytest==9.0.1
pytest-cov==7.0.0
python-dateutil==2.9.0.post0
python-docx==1.2.0
python-dotenv==1.2.1
pytz==2025.2
pywin32-ctypes==0.2.3
requests==2.32.5
rfc3986==1.5.0
rich==14.2.0
rsa==4.9.1
ruamel.yaml==0.18.16
ruamel.yaml.clib==0.2.14
setuptools==80.9.0
shiboken6==6.10.1
six==1.17.0
sniffio==1.3.1
soupsieve==2.7
Telethon==1.40.0
tqdm==4.67.1
truststore==0.10.1
typing_extensions==4.15.0
typing-inspection==0.4.2
tzdata==2025.2
urllib3==2.5.0
wcwidth==0.2.14
wheel==0.45.1
win_inet_pton==1.1.0
xlsxwriter==3.2.9
zstandard==0.24.0

View File

@@ -32,7 +32,7 @@ SCHEMA_ETL=etl_admin
# API 配置
# ------------------------------------------------------------------------------
API_BASE=https://pc.ficoo.vip/apiprod/admin/v1/
API_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnQtdHlwZSI6IjQiLCJ1c2VyLXR5cGUiOiIxIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiMTIiLCJyb2xlLWlkIjoiMTIiLCJ0ZW5hbnQtaWQiOiIyNzkwNjgzMTYwNzA5OTU3Iiwibmlja25hbWUiOiLnp5_miLfnrqHnkIblkZjvvJrmganmgakxIiwic2l0ZS1pZCI6IjAiLCJtb2JpbGUiOiIxMzgxMDUwMjMwNCIsInNpZCI6IjI5NTA0ODk2NTgzOTU4NDUiLCJzdGFmZi1pZCI6IjMwMDk5MTg2OTE1NTkwNDUiLCJvcmctaWQiOiIwIiwicm9sZS10eXBlIjoiMyIsInJlZnJlc2hUb2tlbiI6Iks1ZnBhYlRTNkFsR0FpMmN4WGYrMHdJVkk0L2UvTVQrSVBHM3V5VWRrSjg9IiwicmVmcmVzaEV4cGlyeVRpbWUiOiIyMDI2LzEvMzEg5LiL5Y2IMTA6MTQ6NTEiLCJuZWVkQ2hlY2tUb2tlbiI6ImZhbHNlIiwiZXhwIjoxNzY5ODY4ODkxLCJpc3MiOiJ0ZXN0IiwiYXVkIjoiVXNlciJ9.BH3-iwwrBczb8aFfI__6kwe3AIsEPacN9TruaTrQ3nY
API_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnQtdHlwZSI6IjQiLCJ1c2VyLXR5cGUiOiIxIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xlIjoiMTIiLCJyb2xlLWlkIjoiMTIiLCJ0ZW5hbnQtaWQiOiIyNzkwNjgzMTYwNzA5OTU3Iiwibmlja25hbWUiOiLnp5_miLfnrqHnkIblkZjvvJrmganmgakxIiwic2l0ZS1pZCI6IjAiLCJtb2JpbGUiOiIxMzgxMDUwMjMwNCIsInNpZCI6IjI5NTA0ODk2NTgzOTU4NDUiLCJzdGFmZi1pZCI6IjMwMDk5MTg2OTE1NTkwNDUiLCJvcmctaWQiOiIwIiwicm9sZS10eXBlIjoiMyIsInJlZnJlc2hUb2tlbiI6Ik1oKzFpTitjclRHMTY3cUp5SzFXYllteVBaaUhjdDI2ZTZDZkJvd1pxSVk9IiwicmVmcmVzaEV4cGlyeVRpbWUiOiIyMDI2LzIvNyDkuIvljYg5OjU2OjE4IiwibmVlZENoZWNrVG9rZW4iOiJmYWxzZSIsImV4cCI6MTc3MDQ3MjU3OCwiaXNzIjoidGVzdCIsImF1ZCI6IlVzZXIifQ.rY03o82SKznD7NOktXKzTOI1btl2FHsklMCChOlZUeY
# API 请求超时(秒)
API_TIMEOUT=20

View File

@@ -109,9 +109,18 @@ DEFAULTS = {
"mode": "history",
"history_start": "2025-07-01",
"history_end": "",
"include_dimensions": False,
"include_dimensions": True,
"auto_check": False,
"auto_backfill": False,
"compare_content": True,
"content_sample_limit": 50,
"backfill_mismatch": True,
"recheck_after_backfill": True,
"ods_task_codes": "",
"force_monthly_split": True,
},
"dwd": {
"fact_upsert": True,
},
}

View File

@@ -55,7 +55,12 @@ ENV_MAP = {
"INTEGRITY_INCLUDE_DIMENSIONS": ("integrity.include_dimensions",),
"INTEGRITY_AUTO_CHECK": ("integrity.auto_check",),
"INTEGRITY_AUTO_BACKFILL": ("integrity.auto_backfill",),
"INTEGRITY_COMPARE_CONTENT": ("integrity.compare_content",),
"INTEGRITY_CONTENT_SAMPLE_LIMIT": ("integrity.content_sample_limit",),
"INTEGRITY_BACKFILL_MISMATCH": ("integrity.backfill_mismatch",),
"INTEGRITY_RECHECK_AFTER_BACKFILL": ("integrity.recheck_after_backfill",),
"INTEGRITY_ODS_TASK_CODES": ("integrity.ods_task_codes",),
"DWD_FACT_UPSERT": ("dwd.fact_upsert",),
}

File diff suppressed because it is too large Load Diff

View File

@@ -84,7 +84,7 @@ CREATE TABLE IF NOT EXISTS dim_site (
SCD2_end_time TIMESTAMPTZ DEFAULT '9999-12-31',
SCD2_is_current INT DEFAULT 1,
SCD2_version INT DEFAULT 1,
PRIMARY KEY (site_id)
PRIMARY KEY (site_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_site IS 'DWD 维度表dim_site。ODS 来源表billiards_ods.table_fee_transactions对应 JSONtable_fee_transactions.json分析table_fee_transactions-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -133,7 +133,7 @@ CREATE TABLE IF NOT EXISTS dim_site_Ex (
SCD2_end_time TIMESTAMPTZ DEFAULT '9999-12-31',
SCD2_is_current INT DEFAULT 1,
SCD2_version INT DEFAULT 1,
PRIMARY KEY (site_id)
PRIMARY KEY (site_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_site_ex IS 'DWD 维度表扩展字段表dim_site_ex。ODS 来源表billiards_ods.table_fee_transactions对应 JSONtable_fee_transactions.json分析table_fee_transactions-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -176,7 +176,7 @@ CREATE TABLE IF NOT EXISTS dim_table (
SCD2_end_time TIMESTAMPTZ DEFAULT '9999-12-31',
SCD2_is_current INT DEFAULT 1,
SCD2_version INT DEFAULT 1,
PRIMARY KEY (table_id)
PRIMARY KEY (table_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_table IS 'DWD 维度表dim_table。ODS 来源表billiards_ods.site_tables_master对应 JSONsite_tables_master.json分析site_tables_master-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -204,7 +204,7 @@ CREATE TABLE IF NOT EXISTS dim_table_Ex (
SCD2_end_time TIMESTAMPTZ DEFAULT '9999-12-31',
SCD2_is_current INT DEFAULT 1,
SCD2_version INT DEFAULT 1,
PRIMARY KEY (table_id)
PRIMARY KEY (table_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_table_ex IS 'DWD 维度表扩展字段表dim_table_ex。ODS 来源表billiards_ods.site_tables_master对应 JSONsite_tables_master.json分析site_tables_master-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -240,7 +240,7 @@ CREATE TABLE IF NOT EXISTS dim_assistant (
SCD2_end_time TIMESTAMPTZ,
SCD2_is_current INT,
SCD2_version INT,
PRIMARY KEY (assistant_id)
PRIMARY KEY (assistant_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_assistant IS 'DWD 维度表dim_assistant。ODS 来源表billiards_ods.assistant_accounts_master对应 JSONassistant_accounts_master.json分析assistant_accounts_master-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -314,7 +314,7 @@ CREATE TABLE IF NOT EXISTS dim_assistant_Ex (
SCD2_end_time TIMESTAMPTZ,
SCD2_is_current INT,
SCD2_version INT,
PRIMARY KEY (assistant_id)
PRIMARY KEY (assistant_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_assistant_ex IS 'DWD 维度表扩展字段表dim_assistant_ex。ODS 来源表billiards_ods.assistant_accounts_master对应 JSONassistant_accounts_master.json分析assistant_accounts_master-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -383,7 +383,7 @@ CREATE TABLE IF NOT EXISTS dim_member (
SCD2_end_time TIMESTAMPTZ,
SCD2_is_current INT,
SCD2_version INT,
PRIMARY KEY (member_id)
PRIMARY KEY (member_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_member IS 'DWD 维度表dim_member。ODS 来源表billiards_ods.member_profiles对应 JSONmember_profiles.json分析member_profiles-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -415,7 +415,7 @@ CREATE TABLE IF NOT EXISTS dim_member_Ex (
SCD2_end_time TIMESTAMPTZ,
SCD2_is_current INT,
SCD2_version INT,
PRIMARY KEY (member_id)
PRIMARY KEY (member_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_member_ex IS 'DWD 维度表扩展字段表dim_member_ex。ODS 来源表billiards_ods.member_profiles对应 JSONmember_profiles.json分析member_profiles-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -454,7 +454,7 @@ CREATE TABLE IF NOT EXISTS dim_member_card_account (
SCD2_end_time TIMESTAMPTZ,
SCD2_is_current INT,
SCD2_version INT,
PRIMARY KEY (member_card_id)
PRIMARY KEY (member_card_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_member_card_account IS 'DWD 维度表dim_member_card_account。ODS 来源表billiards_ods.member_stored_value_cards对应 JSONmember_stored_value_cards.json分析member_stored_value_cards-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -538,7 +538,7 @@ CREATE TABLE IF NOT EXISTS dim_member_card_account_Ex (
SCD2_end_time TIMESTAMPTZ,
SCD2_is_current INT,
SCD2_version INT,
PRIMARY KEY (member_card_id)
PRIMARY KEY (member_card_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_member_card_account_ex IS 'DWD 维度表扩展字段表dim_member_card_account_ex。ODS 来源表billiards_ods.member_stored_value_cards对应 JSONmember_stored_value_cards.json分析member_stored_value_cards-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -619,7 +619,7 @@ CREATE TABLE IF NOT EXISTS dim_tenant_goods (
SCD2_end_time TIMESTAMPTZ,
SCD2_is_current INT,
SCD2_version INT,
PRIMARY KEY (tenant_goods_id)
PRIMARY KEY (tenant_goods_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_tenant_goods IS 'DWD 维度表dim_tenant_goods。ODS 来源表billiards_ods.tenant_goods_master对应 JSONtenant_goods_master.json分析tenant_goods_master-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -666,7 +666,7 @@ CREATE TABLE IF NOT EXISTS dim_tenant_goods_Ex (
SCD2_end_time TIMESTAMPTZ,
SCD2_is_current INT,
SCD2_version INT,
PRIMARY KEY (tenant_goods_id)
PRIMARY KEY (tenant_goods_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_tenant_goods_ex IS 'DWD 维度表扩展字段表dim_tenant_goods_ex。ODS 来源表billiards_ods.tenant_goods_master对应 JSONtenant_goods_master.json分析tenant_goods_master-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -719,7 +719,7 @@ CREATE TABLE IF NOT EXISTS dim_store_goods (
SCD2_end_time TIMESTAMPTZ,
SCD2_is_current INT,
SCD2_version INT,
PRIMARY KEY (site_goods_id)
PRIMARY KEY (site_goods_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_store_goods IS 'DWD 维度表dim_store_goods。ODS 来源表billiards_ods.store_goods_master对应 JSONstore_goods_master.json分析store_goods_master-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -780,7 +780,7 @@ CREATE TABLE IF NOT EXISTS dim_store_goods_Ex (
SCD2_end_time TIMESTAMPTZ,
SCD2_is_current INT,
SCD2_version INT,
PRIMARY KEY (site_goods_id)
PRIMARY KEY (site_goods_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_store_goods_ex IS 'DWD 维度表扩展字段表dim_store_goods_ex。ODS 来源表billiards_ods.store_goods_master对应 JSONstore_goods_master.json分析store_goods_master-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -833,7 +833,7 @@ CREATE TABLE IF NOT EXISTS dim_goods_category (
SCD2_end_time TIMESTAMPTZ,
SCD2_is_current INT,
SCD2_version INT,
PRIMARY KEY (category_id)
PRIMARY KEY (category_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_goods_category IS 'DWD 维度表dim_goods_category。ODS 来源表billiards_ods.stock_goods_category_tree对应 JSONstock_goods_category_tree.json分析stock_goods_category_tree-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -876,7 +876,7 @@ CREATE TABLE IF NOT EXISTS dim_groupbuy_package (
SCD2_end_time TIMESTAMPTZ,
SCD2_is_current INT,
SCD2_version INT,
PRIMARY KEY (groupbuy_package_id)
PRIMARY KEY (groupbuy_package_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_groupbuy_package IS 'DWD 维度表dim_groupbuy_package。ODS 来源表billiards_ods.group_buy_packages对应 JSONgroup_buy_packages.json分析group_buy_packages-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';
@@ -927,7 +927,7 @@ CREATE TABLE IF NOT EXISTS dim_groupbuy_package_Ex (
SCD2_end_time TIMESTAMPTZ,
SCD2_is_current INT,
SCD2_version INT,
PRIMARY KEY (groupbuy_package_id)
PRIMARY KEY (groupbuy_package_id, scd2_start_time)
);
COMMENT ON TABLE billiards_dwd.dim_groupbuy_package_ex IS 'DWD 维度表扩展字段表dim_groupbuy_package_ex。ODS 来源表billiards_ods.group_buy_packages对应 JSONgroup_buy_packages.json分析group_buy_packages-Analysis.md。装载/清洗逻辑参考etl_billiards/tasks/dwd_load_task.pyDwdLoadTask';

View File

@@ -0,0 +1,21 @@
# DWS 数据层需求
## 简介
项目路径C:\dev\LLTQ\ETL\feiqiu-ETL
本文档描述在ETL已完成的DWD层数据基础上对DWS层的数据处理
- 完成对DWS层数据库的处理即数据库设计成果为DDL的SQL语句。
- 数据读取处理到落库即DWD读取Python处理SQL写入。
文档更多聚焦业务描述你需要使用专业技能使用面向对象编程OOP思想完成程序设计直至代码完成
- 参考.\README.md 了解现在项目现状。
- 参考.\etl_billiards\docs\dwd_main_tables_dictionary.md 了解 DWD的schema的表和字段若与数据库有出路则以当前数据库为准。
- SQL和Python代码需要详尽的高密度的中文注释。
- 完成内容,需要详尽高密度的补充至.\README.md以方便后续维护。
- DWS的表与表的字段 参考.\etl_billiards\docs\dwd_main_tables_dictionary.md 完成类似的数据库文档,方便后续维护。
- 注意中文编码需求。
## 具体需求
### 助教视角
- 需要

View File

@@ -0,0 +1,80 @@
# dim_assistant_ex 助教档案扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_assistant_ex |
| 主键 | assistant_id, scd2_start_time |
| 主表 | dim_assistant |
| 记录数 | 69 |
| 说明 | 助教档案的扩展字段,包含个人资料、评分、状态配置、灯控等详细信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | assistant_id | BIGINT | NO | PK | 助教 ID → dim_assistant |
| 2 | gender | INTEGER | YES | | 性别。**枚举值**: 0(59)=未填写, 2(10)=女(**[1=男 待确认]** |
| 3 | birth_date | TIMESTAMPTZ | YES | | 出生日期 |
| 4 | avatar | TEXT | YES | | 头像 URL默认: https://oss.ficoo.vip/maUiImages/images/defaultAvatar.png |
| 5 | introduce | TEXT | YES | | 个人简介(当前数据全为空) |
| 6 | video_introduction_url | TEXT | YES | | 视频介绍 URL |
| 7 | height | NUMERIC(5,2) | YES | | 身高(厘米) |
| 8 | weight | NUMERIC(5,2) | YES | | 体重(公斤) |
| 9 | shop_name | TEXT | YES | | 门店名称快照。**当前值**: "朗朗桌球" |
| 10 | group_id | BIGINT | YES | | 分组 ID当前数据全为 0 |
| 11 | group_name | TEXT | YES | | 分组名称(当前数据全为空) |
| 12 | person_org_id | BIGINT | YES | | 人事组织 ID |
| 13 | staff_id | BIGINT | YES | | 员工 ID当前数据全为 0 |
| 14 | staff_profile_id | BIGINT | YES | | 员工档案 ID当前数据全为 0 |
| 15 | assistant_grade | DOUBLE PRECISION | YES | | 平均评分 |
| 16 | sum_grade | DOUBLE PRECISION | YES | | 累计评分 |
| 17 | get_grade_times | INTEGER | YES | | 评分次数(当前数据全为 0 |
| 18 | charge_way | INTEGER | YES | | 计费方式。**枚举值**: 2(69)=计时 **[其他值待确认]** |
| 19 | allow_cx | INTEGER | YES | | 允许促销计费。**枚举值**: 1(69)=允许 |
| 20 | is_guaranteed | INTEGER | YES | | 是否保底。**枚举值**: 1(69)=有保底 |
| 21 | salary_grant_enabled | INTEGER | YES | | 薪资发放开关。**枚举值**: 2(69)=**[含义待确认]** |
| 22 | entry_type | INTEGER | YES | | 入职类型。**枚举值**: 1(68)=正式, 3(1)=**[待确认]** |
| 23 | entry_sign_status | INTEGER | YES | | 入职签约状态。**枚举值**: 0(69)=未签约 |
| 24 | resign_sign_status | INTEGER | YES | | 离职签约状态。**枚举值**: 0(69)=未签约 |
| 25 | work_status | INTEGER | YES | | 工作状态。**枚举值**: 1(29)=在岗, 2(40)=离岗 |
| 26 | show_status | INTEGER | YES | | 展示状态。**枚举值**: 1(69)=显示 |
| 27 | show_sort | INTEGER | YES | | 展示排序序号 |
| 28 | online_status | INTEGER | YES | | 在线状态。**枚举值**: 1(69)=在线 |
| 29 | is_delete | INTEGER | YES | | 删除标记。**枚举值**: 0(69)=未删除 |
| 30 | criticism_status | INTEGER | YES | | 投诉状态。**枚举值**: 1(68)=**[待确认]**, 2(1)=**[待确认]** |
| 31 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
| 32 | update_time | TIMESTAMPTZ | YES | | 更新时间 |
| 33 | start_time | TIMESTAMPTZ | YES | | 配置生效开始时间 |
| 34 | end_time | TIMESTAMPTZ | YES | | 配置生效结束时间 |
| 35 | last_table_id | BIGINT | YES | | 最近服务台桌 ID → dim_table |
| 36 | last_table_name | TEXT | YES | | 最近服务台桌名称。**样本值**: "发财", "C2", "VIP包厢 VIP5" |
| 37 | last_update_name | TEXT | YES | | 最近更新操作人。**样本值**: "教练:周蒙", "管理员:郑丽珊" |
| 38 | order_trade_no | BIGINT | YES | | 最近关联订单号 |
| 39 | ding_talk_synced | INTEGER | YES | | 钉钉同步状态。**枚举值**: 1(69)=已同步 |
| 40 | site_light_cfg_id | BIGINT | YES | | 灯控配置 ID当前数据全为 0 |
| 41 | light_equipment_id | TEXT | YES | | 灯控设备 ID当前数据全为空 |
| 42 | light_status | INTEGER | YES | | 灯控状态。**枚举值**: 2(69)=**[含义待确认]** |
| 43 | is_team_leader | INTEGER | YES | | 是否组长。**枚举值**: 0(69)=否 |
| 44 | serial_number | BIGINT | YES | | 序列号 |
| 45 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 46 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 47 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 48 | scd2_version | INTEGER | YES | | 版本号 |
## 使用说明
```sql
-- 关联主表与扩展表
SELECT m.*, e.*
FROM billiards_dwd.dim_assistant m
JOIN billiards_dwd.dim_assistant_ex e
ON m.assistant_id = e.assistant_id
AND m.scd2_start_time = e.scd2_start_time
WHERE m.scd2_is_current = 1;
```

View File

@@ -0,0 +1,64 @@
# dim_groupbuy_package_ex 团购套餐扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_groupbuy_package_ex |
| 主键 | groupbuy_package_id, scd2_start_time |
| 主表 | dim_groupbuy_package |
| 记录数 | 34 |
| 说明 | 团购套餐的扩展配置,包含使用时段、台区限制、套餐类型等详细信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | groupbuy_package_id | BIGINT | NO | PK | 套餐 ID → dim_groupbuy_package |
| 2 | site_name | VARCHAR(100) | YES | | 门店名称快照。**当前值**: "朗朗桌球" |
| 3 | usable_count | INTEGER | YES | | 可使用次数(当前数据全为 0表示不限次 |
| 4 | date_type | INTEGER | YES | | 日期类型。**枚举值**: 1(34)=**[含义待确认]** |
| 5 | usable_range | VARCHAR(255) | YES | | 可用日期范围描述(当前数据全为空) |
| 6 | date_info | VARCHAR(255) | YES | | 日期信息 |
| 7 | start_clock | VARCHAR(16) | YES | | 可用开始时间。**枚举值**: "00:00:00"(29), "10:00:00"(4), "23:00:00"(1) |
| 8 | end_clock | VARCHAR(16) | YES | | 可用结束时间。**枚举值**: "1.00:00:00"(29)=次日0点, "23:59:59"(3), "1.02:00:00"(2)=次日2点 |
| 9 | add_start_clock | VARCHAR(16) | YES | | 附加时段开始时间 |
| 10 | add_end_clock | VARCHAR(16) | YES | | 附加时段结束时间 |
| 11 | area_tag_type | INTEGER | YES | | 区域标记类型。**枚举值**: 1(34)=**[含义待确认]** |
| 12 | table_area_id | BIGINT | YES | | 台区 ID当前数据全为 0 |
| 13 | tenant_table_area_id | BIGINT | YES | | 租户级台区 ID当前数据全为 0 |
| 14 | table_area_id_list | VARCHAR(512) | YES | | 台区 ID 列表(当前数据全为空) |
| 15 | group_type | INTEGER | YES | | 团购类型。**枚举值**: 1(34)=**[含义待确认]** |
| 16 | system_group_type | INTEGER | YES | | 系统团购类型。**枚举值**: 1(34)=**[含义待确认]** |
| 17 | package_type | INTEGER | YES | | 套餐类型。**枚举值**: 1(26)=普通套餐 **[待确认]**, 2(8)=VIP套餐 **[待确认]** |
| 18 | effective_status | INTEGER | YES | | 生效状态。**枚举值**: 1(24)=有效, 3(10)=失效 **[待确认]** |
| 19 | max_selectable_categories | INTEGER | YES | | 最大可选分类数(当前数据全为 0 |
| 20 | creator_name | VARCHAR(100) | YES | | 创建人。**样本值**: "店长:郑丽珊", "管理员:郑丽珊" |
| 21 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 22 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 23 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 24 | scd2_version | INTEGER | YES | | 版本号 |
## 样本数据
| groupbuy_package_id | start_clock | end_clock | package_type | effective_status | creator_name |
|--------------------|-------------|-----------|--------------|------------------|--------------|
| 2798905767676933 | 00:00:00 | 1.00:00:00 | 2 | 1 | 店长:郑丽珊 |
| 2798901295615045 | 00:00:00 | 1.00:00:00 | 2 | 3 | 店长:郑丽珊 |
| 2798731703045189 | 00:00:00 | 1.00:00:00 | 1 | 1 | 店长:郑丽珊 |
## 使用说明
```sql
-- 关联主表与扩展表
SELECT m.package_name, m.duration_seconds, e.start_clock, e.end_clock, e.effective_status
FROM billiards_dwd.dim_groupbuy_package m
JOIN billiards_dwd.dim_groupbuy_package_ex e
ON m.groupbuy_package_id = e.groupbuy_package_id
AND m.scd2_start_time = e.scd2_start_time
WHERE m.scd2_is_current = 1;
```

View File

@@ -0,0 +1,90 @@
# dim_member_card_account_ex 会员卡账户扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_member_card_account_ex |
| 主键 | member_card_id, scd2_start_time |
| 主表 | dim_member_card_account |
| 记录数 | 945 |
| 说明 | 会员卡账户扩展表,包含折扣配置、抵扣规则、使用限制等详细配置 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | member_card_id | BIGINT | NO | PK | 会员卡 ID → dim_member_card_account |
| 2 | site_name | TEXT | YES | | 门店名称。**当前值**: "朗朗桌球" |
| 3 | tenant_name | VARCHAR(64) | YES | | 租户名称(当前数据全为空) |
| 4 | tenantavatar | TEXT | YES | | 租户头像(当前数据全为空) |
| 5 | effect_site_id | BIGINT | YES | | 生效门店 ID0=不限门店) |
| 6 | able_cross_site | INTEGER | YES | | 允许跨门店。**枚举值**: 1(945)=允许 |
| 7 | card_physics_type | INTEGER | YES | | 物理卡类型。**枚举值**: 1(945)=**[待确认]** |
| 8 | card_no | TEXT | YES | | 物理卡号(当前数据全为空) |
| 9 | bind_password | TEXT | YES | | 绑定密码(当前数据全为空) |
| 10 | use_scene | TEXT | YES | | 使用场景(当前数据全为空) |
| 11 | denomination | NUMERIC(18,2) | YES | | 面额/初始额度 |
| 12 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
| 13 | disable_start_time | TIMESTAMPTZ | YES | | 禁用开始时间 |
| 14 | disable_end_time | TIMESTAMPTZ | YES | | 禁用结束时间 |
| 15 | is_allow_give | INTEGER | YES | | 允许转赠。**枚举值**: 0(945)=不允许 |
| 16 | is_allow_order_deduct | INTEGER | YES | | 允许订单抵扣。**枚举值**: 0(945)=不允许 |
| 17 | sort | INTEGER | YES | | 排序序号 |
| 18 | table_discount | NUMERIC(10,2) | YES | | 台费折扣率10.0=不打折) |
| 19 | goods_discount | NUMERIC(10,2) | YES | | 商品折扣率 |
| 20 | assistant_discount | NUMERIC(10,2) | YES | | 助教折扣率 |
| 21 | assistant_reward_discount | NUMERIC(10,2) | YES | | 助教奖励折扣率 |
| 22 | table_service_discount | NUMERIC(10,2) | YES | | 台费服务折扣率 |
| 23 | goods_service_discount | NUMERIC(10,2) | YES | | 商品服务折扣率 |
| 24 | assistant_service_discount | NUMERIC(10,2) | YES | | 助教服务折扣率 |
| 25 | coupon_discount | NUMERIC(10,2) | YES | | 券折扣率 |
| 26 | table_discount_sub_switch | INTEGER | YES | | 台费折扣叠加开关。**枚举值**: 2(945)=关闭 **[1=开启 待确认]** |
| 27 | goods_discount_sub_switch | INTEGER | YES | | 商品折扣叠加开关 |
| 28 | assistant_discount_sub_switch | INTEGER | YES | | 助教折扣叠加开关 |
| 29 | assistant_reward_discount_sub_switch | INTEGER | YES | | 助教奖励折扣叠加开关 |
| 30 | goods_discount_range_type | INTEGER | YES | | 商品折扣范围类型。**枚举值**: 1(945)=**[待确认]** |
| 31 | table_deduct_radio | NUMERIC(10,2) | YES | | 台费抵扣比例100.0=全额抵扣) |
| 32 | goods_deduct_radio | NUMERIC(10,2) | YES | | 商品抵扣比例 |
| 33 | assistant_deduct_radio | NUMERIC(10,2) | YES | | 助教抵扣比例 |
| 34 | table_service_deduct_radio | NUMERIC(10,2) | YES | | 台费服务抵扣比例 |
| 35 | goods_service_deduct_radio | NUMERIC(10,2) | YES | | 商品服务抵扣比例 |
| 36 | assistant_service_deduct_radio | NUMERIC(10,2) | YES | | 助教服务抵扣比例 |
| 37 | assistant_reward_deduct_radio | NUMERIC(10,2) | YES | | 助教奖励抵扣比例 |
| 38 | coupon_deduct_radio | NUMERIC(10,2) | YES | | 券抵扣比例 |
| 39 | cardsettlededuct | NUMERIC(18,2) | YES | | 结算扣卡金额配置 |
| 40 | tablecarddeduct | NUMERIC(18,2) | YES | | 台费扣卡金额 |
| 41 | tableservicecarddeduct | NUMERIC(18,2) | YES | | 台费服务扣卡金额 |
| 42 | goodscardeduct | NUMERIC(18,2) | YES | | 商品扣卡金额 |
| 43 | goodsservicecarddeduct | NUMERIC(18,2) | YES | | 商品服务扣卡金额 |
| 44 | assistantcarddeduct | NUMERIC(18,2) | YES | | 助教扣卡金额 |
| 45 | assistantservicecarddeduct | NUMERIC(18,2) | YES | | 助教服务扣卡金额 |
| 46 | assistantrewardcarddeduct | NUMERIC(18,2) | YES | | 助教奖励扣卡金额 |
| 47 | couponcarddeduct | NUMERIC(18,2) | YES | | 券扣卡金额 |
| 48 | deliveryfeededuct | NUMERIC(18,2) | YES | | 配送费扣卡金额 |
| 49 | tableareaid | TEXT | YES | | 可用台区 ID 列表(当前数据全为空) |
| 50 | goodscategoryid | TEXT | YES | | 可用商品分类 ID 列表(当前数据全为空) |
| 51 | pdassisnatlevel | TEXT | YES | | 陪打助教等级限制。**当前值**: "{}" |
| 52 | cxassisnatlevel | TEXT | YES | | 促销助教等级限制。**当前值**: "{}" |
| 53 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 54 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 55 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 56 | scd2_version | INTEGER | YES | | 版本号 |
## 使用说明
```sql
-- 关联查询卡片及折扣配置
SELECT
m.member_card_type_name, m.balance,
e.table_discount, e.goods_discount, e.assistant_discount
FROM billiards_dwd.dim_member_card_account m
JOIN billiards_dwd.dim_member_card_account_ex e
ON m.member_card_id = e.member_card_id
AND m.scd2_start_time = e.scd2_start_time
WHERE m.scd2_is_current = 1;
```

View File

@@ -0,0 +1,51 @@
# dim_member_ex 会员档案扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_member_ex |
| 主键 | member_id, scd2_start_time |
| 主表 | dim_member |
| 记录数 | 556 |
| 说明 | 会员档案扩展表,包含积分、成长值、状态等字段 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | member_id | BIGINT | NO | PK | 会员 ID → dim_member |
| 2 | referrer_member_id | BIGINT | YES | | 推荐人会员 ID当前数据全为 0表示无推荐人 |
| 3 | point | NUMERIC(18,2) | YES | | 积分余额 |
| 4 | register_site_name | TEXT | YES | | 注册门店名称。**当前值**: "朗朗桌球" |
| 5 | growth_value | NUMERIC(18,2) | YES | | 成长值 |
| 6 | user_status | INTEGER | YES | | 用户状态。**枚举值**: 1(556)=正常 |
| 7 | status | INTEGER | YES | | 账户状态。**枚举值**: 1(490)=正常, 3(66)=**[含义待确认]** |
| 8 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 9 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 10 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 11 | scd2_version | INTEGER | YES | | 版本号 |
## 样本数据
| member_id | point | growth_value | user_status | status |
|-----------|-------|--------------|-------------|--------|
| 3043883848157381 | 0.00 | 0.00 | 1 | 1 |
| 3037269565082949 | 0.00 | 0.00 | 1 | 1 |
| 3025342944414469 | 0.00 | 0.00 | 1 | 1 |
## 使用说明
```sql
-- 关联主表与扩展表
SELECT m.*, e.point, e.growth_value, e.status
FROM billiards_dwd.dim_member m
JOIN billiards_dwd.dim_member_ex e
ON m.member_id = e.member_id
AND m.scd2_start_time = e.scd2_start_time
WHERE m.scd2_is_current = 1;
```

View File

@@ -0,0 +1,57 @@
# dim_site_ex 门店扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_site_ex |
| 主键 | site_id, scd2_start_time |
| 主表 | dim_site |
| 记录数 | 1 |
| 说明 | 门店扩展表,包含灯控、考勤、客服等配置信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | site_id | BIGINT | NO | PK | 门店 ID → dim_site |
| 2 | avatar | TEXT | YES | | 门店头像 URL |
| 3 | address | TEXT | YES | | 地址(冗余) |
| 4 | longitude | NUMERIC(9,6) | YES | | 经度(冗余) |
| 5 | latitude | NUMERIC(9,6) | YES | | 纬度(冗余) |
| 6 | tenant_site_region_id | BIGINT | YES | | 区域 ID冗余 |
| 7 | auto_light | INTEGER | YES | | 自动灯控。**枚举值**: 1(1)=启用 |
| 8 | light_status | INTEGER | YES | | 灯控状态。**枚举值**: 1(1)=**[待确认]** |
| 9 | light_type | INTEGER | YES | | 灯控类型。**枚举值**: 0(1)=**[待确认]** |
| 10 | light_token | TEXT | YES | | 灯控令牌 |
| 11 | site_type | INTEGER | YES | | 门店类型(冗余) |
| 12 | site_label | TEXT | YES | | 门店标签(冗余) |
| 13 | attendance_enabled | INTEGER | YES | | 考勤启用。**枚举值**: 1(1)=启用 |
| 14 | attendance_distance | INTEGER | YES | | 考勤距离(米)。**当前值**: 0 |
| 15 | customer_service_qrcode | TEXT | YES | | 客服二维码 URL |
| 16 | customer_service_wechat | TEXT | YES | | 客服微信号 |
| 17 | fixed_pay_qrcode | TEXT | YES | | 固定收款码 URL |
| 18 | prod_env | TEXT | YES | | 环境标识。**当前值**: "1" |
| 19 | shop_status | INTEGER | YES | | 营业状态(冗余) |
| 20 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
| 21 | update_time | TIMESTAMPTZ | YES | | 更新时间 |
| 22 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 23 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 24 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 25 | scd2_version | INTEGER | YES | | 版本号 |
## 使用说明
```sql
-- 关联主表与扩展表
SELECT m.*, e.*
FROM billiards_dwd.dim_site m
JOIN billiards_dwd.dim_site_ex e
ON m.site_id = e.site_id
AND m.scd2_start_time = e.scd2_start_time
WHERE m.scd2_is_current = 1;
```

View File

@@ -0,0 +1,62 @@
# dim_store_goods_ex 门店商品扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_store_goods_ex |
| 主键 | site_goods_id, scd2_start_time |
| 主表 | dim_store_goods |
| 记录数 | 170 |
| 说明 | 门店商品扩展表,包含单位、成本、库存管理、折扣等详细配置 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | site_goods_id | BIGINT | NO | PK | 门店商品 ID → dim_store_goods |
| 2 | site_name | TEXT | YES | | 门店名称。**当前值**: "朗朗桌球" |
| 3 | unit | TEXT | YES | | 商品单位。**枚举值**: "包"(62), "瓶"(49), "个"(17), "份"(14), "根"(10), "杯"(5), "盒"(4), "桶"(3), "盘"(2), "罐"(1), "支"(1), "双"(1), "张"(1) |
| 4 | goods_barcode | TEXT | YES | | 商品条码(当前数据全为空) |
| 5 | goods_cover_url | TEXT | YES | | 商品封面图 URL |
| 6 | pinyin_initial | TEXT | YES | | 拼音首字母(用于搜索) |
| 7 | stock_qty | INTEGER | YES | | 库存数量 |
| 8 | stock_secondary_qty | INTEGER | YES | | 副单位库存(当前数据全为 0 |
| 9 | safety_stock_qty | INTEGER | YES | | 安全库存(当前数据全为 0 |
| 10 | cost_price | NUMERIC(18,4) | YES | | 成本价 |
| 11 | cost_price_type | INTEGER | YES | | 成本价类型。**枚举值**: 1(160)=**[待确认]**, 2(10)=**[待确认]** |
| 12 | provisional_total_cost | NUMERIC(18,2) | YES | | 暂估总成本 |
| 13 | total_purchase_cost | NUMERIC(18,2) | YES | | 采购总成本 |
| 14 | min_discount_price | NUMERIC(18,2) | YES | | 最低折扣价 |
| 15 | is_discountable | INTEGER | YES | | 允许折扣。**枚举值**: 1(170)=允许 |
| 16 | days_on_shelf | INTEGER | YES | | 上架天数 |
| 17 | audit_status | INTEGER | YES | | 审核状态。**枚举值**: 2(170)=**[待确认]** |
| 18 | sale_channel | INTEGER | YES | | 销售渠道(当前数据全为空) |
| 19 | is_warehousing | INTEGER | YES | | 库存管理。**枚举值**: 1(170)=参与库存管理 |
| 20 | freeze_status | INTEGER | YES | | 冻结状态。**枚举值**: 0(170)=未冻结 |
| 21 | forbid_sell_status | INTEGER | YES | | 禁售状态。**枚举值**: 1(170)=**[待确认]** |
| 22 | able_site_transfer | INTEGER | YES | | 允许店间调拨。**枚举值**: 0(1), 2(169) **[待确认]** |
| 23 | custom_label_type | INTEGER | YES | | 自定义标签类型。**枚举值**: 2(170)=**[待确认]** |
| 24 | option_required | INTEGER | YES | | 选项必填。**枚举值**: 1(170)=**[待确认]** |
| 25 | remark | TEXT | YES | | 备注(当前数据全为空) |
| 26 | sort_order | INTEGER | YES | | 排序序号 |
| 27 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 28 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 29 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 30 | scd2_version | INTEGER | YES | | 版本号 |
## 使用说明
```sql
-- 关联主表与扩展表
SELECT m.goods_name, m.sale_price, m.sale_qty, e.unit, e.stock_qty, e.cost_price
FROM billiards_dwd.dim_store_goods m
JOIN billiards_dwd.dim_store_goods_ex e
ON m.site_goods_id = e.site_goods_id
AND m.scd2_start_time = e.scd2_start_time
WHERE m.scd2_is_current = 1;
```

View File

@@ -0,0 +1,50 @@
# dim_table_ex 台桌扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_table_ex |
| 主键 | table_id, scd2_start_time |
| 主表 | dim_table |
| 记录数 | 74 |
| 说明 | 台桌扩展表,包含展示状态、预约设置、台呢使用等信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | table_id | BIGINT | NO | PK | 台桌 ID → dim_table |
| 2 | show_status | INTEGER | YES | | 展示状态。**枚举值**: 1(70)=显示, 2(4)=隐藏 |
| 3 | is_online_reservation | INTEGER | YES | | 在线预约。**枚举值**: 1(2)=支持, 2(72)=不支持 |
| 4 | table_cloth_use_time | INTEGER | YES | | 台呢已使用时间(当前数据全为空) |
| 5 | table_cloth_use_cycle | INTEGER | YES | | 台呢使用周期(当前数据全为 0 |
| 6 | table_status | INTEGER | YES | | 台桌状态。**枚举值**: 1(66)=空闲, 2(1)=**[待确认]**, 3(7)=使用中 **[待确认]** |
| 7 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 8 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 9 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 10 | scd2_version | INTEGER | YES | | 版本号 |
## 样本数据
| table_id | show_status | is_online_reservation | table_status |
|----------|-------------|-----------------------|--------------|
| 2791964216463493 | 1 | 2 | 1 |
| 2792521437958213 | 1 | 2 | 1 |
| 2793001695301765 | 1 | 2 | 1 |
## 使用说明
```sql
-- 关联主表与扩展表
SELECT m.table_name, m.site_table_area_name, e.show_status, e.table_status
FROM billiards_dwd.dim_table m
JOIN billiards_dwd.dim_table_ex e
ON m.table_id = e.table_id
AND m.scd2_start_time = e.scd2_start_time
WHERE m.scd2_is_current = 1;
```

View File

@@ -0,0 +1,54 @@
# dim_tenant_goods_ex 租户商品扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_tenant_goods_ex |
| 主键 | tenant_goods_id, scd2_start_time |
| 主表 | dim_tenant_goods |
| 记录数 | 171 |
| 说明 | 租户商品扩展表,包含图片、条码、成本、折扣配置等详细信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | tenant_goods_id | BIGINT | NO | PK | 租户商品 ID → dim_tenant_goods |
| 2 | remark_name | VARCHAR(128) | YES | | 备注名称(当前数据全为空) |
| 3 | pinyin_initial | VARCHAR(128) | YES | | 拼音首字母 |
| 4 | goods_cover | VARCHAR(512) | YES | | 商品封面图 URL |
| 5 | goods_bar_code | VARCHAR(64) | YES | | 商品条码(当前数据全为空) |
| 6 | commodity_code | VARCHAR(64) | YES | | 商品编码 |
| 7 | commodity_code_list | VARCHAR(256) | YES | | 商品编码列表 |
| 8 | min_discount_price | NUMERIC(18,2) | YES | | 最低折扣价 |
| 9 | cost_price | NUMERIC(18,2) | YES | | 成本价 |
| 10 | cost_price_type | INTEGER | YES | | 成本价类型。**枚举值**: 1(160), 2(11) **[待确认]** |
| 11 | able_discount | INTEGER | YES | | 允许折扣。**枚举值**: 1(171)=允许 |
| 12 | sale_channel | INTEGER | YES | | 销售渠道(当前数据全为空) |
| 13 | is_warehousing | INTEGER | YES | | 库存管理。**枚举值**: 1(171)=参与库存管理 |
| 14 | is_in_site | BOOLEAN | YES | | 是否在门店。**枚举值**: False(171)=否 |
| 15 | able_site_transfer | INTEGER | YES | | 允许店间调拨。**枚举值**: 0(1), 2(170) **[待确认]** |
| 16 | common_sale_royalty | INTEGER | YES | | 普通销售提成(当前数据全为 0 |
| 17 | point_sale_royalty | INTEGER | YES | | 积分销售提成(当前数据全为 0 |
| 18 | out_goods_id | BIGINT | YES | | 外部商品 ID当前数据全为 0 |
| 19 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 20 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 21 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 22 | scd2_version | INTEGER | YES | | 版本号 |
## 使用说明
```sql
-- 关联主表与扩展表
SELECT m.goods_name, m.market_price, e.cost_price, e.min_discount_price
FROM billiards_dwd.dim_tenant_goods m
JOIN billiards_dwd.dim_tenant_goods_ex e
ON m.tenant_goods_id = e.tenant_goods_id
AND m.scd2_start_time = e.scd2_start_time
WHERE m.scd2_is_current = 1;
```

View File

@@ -0,0 +1,61 @@
# dwd_assistant_service_log_ex 助教服务流水扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_assistant_service_log_ex |
| 主键 | assistant_service_id |
| 主表 | dwd_assistant_service_log |
| 记录数 | 5003 |
| 说明 | 助教服务流水扩展表,包含台桌、折扣、评分、废单等详细信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | assistant_service_id | BIGINT | NO | PK | 服务流水 ID → dwd_assistant_service_log |
| 2 | table_name | VARCHAR(64) | YES | | 台桌名称。**样本值**: "888", "TV", "VIP5", "666", "C1", "VIP1", "S1", "M1", "A1" |
| 3 | assistant_name | VARCHAR(64) | YES | | 助教真实姓名。**样本值**: "陈嘉怡", "张永英", "邹绮", "胡敏" |
| 4 | ledger_name | VARCHAR(128) | YES | | 账本名称(工号-昵称)。**样本值**: "2-佳怡", "23-婉婉", "15-七七" |
| 5 | ledger_group_name | VARCHAR(128) | YES | | 账本分组名称(当前数据全为空) |
| 6 | ledger_count | INTEGER | YES | | 计费时长(秒,与主表 income_seconds 类似) |
| 7 | member_discount_amount | NUMERIC(10,2) | YES | | 会员折扣金额 |
| 8 | manual_discount_amount | NUMERIC(10,2) | YES | | 手动折扣金额 |
| 9 | service_money | NUMERIC(10,2) | YES | | 服务费金额 |
| 10 | returns_clock | INTEGER | YES | | 退时长(当前数据全为 0 |
| 11 | ledger_start_time | TIMESTAMPTZ | YES | | 账本开始时间 |
| 12 | ledger_end_time | TIMESTAMPTZ | YES | | 账本结束时间 |
| 13 | ledger_status | INTEGER | YES | | 账本状态。**枚举值**: 1(5003)=已结算 |
| 14 | is_confirm | INTEGER | YES | | 是否确认。**枚举值**: 2(5003)=**[待确认]** |
| 15 | is_single_order | INTEGER | YES | | 是否独立订单。**枚举值**: 1(5003)=是 |
| 16 | is_not_responding | INTEGER | YES | | 无响应。**枚举值**: 0(5003)=正常 |
| 17 | is_trash | INTEGER | YES | | 是否废单。**枚举值**: 0(5003)=正常 |
| 18 | trash_applicant_id | BIGINT | YES | | 废单申请人 ID当前数据全为 0 |
| 19 | trash_applicant_name | VARCHAR(64) | YES | | 废单申请人姓名(当前数据全为空) |
| 20 | trash_reason | VARCHAR(255) | YES | | 废单原因(当前数据全为空) |
| 21 | salesman_user_id | BIGINT | YES | | 销售员用户 ID当前数据全为 0 |
| 22 | salesman_name | VARCHAR(64) | YES | | 销售员姓名(当前数据全为空) |
| 23 | salesman_org_id | BIGINT | YES | | 销售员组织 ID当前数据全为 0 |
| 24 | skill_grade | INTEGER | YES | | 技能评分(当前数据全为 0 |
| 25 | service_grade | INTEGER | YES | | 服务评分(当前数据全为 0 |
| 26 | composite_grade | NUMERIC(5,2) | YES | | 综合评分 |
| 27 | sum_grade | NUMERIC(10,2) | YES | | 累计评分 |
| 28 | get_grade_times | INTEGER | YES | | 评分次数(当前数据全为 0 |
| 29 | grade_status | INTEGER | YES | | 评分状态。**枚举值**: 0(216)=未评分, 1(4787)=已评分 **[待确认]** |
| 30 | composite_grade_time | TIMESTAMPTZ | YES | | 评分时间 |
## 使用说明
```sql
-- 关联主表与扩展表
SELECT m.nickname, m.ledger_amount, e.table_name, e.assistant_name, e.grade_status
FROM billiards_dwd.dwd_assistant_service_log m
JOIN billiards_dwd.dwd_assistant_service_log_ex e
ON m.assistant_service_id = e.assistant_service_id
WHERE m.is_delete = 0;
```

View File

@@ -0,0 +1,49 @@
# dwd_assistant_trash_event_ex 助教服务作废扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_assistant_trash_event_ex |
| 主键 | assistant_trash_event_id |
| 主表 | dwd_assistant_trash_event |
| 记录数 | 98 |
| 说明 | 助教服务作废扩展表,记录台桌和台区名称 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | assistant_trash_event_id | BIGINT | NO | PK | 作废事件 ID → dwd_assistant_trash_event |
| 2 | table_name | VARCHAR(64) | YES | | 台桌名称。**热门值**: "888"(14), "发财"(8), "C1"(7), "M7"(6) |
| 3 | table_area_name | VARCHAR(64) | YES | | 台区名称。**枚举值**: "C区"(16), "K包"(14), "A区"(11), "发财"(8), "B区"(7), "麻将房"(7), "补时长"(7), "VIP包厢"(6) |
## 台区作废分布
| 台区名称 | 作废次数 | 占比 |
|----------|----------|------|
| C区 | 16 | 16.3% |
| K包 | 14 | 14.3% |
| A区 | 11 | 11.2% |
| 发财 | 8 | 8.2% |
| B区 | 7 | 7.1% |
| 麻将房 | 7 | 7.1% |
| 补时长 | 7 | 7.1% |
| VIP包厢 | 6 | 6.1% |
## 样本数据
| table_name | table_area_name |
|------------|-----------------|
| C1 | C区 |
| 补时长5 | 补时长 |
| VIP1 | VIP包厢 |
| 888 | K包 |
## 使用说明
与主表 `dwd_assistant_trash_event` 通过 `assistant_trash_event_id` 关联,提供台桌和台区名称信息。

View File

@@ -0,0 +1,62 @@
# dwd_groupbuy_redemption_ex 团购核销扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_groupbuy_redemption_ex |
| 主键 | redemption_id |
| 主表 | dwd_groupbuy_redemption |
| 记录数 | 11427 |
| 说明 | 团购核销扩展表,记录门店、台桌名称、操作员等扩展信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | redemption_id | BIGINT | NO | PK | 核销 ID → dwd_groupbuy_redemption |
| 2 | site_name | VARCHAR(64) | YES | | 门店名称。**枚举值**: "朗朗桌球"(11427) |
| 3 | table_name | VARCHAR(64) | YES | | 台桌名称。**热门值**: "A3"(892), "A4"(858), "A5"(835), "A7"(774) |
| 4 | table_area_name | VARCHAR(64) | YES | | 台区名称。**枚举值**: "A区"(9294), "B区"(998), "斯诺克区"(962), "麻将房"(137) |
| 5 | order_pay_id | BIGINT | YES | | 支付单 ID当前数据全为 0 |
| 6 | goods_option_price | NUMERIC(18,2) | YES | | 商品选项价格 |
| 7 | goods_promotion_money | NUMERIC(18,2) | YES | | 商品促销金额 |
| 8 | table_service_promotion_money | NUMERIC(18,2) | YES | | 台服促销金额 |
| 9 | assistant_promotion_money | NUMERIC(18,2) | YES | | 助教促销金额 |
| 10 | assistant_service_promotion_money | NUMERIC(18,2) | YES | | 助教服务促销金额 |
| 11 | reward_promotion_money | NUMERIC(18,2) | YES | | 奖励促销金额 |
| 12 | recharge_promotion_money | NUMERIC(18,2) | YES | | 充值促销金额 |
| 13 | offer_type | INTEGER | YES | | 优惠类型。**枚举值**: 1(11427) |
| 14 | ledger_status | INTEGER | YES | | 账本状态。**枚举值**: 1(11427)=已结算 |
| 15 | operator_id | BIGINT | YES | | 操作员 ID |
| 16 | operator_name | VARCHAR(64) | YES | | 操作员名称。**枚举值**: "收银员:郑丽珊"(11426), "收银员:郑丽珍"(1) |
| 17 | salesman_user_id | BIGINT | YES | | 销售员用户 ID当前数据全为 0 |
| 18 | salesman_name | VARCHAR(64) | YES | | 销售员名称(当前数据全为 NULL |
| 19 | salesman_role_id | BIGINT | YES | | 销售员角色 ID当前数据全为 0 |
| 20 | salesman_org_id | BIGINT | YES | | 销售员组织 ID当前数据全为 0 |
| 21 | ledger_group_name | VARCHAR(128) | YES | | 账本分组名称(当前数据全为 NULL |
## 台区核销分布
| 台区名称 | 核销数量 | 占比 |
|----------|----------|------|
| A区 | 9294 | 81.3% |
| B区 | 998 | 8.7% |
| 斯诺克区 | 962 | 8.4% |
| 麻将房 | 137 | 1.2% |
## 样本数据
| table_name | table_area_name | operator_name | ledger_status |
|------------|-----------------|---------------|---------------|
| A17 | A区 | 收银员:郑丽珊 | 1 |
| A4 | A区 | 收银员:郑丽珊 | 1 |
| B5 | B区 | 收银员:郑丽珊 | 1 |
## 使用说明
与主表 `dwd_groupbuy_redemption` 通过 `redemption_id` 关联,提供门店、台桌名称、操作员等扩展信息。

View File

@@ -0,0 +1,49 @@
# dwd_member_balance_change_ex 会员余额变动扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_member_balance_change_ex |
| 主键 | balance_change_id |
| 主表 | dwd_member_balance_change |
| 记录数 | 4745 |
| 说明 | 会员余额变动扩展表,记录操作员和门店名称等扩展信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | balance_change_id | BIGINT | NO | PK | 变动流水 ID → dwd_member_balance_change |
| 2 | pay_site_name | VARCHAR(64) | YES | | 支付门店名称。**枚举值**: "朗朗桌球"(4720) |
| 3 | register_site_name | VARCHAR(64) | YES | | 注册门店名称。**枚举值**: "朗朗桌球"(4745) |
| 4 | refund_amount | NUMERIC(18,2) | YES | | 退款金额 |
| 5 | operator_id | BIGINT | YES | | 操作员 ID |
| 6 | operator_name | VARCHAR(64) | YES | | 操作员名称。**枚举值**: "收银员:郑丽珊"(4101), "店长:郑丽珊"(223), "管理员:郑丽珊"(153), "店长:蒋雨轩"(124), "店长:谢晓洪"(115), "店长:黄月柳"(29) |
## 操作员分布
| 操作员名称 | 操作次数 | 占比 |
|------------|----------|------|
| 收银员:郑丽珊 | 4101 | 86.4% |
| 店长:郑丽珊 | 223 | 4.7% |
| 管理员:郑丽珊 | 153 | 3.2% |
| 店长:蒋雨轩 | 124 | 2.6% |
| 店长:谢晓洪 | 115 | 2.4% |
| 店长:黄月柳 | 29 | 0.6% |
## 样本数据
| pay_site_name | register_site_name | operator_name | refund_amount |
|---------------|--------------------|---------------|---------------|
| 朗朗桌球 | 朗朗桌球 | 收银员:郑丽珊 | 0.00 |
| 朗朗桌球 | 朗朗桌球 | 收银员:郑丽珊 | 0.00 |
| 朗朗桌球 | 朗朗桌球 | 收银员:郑丽珊 | 0.00 |
## 使用说明
与主表 `dwd_member_balance_change` 通过 `balance_change_id` 关联,提供操作员和门店名称等扩展信息。

View File

@@ -0,0 +1,47 @@
# dwd_platform_coupon_redemption_ex 平台券核销扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_platform_coupon_redemption_ex |
| 主键 | platform_coupon_redemption_id |
| 主表 | dwd_platform_coupon_redemption |
| 记录数 | 16977 |
| 说明 | 平台券核销扩展表,记录券封面、备注、操作员等扩展信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | platform_coupon_redemption_id | BIGINT | NO | PK | 核销 ID → dwd_platform_coupon_redemption |
| 2 | coupon_cover | VARCHAR(255) | YES | | 券封面图片 URL当前数据全为 NULL |
| 3 | coupon_remark | VARCHAR(255) | YES | | 券备注(抖音券有核验信息) |
| 4 | groupon_type | INTEGER | YES | | 团购类型。**枚举值**: 1(16977)=**[待确认]** |
| 5 | operator_id | BIGINT | YES | | 操作员 ID |
| 6 | operator_name | VARCHAR(50) | YES | | 操作员名称。**枚举值**: "收银员:郑丽珊"(16968), "店长:郑丽珊"(8), "收银员:郑丽珍"(1) |
## 操作员分布
| 操作员名称 | 核销数量 | 占比 |
|------------|----------|------|
| 收银员:郑丽珊 | 16968 | 99.9% |
| 店长:郑丽珊 | 8 | <0.1% |
| 收银员:郑丽珍 | 1 | <0.1% |
## 样本数据
| groupon_type | operator_name | coupon_cover | coupon_remark |
|--------------|---------------|--------------|---------------|
| 1 | 收银员:郑丽珊 | NULL | NULL |
| 1 | 收银员:郑丽珊 | NULL | NULL |
## 使用说明
与主表 `dwd_platform_coupon_redemption` 通过 `platform_coupon_redemption_id` 关联,提供操作员等扩展信息。
**注意**: `coupon_remark` 字段在抖音渠道的核销记录中包含核验信息。

View File

@@ -0,0 +1,69 @@
# dwd_recharge_order_ex 充值订单扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_recharge_order_ex |
| 主键 | recharge_order_id |
| 主表 | dwd_recharge_order |
| 记录数 | 455 |
| 说明 | 充值订单扩展表,记录操作员、各类金额明细等扩展信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | recharge_order_id | BIGINT | NO | PK | 充值订单 ID → dwd_recharge_order |
| 2 | site_name_snapshot | TEXT | YES | | 门店名称快照。**枚举值**: "朗朗桌球"(374) |
| 3 | settle_status | INTEGER | YES | | 结算状态。**枚举值**: 2(455)=已结算 |
| 4 | is_bind_member | BOOLEAN | YES | | 是否绑定会员。**枚举值**: False(455) |
| 5 | is_activity | BOOLEAN | YES | | 是否活动。**枚举值**: False(455) |
| 6 | is_use_coupon | BOOLEAN | YES | | 是否使用优惠券。**枚举值**: False(455) |
| 7 | is_use_discount | BOOLEAN | YES | | 是否使用折扣。**枚举值**: False(455) |
| 8 | can_be_revoked | BOOLEAN | YES | | 是否可撤销。**枚举值**: False(455) |
| 9 | online_amount | NUMERIC(18,2) | YES | | 在线支付金额 |
| 10 | balance_amount | NUMERIC(18,2) | YES | | 余额支付金额 |
| 11 | card_amount | NUMERIC(18,2) | YES | | 卡支付金额 |
| 12 | coupon_amount | NUMERIC(18,2) | YES | | 优惠券金额 |
| 13 | recharge_card_amount | NUMERIC(18,2) | YES | | 充值卡金额 |
| 14 | gift_card_amount | NUMERIC(18,2) | YES | | 礼品卡金额 |
| 15 | prepay_money | NUMERIC(18,2) | YES | | 预付金额 |
| 16 | consume_money | NUMERIC(18,2) | YES | | 消费金额 |
| 17 | goods_money | NUMERIC(18,2) | YES | | 商品金额 |
| 18 | real_goods_money | NUMERIC(18,2) | YES | | 实收商品金额 |
| 19 | table_charge_money | NUMERIC(18,2) | YES | | 台费金额 |
| 20 | service_money | NUMERIC(18,2) | YES | | 服务费金额 |
| 21 | activity_discount | NUMERIC(18,2) | YES | | 活动折扣金额 |
| 22 | all_coupon_discount | NUMERIC(18,2) | YES | | 优惠券折扣总额 |
| 23 | goods_promotion_money | NUMERIC(18,2) | YES | | 商品促销金额 |
| 24 | assistant_promotion_money | NUMERIC(18,2) | YES | | 助教促销金额 |
| 25 | assistant_pd_money | NUMERIC(18,2) | YES | | 助教陪打金额 |
| 26 | assistant_cx_money | NUMERIC(18,2) | YES | | 助教培训金额 |
| 27 | assistant_manual_discount | NUMERIC(18,2) | YES | | 助教手动折扣 |
| 28 | coupon_sale_amount | NUMERIC(18,2) | YES | | 优惠券销售金额 |
| 29 | member_discount_amount | NUMERIC(18,2) | YES | | 会员折扣金额 |
| 30 | point_discount_price | NUMERIC(18,2) | YES | | 积分抵扣金额 |
| 31 | point_discount_cost | NUMERIC(18,2) | YES | | 积分抵扣成本 |
| 32 | adjust_amount | NUMERIC(18,2) | YES | | 调整金额 |
| 33 | rounding_amount | NUMERIC(18,2) | YES | | 取整金额 |
| 34 | operator_id | BIGINT | YES | | 操作员 ID |
| 35 | operator_name_snapshot | TEXT | YES | | 操作员名称快照。**枚举值**: "收银员:郑丽珊"(455) |
| 36 | salesman_user_id | BIGINT | YES | | 销售员用户 ID当前全为 0 |
| 37 | salesman_name | TEXT | YES | | 销售员名称(当前全为 NULL |
| 38 | order_remark | TEXT | YES | | 订单备注(当前全为 NULL |
| 39 | table_id | INTEGER | YES | | 台桌 ID当前全为 0 |
| 40 | serial_number | INTEGER | YES | | 序列号(当前全为 0 |
| 41 | revoke_order_id | BIGINT | YES | | 撤销订单 ID当前全为 0 |
| 42 | revoke_order_name | TEXT | YES | | 撤销订单名称(当前全为 NULL |
| 43 | revoke_time | TIMESTAMPTZ | YES | | 撤销时间 |
## 使用说明
与主表 `dwd_recharge_order` 通过 `recharge_order_id` 关联,提供操作员、各类金额明细等扩展信息。
**注意**: 样本数据获取时因日期解析错误未能获取。

View File

@@ -0,0 +1,51 @@
# dwd_refund_ex 退款流水扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_refund_ex |
| 主键 | refund_id |
| 主表 | dwd_refund |
| 记录数 | 45 |
| 说明 | 退款流水扩展表,记录退款的详细状态和渠道信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | refund_id | BIGINT | NO | PK | 退款流水 ID → dwd_refund |
| 2 | tenant_name | VARCHAR(64) | YES | | 租户名称。**枚举值**: "朗朗桌球"(45) |
| 3 | pay_sn | BIGINT | YES | | 支付序列号(当前全为 0 |
| 4 | refund_amount | NUMERIC(18,2) | YES | | 退款金额(冗余) |
| 5 | round_amount | NUMERIC(18,2) | YES | | 取整金额 |
| 6 | balance_frozen_amount | NUMERIC(18,2) | YES | | 余额冻结金额 |
| 7 | card_frozen_amount | NUMERIC(18,2) | YES | | 卡冻结金额 |
| 8 | pay_status | INTEGER | YES | | 支付状态。**枚举值**: 2(45)=已退款 |
| 9 | action_type | INTEGER | YES | | 操作类型。**枚举值**: 2(45)=退款 |
| 10 | is_revoke | INTEGER | YES | | 是否撤销。**枚举值**: 0(45)=否 |
| 11 | is_delete | INTEGER | YES | | 删除标记。**枚举值**: 0(45)=未删除 |
| 12 | check_status | INTEGER | YES | | 审核状态。**枚举值**: 1(45)=已审核 |
| 13 | online_pay_channel | INTEGER | YES | | 在线支付渠道(当前全为 0 |
| 14 | online_pay_type | INTEGER | YES | | 在线支付类型(当前全为 0 |
| 15 | pay_terminal | INTEGER | YES | | 支付终端。**枚举值**: 1(45)=POS |
| 16 | pay_config_id | INTEGER | YES | | 支付配置 ID当前全为 0 |
| 17 | cashier_point_id | INTEGER | YES | | 收银点 ID当前全为 0 |
| 18 | operator_id | BIGINT | YES | | 操作员 ID当前全为 0 |
| 19 | channel_payer_id | VARCHAR(128) | YES | | 渠道支付者 ID当前全为 NULL |
| 20 | channel_pay_no | VARCHAR(128) | YES | | 渠道支付号(当前全为 NULL |
## 样本数据
| tenant_name | pay_status | action_type | check_status |
|-------------|------------|-------------|--------------|
| 朗朗桌球 | 2 | 2 | 1 |
| 朗朗桌球 | 2 | 2 | 1 |
## 使用说明
与主表 `dwd_refund` 通过 `refund_id` 关联,提供退款状态和渠道等扩展信息。

View File

@@ -0,0 +1,69 @@
# dwd_settlement_head_ex 结账头表扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_settlement_head_ex |
| 主键 | order_settle_id |
| 主表 | dwd_settlement_head |
| 记录数 | 23366 |
| 说明 | 结账单扩展表,包含支付明细、撤销信息、操作员、活动标记等详细信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | order_settle_id | BIGINT | NO | PK | 结账单 ID → dwd_settlement_head |
| 2 | serial_number | INTEGER | YES | | 流水号(当前数据全为 0 |
| 3 | settle_status | INTEGER | YES | | 结账状态。**枚举值**: 2(23366)=已完成 **[待确认]** |
| 4 | can_be_revoked | BOOLEAN | YES | | 可否撤销。**枚举值**: False(23366)=不可撤销 |
| 5 | revoke_order_name | VARCHAR(100) | YES | | 撤销订单名称(当前数据全为空) |
| 6 | revoke_time | TIMESTAMPTZ | YES | | 撤销时间 |
| 7 | is_first_order | BOOLEAN | YES | | 是否首单。**枚举值**: False(23366)=否 |
| 8 | service_money | NUMERIC(18,2) | YES | | 服务费金额 |
| 9 | cash_amount | NUMERIC(18,2) | YES | | 现金支付金额 |
| 10 | card_amount | NUMERIC(18,2) | YES | | 刷卡支付金额 |
| 11 | online_amount | NUMERIC(18,2) | YES | | 在线支付金额 |
| 12 | refund_amount | NUMERIC(18,2) | YES | | 退款金额 |
| 13 | prepay_money | NUMERIC(18,2) | YES | | 预付金额 |
| 14 | payment_method | INTEGER | YES | | 支付方式(当前数据全为 0 |
| 15 | coupon_sale_amount | NUMERIC(18,2) | YES | | 券销售金额 |
| 16 | all_coupon_discount | NUMERIC(18,2) | YES | | 全部券折扣 |
| 17 | goods_promotion_money | NUMERIC(18,2) | YES | | 商品促销金额 |
| 18 | assistant_promotion_money | NUMERIC(18,2) | YES | | 助教促销金额 |
| 19 | activity_discount | NUMERIC(18,2) | YES | | 活动折扣 |
| 20 | assistant_manual_discount | NUMERIC(18,2) | YES | | 助教手动折扣 |
| 21 | point_discount_price | NUMERIC(18,2) | YES | | 积分抵扣金额 |
| 22 | point_discount_cost | NUMERIC(18,2) | YES | | 积分抵扣成本 |
| 23 | is_use_coupon | BOOLEAN | YES | | 是否使用优惠券。**枚举值**: False(23366)=否 |
| 24 | is_use_discount | BOOLEAN | YES | | 是否使用折扣。**枚举值**: False(23366)=否 |
| 25 | is_activity | BOOLEAN | YES | | 是否活动订单。**枚举值**: False(23366)=否 |
| 26 | operator_name | VARCHAR(100) | YES | | 操作员姓名。**枚举值**: "收银员:郑丽珊"(23361), "收银员:郑丽珍"(2), "教练:周蒙"(2), "店长:郑丽珊"(1) |
| 27 | salesman_name | VARCHAR(100) | YES | | 销售员姓名(当前数据全为空) |
| 28 | order_remark | VARCHAR(255) | YES | | 订单备注。**样本值**: "五折"(42), "轩哥"(24), "陈德韩"(7), "免台费"(3) |
| 29 | operator_id | BIGINT | YES | | 操作员 ID |
| 30 | salesman_user_id | BIGINT | YES | | 销售员用户 ID当前数据全为 0 |
## 使用说明
```sql
-- 关联主表与扩展表
SELECT
m.settle_name, m.consume_money, m.pay_amount,
e.operator_name, e.order_remark, e.settle_status
FROM billiards_dwd.dwd_settlement_head m
JOIN billiards_dwd.dwd_settlement_head_ex e
ON m.order_settle_id = e.order_settle_id;
-- 统计备注订单
SELECT order_remark, COUNT(*)
FROM billiards_dwd.dwd_settlement_head_ex
WHERE order_remark IS NOT NULL
GROUP BY order_remark
ORDER BY COUNT(*) DESC;
```

View File

@@ -0,0 +1,59 @@
# dwd_store_goods_sale_ex 商品销售扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_store_goods_sale_ex |
| 主键 | store_goods_sale_id |
| 主表 | dwd_store_goods_sale |
| 记录数 | 17563 |
| 说明 | 商品销售扩展表,记录销售详情、折扣优惠等扩展信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | store_goods_sale_id | BIGINT | NO | PK | 销售流水 ID → dwd_store_goods_sale |
| 2 | legacy_order_goods_id | BIGINT | YES | | 旧系统订单商品 ID当前全为 0 |
| 3 | site_name | TEXT | YES | | 门店名称。**枚举值**: "朗朗桌球"(17563) |
| 4 | legacy_site_id | BIGINT | YES | | 旧系统门店 ID |
| 5 | goods_remark | TEXT | YES | | 商品备注。**热门备注**: "哇哈哈矿泉水", "东方树叶", "可乐", "一次性手套", "地道肠" |
| 6 | option_value_name | TEXT | YES | | 选项值名称(当前全为 NULL |
| 7 | operator_name | TEXT | YES | | 操作员名称。**枚举值**: "收银员:郑丽珊"(17562), "收银员:郑丽珍"(1) |
| 8 | open_salesman_flag | INTEGER | YES | | 开启销售员标记。**枚举值**: 2(17563)=否 |
| 9 | salesman_user_id | BIGINT | YES | | 销售员用户 ID当前全为 0 |
| 10 | salesman_name | TEXT | YES | | 销售员名称(当前全为 NULL |
| 11 | salesman_role_id | BIGINT | YES | | 销售员角色 ID当前全为 0 |
| 12 | salesman_org_id | BIGINT | YES | | 销售员组织 ID当前全为 0 |
| 13 | discount_money | NUMERIC(18,2) | YES | | 折扣金额 |
| 14 | returns_number | INTEGER | YES | | 退货数量(当前全为 0 |
| 15 | coupon_deduct_money | NUMERIC(18,2) | YES | | 优惠券抵扣金额 |
| 16 | member_discount_amount | NUMERIC(18,2) | YES | | 会员折扣金额 |
| 17 | point_discount_money | NUMERIC(18,2) | YES | | 积分抵扣金额 |
| 18 | point_discount_money_cost | NUMERIC(18,2) | YES | | 积分抵扣成本 |
| 19 | package_coupon_id | BIGINT | YES | | 套餐券 ID当前全为 0 |
| 20 | order_coupon_id | BIGINT | YES | | 订单券 ID当前全为 0 |
| 21 | member_coupon_id | BIGINT | YES | | 会员券 ID当前全为 0 |
| 22 | option_price | NUMERIC(18,2) | YES | | 选项价格 |
| 23 | option_member_discount_money | NUMERIC(18,2) | YES | | 选项会员折扣金额 |
| 24 | option_coupon_deduct_money | NUMERIC(18,2) | YES | | 选项券抵扣金额 |
| 25 | push_money | NUMERIC(18,2) | YES | | 推手金额 |
| 26 | is_single_order | INTEGER | YES | | 是否独立订单。**枚举值**: 1(17563)=是 |
| 27 | sales_type | INTEGER | YES | | 销售类型。**枚举值**: 1(17563)=普通销售 |
| 28 | operator_id | BIGINT | YES | | 操作员 ID |
## 样本数据
| site_name | goods_remark | operator_name | discount_money |
|-----------|--------------|---------------|----------------|
| 朗朗桌球 | 鸡翅三个一份 | 收银员:郑丽珊 | 0.00 |
| 朗朗桌球 | NULL | 收银员:郑丽珊 | 0.00 |
## 使用说明
与主表 `dwd_store_goods_sale` 通过 `store_goods_sale_id` 关联,提供销售详情、折扣优惠等扩展信息。

View File

@@ -0,0 +1,39 @@
# dwd_table_fee_adjust_ex 台费调整扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_table_fee_adjust_ex |
| 主键 | table_fee_adjust_id |
| 主表 | dwd_table_fee_adjust |
| 记录数 | 2849 |
| 说明 | 台费调整扩展表,记录调整类型、申请人、操作员等信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | table_fee_adjust_id | BIGINT | NO | PK | 台费调整 ID → dwd_table_fee_adjust |
| 2 | adjust_type | INTEGER | YES | | 调整类型。**枚举值**: 1(2849)=**[待确认]** |
| 3 | ledger_count | INTEGER | YES | | 账本数量。**枚举值**: 1(2849) |
| 4 | ledger_name | VARCHAR(128) | YES | | 账本名称(当前数据全为 NULL |
| 5 | applicant_name | VARCHAR(64) | YES | | 申请人名称。**枚举值**: "收银员:郑丽珊"(2849) |
| 6 | operator_name | VARCHAR(64) | YES | | 操作员名称。**枚举值**: "收银员:郑丽珊"(2849) |
| 7 | applicant_id | BIGINT | YES | | 申请人 ID |
| 8 | operator_id | BIGINT | YES | | 操作员 ID |
## 样本数据
| adjust_type | applicant_name | operator_name |
|-------------|----------------|---------------|
| 1 | 收银员:郑丽珊 | 收银员:郑丽珊 |
| 1 | 收银员:郑丽珊 | 收银员:郑丽珊 |
## 使用说明
与主表 `dwd_table_fee_adjust` 通过 `table_fee_adjust_id` 关联,提供调整类型、申请人、操作员等扩展信息。

View File

@@ -0,0 +1,44 @@
# dwd_table_fee_log_ex 台费流水扩展表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_table_fee_log_ex |
| 主键 | table_fee_log_id |
| 主表 | dwd_table_fee_log |
| 记录数 | 18386 |
| 说明 | 台费流水扩展表,记录操作员、销售员、时间等扩展信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | table_fee_log_id | BIGINT | NO | PK | 台费流水 ID → dwd_table_fee_log |
| 2 | operator_name | VARCHAR(64) | YES | | 操作员名称。**枚举值**: "收银员:郑丽珊"(18382), "收银员:郑丽珍"(2), "店长:郑丽珊"(1), "教练:周蒙"(1) |
| 3 | salesman_name | VARCHAR(64) | YES | | 销售员名称(当前数据全为 NULL |
| 4 | used_card_amount | NUMERIC(18,2) | YES | | 使用卡金额(当前数据全为 0 |
| 5 | service_money | NUMERIC(18,2) | YES | | 服务费金额(当前数据全为 0 |
| 6 | mgmt_fee | NUMERIC(18,2) | YES | | 管理费金额(当前数据全为 0 |
| 7 | fee_total | NUMERIC(18,2) | YES | | 费用合计(当前数据全为 0 |
| 8 | ledger_start_time | TIMESTAMPTZ | YES | | 账本开始时间 |
| 9 | last_use_time | TIMESTAMPTZ | YES | | 最后使用时间 |
| 10 | operator_id | BIGINT | YES | | 操作员 ID。**枚举值**: 3个不同ID |
| 11 | salesman_user_id | BIGINT | YES | | 销售员用户 ID当前数据全为 0 |
| 12 | salesman_org_id | BIGINT | YES | | 销售员组织 ID当前数据全为 0 |
## 样本数据
| operator_name | ledger_start_time | last_use_time |
|---------------|-------------------|---------------|
| 收银员:郑丽珊 | 2025-11-09 22:28:57 | 2025-11-09 23:28:57 |
| 收银员:郑丽珊 | 2025-11-09 21:34:27 | 2025-11-09 23:34:27 |
| 收银员:郑丽珊 | 2025-11-09 22:32:55 | 2025-11-09 23:32:55 |
## 使用说明
与主表 `dwd_table_fee_log` 通过 `table_fee_log_id` 关联,提供操作员和时间相关的扩展信息。

View File

@@ -0,0 +1,118 @@
# billiards_dwd Schema 数据字典
> 生成时间2026-01-28
> 数据来源:数据库实时查询 + 500行样本数据分析
> 不确定内容已使用 **[待确认]** 标记
## 概述
`billiards_dwd` 是台球门店数据仓库的明细层(DWD),包含维度表(DIM)和事实表(DWD)。本 Schema 基于 SCD2 缓慢变化维度设计,支持历史数据追溯。
---
## 维度表 (Dimension Tables)
| 序号 | 表名 | 说明 | 主键 | 扩展表 | 文档链接 |
|------|------|------|------|--------|----------|
| 1 | dim_assistant | 助教信息 | assistant_id | dim_assistant_ex | [主表](BD_manual_dim_assistant.md) / [扩展表](BD_manual_dim_assistant_ex.md) |
| 2 | dim_goods_category | 商品分类 | goods_category_id | 无 | [主表](BD_manual_dim_goods_category.md) |
| 3 | dim_groupbuy_package | 团购套餐 | groupbuy_package_id | dim_groupbuy_package_ex | [主表](BD_manual_dim_groupbuy_package.md) / [扩展表](BD_manual_dim_groupbuy_package_ex.md) |
| 4 | dim_member | 会员信息 | member_id | dim_member_ex | [主表](BD_manual_dim_member.md) / [扩展表](BD_manual_dim_member_ex.md) |
| 5 | dim_member_card_account | 会员卡账户 | member_card_account_id | dim_member_card_account_ex | [主表](BD_manual_dim_member_card_account.md) / [扩展表](BD_manual_dim_member_card_account_ex.md) |
| 6 | dim_site | 门店信息 | site_id | dim_site_ex | [主表](BD_manual_dim_site.md) / [扩展表](BD_manual_dim_site_ex.md) |
| 7 | dim_store_goods | 门店商品 | store_goods_id | dim_store_goods_ex | [主表](BD_manual_dim_store_goods.md) / [扩展表](BD_manual_dim_store_goods_ex.md) |
| 8 | dim_table | 台桌信息 | table_id | dim_table_ex | [主表](BD_manual_dim_table.md) / [扩展表](BD_manual_dim_table_ex.md) |
| 9 | dim_tenant_goods | 租户商品 | tenant_goods_id | dim_tenant_goods_ex | [主表](BD_manual_dim_tenant_goods.md) / [扩展表](BD_manual_dim_tenant_goods_ex.md) |
---
## 事实表 (Fact Tables)
| 序号 | 表名 | 说明 | 主键 | 扩展表 | 文档链接 |
|------|------|------|------|--------|----------|
| 1 | dwd_assistant_service_log | 助教服务流水 | assistant_service_log_id | dwd_assistant_service_log_ex | [主表](BD_manual_dwd_assistant_service_log.md) / [扩展表](BD_manual_dwd_assistant_service_log_ex.md) |
| 2 | dwd_assistant_trash_event | 助教服务作废 | assistant_trash_event_id | dwd_assistant_trash_event_ex | [主表](BD_manual_dwd_assistant_trash_event.md) / [扩展表](BD_manual_dwd_assistant_trash_event_ex.md) |
| 3 | dwd_groupbuy_redemption | 团购券核销 | redemption_id | dwd_groupbuy_redemption_ex | [主表](BD_manual_dwd_groupbuy_redemption.md) / [扩展表](BD_manual_dwd_groupbuy_redemption_ex.md) |
| 4 | dwd_member_balance_change | 会员余额变动 | balance_change_id | dwd_member_balance_change_ex | [主表](BD_manual_dwd_member_balance_change.md) / [扩展表](BD_manual_dwd_member_balance_change_ex.md) |
| 5 | dwd_payment | 支付流水 | payment_id | 无 | [主表](BD_manual_dwd_payment.md) |
| 6 | dwd_platform_coupon_redemption | 平台券核销 | platform_coupon_redemption_id | dwd_platform_coupon_redemption_ex | [主表](BD_manual_dwd_platform_coupon_redemption.md) / [扩展表](BD_manual_dwd_platform_coupon_redemption_ex.md) |
| 7 | dwd_recharge_order | 充值订单 | recharge_order_id | dwd_recharge_order_ex | [主表](BD_manual_dwd_recharge_order.md) / [扩展表](BD_manual_dwd_recharge_order_ex.md) |
| 8 | dwd_refund | 退款流水 | refund_id | dwd_refund_ex | [主表](BD_manual_dwd_refund.md) / [扩展表](BD_manual_dwd_refund_ex.md) |
| 9 | dwd_settlement_head | 结账单 | settlement_head_id | dwd_settlement_head_ex | [主表](BD_manual_dwd_settlement_head.md) / [扩展表](BD_manual_dwd_settlement_head_ex.md) |
| 10 | dwd_store_goods_sale | 商品销售流水 | store_goods_sale_id | dwd_store_goods_sale_ex | [主表](BD_manual_dwd_store_goods_sale.md) / [扩展表](BD_manual_dwd_store_goods_sale_ex.md) |
| 11 | dwd_table_fee_adjust | 台费调整 | table_fee_adjust_id | dwd_table_fee_adjust_ex | [主表](BD_manual_dwd_table_fee_adjust.md) / [扩展表](BD_manual_dwd_table_fee_adjust_ex.md) |
| 12 | dwd_table_fee_log | 台费计费流水 | table_fee_log_id | dwd_table_fee_log_ex | [主表](BD_manual_dwd_table_fee_log.md) / [扩展表](BD_manual_dwd_table_fee_log_ex.md) |
---
## SCD2 公共字段
所有维度表都实现了 SCD2缓慢变化维度类型2包含以下公共字段
| 字段名 | 类型 | 说明 |
|--------|------|------|
| scd2_start_time | TIMESTAMPTZ | 版本生效开始时间 |
| scd2_end_time | TIMESTAMPTZ | 版本生效结束时间NULL 或 9999-12-31 表示当前有效) |
| scd2_is_current | INTEGER | 是否当前版本1=是, 0=否) |
| scd2_version | INTEGER | 版本号 |
---
## 常见 ID 关联说明
| ID 字段 | 关联表 | 说明 |
|---------|--------|------|
| tenant_id | - | 租户 ID标识所属租户 |
| site_id | dim_site | 门店 ID |
| member_id | dim_member | 会员 ID0=散客) |
| tenant_member_card_id | dim_member_card_account | 会员卡账户 ID |
| assistant_id | dim_assistant | 助教 ID |
| table_id / site_table_id | dim_table | 台桌 ID |
| tenant_goods_id | dim_tenant_goods | 租户商品 ID |
| site_goods_id | dim_store_goods | 门店商品 ID |
| order_settle_id | dwd_settlement_head | 结账单 ID |
---
## 表设计模式
### 主表 + 扩展表模式
大部分表采用"主表 + 扩展表"的设计模式:
- **主表**:包含核心业务字段(如金额、状态、关键 ID
- **扩展表**:包含附属信息(如操作员、门店名称快照、各类详细字段)
- 两表通过主键一对一关联
### 枚举值说明
文档中的枚举值格式为 `值(数量)=含义`,例如:
- `1(100)=有效` 表示值为 1 的记录有 100 条,含义为"有效"
- **[待确认]** 表示该值的含义无法从数据中确定
---
## 数据量统计
| 表名 | 记录数 |
|------|--------|
| dwd_payment | 22,949 |
| dwd_settlement_head | 22,475 |
| dwd_table_fee_log | 18,386 |
| dwd_store_goods_sale | 17,563 |
| dwd_platform_coupon_redemption | 16,977 |
| dwd_groupbuy_redemption | 11,420 |
| dwd_member_balance_change | 4,745 |
| dwd_table_fee_adjust | 2,849 |
| dwd_assistant_service_log | 1,090 |
| dwd_recharge_order | 455 |
| dwd_assistant_trash_event | 98 |
| dwd_refund | 45 |
---
## 注意事项
1. **枚举值推断**:文档中的枚举值含义基于 500 行样本数据推断,可能不完整
2. **[待确认] 标记**:不确定的字段含义或枚举值已明确标记
3. **数据时效性**:文档基于 2026-01-28 的数据库快照生成
4. **扩展表样本数据**:部分扩展表因日期解析问题无法获取样本数据

View File

@@ -0,0 +1,47 @@
# dim_assistant 助教档案主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_assistant |
| 主键 | assistant_id, scd2_start_time |
| 扩展表 | dim_assistant_ex |
| 记录数 | 69 |
| 说明 | 助教人员档案的核心信息,包括工号、姓名、联系方式、团队归属、等级等 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | assistant_id | BIGINT | NO | PK | 助教唯一标识 ID |
| 2 | user_id | BIGINT | YES | | 关联用户 ID当前数据全为 0**[作用待确认]** |
| 3 | assistant_no | TEXT | YES | | 助教工号,如 "11"、"27" |
| 4 | real_name | TEXT | YES | | 真实姓名,如 "梁婷婷"、"周佳怡" |
| 5 | nickname | TEXT | YES | | 昵称/花名,如 "柚子"、"周周"、"Amy" |
| 6 | mobile | TEXT | YES | | 手机号码 |
| 7 | tenant_id | BIGINT | YES | | 租户 ID当前值: 2790683160709957 |
| 8 | site_id | BIGINT | YES | | 门店 ID → dim_site当前值: 2790685415443269 |
| 9 | team_id | BIGINT | YES | | 团队 ID |
| 10 | team_name | TEXT | YES | | 团队名称。**枚举值**: "1组"(对应 team_id = 2792011585884037), "2组"(对应 team_id = 2959085810992645) |
| 11 | level | INTEGER | YES | | 助教等级。**枚举值**: 8 = 助教管理, 10 = 初级, 20 = 中级, 30 = 高级, 40 =专家 |
| 12 | entry_time | TIMESTAMPTZ | YES | | 入职时间 |
| 13 | resign_time | TIMESTAMPTZ | YES | | 离职时间(远未来日期如 2225-xx-xx 表示在职) |
| 14 | leave_status | INTEGER | YES | | 在职状态。**枚举值**: 0 = 在职, 1 = 已离职 |
| 15 | assistant_status | INTEGER | YES | | 观察者状态。**枚举值**: 1 = 为非观察者, 2 = 为观察者。 |
| 16 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 17 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 18 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 19 | scd2_version | INTEGER | YES | | 版本号 |
## 使用说明
```sql
-- 查询当前在职助教
SELECT * FROM billiards_dwd.dim_assistant
WHERE scd2_is_current = 1 AND leave_status = 0;
```

View File

@@ -0,0 +1,68 @@
# dim_goods_category 商品分类维度表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_goods_category |
| 主键 | category_id, scd2_start_time |
| 扩展表 | 无 |
| 记录数 | 26 |
| 说明 | 商品分类树结构表,支持一级/二级分类层次 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | category_id | BIGINT | NO | PK | 分类唯一标识 |
| 2 | tenant_id | BIGINT | YES | | 租户 ID当前值: 2790683160709957 |
| 3 | category_name | VARCHAR | YES | | 分类名称。**样本值**: "槟榔", "皮头" 等 |
| 4 | alias_name | VARCHAR | YES | | 分类别名(当前数据大部分为空) |
| 5 | parent_category_id | BIGINT | YES | | 父级分类 ID0=一级分类)→ 自关联 |
| 6 | business_name | VARCHAR | YES | | 业务大类名称。**样本值**: "酒水", "器材" 等 |
| 7 | tenant_goods_business_id | BIGINT | YES | | 业务大类 ID |
| 8 | category_level | INTEGER | YES | | 分类层级。**枚举值**: 1=一级大类, 2=二级子类 |
| 9 | is_leaf | INTEGER | YES | | 是否叶子节点。**枚举值**: 0=非叶子, 1=叶子 |
| 10 | open_salesman | INTEGER | YES | | 营业员开关。 |
| 11 | sort_order | INTEGER | YES | | 排序序号 |
| 12 | is_warehousing | INTEGER | YES | | 是否库存管理。**枚举值**: 1=参与库存管理 |
| 13 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 14 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 15 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 16 | scd2_version | INTEGER | YES | | 版本号 |
## 分类树结构示例
```
槟榔(一级)
├── 槟榔(二级)
器材(一级)
├── 皮头
├── 球杆
├── 其他
酒水(一级)
├── 饮料
├── 酒水
├── 茶水
├── 咖啡
├── 加料
├── 洋酒
```
## 使用说明
```sql
-- 查询一级分类
SELECT * FROM billiards_dwd.dim_goods_category
WHERE scd2_is_current = 1 AND parent_category_id = 0;
-- 查询某一级分类下的二级分类
SELECT * FROM billiards_dwd.dim_goods_category
WHERE scd2_is_current = 1 AND parent_category_id = <ID>;
```

View File

@@ -0,0 +1,49 @@
# dim_groupbuy_package 团购套餐主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_groupbuy_package |
| 主键 | groupbuy_package_id, scd2_start_time |
| 扩展表 | dim_groupbuy_package_ex |
| 记录数 | 34 |
| 说明 | 内部团购/套餐定义,记录套餐名称、价格、时长、适用台区等核心信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | groupbuy_package_id | BIGINT | NO | PK | 团购套餐 ID |
| 2 | tenant_id | BIGINT | YES | | 租户 ID当前值: 2790683160709957 |
| 3 | site_id | BIGINT | YES | | 门店 ID → dim_site当前值: 2790685415443269 |
| 4 | package_name | VARCHAR | YES | | 套餐名称。**样本值**: "中八、斯诺克包厢两小时", "斯诺克两小时"等 |
| 5 | package_template_id | BIGINT | YES | | 套餐模板 ID |
| 6 | selling_price | NUMERIC(10,2) | YES | | 售卖价格每笔订单不同从核销记录中dwd_groupbuy_redemption获取 |
| 7 | coupon_face_value | NUMERIC(10,2) | YES | | 券面值每笔订单不同从核销记录中dwd_groupbuy_redemption获取 |
| 8 | duration_seconds | INTEGER | YES | | 套餐时长(秒)。**样本值**: 3600=1小时, 7200=2小时, 14400=4小时 等 |
| 9 | start_time | TIMESTAMPTZ | YES | | 套餐生效开始时间 |
| 10 | end_time | TIMESTAMPTZ | YES | | 套餐生效结束时间 |
| 11 | table_area_name | VARCHAR | YES | | 适用台区名称。**枚举值**: "A区", "VIP包厢", "斯诺克区", "B区", "麻将房", "888" |
| 12 | is_enabled | INTEGER | YES | | 启用状态。**枚举值**: 1=启用, 2=停用 |
| 13 | is_delete | INTEGER | YES | | 删除标记。**枚举值**: 0=未删除 |
| 14 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
| 15 | tenant_table_area_id_list | VARCHAR | YES | | 租户级台区 ID 列表 |
| 16 | card_type_ids | VARCHAR | YES | | 允许使用的卡类型 ID 列表(当前数据为 "0" |
| 17 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 18 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 19 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 20 | scd2_version | INTEGER | YES | | 版本号 |
## 使用说明
```sql
-- 查询当前启用的套餐
SELECT * FROM billiards_dwd.dim_groupbuy_package
WHERE scd2_is_current = 1 AND is_delete = 0 AND is_enabled = 1;
```

View File

@@ -0,0 +1,49 @@
# dim_member 会员档案主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_member |
| 主键 | member_id, scd2_start_time |
| 扩展表 | dim_member_ex |
| 记录数 | 556 |
| 说明 | 租户会员档案主表,记录会员基本信息和卡种等级 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | member_id | BIGINT | NO | PK | 租户内会员 IDtenant_member_id |
| 2 | system_member_id | BIGINT | YES | | 系统级会员 ID |
| 3 | tenant_id | BIGINT | YES | | 租户 ID当前值: 2790683160709957 |
| 4 | register_site_id | BIGINT | YES | | 注册门店 ID → dim_site当前值: 2790685415443269 |
| 5 | mobile | TEXT | YES | | 手机号码 |
| 6 | nickname | TEXT | YES | | 昵称。**样本值**: "陈先生", "张先生", "李先生",等 |
| 7 | member_card_grade_code | BIGINT | YES | | 卡等级代码 |
| 8 | member_card_grade_name | TEXT | YES | | 卡等级名称。**枚举值**: "储值卡", "台费卡", "年卡", "活动抵用券", "月卡" |
| 9 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
| 10 | update_time | TIMESTAMPTZ | YES | | 更新时间 |
| 11 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 12 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 13 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 14 | scd2_version | INTEGER | YES | | 版本号 |
## 使用说明
```sql
-- 查询当前有效会员
SELECT * FROM billiards_dwd.dim_member
WHERE scd2_is_current = 1;
-- 按卡类型统计会员数
SELECT member_card_grade_name, COUNT(*)
FROM billiards_dwd.dim_member
WHERE scd2_is_current = 1
GROUP BY member_card_grade_name;
```

View File

@@ -0,0 +1,63 @@
# dim_member_card_account 会员卡账户主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_member_card_account |
| 主键 | member_card_id, scd2_start_time |
| 扩展表 | dim_member_card_account_ex |
| 记录数 | 945 |
| 说明 | 会员卡账户主表,记录卡种、余额、有效期等核心信息。一个会员可持有多张卡。 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | member_card_id | BIGINT | NO | PK | 会员卡账户 ID |
| 2 | tenant_id | BIGINT | YES | | 租户 ID |
| 3 | register_site_id | BIGINT | YES | | 开卡门店 ID → dim_site |
| 4 | tenant_member_id | BIGINT | YES | | 持卡会员 ID → dim_member0=未绑定会员) |
| 5 | system_member_id | BIGINT | YES | | 系统级会员 ID |
| 6 | card_type_id | BIGINT | YES | | 卡种 ID |
| 7 | member_card_grade_code | BIGINT | YES | | 卡等级代码 |
| 8 | member_card_grade_code_name | TEXT | YES | | 卡等级名称。**枚举值**: "储值卡", "台费卡", "活动抵用券", "酒水卡", "月卡", "年卡" |
| 9 | member_card_type_name | TEXT | YES | | 卡类型名称(与 grade_code_name 相同) |
| 10 | member_name | TEXT | YES | | 持卡人姓名快照 |
| 11 | member_mobile | TEXT | YES | | 持卡人手机号快照 |
| 12 | balance | NUMERIC(18,2) | YES | | 当前余额(元) |
| 13 | start_time | TIMESTAMPTZ | YES | | 卡生效时间 |
| 14 | end_time | TIMESTAMPTZ | YES | | 卡失效时间2225-01-01=长期有效) |
| 15 | last_consume_time | TIMESTAMPTZ | YES | | 最近消费时间 |
| 16 | status | INTEGER | YES | | 卡状态。**枚举值**: 1=正常, 4=过期 |
| 17 | is_delete | INTEGER | YES | | 删除标记。**枚举值**: 0=未删除 |
| 18 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 19 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 20 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 21 | scd2_version | INTEGER | YES | | 版本号 |
## 卡种分布
| card_type_id | 卡类型 | 说明 |
|--------------|--------|------|
| 2793249295533893 | 储值卡 | 充值获得,可抵扣任意费用 |
| 2791990152417157 | 台费卡 | 充值赠送,即可抵扣台费 |
| 2793266846533445 | 活动抵用券 | 充值赠送,不可抵扣助教费 |
| 2794699703437125 | 酒水卡 | 充值赠送,仅可抵扣酒水饮料食品商品 |
| 2793306611533637 | 月卡 | 充值获得,时长卡,仅可抵扣台费 |
| 2791987095408517 | 年卡 | 充值获得,时长卡,仅可抵扣台费 |
## 使用说明
```sql
-- 查询有效的储值卡
SELECT * FROM billiards_dwd.dim_member_card_account
WHERE scd2_is_current = 1
AND is_delete = 0
AND status = 1
AND member_card_type_name = '储值卡';
```

View File

@@ -0,0 +1,51 @@
# dim_site 门店主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_site |
| 主键 | site_id, scd2_start_time |
| 扩展表 | dim_site_ex |
| 记录数 | 1 |
| 说明 | 门店维度主表,记录门店基本信息(地址、联系方式等) |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | site_id | BIGINT | NO | PK | 门店 ID |
| 2 | org_id | BIGINT | YES | | 组织机构 ID |
| 3 | tenant_id | BIGINT | YES | | 租户 ID当前值: 2790683160709957 |
| 4 | shop_name | TEXT | YES | | 门店名称。**当前值**: "朗朗桌球" |
| 5 | site_label | TEXT | YES | | 门店标签。**当前值**: "A" |
| 6 | full_address | TEXT | YES | | 详细地址。**当前值**: "广东省广州市天河区丽阳街12号" |
| 7 | address | TEXT | YES | | 地址描述。**当前值**: "广东省广州市天河区天园街道朗朗桌球" |
| 8 | longitude | NUMERIC(10,6) | YES | | 经度。**当前值**: 113.360321 |
| 9 | latitude | NUMERIC(10,6) | YES | | 纬度。**当前值**: 23.133629 |
| 10 | tenant_site_region_id | BIGINT | YES | | 区域 ID。**当前值**: 156440100 |
| 11 | business_tel | TEXT | YES | | 联系电话。**当前值**: "13316068642" |
| 12 | site_type | INTEGER | YES | | 门店类型。**枚举值**: 1(1)=**[待确认]** |
| 13 | shop_status | INTEGER | YES | | 营业状态。**枚举值**: 1(1)=营业中 **[待确认]** |
| 14 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 15 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 16 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 17 | scd2_version | INTEGER | YES | | 版本号 |
## 当前门店数据
| site_id | shop_name | full_address | longitude | latitude |
|---------|-----------|--------------|-----------|----------|
| 2790685415443269 | 朗朗桌球 | 广东省广州市天河区丽阳街12号 | 113.360321 | 23.133629 |
## 使用说明
```sql
-- 查询当前有效门店
SELECT * FROM billiards_dwd.dim_site
WHERE scd2_is_current = 1;
```

View File

@@ -0,0 +1,61 @@
# dim_store_goods 门店商品主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_store_goods |
| 主键 | site_goods_id, scd2_start_time |
| 扩展表 | dim_store_goods_ex |
| 记录数 | 170 |
| 说明 | 门店级商品库存维度表,记录门店的商品库存、价格、销量等信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | site_goods_id | BIGINT | NO | PK | 门店商品 ID |
| 2 | tenant_id | BIGINT | YES | | 租户 ID |
| 3 | site_id | BIGINT | YES | | 门店 ID → dim_site |
| 4 | tenant_goods_id | BIGINT | YES | | 租户商品 ID → dim_tenant_goods |
| 5 | goods_name | TEXT | YES | | 商品名称。**样本值**: "双中支中华", "炫赫门小南京"等 |
| 6 | goods_category_id | BIGINT | YES | | 一级分类 ID → dim_goods_category |
| 7 | goods_second_category_id | BIGINT | YES | | 二级分类 ID → dim_goods_category |
| 8 | category_level1_name | TEXT | YES | | 一级分类名称。**样本值**: "零食", "酒水", "其他", "香烟" 等 |
| 9 | category_level2_name | TEXT | YES | | 二级分类名称。**样本值**: "零食", "饮料", "其他2", "香烟", "雪糕", "酒水", "球杆", "槟榔" 等 |
| 10 | batch_stock_qty | INTEGER | YES | | 批次库存数量 |
| 11 | sale_qty | INTEGER | YES | | 销售数量 |
| 12 | total_sales_qty | INTEGER | YES | | 累计销售数量 |
| 13 | sale_price | NUMERIC(18,2) | YES | | 销售价格(元) |
| 14 | created_at | TIMESTAMPTZ | YES | | 创建时间 |
| 15 | updated_at | TIMESTAMPTZ | YES | | 更新时间 |
| 16 | avg_monthly_sales | NUMERIC(18,4) | YES | | 月均销量 |
| 17 | goods_state | INTEGER | YES | | 商品状态。**枚举值**: 1=上架, 2=下架 |
| 18 | enable_status | INTEGER | YES | | 启用状态。**枚举值**: 1=启用 |
| 19 | send_state | INTEGER | YES | | 配送状态。暂无作用 |
| 20 | is_delete | INTEGER | YES | | 删除标记。**枚举值**: 0=未删除 |
| 21 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 22 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 23 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 24 | scd2_version | INTEGER | YES | | 版本号 |
## 样本数据
| goods_name | category_level1_name | sale_price | sale_qty | goods_state |
|------------|----------------------|------------|----------|-------------|
| 双中支中华 | 香烟 | 72.00 | 94 | 1 |
| 炫赫门小南京 | 香烟 | 28.00 | 110 | 1 |
| 细荷花 | 香烟 | 55.00 | 184 | 1 |
| 可乐 | 酒水 | 5.00 | 78 | 1 |
## 使用说明
```sql
-- 查询当前上架商品
SELECT * FROM billiards_dwd.dim_store_goods
WHERE scd2_is_current = 1 AND goods_state = 1 AND is_delete = 0;
```

View File

@@ -0,0 +1,66 @@
# dim_table 台桌主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_table |
| 主键 | table_id, scd2_start_time |
| 扩展表 | dim_table_ex |
| 记录数 | 74 |
| 说明 | 台桌维度主表,记录台桌名称、所属台区、单价等核心信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | table_id | BIGINT | NO | PK | 台桌 ID |
| 2 | site_id | BIGINT | YES | | 门店 ID → dim_site |
| 3 | table_name | TEXT | YES | | 台桌名称。**样本值**: "A1", "A2", "B1", "B2", "S1", "C1", "VIP1", "M3", "666" 等 |
| 4 | site_table_area_id | BIGINT | YES | | 台区 ID |
| 5 | site_table_area_name | TEXT | YES | | 台区名称。**样本值**: "A区", "B区", "补时长", "C区", "麻将房", "K包", "VIP包厢", "斯诺克区", "666", "k包活动区", "M7" 等 |
| 6 | tenant_table_area_id | BIGINT | YES | | 租户级台区 ID |
| 7 | table_price | NUMERIC(18,2) | YES | | 台桌单价(当前数据全为 0.00 |
| 8 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 9 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 10 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 11 | scd2_version | INTEGER | YES | | 版本号 |
## 台区分布
| 台区名称 | 台桌数量 | 大类/索引 |
|----------|----------|----------|
| A区 | 18 | 台球/打球/中八/追分 |
| B区 | 15 | 台球/打球/中八/追分 |
| 补时长 | 7 | 补时长 |
| C区 | 6 | 台球/打球/中八/追分 |
| 麻将房 | 5 | 麻将/麻将棋牌 |
| M7 | 2 | 麻将/麻将棋牌 |
| M8 | 1 | 麻将/麻将棋牌 |
| K包 | 4 | K包/K歌/KTV |
| VIP包厢 | 4 | 台球/打球/中八/追分 (V5为 台球/打球/斯诺克) |
| 斯诺克区 | 4 | 台球/打球/斯诺克 |
| 666 | 2 | 麻将/麻将棋牌 |
| TV台 | 1 | 台球/打球/中八/追分 |
| k包活动区 | 2 | K包/K歌/KTV |
| 幸会158 | 2 | K包/K歌/KTV |
| 发财 | 1 | 麻将/麻将棋牌 |
## 使用说明
```sql
-- 查询当前有效台桌
SELECT * FROM billiards_dwd.dim_table
WHERE scd2_is_current = 1;
-- 按台区统计台桌数
SELECT site_table_area_name, COUNT(*)
FROM billiards_dwd.dim_table
WHERE scd2_is_current = 1
GROUP BY site_table_area_name
ORDER BY COUNT(*) DESC;
```

View File

@@ -0,0 +1,47 @@
# dim_tenant_goods 租户商品主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dim_tenant_goods |
| 主键 | tenant_goods_id, scd2_start_time |
| 扩展表 | dim_tenant_goods_ex |
| 记录数 | 171 |
| 说明 | 租户级商品档案主表SKU 定义),被门店商品表引用 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | tenant_goods_id | BIGINT | NO | PK | 租户商品 IDSKU |
| 2 | tenant_id | BIGINT | YES | | 租户 ID |
| 3 | supplier_id | BIGINT | YES | | 供应商 ID当前数据全为 0 |
| 4 | category_name | VARCHAR | YES | | 分类名称(二级分类)。**样本值**: "零食", "饮料", "香烟"等 |
| 5 | goods_category_id | BIGINT | YES | | 一级分类 ID |
| 6 | goods_second_category_id | BIGINT | YES | | 二级分类 ID |
| 7 | goods_name | VARCHAR | YES | | 商品名称。**样本值**: "海之言", "西梅多多饮品", "美汁源果粒橙", "三诺橙汁"等 |
| 8 | goods_number | VARCHAR | YES | | 商品编号(序号) |
| 9 | unit | VARCHAR | YES | | 商品单位。**枚举值**: "包", "瓶", "个", "份"等 |
| 10 | market_price | NUMERIC(18,2) | YES | | 市场价/吊牌价(元) |
| 11 | goods_state | INTEGER | YES | | 商品状态。**枚举值**: 1=上架, 2=下架 |
| 12 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
| 13 | update_time | TIMESTAMPTZ | YES | | 更新时间 |
| 14 | is_delete | INTEGER | YES | | 删除标记。**枚举值**: 0=未删除 |
| 15 | scd2_start_time | TIMESTAMPTZ | NO | PK | SCD2 版本生效时间 |
| 16 | scd2_end_time | TIMESTAMPTZ | YES | | SCD2 版本失效时间 |
| 17 | scd2_is_current | INTEGER | YES | | 当前版本标记 |
| 18 | scd2_version | INTEGER | YES | | 版本号 |
## 使用说明
```sql
-- 查询当前有效的租户商品
SELECT * FROM billiards_dwd.dim_tenant_goods
WHERE scd2_is_current = 1 AND is_delete = 0;
```

View File

@@ -0,0 +1,67 @@
# dwd_assistant_service_log 助教服务流水主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_assistant_service_log |
| 主键 | assistant_service_id |
| 扩展表 | dwd_assistant_service_log_ex |
| 记录数 | 5003 |
| 说明 | 助教服务计费流水事实表,记录每次陪打/教学服务的详细信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | assistant_service_id | BIGINT | NO | PK | 服务流水 ID |
| 2 | order_trade_no | BIGINT | YES | | 订单号 → dwd_settlement_head |
| 3 | order_settle_id | BIGINT | YES | | 结账单 ID → dwd_settlement_head |
| 4 | order_pay_id | BIGINT | YES | | 支付单 ID当前数据全为 0 |
| 5 | order_assistant_id | BIGINT | YES | | 订单助教 ID |
| 6 | order_assistant_type | INTEGER | YES | | 服务类型。**枚举值**: 1=基础课 或 包厢课, 2=附加课/激励课 |
| 7 | tenant_id | BIGINT | YES | | 租户 ID |
| 8 | site_id | BIGINT | YES | | 门店 ID |
| 9 | site_table_id | BIGINT | YES | | 台桌 ID → dim_table0=非台桌服务) |
| 10 | tenant_member_id | BIGINT | YES | | 会员 ID → dim_member0=散客) |
| 11 | system_member_id | BIGINT | YES | | 系统会员 ID0=散客) |
| 12 | assistant_no | VARCHAR | YES | | 助教工号。**样本值**: "2", "9"等 |
| 13 | nickname | VARCHAR | YES | | 助教昵称。**样本值**: "佳怡", "婉婉", "七七"等 |
| 14 | site_assistant_id | BIGINT | YES | | 助教 ID → dim_assistant |
| 15 | user_id | BIGINT | YES | | 助教用户 ID |
| 16 | assistant_team_id | BIGINT | YES | | 助教团队 ID。**枚举值**: 2792011585884037=1组, 2959085810992645=2组 |
| 17 | person_org_id | BIGINT | YES | | 人事组织 ID |
| 18 | assistant_level | INTEGER | YES | | 助教等级。**枚举值**: 8=助教管理, 10=初级, 20=中级, 30=高级, 40=星级 |
| 19 | level_name | VARCHAR | YES | | 等级名称。**枚举值**: "助教管理", "初级", "中级", "高级", "星级" |
| 20 | skill_id | BIGINT | YES | | 技能 ID |
| 21 | skill_name | VARCHAR | YES | | 技能名称。**枚举值**: "基础课", "附加课/激励课", "包厢课" |
| 22 | ledger_unit_price | NUMERIC(10,2) | YES | | 单价(元/小时),**样本值**: 98.00/108.00/190.00 等 |
| 23 | ledger_amount | NUMERIC(10,2) | YES | | 计费金额 |
| 24 | projected_income | NUMERIC(10,2) | YES | | 预估收入 |
| 25 | coupon_deduct_money | NUMERIC(10,2) | YES | | 券抵扣金额 |
| 26 | income_seconds | INTEGER | YES | | 计费时长(秒)。常见值: 3600=1h, 7200=2h, 10800=3h |
| 27 | real_use_seconds | INTEGER | YES | | 实际使用时长(秒) |
| 28 | add_clock | INTEGER | YES | | 加时时长(秒),大多为 0 |
| 29 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
| 30 | start_use_time | TIMESTAMPTZ | YES | | 服务开始时间 |
| 31 | last_use_time | TIMESTAMPTZ | YES | | 服务结束时间 |
| 32 | is_delete | INTEGER | YES | | 删除标记。**枚举值**: 0=未删除 |
## 使用说明
```sql
-- 统计助教服务收入
SELECT
nickname, level_name,
COUNT(*) AS service_count,
SUM(ledger_amount) AS total_amount,
SUM(income_seconds)/3600.0 AS total_hours
FROM billiards_dwd.dwd_assistant_service_log
WHERE is_delete = 0
GROUP BY nickname, level_name
ORDER BY total_amount DESC;
```

View File

@@ -0,0 +1,43 @@
# dwd_assistant_trash_event 助教服务作废主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_assistant_trash_event |
| 主键 | assistant_trash_event_id |
| 扩展表 | dwd_assistant_trash_event_ex |
| 记录数 | 98 |
| 说明 | 助教服务作废事实表,记录被取消/作废的助教服务记录 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | assistant_trash_event_id | BIGINT | NO | PK | 作废事件 ID |
| 2 | site_id | BIGINT | YES | | 门店 ID |
| 3 | table_id | BIGINT | YES | | 台桌 ID → dim_table |
| 4 | table_area_id | BIGINT | YES | | 台区 ID |
| 5 | assistant_no | VARCHAR | YES | | 助教工号/昵称。**样本值**: "七七", "乔西", "球球"等 |
| 6 | assistant_name | VARCHAR | YES | | 助教名称,与 assistant_no 相同 |
| 7 | charge_minutes_raw | INTEGER | YES | | 原计费时长(秒)。**样本值**: 0, 3600=1h, 10800=3h 等 |
| 8 | abolish_amount | NUMERIC(18,2) | YES | | 作废金额(元)。**样本值**: 0.00, 190.00, 570.00 等 |
| 9 | trash_reason | VARCHAR | YES | | 作废原因(当前数据全为 NULL |
| 10 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
## 使用说明
```sql
-- 助教作废金额统计
SELECT
assistant_name,
COUNT(*) AS trash_count,
SUM(abolish_amount) AS total_abolished
FROM billiards_dwd.dwd_assistant_trash_event
GROUP BY assistant_name
ORDER BY total_abolished DESC;
```

View File

@@ -0,0 +1,57 @@
# dwd_groupbuy_redemption 团购核销主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_groupbuy_redemption |
| 主键 | redemption_id |
| 扩展表 | dwd_groupbuy_redemption_ex |
| 记录数 | 11420 |
| 说明 | 团购券核销事实表,记录团购券的核销使用明细 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | redemption_id | BIGINT | NO | PK | 核销 ID |
| 2 | tenant_id | BIGINT | YES | | 租户 ID |
| 3 | site_id | BIGINT | YES | | 门店 ID |
| 4 | table_id | BIGINT | YES | | 台桌 ID → dim_table |
| 5 | tenant_table_area_id | BIGINT | YES | | 台区 ID |
| 6 | table_charge_seconds | INTEGER | YES | | 台费计费时长(秒)。**样本值**: 3600=1h, 7200=2h, 10800=3h 等 |
| 7 | order_trade_no | BIGINT | YES | | 订单号 |
| 8 | order_settle_id | BIGINT | YES | | 结账单 ID → dwd_settlement_head |
| 9 | order_coupon_id | BIGINT | YES | | 订单券 ID |
| 10 | coupon_origin_id | BIGINT | YES | | 券来源 ID |
| 11 | promotion_activity_id | BIGINT | YES | | 促销活动 ID |
| 12 | promotion_coupon_id | BIGINT | YES | | 促销券 ID → dim_groupbuy_package |
| 13 | order_coupon_channel | INTEGER | YES | | 券渠道。**枚举值**: 1=美团, 2=抖音 |
| 14 | ledger_unit_price | NUMERIC(18,2) | YES | | 单价(元)。**样本值**: 29.90, 12.12, 11.11, 39.90 等 |
| 15 | ledger_count | INTEGER | YES | | 计费数量(秒)。**样本值**: 3600=1h, 7200=2h 等 |
| 16 | ledger_amount | NUMERIC(18,2) | YES | | 账本金额(元)。**样本值**: 48.00, 96.00, 68.00 等 |
| 17 | coupon_money | NUMERIC(18,2) | YES | | 券面额(元)。**样本值**: 48.00, 116.00, 96.00, 68.00 等 |
| 18 | promotion_seconds | INTEGER | YES | | 促销时长(秒)。**样本值**: 3600=1h, 7200=2h, 14400=4h 等 |
| 19 | coupon_code | VARCHAR | YES | | 券码 |
| 20 | is_single_order | INTEGER | YES | | 是否独立订单。**枚举值**: 0=否, 1=是 |
| 21 | is_delete | INTEGER | YES | | 删除标记。**枚举值**: 0=未删除 |
| 22 | ledger_name | VARCHAR | YES | | 套餐名称。**样本值**: "全天A区中八一小时", "中八A区新人特惠一小时" 等 |
| 23 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
## 使用说明
```sql
-- 各套餐核销统计
SELECT
ledger_name,
COUNT(*) AS redemption_count,
SUM(ledger_amount) AS total_amount
FROM billiards_dwd.dwd_groupbuy_redemption
WHERE is_delete = 0
GROUP BY ledger_name
ORDER BY redemption_count DESC;
```

View File

@@ -0,0 +1,72 @@
# dwd_member_balance_change 会员余额变动主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_member_balance_change |
| 主键 | balance_change_id |
| 扩展表 | dwd_member_balance_change_ex |
| 记录数 | 4745 |
| 说明 | 会员卡余额变动流水事实表,记录每次余额变动的金额和原因 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | balance_change_id | BIGINT | NO | PK | 变动流水 ID |
| 2 | tenant_id | BIGINT | YES | | 租户 ID |
| 3 | site_id | BIGINT | YES | | 门店 ID |
| 4 | register_site_id | BIGINT | YES | | 注册门店 ID |
| 5 | tenant_member_id | BIGINT | YES | | 会员 ID → dim_member |
| 6 | system_member_id | BIGINT | YES | | 系统会员 ID |
| 7 | tenant_member_card_id | BIGINT | YES | | 会员卡 ID → dim_member_card_account |
| 8 | card_type_id | BIGINT | YES | | 卡类型 ID |
| 9 | card_type_name | VARCHAR | YES | | 卡类型名称。**枚举值**: "储值卡", "活动抵用券", "台费卡", "酒水卡", "年卡", "月卡" |
| 10 | member_name | VARCHAR | YES | | 会员名称快照 |
| 11 | member_mobile | VARCHAR | YES | | 会员手机号快照 |
| 12 | balance_before | NUMERIC(18,2) | YES | | 变动前余额 |
| 13 | change_amount | NUMERIC(18,2) | YES | | 变动金额(正=充值/赠送,负=消费) |
| 14 | balance_after | NUMERIC(18,2) | YES | | 变动后余额 |
| 15 | from_type | INTEGER | YES | | 变动来源。**枚举值**: 1=结账/消费, 2=结账撤销, 3=现付充值, 4=活动赠送, 7=充值撤销/退款, 9=手动调整 |
| 16 | payment_method | INTEGER | YES | | 支付方式,暂未启用。 |
| 17 | change_time | TIMESTAMPTZ | YES | | 变动时间 |
| 18 | is_delete | INTEGER | YES | | 删除标记 |
| 19 | remark | VARCHAR | YES | | 备注。**样本值**: "注销会员", "充值退款" 等 |
## 卡类型余额变动分布
| 卡类型 | 变动次数 | 说明 |
|--------|----------|------|
| 储值卡 | 2825 | 最主要的消费卡种 |
| 活动抵用券 | 1275 | 营销活动赠送 |
| 台费卡 | 482 | 台费专用卡 |
| 酒水卡 | 149 | 酒水专用卡 |
## 样本数据
| member_name | card_type_name | balance_before | change_amount | balance_after | from_type |
|-------------|----------------|----------------|---------------|---------------|-----------|
| 曾丹烨 | 储值卡 | 816.30 | -120.00 | 696.30 | 1 |
| 葛先生 | 储值卡 | 6745.27 | -144.00 | 6601.27 | 1 |
| 陈腾鑫 | 储值卡 | 293.20 | -114.61 | 178.59 | 1 |
| 轩哥 | 酒水卡 | 532.00 | -41.00 | 491.00 | 1 |
## 使用说明
```sql
-- 会员消费总额排行
SELECT
member_name,
member_mobile,
card_type_name,
SUM(CASE WHEN change_amount < 0 THEN ABS(change_amount) ELSE 0 END) AS total_consume
FROM billiards_dwd.dwd_member_balance_change
WHERE is_delete = 0
GROUP BY member_name, member_mobile, card_type_name
ORDER BY total_consume DESC;
```

View File

@@ -0,0 +1,47 @@
# dwd_payment 支付流水表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_payment |
| 主键 | payment_id |
| 扩展表 | 无 |
| 记录数 | 22949 |
| 说明 | 支付流水事实表,记录每笔支付的方式、金额、时间等信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | payment_id | BIGINT | NO | PK | 支付流水 ID |
| 2 | site_id | BIGINT | YES | | 门店 ID |
| 3 | relate_type | INTEGER | YES | | 关联业务类型。**枚举值**: 1=预付, 2=结账, 5=充值, 6=线上商城 |
| 4 | relate_id | BIGINT | YES | | 关联业务 ID |
| 5 | pay_amount | NUMERIC(18,2) | YES | | 支付金额(元) |
| 6 | pay_status | INTEGER | YES | | 支付状态。**枚举值**: 2=已支付 |
| 7 | payment_method | INTEGER | YES | | 支付方式。**枚举值**: 2=现金支付 , 4=离线支付 |
| 8 | online_pay_channel | INTEGER | YES | | 在线支付渠道(当前数据全为 0 |
| 9 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
| 10 | pay_time | TIMESTAMPTZ | YES | | 支付时间 |
| 11 | pay_date | DATE | YES | | 支付日期 |
## 使用说明
```sql
-- 每日支付金额统计
SELECT
pay_date,
COUNT(*) AS pay_count,
SUM(pay_amount) AS total_amount
FROM billiards_dwd.dwd_payment
WHERE pay_status = 2
GROUP BY pay_date
ORDER BY pay_date DESC;
```

View File

@@ -0,0 +1,57 @@
# dwd_platform_coupon_redemption 平台券核销主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_platform_coupon_redemption |
| 主键 | platform_coupon_redemption_id |
| 扩展表 | dwd_platform_coupon_redemption_ex |
| 记录数 | 16977 |
| 说明 | 平台优惠券核销事实表,记录美团/抖音等平台券的核销明细 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | platform_coupon_redemption_id | BIGINT | NO | PK | 核销 ID |
| 2 | tenant_id | BIGINT | YES | | 租户 ID |
| 3 | site_id | BIGINT | YES | | 门店 ID |
| 4 | coupon_code | VARCHAR | YES | | 券码 |
| 5 | coupon_channel | INTEGER | YES | | 券渠道。**枚举值**: 1=美团, 2=抖音 |
| 6 | coupon_name | VARCHAR | YES | | 券名称。**样本值**: "【全天可用】中八桌球一小时A区", "【全天可用】中八桌球两小时A区" 等 |
| 7 | sale_price | NUMERIC(10,2) | YES | | 售卖价(元)。**样本值**: 29.90, 69.90, 59.90, 39.90, 19.90 等 |
| 8 | coupon_money | NUMERIC(10,2) | YES | | 券面额(元)。**样本值**: 48.00, 96.00, 116.00, 68.00 等 |
| 9 | coupon_free_time | INTEGER | YES | | 券赠送时长(当前数据全为 0 |
| 10 | channel_deal_id | BIGINT | YES | | 渠道交易 ID |
| 11 | deal_id | BIGINT | YES | | 交易 ID |
| 12 | group_package_id | BIGINT | YES | | 团购套餐 ID当前数据全为 0 |
| 13 | site_order_id | BIGINT | YES | | 门店订单 ID |
| 14 | table_id | BIGINT | YES | | 台桌 ID → dim_table |
| 15 | certificate_id | VARCHAR | YES | | 凭证 ID |
| 16 | verify_id | VARCHAR | YES | | 核验 ID仅抖音券有值 |
| 17 | use_status | INTEGER | YES | | 使用状态。**枚举值**: 1=已使用, 2=已撤销 |
| 18 | is_delete | INTEGER | YES | | 删除标记。**枚举值**: 0=未删除 |
| 19 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
| 20 | consume_time | TIMESTAMPTZ | YES | | 核销时间 |
## 使用说明
```sql
-- 各渠道核销统计
SELECT
CASE coupon_channel
WHEN 1 THEN '美团'
WHEN 2 THEN '抖音'
ELSE '其他'
END AS channel,
COUNT(*) AS redemption_count,
SUM(coupon_money) AS total_coupon_value,
SUM(sale_price) AS total_sale_price
FROM billiards_dwd.dwd_platform_coupon_redemption
WHERE is_delete = 0 AND use_status = 1
GROUP BY coupon_channel;
```

View File

@@ -0,0 +1,53 @@
# dwd_recharge_order 充值订单主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_recharge_order |
| 主键 | recharge_order_id |
| 扩展表 | dwd_recharge_order_ex |
| 记录数 | 455 |
| 说明 | 会员充值订单事实表,记录会员卡充值的金额、方式等信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | recharge_order_id | BIGINT | NO | PK | 充值订单 ID |
| 2 | tenant_id | BIGINT | YES | | 租户 ID |
| 3 | site_id | BIGINT | YES | | 门店 ID |
| 4 | member_id | BIGINT | YES | | 会员 ID → dim_member |
| 5 | member_name_snapshot | TEXT | YES | | 会员名称快照 |
| 6 | member_phone_snapshot | TEXT | YES | | 会员电话快照 |
| 7 | tenant_member_card_id | BIGINT | YES | | 会员卡账户 ID → dim_member_card_account |
| 8 | member_card_type_name | TEXT | YES | | 卡类型名称。**枚举值**: "储值卡", "月卡" |
| 9 | settle_relate_id | BIGINT | YES | | 结算关联 ID |
| 10 | settle_type | INTEGER | YES | | 结算类型。**枚举值**: 5=充值订单, 7=充值退款 |
| 11 | settle_name | TEXT | YES | | 结算名称。**枚举值**: "充值订单", "充值退款" |
| 12 | is_first | INTEGER | YES | | 是否首充。**枚举值**: 1=是, 2=否 |
| 13 | pay_amount | NUMERIC(18,2) | YES | | 充值金额(元,撤销为负数) |
| 14 | refund_amount | NUMERIC(18,2) | YES | | 退款金额 |
| 15 | point_amount | NUMERIC(18,2) | YES | | 积分金额 |
| 16 | cash_amount | NUMERIC(18,2) | YES | | 现金金额 |
| 17 | payment_method | INTEGER | YES | | 支付方式,暂未启用。 |
| 18 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
| 19 | pay_time | TIMESTAMPTZ | YES | | 支付时间 |
## 使用说明
```sql
-- 充值总额统计(不含撤销)
SELECT
member_card_type_name,
COUNT(*) AS order_count,
SUM(pay_amount) AS total_recharge
FROM billiards_dwd.dwd_recharge_order
WHERE settle_type = 5
GROUP BY member_card_type_name;
```

View File

@@ -0,0 +1,45 @@
# dwd_refund 退款流水主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_refund |
| 主键 | refund_id |
| 扩展表 | dwd_refund_ex |
| 记录数 | 45 |
| 说明 | 退款流水事实表,记录退款的金额、关联业务等信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | refund_id | BIGINT | NO | PK | 退款流水 ID |
| 2 | tenant_id | BIGINT | YES | | 租户 ID |
| 3 | site_id | BIGINT | YES | | 门店 ID |
| 4 | relate_type | INTEGER | YES | | 关联业务类型。**枚举值**: 1(7)=预付退款 , 2(31)=结账退款, 5(7)=充值退款 |
| 5 | relate_id | BIGINT | YES | | 关联业务 ID |
| 6 | pay_amount | NUMERIC(18,2) | YES | | 退款金额(元,负数) |
| 7 | channel_fee | NUMERIC(18,2) | YES | | 渠道手续费 |
| 8 | pay_time | TIMESTAMPTZ | YES | | 退款时间 |
| 9 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
| 10 | payment_method | INTEGER | YES | | 支付方式,暂无用途。 |
| 11 | member_id | BIGINT | YES | | 会员 ID当前数据全为 0 |
| 12 | member_card_id | BIGINT | YES | | 会员卡 ID当前数据全为 0 |
## 使用说明
```sql
-- 退款统计
SELECT
relate_type,
COUNT(*) AS refund_count,
SUM(ABS(pay_amount)) AS total_refund
FROM billiards_dwd.dwd_refund
GROUP BY relate_type;
```

View File

@@ -0,0 +1,74 @@
# dwd_settlement_head 结账头表主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_settlement_head |
| 主键 | order_settle_id |
| 扩展表 | dwd_settlement_head_ex |
| 记录数 | 23366 |
| 说明 | 结账单头表事实表,是核心交易表,记录每笔结账的消费金额、支付方式、折扣等汇总信息 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | order_settle_id | BIGINT | NO | PK | 结账单 ID |
| 2 | tenant_id | BIGINT | YES | | 租户 ID |
| 3 | site_id | BIGINT | YES | | 门店 ID → dim_site |
| 4 | site_name | VARCHAR | YES | | 门店名称。**当前值**: "朗朗桌球" |
| 5 | table_id | BIGINT | YES | | 台桌 ID → dim_table0=非台桌订单,如商城订单) |
| 6 | settle_name | VARCHAR | YES | | 结账名称。**样本值**: "商城订单", "A区 A3", "A区 A4", "斯诺克区 S1" |
| 7 | order_trade_no | BIGINT | YES | | 订单号 |
| 8 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
| 9 | pay_time | TIMESTAMPTZ | YES | | 支付时间 |
| 10 | settle_type | INTEGER | YES | | 结账类型。**枚举值**: 1=台桌结账, 3=商城订单, 6=退货订单, 7=退款订单 |
| 11 | revoke_order_id | BIGINT | YES | | 撤销订单 ID当前数据全为 0 |
| 12 | member_id | BIGINT | YES | | 会员 ID → dim_member0=散客,占比约 82.8% |
| 13 | member_name | VARCHAR | YES | | 会员名称 |
| 14 | member_phone | VARCHAR | YES | | 会员电话 |
| 15 | member_card_account_id | BIGINT | YES | | 会员卡账户 ID当前数据全为 0 |
| 16 | member_card_type_name | VARCHAR | YES | | 卡类型名称(当前数据全为空) |
| 17 | is_bind_member | BOOLEAN | YES | | 是否绑定会员。**枚举值**: False=否 |
| 18 | member_discount_amount | NUMERIC(18,2) | YES | | 会员折扣金额 |
| 19 | consume_money | NUMERIC(18,2) | YES | | 消费总金额(元) |
| 20 | table_charge_money | NUMERIC(18,2) | YES | | 台费金额 |
| 21 | goods_money | NUMERIC(18,2) | YES | | 商品金额 |
| 22 | real_goods_money | NUMERIC(18,2) | YES | | 实收商品金额 |
| 23 | assistant_pd_money | NUMERIC(18,2) | YES | | 助教陪打费用 |
| 24 | assistant_cx_money | NUMERIC(18,2) | YES | | 助教促销费用 |
| 25 | adjust_amount | NUMERIC(18,2) | YES | | 调整金额 |
| 26 | pay_amount | NUMERIC(18,2) | YES | | 实付金额 |
| 27 | balance_amount | NUMERIC(18,2) | YES | | 余额支付金额 |
| 28 | recharge_card_amount | NUMERIC(18,2) | YES | | 储值卡支付金额 |
| 29 | gift_card_amount | NUMERIC(18,2) | YES | | 礼品卡支付金额 |
| 30 | coupon_amount | NUMERIC(18,2) | YES | | 券抵扣金额 |
| 31 | rounding_amount | NUMERIC(18,2) | YES | | 抹零金额 |
| 32 | point_amount | NUMERIC(18,2) | YES | | 积分抵扣等值金额 |
## 使用说明
```sql
-- 每日营收统计
SELECT
DATE(pay_time) AS pay_date,
COUNT(*) AS order_count,
SUM(consume_money) AS total_consume,
SUM(pay_amount) AS total_pay
FROM billiards_dwd.dwd_settlement_head
GROUP BY DATE(pay_time)
ORDER BY pay_date DESC;
-- 台费 vs 商品 vs 助教收入
SELECT
SUM(table_charge_money) AS table_revenue,
SUM(goods_money) AS goods_revenue,
SUM(assistant_pd_money + assistant_cx_money) AS assistant_revenue
FROM billiards_dwd.dwd_settlement_head;
```

View File

@@ -0,0 +1,61 @@
# dwd_store_goods_sale 商品销售主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_store_goods_sale |
| 主键 | store_goods_sale_id |
| 扩展表 | dwd_store_goods_sale_ex |
| 记录数 | 17563 |
| 说明 | 商品销售流水事实表,记录每笔商品销售明细 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | store_goods_sale_id | BIGINT | NO | PK | 销售流水 ID |
| 2 | order_trade_no | BIGINT | YES | | 订单号 |
| 3 | order_settle_id | BIGINT | YES | | 结账单 ID → dwd_settlement_head |
| 4 | order_pay_id | BIGINT | YES | | 支付单 ID当前数据全为 0 |
| 5 | order_goods_id | BIGINT | YES | | 订单商品 ID0=商城订单) |
| 6 | site_id | BIGINT | YES | | 门店 ID |
| 7 | tenant_id | BIGINT | YES | | 租户 ID |
| 8 | site_goods_id | BIGINT | YES | | 门店商品 ID → dim_store_goods |
| 9 | tenant_goods_id | BIGINT | YES | | 租户商品 ID → dim_tenant_goods |
| 10 | tenant_goods_category_id | BIGINT | YES | | 商品分类 ID |
| 11 | tenant_goods_business_id | BIGINT | YES | | 业务大类 ID |
| 12 | site_table_id | BIGINT | YES | | 台桌 ID0=商城订单,非台桌消费) |
| 13 | ledger_name | VARCHAR | YES | | 商品名称。**样本值**: "哇哈哈矿泉水", "东方树叶", "可乐" 等 |
| 14 | ledger_group_name | VARCHAR | YES | | 商品分类。**样本值**: "酒水", "零食", "香烟" 等 |
| 15 | ledger_unit_price | NUMERIC(18,2) | YES | | 单价(元) |
| 16 | ledger_count | INTEGER | YES | | 购买数量。**样本值**: 1, 2, 3, 4 等 |
| 17 | ledger_amount | NUMERIC(18,2) | YES | | 销售金额(元) |
| 18 | discount_price | NUMERIC(18,2) | YES | | 折扣金额 |
| 19 | real_goods_money | NUMERIC(18,2) | YES | | 实收金额 |
| 20 | cost_money | NUMERIC(18,2) | YES | | 成本金额 |
| 21 | ledger_status | INTEGER | YES | | 账本状态。**枚举值**: 1=已结算 |
| 22 | is_delete | INTEGER | YES | | 删除标记。**枚举值**: 0=未删除 |
| 23 | create_time | TIMESTAMPTZ | YES | | 创建时间 |
## 使用说明
```sql
-- 热销商品排行
SELECT
ledger_name,
ledger_group_name,
COUNT(*) AS sale_count,
SUM(ledger_count) AS total_qty,
SUM(real_goods_money) AS total_revenue
FROM billiards_dwd.dwd_store_goods_sale
WHERE is_delete = 0
GROUP BY ledger_name, ledger_group_name
ORDER BY total_revenue DESC
LIMIT 20;
```

View File

@@ -0,0 +1,43 @@
# dwd_table_fee_adjust 台费调整主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_table_fee_adjust |
| 主键 | table_fee_adjust_id |
| 扩展表 | dwd_table_fee_adjust_ex |
| 记录数 | 2849 |
| 说明 | 台费调整事实表,记录台费调整的金额和时间 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | table_fee_adjust_id | BIGINT | NO | PK | 台费调整 ID |
| 2 | order_trade_no | BIGINT | YES | | 订单号 |
| 3 | order_settle_id | BIGINT | YES | | 结账单 ID → dwd_settlement_head |
| 4 | tenant_id | BIGINT | YES | | 租户 ID |
| 5 | site_id | BIGINT | YES | | 门店 ID |
| 6 | table_id | BIGINT | YES | | 台桌 ID → dim_table |
| 7 | table_area_id | BIGINT | YES | | 台区 ID |
| 8 | table_area_name | VARCHAR | YES | | 台区名称(当前数据全为 NULL |
| 9 | tenant_table_area_id | BIGINT | YES | | 租户台区 ID |
| 10 | ledger_amount | NUMERIC(18,2) | YES | | 调整金额(元) |
| 11 | ledger_status | INTEGER | YES | | 账本状态。**枚举值**: 0=待确认, 1=已确认 |
| 12 | is_delete | INTEGER | YES | | 删除标记。**枚举值**: 0=未删除 |
## 使用说明
```sql
-- 台费调整统计
SELECT
COUNT(*) AS adjust_count,
SUM(ledger_amount) AS total_adjust
FROM billiards_dwd.dwd_table_fee_adjust
WHERE is_delete = 0 AND ledger_status = 1;
```

View File

@@ -0,0 +1,64 @@
# dwd_table_fee_log 台费流水主表
> 生成时间2026-01-28
## 表信息
| 属性 | 值 |
|------|-----|
| Schema | billiards_dwd |
| 表名 | dwd_table_fee_log |
| 主键 | table_fee_log_id |
| 扩展表 | dwd_table_fee_log_ex |
| 记录数 | 18386 |
| 说明 | 台费计费流水事实表,记录每次台桌使用的计费明细 |
## 字段说明
| 序号 | 字段名 | 类型 | 可空 | 主键 | 说明 |
|------|--------|------|------|------|------|
| 1 | table_fee_log_id | BIGINT | NO | PK | 台费流水 ID |
| 2 | order_trade_no | BIGINT | YES | | 订单号 |
| 3 | order_settle_id | BIGINT | YES | | 结账单 ID → dwd_settlement_head |
| 4 | order_pay_id | BIGINT | YES | | 支付单 ID当前数据全为 0 |
| 5 | tenant_id | BIGINT | YES | | 租户 ID |
| 6 | site_id | BIGINT | YES | | 门店 ID |
| 7 | site_table_id | BIGINT | YES | | 台桌 ID → dim_table |
| 8 | site_table_area_id | BIGINT | YES | | 台区 ID |
| 9 | site_table_area_name | VARCHAR | YES | | 台区名称。**枚举值**: "A区", "B区", "斯诺克区", "麻将房", "C区", "补时长", "VIP包厢" 等 |
| 10 | tenant_table_area_id | BIGINT | YES | | 租户级台区 ID |
| 11 | member_id | BIGINT | YES | | 会员 ID0=散客,占比约 82.4% |
| 12 | ledger_name | VARCHAR | YES | | 台桌名称。**样本值**: "A3", "A5", "A4", "S1", "B5", "M3" 等 |
| 13 | ledger_unit_price | NUMERIC(18,2) | YES | | 单价(元/小时),如 48.00/58.00/68.00 |
| 14 | ledger_count | INTEGER | YES | | 计费时长(秒)。**样本值**: 3600=1h, 7200=2h, 10800=3h 等 |
| 15 | ledger_amount | NUMERIC(18,2) | YES | | 计费金额(元) |
| 16 | real_table_charge_money | NUMERIC(18,2) | YES | | 实收台费金额 |
| 17 | coupon_promotion_amount | NUMERIC(18,2) | YES | | 券促销金额 |
| 18 | member_discount_amount | NUMERIC(18,2) | YES | | 会员折扣金额 |
| 19 | adjust_amount | NUMERIC(18,2) | YES | | 调整金额 |
| 20 | real_table_use_seconds | INTEGER | YES | | 实际使用时长(秒) |
| 21 | add_clock_seconds | INTEGER | YES | | 加时时长(秒),大多为 0 |
| 22 | start_use_time | TIMESTAMPTZ | YES | | 开台时间 |
| 23 | ledger_end_time | TIMESTAMPTZ | YES | | 结账时间 |
| 24 | create_time | TIMESTAMPTZ | YES | | 记录创建时间 |
| 25 | ledger_status | INTEGER | YES | | 账本状态。**枚举值**: 1=已结算 |
| 26 | is_single_order | INTEGER | YES | | 是否独立订单。**枚举值**: 0=合并订单, 1=独立订单 |
| 27 | is_delete | INTEGER | YES | | 删除标记。**枚举值**: 0=未删除 |
## 使用说明
```sql
-- 各台区台费收入统计
SELECT
site_table_area_name,
COUNT(*) AS usage_count,
SUM(ledger_amount) AS total_fee,
SUM(real_table_charge_money) AS real_fee,
SUM(coupon_promotion_amount) AS coupon_fee
FROM billiards_dwd.dwd_table_fee_log
WHERE is_delete = 0
GROUP BY site_table_area_name
ORDER BY total_fee DESC;
```

View File

@@ -104,9 +104,9 @@
| `entry_time` | TIMESTAMPTZ | | | 入职时间。 | assistant_accounts_master - entry_time。 | assistant_accounts_master.json - data.assistantInfos - entry_time。 |
| `resign_time` | TIMESTAMPTZ | | | 离职日期;使用“远未来日期”作为“未离职”的占位。 | assistant_accounts_master - resign_time。 | assistant_accounts_master.json - data.assistantInfos - resign_time。 |
| `resign_time` | TIMESTAMPTZ | | | 离职日期;使用“远未来日期大于2200年”作为“未离职”的占位。 | assistant_accounts_master - resign_time。 | assistant_accounts_master.json - data.assistantInfos - resign_time。 |
| `leave_status` | INTEGER | | | 业务状态/类型字段,用于过滤、分类与统计口径区分。 | assistant_accounts_master - leave_status。 | assistant_accounts_master.json - data.assistantInfos - leave_status。 |
| `leave_status` | INTEGER | | | 业务状态/类型字段,是否离职的状态0在职1离职。 | assistant_accounts_master - leave_status。 | assistant_accounts_master.json - data.assistantInfos - leave_status。 |
| `assistant_status` | INTEGER | | | 账号启用状态:。 | assistant_accounts_master - assistant_status。 | assistant_accounts_master.json - data.assistantInfos - assistant_status。 |

View File

@@ -1,585 +0,0 @@
# -*- coding: utf-8 -*-
"""生成 2025年10-12月 助教排行榜 + 助教详情表CSV + MD
输出目录etl_billiards/docs/table_2025-12-19
注意:客户流水/充值归因涉及“多助教/多订单命中”时按全额复制计入,会导致助教汇总>门店汇总,表格说明会写明。
"""
from __future__ import annotations
import csv
import re
from dataclasses import dataclass
from decimal import Decimal
from pathlib import Path
from statistics import median
from typing import Any
import psycopg2
import psycopg2.extras
SITE_ID = 2790685415443269
TZ = "Asia/Shanghai"
WIN_OCT = ("2025-10-01 00:00:00+08", "2025-11-01 00:00:00+08")
WIN_NOV = ("2025-11-01 00:00:00+08", "2025-12-01 00:00:00+08")
WIN_DEC = ("2025-12-01 00:00:00+08", "2026-01-01 00:00:00+08")
WIN_ALL = (WIN_OCT[0], WIN_DEC[1])
MONTHS = [
("2025-10", "10月", WIN_OCT),
("2025-11", "11月", WIN_NOV),
("2025-12", "12月", WIN_DEC),
]
REPO_ROOT = Path(__file__).resolve().parents[3]
ENV_PATH = REPO_ROOT / "etl_billiards" / ".env"
OUT_DIR = Path(__file__).resolve().parent
@dataclass(frozen=True)
class SqlBlock:
title: str
sql: str
def read_pg_dsn() -> str:
text = ENV_PATH.read_text(encoding="utf-8")
m = re.search(r"^PG_DSN=(.+)$", text, re.M)
if not m:
raise RuntimeError(f"未在 {ENV_PATH} 中找到 PG_DSN")
return m.group(1).strip()
def conn():
return psycopg2.connect(read_pg_dsn(), connect_timeout=10)
def sanitize_filename(name: str) -> str:
name = name.strip()
name = re.sub(r"[<>:\"/\\|?*]+", "_", name)
name = re.sub(r"\s+", " ", name)
return name
def d(v: Any) -> Decimal:
if v is None:
return Decimal("0")
if isinstance(v, Decimal):
return v
return Decimal(str(v))
def fmt_money(v: Any) -> str:
return f"{d(v):.2f}"
def fmt_hours(v: Any, digits: int = 2) -> str:
q = Decimal("1").scaleb(-digits)
return f"{d(v).quantize(q):f}h"
def write_csv(path: Path, title: str, description: str, header_rows: list[list[str]], rows: list[list[Any]]) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
with path.open("w", newline="", encoding="utf-8") as f:
w = csv.writer(f)
w.writerow([title])
w.writerow([description])
w.writerow([])
for hr in header_rows:
w.writerow(hr)
for r in rows:
w.writerow(["" if v is None else v for v in r])
def write_csv_sections(path: Path, title: str, description: str, section_rows: list[list[Any]]) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
with path.open("w", newline="", encoding="utf-8") as f:
w = csv.writer(f)
w.writerow([title])
w.writerow([description])
w.writerow([])
for r in section_rows:
w.writerow(["" if v is None else v for v in r])
def write_md(path: Path, title: str, thinking: str, description: str, sql_blocks: list[SqlBlock]) -> None:
parts: list[str] = []
parts.append(f"# {title}\n")
parts.append("## 思考过程\n")
parts.append(thinking.strip() + "\n")
parts.append("\n## 查询说明\n")
parts.append(description.strip() + "\n")
parts.append("\n## SQL\n")
for b in sql_blocks:
parts.append(f"\n### {b.title}\n")
parts.append("```sql\n")
parts.append(b.sql.strip() + "\n")
parts.append("```\n")
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text("".join(parts), encoding="utf-8")
def fetch_all(cur, sql: str, params: dict[str, Any]) -> list[dict[str, Any]]:
cur.execute(sql, params)
return list(cur.fetchall())
def month_case(ts_expr: str) -> str:
parts = []
for month_key, _, (ws, we) in MONTHS:
parts.append(
f"when {ts_expr} >= '{ws}'::timestamptz and {ts_expr} < '{we}'::timestamptz then '{month_key}'"
)
return "case " + " ".join(parts) + " else null end"
def sql_order_base(window_start: str, window_end: str) -> str:
return f"""
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '{window_start}'::timestamptz
and tfl.start_use_time < '{window_end}'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
"""
def dense_rank_desc(values: dict[str, Decimal]) -> dict[str, int]:
uniq = sorted({v for v in values.values() if v > 0}, reverse=True)
rank_map = {v: i + 1 for i, v in enumerate(uniq)}
return {k: rank_map.get(v, 0) for k, v in values.items()}
def calc_diff(all_values: dict[str, Decimal], current: Decimal) -> tuple[Decimal, Decimal]:
xs = [v for v in all_values.values() if v > 0]
if not xs or current <= 0:
return Decimal("0"), Decimal("0")
avg = sum(xs) / Decimal(len(xs))
med = Decimal(str(median([float(v) for v in xs])))
return current - avg, current - med
def main() -> None:
OUT_DIR.mkdir(parents=True, exist_ok=True)
with conn() as c, c.cursor(cursor_factory=psycopg2.extras.RealDictCursor) as cur:
assistants_rows = fetch_all(
cur,
"""
select distinct nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
order by assistant;
""",
{"site_id": SITE_ID, "window_start": WIN_ALL[0], "window_end": WIN_ALL[1]},
)
assistants = [r["assistant"] for r in assistants_rows if r.get("assistant")]
# 助教-客户-月份:服务时长
sql_svc = f"""
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
{month_case('asl.start_use_time')} as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
"""
svc_rows = fetch_all(cur, sql_svc, {"site_id": SITE_ID, "window_start": WIN_ALL[0], "window_end": WIN_ALL[1]})
# 助教-客户-月份:客户流水
sql_rev = sql_order_base(WIN_ALL[0], WIN_ALL[1]) + f"""
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
{month_case('o.order_start_time')} as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
"""
rev_rows = fetch_all(cur, sql_rev, {"site_id": SITE_ID, "window_start": WIN_ALL[0], "window_end": WIN_ALL[1]})
# 助教-客户-月份:充值归因
sql_rech = f"""
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
{month_case('m.pay_time')} as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
"""
rech_rows = fetch_all(cur, sql_rech, {"site_id": SITE_ID, "window_start": WIN_ALL[0], "window_end": WIN_ALL[1]})
# 汇总:月度助教指标
svc_map = {mk: {a: {"base": Decimal('0'), "extra": Decimal('0')} for a in assistants} for mk,_,_ in MONTHS}
for r in svc_rows:
mk = r["month_key"]; a = r["assistant"]
if mk in svc_map and a in svc_map[mk]:
svc_map[mk][a]["base"] += d(r["base_hours"])
svc_map[mk][a]["extra"] += d(r["extra_hours"])
revenue_map = {mk: {a: Decimal('0') for a in assistants} for mk,_,_ in MONTHS}
for r in rev_rows:
mk = r["month_key"]; a = r["assistant"]
if mk in revenue_map and a in revenue_map[mk]:
revenue_map[mk][a] += d(r["revenue_amount"])
recharge_map = {mk: {a: Decimal('0') for a in assistants} for mk,_,_ in MONTHS}
for r in rech_rows:
mk = r["month_key"]; a = r["assistant"]
if mk in recharge_map and a in recharge_map[mk]:
recharge_map[mk][a] += d(r["recharge_amount"])
# ====== 输出4张排行榜 ======
def write_rank(file_stem: str, title: str, desc: str, rows: list[list[Any]]):
write_csv(OUT_DIR / f"{file_stem}.csv", title, desc, [["月份", "排名", "助教昵称", "指标"]], rows)
write_md(OUT_DIR / f"{file_stem}.md", title, "按月聚合并做dense_rank排名。", desc, [])
rows = []
for mk,_,_ in MONTHS:
values = {a: svc_map[mk][a]["base"] for a in assistants}
ranks = dense_rank_desc(values)
for a in sorted(assistants, key=lambda x: (ranks[x] if ranks[x] else 999999, x)):
v = values[a]
if v > 0:
rows.append([mk, ranks[a], a, fmt_hours(v, 2)])
write_rank(
"助教_基础课时长排行_2025年10-12月",
"2025年10-12月 助教基础课时长排行榜",
"口径order_assistant_type=1时长=income_seconds/3600小时按月排名。",
rows,
)
rows = []
for mk,_,_ in MONTHS:
values = {a: svc_map[mk][a]["extra"] for a in assistants}
ranks = dense_rank_desc(values)
for a in sorted(assistants, key=lambda x: (ranks[x] if ranks[x] else 999999, x)):
v = values[a]
if v > 0:
rows.append([mk, ranks[a], a, fmt_hours(v, 2)])
write_rank(
"助教_附加课时长排行_2025年10-12月",
"2025年10-12月 助教附加课(超休)时长排行榜",
"口径order_assistant_type=2超休时长=income_seconds/3600小时按月排名。",
rows,
)
rows = []
for mk,_,_ in MONTHS:
values = revenue_map[mk]
ranks = dense_rank_desc(values)
for a in sorted(assistants, key=lambda x: (ranks[x] if ranks[x] else 999999, x)):
v = values[a]
if v > 0:
rows.append([mk, ranks[a], a, fmt_money(v)])
write_rank(
"助教_客户流水排行_2025年10-12月",
"2025年10-12月 助教客户流水排行榜(全额复制口径)",
"口径:客户流水=台费+助教+商品应付金额按订单归集后,全额计入订单内每位助教;多助教会导致汇总>门店总额。",
rows,
)
rows = []
for mk,_,_ in MONTHS:
values = recharge_map[mk]
ranks = dense_rank_desc(values)
for a in sorted(assistants, key=lambda x: (ranks[x] if ranks[x] else 999999, x)):
v = values[a]
if v > 0:
rows.append([mk, ranks[a], a, fmt_money(v)])
write_rank(
"助教_客户充值归因排行_2025年10-12月",
"2025年10-12月 助教客户充值归因排行榜(全额复制口径)",
"口径:充值支付(dwd_payment.relate_type=5)在消费窗口±30分钟内命中且订单有助教则全额计入助教多助教/多订单命中会重复计入。",
rows,
)
# ====== 输出助教详情(每人一份) ======
# 会员昵称
cur.execute("select member_id, nickname from billiards_dwd.dim_member where scd2_is_current=1")
member_name = {r["member_id"]: (r.get("nickname") or "") for r in cur.fetchall()}
# 索引assistant->member->month
svc_idx = {a: {} for a in assistants}
for r in svc_rows:
a = r["assistant"]; mid = int(r["member_id"]); mk = r["month_key"]
svc_idx.setdefault(a, {}).setdefault(mid, {})[mk] = {"base": d(r["base_hours"]), "extra": d(r["extra_hours"])}
rev_idx = {a: {} for a in assistants}
for r in rev_rows:
a = r["assistant"]; mid = int(r["member_id"]); mk = r["month_key"]
rev_idx.setdefault(a, {}).setdefault(mid, {})[mk] = d(r["revenue_amount"])
rech_idx = {a: {} for a in assistants}
for r in rech_rows:
a = r["assistant"]; mid = int(r["member_id"]); mk = r["month_key"]
rech_idx.setdefault(a, {}).setdefault(mid, {})[mk] = d(r["recharge_amount"])
for a in assistants:
safe = sanitize_filename(a)
csv_path = OUT_DIR / f"助教详情_{safe}.csv"
md_path = OUT_DIR / f"助教详情_{safe}.md"
# 评价(简短)
base_total = sum((svc_map[mk][a]["base"] for mk,_,_ in MONTHS), Decimal('0'))
extra_total = sum((svc_map[mk][a]["extra"] for mk,_,_ in MONTHS), Decimal('0'))
rev_total = sum((revenue_map[mk][a] for mk,_,_ in MONTHS), Decimal('0'))
rech_total = sum((recharge_map[mk][a] for mk,_,_ in MONTHS), Decimal('0'))
# 头部客户 Top100按12月消费业绩
members = set(rev_idx.get(a, {}).keys()) | set(svc_idx.get(a, {}).keys()) | set(rech_idx.get(a, {}).keys())
def rev_dec(mid: int) -> Decimal:
return rev_idx.get(a, {}).get(mid, {}).get('2025-12', Decimal('0'))
top_members = sorted(members, key=lambda mid: rev_dec(mid), reverse=True)[:100]
top3 = ''.join([(member_name.get(mid) or str(mid)) for mid in top_members[:3]])
assistant_review = (
f"评价:基础{fmt_hours(base_total,1)},附加{fmt_hours(extra_total,1)}"
f"客户流水¥{rev_total:.2f},充值归因¥{rech_total:.2f}"
f"头部客户(12月)Top3{top3 or ''}"
)
# Part1-4
part1=[]; part2=[]; part3=[]; part4=[]
for mk, mcn, _ in MONTHS:
base_v = svc_map[mk][a]["base"]
extra_v = svc_map[mk][a]["extra"]
rev_v = revenue_map[mk][a]
rech_v = recharge_map[mk][a]
base_all = {x: svc_map[mk][x]["base"] for x in assistants}
extra_all = {x: svc_map[mk][x]["extra"] for x in assistants}
rev_all = {x: revenue_map[mk][x] for x in assistants}
rech_all = {x: recharge_map[mk][x] for x in assistants}
base_rank = dense_rank_desc(base_all).get(a, 0)
extra_rank = dense_rank_desc(extra_all).get(a, 0)
rev_rank = dense_rank_desc(rev_all).get(a, 0)
rech_rank = dense_rank_desc(rech_all).get(a, 0)
base_da, base_dm = calc_diff(base_all, base_v)
extra_da, extra_dm = calc_diff(extra_all, extra_v)
rev_da, rev_dm = calc_diff(rev_all, rev_v)
rech_da, rech_dm = calc_diff(rech_all, rech_v)
part1.append([mcn, fmt_hours(base_v,2), base_rank or "", fmt_hours(base_da,2), fmt_hours(base_dm,2)])
part2.append([mcn, fmt_hours(extra_v,2), extra_rank or "", fmt_hours(extra_da,2), fmt_hours(extra_dm,2)])
part3.append([mcn, fmt_money(rev_v), rev_rank or "", fmt_money(rev_da), fmt_money(rev_dm)])
part4.append([mcn, fmt_money(rech_v), rech_rank or "", fmt_money(rech_da), fmt_money(rech_dm)])
# Part5 rows
part5=[]
for i, mid in enumerate(top_members, start=1):
def h_pair(month_key: str) -> str:
v = svc_idx.get(a, {}).get(mid, {}).get(month_key, {})
return f"{fmt_hours(v.get('base',Decimal('0')),1)} / {fmt_hours(v.get('extra',Decimal('0')),1)}"
def rev_m(month_key: str) -> Decimal:
return rev_idx.get(a, {}).get(mid, {}).get(month_key, Decimal('0'))
def rech_m(month_key: str) -> Decimal:
return rech_idx.get(a, {}).get(mid, {}).get(month_key, Decimal('0'))
name = member_name.get(mid) or str(mid)
part5.append([
i,
name,
h_pair('2025-12'), fmt_money(rev_m('2025-12')), fmt_money(rech_m('2025-12')),
h_pair('2025-11'), fmt_money(rev_m('2025-11')), fmt_money(rech_m('2025-11')),
h_pair('2025-10'), fmt_money(rev_m('2025-10')), fmt_money(rech_m('2025-10')),
])
title = f"助教详情:{a}2025年10-12月"
desc = (
"本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。"
"均值/中位数差值对比集合为当月该指标>0的助教。"
"充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。"
)
rows=[]
rows += [["一、基础课业绩"], ["说明:" + assistant_review], []]
rows += [["月份", "基础课业绩", "基础课业绩", "基础课业绩", "基础课业绩"], ["月份", "小时数", "排名", "平均值差值小时数", "中位数值差值小时数"]]
rows += part1
rows += [[], ["二、附加课业绩"], ["说明:附加课=order_assistant_type=2。"], []]
rows += [["月份", "附加课业绩", "附加课业绩", "附加课业绩", "附加课业绩"], ["月份", "小时数", "排名", "平均值差值小时数", "中位数值差值小时数"]]
rows += part2
rows += [[], ["三、客户消费业绩"], ["说明:订单台费+助教+商品应付金额全额计入订单内助教。"], []]
rows += [["月份", "客户消费业绩", "客户消费业绩", "客户消费业绩", "客户消费业绩"], ["月份", "合计元", "排名", "平均值差值元", "中位数值差值元"]]
rows += part3
rows += [[], ["四、客户充值业绩"], ["说明充值命中消费窗口±30分钟且有助教则归因全额复制。"], []]
rows += [["月份", "客户充值业绩", "客户充值业绩", "客户充值业绩", "客户充值业绩"], ["月份", "合计元", "排名", "平均值差值元", "中位数值差值元"]]
rows += part4
rows += [[], ["五、头部客户按12月消费业绩排序Top100"], ["说明:基础/附加课时=基础h/附加h。"], []]
rows += [["排名", "客户名称", "12月", "12月", "12月", "11月", "11月", "11月", "10月", "10月", "10月"],
["排名", "客户名称", "基础/附加课时", "消费业绩(元)", "客户充值(元)", "基础/附加课时", "消费业绩(元)", "客户充值(元)", "基础/附加课时", "消费业绩(元)", "客户充值(元)"]]
rows += part5
write_csv_sections(csv_path, title, desc, rows)
write_md(
md_path,
title,
"按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。",
desc + "\n" + assistant_review,
[
SqlBlock("服务时长(助教-客户-月份)", sql_svc),
SqlBlock("客户流水(助教-客户-月份)", sql_rev),
SqlBlock("充值归因(助教-客户-月份)", sql_rech),
],
)
print(f"完成:{OUT_DIR}")
if __name__ == "__main__":
main()

File diff suppressed because it is too large Load Diff

View File

@@ -1,73 +0,0 @@
2025年10-12月 助教基础课时长排行榜
口径order_assistant_type=1时长=income_seconds/3600小时按月排名。
月份,排名,助教昵称,指标
2025-10,1,佳怡,139.55h
2025-10,2,璇子,120.20h
2025-10,3,婉婉,90.68h
2025-10,4,七七,64.70h
2025-10,5,小柔,63.87h
2025-10,6,球球,57.45h
2025-10,7,小敌,55.82h
2025-10,8,涛涛,50.13h
2025-10,9,周周,41.33h
2025-10,10,素素,40.45h
2025-10,11,乔西,32.60h
2025-10,12,苏苏,25.15h
2025-10,13,奈千,23.62h
2025-10,14,年糕,21.23h
2025-10,15,欣怡,19.50h
2025-10,16,饭团,16.00h
2025-10,17,Amy,11.97h
2025-10,18,姜姜,6.60h
2025-10,19,希希,5.02h
2025-10,20,悦悦,2.30h
2025-11,1,佳怡,176.25h
2025-11,2,璇子,147.92h
2025-11,3,小燕,109.28h
2025-11,4,Amy,93.53h
2025-11,5,七七,91.90h
2025-11,6,小柔,88.65h
2025-11,7,涛涛,74.40h
2025-11,8,阿清,73.48h
2025-11,9,小敌,72.90h
2025-11,10,周周,71.27h
2025-11,11,球球,66.50h
2025-11,12,婉婉,46.03h
2025-11,13,小侯,42.58h
2025-11,14,千千,38.88h
2025-11,15,年糕,35.80h
2025-11,16,柚子,35.40h
2025-11,17,素素,35.03h
2025-11,18,瑶瑶,34.25h
2025-11,19,奈千,32.83h
2025-11,20,乔西,30.57h
2025-11,21,泡芙,21.38h
2025-11,22,梦梦,19.60h
2025-11,23,苏苏,13.52h
2025-11,24,欣怡,10.33h
2025-11,25,QQ,5.17h
2025-11,26,西子,1.82h
2025-11,27,希希,1.58h
2025-12,1,小燕,159.02h
2025-12,2,佳怡,109.40h
2025-12,3,璇子,90.75h
2025-12,4,七七,77.72h
2025-12,5,阿清,66.45h
2025-12,6,周周,60.02h
2025-12,7,小柔,54.93h
2025-12,8,小侯,49.57h
2025-12,9,球球,48.58h
2025-12,10,涛涛,44.08h
2025-12,11,苏苏,43.90h
2025-12,12,千千,38.28h
2025-12,13,乔西,25.82h
2025-12,14,年糕,25.62h
2025-12,15,瑶瑶,19.48h
2025-12,16,Amy,18.08h
2025-12,17,婉婉,17.83h
2025-12,18,梦梦,16.08h
2025-12,19,素素,9.98h
2025-12,20,小敌,6.40h
2025-12,21,奈千,2.58h
2025-12,22,QQ,1.22h
1 2025年10-12月 助教基础课时长排行榜
2 口径:order_assistant_type=1,时长=income_seconds/3600(小时),按月排名。
3 月份,排名,助教昵称,指标
4 2025-10,1,佳怡,139.55h
5 2025-10,2,璇子,120.20h
6 2025-10,3,婉婉,90.68h
7 2025-10,4,七七,64.70h
8 2025-10,5,小柔,63.87h
9 2025-10,6,球球,57.45h
10 2025-10,7,小敌,55.82h
11 2025-10,8,涛涛,50.13h
12 2025-10,9,周周,41.33h
13 2025-10,10,素素,40.45h
14 2025-10,11,乔西,32.60h
15 2025-10,12,苏苏,25.15h
16 2025-10,13,奈千,23.62h
17 2025-10,14,年糕,21.23h
18 2025-10,15,欣怡,19.50h
19 2025-10,16,饭团,16.00h
20 2025-10,17,Amy,11.97h
21 2025-10,18,姜姜,6.60h
22 2025-10,19,希希,5.02h
23 2025-10,20,悦悦,2.30h
24 2025-11,1,佳怡,176.25h
25 2025-11,2,璇子,147.92h
26 2025-11,3,小燕,109.28h
27 2025-11,4,Amy,93.53h
28 2025-11,5,七七,91.90h
29 2025-11,6,小柔,88.65h
30 2025-11,7,涛涛,74.40h
31 2025-11,8,阿清,73.48h
32 2025-11,9,小敌,72.90h
33 2025-11,10,周周,71.27h
34 2025-11,11,球球,66.50h
35 2025-11,12,婉婉,46.03h
36 2025-11,13,小侯,42.58h
37 2025-11,14,千千,38.88h
38 2025-11,15,年糕,35.80h
39 2025-11,16,柚子,35.40h
40 2025-11,17,素素,35.03h
41 2025-11,18,瑶瑶,34.25h
42 2025-11,19,奈千,32.83h
43 2025-11,20,乔西,30.57h
44 2025-11,21,泡芙,21.38h
45 2025-11,22,梦梦,19.60h
46 2025-11,23,苏苏,13.52h
47 2025-11,24,欣怡,10.33h
48 2025-11,25,QQ,5.17h
49 2025-11,26,西子,1.82h
50 2025-11,27,希希,1.58h
51 2025-12,1,小燕,159.02h
52 2025-12,2,佳怡,109.40h
53 2025-12,3,璇子,90.75h
54 2025-12,4,七七,77.72h
55 2025-12,5,阿清,66.45h
56 2025-12,6,周周,60.02h
57 2025-12,7,小柔,54.93h
58 2025-12,8,小侯,49.57h
59 2025-12,9,球球,48.58h
60 2025-12,10,涛涛,44.08h
61 2025-12,11,苏苏,43.90h
62 2025-12,12,千千,38.28h
63 2025-12,13,乔西,25.82h
64 2025-12,14,年糕,25.62h
65 2025-12,15,瑶瑶,19.48h
66 2025-12,16,Amy,18.08h
67 2025-12,17,婉婉,17.83h
68 2025-12,18,梦梦,16.08h
69 2025-12,19,素素,9.98h
70 2025-12,20,小敌,6.40h
71 2025-12,21,奈千,2.58h
72 2025-12,22,QQ,1.22h

View File

@@ -1,31 +0,0 @@
# 2025年10-12月 助教基础课时长排行榜
## 思考过程
按月汇总助教基础课时长,并用 dense_rank 做排名。
## 查询说明
口径order_assistant_type=1时长=income_seconds/3600小时
## SQL
### 基础课时长(助教+月份汇总)
```sql
with raw as (
select
asl.nickname as assistant,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0)=0
and asl.order_assistant_type=1
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
)
select
assistant,
month_key,
sum(income_seconds)/3600.0 as hours
from raw
where month_key is not null
group by assistant, month_key;
```

View File

@@ -1,35 +0,0 @@
2025年10-12月 助教客户充值归因排行榜(全额复制口径)
口径:充值支付(dwd_payment.relate_type=5)在消费窗口±30分钟内命中且订单有助教则全额计入助教多助教/多订单命中会重复计入。
月份,排名,助教昵称,指标
2025-10,1,璇子,34700.00
2025-10,2,小柔,31700.00
2025-10,3,佳怡,27000.00
2025-10,4,婉婉,24000.00
2025-10,5,小敌,21000.00
2025-10,5,涛涛,21000.00
2025-10,6,奈千,18000.00
2025-10,7,乔西,17000.00
2025-10,8,球球,15000.00
2025-10,9,周周,11000.00
2025-10,10,年糕,9000.00
2025-10,11,七七,6000.00
2025-10,11,素素,6000.00
2025-10,11,苏苏,6000.00
2025-10,12,姜姜,4000.00
2025-10,13,Amy,3000.00
2025-10,13,悦悦,3000.00
2025-10,13,欣怡,3000.00
2025-11,1,佳怡,20000.00
2025-11,2,小柔,11000.00
2025-11,3,璇子,10000.00
2025-11,4,Amy,9000.00
2025-11,4,周周,9000.00
2025-11,4,婉婉,9000.00
2025-11,4,球球,9000.00
2025-11,5,小敌,8000.00
2025-11,6,涛涛,5000.00
2025-11,7,欣怡,4000.00
2025-11,8,乔西,3000.00
2025-11,8,柚子,3000.00
2025-11,9,素素,1000.00
1 2025年10-12月 助教客户充值归因排行榜(全额复制口径)
2 口径:充值支付(dwd_payment.relate_type=5)在消费窗口±30分钟内命中且订单有助教,则全额计入助教;多助教/多订单命中会重复计入。
3 月份,排名,助教昵称,指标
4 2025-10,1,璇子,34700.00
5 2025-10,2,小柔,31700.00
6 2025-10,3,佳怡,27000.00
7 2025-10,4,婉婉,24000.00
8 2025-10,5,小敌,21000.00
9 2025-10,5,涛涛,21000.00
10 2025-10,6,奈千,18000.00
11 2025-10,7,乔西,17000.00
12 2025-10,8,球球,15000.00
13 2025-10,9,周周,11000.00
14 2025-10,10,年糕,9000.00
15 2025-10,11,七七,6000.00
16 2025-10,11,素素,6000.00
17 2025-10,11,苏苏,6000.00
18 2025-10,12,姜姜,4000.00
19 2025-10,13,Amy,3000.00
20 2025-10,13,悦悦,3000.00
21 2025-10,13,欣怡,3000.00
22 2025-11,1,佳怡,20000.00
23 2025-11,2,小柔,11000.00
24 2025-11,3,璇子,10000.00
25 2025-11,4,Amy,9000.00
26 2025-11,4,周周,9000.00
27 2025-11,4,婉婉,9000.00
28 2025-11,4,球球,9000.00
29 2025-11,5,小敌,8000.00
30 2025-11,6,涛涛,5000.00
31 2025-11,7,欣怡,4000.00
32 2025-11,8,乔西,3000.00
33 2025-11,8,柚子,3000.00
34 2025-11,9,素素,1000.00

View File

@@ -1,85 +0,0 @@
# 2025年10-12月 助教客户充值归因排行榜(全额复制口径)
## 思考过程
按“消费窗口±30分钟”把充值支付命中到订单再全额计入订单内助教并按月排名。
## 查询说明
注意:多助教/多订单命中按全额复制,充值会重复计入,故助教汇总可能大于门店总额。
## SQL
### 充值归因(助教+月份汇总,全额复制)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select rp.pay_time, ow.order_settle_id, rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select assistant, month_key, sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, month_key;
```

View File

@@ -1,51 +0,0 @@
2025年10-12月 助教客户流水排行榜(全额复制口径)
口径:客户流水=台费+助教+商品应付金额按订单归集后,全额计入订单内每位助教;多助教会导致汇总>门店总额。
月份,排名,助教昵称,指标
2025-10,1,璇子,80804.14
2025-10,2,婉婉,62187.64
2025-10,3,小柔,52623.85
2025-10,4,小敌,44510.29
2025-10,5,佳怡,44466.03
2025-10,6,七七,38810.44
2025-10,7,奈千,38653.58
2025-10,8,涛涛,35940.84
2025-10,9,素素,34135.89
2025-10,10,球球,33923.75
2025-10,11,周周,27375.91
2025-10,12,年糕,26289.89
2025-10,13,乔西,17649.50
2025-10,14,Amy,15810.80
2025-10,15,苏苏,11236.84
2025-10,16,饭团,7955.28
2025-10,17,欣怡,4824.69
2025-10,18,希希,3086.34
2025-10,19,悦悦,2970.96
2025-10,20,姜姜,2333.94
2025-11,1,璇子,154486.83
2025-11,2,Amy,121568.32
2025-11,3,小柔,110137.94
2025-11,4,涛涛,88677.55
2025-11,5,七七,84500.79
2025-11,6,佳怡,79249.31
2025-11,7,奈千,68543.08
2025-11,8,瑶瑶,65924.36
2025-11,9,小敌,47986.57
2025-11,10,球球,41907.39
2025-11,11,梦梦,39768.09
2025-11,12,小燕,39426.42
2025-11,13,阿清,37302.04
2025-11,14,婉婉,33326.32
2025-11,15,周周,31436.74
2025-11,16,小侯,27313.21
2025-11,17,千千,24684.71
2025-11,18,柚子,23234.98
2025-11,19,素素,18707.30
2025-11,20,年糕,15696.08
2025-11,21,乔西,15536.78
2025-11,22,苏苏,10254.59
2025-11,23,泡芙,8323.03
2025-11,24,欣怡,5157.29
2025-11,25,QQ,1134.18
2025-11,26,西子,303.51
2025-11,27,希希,281.22
1 2025年10-12月 助教客户流水排行榜(全额复制口径)
2 口径:客户流水=台费+助教+商品应付金额按订单归集后,全额计入订单内每位助教;多助教会导致汇总>门店总额。
3 月份,排名,助教昵称,指标
4 2025-10,1,璇子,80804.14
5 2025-10,2,婉婉,62187.64
6 2025-10,3,小柔,52623.85
7 2025-10,4,小敌,44510.29
8 2025-10,5,佳怡,44466.03
9 2025-10,6,七七,38810.44
10 2025-10,7,奈千,38653.58
11 2025-10,8,涛涛,35940.84
12 2025-10,9,素素,34135.89
13 2025-10,10,球球,33923.75
14 2025-10,11,周周,27375.91
15 2025-10,12,年糕,26289.89
16 2025-10,13,乔西,17649.50
17 2025-10,14,Amy,15810.80
18 2025-10,15,苏苏,11236.84
19 2025-10,16,饭团,7955.28
20 2025-10,17,欣怡,4824.69
21 2025-10,18,希希,3086.34
22 2025-10,19,悦悦,2970.96
23 2025-10,20,姜姜,2333.94
24 2025-11,1,璇子,154486.83
25 2025-11,2,Amy,121568.32
26 2025-11,3,小柔,110137.94
27 2025-11,4,涛涛,88677.55
28 2025-11,5,七七,84500.79
29 2025-11,6,佳怡,79249.31
30 2025-11,7,奈千,68543.08
31 2025-11,8,瑶瑶,65924.36
32 2025-11,9,小敌,47986.57
33 2025-11,10,球球,41907.39
34 2025-11,11,梦梦,39768.09
35 2025-11,12,小燕,39426.42
36 2025-11,13,阿清,37302.04
37 2025-11,14,婉婉,33326.32
38 2025-11,15,周周,31436.74
39 2025-11,16,小侯,27313.21
40 2025-11,17,千千,24684.71
41 2025-11,18,柚子,23234.98
42 2025-11,19,素素,18707.30
43 2025-11,20,年糕,15696.08
44 2025-11,21,乔西,15536.78
45 2025-11,22,苏苏,10254.59
46 2025-11,23,泡芙,8323.03
47 2025-11,24,欣怡,5157.29
48 2025-11,25,QQ,1134.18
49 2025-11,26,西子,303.51
50 2025-11,27,希希,281.22

View File

@@ -1,73 +0,0 @@
# 2025年10-12月 助教客户流水排行榜(全额复制口径)
## 思考过程
先把订单应付金额汇总为 order_amount再把该订单全额计入订单内每位助教并按月排名。
## 查询说明
注意:多助教按全额复制计入,导致助教汇总>门店总额,这是刻意口径。
## SQL
### 客户流水(助教+月份汇总,全额复制)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id=g.order_settle_id
where g.site_id=%(site_id)s and coalesce(g.is_delete,0)=0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
coalesce(bo.table_amount,0)+coalesce(a.assistant_amount,0)+coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id=bo.order_settle_id
left join goods_amount g on g.order_settle_id=bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
)
select assistant, month_key, sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, month_key;
```

View File

@@ -1,37 +0,0 @@
2025年10-12月 助教附加课(超休)时长排行榜
口径order_assistant_type=2超休时长=income_seconds/3600小时按月排名。
月份,排名,助教昵称,指标
2025-10,1,球球,11.00h
2025-10,2,佳怡,9.00h
2025-10,3,璇子,8.00h
2025-10,3,苏苏,8.00h
2025-10,4,婉婉,4.00h
2025-10,5,姜姜,3.00h
2025-10,5,小敌,3.00h
2025-11,1,周周,25.00h
2025-11,1,球球,25.00h
2025-11,2,婉婉,15.00h
2025-11,3,佳怡,10.00h
2025-11,3,柚子,10.00h
2025-11,3,璇子,10.00h
2025-11,3,素素,10.00h
2025-11,4,小柔,7.00h
2025-11,4,年糕,7.00h
2025-11,5,泡芙,3.00h
2025-11,5,涛涛,3.00h
2025-11,5,瑶瑶,3.00h
2025-11,6,小燕,2.00h
2025-11,7,乔西,1.00h
2025-11,7,梦梦,1.00h
2025-12,1,七七,22.00h
2025-12,2,小燕,21.00h
2025-12,3,婉婉,15.00h
2025-12,3,小柔,15.00h
2025-12,4,璇子,14.00h
2025-12,5,周周,8.00h
2025-12,6,千千,5.00h
2025-12,6,球球,5.00h
2025-12,7,佳怡,4.00h
2025-12,8,QQ,3.00h
2025-12,9,苏苏,1.00h
1 2025年10-12月 助教附加课(超休)时长排行榜
2 口径:order_assistant_type=2,超休时长=income_seconds/3600(小时),按月排名。
3 月份,排名,助教昵称,指标
4 2025-10,1,球球,11.00h
5 2025-10,2,佳怡,9.00h
6 2025-10,3,璇子,8.00h
7 2025-10,3,苏苏,8.00h
8 2025-10,4,婉婉,4.00h
9 2025-10,5,姜姜,3.00h
10 2025-10,5,小敌,3.00h
11 2025-11,1,周周,25.00h
12 2025-11,1,球球,25.00h
13 2025-11,2,婉婉,15.00h
14 2025-11,3,佳怡,10.00h
15 2025-11,3,柚子,10.00h
16 2025-11,3,璇子,10.00h
17 2025-11,3,素素,10.00h
18 2025-11,4,小柔,7.00h
19 2025-11,4,年糕,7.00h
20 2025-11,5,泡芙,3.00h
21 2025-11,5,涛涛,3.00h
22 2025-11,5,瑶瑶,3.00h
23 2025-11,6,小燕,2.00h
24 2025-11,7,乔西,1.00h
25 2025-11,7,梦梦,1.00h
26 2025-12,1,七七,22.00h
27 2025-12,2,小燕,21.00h
28 2025-12,3,婉婉,15.00h
29 2025-12,3,小柔,15.00h
30 2025-12,4,璇子,14.00h
31 2025-12,5,周周,8.00h
32 2025-12,6,千千,5.00h
33 2025-12,6,球球,5.00h
34 2025-12,7,佳怡,4.00h
35 2025-12,8,QQ,3.00h
36 2025-12,9,苏苏,1.00h

View File

@@ -1,31 +0,0 @@
# 2025年10-12月 助教附加课(超休)时长排行榜
## 思考过程
按月汇总助教附加课时长,并用 dense_rank 做排名。
## 查询说明
口径order_assistant_type=2时长=income_seconds/3600小时
## SQL
### 附加课时长(助教+月份汇总)
```sql
with raw as (
select
asl.nickname as assistant,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0)=0
and asl.order_assistant_type=2
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
)
select
assistant,
month_key,
sum(income_seconds)/3600.0 as hours
from raw
where month_key is not null
group by assistant, month_key;
```

View File

@@ -1,56 +0,0 @@
助教详情Amy2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础123.6h附加0.0h客户流水¥150692.64充值归因¥12000.00;头部客户(12月)Top3轩哥、明哥、江先生。
一、基础课业绩
说明评价基础123.6h附加0.0h客户流水¥150692.64充值归因¥12000.00;头部客户(12月)Top3轩哥、明哥、江先生。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,11.97h,17,-32.44h,-24.56h
11月,93.53h,4,39.06h,54.65h
12月,18.08h,16,-26.73h,-23.01h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,0.00h,,0.00h,0.00h
12月,0.00h,,0.00h,0.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,15810.80,14,-13468.73,-14839.03
11月,121568.32,2,77313.93,88242.00
12月,13313.52,12,-7417.01,-327.12
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,3000.00,13,-11466.67,-10000.00
11月,9000.00,4,1230.77,0.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,轩哥,8.8h / 0.0h,4500.95,0.00,36.0h / 0.0h,38175.17,0.00,4.6h / 0.0h,8281.61,0.00
2,明哥,0.1h / 0.0h,4190.45,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
3,江先生,2.2h / 0.0h,3202.78,0.00,4.5h / 0.0h,1719.24,0.00,0.0h / 0.0h,0.00,0.00
4,amy,4.8h / 0.0h,1105.90,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
5,小燕,1.0h / 0.0h,313.44,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
6,叶先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,7.4h / 0.0h,7529.19,3000.00
7,,0.0h / 0.0h,0.00,0.00,4.1h / 0.0h,1017.50,1000.00,0.0h / 0.0h,0.00,0.00
8,葛先生,0.0h / 0.0h,0.00,0.00,1.6h / 0.0h,1585.38,0.00,0.0h / 0.0h,0.00,0.00
9,陈先生,0.0h / 0.0h,0.00,0.00,4.2h / 0.0h,2566.75,3000.00,0.0h / 0.0h,0.00,0.00
10,李先生,0.0h / 0.0h,0.00,0.00,1.0h / 0.0h,816.28,0.00,0.0h / 0.0h,0.00,0.00
11,蔡总,1.2h / 0.0h,0.00,0.00,40.2h / 0.0h,75063.98,5000.00,0.0h / 0.0h,0.00,0.00
12,昌哥,0.0h / 0.0h,0.00,0.00,2.0h / 0.0h,624.02,0.00,0.0h / 0.0h,0.00,0.00
1 助教详情:Amy(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础123.6h,附加0.0h;客户流水¥150692.64,充值归因¥12000.00;头部客户(12月)Top3:轩哥、明哥、江先生。
3 一、基础课业绩
4 说明:评价:基础123.6h,附加0.0h;客户流水¥150692.64,充值归因¥12000.00;头部客户(12月)Top3:轩哥、明哥、江先生。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,11.97h,17,-32.44h,-24.56h
8 11月,93.53h,4,39.06h,54.65h
9 12月,18.08h,16,-26.73h,-23.01h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,0.00h,,0.00h,0.00h
16 12月,0.00h,,0.00h,0.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,15810.80,14,-13468.73,-14839.03
22 11月,121568.32,2,77313.93,88242.00
23 12月,13313.52,12,-7417.01,-327.12
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,3000.00,13,-11466.67,-10000.00
29 11月,9000.00,4,1230.77,0.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,轩哥,8.8h / 0.0h,4500.95,0.00,36.0h / 0.0h,38175.17,0.00,4.6h / 0.0h,8281.61,0.00
36 2,明哥,0.1h / 0.0h,4190.45,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
37 3,江先生,2.2h / 0.0h,3202.78,0.00,4.5h / 0.0h,1719.24,0.00,0.0h / 0.0h,0.00,0.00
38 4,amy,4.8h / 0.0h,1105.90,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
39 5,小燕,1.0h / 0.0h,313.44,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
40 6,叶先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,7.4h / 0.0h,7529.19,3000.00
41 7,羊,0.0h / 0.0h,0.00,0.00,4.1h / 0.0h,1017.50,1000.00,0.0h / 0.0h,0.00,0.00
42 8,葛先生,0.0h / 0.0h,0.00,0.00,1.6h / 0.0h,1585.38,0.00,0.0h / 0.0h,0.00,0.00
43 9,陈先生,0.0h / 0.0h,0.00,0.00,4.2h / 0.0h,2566.75,3000.00,0.0h / 0.0h,0.00,0.00
44 10,李先生,0.0h / 0.0h,0.00,0.00,1.0h / 0.0h,816.28,0.00,0.0h / 0.0h,0.00,0.00
45 11,蔡总,1.2h / 0.0h,0.00,0.00,40.2h / 0.0h,75063.98,5000.00,0.0h / 0.0h,0.00,0.00
46 12,昌哥,0.0h / 0.0h,0.00,0.00,2.0h / 0.0h,624.02,0.00,0.0h / 0.0h,0.00,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情Amy2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础123.6h附加0.0h客户流水¥150692.64充值归因¥12000.00;头部客户(12月)Top3轩哥、明哥、江先生。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,47 +0,0 @@
助教详情QQ2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础6.4h附加3.0h客户流水¥1517.46充值归因¥0.00;头部客户(12月)Top3游、张先生、黄先生。
一、基础课业绩
说明评价基础6.4h附加3.0h客户流水¥1517.46充值归因¥0.00;头部客户(12月)Top3游、张先生、黄先生。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,5.17h,25,-49.31h,-33.72h
12月,1.22h,22,-43.59h,-39.88h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,0.00h,,0.00h,0.00h
12月,3.00h,8,-7.27h,-5.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,0.00,,0.00,0.00
11月,1134.18,25,-43120.21,-32192.14
12月,383.28,21,-20347.25,-13257.36
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,0.00,,0.00,0.00
11月,0.00,,0.00,0.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,,1.2h / 0.0h,383.28,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
2,张先生,0.0h / 0.0h,0.00,0.00,2.8h / 0.0h,502.16,0.00,0.0h / 0.0h,0.00,0.00
3,黄先生,0.0h / 3.0h,0.00,0.00,2.4h / 0.0h,632.02,0.00,0.0h / 0.0h,0.00,0.00
1 助教详情:QQ(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础6.4h,附加3.0h;客户流水¥1517.46,充值归因¥0.00;头部客户(12月)Top3:游、张先生、黄先生。
3 一、基础课业绩
4 说明:评价:基础6.4h,附加3.0h;客户流水¥1517.46,充值归因¥0.00;头部客户(12月)Top3:游、张先生、黄先生。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,0.00h,,0.00h,0.00h
8 11月,5.17h,25,-49.31h,-33.72h
9 12月,1.22h,22,-43.59h,-39.88h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,0.00h,,0.00h,0.00h
16 12月,3.00h,8,-7.27h,-5.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,0.00,,0.00,0.00
22 11月,1134.18,25,-43120.21,-32192.14
23 12月,383.28,21,-20347.25,-13257.36
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,0.00,,0.00,0.00
29 11月,0.00,,0.00,0.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,游,1.2h / 0.0h,383.28,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
36 2,张先生,0.0h / 0.0h,0.00,0.00,2.8h / 0.0h,502.16,0.00,0.0h / 0.0h,0.00,0.00
37 3,黄先生,0.0h / 3.0h,0.00,0.00,2.4h / 0.0h,632.02,0.00,0.0h / 0.0h,0.00,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情QQ2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础6.4h附加3.0h客户流水¥1517.46充值归因¥0.00;头部客户(12月)Top3游、张先生、黄先生。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,56 +0,0 @@
助教详情七七2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础234.3h附加22.0h客户流水¥187346.62充值归因¥6000.00;头部客户(12月)Top3蔡总、轩哥、林先生。
一、基础课业绩
说明评价基础234.3h附加22.0h客户流水¥187346.62充值归因¥6000.00;头部客户(12月)Top3蔡总、轩哥、林先生。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,64.70h,4,20.29h,28.17h
11月,91.90h,5,37.42h,53.02h
12月,77.72h,4,32.91h,36.62h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,0.00h,,0.00h,0.00h
12月,22.00h,1,11.73h,14.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,38810.44,6,9530.91,8160.61
11月,84500.79,5,40246.40,51174.47
12月,64035.39,2,43304.86,50394.74
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,6000.00,11,-8466.67,-7000.00
11月,0.00,,0.00,0.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,蔡总,26.6h / 0.0h,29660.33,0.00,45.7h / 0.0h,52373.96,0.00,0.0h / 0.0h,0.00,0.00
2,轩哥,32.8h / 22.0h,27236.57,0.00,24.2h / 0.0h,21849.91,0.00,39.5h / 0.0h,29630.52,3000.00
3,林先生,14.0h / 0.0h,3808.56,0.00,5.4h / 0.0h,1623.92,0.00,0.0h / 0.0h,0.00,0.00
4,江先生,3.2h / 0.0h,3042.99,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
5,张先生,1.0h / 0.0h,286.94,0.00,10.9h / 0.0h,3995.10,0.00,13.2h / 0.0h,5315.81,0.00
6,,0.0h / 0.0h,0.00,0.00,0.2h / 0.0h,3544.42,0.00,0.0h / 0.0h,0.00,0.00
7,罗先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.1h / 0.0h,545.55,0.00
8,小熊,0.0h / 0.0h,0.00,0.00,1.3h / 0.0h,314.44,0.00,0.0h / 0.0h,0.00,0.00
9,叶总,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.0h / 0.0h,862.68,0.00
10,,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.2h / 0.0h,1278.72,0.00
11,T,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.8h / 0.0h,1177.16,3000.00
12,胡先生,0.0h / 0.0h,0.00,0.00,4.2h / 0.0h,799.04,0.00,0.0h / 0.0h,0.00,0.00
1 助教详情:七七(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础234.3h,附加22.0h;客户流水¥187346.62,充值归因¥6000.00;头部客户(12月)Top3:蔡总、轩哥、林先生。
3 一、基础课业绩
4 说明:评价:基础234.3h,附加22.0h;客户流水¥187346.62,充值归因¥6000.00;头部客户(12月)Top3:蔡总、轩哥、林先生。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,64.70h,4,20.29h,28.17h
8 11月,91.90h,5,37.42h,53.02h
9 12月,77.72h,4,32.91h,36.62h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,0.00h,,0.00h,0.00h
16 12月,22.00h,1,11.73h,14.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,38810.44,6,9530.91,8160.61
22 11月,84500.79,5,40246.40,51174.47
23 12月,64035.39,2,43304.86,50394.74
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,6000.00,11,-8466.67,-7000.00
29 11月,0.00,,0.00,0.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,蔡总,26.6h / 0.0h,29660.33,0.00,45.7h / 0.0h,52373.96,0.00,0.0h / 0.0h,0.00,0.00
36 2,轩哥,32.8h / 22.0h,27236.57,0.00,24.2h / 0.0h,21849.91,0.00,39.5h / 0.0h,29630.52,3000.00
37 3,林先生,14.0h / 0.0h,3808.56,0.00,5.4h / 0.0h,1623.92,0.00,0.0h / 0.0h,0.00,0.00
38 4,江先生,3.2h / 0.0h,3042.99,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
39 5,张先生,1.0h / 0.0h,286.94,0.00,10.9h / 0.0h,3995.10,0.00,13.2h / 0.0h,5315.81,0.00
40 6,游,0.0h / 0.0h,0.00,0.00,0.2h / 0.0h,3544.42,0.00,0.0h / 0.0h,0.00,0.00
41 7,罗先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.1h / 0.0h,545.55,0.00
42 8,小熊,0.0h / 0.0h,0.00,0.00,1.3h / 0.0h,314.44,0.00,0.0h / 0.0h,0.00,0.00
43 9,叶总,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.0h / 0.0h,862.68,0.00
44 10,陶,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.2h / 0.0h,1278.72,0.00
45 11,T,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.8h / 0.0h,1177.16,3000.00
46 12,胡先生,0.0h / 0.0h,0.00,0.00,4.2h / 0.0h,799.04,0.00,0.0h / 0.0h,0.00,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情七七2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础234.3h附加22.0h客户流水¥187346.62充值归因¥6000.00;头部客户(12月)Top3蔡总、轩哥、林先生。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,59 +0,0 @@
助教详情乔西2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础89.0h附加1.0h客户流水¥46219.50充值归因¥20000.00;头部客户(12月)Top3轩哥、T、林先生。
一、基础课业绩
说明评价基础89.0h附加1.0h客户流水¥46219.50充值归因¥20000.00;头部客户(12月)Top3轩哥、T、林先生。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,32.60h,11,-11.81h,-3.93h
11月,30.57h,20,-23.91h,-8.32h
12月,25.82h,13,-18.99h,-15.28h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,1.00h,7,-7.80h,-6.00h
12月,0.00h,,0.00h,0.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,17649.50,13,-11630.03,-13000.33
11月,15536.78,21,-28717.61,-17789.54
12月,13033.22,13,-7697.31,-607.42
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,17000.00,7,2533.33,4000.00
11月,3000.00,8,-4769.23,-6000.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,轩哥,8.2h / 0.0h,8244.84,0.00,8.3h / 0.0h,7623.25,0.00,9.3h / 0.0h,11503.53,8000.00
2,T,6.8h / 0.0h,1789.02,0.00,4.4h / 0.0h,1100.80,0.00,0.0h / 0.0h,0.00,0.00
3,林先生,4.6h / 0.0h,1369.51,0.00,5.0h / 0.0h,1645.89,0.00,0.0h / 0.0h,0.00,0.00
4,张先生,3.3h / 0.0h,1066.81,0.00,0.0h / 0.0h,0.00,0.00,2.5h / 0.0h,489.66,0.00
5,,2.9h / 0.0h,563.04,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
6,罗先生,0.0h / 0.0h,0.00,0.00,1.4h / 0.0h,454.46,0.00,0.0h / 0.0h,0.00,0.00
7,陈腾鑫,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,0.9h / 0.0h,162.29,3000.00
8,葛先生,0.0h / 0.0h,0.00,0.00,2.2h / 0.0h,707.97,0.00,0.0h / 0.0h,0.00,0.00
9,陈先生,0.0h / 0.0h,0.00,0.00,4.2h / 0.0h,2566.75,3000.00,0.0h / 0.0h,0.00,0.00
10,陈淑涛,0.0h / 0.0h,0.00,0.00,3.4h / 0.0h,1021.49,0.00,0.0h / 0.0h,0.00,0.00
11,周先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,7.5h / 0.0h,2726.01,0.00
12,陈德韩,0.0h / 0.0h,0.00,0.00,0.0h / 1.0h,0.00,0.00,7.6h / 0.0h,1568.91,5000.00
13,黄先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.6h / 0.0h,300.37,0.00
14,陈先生,0.0h / 0.0h,0.00,0.00,1.8h / 0.0h,416.17,0.00,0.0h / 0.0h,0.00,0.00
15,方先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.2h / 0.0h,898.73,1000.00
1 助教详情:乔西(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础89.0h,附加1.0h;客户流水¥46219.50,充值归因¥20000.00;头部客户(12月)Top3:轩哥、T、林先生。
3 一、基础课业绩
4 说明:评价:基础89.0h,附加1.0h;客户流水¥46219.50,充值归因¥20000.00;头部客户(12月)Top3:轩哥、T、林先生。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,32.60h,11,-11.81h,-3.93h
8 11月,30.57h,20,-23.91h,-8.32h
9 12月,25.82h,13,-18.99h,-15.28h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,1.00h,7,-7.80h,-6.00h
16 12月,0.00h,,0.00h,0.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,17649.50,13,-11630.03,-13000.33
22 11月,15536.78,21,-28717.61,-17789.54
23 12月,13033.22,13,-7697.31,-607.42
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,17000.00,7,2533.33,4000.00
29 11月,3000.00,8,-4769.23,-6000.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,轩哥,8.2h / 0.0h,8244.84,0.00,8.3h / 0.0h,7623.25,0.00,9.3h / 0.0h,11503.53,8000.00
36 2,T,6.8h / 0.0h,1789.02,0.00,4.4h / 0.0h,1100.80,0.00,0.0h / 0.0h,0.00,0.00
37 3,林先生,4.6h / 0.0h,1369.51,0.00,5.0h / 0.0h,1645.89,0.00,0.0h / 0.0h,0.00,0.00
38 4,张先生,3.3h / 0.0h,1066.81,0.00,0.0h / 0.0h,0.00,0.00,2.5h / 0.0h,489.66,0.00
39 5,候,2.9h / 0.0h,563.04,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
40 6,罗先生,0.0h / 0.0h,0.00,0.00,1.4h / 0.0h,454.46,0.00,0.0h / 0.0h,0.00,0.00
41 7,陈腾鑫,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,0.9h / 0.0h,162.29,3000.00
42 8,葛先生,0.0h / 0.0h,0.00,0.00,2.2h / 0.0h,707.97,0.00,0.0h / 0.0h,0.00,0.00
43 9,陈先生,0.0h / 0.0h,0.00,0.00,4.2h / 0.0h,2566.75,3000.00,0.0h / 0.0h,0.00,0.00
44 10,陈淑涛,0.0h / 0.0h,0.00,0.00,3.4h / 0.0h,1021.49,0.00,0.0h / 0.0h,0.00,0.00
45 11,周先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,7.5h / 0.0h,2726.01,0.00
46 12,陈德韩,0.0h / 0.0h,0.00,0.00,0.0h / 1.0h,0.00,0.00,7.6h / 0.0h,1568.91,5000.00
47 13,黄先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.6h / 0.0h,300.37,0.00
48 14,陈先生,0.0h / 0.0h,0.00,0.00,1.8h / 0.0h,416.17,0.00,0.0h / 0.0h,0.00,0.00
49 15,方先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.2h / 0.0h,898.73,1000.00

View File

@@ -1,196 +0,0 @@
# 助教详情乔西2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础89.0h附加1.0h客户流水¥46219.50充值归因¥20000.00;头部客户(12月)Top3轩哥、T、林先生。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,63 +0,0 @@
助教详情佳怡2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础425.2h附加23.0h客户流水¥156229.68充值归因¥47000.00;头部客户(12月)Top3罗先生、周周、轩哥。
一、基础课业绩
说明评价基础425.2h附加23.0h客户流水¥156229.68充值归因¥47000.00;头部客户(12月)Top3罗先生、周周、轩哥。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,139.55h,1,95.14h,103.02h
11月,176.25h,1,121.77h,137.37h
12月,109.40h,2,64.59h,68.31h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,9.00h,2,2.43h,1.00h
11月,10.00h,3,1.20h,3.00h
12月,4.00h,7,-6.27h,-4.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,44466.03,5,15186.50,13816.20
11月,79249.31,6,34994.92,45922.99
12月,32514.34,6,11783.81,18873.70
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,27000.00,3,12533.33,14000.00
11月,20000.00,1,12230.77,11000.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,罗先生,67.8h / 4.0h,16680.01,0.00,57.5h / 10.0h,12309.26,0.00,46.9h / 8.0h,12047.56,7000.00
2,周周,13.2h / 0.0h,3866.19,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
3,轩哥,6.4h / 0.0h,3741.42,0.00,18.0h / 0.0h,24036.03,0.00,24.6h / 1.0h,17999.86,3000.00
4,大G,9.5h / 0.0h,2623.97,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
5,T,1.9h / 0.0h,2053.02,0.00,5.0h / 0.0h,2490.70,0.00,8.1h / 0.0h,1323.17,3000.00
6,林先生,4.5h / 0.0h,1720.12,0.00,10.4h / 0.0h,3269.81,0.00,0.0h / 0.0h,0.00,0.00
7,,3.2h / 0.0h,1307.16,0.00,10.3h / 0.0h,4754.69,0.00,0.0h / 0.0h,0.00,0.00
8,胡先生,3.0h / 0.0h,522.45,0.00,26.4h / 0.0h,9712.14,13000.00,0.0h / 0.0h,0.00,0.00
9,江先生,0.0h / 0.0h,0.00,0.00,3.8h / 0.0h,1374.85,0.00,0.0h / 0.0h,0.00,0.00
10,陈先生,0.0h / 0.0h,0.00,0.00,7.6h / 0.0h,2566.75,3000.00,0.0h / 0.0h,0.00,0.00
11,陈腾鑫,0.0h / 0.0h,0.00,0.00,19.2h / 0.0h,4276.97,1000.00,38.5h / 0.0h,7626.75,12000.00
12,张先生,0.0h / 0.0h,0.00,0.00,4.9h / 0.0h,2233.65,0.00,0.0h / 0.0h,0.00,0.00
13,歌神,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.0h / 0.0h,361.38,0.00
14,,0.0h / 0.0h,0.00,0.00,2.0h / 0.0h,455.03,0.00,5.8h / 0.0h,2595.54,1000.00
15,小熊,0.0h / 0.0h,0.00,0.00,6.4h / 0.0h,2072.54,3000.00,6.8h / 0.0h,1213.06,1000.00
16,蔡总,0.0h / 0.0h,0.00,0.00,4.5h / 0.0h,9696.89,0.00,0.0h / 0.0h,0.00,0.00
17,吕先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.7h / 0.0h,337.17,0.00
18,贺斌,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.0h / 0.0h,247.34,0.00
19,,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.1h / 0.0h,714.20,0.00
1 助教详情:佳怡(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础425.2h,附加23.0h;客户流水¥156229.68,充值归因¥47000.00;头部客户(12月)Top3:罗先生、周周、轩哥。
3 一、基础课业绩
4 说明:评价:基础425.2h,附加23.0h;客户流水¥156229.68,充值归因¥47000.00;头部客户(12月)Top3:罗先生、周周、轩哥。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,139.55h,1,95.14h,103.02h
8 11月,176.25h,1,121.77h,137.37h
9 12月,109.40h,2,64.59h,68.31h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,9.00h,2,2.43h,1.00h
15 11月,10.00h,3,1.20h,3.00h
16 12月,4.00h,7,-6.27h,-4.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,44466.03,5,15186.50,13816.20
22 11月,79249.31,6,34994.92,45922.99
23 12月,32514.34,6,11783.81,18873.70
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,27000.00,3,12533.33,14000.00
29 11月,20000.00,1,12230.77,11000.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,罗先生,67.8h / 4.0h,16680.01,0.00,57.5h / 10.0h,12309.26,0.00,46.9h / 8.0h,12047.56,7000.00
36 2,周周,13.2h / 0.0h,3866.19,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
37 3,轩哥,6.4h / 0.0h,3741.42,0.00,18.0h / 0.0h,24036.03,0.00,24.6h / 1.0h,17999.86,3000.00
38 4,大G,9.5h / 0.0h,2623.97,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
39 5,T,1.9h / 0.0h,2053.02,0.00,5.0h / 0.0h,2490.70,0.00,8.1h / 0.0h,1323.17,3000.00
40 6,林先生,4.5h / 0.0h,1720.12,0.00,10.4h / 0.0h,3269.81,0.00,0.0h / 0.0h,0.00,0.00
41 7,游,3.2h / 0.0h,1307.16,0.00,10.3h / 0.0h,4754.69,0.00,0.0h / 0.0h,0.00,0.00
42 8,胡先生,3.0h / 0.0h,522.45,0.00,26.4h / 0.0h,9712.14,13000.00,0.0h / 0.0h,0.00,0.00
43 9,江先生,0.0h / 0.0h,0.00,0.00,3.8h / 0.0h,1374.85,0.00,0.0h / 0.0h,0.00,0.00
44 10,陈先生,0.0h / 0.0h,0.00,0.00,7.6h / 0.0h,2566.75,3000.00,0.0h / 0.0h,0.00,0.00
45 11,陈腾鑫,0.0h / 0.0h,0.00,0.00,19.2h / 0.0h,4276.97,1000.00,38.5h / 0.0h,7626.75,12000.00
46 12,张先生,0.0h / 0.0h,0.00,0.00,4.9h / 0.0h,2233.65,0.00,0.0h / 0.0h,0.00,0.00
47 13,歌神,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.0h / 0.0h,361.38,0.00
48 14,夏,0.0h / 0.0h,0.00,0.00,2.0h / 0.0h,455.03,0.00,5.8h / 0.0h,2595.54,1000.00
49 15,小熊,0.0h / 0.0h,0.00,0.00,6.4h / 0.0h,2072.54,3000.00,6.8h / 0.0h,1213.06,1000.00
50 16,蔡总,0.0h / 0.0h,0.00,0.00,4.5h / 0.0h,9696.89,0.00,0.0h / 0.0h,0.00,0.00
51 17,吕先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.7h / 0.0h,337.17,0.00
52 18,贺斌,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.0h / 0.0h,247.34,0.00
53 19,陶,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.1h / 0.0h,714.20,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情佳怡2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础425.2h附加23.0h客户流水¥156229.68充值归因¥47000.00;头部客户(12月)Top3罗先生、周周、轩哥。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,55 +0,0 @@
助教详情千千2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础77.2h附加5.0h客户流水¥34297.90充值归因¥0.00;头部客户(12月)Top3张先生、周先生、陈腾鑫。
一、基础课业绩
说明评价基础77.2h附加5.0h客户流水¥34297.90充值归因¥0.00;头部客户(12月)Top3张先生、周先生、陈腾鑫。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,38.88h,14,-15.59h,0.00h
12月,38.28h,12,-6.53h,-2.81h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,0.00h,,0.00h,0.00h
12月,5.00h,6,-5.27h,-3.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,0.00,,0.00,0.00
11月,24684.71,17,-19569.68,-8641.61
12月,9613.19,16,-11117.34,-4027.46
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,0.00,,0.00,0.00
11月,0.00,,0.00,0.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,张先生,10.0h / 0.0h,2622.05,0.00,4.4h / 0.0h,1623.68,0.00,0.0h / 0.0h,0.00,0.00
2,周先生,8.6h / 0.0h,1577.94,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
3,陈腾鑫,4.8h / 0.0h,1375.20,0.00,2.9h / 0.0h,2418.94,0.00,0.0h / 0.0h,0.00,0.00
4,,3.3h / 5.0h,1356.34,0.00,5.8h / 0.0h,2007.81,0.00,0.0h / 0.0h,0.00,0.00
5,,3.0h / 0.0h,1128.06,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
6,黄先生,6.2h / 0.0h,1048.14,0.00,6.8h / 0.0h,1251.92,0.00,0.0h / 0.0h,0.00,0.00
7,,2.2h / 0.0h,505.46,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
8,葛先生,0.0h / 0.0h,0.00,0.00,14.4h / 0.0h,7500.34,0.00,0.0h / 0.0h,0.00,0.00
9,林先生,0.0h / 0.0h,0.00,0.00,2.7h / 0.0h,499.11,0.00,0.0h / 0.0h,0.00,0.00
10,轩哥,0.0h / 0.0h,0.00,0.00,1.2h / 0.0h,415.60,0.00,0.0h / 0.0h,0.00,0.00
11,蔡总,0.0h / 0.0h,0.00,0.00,0.7h / 0.0h,8967.31,0.00,0.0h / 0.0h,0.00,0.00
1 助教详情:千千(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础77.2h,附加5.0h;客户流水¥34297.90,充值归因¥0.00;头部客户(12月)Top3:张先生、周先生、陈腾鑫。
3 一、基础课业绩
4 说明:评价:基础77.2h,附加5.0h;客户流水¥34297.90,充值归因¥0.00;头部客户(12月)Top3:张先生、周先生、陈腾鑫。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,0.00h,,0.00h,0.00h
8 11月,38.88h,14,-15.59h,0.00h
9 12月,38.28h,12,-6.53h,-2.81h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,0.00h,,0.00h,0.00h
16 12月,5.00h,6,-5.27h,-3.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,0.00,,0.00,0.00
22 11月,24684.71,17,-19569.68,-8641.61
23 12月,9613.19,16,-11117.34,-4027.46
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,0.00,,0.00,0.00
29 11月,0.00,,0.00,0.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,张先生,10.0h / 0.0h,2622.05,0.00,4.4h / 0.0h,1623.68,0.00,0.0h / 0.0h,0.00,0.00
36 2,周先生,8.6h / 0.0h,1577.94,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
37 3,陈腾鑫,4.8h / 0.0h,1375.20,0.00,2.9h / 0.0h,2418.94,0.00,0.0h / 0.0h,0.00,0.00
38 4,梅,3.3h / 5.0h,1356.34,0.00,5.8h / 0.0h,2007.81,0.00,0.0h / 0.0h,0.00,0.00
39 5,清,3.0h / 0.0h,1128.06,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
40 6,黄先生,6.2h / 0.0h,1048.14,0.00,6.8h / 0.0h,1251.92,0.00,0.0h / 0.0h,0.00,0.00
41 7,游,2.2h / 0.0h,505.46,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
42 8,葛先生,0.0h / 0.0h,0.00,0.00,14.4h / 0.0h,7500.34,0.00,0.0h / 0.0h,0.00,0.00
43 9,林先生,0.0h / 0.0h,0.00,0.00,2.7h / 0.0h,499.11,0.00,0.0h / 0.0h,0.00,0.00
44 10,轩哥,0.0h / 0.0h,0.00,0.00,1.2h / 0.0h,415.60,0.00,0.0h / 0.0h,0.00,0.00
45 11,蔡总,0.0h / 0.0h,0.00,0.00,0.7h / 0.0h,8967.31,0.00,0.0h / 0.0h,0.00,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情千千2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础77.2h附加5.0h客户流水¥34297.90充值归因¥0.00;头部客户(12月)Top3张先生、周先生、陈腾鑫。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,66 +0,0 @@
助教详情周周2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础172.6h附加33.0h客户流水¥80429.10充值归因¥20000.00;头部客户(12月)Top3周周、明哥、T。
一、基础课业绩
说明评价基础172.6h附加33.0h客户流水¥80429.10充值归因¥20000.00;头部客户(12月)Top3周周、明哥、T。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,41.33h,9,-3.08h,4.81h
11月,71.27h,10,16.79h,32.38h
12月,60.02h,6,15.21h,18.92h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,25.00h,1,16.20h,18.00h
12月,8.00h,5,-2.27h,0.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,27375.91,11,-1903.62,-3273.92
11月,31436.74,15,-12817.65,-1889.58
12月,21616.45,7,885.92,7975.80
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,11000.00,9,-3466.67,-2000.00
11月,9000.00,4,1230.77,0.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,周周,28.8h / 8.0h,8105.19,0.00,0.0h / 20.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
2,明哥,0.4h / 0.0h,4190.45,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
3,T,10.1h / 0.0h,2968.13,0.00,0.0h / 0.0h,0.00,0.00,4.5h / 0.0h,1300.23,0.00
4,大G,14.8h / 0.0h,2724.15,0.00,2.8h / 0.0h,1783.61,0.00,0.0h / 0.0h,0.00,0.00
5,罗先生,2.6h / 0.0h,1584.22,0.00,9.0h / 0.0h,2415.09,0.00,0.0h / 0.0h,0.00,0.00
6,,2.4h / 0.0h,1307.16,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
7,张先生,0.0h / 0.0h,449.03,0.00,6.3h / 0.0h,2092.46,0.00,4.1h / 0.0h,1650.08,0.00
8,轩哥,0.7h / 0.0h,288.12,0.00,5.0h / 3.0h,2175.94,5000.00,20.2h / 0.0h,16154.38,10000.00
9,江先生,0.0h / 0.0h,0.00,0.00,4.3h / 0.0h,3588.88,0.00,0.0h / 0.0h,0.00,0.00
10,罗超杰,0.0h / 0.0h,0.00,0.00,1.2h / 0.0h,255.63,0.00,0.0h / 0.0h,0.00,0.00
11,陈腾鑫,0.0h / 0.0h,0.00,0.00,4.6h / 0.0h,1210.78,0.00,0.0h / 0.0h,197.60,1000.00
12,林总,0.0h / 0.0h,0.00,0.00,2.2h / 0.0h,439.96,0.00,0.0h / 0.0h,0.00,0.00
13,林先生,0.0h / 0.0h,0.00,0.00,0.7h / 0.0h,747.44,0.00,0.0h / 0.0h,0.00,0.00
14,葛先生,0.0h / 0.0h,0.00,0.00,11.0h / 0.0h,3073.27,0.00,0.0h / 0.0h,0.00,0.00
15,,0.0h / 0.0h,0.00,0.00,1.4h / 0.0h,602.50,0.00,0.0h / 0.0h,0.00,0.00
16,小熊,0.0h / 0.0h,0.00,0.00,10.7h / 0.0h,2612.37,4000.00,0.0h / 0.0h,0.00,0.00
17,陈德韩,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.3h / 0.0h,5714.01,0.00
18,蔡总,0.0h / 0.0h,0.00,0.00,8.2h / 0.0h,9385.22,0.00,0.0h / 0.0h,0.00,0.00
19,万先生,0.0h / 0.0h,0.00,0.00,0.0h / 2.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
20,吕先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.7h / 0.0h,1080.89,0.00
21,林先生,0.0h / 0.0h,0.00,0.00,4.0h / 0.0h,1053.59,0.00,0.0h / 0.0h,0.00,0.00
22,,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.4h / 0.0h,1278.72,0.00
1 助教详情:周周(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础172.6h,附加33.0h;客户流水¥80429.10,充值归因¥20000.00;头部客户(12月)Top3:周周、明哥、T。
3 一、基础课业绩
4 说明:评价:基础172.6h,附加33.0h;客户流水¥80429.10,充值归因¥20000.00;头部客户(12月)Top3:周周、明哥、T。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,41.33h,9,-3.08h,4.81h
8 11月,71.27h,10,16.79h,32.38h
9 12月,60.02h,6,15.21h,18.92h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,25.00h,1,16.20h,18.00h
16 12月,8.00h,5,-2.27h,0.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,27375.91,11,-1903.62,-3273.92
22 11月,31436.74,15,-12817.65,-1889.58
23 12月,21616.45,7,885.92,7975.80
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,11000.00,9,-3466.67,-2000.00
29 11月,9000.00,4,1230.77,0.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,周周,28.8h / 8.0h,8105.19,0.00,0.0h / 20.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
36 2,明哥,0.4h / 0.0h,4190.45,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
37 3,T,10.1h / 0.0h,2968.13,0.00,0.0h / 0.0h,0.00,0.00,4.5h / 0.0h,1300.23,0.00
38 4,大G,14.8h / 0.0h,2724.15,0.00,2.8h / 0.0h,1783.61,0.00,0.0h / 0.0h,0.00,0.00
39 5,罗先生,2.6h / 0.0h,1584.22,0.00,9.0h / 0.0h,2415.09,0.00,0.0h / 0.0h,0.00,0.00
40 6,游,2.4h / 0.0h,1307.16,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
41 7,张先生,0.0h / 0.0h,449.03,0.00,6.3h / 0.0h,2092.46,0.00,4.1h / 0.0h,1650.08,0.00
42 8,轩哥,0.7h / 0.0h,288.12,0.00,5.0h / 3.0h,2175.94,5000.00,20.2h / 0.0h,16154.38,10000.00
43 9,江先生,0.0h / 0.0h,0.00,0.00,4.3h / 0.0h,3588.88,0.00,0.0h / 0.0h,0.00,0.00
44 10,罗超杰,0.0h / 0.0h,0.00,0.00,1.2h / 0.0h,255.63,0.00,0.0h / 0.0h,0.00,0.00
45 11,陈腾鑫,0.0h / 0.0h,0.00,0.00,4.6h / 0.0h,1210.78,0.00,0.0h / 0.0h,197.60,1000.00
46 12,林总,0.0h / 0.0h,0.00,0.00,2.2h / 0.0h,439.96,0.00,0.0h / 0.0h,0.00,0.00
47 13,林先生,0.0h / 0.0h,0.00,0.00,0.7h / 0.0h,747.44,0.00,0.0h / 0.0h,0.00,0.00
48 14,葛先生,0.0h / 0.0h,0.00,0.00,11.0h / 0.0h,3073.27,0.00,0.0h / 0.0h,0.00,0.00
49 15,羊,0.0h / 0.0h,0.00,0.00,1.4h / 0.0h,602.50,0.00,0.0h / 0.0h,0.00,0.00
50 16,小熊,0.0h / 0.0h,0.00,0.00,10.7h / 0.0h,2612.37,4000.00,0.0h / 0.0h,0.00,0.00
51 17,陈德韩,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.3h / 0.0h,5714.01,0.00
52 18,蔡总,0.0h / 0.0h,0.00,0.00,8.2h / 0.0h,9385.22,0.00,0.0h / 0.0h,0.00,0.00
53 19,万先生,0.0h / 0.0h,0.00,0.00,0.0h / 2.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
54 20,吕先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.7h / 0.0h,1080.89,0.00
55 21,林先生,0.0h / 0.0h,0.00,0.00,4.0h / 0.0h,1053.59,0.00,0.0h / 0.0h,0.00,0.00
56 22,陶,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.4h / 0.0h,1278.72,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情周周2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础172.6h附加33.0h客户流水¥80429.10充值归因¥20000.00;头部客户(12月)Top3周周、明哥、T。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,58 +0,0 @@
助教详情奈千2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础59.0h附加0.0h客户流水¥107484.78充值归因¥18000.00;头部客户(12月)Top3轩哥、黎先生、陈先生。
一、基础课业绩
说明评价基础59.0h附加0.0h客户流水¥107484.78充值归因¥18000.00;头部客户(12月)Top3轩哥、黎先生、陈先生。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,23.62h,13,-20.79h,-12.91h
11月,32.83h,19,-21.64h,-6.05h
12月,2.58h,21,-42.23h,-38.51h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,0.00h,,0.00h,0.00h
12月,0.00h,,0.00h,0.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,38653.58,7,9374.05,8003.75
11月,68543.08,7,24288.69,35216.76
12月,288.12,22,-20442.41,-13352.52
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,18000.00,6,3533.33,5000.00
11月,0.00,,0.00,0.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,轩哥,0.7h / 0.0h,288.12,0.00,4.3h / 0.0h,14349.45,0.00,6.2h / 0.0h,22341.76,13000.00
2,黎先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.7h / 0.0h,470.19,0.00
3,陈先生,0.0h / 0.0h,0.00,0.00,5.1h / 0.0h,1150.83,0.00,0.0h / 0.0h,0.00,0.00
4,,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.4h / 0.0h,3620.75,0.00
5,陈腾鑫,0.0h / 0.0h,0.00,0.00,2.6h / 0.0h,441.39,0.00,2.1h / 0.0h,1084.69,1000.00
6,张先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.2h / 0.0h,474.93,0.00
7,,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.0h / 0.0h,2595.54,1000.00
8,罗超,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.5h / 0.0h,1013.51,0.00
9,罗先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,1143.87,3000.00
10,陈德韩,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.4h / 0.0h,5714.01,0.00
11,阿亮,0.0h / 0.0h,0.00,0.00,2.9h / 0.0h,493.02,0.00,0.0h / 0.0h,0.00,0.00
12,曾先生,0.0h / 0.0h,0.00,0.00,1.0h / 0.0h,206.16,0.00,0.0h / 0.0h,0.00,0.00
13,蔡总,1.8h / 0.0h,0.00,0.00,17.0h / 0.0h,51902.23,0.00,0.0h / 0.0h,0.00,0.00
14,T,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.2h / 0.0h,194.33,0.00
1 助教详情:奈千(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础59.0h,附加0.0h;客户流水¥107484.78,充值归因¥18000.00;头部客户(12月)Top3:轩哥、黎先生、陈先生。
3 一、基础课业绩
4 说明:评价:基础59.0h,附加0.0h;客户流水¥107484.78,充值归因¥18000.00;头部客户(12月)Top3:轩哥、黎先生、陈先生。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,23.62h,13,-20.79h,-12.91h
8 11月,32.83h,19,-21.64h,-6.05h
9 12月,2.58h,21,-42.23h,-38.51h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,0.00h,,0.00h,0.00h
16 12月,0.00h,,0.00h,0.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,38653.58,7,9374.05,8003.75
22 11月,68543.08,7,24288.69,35216.76
23 12月,288.12,22,-20442.41,-13352.52
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,18000.00,6,3533.33,5000.00
29 11月,0.00,,0.00,0.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,轩哥,0.7h / 0.0h,288.12,0.00,4.3h / 0.0h,14349.45,0.00,6.2h / 0.0h,22341.76,13000.00
36 2,黎先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.7h / 0.0h,470.19,0.00
37 3,陈先生,0.0h / 0.0h,0.00,0.00,5.1h / 0.0h,1150.83,0.00,0.0h / 0.0h,0.00,0.00
38 4,羊,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.4h / 0.0h,3620.75,0.00
39 5,陈腾鑫,0.0h / 0.0h,0.00,0.00,2.6h / 0.0h,441.39,0.00,2.1h / 0.0h,1084.69,1000.00
40 6,张先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.2h / 0.0h,474.93,0.00
41 7,夏,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.0h / 0.0h,2595.54,1000.00
42 8,罗超,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.5h / 0.0h,1013.51,0.00
43 9,罗先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,1143.87,3000.00
44 10,陈德韩,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.4h / 0.0h,5714.01,0.00
45 11,阿亮,0.0h / 0.0h,0.00,0.00,2.9h / 0.0h,493.02,0.00,0.0h / 0.0h,0.00,0.00
46 12,曾先生,0.0h / 0.0h,0.00,0.00,1.0h / 0.0h,206.16,0.00,0.0h / 0.0h,0.00,0.00
47 13,蔡总,1.8h / 0.0h,0.00,0.00,17.0h / 0.0h,51902.23,0.00,0.0h / 0.0h,0.00,0.00
48 14,T,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.2h / 0.0h,194.33,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情奈千2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础59.0h附加0.0h客户流水¥107484.78充值归因¥18000.00;头部客户(12月)Top3轩哥、黎先生、陈先生。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,46 +0,0 @@
助教详情姜姜2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础6.6h附加3.0h客户流水¥2333.94充值归因¥4000.00;头部客户(12月)Top3罗先生、汪先生。
一、基础课业绩
说明评价基础6.6h附加3.0h客户流水¥2333.94充值归因¥4000.00;头部客户(12月)Top3罗先生、汪先生。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,6.60h,18,-37.81h,-29.93h
11月,0.00h,,0.00h,0.00h
12月,0.00h,,0.00h,0.00h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,3.00h,5,-3.57h,-5.00h
11月,0.00h,,0.00h,0.00h
12月,0.00h,,0.00h,0.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,2333.94,20,-26945.59,-28315.89
11月,0.00,,0.00,0.00
12月,0.00,,0.00,0.00
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,4000.00,12,-10466.67,-9000.00
11月,0.00,,0.00,0.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,罗先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.5h / 0.0h,1143.87,3000.00
2,汪先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,5.1h / 3.0h,1190.07,1000.00
1 助教详情:姜姜(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础6.6h,附加3.0h;客户流水¥2333.94,充值归因¥4000.00;头部客户(12月)Top3:罗先生、汪先生。
3 一、基础课业绩
4 说明:评价:基础6.6h,附加3.0h;客户流水¥2333.94,充值归因¥4000.00;头部客户(12月)Top3:罗先生、汪先生。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,6.60h,18,-37.81h,-29.93h
8 11月,0.00h,,0.00h,0.00h
9 12月,0.00h,,0.00h,0.00h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,3.00h,5,-3.57h,-5.00h
15 11月,0.00h,,0.00h,0.00h
16 12月,0.00h,,0.00h,0.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,2333.94,20,-26945.59,-28315.89
22 11月,0.00,,0.00,0.00
23 12月,0.00,,0.00,0.00
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,4000.00,12,-10466.67,-9000.00
29 11月,0.00,,0.00,0.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,罗先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.5h / 0.0h,1143.87,3000.00
36 2,汪先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,5.1h / 3.0h,1190.07,1000.00

View File

@@ -1,196 +0,0 @@
# 助教详情姜姜2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础6.6h附加3.0h客户流水¥2333.94充值归因¥4000.00;头部客户(12月)Top3罗先生、汪先生。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,65 +0,0 @@
助教详情婉婉2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础154.6h附加34.0h客户流水¥106476.37充值归因¥33000.00;头部客户(12月)Top3江先生、明哥、候。
一、基础课业绩
说明评价基础154.6h附加34.0h客户流水¥106476.37充值归因¥33000.00;头部客户(12月)Top3江先生、明哥、候。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,90.68h,3,46.27h,54.16h
11月,46.03h,12,-8.44h,7.15h
12月,17.83h,17,-26.98h,-23.26h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,4.00h,4,-2.57h,-4.00h
11月,15.00h,2,6.20h,8.00h
12月,15.00h,3,4.73h,7.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,62187.64,2,32908.11,31537.81
11月,33326.32,14,-10928.07,0.00
12月,10962.41,15,-9768.12,-2678.24
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,24000.00,4,9533.33,11000.00
11月,9000.00,4,1230.77,0.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,江先生,4.7h / 0.0h,5889.30,0.00,9.4h / 0.0h,6947.07,5000.00,2.7h / 0.0h,1538.09,0.00
2,明哥,11.7h / 10.0h,4822.90,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
3,,1.1h / 0.0h,195.75,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
4,刘哥,0.3h / 0.0h,54.46,0.00,5.0h / 0.0h,2982.34,0.00,0.0h / 0.0h,0.00,0.00
5,林总,0.0h / 0.0h,0.00,0.00,0.9h / 0.0h,244.48,0.00,0.0h / 0.0h,0.00,0.00
6,,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.3h / 0.0h,3620.75,0.00
7,叶先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.7h / 0.0h,1278.01,0.00
8,邓飛,0.0h / 0.0h,0.00,0.00,0.8h / 0.0h,925.47,1000.00,0.0h / 4.0h,0.00,0.00
9,歌神,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,6.7h / 0.0h,4718.40,0.00
10,,0.0h / 0.0h,0.00,0.00,5.4h / 4.0h,2991.13,0.00,18.2h / 0.0h,11826.32,1000.00
11,轩哥,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,45.2h / 0.0h,33043.15,16000.00
12,罗先生,0.0h / 5.0h,0.00,0.00,7.9h / 0.0h,2086.94,0.00,3.4h / 0.0h,1143.87,3000.00
13,蔡总,0.0h / 0.0h,0.00,0.00,0.0h / 3.0h,6196.43,0.00,0.0h / 0.0h,0.00,0.00
14,吕先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.8h / 0.0h,3924.18,3000.00
15,万先生,0.0h / 0.0h,0.00,0.00,0.0h / 4.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
16,老宋,0.0h / 0.0h,0.00,0.00,1.0h / 0.0h,465.98,0.00,0.0h / 0.0h,0.00,0.00
17,黎先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,0.8h / 0.0h,470.19,0.00
18,君姐,0.0h / 0.0h,0.00,0.00,4.2h / 0.0h,1864.86,0.00,0.0h / 0.0h,0.00,0.00
19,林先生,0.0h / 0.0h,0.00,0.00,6.0h / 4.0h,2690.52,0.00,0.0h / 0.0h,0.00,0.00
20,婉婉,0.0h / 0.0h,0.00,0.00,1.6h / 0.0h,242.81,0.00,2.8h / 0.0h,624.68,1000.00
21,胡先生,0.0h / 0.0h,0.00,0.00,3.8h / 0.0h,5688.29,3000.00,0.0h / 0.0h,0.00,0.00
1 助教详情:婉婉(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础154.6h,附加34.0h;客户流水¥106476.37,充值归因¥33000.00;头部客户(12月)Top3:江先生、明哥、候。
3 一、基础课业绩
4 说明:评价:基础154.6h,附加34.0h;客户流水¥106476.37,充值归因¥33000.00;头部客户(12月)Top3:江先生、明哥、候。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,90.68h,3,46.27h,54.16h
8 11月,46.03h,12,-8.44h,7.15h
9 12月,17.83h,17,-26.98h,-23.26h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,4.00h,4,-2.57h,-4.00h
15 11月,15.00h,2,6.20h,8.00h
16 12月,15.00h,3,4.73h,7.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,62187.64,2,32908.11,31537.81
22 11月,33326.32,14,-10928.07,0.00
23 12月,10962.41,15,-9768.12,-2678.24
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,24000.00,4,9533.33,11000.00
29 11月,9000.00,4,1230.77,0.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,江先生,4.7h / 0.0h,5889.30,0.00,9.4h / 0.0h,6947.07,5000.00,2.7h / 0.0h,1538.09,0.00
36 2,明哥,11.7h / 10.0h,4822.90,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
37 3,候,1.1h / 0.0h,195.75,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
38 4,刘哥,0.3h / 0.0h,54.46,0.00,5.0h / 0.0h,2982.34,0.00,0.0h / 0.0h,0.00,0.00
39 5,林总,0.0h / 0.0h,0.00,0.00,0.9h / 0.0h,244.48,0.00,0.0h / 0.0h,0.00,0.00
40 6,羊,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.3h / 0.0h,3620.75,0.00
41 7,叶先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.7h / 0.0h,1278.01,0.00
42 8,邓飛,0.0h / 0.0h,0.00,0.00,0.8h / 0.0h,925.47,1000.00,0.0h / 4.0h,0.00,0.00
43 9,歌神,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,6.7h / 0.0h,4718.40,0.00
44 10,夏,0.0h / 0.0h,0.00,0.00,5.4h / 4.0h,2991.13,0.00,18.2h / 0.0h,11826.32,1000.00
45 11,轩哥,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,45.2h / 0.0h,33043.15,16000.00
46 12,罗先生,0.0h / 5.0h,0.00,0.00,7.9h / 0.0h,2086.94,0.00,3.4h / 0.0h,1143.87,3000.00
47 13,蔡总,0.0h / 0.0h,0.00,0.00,0.0h / 3.0h,6196.43,0.00,0.0h / 0.0h,0.00,0.00
48 14,吕先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.8h / 0.0h,3924.18,3000.00
49 15,万先生,0.0h / 0.0h,0.00,0.00,0.0h / 4.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
50 16,老宋,0.0h / 0.0h,0.00,0.00,1.0h / 0.0h,465.98,0.00,0.0h / 0.0h,0.00,0.00
51 17,黎先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,0.8h / 0.0h,470.19,0.00
52 18,君姐,0.0h / 0.0h,0.00,0.00,4.2h / 0.0h,1864.86,0.00,0.0h / 0.0h,0.00,0.00
53 19,林先生,0.0h / 0.0h,0.00,0.00,6.0h / 4.0h,2690.52,0.00,0.0h / 0.0h,0.00,0.00
54 20,婉婉,0.0h / 0.0h,0.00,0.00,1.6h / 0.0h,242.81,0.00,2.8h / 0.0h,624.68,1000.00
55 21,胡先生,0.0h / 0.0h,0.00,0.00,3.8h / 0.0h,5688.29,3000.00,0.0h / 0.0h,0.00,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情婉婉2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础154.6h附加34.0h客户流水¥106476.37充值归因¥33000.00;头部客户(12月)Top3江先生、明哥、候。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,57 +0,0 @@
助教详情小侯2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础92.2h附加0.0h客户流水¥41280.98充值归因¥0.00;头部客户(12月)Top3张先生、陈腾鑫、李先生。
一、基础课业绩
说明评价基础92.2h附加0.0h客户流水¥41280.98充值归因¥0.00;头部客户(12月)Top3张先生、陈腾鑫、李先生。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,42.58h,13,-11.89h,3.70h
12月,49.57h,8,4.76h,8.47h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,0.00h,,0.00h,0.00h
12月,0.00h,,0.00h,0.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,0.00,,0.00,0.00
11月,27313.21,16,-16941.18,-6013.11
12月,13967.77,11,-6762.76,327.12
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,0.00,,0.00,0.00
11月,0.00,,0.00,0.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,张先生,14.4h / 0.0h,4161.57,0.00,5.8h / 0.0h,1583.86,0.00,0.0h / 0.0h,0.00,0.00
2,陈腾鑫,12.1h / 0.0h,3984.45,0.00,7.0h / 0.0h,2965.62,0.00,0.0h / 0.0h,0.00,0.00
3,李先生,9.3h / 0.0h,1729.57,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
4,,3.3h / 0.0h,1356.34,0.00,1.4h / 0.0h,1573.10,0.00,0.0h / 0.0h,0.00,0.00
5,,3.0h / 0.0h,1128.06,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
6,T,3.9h / 0.0h,938.16,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
7,,3.4h / 0.0h,669.62,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
8,林志铭,0.0h / 0.0h,0.00,0.00,1.2h / 0.0h,220.15,0.00,0.0h / 0.0h,0.00,0.00
9,林先生,0.0h / 0.0h,0.00,0.00,9.7h / 0.0h,3619.37,0.00,0.0h / 0.0h,0.00,0.00
10,艾宇民,0.0h / 0.0h,0.00,0.00,7.6h / 0.0h,3872.24,0.00,0.0h / 0.0h,0.00,0.00
11,蔡总,0.0h / 0.0h,0.00,0.00,2.6h / 0.0h,10419.30,0.00,0.0h / 0.0h,0.00,0.00
12,钟智豪,0.0h / 0.0h,0.00,0.00,1.8h / 0.0h,274.34,0.00,0.0h / 0.0h,0.00,0.00
13,李先生,0.0h / 0.0h,0.00,0.00,5.6h / 0.0h,2785.23,0.00,0.0h / 0.0h,0.00,0.00
1 助教详情:小侯(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础92.2h,附加0.0h;客户流水¥41280.98,充值归因¥0.00;头部客户(12月)Top3:张先生、陈腾鑫、李先生。
3 一、基础课业绩
4 说明:评价:基础92.2h,附加0.0h;客户流水¥41280.98,充值归因¥0.00;头部客户(12月)Top3:张先生、陈腾鑫、李先生。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,0.00h,,0.00h,0.00h
8 11月,42.58h,13,-11.89h,3.70h
9 12月,49.57h,8,4.76h,8.47h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,0.00h,,0.00h,0.00h
16 12月,0.00h,,0.00h,0.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,0.00,,0.00,0.00
22 11月,27313.21,16,-16941.18,-6013.11
23 12月,13967.77,11,-6762.76,327.12
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,0.00,,0.00,0.00
29 11月,0.00,,0.00,0.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,张先生,14.4h / 0.0h,4161.57,0.00,5.8h / 0.0h,1583.86,0.00,0.0h / 0.0h,0.00,0.00
36 2,陈腾鑫,12.1h / 0.0h,3984.45,0.00,7.0h / 0.0h,2965.62,0.00,0.0h / 0.0h,0.00,0.00
37 3,李先生,9.3h / 0.0h,1729.57,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
38 4,梅,3.3h / 0.0h,1356.34,0.00,1.4h / 0.0h,1573.10,0.00,0.0h / 0.0h,0.00,0.00
39 5,清,3.0h / 0.0h,1128.06,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
40 6,T,3.9h / 0.0h,938.16,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
41 7,候,3.4h / 0.0h,669.62,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
42 8,林志铭,0.0h / 0.0h,0.00,0.00,1.2h / 0.0h,220.15,0.00,0.0h / 0.0h,0.00,0.00
43 9,林先生,0.0h / 0.0h,0.00,0.00,9.7h / 0.0h,3619.37,0.00,0.0h / 0.0h,0.00,0.00
44 10,艾宇民,0.0h / 0.0h,0.00,0.00,7.6h / 0.0h,3872.24,0.00,0.0h / 0.0h,0.00,0.00
45 11,蔡总,0.0h / 0.0h,0.00,0.00,2.6h / 0.0h,10419.30,0.00,0.0h / 0.0h,0.00,0.00
46 12,钟智豪,0.0h / 0.0h,0.00,0.00,1.8h / 0.0h,274.34,0.00,0.0h / 0.0h,0.00,0.00
47 13,李先生,0.0h / 0.0h,0.00,0.00,5.6h / 0.0h,2785.23,0.00,0.0h / 0.0h,0.00,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情小侯2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础92.2h附加0.0h客户流水¥41280.98充值归因¥0.00;头部客户(12月)Top3张先生、陈腾鑫、李先生。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,55 +0,0 @@
助教详情小敌2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础135.1h附加3.0h客户流水¥93760.82充值归因¥29000.00;头部客户(12月)Top3郑先生、张先生、轩哥。
一、基础课业绩
说明评价基础135.1h附加3.0h客户流水¥93760.82充值归因¥29000.00;头部客户(12月)Top3郑先生、张先生、轩哥。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,55.82h,7,11.41h,19.29h
11月,72.90h,9,18.42h,34.02h
12月,6.40h,20,-38.41h,-34.69h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,3.00h,5,-3.57h,-5.00h
11月,0.00h,,0.00h,0.00h
12月,0.00h,,0.00h,0.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,44510.29,4,15230.76,13860.46
11月,47986.57,9,3732.18,14660.25
12月,1263.96,20,-19466.57,-12376.68
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,21000.00,5,6533.33,8000.00
11月,8000.00,5,230.77,-1000.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,郑先生,4.9h / 0.0h,814.93,0.00,27.3h / 0.0h,4745.90,0.00,0.0h / 0.0h,0.00,0.00
2,张先生,1.5h / 0.0h,449.03,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
3,轩哥,0.0h / 0.0h,0.00,0.00,11.2h / 0.0h,15962.93,0.00,43.1h / 0.0h,32148.10,21000.00
4,,0.0h / 0.0h,0.00,0.00,3.6h / 0.0h,3791.20,0.00,0.0h / 0.0h,0.00,0.00
5,叶先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.1h / 0.0h,3922.17,0.00
6,李先生,0.0h / 0.0h,0.00,0.00,11.8h / 0.0h,2997.53,3000.00,0.0h / 0.0h,0.00,0.00
7,周先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,6.6h / 0.0h,2726.01,0.00
8,陈德韩,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.0h / 0.0h,5714.01,0.00
9,蔡总,0.0h / 0.0h,0.00,0.00,17.2h / 0.0h,19881.95,5000.00,0.0h / 0.0h,0.00,0.00
10,林先生,0.0h / 0.0h,0.00,0.00,1.9h / 0.0h,607.06,0.00,0.0h / 0.0h,0.00,0.00
11,邓飛,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 3.0h,0.00,0.00
1 助教详情:小敌(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础135.1h,附加3.0h;客户流水¥93760.82,充值归因¥29000.00;头部客户(12月)Top3:郑先生、张先生、轩哥。
3 一、基础课业绩
4 说明:评价:基础135.1h,附加3.0h;客户流水¥93760.82,充值归因¥29000.00;头部客户(12月)Top3:郑先生、张先生、轩哥。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,55.82h,7,11.41h,19.29h
8 11月,72.90h,9,18.42h,34.02h
9 12月,6.40h,20,-38.41h,-34.69h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,3.00h,5,-3.57h,-5.00h
15 11月,0.00h,,0.00h,0.00h
16 12月,0.00h,,0.00h,0.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,44510.29,4,15230.76,13860.46
22 11月,47986.57,9,3732.18,14660.25
23 12月,1263.96,20,-19466.57,-12376.68
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,21000.00,5,6533.33,8000.00
29 11月,8000.00,5,230.77,-1000.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,郑先生,4.9h / 0.0h,814.93,0.00,27.3h / 0.0h,4745.90,0.00,0.0h / 0.0h,0.00,0.00
36 2,张先生,1.5h / 0.0h,449.03,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
37 3,轩哥,0.0h / 0.0h,0.00,0.00,11.2h / 0.0h,15962.93,0.00,43.1h / 0.0h,32148.10,21000.00
38 4,游,0.0h / 0.0h,0.00,0.00,3.6h / 0.0h,3791.20,0.00,0.0h / 0.0h,0.00,0.00
39 5,叶先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.1h / 0.0h,3922.17,0.00
40 6,李先生,0.0h / 0.0h,0.00,0.00,11.8h / 0.0h,2997.53,3000.00,0.0h / 0.0h,0.00,0.00
41 7,周先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,6.6h / 0.0h,2726.01,0.00
42 8,陈德韩,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.0h / 0.0h,5714.01,0.00
43 9,蔡总,0.0h / 0.0h,0.00,0.00,17.2h / 0.0h,19881.95,5000.00,0.0h / 0.0h,0.00,0.00
44 10,林先生,0.0h / 0.0h,0.00,0.00,1.9h / 0.0h,607.06,0.00,0.0h / 0.0h,0.00,0.00
45 11,邓飛,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 3.0h,0.00,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情小敌2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础135.1h附加3.0h客户流水¥93760.82充值归因¥29000.00;头部客户(12月)Top3郑先生、张先生、轩哥。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,66 +0,0 @@
助教详情小柔2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础207.4h附加22.0h客户流水¥209918.77充值归因¥42700.00;头部客户(12月)Top3蔡总、轩哥、明哥。
一、基础课业绩
说明评价基础207.4h附加22.0h客户流水¥209918.77充值归因¥42700.00;头部客户(12月)Top3蔡总、轩哥、明哥。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,63.87h,5,19.46h,27.34h
11月,88.65h,6,34.17h,49.77h
12月,54.93h,7,10.12h,13.84h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,7.00h,4,-1.80h,0.00h
12月,15.00h,3,4.73h,7.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,52623.85,3,23344.32,21974.02
11月,110137.94,3,65883.55,76811.62
12月,47156.98,3,26426.45,33516.34
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,31700.00,2,17233.33,18700.00
11月,11000.00,2,3230.77,2000.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,蔡总,30.2h / 0.0h,25658.77,0.00,62.2h / 3.0h,88451.79,5000.00,0.0h / 0.0h,0.00,0.00
2,轩哥,8.4h / 0.0h,13202.16,0.00,2.0h / 0.0h,4130.37,0.00,35.2h / 0.0h,33211.31,23000.00
3,明哥,7.7h / 12.0h,4190.45,0.00,5.8h / 0.0h,2258.14,0.00,0.0h / 0.0h,0.00,0.00
4,江先生,3.2h / 0.0h,3042.99,0.00,6.1h / 0.0h,7578.00,5000.00,2.7h / 0.0h,1538.09,0.00
5,T,2.0h / 0.0h,434.21,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
6,昌哥,1.8h / 0.0h,318.40,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
7,陈腾鑫,1.6h / 0.0h,310.00,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
8,罗先生,0.0h / 0.0h,0.00,0.00,4.1h / 0.0h,722.25,0.00,0.0h / 0.0h,0.00,0.00
9,邓飛,0.0h / 0.0h,0.00,0.00,1.2h / 0.0h,925.47,1000.00,0.0h / 0.0h,0.00,0.00
10,吴生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.8h / 0.0h,685.89,0.00
11,歌神,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.8h / 0.0h,2789.21,0.00
12,,0.0h / 0.0h,0.00,0.00,1.6h / 0.0h,383.40,0.00,0.0h / 0.0h,0.00,0.00
13,张先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.3h / 0.0h,568.87,0.00
14,,0.0h / 0.0h,0.00,0.00,2.2h / 0.0h,935.84,0.00,0.0h / 0.0h,0.00,0.00
15,陈德韩,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.0h / 0.0h,5714.01,0.00
16,吕先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,7.5h / 0.0h,2750.70,3000.00
17,罗先生,0.0h / 3.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
18,万先生,0.0h / 0.0h,0.00,0.00,0.0h / 4.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
19,林先生,0.0h / 0.0h,0.00,0.00,3.2h / 0.0h,2398.29,0.00,0.0h / 0.0h,0.00,0.00
20,,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.7h / 0.0h,362.17,0.00
21,叶总,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.8h / 0.0h,5003.60,5700.00
22,胡先生,0.0h / 0.0h,0.00,0.00,0.1h / 0.0h,2354.39,0.00,0.0h / 0.0h,0.00,0.00
1 助教详情:小柔(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础207.4h,附加22.0h;客户流水¥209918.77,充值归因¥42700.00;头部客户(12月)Top3:蔡总、轩哥、明哥。
3 一、基础课业绩
4 说明:评价:基础207.4h,附加22.0h;客户流水¥209918.77,充值归因¥42700.00;头部客户(12月)Top3:蔡总、轩哥、明哥。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,63.87h,5,19.46h,27.34h
8 11月,88.65h,6,34.17h,49.77h
9 12月,54.93h,7,10.12h,13.84h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,7.00h,4,-1.80h,0.00h
16 12月,15.00h,3,4.73h,7.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,52623.85,3,23344.32,21974.02
22 11月,110137.94,3,65883.55,76811.62
23 12月,47156.98,3,26426.45,33516.34
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,31700.00,2,17233.33,18700.00
29 11月,11000.00,2,3230.77,2000.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,蔡总,30.2h / 0.0h,25658.77,0.00,62.2h / 3.0h,88451.79,5000.00,0.0h / 0.0h,0.00,0.00
36 2,轩哥,8.4h / 0.0h,13202.16,0.00,2.0h / 0.0h,4130.37,0.00,35.2h / 0.0h,33211.31,23000.00
37 3,明哥,7.7h / 12.0h,4190.45,0.00,5.8h / 0.0h,2258.14,0.00,0.0h / 0.0h,0.00,0.00
38 4,江先生,3.2h / 0.0h,3042.99,0.00,6.1h / 0.0h,7578.00,5000.00,2.7h / 0.0h,1538.09,0.00
39 5,T,2.0h / 0.0h,434.21,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
40 6,昌哥,1.8h / 0.0h,318.40,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
41 7,陈腾鑫,1.6h / 0.0h,310.00,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
42 8,罗先生,0.0h / 0.0h,0.00,0.00,4.1h / 0.0h,722.25,0.00,0.0h / 0.0h,0.00,0.00
43 9,邓飛,0.0h / 0.0h,0.00,0.00,1.2h / 0.0h,925.47,1000.00,0.0h / 0.0h,0.00,0.00
44 10,吴生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.8h / 0.0h,685.89,0.00
45 11,歌神,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.8h / 0.0h,2789.21,0.00
46 12,羊,0.0h / 0.0h,0.00,0.00,1.6h / 0.0h,383.40,0.00,0.0h / 0.0h,0.00,0.00
47 13,张先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.3h / 0.0h,568.87,0.00
48 14,游,0.0h / 0.0h,0.00,0.00,2.2h / 0.0h,935.84,0.00,0.0h / 0.0h,0.00,0.00
49 15,陈德韩,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.0h / 0.0h,5714.01,0.00
50 16,吕先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,7.5h / 0.0h,2750.70,3000.00
51 17,罗先生,0.0h / 3.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
52 18,万先生,0.0h / 0.0h,0.00,0.00,0.0h / 4.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
53 19,林先生,0.0h / 0.0h,0.00,0.00,3.2h / 0.0h,2398.29,0.00,0.0h / 0.0h,0.00,0.00
54 20,陶,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.7h / 0.0h,362.17,0.00
55 21,叶总,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,3.8h / 0.0h,5003.60,5700.00
56 22,胡先生,0.0h / 0.0h,0.00,0.00,0.1h / 0.0h,2354.39,0.00,0.0h / 0.0h,0.00,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情小柔2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础207.4h附加22.0h客户流水¥209918.77充值归因¥42700.00;头部客户(12月)Top3蔡总、轩哥、明哥。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,44 +0,0 @@
助教详情小柳2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础0.0h附加0.0h客户流水¥0.00充值归因¥0.00;头部客户(12月)Top3无。
一、基础课业绩
说明评价基础0.0h附加0.0h客户流水¥0.00充值归因¥0.00;头部客户(12月)Top3无。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,0.00h,,0.00h,0.00h
12月,0.00h,,0.00h,0.00h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,0.00h,,0.00h,0.00h
12月,0.00h,,0.00h,0.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,0.00,,0.00,0.00
11月,0.00,,0.00,0.00
12月,0.00,,0.00,0.00
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,0.00,,0.00,0.00
11月,0.00,,0.00,0.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1 助教详情:小柳(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础0.0h,附加0.0h;客户流水¥0.00,充值归因¥0.00;头部客户(12月)Top3:无。
3 一、基础课业绩
4 说明:评价:基础0.0h,附加0.0h;客户流水¥0.00,充值归因¥0.00;头部客户(12月)Top3:无。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,0.00h,,0.00h,0.00h
8 11月,0.00h,,0.00h,0.00h
9 12月,0.00h,,0.00h,0.00h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,0.00h,,0.00h,0.00h
16 12月,0.00h,,0.00h,0.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,0.00,,0.00,0.00
22 11月,0.00,,0.00,0.00
23 12月,0.00,,0.00,0.00
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,0.00,,0.00,0.00
29 11月,0.00,,0.00,0.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)

View File

@@ -1,196 +0,0 @@
# 助教详情小柳2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础0.0h附加0.0h客户流水¥0.00充值归因¥0.00;头部客户(12月)Top3无。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,48 +0,0 @@
助教详情小燕2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础268.3h附加23.0h客户流水¥77172.28充值归因¥0.00;头部客户(12月)Top3葛先生、小燕、梅。
一、基础课业绩
说明评价基础268.3h附加23.0h客户流水¥77172.28充值归因¥0.00;头部客户(12月)Top3葛先生、小燕、梅。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,109.28h,3,54.81h,70.40h
12月,159.02h,1,114.21h,117.92h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,2.00h,6,-6.80h,-5.00h
12月,21.00h,2,10.73h,13.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,0.00,,0.00,0.00
11月,39426.42,12,-4827.97,6100.10
12月,37745.86,5,17015.33,24105.22
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,0.00,,0.00,0.00
11月,0.00,,0.00,0.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,葛先生,80.8h / 16.0h,22323.38,0.00,53.5h / 0.0h,17941.19,0.00,0.0h / 0.0h,0.00,0.00
2,小燕,78.2h / 5.0h,15422.48,0.00,51.4h / 2.0h,10944.82,0.00,0.0h / 0.0h,0.00,0.00
3,,0.0h / 0.0h,0.00,0.00,3.8h / 0.0h,1573.10,0.00,0.0h / 0.0h,0.00,0.00
4,蔡总,0.0h / 0.0h,0.00,0.00,0.7h / 0.0h,8967.31,0.00,0.0h / 0.0h,0.00,0.00
1 助教详情:小燕(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础268.3h,附加23.0h;客户流水¥77172.28,充值归因¥0.00;头部客户(12月)Top3:葛先生、小燕、梅。
3 一、基础课业绩
4 说明:评价:基础268.3h,附加23.0h;客户流水¥77172.28,充值归因¥0.00;头部客户(12月)Top3:葛先生、小燕、梅。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,0.00h,,0.00h,0.00h
8 11月,109.28h,3,54.81h,70.40h
9 12月,159.02h,1,114.21h,117.92h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,2.00h,6,-6.80h,-5.00h
16 12月,21.00h,2,10.73h,13.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,0.00,,0.00,0.00
22 11月,39426.42,12,-4827.97,6100.10
23 12月,37745.86,5,17015.33,24105.22
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,0.00,,0.00,0.00
29 11月,0.00,,0.00,0.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,葛先生,80.8h / 16.0h,22323.38,0.00,53.5h / 0.0h,17941.19,0.00,0.0h / 0.0h,0.00,0.00
36 2,小燕,78.2h / 5.0h,15422.48,0.00,51.4h / 2.0h,10944.82,0.00,0.0h / 0.0h,0.00,0.00
37 3,梅,0.0h / 0.0h,0.00,0.00,3.8h / 0.0h,1573.10,0.00,0.0h / 0.0h,0.00,0.00
38 4,蔡总,0.0h / 0.0h,0.00,0.00,0.7h / 0.0h,8967.31,0.00,0.0h / 0.0h,0.00,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情小燕2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础268.3h附加23.0h客户流水¥77172.28充值归因¥0.00;头部客户(12月)Top3葛先生、小燕、梅。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,47 +0,0 @@
助教详情希希2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础6.6h附加0.0h客户流水¥3367.56充值归因¥0.00;头部客户(12月)Top3陈腾鑫、歌神、郭先生。
一、基础课业绩
说明评价基础6.6h附加0.0h客户流水¥3367.56充值归因¥0.00;头部客户(12月)Top3陈腾鑫、歌神、郭先生。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,5.02h,19,-39.39h,-31.51h
11月,1.58h,27,-52.89h,-37.30h
12月,0.00h,,0.00h,0.00h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,0.00h,,0.00h,0.00h
12月,0.00h,,0.00h,0.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,3086.34,18,-26193.19,-27563.49
11月,281.22,27,-43973.17,-33045.10
12月,0.00,,0.00,0.00
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,0.00,,0.00,0.00
11月,0.00,,0.00,0.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,陈腾鑫,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.0h / 0.0h,359.28,0.00
2,歌神,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.0h / 0.0h,2727.06,0.00
3,郭先生,0.0h / 0.0h,0.00,0.00,1.6h / 0.0h,281.22,0.00,0.0h / 0.0h,0.00,0.00
1 助教详情:希希(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础6.6h,附加0.0h;客户流水¥3367.56,充值归因¥0.00;头部客户(12月)Top3:陈腾鑫、歌神、郭先生。
3 一、基础课业绩
4 说明:评价:基础6.6h,附加0.0h;客户流水¥3367.56,充值归因¥0.00;头部客户(12月)Top3:陈腾鑫、歌神、郭先生。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,5.02h,19,-39.39h,-31.51h
8 11月,1.58h,27,-52.89h,-37.30h
9 12月,0.00h,,0.00h,0.00h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,0.00h,,0.00h,0.00h
16 12月,0.00h,,0.00h,0.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,3086.34,18,-26193.19,-27563.49
22 11月,281.22,27,-43973.17,-33045.10
23 12月,0.00,,0.00,0.00
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,0.00,,0.00,0.00
29 11月,0.00,,0.00,0.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,陈腾鑫,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.0h / 0.0h,359.28,0.00
36 2,歌神,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.0h / 0.0h,2727.06,0.00
37 3,郭先生,0.0h / 0.0h,0.00,0.00,1.6h / 0.0h,281.22,0.00,0.0h / 0.0h,0.00,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情希希2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础6.6h附加0.0h客户流水¥3367.56充值归因¥0.00;头部客户(12月)Top3陈腾鑫、歌神、郭先生。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,63 +0,0 @@
助教详情年糕2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础82.6h附加7.0h客户流水¥59830.16充值归因¥9000.00;头部客户(12月)Top3葛先生、明哥、蔡总。
一、基础课业绩
说明评价基础82.6h附加7.0h客户流水¥59830.16充值归因¥9000.00;头部客户(12月)Top3葛先生、明哥、蔡总。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,21.23h,14,-23.18h,-15.29h
11月,35.80h,15,-18.68h,-3.08h
12月,25.62h,14,-19.19h,-15.48h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,7.00h,4,-1.80h,0.00h
12月,0.00h,,0.00h,0.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,26289.89,12,-2989.64,-4359.94
11月,15696.08,20,-28558.31,-17630.24
12月,17844.19,9,-2886.34,4203.54
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,9000.00,10,-5466.67,-4000.00
11月,0.00,,0.00,0.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,葛先生,2.6h / 0.0h,5551.79,0.00,6.7h / 0.0h,3777.09,0.00,0.0h / 0.0h,0.00,0.00
2,明哥,4.6h / 0.0h,4190.45,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
3,蔡总,6.0h / 0.0h,2130.39,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
4,叶先生,2.6h / 0.0h,1558.40,0.00,1.8h / 0.0h,711.79,0.00,5.3h / 0.0h,3607.02,3000.00
5,君姐,2.2h / 0.0h,1414.23,0.00,6.0h / 0.0h,1864.86,0.00,0.0h / 0.0h,0.00,0.00
6,林先生,0.9h / 0.0h,1369.51,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
7,张先生,2.5h / 0.0h,540.07,0.00,4.2h / 0.0h,1007.52,0.00,2.1h / 0.0h,596.24,0.00
8,潘先生,2.0h / 0.0h,516.93,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
9,常总,1.7h / 0.0h,460.52,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
10,小燕,0.5h / 0.0h,111.90,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
11,谢俊,0.0h / 0.0h,0.00,0.00,4.5h / 0.0h,794.53,0.00,0.0h / 0.0h,0.00,0.00
12,歌神,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.6h / 0.0h,1929.19,0.00
13,,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.2h / 0.0h,4670.88,0.00
14,轩哥,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,7.2h / 0.0h,12643.27,3000.00
15,罗先生,0.0h / 0.0h,0.00,0.00,7.6h / 0.0h,2400.67,0.00,0.0h / 0.0h,0.00,0.00
16,吕先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.8h / 0.0h,2843.29,3000.00
17,万先生,0.0h / 0.0h,0.00,0.00,0.0h / 7.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
18,胡先生,0.0h / 0.0h,0.00,0.00,0.8h / 0.0h,2354.39,0.00,0.0h / 0.0h,0.00,0.00
19,李先生,0.0h / 0.0h,0.00,0.00,4.2h / 0.0h,2785.23,0.00,0.0h / 0.0h,0.00,0.00
1 助教详情:年糕(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础82.6h,附加7.0h;客户流水¥59830.16,充值归因¥9000.00;头部客户(12月)Top3:葛先生、明哥、蔡总。
3 一、基础课业绩
4 说明:评价:基础82.6h,附加7.0h;客户流水¥59830.16,充值归因¥9000.00;头部客户(12月)Top3:葛先生、明哥、蔡总。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,21.23h,14,-23.18h,-15.29h
8 11月,35.80h,15,-18.68h,-3.08h
9 12月,25.62h,14,-19.19h,-15.48h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,7.00h,4,-1.80h,0.00h
16 12月,0.00h,,0.00h,0.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,26289.89,12,-2989.64,-4359.94
22 11月,15696.08,20,-28558.31,-17630.24
23 12月,17844.19,9,-2886.34,4203.54
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,9000.00,10,-5466.67,-4000.00
29 11月,0.00,,0.00,0.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,葛先生,2.6h / 0.0h,5551.79,0.00,6.7h / 0.0h,3777.09,0.00,0.0h / 0.0h,0.00,0.00
36 2,明哥,4.6h / 0.0h,4190.45,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
37 3,蔡总,6.0h / 0.0h,2130.39,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
38 4,叶先生,2.6h / 0.0h,1558.40,0.00,1.8h / 0.0h,711.79,0.00,5.3h / 0.0h,3607.02,3000.00
39 5,君姐,2.2h / 0.0h,1414.23,0.00,6.0h / 0.0h,1864.86,0.00,0.0h / 0.0h,0.00,0.00
40 6,林先生,0.9h / 0.0h,1369.51,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
41 7,张先生,2.5h / 0.0h,540.07,0.00,4.2h / 0.0h,1007.52,0.00,2.1h / 0.0h,596.24,0.00
42 8,潘先生,2.0h / 0.0h,516.93,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
43 9,常总,1.7h / 0.0h,460.52,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
44 10,小燕,0.5h / 0.0h,111.90,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
45 11,谢俊,0.0h / 0.0h,0.00,0.00,4.5h / 0.0h,794.53,0.00,0.0h / 0.0h,0.00,0.00
46 12,歌神,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.6h / 0.0h,1929.19,0.00
47 13,夏,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.2h / 0.0h,4670.88,0.00
48 14,轩哥,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,7.2h / 0.0h,12643.27,3000.00
49 15,罗先生,0.0h / 0.0h,0.00,0.00,7.6h / 0.0h,2400.67,0.00,0.0h / 0.0h,0.00,0.00
50 16,吕先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.8h / 0.0h,2843.29,3000.00
51 17,万先生,0.0h / 0.0h,0.00,0.00,0.0h / 7.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
52 18,胡先生,0.0h / 0.0h,0.00,0.00,0.8h / 0.0h,2354.39,0.00,0.0h / 0.0h,0.00,0.00
53 19,李先生,0.0h / 0.0h,0.00,0.00,4.2h / 0.0h,2785.23,0.00,0.0h / 0.0h,0.00,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情年糕2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础82.6h附加7.0h客户流水¥59830.16充值归因¥9000.00;头部客户(12月)Top3葛先生、明哥、蔡总。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,46 +0,0 @@
助教详情悦悦2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础2.3h附加0.0h客户流水¥2970.96充值归因¥3000.00;头部客户(12月)Top3小宇、轩哥。
一、基础课业绩
说明评价基础2.3h附加0.0h客户流水¥2970.96充值归因¥3000.00;头部客户(12月)Top3小宇、轩哥。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,2.30h,20,-42.11h,-34.23h
11月,0.00h,,0.00h,0.00h
12月,0.00h,,0.00h,0.00h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,0.00h,,0.00h,0.00h
12月,0.00h,,0.00h,0.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,2970.96,19,-26308.57,-27678.87
11月,0.00,,0.00,0.00
12月,0.00,,0.00,0.00
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,3000.00,13,-11466.67,-10000.00
11月,0.00,,0.00,0.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,小宇,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,0.4h / 0.0h,78.52,0.00
2,轩哥,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.9h / 0.0h,2892.44,3000.00
1 助教详情:悦悦(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础2.3h,附加0.0h;客户流水¥2970.96,充值归因¥3000.00;头部客户(12月)Top3:小宇、轩哥。
3 一、基础课业绩
4 说明:评价:基础2.3h,附加0.0h;客户流水¥2970.96,充值归因¥3000.00;头部客户(12月)Top3:小宇、轩哥。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,2.30h,20,-42.11h,-34.23h
8 11月,0.00h,,0.00h,0.00h
9 12月,0.00h,,0.00h,0.00h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,0.00h,,0.00h,0.00h
16 12月,0.00h,,0.00h,0.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,2970.96,19,-26308.57,-27678.87
22 11月,0.00,,0.00,0.00
23 12月,0.00,,0.00,0.00
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,3000.00,13,-11466.67,-10000.00
29 11月,0.00,,0.00,0.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,小宇,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,0.4h / 0.0h,78.52,0.00
36 2,轩哥,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.9h / 0.0h,2892.44,3000.00

View File

@@ -1,196 +0,0 @@
# 助教详情悦悦2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础2.3h附加0.0h客户流水¥2970.96充值归因¥3000.00;头部客户(12月)Top3小宇、轩哥。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,56 +0,0 @@
助教详情柚子2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础35.4h附加10.0h客户流水¥23234.98充值归因¥3000.00;头部客户(12月)Top3陈先生、羊、葛先生。
一、基础课业绩
说明评价基础35.4h附加10.0h客户流水¥23234.98充值归因¥3000.00;头部客户(12月)Top3陈先生、羊、葛先生。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,35.40h,16,-19.08h,-3.48h
12月,0.00h,,0.00h,0.00h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,10.00h,3,1.20h,3.00h
12月,0.00h,,0.00h,0.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,0.00,,0.00,0.00
11月,23234.98,18,-21019.41,-10091.34
12月,0.00,,0.00,0.00
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,0.00,,0.00,0.00
11月,3000.00,8,-4769.23,-6000.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,陈先生,0.0h / 0.0h,0.00,0.00,4.4h / 0.0h,1150.83,0.00,0.0h / 0.0h,0.00,0.00
2,,0.0h / 0.0h,0.00,0.00,1.6h / 0.0h,429.33,0.00,0.0h / 0.0h,0.00,0.00
3,葛先生,0.0h / 0.0h,0.00,0.00,3.4h / 0.0h,3052.28,0.00,0.0h / 0.0h,0.00,0.00
4,陈腾鑫,0.0h / 0.0h,0.00,0.00,0.8h / 0.0h,472.03,0.00,0.0h / 0.0h,0.00,0.00
5,张先生,0.0h / 0.0h,0.00,0.00,3.2h / 0.0h,941.37,0.00,0.0h / 0.0h,0.00,0.00
6,,0.0h / 0.0h,0.00,0.00,0.2h / 7.0h,2991.13,0.00,0.0h / 0.0h,0.00,0.00
7,轩哥,0.0h / 0.0h,0.00,0.00,0.2h / 0.0h,4484.68,0.00,0.0h / 0.0h,0.00,0.00
8,胡先生,0.0h / 0.0h,0.00,0.00,1.0h / 0.0h,5688.29,3000.00,0.0h / 0.0h,0.00,0.00
9,李先生,0.0h / 0.0h,0.00,0.00,7.8h / 0.0h,1712.78,0.00,0.0h / 0.0h,0.00,0.00
10,牛先生,0.0h / 0.0h,0.00,0.00,10.4h / 0.0h,1887.48,0.00,0.0h / 0.0h,0.00,0.00
11,阿亮,0.0h / 0.0h,0.00,0.00,2.4h / 0.0h,424.78,0.00,0.0h / 0.0h,0.00,0.00
12,万先生,0.0h / 0.0h,0.00,0.00,0.0h / 3.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
1 助教详情:柚子(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础35.4h,附加10.0h;客户流水¥23234.98,充值归因¥3000.00;头部客户(12月)Top3:陈先生、羊、葛先生。
3 一、基础课业绩
4 说明:评价:基础35.4h,附加10.0h;客户流水¥23234.98,充值归因¥3000.00;头部客户(12月)Top3:陈先生、羊、葛先生。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,0.00h,,0.00h,0.00h
8 11月,35.40h,16,-19.08h,-3.48h
9 12月,0.00h,,0.00h,0.00h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,10.00h,3,1.20h,3.00h
16 12月,0.00h,,0.00h,0.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,0.00,,0.00,0.00
22 11月,23234.98,18,-21019.41,-10091.34
23 12月,0.00,,0.00,0.00
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,0.00,,0.00,0.00
29 11月,3000.00,8,-4769.23,-6000.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,陈先生,0.0h / 0.0h,0.00,0.00,4.4h / 0.0h,1150.83,0.00,0.0h / 0.0h,0.00,0.00
36 2,羊,0.0h / 0.0h,0.00,0.00,1.6h / 0.0h,429.33,0.00,0.0h / 0.0h,0.00,0.00
37 3,葛先生,0.0h / 0.0h,0.00,0.00,3.4h / 0.0h,3052.28,0.00,0.0h / 0.0h,0.00,0.00
38 4,陈腾鑫,0.0h / 0.0h,0.00,0.00,0.8h / 0.0h,472.03,0.00,0.0h / 0.0h,0.00,0.00
39 5,张先生,0.0h / 0.0h,0.00,0.00,3.2h / 0.0h,941.37,0.00,0.0h / 0.0h,0.00,0.00
40 6,夏,0.0h / 0.0h,0.00,0.00,0.2h / 7.0h,2991.13,0.00,0.0h / 0.0h,0.00,0.00
41 7,轩哥,0.0h / 0.0h,0.00,0.00,0.2h / 0.0h,4484.68,0.00,0.0h / 0.0h,0.00,0.00
42 8,胡先生,0.0h / 0.0h,0.00,0.00,1.0h / 0.0h,5688.29,3000.00,0.0h / 0.0h,0.00,0.00
43 9,李先生,0.0h / 0.0h,0.00,0.00,7.8h / 0.0h,1712.78,0.00,0.0h / 0.0h,0.00,0.00
44 10,牛先生,0.0h / 0.0h,0.00,0.00,10.4h / 0.0h,1887.48,0.00,0.0h / 0.0h,0.00,0.00
45 11,阿亮,0.0h / 0.0h,0.00,0.00,2.4h / 0.0h,424.78,0.00,0.0h / 0.0h,0.00,0.00
46 12,万先生,0.0h / 0.0h,0.00,0.00,0.0h / 3.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情柚子2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础35.4h附加10.0h客户流水¥23234.98充值归因¥3000.00;头部客户(12月)Top3陈先生、羊、葛先生。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

View File

@@ -1,51 +0,0 @@
助教详情梦梦2025年10-12月
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入故汇总可能大于门店总额。评价基础35.7h附加1.0h客户流水¥45991.89充值归因¥0.00;头部客户(12月)Top3葛先生、阿亮、蔡总。
一、基础课业绩
说明评价基础35.7h附加1.0h客户流水¥45991.89充值归因¥0.00;头部客户(12月)Top3葛先生、阿亮、蔡总。
月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,19.60h,22,-34.88h,-19.28h
12月,16.08h,18,-28.73h,-25.01h
二、附加课业绩
说明:附加课=order_assistant_type=2。
月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
月份,小时数,排名,平均值差值小时数,中位数值差值小时数
10月,0.00h,,0.00h,0.00h
11月,1.00h,7,-7.80h,-6.00h
12月,0.00h,,0.00h,0.00h
三、客户消费业绩
说明:订单台费+助教+商品应付金额全额计入订单内助教。
月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,0.00,,0.00,0.00
11月,39768.09,11,-4486.30,6441.77
12月,6223.80,18,-14506.73,-7416.84
四、客户充值业绩
说明充值命中消费窗口±30分钟且有助教则归因全额复制。
月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
月份,合计元,排名,平均值差值元,中位数值差值元
10月,0.00,,0.00,0.00
11月,0.00,,0.00,0.00
12月,0.00,,0.00,0.00
五、头部客户按12月消费业绩排序Top100
说明:基础/附加课时=基础h/附加h。
排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
1,葛先生,2.9h / 0.0h,5551.79,0.00,4.4h / 0.0h,1884.66,0.00,0.0h / 0.0h,0.00,0.00
2,阿亮,2.7h / 0.0h,495.46,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
3,蔡总,10.5h / 0.0h,176.55,0.00,7.0h / 1.0h,34274.25,0.00,0.0h / 0.0h,0.00,0.00
4,轩哥,0.0h / 0.0h,0.00,0.00,1.0h / 0.0h,363.25,0.00,0.0h / 0.0h,0.00,0.00
5,,0.0h / 0.0h,0.00,0.00,0.6h / 0.0h,104.77,0.00,0.0h / 0.0h,0.00,0.00
6,林先生,0.0h / 0.0h,0.00,0.00,4.3h / 0.0h,2461.85,0.00,0.0h / 0.0h,0.00,0.00
7,张先生,0.0h / 0.0h,0.00,0.00,2.3h / 0.0h,679.31,0.00,0.0h / 0.0h,0.00,0.00
1 助教详情:梦梦(2025年10-12月)
2 本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础35.7h,附加1.0h;客户流水¥45991.89,充值归因¥0.00;头部客户(12月)Top3:葛先生、阿亮、蔡总。
3 一、基础课业绩
4 说明:评价:基础35.7h,附加1.0h;客户流水¥45991.89,充值归因¥0.00;头部客户(12月)Top3:葛先生、阿亮、蔡总。
5 月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩
6 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
7 10月,0.00h,,0.00h,0.00h
8 11月,19.60h,22,-34.88h,-19.28h
9 12月,16.08h,18,-28.73h,-25.01h
10 二、附加课业绩
11 说明:附加课=order_assistant_type=2。
12 月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩
13 月份,小时数,排名,平均值差值小时数,中位数值差值小时数
14 10月,0.00h,,0.00h,0.00h
15 11月,1.00h,7,-7.80h,-6.00h
16 12月,0.00h,,0.00h,0.00h
17 三、客户消费业绩
18 说明:订单台费+助教+商品应付金额全额计入订单内助教。
19 月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩
20 月份,合计元,排名,平均值差值元,中位数值差值元
21 10月,0.00,,0.00,0.00
22 11月,39768.09,11,-4486.30,6441.77
23 12月,6223.80,18,-14506.73,-7416.84
24 四、客户充值业绩
25 说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。
26 月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩
27 月份,合计元,排名,平均值差值元,中位数值差值元
28 10月,0.00,,0.00,0.00
29 11月,0.00,,0.00,0.00
30 12月,0.00,,0.00,0.00
31 五、头部客户(按12月消费业绩排序,Top100)
32 说明:基础/附加课时=基础h/附加h。
33 排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月
34 排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元)
35 1,葛先生,2.9h / 0.0h,5551.79,0.00,4.4h / 0.0h,1884.66,0.00,0.0h / 0.0h,0.00,0.00
36 2,阿亮,2.7h / 0.0h,495.46,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00
37 3,蔡总,10.5h / 0.0h,176.55,0.00,7.0h / 1.0h,34274.25,0.00,0.0h / 0.0h,0.00,0.00
38 4,轩哥,0.0h / 0.0h,0.00,0.00,1.0h / 0.0h,363.25,0.00,0.0h / 0.0h,0.00,0.00
39 5,羊,0.0h / 0.0h,0.00,0.00,0.6h / 0.0h,104.77,0.00,0.0h / 0.0h,0.00,0.00
40 6,林先生,0.0h / 0.0h,0.00,0.00,4.3h / 0.0h,2461.85,0.00,0.0h / 0.0h,0.00,0.00
41 7,张先生,0.0h / 0.0h,0.00,0.00,2.3h / 0.0h,679.31,0.00,0.0h / 0.0h,0.00,0.00

View File

@@ -1,196 +0,0 @@
# 助教详情梦梦2025年10-12月
## 思考过程
按模板拆分5部分输出月度排名采用dense_rank均值/中位数在当月该指标>0助教集合上计算。
## 查询说明
本表包含5个部分基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。
评价基础35.7h附加1.0h客户流水¥45991.89充值归因¥0.00;头部客户(12月)Top3葛先生、阿亮、蔡总。
## SQL
### 服务时长(助教-客户-月份)
```sql
with raw as (
select
asl.nickname as assistant,
asl.tenant_member_id as member_id,
case when asl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when asl.start_use_time >= '2025-11-01 00:00:00+08'::timestamptz and asl.start_use_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when asl.start_use_time >= '2025-12-01 00:00:00+08'::timestamptz and asl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
asl.order_assistant_type,
asl.income_seconds
from billiards_dwd.dwd_assistant_service_log asl
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
and asl.start_use_time >= %(window_start)s::timestamptz
and asl.start_use_time < %(window_end)s::timestamptz
and asl.tenant_member_id is not null and asl.tenant_member_id<>0
)
select
assistant,
member_id,
month_key,
sum(case when order_assistant_type=1 then income_seconds else 0 end)/3600.0 as base_hours,
sum(case when order_assistant_type=2 then income_seconds else 0 end)/3600.0 as extra_hours
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 客户流水(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as order_start_time,
max(tfl.ledger_end_time) as order_end_time,
sum(tfl.ledger_amount) as table_amount
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id = %(site_id)s
and coalesce(tfl.is_delete,0) = 0
and tfl.start_use_time >= '2025-10-01 00:00:00+08'::timestamptz
and tfl.start_use_time < '2026-01-01 00:00:00+08'::timestamptz
group by tfl.order_settle_id
),
assistant_amount as (
select
asl.order_settle_id,
sum(asl.ledger_amount) as assistant_amount
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id = asl.order_settle_id
where asl.site_id = %(site_id)s
and coalesce(asl.is_delete,0) = 0
group by asl.order_settle_id
),
goods_amount as (
select
g.order_settle_id,
sum(g.ledger_amount) as goods_amount
from billiards_dwd.dwd_store_goods_sale g
join base_orders bo on bo.order_settle_id = g.order_settle_id
where g.site_id = %(site_id)s
and coalesce(g.is_delete,0) = 0
group by g.order_settle_id
),
orders as (
select
bo.order_settle_id,
bo.member_id,
bo.order_start_time,
bo.order_end_time,
coalesce(bo.table_amount,0) + coalesce(a.assistant_amount,0) + coalesce(g.goods_amount,0) as order_amount
from base_orders bo
left join assistant_amount a on a.order_settle_id = bo.order_settle_id
left join goods_amount g on g.order_settle_id = bo.order_settle_id
)
, assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
raw as (
select
ao.assistant,
o.member_id,
case when o.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when o.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and o.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when o.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and o.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
o.order_amount
from orders o
join assistant_orders ao on ao.order_settle_id=o.order_settle_id
where o.member_id is not null and o.member_id<>0
)
select
assistant,
member_id,
month_key,
sum(order_amount) as revenue_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```
### 充值归因(助教-客户-月份)
```sql
with base_orders as (
select
tfl.order_settle_id,
max(tfl.member_id) as member_id,
min(tfl.start_use_time) as table_start_time,
max(tfl.ledger_end_time) as table_end_time
from billiards_dwd.dwd_table_fee_log tfl
where tfl.site_id=%(site_id)s and coalesce(tfl.is_delete,0)=0
and tfl.start_use_time >= %(window_start)s::timestamptz
and tfl.start_use_time < %(window_end)s::timestamptz
group by tfl.order_settle_id
),
assistant_time as (
select
asl.order_settle_id,
min(asl.start_use_time) as assistant_start_time,
max(asl.last_use_time) as assistant_end_time
from billiards_dwd.dwd_assistant_service_log asl
join base_orders bo on bo.order_settle_id=asl.order_settle_id
where asl.site_id=%(site_id)s and coalesce(asl.is_delete,0)=0
group by asl.order_settle_id
),
order_windows as (
select
bo.order_settle_id,
bo.member_id,
least(bo.table_start_time, coalesce(at.assistant_start_time, bo.table_start_time)) as win_start,
greatest(bo.table_end_time, coalesce(at.assistant_end_time, bo.table_end_time)) as win_end
from base_orders bo
left join assistant_time at on at.order_settle_id=bo.order_settle_id
where bo.member_id is not null and bo.member_id<>0
),
assistant_orders as (
select distinct order_settle_id, nickname as assistant
from billiards_dwd.dwd_assistant_service_log
where site_id=%(site_id)s and coalesce(is_delete,0)=0
and start_use_time >= %(window_start)s::timestamptz
and start_use_time < %(window_end)s::timestamptz
),
recharge_pay as (
select
p.pay_time,
r.member_id,
p.pay_amount
from billiards_dwd.dwd_payment p
join billiards_dwd.dwd_recharge_order r on r.recharge_order_id=p.relate_id
where p.site_id=%(site_id)s
and p.relate_type=5
and p.pay_status=2
and p.pay_amount>0
and p.pay_time >= %(window_start)s::timestamptz
and p.pay_time < %(window_end)s::timestamptz
),
matched as (
select
rp.pay_time,
ow.order_settle_id,
ow.member_id,
rp.pay_amount
from recharge_pay rp
join order_windows ow
on ow.member_id=rp.member_id
and rp.pay_time >= ow.win_start - interval '30 minutes'
and rp.pay_time <= ow.win_end + interval '30 minutes'
),
raw as (
select
ao.assistant,
m.member_id,
case when m.pay_time >= '2025-10-01 00:00:00+08'::timestamptz and m.pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when m.pay_time >= '2025-11-01 00:00:00+08'::timestamptz and m.pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when m.pay_time >= '2025-12-01 00:00:00+08'::timestamptz and m.pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key,
m.pay_amount
from matched m
join assistant_orders ao on ao.order_settle_id=m.order_settle_id
)
select
assistant,
member_id,
month_key,
sum(pay_amount) as recharge_amount
from raw
where month_key is not null
group by assistant, member_id, month_key;
```

Some files were not shown because too many files have changed in this diff Show More