微信小程序页面迁移校验之前 P5任务处理之前

This commit is contained in:
Neo
2026-03-09 01:19:21 +08:00
parent 263bf96035
commit 6e20987d2f
1112 changed files with 153824 additions and 219694 deletions

View File

@@ -1,6 +1,6 @@
-- =============================================================================
-- etl_feiqiu / dws汇总数据层
-- 生成日期2026-02-25
-- 生成日期2026-02-27
-- 来源:测试库(通过脚本自动导出)
-- =============================================================================
@@ -42,8 +42,11 @@ CREATE SEQUENCE IF NOT EXISTS dws.dws_platform_settlement_id_seq AS bigint;
CREATE TABLE dws.cfg_area_category (
category_id integer DEFAULT nextval('dws.cfg_area_category_category_id_seq'::regclass) NOT NULL,
source_area_name character varying(100) NOT NULL,
source_table_name character varying(100) DEFAULT NULL,
category_code character varying(20) NOT NULL,
category_name character varying(50) NOT NULL,
display_name character varying(50) DEFAULT NULL,
short_name character varying(20) DEFAULT NULL,
match_type character varying(10) DEFAULT 'EXACT'::character varying NOT NULL,
match_priority integer DEFAULT 100 NOT NULL,
is_active boolean DEFAULT true NOT NULL,
@@ -51,6 +54,9 @@ CREATE TABLE dws.cfg_area_category (
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL
);
-- 唯一约束:(source_area_name, source_table_name) 支持同一台区下按台桌细分
CREATE UNIQUE INDEX uk_cfg_area_category
ON dws.cfg_area_category (source_area_name, COALESCE(source_table_name, ''));
CREATE TABLE dws.cfg_assistant_level_price (
price_id integer DEFAULT nextval('dws.cfg_assistant_level_price_price_id_seq'::regclass) NOT NULL,
@@ -102,7 +108,7 @@ CREATE TABLE dws.cfg_performance_tier (
min_hours numeric(10,2) NOT NULL,
max_hours numeric(10,2),
base_deduction numeric(10,2) DEFAULT 0 NOT NULL,
bonus_deduction_ratio numeric(5,4) DEFAULT 0 NOT NULL,
bonus_deduction_ratio numeric(7,4) DEFAULT 0 NOT NULL,
vacation_days integer DEFAULT 0 NOT NULL,
vacation_unlimited boolean DEFAULT false NOT NULL,
is_new_hire_tier boolean DEFAULT false NOT NULL,
@@ -215,7 +221,7 @@ CREATE TABLE dws.dws_assistant_finance_analysis (
revenue_room numeric(14,2) DEFAULT 0 NOT NULL,
cost_daily numeric(14,2) DEFAULT 0 NOT NULL,
gross_profit numeric(14,2) DEFAULT 0 NOT NULL,
gross_margin numeric(5,4) DEFAULT 0 NOT NULL,
gross_margin numeric(7,4) DEFAULT 0 NOT NULL,
service_count integer DEFAULT 0 NOT NULL,
service_hours numeric(10,2) DEFAULT 0 NOT NULL,
room_service_count integer DEFAULT 0 NOT NULL,
@@ -265,8 +271,8 @@ CREATE TABLE dws.dws_assistant_monthly_summary (
CREATE TABLE dws.dws_assistant_order_contribution (
contribution_id bigint DEFAULT nextval('dws.dws_assistant_order_contribution_contribution_id_seq'::regclass) NOT NULL,
site_id integer NOT NULL,
tenant_id integer NOT NULL,
site_id bigint NOT NULL,
tenant_id bigint NOT NULL,
assistant_id bigint NOT NULL,
assistant_nickname character varying(100),
stat_date date NOT NULL,
@@ -291,7 +297,7 @@ CREATE TABLE dws.dws_assistant_recharge_commission (
recharge_order_no character varying(50),
recharge_amount numeric(12,2) DEFAULT 0 NOT NULL,
commission_amount numeric(12,2) DEFAULT 0 NOT NULL,
commission_ratio numeric(5,4),
commission_ratio numeric(7,4),
import_batch_no character varying(50),
import_file_name character varying(200),
import_time timestamp with time zone,
@@ -323,7 +329,7 @@ CREATE TABLE dws.dws_assistant_salary_calc (
base_course_price numeric(10,2) DEFAULT 0 NOT NULL,
bonus_course_price numeric(10,2) DEFAULT 0 NOT NULL,
base_deduction numeric(10,2) DEFAULT 0 NOT NULL,
bonus_deduction_ratio numeric(5,4) DEFAULT 0 NOT NULL,
bonus_deduction_ratio numeric(7,4) DEFAULT 0 NOT NULL,
base_income numeric(12,2) DEFAULT 0 NOT NULL,
bonus_income numeric(12,2) DEFAULT 0 NOT NULL,
room_income numeric(12,2) DEFAULT 0 NOT NULL,
@@ -366,7 +372,7 @@ CREATE TABLE dws.dws_finance_daily_summary (
platform_fee_amount numeric(14,2) DEFAULT 0 NOT NULL,
recharge_cash_inflow numeric(14,2) DEFAULT 0 NOT NULL,
card_consume_total numeric(14,2) DEFAULT 0 NOT NULL,
cash_card_consume numeric(14,2) DEFAULT 0 NOT NULL,
recharge_card_consume numeric(14,2) DEFAULT 0 NOT NULL,
gift_card_consume numeric(14,2) DEFAULT 0 NOT NULL,
cash_outflow_total numeric(14,2) DEFAULT 0 NOT NULL,
cash_balance_change numeric(14,2) DEFAULT 0 NOT NULL,
@@ -394,7 +400,7 @@ CREATE TABLE dws.dws_finance_discount_detail (
discount_type_code character varying(30) NOT NULL,
discount_type_name character varying(50) NOT NULL,
discount_amount numeric(14,2) DEFAULT 0 NOT NULL,
discount_ratio numeric(5,4) DEFAULT 0 NOT NULL,
discount_ratio numeric(7,4) DEFAULT 0 NOT NULL,
usage_count integer DEFAULT 0 NOT NULL,
affected_orders integer DEFAULT 0 NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
@@ -429,7 +435,7 @@ CREATE TABLE dws.dws_finance_income_structure (
category_code character varying(30) NOT NULL,
category_name character varying(50) NOT NULL,
income_amount numeric(14,2) DEFAULT 0 NOT NULL,
income_ratio numeric(5,4) DEFAULT 0 NOT NULL,
income_ratio numeric(7,4) DEFAULT 0 NOT NULL,
order_count integer DEFAULT 0 NOT NULL,
duration_minutes integer DEFAULT 0 NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL,
@@ -564,7 +570,7 @@ CREATE TABLE dws.dws_member_assistant_intimacy (
score_recency numeric(10,4),
score_recharge numeric(10,4),
score_duration numeric(10,4),
burst_multiplier numeric(6,4),
burst_multiplier numeric(7,4),
raw_score numeric(14,6),
display_score numeric(4,2),
calc_time timestamp with time zone DEFAULT now() NOT NULL,
@@ -720,7 +726,7 @@ CREATE TABLE dws.dws_member_recall_index (
CREATE TABLE dws.dws_member_spending_power_index (
spi_id bigint DEFAULT nextval('dws.dws_member_spending_power_index_spi_id_seq'::regclass) NOT NULL,
site_id integer NOT NULL,
site_id bigint NOT NULL,
member_id bigint NOT NULL,
spend_30 numeric(14,2) DEFAULT 0,
spend_90 numeric(14,2) DEFAULT 0,
@@ -767,7 +773,8 @@ CREATE TABLE dws.dws_member_visit_detail (
total_discount numeric(12,2) DEFAULT 0 NOT NULL,
actual_pay numeric(12,2) DEFAULT 0 NOT NULL,
cash_pay numeric(12,2) DEFAULT 0 NOT NULL,
cash_card_pay numeric(12,2) DEFAULT 0 NOT NULL,
balance_pay numeric(12,2) DEFAULT 0 NOT NULL,
recharge_card_pay numeric(12,2) DEFAULT 0 NOT NULL,
gift_card_pay numeric(12,2) DEFAULT 0 NOT NULL,
groupbuy_pay numeric(12,2) DEFAULT 0 NOT NULL,
table_duration_min integer DEFAULT 0 NOT NULL,
@@ -1310,7 +1317,7 @@ SELECT id,
platform_fee_amount,
recharge_cash_inflow,
card_consume_total,
cash_card_consume,
recharge_card_consume,
gift_card_consume,
cash_outflow_total,
cash_balance_change,
@@ -1357,7 +1364,7 @@ SELECT id,
platform_fee_amount,
recharge_cash_inflow,
card_consume_total,
cash_card_consume,
recharge_card_consume,
gift_card_consume,
cash_outflow_total,
cash_balance_change,
@@ -1404,7 +1411,7 @@ SELECT id,
platform_fee_amount,
recharge_cash_inflow,
card_consume_total,
cash_card_consume,
recharge_card_consume,
gift_card_consume,
cash_outflow_total,
cash_balance_change,
@@ -1451,7 +1458,7 @@ SELECT id,
platform_fee_amount,
recharge_cash_inflow,
card_consume_total,
cash_card_consume,
recharge_card_consume,
gift_card_consume,
cash_outflow_total,
cash_balance_change,
@@ -1483,3 +1490,69 @@ CREATE INDEX idx_mv_finance_daily_l2 ON dws.mv_dws_finance_daily_summary_l2 USIN
CREATE INDEX idx_mv_finance_daily_l3 ON dws.mv_dws_finance_daily_summary_l3 USING btree (site_id, stat_date);
CREATE INDEX idx_mv_finance_daily_l4 ON dws.mv_dws_finance_daily_summary_l4 USING btree (site_id, stat_date);
-- =============================================================================
-- 项目标签表2026-03-07 新增)
-- =============================================================================
CREATE SEQUENCE IF NOT EXISTS dws.dws_assistant_project_tag_id_seq AS bigint;
CREATE SEQUENCE IF NOT EXISTS dws.dws_member_project_tag_id_seq AS bigint;
CREATE TABLE dws.dws_assistant_project_tag (
id BIGSERIAL NOT NULL,
site_id BIGINT NOT NULL,
tenant_id BIGINT NOT NULL,
assistant_id BIGINT NOT NULL,
time_window VARCHAR(40) NOT NULL,
category_code VARCHAR(30) NOT NULL,
category_name VARCHAR(50) NOT NULL,
short_name VARCHAR(10) NOT NULL,
duration_seconds BIGINT NOT NULL DEFAULT 0,
total_seconds BIGINT NOT NULL DEFAULT 0,
percentage NUMERIC(5,4) NOT NULL DEFAULT 0,
is_tagged BOOLEAN NOT NULL DEFAULT FALSE,
computed_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT pk_dws_assistant_project_tag PRIMARY KEY (id),
CONSTRAINT uk_dws_assistant_project_tag
UNIQUE (site_id, assistant_id, time_window, category_code)
);
COMMENT ON TABLE dws.dws_assistant_project_tag IS '助教项目标签按时间窗口计算各项目时长占比≥25%分配标签';
COMMENT ON COLUMN dws.dws_assistant_project_tag.time_window IS '时间窗口THIS_MONTH/THIS_QUARTER/LAST_MONTH/LAST_3_MONTHS_EXCL_CURRENT/LAST_QUARTER/LAST_6_MONTHS';
COMMENT ON COLUMN dws.dws_assistant_project_tag.is_tagged IS '占比≥0.25时为TRUE表示该助教拥有此项目标签';
CREATE TABLE dws.dws_member_project_tag (
id BIGSERIAL NOT NULL,
site_id BIGINT NOT NULL,
tenant_id BIGINT NOT NULL,
member_id BIGINT NOT NULL,
time_window VARCHAR(40) NOT NULL,
category_code VARCHAR(30) NOT NULL,
category_name VARCHAR(50) NOT NULL,
short_name VARCHAR(10) NOT NULL,
duration_seconds BIGINT NOT NULL DEFAULT 0,
total_seconds BIGINT NOT NULL DEFAULT 0,
percentage NUMERIC(5,4) NOT NULL DEFAULT 0,
is_tagged BOOLEAN NOT NULL DEFAULT FALSE,
computed_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT pk_dws_member_project_tag PRIMARY KEY (id),
CONSTRAINT uk_dws_member_project_tag
UNIQUE (site_id, member_id, time_window, category_code)
);
COMMENT ON TABLE dws.dws_member_project_tag IS '客户项目标签按时间窗口计算各项目消费时长占比≥25%分配标签';
COMMENT ON COLUMN dws.dws_member_project_tag.time_window IS '时间窗口LAST_30_DAYS/LAST_60_DAYS';
COMMENT ON COLUMN dws.dws_member_project_tag.is_tagged IS '占比≥0.25时为TRUE表示该客户拥有此项目标签';
-- 部分索引(加速看板查询)
CREATE INDEX idx_apt_site_window_tagged
ON dws.dws_assistant_project_tag (site_id, time_window)
WHERE is_tagged = TRUE;
CREATE INDEX idx_mpt_site_window_tagged
ON dws.dws_member_project_tag (site_id, time_window)
WHERE is_tagged = TRUE;