diff --git a/collect_env_report.ps1 b/collect_env_report.ps1 new file mode 100644 index 0000000..f45f4a6 --- /dev/null +++ b/collect_env_report.ps1 @@ -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 diff --git a/env_report_local.txt b/env_report_local.txt new file mode 100644 index 0000000..8a311dc --- /dev/null +++ b/env_report_local.txt @@ -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 diff --git a/etl_billiards/1.zip b/etl_billiards/1.zip deleted file mode 100644 index 1b03012..0000000 Binary files a/etl_billiards/1.zip and /dev/null differ diff --git a/etl_billiards/docs/dwd_main_tables_dictionary.md b/etl_billiards/docs/dwd_main_tables_dictionary.md index ea88118..bce8375 100644 --- a/etl_billiards/docs/dwd_main_tables_dictionary.md +++ b/etl_billiards/docs/dwd_main_tables_dictionary.md @@ -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。 | diff --git a/etl_billiards/docs/table_2025-12-19/助教_基础课时长排行_2025年10-12月.csv b/etl_billiards/docs/table_2025-12-19/助教_基础课时长排行_2025年10-12月.csv deleted file mode 100644 index 3032bdc..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教_基础课时长排行_2025年10-12月.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教_基础课时长排行_2025年10-12月.md b/etl_billiards/docs/table_2025-12-19/助教_基础课时长排行_2025年10-12月.md deleted file mode 100644 index 0cfa257..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教_基础课时长排行_2025年10-12月.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教_客户充值归因排行_2025年10-12月.csv b/etl_billiards/docs/table_2025-12-19/助教_客户充值归因排行_2025年10-12月.csv deleted file mode 100644 index cc075d5..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教_客户充值归因排行_2025年10-12月.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教_客户充值归因排行_2025年10-12月.md b/etl_billiards/docs/table_2025-12-19/助教_客户充值归因排行_2025年10-12月.md deleted file mode 100644 index 1050c8c..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教_客户充值归因排行_2025年10-12月.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教_客户流水排行_2025年10-12月.csv b/etl_billiards/docs/table_2025-12-19/助教_客户流水排行_2025年10-12月.csv deleted file mode 100644 index 204968c..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教_客户流水排行_2025年10-12月.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教_客户流水排行_2025年10-12月.md b/etl_billiards/docs/table_2025-12-19/助教_客户流水排行_2025年10-12月.md deleted file mode 100644 index 8d68e7c..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教_客户流水排行_2025年10-12月.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教_附加课时长排行_2025年10-12月.csv b/etl_billiards/docs/table_2025-12-19/助教_附加课时长排行_2025年10-12月.csv deleted file mode 100644 index 902ea41..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教_附加课时长排行_2025年10-12月.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教_附加课时长排行_2025年10-12月.md b/etl_billiards/docs/table_2025-12-19/助教_附加课时长排行_2025年10-12月.md deleted file mode 100644 index e8986cb..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教_附加课时长排行_2025年10-12月.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_Amy.csv b/etl_billiards/docs/table_2025-12-19/助教详情_Amy.csv deleted file mode 100644 index bad2eac..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_Amy.csv +++ /dev/null @@ -1,56 +0,0 @@ -助教详情:Amy(2025年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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_Amy.md b/etl_billiards/docs/table_2025-12-19/助教详情_Amy.md deleted file mode 100644 index dda6894..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_Amy.md +++ /dev/null @@ -1,196 +0,0 @@ -# 助教详情:Amy(2025年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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_QQ.csv b/etl_billiards/docs/table_2025-12-19/助教详情_QQ.csv deleted file mode 100644 index af1c043..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_QQ.csv +++ /dev/null @@ -1,47 +0,0 @@ -助教详情:QQ(2025年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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_QQ.md b/etl_billiards/docs/table_2025-12-19/助教详情_QQ.md deleted file mode 100644 index 040c778..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_QQ.md +++ /dev/null @@ -1,196 +0,0 @@ -# 助教详情:QQ(2025年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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_七七.csv b/etl_billiards/docs/table_2025-12-19/助教详情_七七.csv deleted file mode 100644 index 47420c2..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_七七.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_七七.md b/etl_billiards/docs/table_2025-12-19/助教详情_七七.md deleted file mode 100644 index 4cb7dde..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_七七.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_乔西.csv b/etl_billiards/docs/table_2025-12-19/助教详情_乔西.csv deleted file mode 100644 index cbd3b25..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_乔西.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_乔西.md b/etl_billiards/docs/table_2025-12-19/助教详情_乔西.md deleted file mode 100644 index 1d4e6a0..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_乔西.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_佳怡.csv b/etl_billiards/docs/table_2025-12-19/助教详情_佳怡.csv deleted file mode 100644 index f62f7b6..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_佳怡.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_佳怡.md b/etl_billiards/docs/table_2025-12-19/助教详情_佳怡.md deleted file mode 100644 index a524aa2..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_佳怡.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_千千.csv b/etl_billiards/docs/table_2025-12-19/助教详情_千千.csv deleted file mode 100644 index a3f43c0..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_千千.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_千千.md b/etl_billiards/docs/table_2025-12-19/助教详情_千千.md deleted file mode 100644 index 07dd33f..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_千千.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_周周.csv b/etl_billiards/docs/table_2025-12-19/助教详情_周周.csv deleted file mode 100644 index c5ba351..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_周周.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_周周.md b/etl_billiards/docs/table_2025-12-19/助教详情_周周.md deleted file mode 100644 index 68ef417..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_周周.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_奈千.csv b/etl_billiards/docs/table_2025-12-19/助教详情_奈千.csv deleted file mode 100644 index 55b648d..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_奈千.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_奈千.md b/etl_billiards/docs/table_2025-12-19/助教详情_奈千.md deleted file mode 100644 index 25e397f..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_奈千.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_姜姜.csv b/etl_billiards/docs/table_2025-12-19/助教详情_姜姜.csv deleted file mode 100644 index c91de92..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_姜姜.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_姜姜.md b/etl_billiards/docs/table_2025-12-19/助教详情_姜姜.md deleted file mode 100644 index 3b5c045..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_姜姜.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_婉婉.csv b/etl_billiards/docs/table_2025-12-19/助教详情_婉婉.csv deleted file mode 100644 index ece6ca8..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_婉婉.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_婉婉.md b/etl_billiards/docs/table_2025-12-19/助教详情_婉婉.md deleted file mode 100644 index 09efb40..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_婉婉.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_小侯.csv b/etl_billiards/docs/table_2025-12-19/助教详情_小侯.csv deleted file mode 100644 index 27942ed..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_小侯.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_小侯.md b/etl_billiards/docs/table_2025-12-19/助教详情_小侯.md deleted file mode 100644 index b71681b..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_小侯.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_小敌.csv b/etl_billiards/docs/table_2025-12-19/助教详情_小敌.csv deleted file mode 100644 index 659a0d4..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_小敌.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_小敌.md b/etl_billiards/docs/table_2025-12-19/助教详情_小敌.md deleted file mode 100644 index e1078be..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_小敌.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_小柔.csv b/etl_billiards/docs/table_2025-12-19/助教详情_小柔.csv deleted file mode 100644 index 384edcd..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_小柔.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_小柔.md b/etl_billiards/docs/table_2025-12-19/助教详情_小柔.md deleted file mode 100644 index 9247805..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_小柔.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_小柳.csv b/etl_billiards/docs/table_2025-12-19/助教详情_小柳.csv deleted file mode 100644 index 0a44a03..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_小柳.csv +++ /dev/null @@ -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月 -排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元) diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_小柳.md b/etl_billiards/docs/table_2025-12-19/助教详情_小柳.md deleted file mode 100644 index 8872c16..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_小柳.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_小燕.csv b/etl_billiards/docs/table_2025-12-19/助教详情_小燕.csv deleted file mode 100644 index eca0b93..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_小燕.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_小燕.md b/etl_billiards/docs/table_2025-12-19/助教详情_小燕.md deleted file mode 100644 index af5c276..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_小燕.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_希希.csv b/etl_billiards/docs/table_2025-12-19/助教详情_希希.csv deleted file mode 100644 index bc73ed6..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_希希.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_希希.md b/etl_billiards/docs/table_2025-12-19/助教详情_希希.md deleted file mode 100644 index 7a68a55..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_希希.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_年糕.csv b/etl_billiards/docs/table_2025-12-19/助教详情_年糕.csv deleted file mode 100644 index e37cfbe..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_年糕.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_年糕.md b/etl_billiards/docs/table_2025-12-19/助教详情_年糕.md deleted file mode 100644 index 6d5df8b..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_年糕.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_悦悦.csv b/etl_billiards/docs/table_2025-12-19/助教详情_悦悦.csv deleted file mode 100644 index 4787f35..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_悦悦.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_悦悦.md b/etl_billiards/docs/table_2025-12-19/助教详情_悦悦.md deleted file mode 100644 index ef5b8b0..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_悦悦.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_柚子.csv b/etl_billiards/docs/table_2025-12-19/助教详情_柚子.csv deleted file mode 100644 index 546d754..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_柚子.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_柚子.md b/etl_billiards/docs/table_2025-12-19/助教详情_柚子.md deleted file mode 100644 index 15b80ae..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_柚子.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_梦梦.csv b/etl_billiards/docs/table_2025-12-19/助教详情_梦梦.csv deleted file mode 100644 index 068ad17..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_梦梦.csv +++ /dev/null @@ -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 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_梦梦.md b/etl_billiards/docs/table_2025-12-19/助教详情_梦梦.md deleted file mode 100644 index 0068571..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_梦梦.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_楚楚.csv b/etl_billiards/docs/table_2025-12-19/助教详情_楚楚.csv deleted file mode 100644 index 6b3c3fa..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_楚楚.csv +++ /dev/null @@ -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月 -排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元) diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_楚楚.md b/etl_billiards/docs/table_2025-12-19/助教详情_楚楚.md deleted file mode 100644 index d1aacfc..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_楚楚.md +++ /dev/null @@ -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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_欣怡.csv b/etl_billiards/docs/table_2025-12-19/助教详情_欣怡.csv deleted file mode 100644 index 312e2b0..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_欣怡.csv +++ /dev/null @@ -1,52 +0,0 @@ -助教详情:欣怡(2025年10-12月) -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础29.8h,附加0.0h;客户流水¥9981.98,充值归因¥7000.00;头部客户(12月)Top3:老宋、张先生、轩哥。 - -一、基础课业绩 -说明:评价:基础29.8h,附加0.0h;客户流水¥9981.98,充值归因¥7000.00;头部客户(12月)Top3:老宋、张先生、轩哥。 - -月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,19.50h,15,-24.91h,-17.03h -11月,10.33h,24,-44.14h,-28.55h -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月,4824.69,17,-24454.84,-25825.14 -11月,5157.29,24,-39097.10,-28169.03 -12月,0.00,,0.00,0.00 - -四、客户充值业绩 -说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。 - -月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩 -月份,合计元,排名,平均值差值元,中位数值差值元 -10月,3000.00,13,-11466.67,-10000.00 -11月,4000.00,7,-3769.23,-5000.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.5h / 0.0h,75.99,0.00 -2,张先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.4h / 0.0h,570.76,0.00 -3,轩哥,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.4h / 0.0h,408.24,0.00 -4,羊,0.0h / 0.0h,0.00,0.00,2.0h / 0.0h,364.70,0.00,0.0h / 0.0h,0.00,0.00 -5,小熊,0.0h / 0.0h,0.00,0.00,7.8h / 0.0h,2438.20,4000.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.9h / 0.0h,904.50,0.00 -7,T,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,10.3h / 0.0h,2865.20,3000.00 -8,胡先生,0.0h / 0.0h,0.00,0.00,0.4h / 0.0h,2354.39,0.00,0.0h / 0.0h,0.00,0.00 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_欣怡.md b/etl_billiards/docs/table_2025-12-19/助教详情_欣怡.md deleted file mode 100644 index 55c8a47..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_欣怡.md +++ /dev/null @@ -1,196 +0,0 @@ -# 助教详情:欣怡(2025年10-12月) -## 思考过程 -按模板拆分5部分输出;月度排名采用dense_rank;均值/中位数在当月该指标>0助教集合上计算。 - -## 查询说明 -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。 -评价:基础29.8h,附加0.0h;客户流水¥9981.98,充值归因¥7000.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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_泡芙.csv b/etl_billiards/docs/table_2025-12-19/助教详情_泡芙.csv deleted file mode 100644 index 29e1380..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_泡芙.csv +++ /dev/null @@ -1,48 +0,0 @@ -助教详情:泡芙(2025年10-12月) -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础21.4h,附加3.0h;客户流水¥8323.03,充值归因¥0.00;头部客户(12月)Top3:夏、艾宇民、羊。 - -一、基础课业绩 -说明:评价:基础21.4h,附加3.0h;客户流水¥8323.03,充值归因¥0.00;头部客户(12月)Top3:夏、艾宇民、羊。 - -月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,0.00h,,0.00h,0.00h -11月,21.38h,21,-33.09h,-17.50h -12月,0.00h,,0.00h,0.00h - -二、附加课业绩 -说明:附加课=order_assistant_type=2。 - -月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,0.00h,,0.00h,0.00h -11月,3.00h,5,-5.80h,-4.00h -12月,0.00h,,0.00h,0.00h - -三、客户消费业绩 -说明:订单台费+助教+商品应付金额全额计入订单内助教。 - -月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩 -月份,合计元,排名,平均值差值元,中位数值差值元 -10月,0.00,,0.00,0.00 -11月,8323.03,23,-35931.36,-25003.29 -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,2.4h / 0.0h,501.87,0.00,0.0h / 0.0h,0.00,0.00 -2,艾宇民,0.0h / 0.0h,0.00,0.00,17.5h / 3.0h,5037.44,0.00,0.0h / 0.0h,0.00,0.00 -3,羊,0.0h / 0.0h,0.00,0.00,0.8h / 0.0h,429.33,0.00,0.0h / 0.0h,0.00,0.00 -4,胡先生,0.0h / 0.0h,0.00,0.00,0.8h / 0.0h,2354.39,0.00,0.0h / 0.0h,0.00,0.00 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_泡芙.md b/etl_billiards/docs/table_2025-12-19/助教详情_泡芙.md deleted file mode 100644 index f47a20a..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_泡芙.md +++ /dev/null @@ -1,196 +0,0 @@ -# 助教详情:泡芙(2025年10-12月) -## 思考过程 -按模板拆分5部分输出;月度排名采用dense_rank;均值/中位数在当月该指标>0助教集合上计算。 - -## 查询说明 -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。 -评价:基础21.4h,附加3.0h;客户流水¥8323.03,充值归因¥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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_涛涛.csv b/etl_billiards/docs/table_2025-12-19/助教详情_涛涛.csv deleted file mode 100644 index e365ba9..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_涛涛.csv +++ /dev/null @@ -1,60 +0,0 @@ -助教详情:涛涛(2025年10-12月) -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础168.6h,附加3.0h;客户流水¥166962.41,充值归因¥26000.00;头部客户(12月)Top3:蔡总、轩哥、葛先生。 - -一、基础课业绩 -说明:评价:基础168.6h,附加3.0h;客户流水¥166962.41,充值归因¥26000.00;头部客户(12月)Top3:蔡总、轩哥、葛先生。 - -月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,50.13h,8,5.72h,13.61h -11月,74.40h,7,19.92h,35.52h -12月,44.08h,10,-0.73h,2.99h - -二、附加课业绩 -说明:附加课=order_assistant_type=2。 - -月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,0.00h,,0.00h,0.00h -11月,3.00h,5,-5.80h,-4.00h -12月,0.00h,,0.00h,0.00h - -三、客户消费业绩 -说明:订单台费+助教+商品应付金额全额计入订单内助教。 - -月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩 -月份,合计元,排名,平均值差值元,中位数值差值元 -10月,35940.84,8,6661.31,5291.01 -11月,88677.55,4,44423.16,55351.23 -12月,42344.02,4,21613.49,28703.38 - -四、客户充值业绩 -说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。 - -月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩 -月份,合计元,排名,平均值差值元,中位数值差值元 -10月,21000.00,5,6533.33,8000.00 -11月,5000.00,6,-2769.23,-4000.00 -12月,0.00,,0.00,0.00 - -五、头部客户(按12月消费业绩排序,Top100) -说明:基础/附加课时=基础h/附加h。 - -排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月 -排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元) -1,蔡总,15.1h / 0.0h,18914.63,0.00,28.4h / 0.0h,57785.21,0.00,0.0h / 0.0h,0.00,0.00 -2,轩哥,10.8h / 0.0h,14490.25,0.00,21.8h / 0.0h,22186.78,0.00,40.1h / 0.0h,30415.18,15000.00 -3,葛先生,5.8h / 0.0h,5551.79,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -4,君姐,2.2h / 0.0h,1414.23,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -5,候,3.1h / 0.0h,563.70,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -6,阿亮,2.9h / 0.0h,538.07,0.00,1.7h / 3.0h,300.53,0.00,0.0h / 0.0h,0.00,0.00 -7,罗先生,2.3h / 0.0h,524.41,0.00,2.3h / 0.0h,844.76,0.00,6.0h / 0.0h,1773.80,3000.00 -8,张先生,1.9h / 0.0h,346.94,0.00,1.8h / 0.0h,325.27,0.00,0.0h / 0.0h,0.00,0.00 -9,江先生,0.0h / 0.0h,0.00,0.00,1.8h / 0.0h,2095.41,5000.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,3.1h / 0.0h,3607.02,3000.00 -11,吴生,0.0h / 0.0h,0.00,0.00,2.2h / 0.0h,537.96,0.00,0.0h / 0.0h,0.00,0.00 -12,陈淑涛,0.0h / 0.0h,0.00,0.00,4.4h / 0.0h,1176.77,0.00,0.0h / 0.0h,0.00,0.00 -13,李先生,0.0h / 0.0h,0.00,0.00,2.0h / 0.0h,779.48,0.00,0.0h / 0.0h,0.00,0.00 -14,明哥,0.0h / 0.0h,0.00,0.00,5.4h / 0.0h,2258.14,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,0.9h / 0.0h,144.84,0.00 -16,胡先生,0.0h / 0.0h,0.00,0.00,2.7h / 0.0h,387.24,0.00,0.0h / 0.0h,0.00,0.00 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_涛涛.md b/etl_billiards/docs/table_2025-12-19/助教详情_涛涛.md deleted file mode 100644 index cc57443..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_涛涛.md +++ /dev/null @@ -1,196 +0,0 @@ -# 助教详情:涛涛(2025年10-12月) -## 思考过程 -按模板拆分5部分输出;月度排名采用dense_rank;均值/中位数在当月该指标>0助教集合上计算。 - -## 查询说明 -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。 -评价:基础168.6h,附加3.0h;客户流水¥166962.41,充值归因¥26000.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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_球球.csv b/etl_billiards/docs/table_2025-12-19/助教详情_球球.csv deleted file mode 100644 index ae1ce76..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_球球.csv +++ /dev/null @@ -1,74 +0,0 @@ -助教详情:球球(2025年10-12月) -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础172.5h,附加41.0h;客户流水¥95647.82,充值归因¥24000.00;头部客户(12月)Top3:葛先生、周周、T。 - -一、基础课业绩 -说明:评价:基础172.5h,附加41.0h;客户流水¥95647.82,充值归因¥24000.00;头部客户(12月)Top3:葛先生、周周、T。 - -月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,57.45h,6,13.04h,20.92h -11月,66.50h,11,12.02h,27.62h -12月,48.58h,9,3.77h,7.49h - -二、附加课业绩 -说明:附加课=order_assistant_type=2。 - -月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,11.00h,1,4.43h,3.00h -11月,25.00h,1,16.20h,18.00h -12月,5.00h,6,-5.27h,-3.00h - -三、客户消费业绩 -说明:订单台费+助教+商品应付金额全额计入订单内助教。 - -月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩 -月份,合计元,排名,平均值差值元,中位数值差值元 -10月,33923.75,10,4644.22,3273.92 -11月,41907.39,10,-2347.00,8581.07 -12月,19816.68,8,-913.85,6176.04 - -四、客户充值业绩 -说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。 - -月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩 -月份,合计元,排名,平均值差值元,中位数值差值元 -10月,15000.00,8,533.33,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,葛先生,1.1h / 0.0h,5551.79,0.00,0.9h / 0.0h,3052.28,0.00,0.0h / 0.0h,0.00,0.00 -2,周周,15.2h / 0.0h,4161.75,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -3,T,10.7h / 0.0h,3327.26,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -4,蔡总,8.5h / 0.0h,2130.39,0.00,3.4h / 0.0h,6196.43,0.00,0.0h / 0.0h,0.00,0.00 -5,罗先生,2.3h / 0.0h,1584.22,0.00,0.0h / 0.0h,0.00,0.00,1.4h / 0.0h,514.68,0.00 -6,候,5.3h / 0.0h,926.59,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -7,张先生,3.0h / 0.0h,876.46,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -8,李先生,0.0h / 0.0h,703.83,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -9,大G,1.8h / 0.0h,467.10,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -10,黄先生,0.6h / 5.0h,87.29,0.00,4.4h / 18.0h,828.62,0.00,11.0h / 9.0h,1608.13,0.00 -11,邓飛,0.0h / 0.0h,0.00,0.00,0.8h / 0.0h,925.47,1000.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,0.8h / 0.0h,176.14,0.00 -13,陈腾鑫,0.0h / 0.0h,0.00,0.00,25.1h / 0.0h,5150.83,0.00,6.1h / 2.0h,980.14,0.00 -14,叶先生,0.0h / 0.0h,0.00,0.00,6.7h / 0.0h,3013.86,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,2.6h / 0.0h,1929.19,0.00 -16,羊,0.0h / 0.0h,0.00,0.00,2.2h / 0.0h,383.40,0.00,3.1h / 0.0h,3620.75,0.00 -17,夏,0.0h / 0.0h,0.00,0.00,2.0h / 4.0h,370.12,0.00,2.5h / 0.0h,455.12,0.00 -18,轩哥,0.0h / 0.0h,0.00,0.00,11.2h / 0.0h,12063.93,5000.00,9.1h / 0.0h,9207.48,6000.00 -19,罗超,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.9h / 0.0h,2385.30,3000.00 -20,小熊,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.4h / 0.0h,709.18,0.00 -21,陈德韩,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.8h / 0.0h,5714.01,0.00 -22,刘哥,0.0h / 0.0h,0.00,0.00,2.0h / 0.0h,2982.34,0.00,0.0h / 0.0h,0.00,0.00 -23,桂先生,0.0h / 0.0h,0.00,0.00,2.6h / 0.0h,826.02,0.00,0.0h / 0.0h,0.00,0.00 -24,万先生,0.0h / 0.0h,0.00,0.00,0.0h / 3.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -25,吕先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.8h / 0.0h,2843.29,3000.00 -26,胡先生,0.0h / 0.0h,0.00,0.00,3.9h / 0.0h,5688.29,3000.00,0.0h / 0.0h,0.00,0.00 -27,江先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.7h / 0.0h,2740.35,3000.00 -28,小宇,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.5h / 0.0h,318.98,0.00 -29,陶,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.7h / 0.0h,721.01,0.00 -30,小燕,0.0h / 0.0h,0.00,0.00,1.4h / 0.0h,425.80,0.00,0.0h / 0.0h,0.00,0.00 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_球球.md b/etl_billiards/docs/table_2025-12-19/助教详情_球球.md deleted file mode 100644 index de1e3ee..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_球球.md +++ /dev/null @@ -1,196 +0,0 @@ -# 助教详情:球球(2025年10-12月) -## 思考过程 -按模板拆分5部分输出;月度排名采用dense_rank;均值/中位数在当月该指标>0助教集合上计算。 - -## 查询说明 -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。 -评价:基础172.5h,附加41.0h;客户流水¥95647.82,充值归因¥24000.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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_瑶瑶.csv b/etl_billiards/docs/table_2025-12-19/助教详情_瑶瑶.csv deleted file mode 100644 index aef2879..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_瑶瑶.csv +++ /dev/null @@ -1,49 +0,0 @@ -助教详情:瑶瑶(2025年10-12月) -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础53.7h,附加3.0h;客户流水¥72216.91,充值归因¥0.00;头部客户(12月)Top3:蔡总、轩哥、陈世。 - -一、基础课业绩 -说明:评价:基础53.7h,附加3.0h;客户流水¥72216.91,充值归因¥0.00;头部客户(12月)Top3:蔡总、轩哥、陈世。 - -月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,0.00h,,0.00h,0.00h -11月,34.25h,18,-20.23h,-4.63h -12月,19.48h,15,-25.33h,-21.61h - -二、附加课业绩 -说明:附加课=order_assistant_type=2。 - -月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,0.00h,,0.00h,0.00h -11月,3.00h,5,-5.80h,-4.00h -12月,0.00h,,0.00h,0.00h - -三、客户消费业绩 -说明:订单台费+助教+商品应付金额全额计入订单内助教。 - -月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩 -月份,合计元,排名,平均值差值元,中位数值差值元 -10月,0.00,,0.00,0.00 -11月,65924.36,8,21669.97,32598.04 -12月,6292.55,17,-14437.98,-7348.10 - -四、客户充值业绩 -说明:充值命中消费窗口±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,蔡总,19.5h / 0.0h,6292.55,0.00,20.3h / 2.0h,53735.58,0.00,0.0h / 0.0h,0.00,0.00 -2,轩哥,0.0h / 0.0h,0.00,0.00,9.3h / 1.0h,8137.22,0.00,0.0h / 0.0h,0.00,0.00 -3,陈世,0.0h / 0.0h,0.00,0.00,0.8h / 0.0h,139.15,0.00,0.0h / 0.0h,0.00,0.00 -4,游,0.0h / 0.0h,0.00,0.00,2.0h / 0.0h,3544.42,0.00,0.0h / 0.0h,0.00,0.00 -5,林先生,0.0h / 0.0h,0.00,0.00,1.9h / 0.0h,367.99,0.00,0.0h / 0.0h,0.00,0.00 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_瑶瑶.md b/etl_billiards/docs/table_2025-12-19/助教详情_瑶瑶.md deleted file mode 100644 index 5a7271b..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_瑶瑶.md +++ /dev/null @@ -1,196 +0,0 @@ -# 助教详情:瑶瑶(2025年10-12月) -## 思考过程 -按模板拆分5部分输出;月度排名采用dense_rank;均值/中位数在当月该指标>0助教集合上计算。 - -## 查询说明 -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。 -评价:基础53.7h,附加3.0h;客户流水¥72216.91,充值归因¥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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_璇子.csv b/etl_billiards/docs/table_2025-12-19/助教详情_璇子.csv deleted file mode 100644 index cead2b0..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_璇子.csv +++ /dev/null @@ -1,56 +0,0 @@ -助教详情:璇子(2025年10-12月) -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础358.9h,附加32.0h;客户流水¥301070.23,充值归因¥44700.00;头部客户(12月)Top3:轩哥、蔡总、江先生。 - -一、基础课业绩 -说明:评价:基础358.9h,附加32.0h;客户流水¥301070.23,充值归因¥44700.00;头部客户(12月)Top3:轩哥、蔡总、江先生。 - -月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,120.20h,2,75.79h,83.67h -11月,147.92h,2,93.44h,109.03h -12月,90.75h,3,45.94h,49.66h - -二、附加课业绩 -说明:附加课=order_assistant_type=2。 - -月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,8.00h,3,1.43h,0.00h -11月,10.00h,3,1.20h,3.00h -12月,14.00h,4,3.73h,6.00h - -三、客户消费业绩 -说明:订单台费+助教+商品应付金额全额计入订单内助教。 - -月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩 -月份,合计元,排名,平均值差值元,中位数值差值元 -10月,80804.14,1,51524.61,50154.31 -11月,154486.83,1,110232.44,121160.51 -12月,65779.26,1,45048.73,52138.62 - -四、客户充值业绩 -说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。 - -月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩 -月份,合计元,排名,平均值差值元,中位数值差值元 -10月,34700.00,1,20233.33,21700.00 -11月,10000.00,3,2230.77,1000.00 -12月,0.00,,0.00,0.00 - -五、头部客户(按12月消费业绩排序,Top100) -说明:基础/附加课时=基础h/附加h。 - -排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月 -排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元) -1,轩哥,37.7h / 0.0h,28122.15,0.00,50.3h / 0.0h,46514.85,0.00,64.6h / 0.0h,53866.23,23000.00 -2,蔡总,18.3h / 0.0h,21216.97,0.00,49.9h / 0.0h,84757.28,5000.00,0.0h / 0.0h,0.00,0.00 -3,江先生,17.7h / 14.0h,10018.73,0.00,29.6h / 10.0h,14700.83,5000.00,15.2h / 8.0h,5637.50,3000.00 -4,林先生,9.6h / 0.0h,3351.61,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -5,罗先生,5.2h / 0.0h,1655.57,0.00,5.1h / 0.0h,1718.68,0.00,2.8h / 0.0h,1087.21,0.00 -6,君姐,2.2h / 0.0h,1414.23,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -7,游,0.0h / 0.0h,0.00,0.00,3.1h / 0.0h,3544.42,0.00,0.0h / 0.0h,0.00,0.00 -8,羊,0.0h / 0.0h,0.00,0.00,5.0h / 0.0h,1017.12,0.00,0.0h / 0.0h,0.00,0.00 -9,张先生,0.0h / 0.0h,0.00,0.00,4.9h / 0.0h,2233.65,0.00,5.4h / 0.0h,3211.91,0.00 -10,夏,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,7.6h / 0.0h,6452.71,0.00 -11,罗超,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.6h / 0.0h,2385.30,3000.00 -12,叶总,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,22.0h / 0.0h,8163.28,5700.00 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_璇子.md b/etl_billiards/docs/table_2025-12-19/助教详情_璇子.md deleted file mode 100644 index 30e4c11..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_璇子.md +++ /dev/null @@ -1,196 +0,0 @@ -# 助教详情:璇子(2025年10-12月) -## 思考过程 -按模板拆分5部分输出;月度排名采用dense_rank;均值/中位数在当月该指标>0助教集合上计算。 - -## 查询说明 -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。 -评价:基础358.9h,附加32.0h;客户流水¥301070.23,充值归因¥44700.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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_素素.csv b/etl_billiards/docs/table_2025-12-19/助教详情_素素.csv deleted file mode 100644 index ce40957..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_素素.csv +++ /dev/null @@ -1,64 +0,0 @@ -助教详情:素素(2025年10-12月) -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础85.5h,附加10.0h;客户流水¥55755.41,充值归因¥7000.00;头部客户(12月)Top3:叶先生、周先生、轩哥。 - -一、基础课业绩 -说明:评价:基础85.5h,附加10.0h;客户流水¥55755.41,充值归因¥7000.00;头部客户(12月)Top3:叶先生、周先生、轩哥。 - -月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,40.45h,10,-3.96h,3.92h -11月,35.03h,17,-19.44h,-3.85h -12月,9.98h,19,-34.83h,-31.11h - -二、附加课业绩 -说明:附加课=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月,34135.89,9,4856.36,3486.06 -11月,18707.30,19,-25547.09,-14619.02 -12月,2912.22,19,-17818.31,-10728.42 - -四、客户充值业绩 -说明:充值命中消费窗口±30分钟且有助教则归因;全额复制。 - -月份,客户充值业绩,客户充值业绩,客户充值业绩,客户充值业绩 -月份,合计元,排名,平均值差值元,中位数值差值元 -10月,6000.00,11,-8466.67,-7000.00 -11月,1000.00,9,-6769.23,-8000.00 -12月,0.00,,0.00,0.00 - -五、头部客户(按12月消费业绩排序,Top100) -说明:基础/附加课时=基础h/附加h。 - -排名,客户名称,12月,12月,12月,11月,11月,11月,10月,10月,10月 -排名,客户名称,基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元),基础/附加课时,消费业绩(元),客户充值(元) -1,叶先生,3.0h / 0.0h,1558.40,0.00,7.0h / 3.0h,3725.65,0.00,15.1h / 0.0h,8807.20,3000.00 -2,周先生,6.2h / 0.0h,1065.70,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -3,轩哥,0.8h / 0.0h,288.12,0.00,0.0h / 0.0h,0.00,0.00,3.6h / 0.0h,8972.50,0.00 -4,邓飛,0.0h / 0.0h,0.00,0.00,0.8h / 0.0h,925.47,1000.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,1.9h / 0.0h,396.94,0.00 -6,陈腾鑫,0.0h / 0.0h,0.00,0.00,0.4h / 0.0h,152.18,0.00,2.1h / 0.0h,542.06,0.00 -7,谢俊,0.0h / 0.0h,0.00,0.00,2.4h / 0.0h,417.75,0.00,0.0h / 0.0h,0.00,0.00 -8,罗先生,0.0h / 0.0h,0.00,0.00,4.7h / 0.0h,861.57,0.00,0.0h / 0.0h,0.00,0.00 -9,葛先生,0.0h / 0.0h,0.00,0.00,9.1h / 0.0h,4668.26,0.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,3.9h / 0.0h,2789.21,0.00 -11,羊,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,4.3h / 0.0h,3620.75,0.00 -12,张先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,1.1h / 0.0h,449.93,0.00 -13,都先生,0.0h / 0.0h,0.00,0.00,1.6h / 0.0h,269.64,0.00,0.0h / 0.0h,0.00,0.00 -14,夏,0.0h / 0.0h,0.00,0.00,0.8h / 4.0h,2991.13,0.00,0.0h / 0.0h,0.00,0.00 -15,罗先生,0.0h / 0.0h,0.00,0.00,4.3h / 0.0h,1856.86,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,5.5h / 0.0h,5714.01,0.00 -17,吕先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.8h / 0.0h,2843.29,3000.00 -18,万先生,0.0h / 0.0h,0.00,0.00,0.0h / 3.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -19,阿亮,0.0h / 0.0h,0.00,0.00,3.1h / 0.0h,484.40,0.00,0.0h / 0.0h,0.00,0.00 -20,胡先生,0.0h / 0.0h,0.00,0.00,0.8h / 0.0h,2354.39,0.00,0.0h / 0.0h,0.00,0.00 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_素素.md b/etl_billiards/docs/table_2025-12-19/助教详情_素素.md deleted file mode 100644 index 5480ae0..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_素素.md +++ /dev/null @@ -1,196 +0,0 @@ -# 助教详情:素素(2025年10-12月) -## 思考过程 -按模板拆分5部分输出;月度排名采用dense_rank;均值/中位数在当月该指标>0助教集合上计算。 - -## 查询说明 -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。 -评价:基础85.5h,附加10.0h;客户流水¥55755.41,充值归因¥7000.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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_苏苏.csv b/etl_billiards/docs/table_2025-12-19/助教详情_苏苏.csv deleted file mode 100644 index 07c011a..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_苏苏.csv +++ /dev/null @@ -1,58 +0,0 @@ -助教详情:苏苏(2025年10-12月) -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础82.6h,附加9.0h;客户流水¥33952.79,充值归因¥6000.00;头部客户(12月)Top3:罗先生、T、林先生。 - -一、基础课业绩 -说明:评价:基础82.6h,附加9.0h;客户流水¥33952.79,充值归因¥6000.00;头部客户(12月)Top3:罗先生、T、林先生。 - -月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,25.15h,12,-19.26h,-11.38h -11月,13.52h,23,-40.96h,-25.37h -12月,43.90h,11,-0.91h,2.81h - -二、附加课业绩 -说明:附加课=order_assistant_type=2。 - -月份,附加课业绩,附加课业绩,附加课业绩,附加课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,8.00h,3,1.43h,0.00h -11月,0.00h,,0.00h,0.00h -12月,1.00h,9,-9.27h,-7.00h - -三、客户消费业绩 -说明:订单台费+助教+商品应付金额全额计入订单内助教。 - -月份,客户消费业绩,客户消费业绩,客户消费业绩,客户消费业绩 -月份,合计元,排名,平均值差值元,中位数值差值元 -10月,11236.84,15,-18042.69,-19412.99 -11月,10254.59,22,-33999.80,-23071.73 -12月,12461.36,14,-8269.17,-1179.28 - -四、客户充值业绩 -说明:充值命中消费窗口±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,罗先生,19.6h / 0.0h,6061.87,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -2,T,4.5h / 0.0h,1429.89,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -3,林先生,4.9h / 0.0h,1369.86,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -4,黄先生,8.1h / 1.0h,1357.90,0.00,4.0h / 0.0h,674.36,0.00,11.2h / 4.0h,1960.96,0.00 -5,张先生,3.9h / 0.0h,1163.40,0.00,0.0h / 0.0h,0.00,0.00,6.4h / 0.0h,3604.02,0.00 -6,葛先生,2.5h / 0.0h,1004.77,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -7,候,0.4h / 0.0h,73.67,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,0.0h / 0.0h,0.00,0.00,2.6h / 0.0h,2385.30,3000.00 -9,罗超杰,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,2.1h / 0.0h,443.27,0.00 -10,蔡总,0.0h / 0.0h,0.00,0.00,4.7h / 0.0h,6557.92,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,2.8h / 0.0h,2843.29,3000.00 -12,林先生,0.0h / 0.0h,0.00,0.00,3.1h / 0.0h,2398.29,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,0.0h / 4.0h,0.00,0.00 -14,昌哥,0.0h / 0.0h,0.00,0.00,1.6h / 0.0h,624.02,0.00,0.0h / 0.0h,0.00,0.00 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_苏苏.md b/etl_billiards/docs/table_2025-12-19/助教详情_苏苏.md deleted file mode 100644 index 3d21174..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_苏苏.md +++ /dev/null @@ -1,196 +0,0 @@ -# 助教详情:苏苏(2025年10-12月) -## 思考过程 -按模板拆分5部分输出;月度排名采用dense_rank;均值/中位数在当月该指标>0助教集合上计算。 - -## 查询说明 -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。 -评价:基础82.6h,附加9.0h;客户流水¥33952.79,充值归因¥6000.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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_西子.csv b/etl_billiards/docs/table_2025-12-19/助教详情_西子.csv deleted file mode 100644 index 2e02cd3..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_西子.csv +++ /dev/null @@ -1,45 +0,0 @@ -助教详情:西子(2025年10-12月) -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础1.8h,附加0.0h;客户流水¥303.51,充值归因¥0.00;头部客户(12月)Top3:张先生。 - -一、基础课业绩 -说明:评价:基础1.8h,附加0.0h;客户流水¥303.51,充值归因¥0.00;头部客户(12月)Top3:张先生。 - -月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,0.00h,,0.00h,0.00h -11月,1.82h,26,-52.66h,-37.07h -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月,303.51,26,-43950.88,-33022.81 -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,1.8h / 0.0h,303.51,0.00,0.0h / 0.0h,0.00,0.00 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_西子.md b/etl_billiards/docs/table_2025-12-19/助教详情_西子.md deleted file mode 100644 index 43e0809..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_西子.md +++ /dev/null @@ -1,196 +0,0 @@ -# 助教详情:西子(2025年10-12月) -## 思考过程 -按模板拆分5部分输出;月度排名采用dense_rank;均值/中位数在当月该指标>0助教集合上计算。 - -## 查询说明 -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。 -评价:基础1.8h,附加0.0h;客户流水¥303.51,充值归因¥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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_阿清.csv b/etl_billiards/docs/table_2025-12-19/助教详情_阿清.csv deleted file mode 100644 index 3c1cd86..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_阿清.csv +++ /dev/null @@ -1,55 +0,0 @@ -助教详情:阿清(2025年10-12月) -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础139.9h,附加0.0h;客户流水¥53805.04,充值归因¥0.00;头部客户(12月)Top3:陈腾鑫、葛先生、梅。 - -一、基础课业绩 -说明:评价:基础139.9h,附加0.0h;客户流水¥53805.04,充值归因¥0.00;头部客户(12月)Top3:陈腾鑫、葛先生、梅。 - -月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,0.00h,,0.00h,0.00h -11月,73.48h,8,19.01h,34.60h -12月,66.45h,5,21.64h,25.36h - -二、附加课业绩 -说明:附加课=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月,37302.04,13,-6952.35,3975.72 -12月,16503.00,10,-4227.53,2862.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,陈腾鑫,34.9h / 0.0h,7428.12,0.00,44.4h / 0.0h,10029.58,0.00,0.0h / 0.0h,0.00,0.00 -2,葛先生,7.9h / 0.0h,2831.40,0.00,19.7h / 0.0h,7141.04,0.00,0.0h / 0.0h,0.00,0.00 -3,梅,7.5h / 0.0h,2086.99,0.00,3.3h / 0.0h,1573.10,0.00,0.0h / 0.0h,0.00,0.00 -4,张先生,7.2h / 0.0h,1794.40,0.00,1.0h / 0.0h,679.31,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,候,4.2h / 0.0h,773.51,0.00,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00 -7,常总,1.7h / 0.0h,460.52,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.0h / 0.0h,10078.85,0.00,0.0h / 0.0h,0.00,0.00 -9,黄先生,0.0h / 0.0h,0.00,0.00,0.7h / 0.0h,382.08,0.00,0.0h / 0.0h,0.00,0.00 -10,蔡总,0.0h / 0.0h,0.00,0.00,1.5h / 0.0h,6557.92,0.00,0.0h / 0.0h,0.00,0.00 -11,小燕,0.0h / 0.0h,0.00,0.00,2.0h / 0.0h,860.16,0.00,0.0h / 0.0h,0.00,0.00 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_阿清.md b/etl_billiards/docs/table_2025-12-19/助教详情_阿清.md deleted file mode 100644 index 0c79f34..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_阿清.md +++ /dev/null @@ -1,196 +0,0 @@ -# 助教详情:阿清(2025年10-12月) -## 思考过程 -按模板拆分5部分输出;月度排名采用dense_rank;均值/中位数在当月该指标>0助教集合上计算。 - -## 查询说明 -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。 -评价:基础139.9h,附加0.0h;客户流水¥53805.04,充值归因¥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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_饭团.csv b/etl_billiards/docs/table_2025-12-19/助教详情_饭团.csv deleted file mode 100644 index 4a01a9e..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_饭团.csv +++ /dev/null @@ -1,46 +0,0 @@ -助教详情:饭团(2025年10-12月) -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。评价:基础16.0h,附加0.0h;客户流水¥7955.28,充值归因¥0.00;头部客户(12月)Top3:轩哥、张先生。 - -一、基础课业绩 -说明:评价:基础16.0h,附加0.0h;客户流水¥7955.28,充值归因¥0.00;头部客户(12月)Top3:轩哥、张先生。 - -月份,基础课业绩,基础课业绩,基础课业绩,基础课业绩 -月份,小时数,排名,平均值差值小时数,中位数值差值小时数 -10月,16.00h,16,-28.41h,-20.53h -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月,7955.28,16,-21324.25,-22694.55 -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,轩哥,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,6.9h / 0.0h,5089.50,0.00 -2,张先生,0.0h / 0.0h,0.00,0.00,0.0h / 0.0h,0.00,0.00,9.1h / 0.0h,2865.78,0.00 diff --git a/etl_billiards/docs/table_2025-12-19/助教详情_饭团.md b/etl_billiards/docs/table_2025-12-19/助教详情_饭团.md deleted file mode 100644 index e47ee2e..0000000 --- a/etl_billiards/docs/table_2025-12-19/助教详情_饭团.md +++ /dev/null @@ -1,196 +0,0 @@ -# 助教详情:饭团(2025年10-12月) -## 思考过程 -按模板拆分5部分输出;月度排名采用dense_rank;均值/中位数在当月该指标>0助教集合上计算。 - -## 查询说明 -本表包含5个部分:基础课业绩、附加课业绩、客户消费业绩、客户充值业绩、头部客户情况。均值/中位数差值对比集合为当月该指标>0的助教。充值/客户流水多助教与多订单命中均按全额复制计入,故汇总可能大于门店总额。 -评价:基础16.0h,附加0.0h;客户流水¥7955.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; -``` diff --git a/etl_billiards/docs/table_2025-12-19/客户_Top100_2025年10-12月_分表.csv b/etl_billiards/docs/table_2025-12-19/客户_Top100_2025年10-12月_分表.csv deleted file mode 100644 index d0a15d3..0000000 --- a/etl_billiards/docs/table_2025-12-19/客户_Top100_2025年10-12月_分表.csv +++ /dev/null @@ -1,105 +0,0 @@ -2025年10-12月 客户消费能力Top100(分表) -与总表同口径;分表仅计算12月喜爱助教Top5,并展示10-12月各月消费/充值。 - -排名,客户名称,电话号码,12月,12月,12月,11月,11月,10月,10月 -排名,客户名称,电话号码,喜爱助教昵称,消费(元),充值(元),消费(元),充值(元),消费(元),充值(元) - 1,轩哥,188****7530,七七(65.8h)、璇子(37.7h)、涛涛(10.8h)、Amy(8.8h)、小柔(8.4h),29170.33,0.00,51318.11,13000.00,72647.61,53000.00 - 2,蔡总,159****8893,小柔(30.2h)、七七(26.7h)、瑶瑶(19.5h)、璇子(18.3h)、涛涛(15.1h),34327.09,0.00,115512.37,5000.00,0.00,0.00 - 3,葛先生,138****8071,小燕(104.8h)、阿清(7.9h)、涛涛(5.9h)、梦梦(2.9h)、年糕(2.6h),23237.78,0.00,24991.55,0.00,0.00,0.00 - 4,罗先生,139****6996,佳怡(73.8h)、苏苏(19.6h)、璇子(5.3h)、周周(2.6h)、球球(2.3h),17515.75,0.00,16177.44,0.00,12880.69,10000.00 - 5,陈腾鑫,178****8218,阿清(34.9h)、小侯(12.1h)、千千(4.9h)、小柔(1.7h),10701.83,0.00,19428.27,1000.00,9945.66,8000.00 - 6,江先生,188****4838,璇子(38.7h)、婉婉(4.7h)、小柔(3.2h)、七七(3.2h)、Amy(2.2h),10050.26,0.00,14700.83,5000.00,5721.32,6000.00 - 7,小燕,178****1334,小燕(85.7h)、Amy(1.0h)、年糕(0.5h),17306.66,0.00,12582.23,0.00,0.00,0.00 - 8,张先生,139****8852,小侯(14.5h)、千千(10.0h)、阿清(7.2h)、苏苏(3.9h)、乔西(3.3h),7533.67,0.00,8692.62,0.00,9878.04,0.00 - 9,曾巧明,186****1488,,6331.51,0.00,8821.59,0.00,9677.06,0.00 - 10,黄生,136****9719,,4181.24,0.00,6353.05,0.00,7871.94,0.00 - 11,夏,191****2851,,0.00,0.00,4318.15,6000.00,12281.44,11000.00 - 12,叶先生,138****9539,素素(3.1h)、年糕(2.6h),1658.40,0.00,3725.65,0.00,9107.20,6307.00 - 13,T,180****9962,球球(10.7h)、周周(10.1h)、乔西(6.9h)、苏苏(4.5h)、小侯(3.9h),6777.66,0.00,2490.70,0.00,4382.70,3000.00 - 14,林先生,133****1070,七七(14.0h)、璇子(9.6h)、苏苏(4.9h)、乔西(4.6h)、佳怡(4.5h),9468.05,0.00,3469.81,0.00,0.00,0.00 - 15,曾丹烨,139****3242,,2485.41,0.00,5168.56,0.00,4702.36,3000.00 - 16,胡先生,186****3391,佳怡(3.0h),522.45,0.00,10898.42,8000.00,0.00,0.00 - 17,艾宇民,150****9958,,1179.56,0.00,7185.78,0.00,2397.73,0.00 - 18,谢俊,186****5198,,969.66,0.00,4819.27,0.00,4193.93,0.00 - 19,周周,198****8725,周周(40.8h)、球球(15.2h)、佳怡(13.2h),8905.19,0.00,0.00,0.00,0.00,0.00 - 20,叶总,137****3287,,0.00,0.00,0.00,0.00,8163.28,5700.00 - 21,羊,187****5094,,0.00,0.00,4534.79,16000.00,3620.75,48000.00 - 22,游,172****6666,佳怡(3.2h)、周周(2.4h)、千千(2.2h)、QQ(1.2h),2795.90,0.00,5001.47,0.00,0.00,0.00 - 23,桂先生,166****7275,,606.24,0.00,4788.94,0.00,2283.11,985.00 - 24,明哥,166****0999,婉婉(26.7h)、小柔(25.7h)、年糕(4.6h)、周周(0.4h)、Amy(0.1h),5322.90,0.00,2258.14,0.00,0.00,0.00 - 25,陈德韩,134****7864,,20.00,0.00,0.00,0.00,7282.92,5000.00 - 26,小熊,139****0145,,0.00,0.00,5213.64,4000.00,1922.24,1000.00 - 27,黄先生,135****3507,苏苏(9.6h)、千千(6.2h),2506.04,0.00,1926.28,0.00,2620.40,3000.00 - 28,吕先生,155****0663,,0.00,0.00,0.00,0.00,7012.05,6000.00 - 29,郑先生,159****4331,小敌(4.9h),1614.93,0.00,4823.14,0.00,0.00,0.00 - 30,歌神,188****2164,,0.00,0.00,0.00,0.00,5877.65,5000.00 - 31,罗先生,139****9222,婉婉(7.5h)、小柔(4.5h),0.00,0.00,4687.61,0.00,1143.87,3000.00 - 32,大G,186****4598,周周(14.9h)、佳怡(9.5h)、球球(1.9h),3591.07,0.00,1783.61,0.00,0.00,0.00 - 33,林先生,137****8785,,480.91,0.00,4486.47,0.00,0.00,0.00 - 34,梅,136****4552,千千(10.8h)、阿清(7.5h)、小侯(3.3h),2483.11,0.00,2107.81,0.00,0.00,0.00 - 35,李先生,134****4343,小侯(9.3h)、球球(0.0h),2395.25,0.00,2084.52,0.00,0.00,0.00 - 36,陶,189****2151,,0.00,0.00,0.00,0.00,4096.07,6000.00 - 37,陈先生,159****2829,,0.00,0.00,3717.58,3000.00,100.00,0.00 - 38,候,131****0323,球球(5.3h)、阿清(4.3h)、小侯(3.4h)、涛涛(3.1h)、乔西(2.9h),3765.88,0.00,0.00,0.00,0.00,0.00 - 39,黄先生,158****2109,球球(8.1h)、QQ(4.5h),300.15,0.00,1660.64,0.00,1608.13,3000.00 - 40,孟紫龙,176****3741,,2888.95,0.00,603.78,0.00,0.00,0.00 - 41,罗超,137****0990,,0.00,0.00,0.00,0.00,3398.81,3000.00 - 42,君姐,166****4594,璇子(2.3h)、涛涛(2.2h)、年糕(2.2h),1414.23,0.00,1947.72,0.00,0.00,0.00 - 43,吴生,136****3341,,368.03,0.00,1721.17,0.00,1164.50,0.00 - 44,刘哥,135****0020,婉婉(0.3h),54.46,0.00,2982.34,0.00,0.00,0.00 - 45,李先生,131****4000,,0.00,0.00,2997.53,3000.00,0.00,0.00 - 46,阿亮,159****2628,涛涛(2.9h)、梦梦(2.7h),1133.53,0.00,1802.73,0.00,0.00,0.00 - 47,李先生,186****8308,,0.00,0.00,2785.23,0.00,0.00,0.00 - 48,周先生,173****7775,,0.00,0.00,0.00,0.00,2726.01,0.00 - 49,林先生,159****0021,,0.00,0.00,2690.52,0.00,0.00,0.00 - 50,周先生,193****6822,千千(8.6h)、素素(6.2h),2643.64,0.00,0.00,0.00,0.00,0.00 - 51,林先生,188****0332,,0.00,0.00,2612.01,0.00,0.00,0.00 - 52,牛先生,152****5159,,0.00,0.00,2187.48,0.00,0.00,0.00 - 53,孟紫龙(该会员已注销),176****37411,,0.00,0.00,300.00,0.00,1831.72,0.00 - 54,罗超杰,137****8012,,0.00,0.00,423.70,0.00,1160.35,0.00 - 55,汪先生,139****6339,,0.00,0.00,0.00,0.00,1390.07,1000.00 - 56,桂先生(该会员已注销),166****72751,,0.00,0.00,0.00,0.00,1370.81,0.00 - 57,方先生,153****3185,,0.00,0.00,414.57,0.00,898.73,1000.00 - 58,陈淑涛,132****5485,,0.00,0.00,1276.77,0.00,0.00,0.00 - 59,清,130****3087,阿清(3.0h)、千千(3.0h)、小侯(3.0h),1128.06,0.00,0.00,0.00,0.00,0.00 - 60,amy,137****8221,Amy(4.8h),1105.90,0.00,0.00,0.00,0.00,0.00 - 61,曾先生,133****1235,,193.90,0.00,700.09,0.00,97.35,0.00 - 62,昌哥,137****1229,小柔(1.8h),318.40,0.00,624.02,0.00,0.00,0.00 - 63,李,131****9882,,0.00,0.00,320.99,0.00,606.45,0.00 - 64,邓飛,136****9597,,0.00,0.00,925.47,1000.00,0.00,1345.00 - 65,陈世,134****1938,,0.00,0.00,502.07,0.00,419.02,0.00 - 66,婉婉,183****2742,,0.00,0.00,242.81,0.00,624.68,1000.00 - 67,贺斌,150****0885,,0.00,0.00,108.29,0.00,662.27,0.00 - 68,陈泽斌,132****6060,,100.00,0.00,500.00,0.00,100.00,0.00 - 69,林总,138****1180,,0.00,0.00,684.44,0.00,0.00,0.00 - 70,卢广贤,186****6220,,128.86,0.00,288.51,0.00,263.07,0.00 - 71,王龙,186****8011,,669.58,0.00,0.00,0.00,0.00,0.00 - 72,王先生,185****1125,,183.75,0.00,416.93,0.00,0.00,0.00 - 73,潘先生,186****0511,年糕(2.0h),564.93,0.00,0.00,0.00,0.00,0.00 - 74,老宋,138****4554,,0.00,0.00,465.98,0.00,75.99,0.00 - 75,郭先生,156****5001,,0.00,0.00,281.22,0.00,237.13,0.00 - 76,孙启明,137****6325,,0.00,0.00,200.00,0.00,300.00,0.00 - 77,王先生,136****0168,,100.00,0.00,400.00,0.00,0.00,0.00 - 78,黎先生,133****0983,,0.00,0.00,0.00,0.00,470.19,0.00 - 79,常总,185****7188,阿清(1.7h)、年糕(1.7h),460.52,0.00,0.00,0.00,0.00,0.00 - 80,张丹逸,136****6637,,100.00,0.00,0.00,0.00,339.36,0.00 - 81,陈先生,186****8238,,0.00,0.00,416.17,0.00,0.00,0.00 - 82,陈先生,138****3964,,100.00,0.00,0.00,0.00,300.00,0.00 - 83,张先生,136****4528,,298.35,0.00,100.00,0.00,0.00,0.00 - 84,小宇,187****8077,,0.00,0.00,0.00,0.00,397.50,0.00 - 85,黄先生,191****8219,,0.00,0.00,364.33,0.00,0.00,0.00 - 86,刘女士,177****7538,,0.00,0.00,0.00,0.00,362.58,0.00 - 87,魏先生,137****6862,,319.39,0.00,0.00,0.00,0.00,0.00 - 88,杜先生,188****4705,,0.00,0.00,207.47,0.00,100.00,0.00 - 89,刘先生,137****2930,,300.00,0.00,0.00,0.00,0.00,0.00 - 90,陈先生,133****6117,,0.00,0.00,300.00,0.00,0.00,0.00 - 91,潘先生,176****7964,,300.00,0.00,0.00,0.00,0.00,0.00 - 92,钟智豪,188****2803,,0.00,0.00,274.34,0.00,0.00,0.00 - 93,都先生,138****7796,,0.00,0.00,269.64,0.00,0.00,0.00 - 94,林志铭,135****4233,,0.00,0.00,267.96,0.00,0.00,0.00 - 95,方先生,158****6447,,148.00,0.00,100.00,0.00,0.00,0.00 - 96,李先生,176****5124,,0.00,0.00,0.00,0.00,244.00,0.00 - 97,钟先生,132****3438,,0.00,0.00,0.00,0.00,239.37,0.00 - 98,杨,130****5960,,232.00,0.00,0.00,0.00,0.00,0.00 - 99,黄国磊,131****3045,,100.00,0.00,100.00,0.00,25.33,0.00 - 100,周先生,159****9997,,100.00,0.00,100.00,0.00,0.00,0.00 diff --git a/etl_billiards/docs/table_2025-12-19/客户_Top100_2025年10-12月_分表.md b/etl_billiards/docs/table_2025-12-19/客户_Top100_2025年10-12月_分表.md deleted file mode 100644 index 8c2578b..0000000 --- a/etl_billiards/docs/table_2025-12-19/客户_Top100_2025年10-12月_分表.md +++ /dev/null @@ -1,199 +0,0 @@ -# 2025年10-12月 客户消费能力Top100(分表) -## 思考过程 -以台费订单为基准汇总三类明细,满足应付金额口径,并输出Top100客户的消费/充值/助教偏好。按你的要求,先生成评价为空的版本,再在脚本末尾回填评价。 - -## 查询说明 -与总表同口径;分表仅计算12月喜爱助教Top5,并展示10-12月各月消费/充值。 - -## SQL - -### Top100(按消费总额) -```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, - sum(tfl.real_table_use_seconds) as table_use_seconds - 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_info as ( - select - asl.order_settle_id, - sum(asl.ledger_amount) as assistant_amount, - 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 -), -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, - least(bo.order_start_time, coalesce(a.assistant_start_time, bo.order_start_time)) as order_start_time, - greatest(bo.order_end_time, coalesce(a.assistant_end_time, bo.order_end_time)) as order_end_time, - bo.table_use_seconds, - 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_info a on a.order_settle_id = bo.order_settle_id - left join goods_amount g on g.order_settle_id = bo.order_settle_id -) - -select - o.member_id, - sum(o.order_amount) as consume_total, - count(*) as order_cnt -from orders o -where o.member_id is not null and o.member_id <> 0 -group by o.member_id -order by consume_total desc -limit 100; -``` - -### 按月消费汇总 -```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, - sum(tfl.real_table_use_seconds) as table_use_seconds - 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_info as ( - select - asl.order_settle_id, - sum(asl.ledger_amount) as assistant_amount, - 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 -), -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, - least(bo.order_start_time, coalesce(a.assistant_start_time, bo.order_start_time)) as order_start_time, - greatest(bo.order_end_time, coalesce(a.assistant_end_time, bo.order_end_time)) as order_end_time, - bo.table_use_seconds, - 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_info a on a.order_settle_id = bo.order_settle_id - left join goods_amount g on g.order_settle_id = bo.order_settle_id -) - -, x as ( - select - 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 - where o.member_id is not null and o.member_id <> 0 -) -select - member_id, - month_key, - sum(order_amount) as consume_sum -from x -where month_key is not null -group by member_id, month_key; -``` - -### 按月充值汇总 -```sql -with 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 -) -, x as ( - select - member_id, - case when pay_time >= '2025-10-01 00:00:00+08'::timestamptz and pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when pay_time >= '2025-11-01 00:00:00+08'::timestamptz and pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when pay_time >= '2025-12-01 00:00:00+08'::timestamptz and pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key, - pay_amount - from pay -) -select - member_id, - month_key, - sum(pay_amount) as recharge_sum -from x -where month_key is not null -group by member_id, month_key; -``` - -### 喜爱助教Top5(仅12月) -```sql -with x as ( - select - asl.tenant_member_id as member_id, - asl.nickname as assistant_nickname, - sum(case when asl.order_assistant_type=1 then asl.income_seconds else asl.income_seconds*1.5 end) / 3600.0 as weighted_hours - from billiards_dwd.dwd_assistant_service_log asl - where asl.site_id = %(site_id)s - and coalesce(asl.is_delete,0)=0 - and asl.tenant_member_id is not null and asl.tenant_member_id <> 0 - and 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 - group by asl.tenant_member_id, asl.nickname -), -ranked as ( - select *, row_number() over(partition by member_id order by weighted_hours desc) as rn - from x -) -select - member_id, - string_agg(assistant_nickname || '(' || to_char(round(weighted_hours::numeric, 1), 'FM999999990.0') || 'h)', '、' order by weighted_hours desc) as fav5 -from ranked -where rn <= 5 -group by member_id; -``` diff --git a/etl_billiards/docs/table_2025-12-19/客户_Top100_2025年10-12月_总表.csv b/etl_billiards/docs/table_2025-12-19/客户_Top100_2025年10-12月_总表.csv deleted file mode 100644 index eea0105..0000000 --- a/etl_billiards/docs/table_2025-12-19/客户_Top100_2025年10-12月_总表.csv +++ /dev/null @@ -1,105 +0,0 @@ -2025年10-12月 客户消费能力Top100(总表) -"消费=台费(dwd_table_fee_log.ledger_amount)+助教(dwd_assistant_service_log.ledger_amount)+商品(dwd_store_goods_sale.ledger_amount),均为应付金额(不扣优惠),以台费订单为基准串联;充值=充值支付流水(dwd_payment.relate_type=5, pay_status=2, pay_amount>0)按支付时间切月;储值卡未使用金额=当前有效储值卡余额之和(dim_member_card_account.balance, member_card_type_name='储值卡');喜爱助教=基础课时长+附加课时长*1.5(income_seconds换算小时),总表按10-12月汇总Top5。" - -排名,客户名称,电话号码,10月-12月,10月-12月,10月-12月,当前,评价 -排名,客户名称,电话号码,喜爱助教昵称,总消费(元),总充值(元),储值卡未使用金额(元),评价 -1,轩哥,188****7530,璇子(152.6h)、七七(129.6h)、涛涛(72.7h)、小敌(54.3h)、佳怡(50.6h),153136.05,66000.00,6050.80,订单:53单,平均单次¥2889.36;打球:279.0h,平均单次5.3h;偏好:666(54.4%)、发财(13.7%)、包厢(6.5%)、A区(5.9%);时间:到店均值16:43 中位19:21;离店均值22:31 中位次日01:03;商品:荷花双中支×56(¥3808.00)、细和天下×21(¥2625.00)、100 和成天下×13(¥1495.00)、农夫山泉苏打水×211(¥1266.00)、红牛×101(¥1010.00)、双中支中华×14(¥1008.00)(商品合计¥26812.00 占比17.5%);综合:10-12月到店消费40天/53次,到店周期中位#1,消费排名#1,在店时长#3;12月到店消费8天/9次,到店周期中位#1,消费排名#1,在店时长#7;最近到店2025-12-18;趋势:10-12月到店频次下降,建议重点唤醒;围客与客户运营建议:重点维护包厢/团建需求,提前锁档与套餐化;商品贡献高,可做常购商品补货提醒与组合促销 -2,蔡总,159****8893,小柔(97.0h)、七七(72.4h)、璇子(68.2h)、涛涛(43.5h)、瑶瑶(42.8h),149839.46,5000.00,2016.18,订单:23单,平均单次¥6514.76;打球:180.4h,平均单次7.8h;偏好:发财(79.2%)、666(6.5%)、A区(4.3%)、补时长(2.8%);时间:到店均值18:05 中位20:12;离店均值次日02:58 中位次日04:48;商品:钻石荷花×100(¥4685.00)、细和天下×30(¥3750.00)、粗和天下×24(¥3000.00)、100 和成天下×20(¥2300.00)、双中支中华×31(¥2232.00)、荷花双中支×29(¥2008.00)(商品合计¥37968.00 占比25.3%);综合:10-12月到店消费22天/23次,到店周期中位#2,消费排名#2,在店时长#8;12月到店消费8天/8次,到店周期中位#1,消费排名#2,在店时长#10;最近到店2025-12-15;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:商品贡献高,可做常购商品补货提醒与组合促销 -3,葛先生,138****8071,小燕(158.3h)、阿清(27.6h)、千千(14.4h)、周周(11.0h)、年糕(9.4h),48229.33,0.00,9011.19,订单:42单,平均单次¥1148.32;打球:180.6h,平均单次4.3h;偏好:TV台(43.8%)、A区(21.2%)、包厢(20.6%)、S区/斯诺克(6.7%);时间:到店均值14:01 中位19:40;离店均值18:19 中位21:54;商品:百威235毫升×72(¥1080.00)、卡士×33(¥726.00)、风花雪月×36(¥576.00)、细荷花×7(¥370.00)、蜂蜜水×36(¥360.00)、东方树叶×39(¥312.00)(商品合计¥5432.00 占比11.3%);综合:10-12月到店消费25天/42次,到店周期中位#1,消费排名#3,在店时长#7;12月到店消费11天/24次,到店周期中位#1,消费排名#3,在店时长#2;最近到店2025-12-19;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:重点维护包厢/团建需求,提前锁档与套餐化;商品贡献高,可做常购商品补货提醒与组合促销 -4,罗先生,139****6996,佳怡(205.2h)、苏苏(19.6h)、璇子(13.2h)、周周(11.6h)、涛涛(10.5h),46573.88,10000.00,585.35,订单:86单,平均单次¥541.56;打球:212.7h,平均单次2.5h;偏好:TV台(39.2%)、C区(31.8%)、M7(7.8%)、麻将(5.8%);时间:到店均值15:24 中位18:18;离店均值18:05 中位20:27;商品:百威235毫升×94(¥1410.00)、东方树叶×39(¥312.00)、细荷花×6(¥300.00)、荷花双中支×4(¥276.00)、中支芙蓉王×6(¥228.00)、哇哈哈矿泉水×38(¥190.00)(商品合计¥4390.00 占比9.4%);综合:10-12月到店消费59天/86次,到店周期中位#1,消费排名#4,在店时长#5;12月到店消费17天/25次,到店周期中位#1,消费排名#4,在店时长#5;最近到店2025-12-18;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:商品贡献高,可做常购商品补货提醒与组合促销 -5,陈腾鑫,178****8218,阿清(79.2h)、佳怡(57.7h)、球球(34.2h)、小侯(19.1h)、千千(7.7h),40075.76,9000.00,0.00,订单:93单,平均单次¥430.92;打球:207.0h,平均单次2.2h;偏好:麻将(25.0%)、C区(18.7%)、TV台(13.6%)、包厢(11.4%);时间:到店均值17:33 中位20:09;离店均值19:45 中位22:28;商品:百威235毫升×27(¥405.00)、东方树叶×50(¥400.00)、哇哈哈矿泉水×41(¥205.00)、荷花双中支×2(¥144.00)、地道肠×27(¥135.00)、哈啤×12(¥120.00)(商品合计¥2468.00 占比6.2%);综合:10-12月到店消费49天/93次,到店周期中位#1,消费排名#5,在店时长#6;12月到店消费11天/20次,到店周期中位#1,消费排名#5,在店时长#8;最近到店2025-12-13;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:关注是否为临时充值型,建议引导储值梯度与权益;重点维护包厢/团建需求,提前锁档与套餐化;商品贡献高,可做常购商品补货提醒与组合促销 -6,江先生,188****4838,璇子(110.5h)、婉婉(16.8h)、小柔(12.0h)、Amy(6.7h)、周周(4.3h),30472.41,11000.00,0.00,订单:24单,平均单次¥1269.68;打球:65.6h,平均单次2.7h;偏好:包厢(44.5%)、888(15.3%)、M8(12.8%)、B区(10.3%);时间:到店均值16:05 中位19:47;离店均值18:53 中位21:24;商品:百威235毫升×480(¥7200.00)、风花雪月×28(¥448.00)、钻石荷花×7(¥330.00)、东方树叶×11(¥88.00)、双中支中华×1(¥72.00)、荷花双中支×1(¥68.00)(商品合计¥8943.00 占比29.3%);综合:10-12月到店消费21天/24次,到店周期中位#3,消费排名#6,在店时长#14;12月到店消费5天/6次,到店周期中位#3,消费排名#6,在店时长#18;最近到店2025-12-13;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:关注是否为临时充值型,建议引导储值梯度与权益;重点维护包厢/团建需求,提前锁档与套餐化;商品贡献高,可做常购商品补货提醒与组合促销 -7,小燕,178****1334,小燕(140.1h)、阿清(2.0h)、球球(1.4h)、Amy(1.0h)、年糕(0.5h),29888.89,0.00,1802.64,订单:62单,平均单次¥482.08;打球:148.0h,平均单次2.4h;偏好:A区(55.2%)、麻将(20.7%)、S区/斯诺克(14.7%)、补时长(4.3%);时间:到店均值15:22 中位19:05;离店均值17:50 中位21:43;商品:东方树叶×28(¥224.00)、双中支中华×2(¥144.00)、钻石荷花×2(¥90.00)、荷花双中支×1(¥68.00)、蜂蜜水×6(¥60.00)、百威235毫升×3(¥45.00)(商品合计¥863.00 占比2.9%);综合:10-12月到店消费27天/62次,到店周期中位#1,消费排名#7,在店时长#10;12月到店消费15天/30次,到店周期中位#1,消费排名#7,在店时长#3;最近到店2025-12-18;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -8,张先生,139****8852,七七(25.1h)、小侯(20.2h)、千千(14.4h)、周周(10.4h)、璇子(10.3h),26104.33,0.00,1942.41,订单:46单,平均单次¥567.49;打球:105.7h,平均单次2.3h;偏好:C区(76.3%)、666(8.8%)、麻将(5.7%)、补时长(4.8%);时间:到店均值18:43 中位18:47;离店均值21:25 中位21:12;商品:东方树叶×28(¥224.00)、哇哈哈矿泉水×41(¥205.00)、钻石荷花×3(¥135.00)、细和天下×1(¥125.00)、双中支中华×1(¥72.00)、农夫山泉苏打水×11(¥66.00)(商品合计¥1205.00 占比4.6%);综合:10-12月到店消费40天/46次,到店周期中位#1,消费排名#8,在店时长#13;12月到店消费13天/13次,到店周期中位#1,消费排名#8,在店时长#13;最近到店2025-12-18;趋势:10-12月到店频次下降,建议重点唤醒;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -9,曾巧明,186****1488,,24830.16,0.00,0.00,订单:59单,平均单次¥420.85;打球:404.3h,平均单次6.9h;偏好:B区(66.4%)、C区(32.8%)、A区(0.8%);时间:到店均值17:01 中位16:13;离店均值23:52 中位次日00:12;商品:跨越贵烟×1(¥30.00)、地道肠×4(¥20.00)、东方树叶×2(¥16.00)、可乐×2(¥10.00)、哇哈哈矿泉水×2(¥10.00)(商品合计¥86.00 占比0.3%);综合:10-12月到店消费54天/59次,到店周期中位#1,消费排名#9,在店时长#1;12月到店消费15天/16次,到店周期中位#1,消费排名#9,在店时长#1;最近到店2025-12-18;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -10,黄生,136****9719,,18406.23,0.00,0.00,订单:36单,平均单次¥511.28;打球:298.2h,平均单次8.3h;偏好:B区(64.4%)、C区(35.6%);时间:到店均值13:13 中位12:53;离店均值21:30 中位22:04;商品:地道肠×8(¥40.00)、可乐×2(¥10.00)(商品合计¥50.00 占比0.3%);综合:10-12月到店消费36天/36次,到店周期中位#1,消费排名#10,在店时长#2;12月到店消费7天/7次,到店周期中位#3,消费排名#10,在店时长#4;最近到店2025-12-18;趋势:10-12月到店频次下降,建议重点唤醒;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -11,夏,191****2851,婉婉(29.7h)、柚子(10.7h)、球球(10.6h)、佳怡(7.8h)、璇子(7.6h),16599.59,17000.00,0.00,订单:10单,平均单次¥1659.96;打球:40.5h,平均单次4.1h;偏好:888(72.1%)、TV台(22.1%)、包厢(5.8%)、补时长(0.0%);时间:到店均值18:28 中位20:36;离店均值22:43 中位次日01:10;商品:百威235毫升×247(¥3705.00)、细荷花×5(¥250.00)、荷花双中支×3(¥204.00)、清洁费150×1(¥150.00)、三只松鼠开心果×4(¥120.00)、鸡翅三个一份×6(¥108.00)(商品合计¥5162.90 占比31.1%);综合:10-12月到店消费9天/10次,到店周期中位#5,消费排名#11,在店时长#19;12月到店消费0天/0次,到店周期中位—,消费排名#11,在店时长—;最近到店2025-11-06;趋势:10-12月到店频次下降,建议重点唤醒;围客与客户运营建议:关注是否为临时充值型,建议引导储值梯度与权益;重点维护包厢/团建需求,提前锁档与套餐化;商品贡献高,可做常购商品补货提醒与组合促销 -12,叶先生,138****9539,素素(29.7h)、年糕(9.7h)、Amy(7.4h)、球球(6.7h)、婉婉(3.7h),14491.25,6307.00,0.00,订单:8单,平均单次¥1811.41;打球:27.2h,平均单次3.4h;偏好:B区(30.9%)、888(24.0%)、C区(17.8%)、包厢(16.3%);时间:到店均值18:38 中位20:59;离店均值次日00:04 中位次日02:12;商品:蓝妹×96(¥1728.00)、钻石荷花×9(¥405.00)、50 和成天下×6(¥390.00)、鸡翅三个一份×14(¥252.00)、100 和成天下×2(¥230.00)、透明袋无穷鸡翅×10(¥200.00)(商品合计¥4880.00 占比33.7%);综合:10-12月到店消费8天/8次,到店周期中位#2,消费排名#12,在店时长#27;12月到店消费2天/2次,到店周期中位#1,消费排名#12,在店时长#37;最近到店2025-12-06;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:关注是否为临时充值型,建议引导储值梯度与权益;重点维护包厢/团建需求,提前锁档与套餐化;商品贡献高,可做常购商品补货提醒与组合促销 -13,T,180****9962,佳怡(15.0h)、周周(14.7h)、乔西(11.2h)、球球(10.7h)、欣怡(10.3h),13651.06,3000.00,849.68,订单:16单,平均单次¥853.19;打球:55.6h,平均单次3.5h;偏好:麻将(50.8%)、M8(17.0%)、包厢(16.0%)、A区(9.2%);时间:到店均值18:05 中位19:34;离店均值21:23 中位22:01;商品:荷花双中支×4(¥288.00)、钻石荷花×4(¥190.00)、软荷花×3(¥174.00)、哇哈哈矿泉水×26(¥130.00)、红牛×10(¥100.00)、跨越贵烟×3(¥86.00)(商品合计¥1689.00 占比12.4%);综合:10-12月到店消费12天/16次,到店周期中位#1,消费排名#13,在店时长#16;12月到店消费5天/8次,到店周期中位#1,消费排名#13,在店时长#14;最近到店2025-12-17;趋势:12月为高峰月,具备加深运营空间;围客与客户运营建议:重点维护包厢/团建需求,提前锁档与套餐化 -14,林先生,133****1070,七七(19.4h)、佳怡(14.9h)、璇子(9.6h)、乔西(9.6h)、苏苏(4.9h),12937.86,0.00,158.79,订单:14单,平均单次¥924.13;打球:44.4h,平均单次3.2h;偏好:麻将(33.6%)、M8(31.5%)、M7(21.5%)、补时长(11.4%);时间:到店均值12:18 中位17:34;离店均值15:50 中位次日01:15;商品:荷花双中支×5(¥360.00)、细荷花×5(¥260.00)、细和天下×2(¥250.00)、钻石荷花×5(¥250.00)、双中支中华×3(¥216.00)、粗和天下×1(¥125.00)(商品合计¥2246.00 占比17.4%);综合:10-12月到店消费13天/14次,到店周期中位#1,消费排名#14,在店时长#17;12月到店消费10天/11次,到店周期中位#1,消费排名#14,在店时长#12;最近到店2025-12-13;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导;商品贡献高,可做常购商品补货提醒与组合促销 -15,曾丹烨,139****3242,,12356.33,3000.00,6639.14,订单:54单,平均单次¥228.82;打球:256.7h,平均单次4.8h;偏好:麻将(100.0%);时间:到店均值16:05 中位17:32;离店均值20:29 中位22:06;商品:合味道泡面×1(¥12.00)、地道肠×2(¥10.00)、东鹏特饮×1(¥7.00)、喜之郎果冻×1(¥5.00)(商品合计¥34.00 占比0.3%);综合:10-12月到店消费44天/54次,到店周期中位#1,消费排名#15,在店时长#4;12月到店消费9天/11次,到店周期中位#2,消费排名#15,在店时长#6;最近到店2025-12-16;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -16,胡先生,186****3391,佳怡(29.4h)、七七(4.2h)、球球(3.9h)、婉婉(3.9h)、涛涛(2.7h),11420.87,8000.00,0.00,订单:9单,平均单次¥1268.99;打球:39.8h,平均单次4.4h;偏好:包厢(44.2%)、A区(23.1%)、888(11.9%)、麻将(10.7%);时间:到店均值13:36 中位17:09;离店均值17:14 中位20:36;商品:百威235毫升×70(¥1050.00)、钻石荷花×5(¥225.00)、鸡翅三个一份×4(¥72.00)、蜂蜜水×7(¥70.00)、50 和成天下×1(¥65.00)、软荷花×1(¥58.00)(商品合计¥1900.00 占比16.6%);综合:10-12月到店消费5天/9次,到店周期中位#6,消费排名#16,在店时长#20;12月到店消费1天/1次,到店周期中位—,消费排名#16,在店时长#41;最近到店2025-12-01;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:关注是否为临时充值型,建议引导储值梯度与权益;重点维护包厢/团建需求,提前锁档与套餐化 -17,艾宇民,150****9958,泡芙(22.0h)、小侯(7.6h),10763.07,0.00,0.00,订单:44单,平均单次¥244.62;打球:112.4h,平均单次2.6h;偏好:B区(82.1%)、C区(12.7%)、包厢(5.2%);时间:到店均值16:20 中位16:06;离店均值18:50 中位18:03;商品:百威235毫升×30(¥450.00)、地道肠×13(¥65.00)、细荷花×1(¥50.00)、中支芙蓉王×1(¥38.00)、乖媳妇山椒泡爪×1(¥25.00)、哇哈哈矿泉水×5(¥25.00)(商品合计¥808.00 占比7.5%);综合:10-12月到店消费41天/44次,到店周期中位#1,消费排名#17,在店时长#12;12月到店消费8天/10次,到店周期中位#2,消费排名#17,在店时长#16;最近到店2025-12-17;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:重点维护包厢/团建需求,提前锁档与套餐化 -18,谢俊,186****5198,年糕(4.5h)、素素(2.4h),9982.86,0.00,0.00,订单:46单,平均单次¥217.02;打球:159.5h,平均单次3.5h;偏好:B区(100.0%);时间:到店均值19:31 中位20:12;离店均值22:59 中位23:48;商品:钻石荷花×1(¥45.00)(商品合计¥45.00 占比0.5%);综合:10-12月到店消费43天/46次,到店周期中位#1,消费排名#18,在店时长#9;12月到店消费4天/6次,到店周期中位#5,消费排名#18,在店时长#19;最近到店2025-12-17;趋势:10-12月到店频次下降,建议重点唤醒;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -19,周周,198****8725,周周(70.8h)、球球(15.2h)、佳怡(13.2h),8905.19,0.00,0.00,订单:10单,平均单次¥890.52;打球:35.9h,平均单次3.6h;偏好:麻将(59.3%)、M7(19.6%)、补时长(19.6%)、A区(1.5%);时间:到店均值11:40 中位14:30;离店均值17:04 中位次日00:34;商品:哇哈哈AD钙奶×13(¥104.00)、跨越贵烟×3(¥90.00)、细荷花×1(¥55.00)、红利群×2(¥52.00)、钻石荷花×1(¥50.00)、哇哈哈矿泉水×7(¥35.00)(商品合计¥685.00 占比7.7%);综合:10-12月到店消费8天/10次,到店周期中位#1,消费排名#19,在店时长#22;12月到店消费8天/10次,到店周期中位#1,消费排名#19,在店时长#11;最近到店2025-12-17;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -20,叶总,137****3287,璇子(22.0h)、小柔(3.8h)、七七(3.0h),8163.28,5700.00,0.00,订单:5单,平均单次¥1632.66;打球:23.4h,平均单次4.7h;偏好:包厢(53.5%)、888(25.5%)、麻将(12.9%)、B区(8.2%);时间:到店均值21:36 中位21:10;离店均值次日02:18 中位次日02:08;商品:百威235毫升×132(¥1980.00)、荷花双中支×3(¥204.00)、软荷花×1(¥58.00)、跨越贵烟×2(¥56.00)、细荷花×1(¥50.00)、钻石荷花×1(¥45.00)(商品合计¥2487.00 占比30.5%);综合:10-12月到店消费5天/5次,到店周期中位#2,消费排名#20,在店时长#31;12月到店消费0天/0次,到店周期中位—,消费排名#20,在店时长—;最近到店2025-10-27;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:关注是否为临时充值型,建议引导储值梯度与权益;重点维护包厢/团建需求,提前锁档与套餐化;商品贡献高,可做常购商品补货提醒与组合促销 -21,羊,187****5094,球球(5.3h)、璇子(5.0h)、素素(4.3h)、婉婉(4.3h)、Amy(4.1h),8155.54,64000.00,0.00,订单:13单,平均单次¥627.35;打球:35.7h,平均单次2.7h;偏好:麻将(64.8%)、TV台(14.7%)、B区(10.3%)、888(9.7%);时间:到店均值18:13 中位19:52;离店均值21:16 中位22:36;商品:蓝妹×54(¥972.00)、钻石荷花×4(¥180.00)、中支芙蓉王×2(¥76.00)、无穷烤小腿×3(¥60.00)、跨越贵烟×2(¥56.00)、鸡翅三个一份×3(¥54.00)(商品合计¥2072.00 占比25.4%);综合:10-12月到店消费10天/13次,到店周期中位#1,消费排名#21,在店时长#23;12月到店消费0天/0次,到店周期中位—,消费排名#21,在店时长—;最近到店2025-11-23;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:关注是否为临时充值型,建议引导储值梯度与权益;商品贡献高,可做常购商品补货提醒与组合促销 -22,游,172****6666,佳怡(13.5h)、小敌(3.6h)、璇子(3.1h)、周周(2.4h)、千千(2.2h),7797.37,0.00,0.00,订单:13单,平均单次¥599.80;打球:24.1h,平均单次1.9h;偏好:包厢(52.1%)、666(31.7%)、补时长(8.5%)、S区/斯诺克(7.7%);时间:到店均值19:13 中位18:51;离店均值21:14 中位20:36;商品:双中支中华×3(¥216.00)、红牛×17(¥170.00)、跨越贵烟×5(¥140.00)、荷花双中支×2(¥136.00)、50枸杞槟榔×2(¥130.00)、100 和成天下×1(¥115.00)(商品合计¥1406.00 占比18.0%);综合:10-12月到店消费9天/13次,到店周期中位#2,消费排名#22,在店时长#29;12月到店消费6天/9次,到店周期中位#1,消费排名#22,在店时长#27;最近到店2025-12-13;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:重点维护包厢/团建需求,提前锁档与套餐化 -23,桂先生,166****7275,球球(2.6h),7678.29,985.00,0.00,订单:21单,平均单次¥365.63;打球:117.4h,平均单次5.6h;偏好:B区(79.3%)、C区(20.7%);时间:到店均值18:37 中位19:01;离店均值次日00:12 中位次日00:13;商品:地道肠×17(¥85.00)、哇哈哈矿泉水×15(¥75.00)、可乐×13(¥65.00)、红牛×4(¥40.00)、蜂蜜水×3(¥30.00)、东方树叶×3(¥24.00)(商品合计¥373.00 占比4.9%);综合:10-12月到店消费21天/21次,到店周期中位#2,消费排名#23,在店时长#11;12月到店消费2天/2次,到店周期中位#9,消费排名#23,在店时长#26;最近到店2025-12-16;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:关注是否为临时充值型,建议引导储值梯度与权益 -24,明哥,166****0999,小柔(31.6h)、婉婉(26.7h)、涛涛(5.4h)、年糕(4.6h)、周周(0.4h),7581.04,0.00,954.64,订单:4单,平均单次¥1895.26;打球:21.1h,平均单次5.3h;偏好:包厢(43.0%)、A区(26.0%)、补时长(23.8%)、C区(5.2%);时间:到店均值10:22 中位10:15;离店均值13:40 中位13:49;商品:百威235毫升×78(¥1170.00)、硬中华×2(¥100.00)、地道肠×9(¥45.00)、东方树叶×4(¥32.00)、鱼蛋×6(¥30.00)、蜂蜜水×2(¥20.00)(商品合计¥1447.00 占比19.1%);综合:10-12月到店消费4天/4次,到店周期中位#5,消费排名#24,在店时长#35;12月到店消费3天/3次,到店周期中位#5,消费排名#24,在店时长#20;最近到店2025-12-10;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:重点维护包厢/团建需求,提前锁档与套餐化 -25,陈德韩,134****7864,乔西(9.1h)、素素(5.5h)、奈千(4.4h)、周周(4.3h)、小敌(4.0h),7302.92,5000.00,20.11,订单:4单,平均单次¥1825.73;打球:19.6h,平均单次4.9h;偏好:包厢(66.6%)、888(21.3%)、麻将(12.1%)、补时长(0.0%);时间:到店均值18:53 中位18:48;离店均值21:23 中位21:56;商品:百威235毫升×85(¥1275.00)、卡士×9(¥198.00)、无穷爱辣烤鸡爪×3(¥60.00)、鸡翅三个一份×2(¥36.00)、鱼蛋×6(¥30.00)、鱼豆腐×2(¥30.00)(商品合计¥1898.00 占比26.0%);综合:10-12月到店消费4天/4次,到店周期中位#15,消费排名#25,在店时长#38;12月到店消费1天/1次,到店周期中位—,消费排名#25,在店时长—;最近到店2025-12-01;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导;重点维护包厢/团建需求,提前锁档与套餐化 -26,小熊,139****0145,佳怡(13.2h)、周周(10.7h)、欣怡(7.9h)、球球(4.4h)、七七(1.3h),7135.88,5000.00,0.00,订单:9单,平均单次¥792.88;打球:32.7h,平均单次3.6h;偏好:麻将(82.3%)、包厢(9.2%)、TV台(8.5%)、补时长(0.0%);时间:到店均值14:59 中位18:25;离店均值19:25 中位23:36;商品:软荷花×3(¥174.00)、100 和成天下×1(¥115.00)、中支芙蓉王×3(¥114.00)、钻石荷花×2(¥90.00)、炫赫门小南京×3(¥78.00)、荷花双中支×1(¥68.00)(商品合计¥1223.00 占比17.1%);综合:10-12月到店消费6天/9次,到店周期中位#2,消费排名#26,在店时长#25;12月到店消费0天/0次,到店周期中位—,消费排名#26,在店时长—;最近到店2025-11-05;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:关注是否为临时充值型,建议引导储值梯度与权益;重点维护包厢/团建需求,提前锁档与套餐化 -27,黄先生,135****3507,苏苏(30.8h)、千千(13.1h)、乔西(1.6h)、阿清(0.7h),7052.72,3000.00,1639.43,订单:22单,平均单次¥320.58;打球:39.4h,平均单次1.8h;偏好:B区(80.5%)、A区(17.0%)、C区(2.2%)、补时长(0.4%);时间:到店均值18:32 中位19:27;离店均值20:30 中位21:28;商品:东方树叶×6(¥48.00)、钻石荷花×1(¥45.00)、哇哈哈AD钙奶×4(¥32.00)、东鹏特饮×3(¥21.00)、无穷烤小腿×1(¥20.00)、综合蔬果干×1(¥15.00)(商品合计¥225.00 占比3.2%);综合:10-12月到店消费20天/22次,到店周期中位#3,消费排名#27,在店时长#21;12月到店消费7天/7次,到店周期中位#2,消费排名#27,在店时长#22;最近到店2025-12-16;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -28,吕先生,155****0663,小柔(7.5h)、周周(3.7h)、素素(2.8h)、婉婉(2.8h)、苏苏(2.8h),7012.05,6000.00,0.00,订单:4单,平均单次¥1753.01;打球:17.0h,平均单次4.2h;偏好:666(66.5%)、888(18.2%)、麻将(15.3%);时间:到店均值14:20 中位18:05;离店均值18:34 中位21:28;商品:蓝妹×35(¥630.00)、软中华×3(¥210.00)、红牛×17(¥170.00)、软荷花×2(¥116.00)、鸡翅三个一份×4(¥72.00)、地道肠×10(¥50.00)(商品合计¥1819.00 占比25.9%);综合:10-12月到店消费4天/4次,到店周期中位#1,消费排名#28,在店时长#41;12月到店消费0天/0次,到店周期中位—,消费排名#28,在店时长—;最近到店2025-10-20;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:关注是否为临时充值型,建议引导储值梯度与权益 -29,郑先生,159****4331,小敌(32.1h),6438.07,0.00,0.00,订单:16单,平均单次¥402.38;打球:42.2h,平均单次2.6h;偏好:C区(63.7%)、补时长(14.4%)、B区(12.9%)、A区(9.0%);时间:到店均值15:29 中位20:24;离店均值19:22 中位次日00:03;商品:农夫山泉苏打水×8(¥48.00)、蜂蜜水×4(¥40.00)、地道肠×7(¥35.00)、一次性手套×5(¥10.00)、东方树叶×1(¥8.00)、哇哈哈矿泉水×1(¥5.00)(商品合计¥156.00 占比2.4%);综合:10-12月到店消费13天/16次,到店周期中位#1,消费排名#29,在店时长#18;12月到店消费5天/7次,到店周期中位#1,消费排名#29,在店时长#25;最近到店2025-12-12;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -30,歌神,188****2164,婉婉(6.7h)、希希(4.0h)、素素(3.9h)、小柔(3.8h)、年糕(2.6h),5877.65,5000.00,0.00,订单:4单,平均单次¥1469.41;打球:12.8h,平均单次3.2h;偏好:888(43.0%)、包厢(41.0%)、麻将(16.0%);时间:到店均值22:20 中位22:39;离店均值次日01:34 中位次日01:19;商品:百威235毫升×90(¥1350.00)、鸡翅三个一份×5(¥90.00)、焦糖瓜子×3(¥45.00)、鱼蛋×9(¥45.00)、三只松鼠开心果×1(¥30.00)、地道肠×6(¥30.00)(商品合计¥1687.00 占比28.7%);综合:10-12月到店消费4天/4次,到店周期中位#4,消费排名#30,在店时长#46;12月到店消费0天/0次,到店周期中位—,消费排名#30,在店时长—;最近到店2025-10-24;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:关注是否为临时充值型,建议引导储值梯度与权益;重点维护包厢/团建需求,提前锁档与套餐化 -31,罗先生,139****9222,婉婉(18.8h)、年糕(7.7h)、小柔(4.5h)、素素(4.3h)、姜姜(1.5h),5831.48,3000.00,310.31,订单:5单,平均单次¥1166.30;打球:20.0h,平均单次4.0h;偏好:包厢(72.1%)、888(17.8%)、补时长(10.2%);时间:到店均值16:46 中位21:04;离店均值次日01:10 中位次日00:07;商品:科罗娜啤酒275ml×26(¥468.00)、蓝妹×18(¥324.00)、鸡翅三个一份×2(¥36.00)、三只松鼠开心果×1(¥30.00)、地道肠×5(¥25.00)、焦糖瓜子×1(¥15.00)(商品合计¥924.00 占比15.8%);综合:10-12月到店消费5天/5次,到店周期中位#14,消费排名#31,在店时长#37;12月到店消费0天/0次,到店周期中位—,消费排名#31,在店时长—;最近到店2025-11-27;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导;重点维护包厢/团建需求,提前锁档与套餐化 -32,大G,186****4598,周周(17.7h)、佳怡(9.5h)、球球(1.9h),5374.68,0.00,0.00,订单:5单,平均单次¥1074.94;打球:21.6h,平均单次4.3h;偏好:麻将(47.3%)、M7(33.2%)、A区(19.4%)、补时长(0.1%);时间:到店均值17:16 中位20:28;离店均值21:48 中位次日00:04;商品:荷花双中支×2(¥144.00)、哇哈哈AD钙奶×9(¥72.00)、无穷烤小腿×3(¥60.00)、芙蓉王×2(¥56.00)、红利群×2(¥52.00)、蜂蜜水×4(¥40.00)(商品合计¥748.00 占比13.9%);综合:10-12月到店消费5天/5次,到店周期中位#1,消费排名#32,在店时长#34;12月到店消费4天/4次,到店周期中位#1,消费排名#32,在店时长#24;最近到店2025-12-07;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -33,林先生,137****8785,小侯(9.7h)、梦梦(4.3h)、千千(2.7h)、瑶瑶(1.9h)、周周(0.7h),4967.38,0.00,0.00,订单:7单,平均单次¥709.63;打球:18.7h,平均单次2.7h;偏好:C区(76.5%)、包厢(23.4%)、补时长(0.0%);时间:到店均值17:58 中位19:48;离店均值20:49 中位23:39;商品:百威235毫升×30(¥450.00)、50枸杞槟榔×1(¥65.00)、东方树叶×5(¥40.00)、蜂蜜水×4(¥40.00)、哇哈哈矿泉水×7(¥35.00)、酒鬼花生×4(¥32.00)(商品合计¥887.00 占比17.9%);综合:10-12月到店消费6天/7次,到店周期中位#3,消费排名#33,在店时长#40;12月到店消费2天/2次,到店周期中位#4,消费排名#33,在店时长#34;最近到店2025-12-06;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:重点维护包厢/团建需求,提前锁档与套餐化 -34,梅,136****4552,千千(16.6h)、阿清(10.8h)、小侯(4.7h)、小燕(3.8h),4590.92,0.00,2050.00,订单:8单,平均单次¥573.86;打球:20.4h,平均单次2.5h;偏好:麻将(77.0%)、C区(12.1%)、补时长(10.8%);时间:到店均值14:47 中位20:54;离店均值20:02 中位23:31;商品:硬中华×1(¥50.00)、轻上椰子水×2(¥24.00)、哇哈哈矿泉水×2(¥10.00)(商品合计¥84.00 占比1.8%);综合:10-12月到店消费7天/8次,到店周期中位#5,消费排名#34,在店时长#36;12月到店消费5天/5次,到店周期中位#5,消费排名#34,在店时长#23;最近到店2025-12-19;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -35,李先生,134****4343,小侯(9.3h)、柚子(7.8h)、球球(0.0h),4479.77,0.00,2433.01,订单:8单,平均单次¥559.97;打球:32.1h,平均单次4.0h;偏好:C区(73.4%)、包厢(26.6%);时间:到店均值19:34 中位20:19;离店均值23:35 中位23:13;商品:热水可续杯×13(¥39.00)、农夫山泉苏打水×5(¥30.00)、水果脆×1(¥30.00)、跨越贵烟×1(¥30.00)、哇哈哈矿泉水×4(¥20.00)、水溶C×1(¥8.00)(商品合计¥185.00 占比4.1%);综合:10-12月到店消费8天/8次,到店周期中位#3,消费排名#35,在店时长#26;12月到店消费5天/5次,到店周期中位#3,消费排名#35,在店时长#17;最近到店2025-12-18;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:重点维护包厢/团建需求,提前锁档与套餐化 -36,陶,189****2151,欣怡(4.9h)、球球(4.7h)、周周(4.4h)、七七(4.2h)、佳怡(4.1h),4096.07,6000.00,8.82,订单:7单,平均单次¥585.15;打球:21.7h,平均单次3.1h;偏好:麻将(61.0%)、A区(13.3%)、包厢(9.7%)、C区(8.1%);时间:到店均值20:49 中位21:49;离店均值23:55 中位次日01:19;商品:荷花双中支×1(¥68.00)、红牛×5(¥50.00)、轻上椰子水×4(¥48.00)、哇哈哈矿泉水×8(¥40.00)、软玉溪×1(¥28.00)、炫赫门小南京×1(¥26.00)(商品合计¥399.00 占比9.7%);综合:10-12月到店消费6天/7次,到店周期中位#2,消费排名#36,在店时长#33;12月到店消费0天/0次,到店周期中位—,消费排名#36,在店时长—;最近到店2025-10-26;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导;重点维护包厢/团建需求,提前锁档与套餐化 -37,陈先生,159****2829,佳怡(7.6h)、奈千(5.1h)、柚子(4.4h)、乔西(4.2h)、Amy(4.2h),3817.58,3000.00,0.55,订单:3单,平均单次¥1272.53;打球:7.6h,平均单次2.5h;偏好:麻将(54.5%)、TV台(45.4%)、补时长(0.1%)、A区(0.0%);时间:到店均值13:21 中位19:06;离店均值18:07 中位次日00:40;商品:百威235毫升×10(¥150.00)、钻石荷花×1(¥45.00)、跨越贵烟×1(¥28.00)、无穷爱辣烤鸡爪×1(¥20.00)、白桦树汁×1(¥12.00)、椰汁×1(¥8.00)(商品合计¥277.00 占比7.3%);综合:10-12月到店消费3天/3次,到店周期中位#19,消费排名#37,在店时长#57;12月到店消费0天/0次,到店周期中位—,消费排名#37,在店时长—;最近到店2025-11-07;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导 -38,候,131****0323,球球(5.3h)、阿清(4.3h)、小侯(3.4h)、涛涛(3.1h)、乔西(2.9h),3765.88,0.00,0.00,订单:8单,平均单次¥470.74;打球:22.0h,平均单次2.7h;偏好:TV台(66.3%)、A区(28.3%)、C区(5.4%);时间:到店均值20:08 中位19:43;离店均值22:53 中位22:54;商品:冰红茶×8(¥48.00)、地道肠×4(¥20.00)、鱼蛋×4(¥20.00)、可乐×2(¥10.00)、哇米诺豆奶×1(¥10.00)、红牛×1(¥10.00)(商品合计¥161.00 占比4.3%);综合:10-12月到店消费5天/8次,到店周期中位#1,消费排名#38,在店时长#32;12月到店消费5天/8次,到店周期中位#1,消费排名#38,在店时长#15;最近到店2025-12-17;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -39,黄先生,158****2109,球球(64.0h)、QQ(6.9h),3568.92,3000.00,420.01,订单:10单,平均单次¥356.89;打球:23.4h,平均单次2.3h;偏好:A区(60.1%)、包厢(27.0%)、补时长(12.9%);时间:到店均值04:58 中位01:43;离店均值06:06 中位03:20;商品:蓝妹×4(¥72.00)、跨越贵烟×1(¥28.00)、火腿肠×2(¥10.00)、东方树叶×1(¥8.00)、卫龙魔芋爽×1(¥8.00)、农夫山泉苏打水×1(¥6.00)(商品合计¥142.00 占比4.0%);综合:10-12月到店消费8天/10次,到店周期中位#4,消费排名#39,在店时长#30;12月到店消费3天/4次,到店周期中位#8,消费排名#39,在店时长#45;最近到店2025-12-17;趋势:12月为高峰月,具备加深运营空间;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导;重点维护包厢/团建需求,提前锁档与套餐化 -40,孟紫龙,176****3741,,3492.73,0.00,0.00,订单:13单,平均单次¥268.67;打球:57.6h,平均单次4.4h;偏好:B区(100.0%);时间:到店均值18:44 中位18:50;离店均值23:10 中位23:35;商品:哇哈哈矿泉水×9(¥45.00)、东方树叶×5(¥40.00)、地道肠×7(¥35.00)、可乐×2(¥10.00)、维他柠檬茶×1(¥8.00)、脉动×1(¥8.00)(商品合计¥153.00 占比4.4%);综合:10-12月到店消费12天/13次,到店周期中位#1,消费排名#40,在店时长#15;12月到店消费10天/11次,到店周期中位#1,消费排名#40,在店时长#9;最近到店2025-12-18;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -41,罗超,137****0990,球球(2.9h)、璇子(2.7h)、苏苏(2.6h)、奈千(2.5h),3398.81,3000.00,101.19,订单:2单,平均单次¥1699.40;打球:7.3h,平均单次3.7h;偏好:888(78.8%)、麻将(21.2%);时间:到店均值20:57 中位20:57;离店均值次日00:37 中位次日00:37;商品:科罗娜啤酒275ml×49(¥882.00)、荷花双中支×1(¥68.00)、百威235毫升×3(¥45.00)、掼蛋扑克×4(¥32.00)、跨越贵烟×1(¥28.00)、东方树叶×3(¥24.00)(商品合计¥1115.00 占比32.8%);综合:10-12月到店消费2天/2次,到店周期中位#16,消费排名#41,在店时长#59;12月到店消费0天/0次,到店周期中位—,消费排名#41,在店时长—;最近到店2025-10-24;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导 -42,君姐,166****4594,年糕(8.2h)、婉婉(4.3h)、璇子(2.3h)、涛涛(2.2h),3361.95,0.00,272.15,订单:3单,平均单次¥1120.65;打球:12.5h,平均单次4.2h;偏好:666(30.5%)、M8(25.3%)、M7(17.7%)、包厢(13.9%);时间:到店均值15:38 中位16:21;离店均值20:33 中位21:15;商品:哇哈哈矿泉水×20(¥100.00)、卡士×2(¥44.00)、东方树叶×5(¥40.00)、麻将房茶位费×1(¥40.00)、小果盘×1(¥37.90)、软玉溪×1(¥28.00)(商品合计¥319.90 占比9.5%);综合:10-12月到店消费3天/3次,到店周期中位#5,消费排名#42,在店时长#47;12月到店消费1天/1次,到店周期中位—,消费排名#42,在店时长#31;最近到店2025-12-02;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导;重点维护包厢/团建需求,提前锁档与套餐化 -43,吴生,136****3341,小柔(2.8h)、涛涛(2.2h),3253.70,0.00,3680.65,订单:15单,平均单次¥216.91;打球:34.3h,平均单次2.3h;偏好:C区(86.1%)、B区(7.0%)、包厢(6.7%)、补时长(0.1%);时间:到店均值19:01 中位18:43;离店均值21:14 中位21:25;商品:哇哈哈矿泉水×18(¥90.00)、双中支中华×1(¥72.00)、阿萨姆×1(¥8.00)(商品合计¥170.00 占比5.2%);综合:10-12月到店消费12天/15次,到店周期中位#6,消费排名#43,在店时长#24;12月到店消费2天/3次,到店周期中位#5,消费排名#43,在店时长#35;最近到店2025-12-16;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:重点维护包厢/团建需求,提前锁档与套餐化 -44,刘哥,135****0020,婉婉(5.3h)、球球(2.1h),3036.80,0.00,371.51,订单:2单,平均单次¥1518.40;打球:5.0h,平均单次2.5h;偏好:包厢(93.4%)、S区/斯诺克(6.6%)、补时长(0.0%);时间:到店均值11:33 中位11:33;离店均值12:15 中位12:15;商品:百威235毫升×79(¥1185.00)、中支芙蓉王×2(¥76.00)、地道肠×6(¥30.00)、鱼蛋×6(¥30.00)、红利群×1(¥26.00)、红烧牛肉面×2(¥24.00)(商品合计¥1417.00 占比46.7%);综合:10-12月到店消费2天/2次,到店周期中位#20,消费排名#44,在店时长#66;12月到店消费1天/1次,到店周期中位—,消费排名#44,在店时长#49;最近到店2025-12-17;趋势:12月为高峰月,具备加深运营空间;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导;重点维护包厢/团建需求,提前锁档与套餐化 -45,李先生,131****4000,小敌(11.8h)、涛涛(2.1h)、Amy(1.1h),2997.53,3000.00,563.47,订单:4单,平均单次¥749.38;打球:11.8h,平均单次3.0h;偏好:包厢(100.0%);时间:到店均值16:24 中位20:21;离店均值19:21 中位23:11;商品:轻上椰子水×10(¥120.00)、科罗娜啤酒275ml×6(¥108.00)、跨越贵烟×1(¥28.00)、地道肠×2(¥10.00)、海之言×1(¥8.00)、茶兀×1(¥8.00)(商品合计¥298.00 占比9.9%);综合:10-12月到店消费3天/4次,到店周期中位#5,消费排名#45,在店时长#48;12月到店消费0天/0次,到店周期中位—,消费排名#45,在店时长—;最近到店2025-11-07;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:重点维护包厢/团建需求,提前锁档与套餐化 -46,阿亮,159****2628,涛涛(9.1h)、素素(3.1h)、奈千(2.9h)、梦梦(2.7h)、柚子(2.4h),2936.26,0.00,612.33,订单:8单,平均单次¥367.03;打球:16.8h,平均单次2.1h;偏好:B区(65.3%)、S区/斯诺克(34.5%)、补时长(0.2%);时间:到店均值21:06 中位20:32;离店均值23:26 中位23:29;商品:哇哈哈矿泉水×4(¥20.00)、香飘飘果汁茶×1(¥10.00)、茶兀×1(¥8.00)(商品合计¥38.00 占比1.3%);综合:10-12月到店消费6天/8次,到店周期中位#1,消费排名#46,在店时长#43;12月到店消费2天/3次,到店周期中位#1,消费排名#46,在店时长#29;最近到店2025-12-04;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -47,李先生,186****8308,小侯(5.6h)、年糕(4.2h),2785.23,0.00,0.00,订单:1单,平均单次¥2785.23;打球:8.3h,平均单次8.3h;偏好:包厢(100.0%);时间:到店均值23:15 中位23:15;离店均值次日07:32 中位次日07:32;商品:清洁费150×1(¥150.00)、卡士×1(¥22.00)、合味道泡面×1(¥12.00)、轻上椰子水×1(¥12.00)、雪碧×2(¥10.00)、哇哈哈矿泉水×1(¥5.00)(商品合计¥216.00 占比7.8%);综合:10-12月到店消费1天/1次,到店周期中位—,消费排名#47,在店时长#55;12月到店消费0天/0次,到店周期中位—,消费排名#47,在店时长—;最近到店2025-11-28;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:重点维护包厢/团建需求,提前锁档与套餐化 -48,周先生,173****7775,乔西(7.5h)、小敌(6.6h),2726.01,0.00,0.00,订单:1单,平均单次¥2726.01;打球:7.5h,平均单次7.5h;偏好:666(100.0%);时间:到店均值15:40 中位15:40;离店均值23:11 中位23:11;商品:哇哈哈矿泉水×1(¥5.00)(商品合计¥5.00 占比0.2%);综合:10-12月到店消费1天/1次,到店周期中位—,消费排名#48,在店时长#58;12月到店消费0天/0次,到店周期中位—,消费排名#48,在店时长—;最近到店2025-10-25;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -49,林先生,159****0021,婉婉(12.0h)、小柔(3.2h)、苏苏(3.1h),2690.52,0.00,49.48,订单:2单,平均单次¥1345.26;打球:6.0h,平均单次3.0h;偏好:包厢(66.7%)、A区(33.3%);时间:到店均值10:13 中位10:13;离店均值12:14 中位12:14;商品:百威235毫升×24(¥360.00)、中支芙蓉王×2(¥76.00)、绿茶×4(¥24.00)、无穷爱辣烤鸡爪×1(¥20.00)、透明袋无穷鸡翅×1(¥20.00)、益达×1(¥18.00)(商品合计¥597.00 占比22.2%);综合:10-12月到店消费2天/2次,到店周期中位#6,消费排名#49,在店时长#62;12月到店消费0天/0次,到店周期中位—,消费排名#49,在店时长—;最近到店2025-11-25;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导;重点维护包厢/团建需求,提前锁档与套餐化 -50,周先生,193****6822,千千(8.6h)、素素(6.2h),2643.64,0.00,2092.01,订单:3单,平均单次¥881.21;打球:14.9h,平均单次5.0h;偏好:C区(100.0%);时间:到店均值21:06 中位22:21;离店均值次日02:04 中位次日02:07;商品:哇哈哈矿泉水×5(¥25.00)、卡士×1(¥22.00)、东方树叶×2(¥16.00)、王老吉×1(¥8.00)、美汁源果粒橙×1(¥8.00)、一次性拖鞋×1(¥5.00)(商品合计¥89.00 占比3.4%);综合:10-12月到店消费3天/3次,到店周期中位#4,消费排名#50,在店时长#44;12月到店消费3天/3次,到店周期中位#4,消费排名#50,在店时长#21;最近到店2025-12-13;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -51,林先生,188****0332,周周(4.0h)、小敌(1.9h),2612.01,0.00,0.00,订单:8单,平均单次¥326.50;打球:16.9h,平均单次2.1h;偏好:666(25.1%)、麻将(22.3%)、M7(20.7%)、S区/斯诺克(12.8%);时间:到店均值14:55 中位17:06;离店均值17:17 中位19:13;商品:钻石荷花×3(¥135.00)、50枸杞槟榔×1(¥65.00)、跨越贵烟×1(¥28.00)、哇哈哈矿泉水×5(¥25.00)、红牛×2(¥20.00)、蜂蜜水×2(¥20.00)(商品合计¥330.00 占比12.6%);综合:10-12月到店消费6天/8次,到店周期中位#1,消费排名#51,在店时长#42;12月到店消费0天/0次,到店周期中位—,消费排名#51,在店时长—;最近到店2025-11-28;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -52,牛先生,152****5159,柚子(10.4h),2187.48,0.00,0.00,订单:5单,平均单次¥437.50;打球:10.4h,平均单次2.1h;偏好:C区(99.8%)、补时长(0.2%)、A区(0.0%)、B区(0.0%);时间:到店均值19:00 中位19:37;离店均值21:29 中位20:52;商品:地道肠×6(¥30.00)、东方树叶×2(¥16.00)、美汁源果粒橙×2(¥16.00)(商品合计¥62.00 占比2.8%);综合:10-12月到店消费3天/5次,到店周期中位#1,消费排名#52,在店时长#51;12月到店消费0天/0次,到店周期中位—,消费排名#52,在店时长—;最近到店2025-11-24;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -53,孟紫龙(该会员已注销),176****37411,,2131.72,0.00,0.00,订单:7单,平均单次¥304.53;打球:26.3h,平均单次3.8h;偏好:C区(99.9%)、补时长(0.1%);时间:到店均值19:17 中位19:34;离店均值23:32 中位23:56;商品:可乐×5(¥25.00)、东鹏特饮×2(¥14.00)、鱼蛋×1(¥5.00)、一次性手套×1(¥2.00)(商品合计¥46.00 占比2.2%);综合:10-12月到店消费7天/7次,到店周期中位#4,消费排名#53,在店时长#28;12月到店消费0天/0次,到店周期中位—,消费排名#53,在店时长—;最近到店2025-11-28;趋势:10-12月到店频次下降,建议重点唤醒;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -54,罗超杰,137****8012,苏苏(2.1h)、素素(1.9h)、周周(1.2h)、球球(0.8h),1584.05,0.00,3037.00,订单:8单,平均单次¥198.01;打球:8.4h,平均单次1.0h;偏好:包厢(74.8%)、B区(14.0%)、A区(10.9%)、补时长(0.2%);时间:到店均值18:55 中位22:56;离店均值20:06 中位23:23;商品:雪碧×4(¥20.00)、可乐×3(¥15.00)、维他柠檬茶×1(¥8.00)、打火机×1(¥2.00)(商品合计¥45.00 占比2.8%);综合:10-12月到店消费6天/8次,到店周期中位#3,消费排名#54,在店时长#54;12月到店消费0天/0次,到店周期中位—,消费排名#54,在店时长—;最近到店2025-11-05;趋势:10-12月到店频次下降,建议重点唤醒;围客与客户运营建议:重点维护包厢/团建需求,提前锁档与套餐化 -55,汪先生,139****6339,姜姜(9.6h),1390.07,1000.00,11.99,订单:4单,平均单次¥347.52;打球:5.1h,平均单次1.3h;偏好:包厢(82.3%)、A区(17.4%)、补时长(0.4%);时间:到店均值21:16 中位22:01;离店均值23:26 中位23:25;商品:轻上椰子水×1(¥12.00)、三得利×1(¥8.00)、巧乐兹伊利×1(¥8.00)(商品合计¥28.00 占比2.0%);综合:10-12月到店消费3天/4次,到店周期中位#1,消费排名#55,在店时长#65;12月到店消费0天/0次,到店周期中位—,消费排名#55,在店时长—;最近到店2025-10-09;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导;重点维护包厢/团建需求,提前锁档与套餐化 -56,桂先生(该会员已注销),166****72751,,1370.81,0.00,0.00,订单:5单,平均单次¥274.16;打球:19.0h,平均单次3.8h;偏好:C区(100.0%);时间:到店均值19:20 中位19:37;离店均值23:08 中位23:57;商品:红牛×4(¥40.00)、东鹏特饮×2(¥14.00)、可乐×2(¥10.00)、地道肠×2(¥10.00)、普通扑克×1(¥5.00)(商品合计¥79.00 占比5.8%);综合:10-12月到店消费5天/5次,到店周期中位#2,消费排名#56,在店时长#39;12月到店消费0天/0次,到店周期中位—,消费排名#56,在店时长—;最近到店2025-10-16;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -57,方先生,153****3185,乔西(3.2h),1313.30,1000.00,0.00,订单:3单,平均单次¥437.77;打球:10.2h,平均单次3.4h;偏好:麻将(69.0%)、666(31.0%);时间:到店均值17:32 中位17:19;离店均值21:01 中位20:30;商品:农夫山泉苏打水×5(¥30.00)、掼蛋扑克×2(¥16.00)、可乐×3(¥15.00)、普通扑克×2(¥10.00)、红牛×1(¥10.00)、椰汁×1(¥8.00)(商品合计¥100.00 占比7.6%);综合:10-12月到店消费3天/3次,到店周期中位#10,消费排名#57,在店时长#52;12月到店消费0天/0次,到店周期中位—,消费排名#57,在店时长—;最近到店2025-11-17;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:关注是否为临时充值型,建议引导储值梯度与权益 -58,陈淑涛,132****5485,涛涛(4.4h)、乔西(3.4h),1276.77,0.00,0.00,订单:3单,平均单次¥425.59;打球:4.4h,平均单次1.5h;偏好:麻将(77.1%)、A区(22.9%)、补时长(0.0%);时间:到店均值12:52 中位09:40;离店均值14:39 中位10:40;商品:细荷花×1(¥50.00)、轻上椰子水×1(¥12.00)、哇哈哈矿泉水×2(¥10.00)、火鸡面×1(¥10.00)、茶兀×1(¥8.00)、火腿肠×1(¥5.00)(商品合计¥99.00 占比7.8%);综合:10-12月到店消费2天/3次,到店周期中位#7,消费排名#58,在店时长#69;12月到店消费0天/0次,到店周期中位—,消费排名#58,在店时长—;最近到店2025-11-22;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -59,清,130****3087,小侯(3.0h)、阿清(3.0h)、千千(3.0h),1128.06,0.00,1944.76,订单:1单,平均单次¥1128.06;打球:3.0h,平均单次3.0h;偏好:麻将(100.0%);时间:到店均值21:18 中位21:18;离店均值次日02:00 中位次日02:00;综合:10-12月到店消费1天/1次,到店周期中位—,消费排名#59,在店时长#73;12月到店消费1天/1次,到店周期中位—,消费排名#59,在店时长#38;最近到店2025-12-08;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -60,amy,137****8221,Amy(4.8h),1105.90,0.00,0.38,订单:1单,平均单次¥1105.90;打球:4.8h,平均单次4.8h;偏好:麻将(100.0%);时间:到店均值22:47 中位22:47;离店均值次日03:37 中位次日03:37;商品:跨越贵烟×2(¥60.00)、掼蛋扑克×2(¥16.00)、热水可续杯×4(¥12.00)、可乐×2(¥10.00)、蜂蜜水×1(¥10.00)(商品合计¥108.00 占比9.8%);综合:10-12月到店消费1天/1次,到店周期中位—,消费排名#60,在店时长#67;12月到店消费1天/1次,到店周期中位—,消费排名#60,在店时长#32;最近到店2025-12-06;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导 -61,曾先生,133****1235,奈千(1.0h),991.34,0.00,303.19,订单:7单,平均单次¥141.62;打球:13.0h,平均单次1.9h;偏好:S区/斯诺克(63.2%)、A区(36.8%);时间:到店均值13:58 中位12:19;离店均值15:49 中位14:10;商品:咖啡代购×3(¥45.00)、东方树叶×3(¥24.00)、屈臣氏苏打水×1(¥8.00)、阿萨姆×1(¥8.00)、绿茶×1(¥6.00)、哇哈哈矿泉水×1(¥5.00)(商品合计¥98.00 占比9.9%);综合:10-12月到店消费7天/7次,到店周期中位#6,消费排名#61,在店时长#45;12月到店消费2天/2次,到店周期中位#6,消费排名#61,在店时长#36;最近到店2025-12-10;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导 -62,昌哥,137****1229,Amy(2.0h)、小柔(1.8h)、苏苏(1.7h),942.42,0.00,2471.98,订单:2单,平均单次¥471.21;打球:4.5h,平均单次2.3h;偏好:A区(100.0%);时间:到店均值20:05 中位20:05;离店均值22:21 中位22:21;商品:农夫山泉苏打水×3(¥18.00)、麻辣王子×1(¥12.00)、哇哈哈矿泉水×2(¥10.00)、营养快线×1(¥8.00)、阿萨姆×1(¥8.00)(商品合计¥56.00 占比5.9%);综合:10-12月到店消费2天/2次,到店周期中位#15,消费排名#62,在店时长#68;12月到店消费1天/1次,到店周期中位—,消费排名#62,在店时长#44;最近到店2025-12-07;趋势:12月为高峰月,具备加深运营空间;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -63,李,131****9882,,927.44,0.00,0.00,订单:11单,平均单次¥84.31;打球:11.1h,平均单次1.0h;偏好:B区(68.7%)、A区(30.9%)、补时长(0.4%);时间:到店均值13:13 中位13:14;离店均值14:13 中位14:00;商品:哇哈哈矿泉水×4(¥20.00)(商品合计¥20.00 占比2.2%);综合:10-12月到店消费6天/11次,到店周期中位#8,消费排名#63,在店时长#49;12月到店消费0天/0次,到店周期中位—,消费排名#63,在店时长—;最近到店2025-11-24;趋势:10-12月到店频次下降,建议重点唤醒;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -64,邓飛,136****9597,婉婉(6.8h)、苏苏(6.0h)、小敌(4.5h)、小柔(1.2h)、球球(0.8h),925.47,2345.00,74.77,订单:1单,平均单次¥925.47;打球:1.9h,平均单次1.9h;偏好:包厢(100.0%);时间:到店均值01:56 中位01:56;离店均值03:48 中位03:48;商品:百威235毫升×12(¥180.00)、卡士×1(¥22.00)、农夫山泉苏打水×3(¥18.00)、一次性拖鞋×1(¥5.00)、哇哈哈矿泉水×1(¥5.00)(商品合计¥230.00 占比24.9%);综合:10-12月到店消费1天/1次,到店周期中位—,消费排名#64,在店时长#85;12月到店消费0天/0次,到店周期中位—,消费排名#64,在店时长—;最近到店2025-11-09;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导;重点维护包厢/团建需求,提前锁档与套餐化 -65,陈世,134****1938,瑶瑶(0.8h),921.09,0.00,0.00,订单:6单,平均单次¥153.52;打球:6.5h,平均单次1.1h;偏好:C区(49.7%)、S区/斯诺克(49.6%)、补时长(0.7%);时间:到店均值20:42 中位21:08;离店均值22:16 中位22:24;综合:10-12月到店消费3天/6次,到店周期中位#24,消费排名#65,在店时长#61;12月到店消费0天/0次,到店周期中位—,消费排名#65,在店时长—;最近到店2025-11-20;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -66,婉婉,183****2742,婉婉(4.3h),867.49,1000.00,514.08,订单:2单,平均单次¥433.74;打球:4.4h,平均单次2.2h;偏好:B区(36.5%)、A区(35.9%)、888(27.6%);时间:到店均值15:41 中位15:41;离店均值18:01 中位18:01;商品:旺仔牛奶×2(¥20.00)、红牛×1(¥10.00)、王老吉×1(¥8.00)、哇哈哈矿泉水×1(¥5.00)、喜之郎果冻×1(¥5.00)(商品合计¥48.00 占比5.5%);综合:10-12月到店消费2天/2次,到店周期中位#23,消费排名#66,在店时长#70;12月到店消费0天/0次,到店周期中位—,消费排名#66,在店时长—;最近到店2025-11-21;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -67,贺斌,150****0885,佳怡(1.0h),770.56,0.00,0.00,订单:4单,平均单次¥192.64;打球:9.6h,平均单次2.4h;偏好:A区(50.1%)、C区(49.9%);时间:到店均值17:30 中位17:55;离店均值19:53 中位19:54;商品:细荷花×1(¥50.00)、可乐×5(¥25.00)、哇哈哈矿泉水×2(¥10.00)、地道肠×2(¥10.00)、东方树叶×1(¥8.00)(商品合计¥103.00 占比13.4%);综合:10-12月到店消费3天/4次,到店周期中位#4,消费排名#67,在店时长#53;12月到店消费0天/0次,到店周期中位—,消费排名#67,在店时长—;最近到店2025-11-03;趋势:10-12月到店频次下降,建议重点唤醒;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -68,陈泽斌,132****6060,,700.00,0.00,0.00,订单:6单,平均单次¥116.67;打球:0.1h,平均单次0.0h;偏好:补时长(100.0%);时间:到店均值17:51 中位20:40;离店均值18:50 中位21:39;综合:10-12月到店消费6天/6次,到店周期中位#10,消费排名#68,在店时长#97;12月到店消费1天/1次,到店周期中位—,消费排名#68,在店时长#51;最近到店2025-12-11;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -69,林总,138****1180,周周(2.2h)、婉婉(0.9h),684.44,0.00,16729.21,订单:2单,平均单次¥342.22;打球:3.7h,平均单次1.9h;偏好:包厢(100.0%);时间:到店均值18:28 中位18:28;离店均值20:20 中位20:20;商品:东方树叶×1(¥8.00)、哇哈哈AD钙奶×1(¥8.00)(商品合计¥16.00 占比2.3%);综合:10-12月到店消费2天/2次,到店周期中位#2,消费排名#69,在店时长#72;12月到店消费0天/0次,到店周期中位—,消费排名#69,在店时长—;最近到店2025-11-25;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:储值余额充足,可提供包厢/团建档期与专属权益;重点维护包厢/团建需求,提前锁档与套餐化 -70,卢广贤,186****6220,,680.44,0.00,0.00,订单:4单,平均单次¥170.11;打球:10.4h,平均单次2.6h;偏好:B区(62.8%)、C区(37.2%);时间:到店均值18:15 中位18:45;离店均值20:51 中位20:41;商品:轻上椰子水×1(¥12.00)、三得利×1(¥8.00)、东鹏特饮×1(¥7.00)、冰红茶×1(¥6.00)、普通扑克×1(¥5.00)(商品合计¥38.00 占比5.6%);综合:10-12月到店消费4天/4次,到店周期中位#18,消费排名#70,在店时长#50;12月到店消费1天/1次,到店周期中位—,消费排名#70,在店时长#46;最近到店2025-12-13;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -71,王龙,186****8011,,669.58,0.00,95.20,订单:4单,平均单次¥167.40;打球:7.8h,平均单次2.0h;偏好:麻将(99.7%)、补时长(0.3%);时间:到店均值20:56 中位21:02;离店均值23:28 中位23:28;商品:麻将房茶位费×2(¥80.00)、东方树叶×2(¥16.00)(商品合计¥96.00 占比14.3%);综合:10-12月到店消费2天/4次,到店周期中位#9,消费排名#71,在店时长#56;12月到店消费2天/4次,到店周期中位#7,消费排名#71,在店时长#28;最近到店2025-12-12;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导 -72,王先生,185****1125,,600.68,0.00,0.00,订单:4单,平均单次¥150.17;打球:5.9h,平均单次1.5h;偏好:S区/斯诺克(99.4%)、补时长(0.6%);时间:到店均值18:13 中位18:31;离店均值20:09 中位19:30;商品:哇哈哈矿泉水×1(¥5.00)(商品合计¥5.00 占比0.8%);综合:10-12月到店消费4天/4次,到店周期中位#6,消费排名#72,在店时长#63;12月到店消费1天/1次,到店周期中位—,消费排名#72,在店时长#43;最近到店2025-12-02;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -73,潘先生,186****0511,年糕(2.0h),564.93,0.00,0.00,订单:2单,平均单次¥282.46;打球:3.0h,平均单次1.5h;偏好:666(66.7%)、A区(33.3%);时间:到店均值18:28 中位18:28;离店均值19:29 中位19:29;商品:农夫山泉苏打水×1(¥6.00)(商品合计¥6.00 占比1.1%);综合:10-12月到店消费2天/2次,到店周期中位#11,消费排名#73,在店时长#75;12月到店消费2天/2次,到店周期中位#8,消费排名#73,在店时长#40;最近到店2025-12-13;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -74,老宋,138****4554,婉婉(1.0h)、欣怡(0.5h),541.97,0.00,2126.14,订单:2单,平均单次¥270.98;打球:1.5h,平均单次0.7h;偏好:888(66.9%)、A区(33.1%);时间:到店均值19:24 中位19:24;离店均值20:02 中位20:02;商品:百威235毫升×12(¥180.00)(商品合计¥180.00 占比33.2%);综合:10-12月到店消费2天/2次,到店周期中位#13,消费排名#74,在店时长#91;12月到店消费0天/0次,到店周期中位—,消费排名#74,在店时长—;最近到店2025-11-07;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -75,郭先生,156****5001,希希(1.6h),518.35,0.00,2.57,订单:2单,平均单次¥259.18;打球:7.1h,平均单次3.5h;偏好:A区(100.0%);时间:到店均值20:53 中位20:53;离店均值次日00:32 中位次日00:32;商品:可乐×2(¥10.00)、普通扑克×2(¥10.00)、一次性手套×2(¥4.00)(商品合计¥24.00 占比4.6%);综合:10-12月到店消费2天/2次,到店周期中位#7,消费排名#75,在店时长#60;12月到店消费0天/0次,到店周期中位—,消费排名#75,在店时长—;最近到店2025-11-01;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导 -76,孙启明,137****6325,,500.00,0.00,0.00,订单:4单,平均单次¥125.00;打球:2.0h,平均单次0.5h;偏好:补时长(100.0%);时间:到店均值10:50 中位09:58;离店均值11:49 中位10:57;综合:10-12月到店消费4天/4次,到店周期中位#16,消费排名#76,在店时长#83;12月到店消费0天/0次,到店周期中位—,消费排名#76,在店时长—;最近到店2025-11-19;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -77,王先生,136****0168,,500.00,0.00,0.00,订单:5单,平均单次¥100.00;打球:0.1h,平均单次0.0h;偏好:补时长(100.0%);时间:到店均值19:45 中位19:22;离店均值20:44 中位20:21;综合:10-12月到店消费4天/5次,到店周期中位#5,消费排名#77,在店时长#98;12月到店消费1天/1次,到店周期中位—,消费排名#77,在店时长#53;最近到店2025-12-03;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -78,黎先生,133****0983,奈千(1.7h)、婉婉(0.8h),470.19,0.00,0.00,订单:1单,平均单次¥470.19;打球:1.7h,平均单次1.7h;偏好:包厢(100.0%);时间:到店均值19:17 中位19:17;离店均值21:01 中位21:01;商品:王老吉×2(¥16.00)、普通茶位×1(¥10.00)、香飘飘果汁茶×1(¥10.00)(商品合计¥36.00 占比7.7%);综合:10-12月到店消费1天/1次,到店周期中位—,消费排名#78,在店时长#89;12月到店消费0天/0次,到店周期中位—,消费排名#78,在店时长—;最近到店2025-10-10;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:重点维护包厢/团建需求,提前锁档与套餐化 -79,常总,185****7188,年糕(1.7h)、阿清(1.7h),460.52,0.00,5000.00,订单:1单,平均单次¥460.52;打球:1.8h,平均单次1.8h;偏好:A区(100.0%);时间:到店均值19:13 中位19:13;离店均值20:58 中位20:58;商品:哇哈哈矿泉水×2(¥10.00)、脉动×1(¥8.00)(商品合计¥18.00 占比3.9%);综合:10-12月到店消费1天/1次,到店周期中位—,消费排名#79,在店时长#88;12月到店消费1天/1次,到店周期中位—,消费排名#79,在店时长#47;最近到店2025-12-14;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -80,张丹逸,136****6637,,439.36,0.00,0.00,订单:4单,平均单次¥109.84;打球:2.4h,平均单次0.6h;偏好:B区(99.0%)、补时长(1.0%);时间:到店均值11:15 中位10:29;离店均值12:36 中位11:29;综合:10-12月到店消费4天/4次,到店周期中位#1,消费排名#80,在店时长#80;12月到店消费1天/1次,到店周期中位—,消费排名#80,在店时长#55;最近到店2025-12-03;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -81,陈先生,186****8238,乔西(1.8h),416.17,0.00,497.83,订单:1单,平均单次¥416.17;打球:1.8h,平均单次1.8h;偏好:包厢(100.0%);时间:到店均值21:15 中位21:15;离店均值23:04 中位23:04;商品:普通茶位×3(¥30.00)(商品合计¥30.00 占比7.2%);综合:10-12月到店消费1天/1次,到店周期中位—,消费排名#81,在店时长#86;12月到店消费0天/0次,到店周期中位—,消费排名#81,在店时长—;最近到店2025-11-20;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导;重点维护包厢/团建需求,提前锁档与套餐化 -82,陈先生,138****3964,,400.00,0.00,0.00,订单:3单,平均单次¥133.33;打球:2.5h,平均单次0.8h;偏好:补时长(100.0%);时间:到店均值15:17 中位21:41;离店均值15:57 中位22:40;综合:10-12月到店消费3天/3次,到店周期中位#24,消费排名#82,在店时长#79;12月到店消费1天/1次,到店周期中位—,消费排名#82,在店时长#52;最近到店2025-12-04;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -83,张先生,136****4528,,398.35,0.00,0.00,订单:3单,平均单次¥132.78;打球:2.9h,平均单次1.0h;偏好:S区/斯诺克(98.8%)、补时长(1.2%);时间:到店均值21:05 中位20:51;离店均值22:41 中位22:13;商品:农夫山泉苏打水×1(¥6.00)(商品合计¥6.00 占比1.5%);综合:10-12月到店消费3天/3次,到店周期中位#15,消费排名#83,在店时长#76;12月到店消费2天/2次,到店周期中位#10,消费排名#83,在店时长#42;最近到店2025-12-17;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -84,小宇,187****8077,球球(1.5h)、悦悦(0.4h),397.50,0.00,936.07,订单:2单,平均单次¥198.75;打球:2.1h,平均单次1.0h;偏好:包厢(80.9%)、TV台(19.1%);时间:到店均值18:07 中位18:07;离店均值19:09 中位19:09;商品:哇哈哈AD钙奶×1(¥8.00)、农夫山泉苏打水×1(¥6.00)、哇哈哈矿泉水×1(¥5.00)(商品合计¥19.00 占比4.8%);综合:10-12月到店消费2天/2次,到店周期中位#9,消费排名#84,在店时长#82;12月到店消费0天/0次,到店周期中位—,消费排名#84,在店时长—;最近到店2025-10-13;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:重点维护包厢/团建需求,提前锁档与套餐化 -85,黄先生,191****8219,,364.33,0.00,0.00,订单:4单,平均单次¥91.08;打球:1.2h,平均单次0.3h;偏好:B区(95.4%)、补时长(4.6%);时间:到店均值22:45 中位22:43;离店均值23:46 中位23:45;综合:10-12月到店消费3天/4次,到店周期中位#4,消费排名#85,在店时长#93;12月到店消费0天/0次,到店周期中位—,消费排名#85,在店时长—;最近到店2025-11-29;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -86,刘女士,177****7538,,362.58,0.00,0.00,订单:4单,平均单次¥90.64;打球:2.8h,平均单次0.7h;偏好:B区(99.3%)、补时长(0.7%);时间:到店均值15:53 中位15:44;离店均值17:04 中位17:04;综合:10-12月到店消费1天/4次,到店周期中位—,消费排名#86,在店时长#77;12月到店消费0天/0次,到店周期中位—,消费排名#86,在店时长—;最近到店2025-10-14;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -87,魏先生,137****6862,,319.39,0.00,84.51,订单:1单,平均单次¥319.39;打球:5.4h,平均单次5.4h;偏好:A区(66.1%)、S区/斯诺克(33.9%)、B区(0.0%);时间:到店均值18:44 中位18:44;离店均值次日00:08 中位次日00:08;商品:维他柠檬茶×2(¥16.00)、东方树叶×1(¥8.00)(商品合计¥24.00 占比7.5%);综合:10-12月到店消费1天/1次,到店周期中位—,消费排名#87,在店时长#64;12月到店消费1天/1次,到店周期中位—,消费排名#87,在店时长#30;最近到店2025-12-05;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导 -88,杜先生,188****4705,,307.47,0.00,0.00,订单:3单,平均单次¥102.49;打球:2.1h,平均单次0.7h;偏好:A区(98.3%)、补时长(1.7%);时间:到店均值21:25 中位21:44;离店均值22:45 中位22:43;商品:哇哈哈矿泉水×2(¥10.00)(商品合计¥10.00 占比3.3%);综合:10-12月到店消费2天/3次,到店周期中位#21,消费排名#88,在店时长#81;12月到店消费0天/0次,到店周期中位—,消费排名#88,在店时长—;最近到店2025-11-02;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -89,刘先生,137****2930,,300.00,0.00,1.27,订单:1单,平均单次¥300.00;打球:0.0h,平均单次0.0h;偏好:补时长(100.0%);时间:到店均值23:47 中位23:47;离店均值次日00:48 中位次日00:48;综合:10-12月到店消费1天/1次,到店周期中位—,消费排名#89,在店时长#100;12月到店消费1天/1次,到店周期中位—,消费排名#89,在店时长#54;最近到店2025-12-07;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导 -90,陈先生,133****6117,,300.00,0.00,0.00,订单:2单,平均单次¥150.00;打球:0.0h,平均单次0.0h;偏好:补时长(100.0%);时间:到店均值20:50 中位20:50;离店均值21:49 中位21:49;综合:10-12月到店消费2天/2次,到店周期中位#2,消费排名#90,在店时长#99;12月到店消费0天/0次,到店周期中位—,消费排名#90,在店时长—;最近到店2025-11-21;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -91,潘先生,176****7964,,300.00,0.00,0.00,订单:1单,平均单次¥300.00;打球:3.0h,平均单次3.0h;偏好:补时长(100.0%);时间:到店均值00:03 中位00:03;离店均值00:03 中位00:03;综合:10-12月到店消费1天/1次,到店周期中位—,消费排名#91,在店时长#74;12月到店消费1天/1次,到店周期中位—,消费排名#91,在店时长#39;最近到店2025-12-19;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -92,钟智豪,188****2803,小侯(1.8h),274.34,0.00,0.00,订单:1单,平均单次¥274.34;打球:1.8h,平均单次1.8h;偏好:A区(100.0%);时间:到店均值23:50 中位23:50;离店均值次日01:36 中位次日01:36;综合:10-12月到店消费1天/1次,到店周期中位—,消费排名#92,在店时长#87;12月到店消费0天/0次,到店周期中位—,消费排名#92,在店时长—;最近到店2025-11-28;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -93,都先生,138****7796,素素(1.6h),269.64,0.00,0.00,订单:1单,平均单次¥269.64;打球:1.6h,平均单次1.6h;偏好:B区(100.0%);时间:到店均值15:17 中位15:17;离店均值16:56 中位16:56;商品:东方树叶×1(¥8.00)、哇哈哈AD钙奶×1(¥8.00)(商品合计¥16.00 占比5.9%);综合:10-12月到店消费1天/1次,到店周期中位—,消费排名#93,在店时长#90;12月到店消费0天/0次,到店周期中位—,消费排名#93,在店时长—;最近到店2025-11-13;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -94,林志铭,135****4233,小侯(1.2h),267.96,0.00,795.66,订单:3单,平均单次¥89.32;打球:2.0h,平均单次0.7h;偏好:TV台(75.2%)、S区/斯诺克(24.8%);时间:到店均值19:45 中位20:54;离店均值20:24 中位21:40;综合:10-12月到店消费2天/3次,到店周期中位#12,消费排名#94,在店时长#84;12月到店消费0天/0次,到店周期中位—,消费排名#94,在店时长—;最近到店2025-11-30;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -95,方先生,158****6447,,248.00,0.00,0.00,订单:3单,平均单次¥82.67;打球:1.0h,平均单次0.3h;偏好:A区(97.2%)、补时长(2.8%);时间:到店均值15:35 中位22:11;离店均值16:15 中位23:11;综合:10-12月到店消费3天/3次,到店周期中位#17,消费排名#95,在店时长#94;12月到店消费2天/2次,到店周期中位#2,消费排名#95,在店时长#48;最近到店2025-12-18;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -96,李先生,176****5124,,244.00,0.00,0.00,订单:3单,平均单次¥81.33;打球:0.9h,平均单次0.3h;偏好:A区(97.8%)、补时长(2.2%);时间:到店均值20:59 中位21:28;离店均值21:39 中位21:28;综合:10-12月到店消费3天/3次,到店周期中位#5,消费排名#96,在店时长#95;12月到店消费0天/0次,到店周期中位—,消费排名#96,在店时长—;最近到店2025-10-13;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -97,钟先生,132****3438,,239.37,0.00,0.00,订单:1单,平均单次¥239.37;打球:2.6h,平均单次2.6h;偏好:麻将(100.0%);时间:到店均值19:32 中位19:32;离店均值22:10 中位22:10;商品:50枸杞槟榔×1(¥65.00)、地道肠×3(¥15.00)、哇哈哈矿泉水×2(¥10.00)、蜂蜜水×1(¥10.00)、屈臣氏苏打水×1(¥8.00)、芬达×1(¥5.00)(商品合计¥113.00 占比47.2%);综合:10-12月到店消费1天/1次,到店周期中位—,消费排名#97,在店时长#78;12月到店消费0天/0次,到店周期中位—,消费排名#97,在店时长—;最近到店2025-10-20;趋势:到店频次波动,建议按常用时段做稳定触达;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 -98,杨,130****5960,,232.00,0.00,287.50,订单:2单,平均单次¥116.00;打球:4.0h,平均单次2.0h;偏好:B区(100.0%);时间:到店均值18:09 中位18:09;离店均值20:11 中位20:11;综合:10-12月到店消费2天/2次,到店周期中位#2,消费排名#98,在店时长#71;12月到店消费2天/2次,到店周期中位#2,消费排名#98,在店时长#33;最近到店2025-12-05;趋势:10-12月到店频次上升,12月更活跃;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导 -99,黄国磊,131****3045,,225.33,0.00,0.22,订单:3单,平均单次¥75.11;打球:0.1h,平均单次0.0h;偏好:A区(85.5%)、补时长(14.5%);时间:到店均值17:56 中位18:02;离店均值18:36 中位18:19;商品:蜂蜜水×2(¥20.00)(商品合计¥20.00 占比8.9%);综合:10-12月到店消费3天/3次,到店周期中位#22,消费排名#99,在店时长#96;12月到店消费1天/1次,到店周期中位—,消费排名#99,在店时长#55;最近到店2025-12-12;趋势:12月为高峰月,具备加深运营空间;围客与客户运营建议:储值余额偏低,建议在其常用时段做补能引导 -100,周先生,159****9997,,200.00,0.00,0.00,订单:2单,平均单次¥100.00;打球:1.2h,平均单次0.6h;偏好:补时长(100.0%);时间:到店均值02:54 中位02:54;离店均值03:19 中位03:19;综合:10-12月到店消费2天/2次,到店周期中位#2,消费排名#100,在店时长#92;12月到店消费1天/1次,到店周期中位—,消费排名#100,在店时长#50;最近到店2025-12-01;趋势:12月为高峰月,具备加深运营空间;围客与客户运营建议:保持常用时段的稳定服务供给,提升复购粘性 diff --git a/etl_billiards/docs/table_2025-12-19/客户_Top100_2025年10-12月_总表.md b/etl_billiards/docs/table_2025-12-19/客户_Top100_2025年10-12月_总表.md deleted file mode 100644 index 826151c..0000000 --- a/etl_billiards/docs/table_2025-12-19/客户_Top100_2025年10-12月_总表.md +++ /dev/null @@ -1,459 +0,0 @@ -# 2025年10-12月 客户消费能力Top100(总表) -## 思考过程 -以台费订单为基准汇总三类明细,满足应付金额口径,并输出Top100客户的消费/充值/助教偏好。按你的要求,先生成评价为空的版本,再在脚本末尾回填评价。 - -## 查询说明 -消费=台费(dwd_table_fee_log.ledger_amount)+助教(dwd_assistant_service_log.ledger_amount)+商品(dwd_store_goods_sale.ledger_amount),均为应付金额(不扣优惠),以台费订单为基准串联;充值=充值支付流水(dwd_payment.relate_type=5, pay_status=2, pay_amount>0)按支付时间切月;储值卡未使用金额=当前有效储值卡余额之和(dim_member_card_account.balance, member_card_type_name='储值卡');喜爱助教=基础课时长+附加课时长*1.5(income_seconds换算小时),总表按10-12月汇总Top5。 - -## SQL - -### Top100(按消费总额) -```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, - sum(tfl.real_table_use_seconds) as table_use_seconds - 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_info as ( - select - asl.order_settle_id, - sum(asl.ledger_amount) as assistant_amount, - 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 -), -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, - least(bo.order_start_time, coalesce(a.assistant_start_time, bo.order_start_time)) as order_start_time, - greatest(bo.order_end_time, coalesce(a.assistant_end_time, bo.order_end_time)) as order_end_time, - bo.table_use_seconds, - 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_info a on a.order_settle_id = bo.order_settle_id - left join goods_amount g on g.order_settle_id = bo.order_settle_id -) - -select - o.member_id, - sum(o.order_amount) as consume_total, - count(*) as order_cnt -from orders o -where o.member_id is not null and o.member_id <> 0 -group by o.member_id -order by consume_total desc -limit 100; -``` - -### 按月消费汇总 -```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, - sum(tfl.real_table_use_seconds) as table_use_seconds - 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_info as ( - select - asl.order_settle_id, - sum(asl.ledger_amount) as assistant_amount, - 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 -), -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, - least(bo.order_start_time, coalesce(a.assistant_start_time, bo.order_start_time)) as order_start_time, - greatest(bo.order_end_time, coalesce(a.assistant_end_time, bo.order_end_time)) as order_end_time, - bo.table_use_seconds, - 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_info a on a.order_settle_id = bo.order_settle_id - left join goods_amount g on g.order_settle_id = bo.order_settle_id -) - -, x as ( - select - 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 - where o.member_id is not null and o.member_id <> 0 -) -select - member_id, - month_key, - sum(order_amount) as consume_sum -from x -where month_key is not null -group by member_id, month_key; -``` - -### 按月充值汇总 -```sql -with 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 -) -, x as ( - select - member_id, - case when pay_time >= '2025-10-01 00:00:00+08'::timestamptz and pay_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when pay_time >= '2025-11-01 00:00:00+08'::timestamptz and pay_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when pay_time >= '2025-12-01 00:00:00+08'::timestamptz and pay_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key, - pay_amount - from pay -) -select - member_id, - month_key, - sum(pay_amount) as recharge_sum -from x -where month_key is not null -group by member_id, month_key; -``` - -### 储值卡未使用金额(当前余额汇总) -```sql -select - tenant_member_id as member_id, - sum(balance) as stored_value_balance -from billiards_dwd.dim_member_card_account -where scd2_is_current=1 - and coalesce(is_delete,0)=0 - and member_card_type_name='储值卡' - and tenant_member_id = any(%(ids)s) -group by tenant_member_id; -``` - -### 喜爱助教Top5(10-12月) -```sql -with x as ( - select - asl.tenant_member_id as member_id, - asl.nickname as assistant_nickname, - sum(case when asl.order_assistant_type=1 then asl.income_seconds else asl.income_seconds*1.5 end) / 3600.0 as weighted_hours - from billiards_dwd.dwd_assistant_service_log asl - where asl.site_id = %(site_id)s - and coalesce(asl.is_delete,0)=0 - and asl.tenant_member_id is not null and asl.tenant_member_id <> 0 - and asl.start_use_time >= %(window_start)s::timestamptz - and asl.start_use_time < %(window_end)s::timestamptz - group by asl.tenant_member_id, asl.nickname -), -ranked as ( - select *, row_number() over(partition by member_id order by weighted_hours desc) as rn - from x -) -select - member_id, - string_agg(assistant_nickname || '(' || to_char(round(weighted_hours::numeric, 1), 'FM999999990.0') || 'h)', '、' order by weighted_hours desc) as fav5 -from ranked -where rn <= 5 -group by member_id; -``` - -### 评价画像:订单/时长/到店日期 -```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, - sum(tfl.real_table_use_seconds) as table_use_seconds - 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_info as ( - select - asl.order_settle_id, - sum(asl.ledger_amount) as assistant_amount, - 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 -), -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, - least(bo.order_start_time, coalesce(a.assistant_start_time, bo.order_start_time)) as order_start_time, - greatest(bo.order_end_time, coalesce(a.assistant_end_time, bo.order_end_time)) as order_end_time, - bo.table_use_seconds, - 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_info a on a.order_settle_id = bo.order_settle_id - left join goods_amount g on g.order_settle_id = bo.order_settle_id -) - -select - o.member_id, - count(*) as orders, - avg(o.order_amount) as avg_order, - sum(o.table_use_seconds)/3600.0 as play_hours, - avg(o.table_use_seconds)/3600.0 as avg_play_hours, - min((o.order_start_time at time zone 'Asia/Shanghai')::date) as first_visit_day, - max((o.order_start_time at time zone 'Asia/Shanghai')::date) as last_visit_day, - count(distinct (o.order_start_time at time zone 'Asia/Shanghai')::date) as visit_days, - sum(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 1 else 0 end) as orders_oct, - sum(case 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 1 else 0 end) as orders_nov, - sum(case 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 1 else 0 end) as orders_dec -from orders o -where o.member_id = any(%(ids)s) -group by o.member_id; -``` - -### 评价画像:到店/离店时间(小时) -```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, - sum(tfl.real_table_use_seconds) as table_use_seconds - 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_info as ( - select - asl.order_settle_id, - sum(asl.ledger_amount) as assistant_amount, - 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 -), -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, - least(bo.order_start_time, coalesce(a.assistant_start_time, bo.order_start_time)) as order_start_time, - greatest(bo.order_end_time, coalesce(a.assistant_end_time, bo.order_end_time)) as order_end_time, - bo.table_use_seconds, - 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_info a on a.order_settle_id = bo.order_settle_id - left join goods_amount g on g.order_settle_id = bo.order_settle_id -) - -, t as ( - select - o.member_id, - extract(hour from (o.order_start_time at time zone 'Asia/Shanghai')) - + extract(minute from (o.order_start_time at time zone 'Asia/Shanghai'))/60.0 - + extract(second from (o.order_start_time at time zone 'Asia/Shanghai'))/3600.0 as arrive_h, - extract(hour from (o.order_end_time at time zone 'Asia/Shanghai')) - + extract(minute from (o.order_end_time at time zone 'Asia/Shanghai'))/60.0 - + extract(second from (o.order_end_time at time zone 'Asia/Shanghai'))/3600.0 as leave_h_raw - from orders o - where o.member_id = any(%(ids)s) -), -tt as ( - select - member_id, - arrive_h, - case when leave_h_raw < arrive_h then leave_h_raw + 24 else leave_h_raw end as leave_h - from t -) -select - member_id, - avg(arrive_h) as arrive_avg_h, - percentile_cont(0.5) within group (order by arrive_h) as arrive_med_h, - avg(leave_h) as leave_avg_h, - percentile_cont(0.5) within group (order by leave_h) as leave_med_h -from tt -group by member_id; -``` - -### 评价画像:球台分区偏好(按时长) -```sql -select - tfl.member_id, - coalesce(tfl.site_table_area_name,'') as site_table_area_name, - sum(tfl.real_table_use_seconds)/3600.0 as hours -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 - and tfl.member_id = any(%(ids)s) -group by tfl.member_id, site_table_area_name; -``` - -### 评价画像:商品明细(名称+数量) -```sql -with base_orders as ( - select order_settle_id, max(member_id) as member_id - from billiards_dwd.dwd_table_fee_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 - group by order_settle_id -) -select - bo.member_id, - g.ledger_name, - sum(g.ledger_count) as qty, - sum(g.ledger_amount) as amount -from base_orders bo -join billiards_dwd.dwd_store_goods_sale g on g.order_settle_id = bo.order_settle_id -where g.site_id=%(site_id)s and coalesce(g.is_delete,0)=0 - and bo.member_id = any(%(ids)s) -group by bo.member_id, g.ledger_name; -``` - -### 评价画像:到店日期明细(用于周期/近期分析) -```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, - sum(tfl.real_table_use_seconds) as table_use_seconds - 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_info as ( - select - asl.order_settle_id, - sum(asl.ledger_amount) as assistant_amount, - 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 -), -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, - least(bo.order_start_time, coalesce(a.assistant_start_time, bo.order_start_time)) as order_start_time, - greatest(bo.order_end_time, coalesce(a.assistant_end_time, bo.order_end_time)) as order_end_time, - bo.table_use_seconds, - 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_info a on a.order_settle_id = bo.order_settle_id - left join goods_amount g on g.order_settle_id = bo.order_settle_id -) - -select - o.member_id, - (o.order_start_time at time zone 'Asia/Shanghai')::date as visit_date, - count(*) as orders, - sum(o.order_amount) as amount -from orders o -where o.member_id = any(%(ids)s) -group by o.member_id, visit_date -order by o.member_id, visit_date; -``` diff --git a/etl_billiards/docs/table_2025-12-19/财务_优惠分布_2025年10-12月.csv b/etl_billiards/docs/table_2025-12-19/财务_优惠分布_2025年10-12月.csv deleted file mode 100644 index 24f1db7..0000000 --- a/etl_billiards/docs/table_2025-12-19/财务_优惠分布_2025年10-12月.csv +++ /dev/null @@ -1,119 +0,0 @@ -2025年10-12月 财务优惠(会员折扣+台费调账)分布 -优惠=会员折扣(dwd_table_fee_log.member_discount_amount)+台费调账(dwd_table_fee_adjust.ledger_amount),按订单归集后汇总到客户(member_id),按订单最早开台时间切月;不含团购抵扣等其它优惠。 - -客户名称,手机号(脱敏),VIP卡/等级,10月,10月,10月,11月,11月,11月,12月,12月,12月,10-12月 -客户名称,手机号(脱敏),VIP卡/等级,会员折扣(元),台费调账(元),合计优惠(元),会员折扣(元),台费调账(元),合计优惠(元),会员折扣(元),台费调账(元),合计优惠(元),合计优惠(元) -轩哥,188****7530,储值卡,0.00,9212.40,9212.40,0.00,10685.47,10685.47,0.00,5331.76,5331.76,25229.63 -曾巧明,186****1488,年卡,9649.06,0.00,9649.06,8811.59,0.00,8811.59,6283.51,0.00,6283.51,24744.16 -黄生,136****9719,年卡,7821.94,0.00,7821.94,6353.05,0.00,6353.05,4181.24,0.00,4181.24,18356.23 -蔡总,159****8893,台费卡,0.00,0.00,0.00,0.00,12274.20,12274.20,0.00,2587.28,2587.28,14861.48 -罗先生,139****6996,年卡,3315.05,566.48,3881.53,4474.12,460.59,4934.71,2087.14,1320.22,3407.36,12223.60 -陈腾鑫,178****8218,台费卡,0.00,2843.20,2843.20,0.00,4913.52,4913.52,0.00,1935.78,1935.78,9692.50 -谢俊,186****5198,年卡,4193.93,0.00,4193.93,4089.12,0.00,4089.12,969.66,0.00,969.66,9252.71 -桂先生,166****7275,月卡,2175.11,0.00,2175.11,4009.66,301.18,4310.84,0.00,568.24,568.24,7054.19 -张先生,139****8852,年卡,1317.04,1307.13,2624.17,2114.89,168.51,2283.40,2007.34,0.00,2007.34,6914.91 -艾宇民,150****9958,年卡,2342.73,0.00,2342.73,2543.78,545.12,3088.90,1179.56,0.00,1179.56,6611.19 -曾丹烨,139****3242,储值卡,0.00,2348.26,2348.26,0.00,2573.25,2573.25,0.00,1240.20,1240.20,6161.71 -葛先生,138****8071,储值卡,0.00,0.00,0.00,0.00,3548.54,3548.54,0.00,2593.02,2593.02,6141.56 -小燕,178****1334,储值卡,0.00,0.00,0.00,0.00,2250.36,2250.36,0.00,2228.54,2228.54,4478.90 -孟紫龙,176****3741,月卡,0.00,0.00,0.00,576.78,0.00,576.78,2762.95,0.00,2762.95,3339.73 -江先生,188****4838,储值卡,0.00,344.54,344.54,0.00,1454.41,1454.41,0.00,405.54,405.54,2204.49 -郑先生,159****4331,储值卡,0.00,0.00,0.00,0.00,1659.16,1659.16,0.00,463.02,463.02,2122.18 -黄先生,135****3507,台费卡,0.00,631.08,631.08,0.00,631.56,631.56,0.00,810.48,810.48,2073.12 -孟紫龙(该会员已注销),176****37411,月卡,1785.72,0.00,1785.72,0.00,164.00,164.00,0.00,0.00,0.00,1949.72 -T,180****9962,储值卡,0.00,578.93,578.93,0.00,461.72,461.72,0.00,839.34,839.34,1879.99 -林先生,133****1070,储值卡,0.00,0.00,0.00,0.00,199.95,199.95,0.00,1417.70,1417.70,1617.65 -游,172****6666,储值卡,0.00,0.00,0.00,0.00,921.43,921.43,0.00,600.85,600.85,1522.28 -林先生,137****8785,储值卡,0.00,0.00,0.00,0.00,1114.20,1114.20,0.00,186.45,186.45,1300.65 -桂先生(该会员已注销),166****72751,月卡,988.04,303.77,1291.81,0.00,0.00,0.00,0.00,0.00,0.00,1291.81 -叶先生,138****9539,储值卡,0.00,703.64,703.64,0.00,341.29,341.29,0.00,99.41,99.41,1144.34 -陈德韩,134****7864,台费卡,0.00,1091.02,1091.02,0.00,0.00,0.00,0.00,0.00,0.00,1091.02 -周周,198****8725,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,1061.95,1061.95,1061.95 -胡先生,186****3391,储值卡,0.00,0.00,0.00,0.00,785.20,785.20,0.00,100.59,100.59,885.79 -小熊,139****0145,台费卡,0.00,297.01,297.01,0.00,530.45,530.45,0.00,0.00,0.00,827.46 -夏,191****2851,储值卡,0.00,659.78,659.78,0.00,137.90,137.90,0.00,0.00,0.00,797.68 -李先生,186****8308,储值卡,0.00,0.00,0.00,0.00,777.27,777.27,0.00,0.00,0.00,777.27 -叶总,137****3287,储值卡,0.00,737.12,737.12,0.00,0.00,0.00,0.00,0.00,0.00,737.12 -羊,187****5094,储值卡,0.00,38.64,38.64,0.00,647.57,647.57,0.00,0.00,0.00,686.21 -黄先生,158****2109,储值卡,0.00,240.00,240.00,0.00,326.90,326.90,0.00,100.06,100.06,666.96 -卢广贤,186****6220,年卡,263.07,0.00,263.07,250.51,0.00,250.51,128.86,0.00,128.86,642.44 -陶,189****2151,储值卡,0.00,604.89,604.89,0.00,0.00,0.00,0.00,0.00,0.00,604.89 -大G,186****4598,台费卡,0.00,0.00,0.00,0.00,245.70,245.70,0.00,356.31,356.31,602.01 -明哥,166****0999,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,547.68,547.68,547.68 -梅,136****4552,储值卡,0.00,0.00,0.00,0.00,99.02,99.02,0.00,372.66,372.66,471.68 -阿亮,159****2628,储值卡,0.00,0.00,0.00,0.00,361.34,361.34,0.00,100.86,100.86,462.20 -牛先生,152****5159,台费卡,0.00,0.00,0.00,0.00,424.31,424.31,0.00,0.00,0.00,424.31 -罗超杰,137****8012,储值卡,0.00,245.95,245.95,0.00,164.54,164.54,0.00,0.00,0.00,410.49 -陈世,134****1938,储值卡,0.00,199.51,199.51,0.00,198.89,198.89,0.00,0.00,0.00,398.40 -曾先生,133****1235,储值卡,0.00,36.67,36.67,0.00,265.71,265.71,0.00,90.45,90.45,392.83 -李,131****9882,储值卡,0.00,254.13,254.13,0.00,138.12,138.12,0.00,0.00,0.00,392.25 -陈泽斌,132****6060,储值卡,0.00,77.00,77.00,0.00,222.00,222.00,0.00,78.00,78.00,377.00 -王先生,136****0168,台费卡,0.00,0.00,0.00,0.00,235.00,235.00,0.00,65.00,65.00,300.00 -林先生,188****0332,储值卡,0.00,0.00,0.00,0.00,252.11,252.11,0.00,0.00,0.00,252.11 -歌神,188****2164,储值卡,0.00,246.28,246.28,0.00,0.00,0.00,0.00,0.00,0.00,246.28 -陈先生,159****2829,台费卡,0.00,21.00,21.00,0.00,218.13,218.13,0.00,0.00,0.00,239.13 -黄先生,191****8219,台费卡,0.00,0.00,0.00,0.00,229.16,229.16,0.00,0.00,0.00,229.16 -汪先生,139****6339,储值卡,0.00,228.07,228.07,0.00,0.00,0.00,0.00,0.00,0.00,228.07 -王龙,186****8011,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,200.78,200.78,200.78 -罗先生,139****9222,储值卡,0.00,0.00,0.00,0.00,199.17,199.17,0.00,0.00,0.00,199.17 -吴生,136****3341,储值卡,0.00,0.00,0.00,0.00,99.23,99.23,0.00,99.92,99.92,199.15 -刘女士,177****7538,储值卡,0.00,193.29,193.29,0.00,0.00,0.00,0.00,0.00,0.00,193.29 -林总,138****1180,储值卡,0.00,0.00,0.00,0.00,183.25,183.25,0.00,0.00,0.00,183.25 -陈淑涛,132****5485,储值卡,0.00,0.00,0.00,0.00,180.86,180.86,0.00,0.00,0.00,180.86 -张丹逸,136****6637,储值卡,0.00,133.68,133.68,0.00,0.00,0.00,0.00,45.00,45.00,178.68 -孙启明,137****6325,台费卡,0.00,90.00,90.00,0.00,85.00,85.00,0.00,0.00,0.00,175.00 -陈先生,138****3964,储值卡,0.00,98.00,98.00,0.00,0.00,0.00,0.00,60.00,60.00,158.00 -杜先生,188****4705,台费卡,0.00,48.00,48.00,0.00,99.73,99.73,0.00,0.00,0.00,147.73 -周先生,193****6822,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,135.65,135.65,135.65 -君姐,166****4594,储值卡,0.00,0.00,0.00,0.00,134.10,134.10,0.00,0.00,0.00,134.10 -昌哥,137****1229,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,122.03,122.03,122.03 -amy,137****8221,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,116.28,116.28,116.28 -杨,130****5960,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,116.00,116.00,116.00 -方先生,153****3185,储值卡,0.00,100.27,100.27,0.00,0.00,0.00,0.00,0.00,0.00,100.27 -方先生,158****6447,台费卡,0.00,0.00,0.00,0.00,72.00,72.00,0.00,28.00,28.00,100.00 -陈先生,133****6117,台费卡,0.00,0.00,0.00,0.00,100.00,100.00,0.00,0.00,0.00,100.00 -周先生,159****9997,台费卡,0.00,0.00,0.00,0.00,61.00,61.00,0.00,37.00,37.00,98.00 -王姐,158****8819,储值卡,0.00,97.40,97.40,0.00,0.00,0.00,0.00,0.00,0.00,97.40 -老宋,138****4554,储值卡,0.00,0.00,0.00,0.00,93.95,93.95,0.00,0.00,0.00,93.95 -李先生,176****5124,储值卡,0.00,90.00,90.00,0.00,0.00,0.00,0.00,0.00,0.00,90.00 -曾先生,159****0492,储值卡,0.00,88.00,88.00,0.00,0.00,0.00,0.00,0.00,0.00,88.00 -张先生,136****4528,台费卡,0.00,0.00,0.00,0.00,37.00,37.00,0.00,45.00,45.00,82.00 -刘先生,137****2930,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,82.00,82.00,82.00 -潘先生,176****7964,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,74.00,74.00,74.00 -王先生,183****9763,台费卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,74.00,74.00,74.00 -王先生,185****1125,台费卡,0.00,0.00,0.00,0.00,73.00,73.00,0.00,0.00,0.00,73.00 -清,130****3087,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,72.82,72.82,72.82 -贺斌,150****0885,活动抵用券,0.00,71.27,71.27,0.00,0.00,0.00,0.00,0.00,0.00,71.27 -李先生,186****9266,储值卡,0.00,0.00,0.00,0.00,69.00,69.00,0.00,0.00,0.00,69.00 -林志铭,135****4233,储值卡,0.00,0.00,0.00,0.00,66.50,66.50,0.00,0.00,0.00,66.50 -候,131****0323,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,62.79,62.79,62.79 -吕先生,155****0663,储值卡,0.00,62.54,62.54,0.00,0.00,0.00,0.00,0.00,0.00,62.54 -梁先生,134****2609,台费卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,59.00,59.00,59.00 -肖先生,156****6427,台费卡,0.00,0.00,0.00,0.00,7.00,7.00,0.00,50.00,50.00,57.00 -婉婉,183****2742,储值卡,0.00,0.00,0.00,0.00,37.47,37.47,0.00,0.00,0.00,37.47 -陈小姐,138****0778,储值卡,0.00,32.49,32.49,0.00,0.00,0.00,0.00,0.00,0.00,32.49 -黄国磊,131****3045,台费卡,0.00,0.30,0.30,0.00,19.00,19.00,0.00,0.00,0.00,19.30 -小宇,187****8077,储值卡,0.00,13.42,13.42,0.00,0.00,0.00,0.00,0.00,0.00,13.42 -胡总,133****3091,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,1.00,1.00,1.00 -李先生,131****4000,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -周先生,173****7775,台费卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -林先生,159****0021,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -魏先生,137****6862,台费卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -都先生,138****7796,活动抵用券,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -陈先生,188****8626,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -冯先生,155****0348,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -常总,185****7188,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -邓飛,136****9597,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -李先生,134****4343,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -谭先生,138****3185,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -黎先生,133****0983,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -刘哥,135****0020,台费卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -孙先生,135****3191,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -钟智豪,188****2803,活动抵用券,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -陈先生,186****8238,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -郭先生,156****5001,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -钟先生,132****3438,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -唐先生,135****0785,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -陈先生,139****0419,储值卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -潘先生,186****0511,台费卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 -罗超,137****0990,台费卡,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00 diff --git a/etl_billiards/docs/table_2025-12-19/财务_优惠分布_2025年10-12月.md b/etl_billiards/docs/table_2025-12-19/财务_优惠分布_2025年10-12月.md deleted file mode 100644 index afba5bd..0000000 --- a/etl_billiards/docs/table_2025-12-19/财务_优惠分布_2025年10-12月.md +++ /dev/null @@ -1,52 +0,0 @@ -# 2025年10-12月 财务优惠(会员折扣+台费调账)分布 -## 思考过程 -用台费订单为基准关联调账表,再按客户+月份汇总,输出“谁享受了优惠”及金额分布。 - -## 查询说明 -优惠=会员折扣(dwd_table_fee_log.member_discount_amount)+台费调账(dwd_table_fee_adjust.ledger_amount),按订单归集后汇总到客户(member_id),按订单最早开台时间切月;不含团购抵扣等其它优惠。 - -## 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.member_discount_amount) as member_discount_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 -), -adjusts as ( - select - tfa.order_settle_id, - sum(tfa.ledger_amount) as adjust_amount - from billiards_dwd.dwd_table_fee_adjust tfa - join base_orders bo on bo.order_settle_id = tfa.order_settle_id - where tfa.site_id = %(site_id)s - and coalesce(tfa.is_delete,0) = 0 - group by tfa.order_settle_id -) -, x as ( - select - bo.member_id, - case when bo.order_start_time >= '2025-10-01 00:00:00+08'::timestamptz and bo.order_start_time < '2025-11-01 00:00:00+08'::timestamptz then '2025-10' when bo.order_start_time >= '2025-11-01 00:00:00+08'::timestamptz and bo.order_start_time < '2025-12-01 00:00:00+08'::timestamptz then '2025-11' when bo.order_start_time >= '2025-12-01 00:00:00+08'::timestamptz and bo.order_start_time < '2026-01-01 00:00:00+08'::timestamptz then '2025-12' else null end as month_key, - coalesce(bo.member_discount_amount,0) as member_discount_amount, - coalesce(a.adjust_amount,0) as adjust_amount - from base_orders bo - left join adjusts a on a.order_settle_id = bo.order_settle_id -) -select - member_id, - month_key, - sum(member_discount_amount) as member_discount_sum, - sum(adjust_amount) as adjust_sum -from x -where month_key is not null -group by member_id, month_key; -``` diff --git a/tmp/env_report_local.txt b/tmp/env_report_local.txt new file mode 100644 index 0000000..2bc51b1 --- /dev/null +++ b/tmp/env_report_local.txt @@ -0,0 +1,121 @@ +# ETL Manager Environment Report +Timestamp: 2026-01-28 00:43:50 + +## 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 + File "", line 1 + try:\n import PySide6\n from PySide6 import QtCore\n print('PySide6='+PySide6.__version__)\n print('Qt='+QtCore.qVersion())\n print('PySide6_path='+PySide6.__file__)\n print('Qt_plugins_path='+QtCore.QLibraryInfo.path(QtCore.QLibraryInfo.PluginsPath))\n except Exception as e:\n print('PySide6_import_error='+repr(e)) + ^ +SyntaxError: unexpected character after line continuation character + +## 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