ODS 完成

This commit is contained in:
Neo
2025-11-30 07:19:05 +08:00
parent b9b050bb5d
commit a6ad343092
81 changed files with 15695 additions and 227180 deletions

View File

@@ -1,7 +1,7 @@
-- Data warehouse schema for the entertainment chain (ODS -> DWD -> DWS)
-- ASCII only to keep cross-platform friendly.
-- ---------- Schemas ----------
DROP SCHEMA IF EXISTS billiards_ods CASCADE;
CREATE SCHEMA IF NOT EXISTS billiards_ods;
CREATE SCHEMA IF NOT EXISTS billiards_dwd;
CREATE SCHEMA IF NOT EXISTS billiards_dws;
@@ -13,6 +13,9 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_member_profile (
tenant_id BIGINT,
site_id BIGINT NOT NULL,
member_id BIGINT NOT NULL,
system_member_id BIGINT,
register_site_id BIGINT,
site_name TEXT,
member_name TEXT,
nickname TEXT,
mobile TEXT,
@@ -21,13 +24,17 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_member_profile (
register_time TIMESTAMPTZ,
member_type_id BIGINT,
member_type_name TEXT,
member_card_grade_code TEXT,
status TEXT,
user_status TEXT,
balance NUMERIC(18,2),
points NUMERIC(18,2),
growth_value NUMERIC(18,2),
last_visit_time TIMESTAMPTZ,
wechat_id TEXT,
alipay_id TEXT,
member_card_no TEXT,
referrer_member_id BIGINT,
remarks TEXT,
source_file TEXT,
source_endpoint TEXT,
@@ -41,16 +48,28 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_member_card (
site_id BIGINT NOT NULL,
card_id BIGINT NOT NULL,
member_id BIGINT,
tenant_member_id BIGINT,
card_type_id BIGINT,
card_type_name TEXT,
card_no TEXT,
card_physics_type TEXT,
card_balance NUMERIC(18,2),
denomination NUMERIC(18,2),
discount_rate NUMERIC(8,4),
table_discount NUMERIC(18,2),
goods_discount NUMERIC(18,2),
assistant_discount NUMERIC(18,2),
assistant_reward_discount NUMERIC(18,2),
valid_start_date DATE,
valid_end_date DATE,
disable_start_date DATE,
disable_end_date DATE,
last_consume_time TIMESTAMPTZ,
status TEXT,
is_delete BOOLEAN,
activate_time TIMESTAMPTZ,
deactivate_time TIMESTAMPTZ,
register_site_id BIGINT,
issuer_id BIGINT,
issuer_name TEXT,
source_file TEXT,
@@ -65,12 +84,20 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_balance_change (
site_id BIGINT NOT NULL,
change_id BIGINT NOT NULL,
member_id BIGINT,
tenant_member_id BIGINT,
tenant_member_card_id BIGINT,
member_name TEXT,
member_mobile TEXT,
change_amount NUMERIC(18,2),
balance_before NUMERIC(18,2),
balance_after NUMERIC(18,2),
change_type INT,
payment_method INT,
refund_amount NUMERIC(18,2),
relate_id BIGINT,
pay_method INT,
register_site_id BIGINT,
register_site_name TEXT,
pay_site_name TEXT,
remark TEXT,
operator_id BIGINT,
operator_name TEXT,
@@ -112,8 +139,16 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_product (
goods_code TEXT,
category_id BIGINT,
category_name TEXT,
goods_second_category_id BIGINT,
unit TEXT,
price NUMERIC(18,2),
cost_price NUMERIC(18,2),
market_price NUMERIC(18,2),
goods_state TEXT,
goods_cover TEXT,
goods_bar_code TEXT,
able_discount BOOLEAN,
is_delete BOOLEAN,
status TEXT,
source_file TEXT,
source_endpoint TEXT,
@@ -130,8 +165,16 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_store_product (
goods_name TEXT,
category_id BIGINT,
category_name TEXT,
unit TEXT,
sale_price NUMERIC(18,2),
cost_price NUMERIC(18,2),
sale_num NUMERIC(18,2),
stock_a NUMERIC(18,2),
stock NUMERIC(18,2),
provisional_total_cost NUMERIC(18,2),
total_purchase_cost NUMERIC(18,2),
batch_stock_quantity NUMERIC(18,2),
goods_state TEXT,
status TEXT,
source_file TEXT,
source_endpoint TEXT,
@@ -144,17 +187,32 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_store_sale_item (
tenant_id BIGINT,
site_id BIGINT NOT NULL,
sale_item_id BIGINT NOT NULL,
order_goods_id BIGINT,
order_trade_no TEXT,
order_settle_id BIGINT,
site_goods_id BIGINT,
goods_id BIGINT,
goods_name TEXT,
category_id BIGINT,
quantity NUMERIC(18,4),
unit_price NUMERIC(18,2),
original_amount NUMERIC(18,2),
discount_amount NUMERIC(18,2),
final_amount NUMERIC(18,2),
is_gift BOOLEAN DEFAULT FALSE,
sale_time TIMESTAMPTZ,
member_id BIGINT,
salesman_id BIGINT,
operator_id BIGINT,
is_refunded BOOLEAN DEFAULT FALSE,
discount_price NUMERIC(18,2),
cost_money NUMERIC(18,2),
coupon_deduct_amount NUMERIC(18,2),
member_discount_amount NUMERIC(18,2),
point_discount_money NUMERIC(18,2),
point_discount_cost NUMERIC(18,2),
sales_type TEXT,
goods_remark TEXT,
source_file TEXT,
source_endpoint TEXT,
fetched_at TIMESTAMPTZ DEFAULT now(),
@@ -170,6 +228,18 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_table_info (
table_name TEXT,
table_type TEXT,
area_name TEXT,
site_table_area_id BIGINT,
tenant_table_area_id BIGINT,
table_price NUMERIC(18,2),
table_status TEXT,
audit_status INT,
show_status INT,
light_status INT,
virtual_table BOOLEAN,
is_rest_area BOOLEAN,
charge_free BOOLEAN,
table_cloth_use_time INT,
table_cloth_use_cycle INT,
status TEXT,
created_time TIMESTAMPTZ,
updated_time TIMESTAMPTZ,
@@ -185,15 +255,42 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_table_use_log (
site_id BIGINT NOT NULL,
ledger_id BIGINT NOT NULL,
table_id BIGINT,
table_name TEXT,
order_trade_no TEXT,
order_settle_id BIGINT,
start_time TIMESTAMPTZ,
end_time TIMESTAMPTZ,
duration_minutes INT,
duration_seconds INT,
billing_unit_price NUMERIC(18,4),
billing_count NUMERIC(18,4),
original_table_fee NUMERIC(18,2),
discount_amount NUMERIC(18,2),
member_discount_amount NUMERIC(18,2),
coupon_discount_amount NUMERIC(18,2),
manual_discount_amount NUMERIC(18,2),
service_fee NUMERIC(18,2),
final_table_fee NUMERIC(18,2),
member_id BIGINT,
operator_id BIGINT,
salesman_id BIGINT,
is_canceled BOOLEAN DEFAULT FALSE,
cancel_time TIMESTAMPTZ,
site_table_area_id BIGINT,
tenant_table_area_id BIGINT,
site_table_area_name TEXT,
is_single_order BOOLEAN,
used_card_amount NUMERIC(18,2),
adjust_amount NUMERIC(18,2),
coupon_promotion_amount NUMERIC(18,2),
service_money NUMERIC(18,2),
mgmt_fee NUMERIC(18,2),
fee_total NUMERIC(18,2),
real_table_use_seconds INT,
last_use_time TIMESTAMPTZ,
ledger_start_time TIMESTAMPTZ,
ledger_end_time TIMESTAMPTZ,
ledger_status INT,
start_use_time TIMESTAMPTZ,
add_clock_seconds INT,
status TEXT,
source_file TEXT,
source_endpoint TEXT,
@@ -226,8 +323,16 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_assistant_account (
assistant_id BIGINT NOT NULL,
assistant_name TEXT,
mobile TEXT,
assistant_no INT,
team_id BIGINT,
team_name TEXT,
group_id BIGINT,
group_name TEXT,
job_num TEXT,
entry_type TEXT,
leave_status TEXT,
assistant_status TEXT,
allow_cx BOOLEAN,
status TEXT,
hired_date DATE,
left_date DATE,
@@ -243,16 +348,27 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_assistant_service_log (
site_id BIGINT NOT NULL,
ledger_id BIGINT NOT NULL,
assistant_id BIGINT,
assistant_name TEXT,
service_type TEXT,
order_trade_no TEXT,
order_settle_id BIGINT,
start_time TIMESTAMPTZ,
end_time TIMESTAMPTZ,
duration_minutes INT,
duration_seconds INT,
original_fee NUMERIC(18,2),
discount_amount NUMERIC(18,2),
member_discount_amount NUMERIC(18,2),
manual_discount_amount NUMERIC(18,2),
coupon_discount_amount NUMERIC(18,2),
final_fee NUMERIC(18,2),
member_id BIGINT,
operator_id BIGINT,
salesman_id BIGINT,
is_canceled BOOLEAN DEFAULT FALSE,
cancel_time TIMESTAMPTZ,
skill_grade NUMERIC(10,2),
service_grade NUMERIC(10,2),
composite_grade NUMERIC(10,2),
overall_score NUMERIC(10,2),
status TEXT,
source_file TEXT,
source_endpoint TEXT,
@@ -268,6 +384,13 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_assistant_cancel_log (
ledger_id BIGINT,
assistant_id BIGINT,
order_trade_no TEXT,
table_id BIGINT,
table_area_id BIGINT,
table_area_name TEXT,
table_name TEXT,
assistant_on INT,
pd_charge_minutes INT,
assistant_abolish_amount NUMERIC(18,2),
reason TEXT,
cancel_time TIMESTAMPTZ,
operator_id BIGINT,
@@ -284,12 +407,24 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_group_package (
site_id BIGINT NOT NULL,
package_id BIGINT NOT NULL,
package_name TEXT,
table_area_id BIGINT,
table_area_name TEXT,
platform_code TEXT,
status TEXT,
face_price NUMERIC(18,2),
settle_price NUMERIC(18,2),
selling_price NUMERIC(18,2),
duration INT,
valid_from DATE,
valid_to DATE,
start_time TIMESTAMPTZ,
end_time TIMESTAMPTZ,
is_enabled BOOLEAN,
is_delete BOOLEAN,
package_type TEXT,
usable_count INT,
creator_name TEXT,
tenant_table_area_id BIGINT,
source_file TEXT,
source_endpoint TEXT,
fetched_at TIMESTAMPTZ DEFAULT now(),
@@ -310,6 +445,7 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_group_package_log (
used_time TIMESTAMPTZ,
deduct_amount NUMERIC(18,2),
settle_price NUMERIC(18,2),
coupon_code TEXT,
source_file TEXT,
source_endpoint TEXT,
fetched_at TIMESTAMPTZ DEFAULT now(),
@@ -323,6 +459,8 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_platform_coupon_log (
coupon_id BIGINT NOT NULL,
platform_code TEXT,
verify_code TEXT,
coupon_code TEXT,
coupon_channel TEXT,
order_trade_no TEXT,
order_settle_id BIGINT,
member_id BIGINT,
@@ -330,6 +468,7 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_platform_coupon_log (
used_time TIMESTAMPTZ,
deduct_amount NUMERIC(18,2),
settle_price NUMERIC(18,2),
coupon_money NUMERIC(18,2),
source_file TEXT,
source_endpoint TEXT,
fetched_at TIMESTAMPTZ DEFAULT now(),
@@ -343,11 +482,19 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_inventory_change (
change_id BIGINT NOT NULL,
site_goods_id BIGINT,
goods_id BIGINT,
stock_type TEXT,
change_amount NUMERIC(18,2),
before_stock NUMERIC(18,2),
after_stock NUMERIC(18,2),
change_amount_alt NUMERIC(18,2),
before_stock_alt NUMERIC(18,2),
after_stock_alt NUMERIC(18,2),
change_type TEXT,
relate_id BIGINT,
unit TEXT,
price NUMERIC(18,2),
goods_category_id BIGINT,
goods_second_category_id BIGINT,
remark TEXT,
operator_id BIGINT,
operator_name TEXT,
@@ -364,8 +511,20 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_inventory_stock (
site_id BIGINT NOT NULL,
site_goods_id BIGINT NOT NULL,
goods_id BIGINT,
goods_name TEXT,
goods_unit TEXT,
goods_category_id BIGINT,
goods_second_category_id BIGINT,
range_start_stock NUMERIC(18,2),
range_end_stock NUMERIC(18,2),
range_in NUMERIC(18,2),
range_out NUMERIC(18,2),
range_inventory NUMERIC(18,2),
range_sale NUMERIC(18,2),
range_sale_money NUMERIC(18,2),
current_stock NUMERIC(18,2),
cost_price NUMERIC(18,2),
category_name TEXT,
snapshot_key TEXT NOT NULL DEFAULT 'default',
source_file TEXT,
source_endpoint TEXT,
@@ -383,6 +542,7 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_order_settle (
settle_type INT,
settle_status INT,
member_id BIGINT,
member_name TEXT,
member_phone TEXT,
table_id BIGINT,
consume_money NUMERIC(18,2),
@@ -392,6 +552,9 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_order_settle (
assistant_pd_money NUMERIC(18,2),
assistant_cx_money NUMERIC(18,2),
pay_amount NUMERIC(18,2),
cash_amount NUMERIC(18,2),
online_amount NUMERIC(18,2),
point_amount NUMERIC(18,2),
coupon_amount NUMERIC(18,2),
card_amount NUMERIC(18,2),
balance_amount NUMERIC(18,2),
@@ -399,9 +562,33 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_order_settle (
prepay_money NUMERIC(18,2),
adjust_amount NUMERIC(18,2),
rounding_amount NUMERIC(18,2),
member_discount_amount NUMERIC(18,2),
coupon_sale_amount NUMERIC(18,2),
goods_promotion_money NUMERIC(18,2),
assistant_promotion_money NUMERIC(18,2),
point_discount_price NUMERIC(18,2),
point_discount_cost NUMERIC(18,2),
real_goods_money NUMERIC(18,2),
assistant_manual_discount NUMERIC(18,2),
all_coupon_discount NUMERIC(18,2),
is_use_coupon BOOLEAN,
is_use_discount BOOLEAN,
is_activity BOOLEAN,
is_bind_member BOOLEAN,
is_first BOOLEAN,
recharge_card_amount NUMERIC(18,2),
gift_card_amount NUMERIC(18,2),
payment_method INT,
create_time TIMESTAMPTZ,
pay_time TIMESTAMPTZ,
revoke_order_id BIGINT,
revoke_order_name TEXT,
revoke_time TIMESTAMPTZ,
can_be_revoked BOOLEAN,
serial_number TEXT,
sales_man_name TEXT,
sales_man_user_id BIGINT,
order_remark TEXT,
operator_id BIGINT,
operator_name TEXT,
source_file TEXT,
@@ -436,8 +623,13 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_payment_record (
member_id BIGINT,
pay_method_code TEXT,
pay_method_name TEXT,
pay_status INT,
pay_amount NUMERIC(18,2),
pay_time TIMESTAMPTZ,
online_pay_channel TEXT,
transaction_id TEXT,
operator_id BIGINT,
remark TEXT,
relate_type TEXT,
relate_id BIGINT,
source_file TEXT,
@@ -454,10 +646,34 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_refund_record (
order_trade_no TEXT,
order_settle_id BIGINT,
member_id BIGINT,
pay_sn TEXT,
pay_amount NUMERIC(18,2),
pay_status INT,
is_revoke BOOLEAN,
is_delete BOOLEAN,
online_pay_channel TEXT,
pay_method_code TEXT,
refund_amount NUMERIC(18,2),
refund_time TIMESTAMPTZ,
action_type INT,
pay_terminal INT,
pay_config_id BIGINT,
cashier_point_id BIGINT,
operator_id BIGINT,
member_card_id BIGINT,
balance_frozen_amount NUMERIC(18,2),
card_frozen_amount NUMERIC(18,2),
round_amount NUMERIC(18,2),
online_pay_type INT,
channel_payer_id TEXT,
channel_pay_no TEXT,
check_status INT,
channel_fee NUMERIC(18,2),
relate_type TEXT,
relate_id BIGINT,
status TEXT,
reason TEXT,
related_payment_id BIGINT,
source_file TEXT,
source_endpoint TEXT,
fetched_at TIMESTAMPTZ DEFAULT now(),
@@ -470,13 +686,36 @@ CREATE TABLE IF NOT EXISTS billiards_ods.ods_order_receipt_detail (
site_id BIGINT NOT NULL,
order_settle_id BIGINT NOT NULL,
order_trade_no TEXT,
order_settle_number TEXT,
settle_type INT,
receipt_no TEXT,
receipt_time TIMESTAMPTZ,
total_amount NUMERIC(18,2),
discount_amount NUMERIC(18,2),
final_amount NUMERIC(18,2),
actual_payment NUMERIC(18,2),
ledger_amount NUMERIC(18,2),
member_offer_amount NUMERIC(18,2),
delivery_fee NUMERIC(18,2),
adjust_amount NUMERIC(18,2),
payment_method INT,
pay_time TIMESTAMPTZ,
member_id BIGINT,
order_remark TEXT,
cashier_name TEXT,
ticket_remark TEXT,
ticket_custom_content TEXT,
voucher_money NUMERIC(18,2),
reward_name TEXT,
consume_money NUMERIC(18,2),
refund_amount NUMERIC(18,2),
balance_amount NUMERIC(18,2),
coupon_amount NUMERIC(18,2),
member_deduct_amount NUMERIC(18,2),
prepay_money NUMERIC(18,2),
delivery_address TEXT,
snapshot_raw JSONB,
member_snapshot JSONB,
source_file TEXT,
source_endpoint TEXT,
fetched_at TIMESTAMPTZ DEFAULT now(),