Files
Neo-ZQYY/db/etl_feiqiu/schemas/core.sql
Neo 2a7a5d68aa feat: 2026-04-15~04-20 累积变更基线 — 多主线合流
主线 1: rns1-customer-coach-api + 04-miniapp-core-business 后端实施
  - 新增 GET /xcx/coaches/{id}/banner 轻量接口
  - performance/records 加 coach_id 参数 + view_board_coach 权限分流
  - coach/customer/performance/board/task 服务层重构
  - fdw_queries 结算单粒度聚合 + consumption_summary 视图统一
  - task_generator 回访宽限 72h + UPSERT 替代策略 + Step 5 保底清理
  - recall_detector settle_type=3 双重限制 + 门店级 resolved

主线 2: 小程序权限分流 + 新增 coach-service-records 管理者视角业绩明细页
  - perf-progress 共享模块去重 task-list/coach-detail 动画逻辑
  - isScattered 散客标记端到端
  - foodDetail/phoneFull/creator* 字段透传

主线 3: P19 指数回测框架 Phase 1+2
  - 3 个指数表 stat_date 日快照模式
  - 新增 DWS_INDEX_BACKFILL / DWS_TASK_SIMULATION 工具任务
  - task_engine 升级 HTTP 实时 + 推演回测双模式

主线 4: Core 维度层启用
  - 新增 CORE_DIM_SYNC 任务(DWD → core 4 维度表)
  - 修复 app 视图空查询问题

主线 5: member_project_tag 改为 LAST_30_VISITS 消费次数窗口

主线 6: 2 个迁移 SQL 已执行(stat_date + member_project_tag 新窗口)
  - schema 基线与 DDL 快照同步

主线 7: 开发机路径迁移 C:\NeoZQYY → C:\Project\NeoZQYY(约 95% 改动量)

附带: 新建运维脚本(churned_customer_report / simulate_historical_tasks /
      backfill_index_snapshots)+ tools/task-analysis/ 任务分析工具

合计 157 文件。未包含中间产物(tmp/ .playwright-mcp/ inspect-* excel/sheet 分析 txt)。
审计记录见下一个 commit。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 06:32:07 +08:00

104 lines
3.4 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- =============================================================================
-- etl_feiqiu / core跨平台统一维度/事实层)
-- 生成日期2026-04-06
-- 来源:测试库(通过脚本自动导出)
--
-- 定位:屏蔽 ODS/DWD 多数据源差异,输出标准化维度和事实。
-- DWS/app 层只依赖 core不直接查 DWD。
-- 当前数据源飞球dwd.*),后续可接入美团、抖音等。
-- =============================================================================
CREATE SCHEMA IF NOT EXISTS core;
-- 表
CREATE TABLE core.dim_assistant (
assistant_id bigint NOT NULL,
tenant_id bigint NOT NULL,
site_id bigint NOT NULL,
real_name text NOT NULL,
nickname text,
mobile text,
level integer,
assistant_status integer,
leave_status integer
);
CREATE TABLE core.dim_goods_category (
category_id bigint NOT NULL,
tenant_id bigint NOT NULL,
category_name text NOT NULL,
parent_id bigint,
level integer
);
CREATE TABLE core.dim_member (
member_id bigint NOT NULL,
system_member_id bigint,
tenant_id bigint NOT NULL,
register_site_id bigint NOT NULL,
mobile text,
nickname text,
member_card_grade_name text,
status integer
);
CREATE TABLE core.dim_site (
site_id bigint NOT NULL,
tenant_id bigint NOT NULL,
shop_name text NOT NULL,
site_label text,
shop_status integer,
site_id_alias bigint
);
CREATE TABLE core.dim_table (
table_id bigint NOT NULL,
site_id bigint NOT NULL,
table_name text NOT NULL,
site_table_area_name text,
table_price numeric(18,2)
);
CREATE TABLE core.fact_payment (
payment_id bigint NOT NULL,
site_id bigint NOT NULL,
order_settle_id bigint,
pay_type integer,
pay_amount numeric(18,2),
pay_time timestamp with time zone,
status integer
);
CREATE TABLE core.fact_settlement (
order_settle_id bigint NOT NULL,
site_id bigint NOT NULL,
tenant_id bigint NOT NULL,
order_trade_no bigint,
member_id bigint,
total_amount numeric(18,2),
actual_amount numeric(18,2),
discount_amount numeric(18,2),
pay_status integer,
settle_time timestamp with time zone,
created_at timestamp with time zone,
updated_at timestamp with time zone
);
-- 约束(主键 / 唯一 / 外键)
ALTER TABLE core.dim_assistant ADD CONSTRAINT dim_assistant_pkey PRIMARY KEY (assistant_id);
ALTER TABLE core.dim_goods_category ADD CONSTRAINT dim_goods_category_pkey PRIMARY KEY (category_id);
ALTER TABLE core.dim_member ADD CONSTRAINT dim_member_pkey PRIMARY KEY (member_id);
ALTER TABLE core.dim_site ADD CONSTRAINT dim_site_pkey PRIMARY KEY (site_id);
ALTER TABLE core.dim_table ADD CONSTRAINT dim_table_pkey PRIMARY KEY (table_id);
ALTER TABLE core.fact_payment ADD CONSTRAINT fact_payment_pkey PRIMARY KEY (payment_id);
ALTER TABLE core.fact_settlement ADD CONSTRAINT fact_settlement_pkey PRIMARY KEY (order_settle_id);
-- 索引
CREATE INDEX idx_core_assistant_site ON core.dim_assistant USING btree (site_id);
CREATE INDEX idx_core_member_site ON core.dim_member USING btree (register_site_id);
CREATE INDEX idx_core_table_site ON core.dim_table USING btree (site_id);
CREATE INDEX idx_core_payment_site ON core.fact_payment USING btree (site_id);
CREATE INDEX idx_core_settlement_site ON core.fact_settlement USING btree (site_id);
CREATE INDEX idx_core_settlement_time ON core.fact_settlement USING btree (settle_time);