chore: 文档与 IDE 配置整理
- .kiro/specs/ → docs/specs/(41 个历史需求 spec 迁移,移除 .config.kiro) - CLAUDE.md 三层拆分:根文件精简 + apps/backend/CLAUDE.md + .claude/commands/ - 新增 /spec-close、/pre-change 两个工作流命令 - DDL 基线刷新(从测试库重新导出 11 个文件,dws 35→38 表,biz 18→21 表) - BD_Manual → BD_manual 命名统一(48 个文件) - 修复 3 处文档与数据库不一致(auth.users.status 默认值、scheduled_tasks 字段、RLS 视图数) - 新增 BD_manual_public_rbac_tables.md(public schema 8 张 RBAC/工作流表) - 合并 biz.trigger_jobs 文档(10→12 字段,归档独立文档) - docs/database/README.md 索引更新 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
-- =============================================================================
|
||||
-- etl_feiqiu / app(RLS 视图层)
|
||||
-- 生成日期:2026-03-15
|
||||
-- 生成日期:2026-04-05
|
||||
-- 来源:测试库(通过脚本自动导出)
|
||||
-- =============================================================================
|
||||
|
||||
@@ -39,6 +39,17 @@ SELECT id,
|
||||
FROM dws.dws_assistant_daily_detail d;
|
||||
;
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_cfg_area_category AS
|
||||
SELECT DISTINCT category_code,
|
||||
category_name,
|
||||
display_name,
|
||||
short_name,
|
||||
sort_order
|
||||
FROM dws.cfg_area_category
|
||||
WHERE ((is_active = true) AND ((category_code)::text <> ALL ((ARRAY['SPECIAL'::character varying, 'OTHER'::character varying])::text[])))
|
||||
ORDER BY sort_order;
|
||||
;
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_cfg_assistant_level_price AS
|
||||
SELECT price_id,
|
||||
level_code,
|
||||
@@ -104,19 +115,6 @@ SELECT tier_id,
|
||||
FROM dws.cfg_performance_tier;
|
||||
;
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_cfg_area_category AS
|
||||
SELECT DISTINCT
|
||||
category_code,
|
||||
category_name,
|
||||
display_name,
|
||||
short_name,
|
||||
sort_order
|
||||
FROM dws.cfg_area_category
|
||||
WHERE is_active = TRUE
|
||||
AND category_code NOT IN ('SPECIAL', 'OTHER')
|
||||
ORDER BY sort_order;
|
||||
;
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_dim_assistant AS
|
||||
SELECT assistant_id,
|
||||
user_id,
|
||||
@@ -606,6 +604,26 @@ SELECT contribution_id,
|
||||
WHERE (site_id = (current_setting('app.current_site_id'::text))::bigint);
|
||||
;
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_dws_assistant_project_tag AS
|
||||
SELECT id,
|
||||
site_id,
|
||||
tenant_id,
|
||||
assistant_id,
|
||||
time_window,
|
||||
category_code,
|
||||
category_name,
|
||||
short_name,
|
||||
duration_seconds,
|
||||
total_seconds,
|
||||
percentage,
|
||||
is_tagged,
|
||||
computed_at,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM dws.dws_assistant_project_tag
|
||||
WHERE (site_id = (current_setting('app.current_site_id'::text))::bigint);
|
||||
;
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_dws_assistant_recharge_commission AS
|
||||
SELECT id,
|
||||
site_id,
|
||||
@@ -671,6 +689,92 @@ SELECT id,
|
||||
WHERE (site_id = (current_setting('app.current_site_id'::text))::bigint);
|
||||
;
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_dws_coach_area_hours AS
|
||||
SELECT id,
|
||||
site_id,
|
||||
tenant_id,
|
||||
stat_month,
|
||||
assistant_id,
|
||||
area_code,
|
||||
base_hours,
|
||||
bonus_hours,
|
||||
room_hours,
|
||||
effective_hours,
|
||||
trashed_hours,
|
||||
base_service_count,
|
||||
bonus_service_count,
|
||||
room_service_count,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM dws.dws_coach_area_hours
|
||||
WHERE (site_id = (current_setting('app.current_site_id'::text))::bigint);
|
||||
;
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_dws_finance_area_daily AS
|
||||
SELECT id,
|
||||
site_id,
|
||||
tenant_id,
|
||||
stat_date,
|
||||
area_code,
|
||||
table_fee_amount,
|
||||
goods_amount,
|
||||
assistant_pd_amount,
|
||||
assistant_cx_amount,
|
||||
gross_amount,
|
||||
discount_groupbuy,
|
||||
discount_vip,
|
||||
discount_manual,
|
||||
discount_gift_card,
|
||||
discount_rounding,
|
||||
discount_other,
|
||||
discount_total,
|
||||
confirmed_income,
|
||||
cash_pay_amount,
|
||||
cash_paper_amount,
|
||||
scan_pay_amount,
|
||||
groupbuy_pay_amount,
|
||||
recharge_cash_inflow,
|
||||
cash_inflow_total,
|
||||
cash_outflow_total,
|
||||
cash_balance_change,
|
||||
card_consume_total,
|
||||
recharge_card_consume,
|
||||
gift_card_consume,
|
||||
recharge_cash,
|
||||
first_recharge_cash,
|
||||
renewal_cash,
|
||||
order_count,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM dws.dws_finance_area_daily
|
||||
WHERE (site_id = (current_setting('app.current_site_id'::text))::bigint);
|
||||
;
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_dws_finance_board_cache AS
|
||||
SELECT id,
|
||||
site_id,
|
||||
time_range,
|
||||
area_code,
|
||||
start_date,
|
||||
end_date,
|
||||
prev_start_date,
|
||||
prev_end_date,
|
||||
occurrence,
|
||||
discount,
|
||||
discount_rate,
|
||||
confirmed_revenue,
|
||||
cash_in,
|
||||
cash_out,
|
||||
cash_balance,
|
||||
balance_rate,
|
||||
data_fingerprint,
|
||||
computed_at,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM dws.dws_finance_board_cache
|
||||
WHERE (site_id = (current_setting('app.current_site_id'::text))::bigint);
|
||||
;
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_dws_finance_daily_summary AS
|
||||
SELECT id,
|
||||
site_id,
|
||||
@@ -691,6 +795,8 @@ SELECT id,
|
||||
confirmed_income,
|
||||
cash_inflow_total,
|
||||
cash_pay_amount,
|
||||
cash_paper_amount,
|
||||
scan_pay_amount,
|
||||
groupbuy_pay_amount,
|
||||
platform_settlement_amount,
|
||||
platform_fee_amount,
|
||||
@@ -963,7 +1069,54 @@ SELECT newconv_id,
|
||||
WHERE (site_id = (current_setting('app.current_site_id'::text))::bigint);
|
||||
;
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_dws_member_project_tag AS
|
||||
SELECT id,
|
||||
site_id,
|
||||
tenant_id,
|
||||
member_id,
|
||||
time_window,
|
||||
category_code,
|
||||
category_name,
|
||||
short_name,
|
||||
duration_seconds,
|
||||
total_seconds,
|
||||
percentage,
|
||||
is_tagged,
|
||||
computed_at,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM dws.dws_member_project_tag
|
||||
WHERE (site_id = (current_setting('app.current_site_id'::text))::bigint);
|
||||
;
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_dws_member_spending_power_index AS
|
||||
SELECT spi_id,
|
||||
site_id,
|
||||
member_id,
|
||||
spend_30,
|
||||
spend_90,
|
||||
recharge_90,
|
||||
orders_30,
|
||||
orders_90,
|
||||
visit_days_30,
|
||||
visit_days_90,
|
||||
avg_ticket_90,
|
||||
active_weeks_90,
|
||||
daily_spend_ewma_90,
|
||||
score_level_raw,
|
||||
score_speed_raw,
|
||||
score_stability_raw,
|
||||
score_level_display,
|
||||
score_speed_display,
|
||||
score_stability_display,
|
||||
raw_score,
|
||||
display_score,
|
||||
calc_time,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM dws.dws_member_spending_power_index
|
||||
WHERE (site_id = (current_setting('app.current_site_id'::text))::bigint);
|
||||
;
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_dws_member_visit_detail AS
|
||||
SELECT id,
|
||||
@@ -1182,34 +1335,3 @@ SELECT site_id,
|
||||
FROM core.dim_site s;
|
||||
;
|
||||
|
||||
|
||||
-- 2026-03-19 新增:BOARD 看板所需的 3 个 RLS 视图
|
||||
-- 迁移脚本:db/etl_feiqiu/migrations/2026-03-19_add_board_rls_views.sql
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_dws_assistant_project_tag AS
|
||||
SELECT id, site_id, tenant_id, assistant_id, time_window,
|
||||
category_code, category_name, short_name,
|
||||
duration_seconds, total_seconds, percentage, is_tagged,
|
||||
computed_at, created_at, updated_at
|
||||
FROM dws.dws_assistant_project_tag
|
||||
WHERE site_id = current_setting('app.current_site_id')::bigint;
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_dws_member_project_tag AS
|
||||
SELECT id, site_id, tenant_id, member_id, time_window,
|
||||
category_code, category_name, short_name,
|
||||
duration_seconds, total_seconds, percentage, is_tagged,
|
||||
computed_at, created_at, updated_at
|
||||
FROM dws.dws_member_project_tag
|
||||
WHERE site_id = current_setting('app.current_site_id')::bigint;
|
||||
|
||||
CREATE OR REPLACE VIEW app.v_dws_member_spending_power_index AS
|
||||
SELECT spi_id, site_id, member_id,
|
||||
spend_30, spend_90, recharge_90,
|
||||
orders_30, orders_90, visit_days_30, visit_days_90,
|
||||
avg_ticket_90, active_weeks_90, daily_spend_ewma_90,
|
||||
score_level_raw, score_speed_raw, score_stability_raw,
|
||||
score_level_display, score_speed_display, score_stability_display,
|
||||
raw_score, display_score,
|
||||
calc_time, created_at, updated_at
|
||||
FROM dws.dws_member_spending_power_index
|
||||
WHERE site_id = current_setting('app.current_site_id')::bigint;
|
||||
|
||||
Reference in New Issue
Block a user