-- 文件：schema_ODS_doc.sql
-- 说明：ODS 层 DDL，表名与示例 JSON 前缀对应，用于本地回放/调试。
-- 编码：UTF-8
SET client_encoding TO "UTF8";

DROP SCHEMA IF EXISTS billiards_ods CASCADE;
CREATE SCHEMA IF NOT EXISTS billiards_ods;

CREATE TABLE IF NOT EXISTS billiards_ods.member_profiles (
    tenant_id                BIGINT,
    register_site_id         BIGINT,
    site_name                TEXT,
    id                       BIGINT PRIMARY KEY,
    system_member_id         BIGINT,
    member_card_grade_code   BIGINT,
    member_card_grade_name   TEXT,
    mobile                   TEXT,
    nickname                 TEXT,
    point                    NUMERIC(18,2),
    growth_value             NUMERIC(18,2),
    referrer_member_id       BIGINT,
    status                   INT,
    user_status              INT,
    create_time              TIMESTAMP,
    source_file              TEXT,
    source_endpoint          TEXT,
    fetched_at               TIMESTAMPTZ DEFAULT now(),
    payload                  JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.member_profiles IS '表用途：ODS 原始明细，对应 JSON 文件 member_profiles.json，详见 member_profiles-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.member_profiles.tenant_id IS '说明：同名 JSON 字段，业务含义详见 member_profiles-Analysis.md；示例：2790683160709957（样例对照）；JSON字段：tenant_id';
COMMENT ON COLUMN billiards_ods.member_profiles.register_site_id IS '说明：同名 JSON 字段，业务含义详见 member_profiles-Analysis.md；示例：2790685415443269（样例对照）；JSON字段：register_site_id';
COMMENT ON COLUMN billiards_ods.member_profiles.site_name IS '说明：同名 JSON 字段，业务含义详见 member_profiles-Analysis.md；示例：朗朗桌球（样例对照）；JSON字段：site_name';
COMMENT ON COLUMN billiards_ods.member_profiles.id IS '说明：同名 JSON 字段，业务含义详见 member_profiles-Analysis.md；示例：2955204541320325（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.member_profiles.system_member_id IS '说明：同名 JSON 字段，业务含义详见 member_profiles-Analysis.md；示例：2955204540009605（样例对照）；JSON字段：system_member_id';
COMMENT ON COLUMN billiards_ods.member_profiles.member_card_grade_code IS '说明：同名 JSON 字段，业务含义详见 member_profiles-Analysis.md；示例：2790683528022853（样例对照）；JSON字段：member_card_grade_code';
COMMENT ON COLUMN billiards_ods.member_profiles.member_card_grade_name IS '说明：同名 JSON 字段，业务含义详见 member_profiles-Analysis.md；示例：储值卡（样例对照）；JSON字段：member_card_grade_name';
COMMENT ON COLUMN billiards_ods.member_profiles.mobile IS '说明：同名 JSON 字段，业务含义详见 member_profiles-Analysis.md；示例：18620043391（样例对照）；JSON字段：mobile';
COMMENT ON COLUMN billiards_ods.member_profiles.nickname IS '说明：同名 JSON 字段，业务含义详见 member_profiles-Analysis.md；示例：胡先生（样例对照）；JSON字段：nickname';
COMMENT ON COLUMN billiards_ods.member_profiles.point IS '说明：同名 JSON 字段，业务含义详见 member_profiles-Analysis.md；示例：0.0（样例对照）；JSON字段：point';
COMMENT ON COLUMN billiards_ods.member_profiles.growth_value IS '说明：同名 JSON 字段，业务含义详见 member_profiles-Analysis.md；示例：0.0（样例对照）；JSON字段：growth_value';
COMMENT ON COLUMN billiards_ods.member_profiles.referrer_member_id IS '说明：同名 JSON 字段，业务含义详见 member_profiles-Analysis.md；示例：0（样例对照）；JSON字段：referrer_member_id';
COMMENT ON COLUMN billiards_ods.member_profiles.status IS '说明：同名 JSON 字段，业务含义详见 member_profiles-Analysis.md；示例：1（样例对照）；JSON字段：status';
COMMENT ON COLUMN billiards_ods.member_profiles.user_status IS '说明：同名 JSON 字段，业务含义详见 member_profiles-Analysis.md；示例：1（样例对照）；JSON字段：user_status';
COMMENT ON COLUMN billiards_ods.member_profiles.create_time IS '说明：同名 JSON 字段，业务含义详见 member_profiles-Analysis.md；示例：2025-11-08 01:29:33（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.member_profiles.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：member_profiles.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.member_profiles.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.member_profiles.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.member_profiles.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.member_balance_changes (
    tenant_id             BIGINT,
    site_id               BIGINT,
    register_site_id      BIGINT,
    registerSiteName      TEXT,
    paySiteName           TEXT,
    id                    BIGINT PRIMARY KEY,
    tenant_member_id      BIGINT,
    tenant_member_card_id BIGINT,
    system_member_id      BIGINT,
    memberName            TEXT,
    memberMobile          TEXT,
    card_type_id          BIGINT,
    memberCardTypeName    TEXT,
    account_data          NUMERIC(18,2),
    before                NUMERIC(18,2),
    after                 NUMERIC(18,2),
    refund_amount         NUMERIC(18,2),
    from_type             INT,
    payment_method        INT,
    relate_id             BIGINT,
    remark                TEXT,
    operator_id           BIGINT,
    operator_name         TEXT,
    is_delete             INT,
    create_time           TIMESTAMP,
    source_file           TEXT,
    source_endpoint       TEXT,
    fetched_at            TIMESTAMPTZ DEFAULT now(),
    payload               JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.member_balance_changes IS '表用途：ODS 原始明细，对应 JSON 文件 member_balance_changes.json，详见 member_balance_changes-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.member_balance_changes.tenant_id IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：2790683160709957（样例对照）；JSON字段：tenant_id';
COMMENT ON COLUMN billiards_ods.member_balance_changes.site_id IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：2790685415443269（样例对照）；JSON字段：site_id';
COMMENT ON COLUMN billiards_ods.member_balance_changes.register_site_id IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：2790685415443269（样例对照）；JSON字段：register_site_id';
COMMENT ON COLUMN billiards_ods.member_balance_changes.registerSiteName IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：朗朗桌球（样例对照）；JSON字段：registerSiteName';
COMMENT ON COLUMN billiards_ods.member_balance_changes.paySiteName IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：朗朗桌球（样例对照）；JSON字段：paySiteName';
COMMENT ON COLUMN billiards_ods.member_balance_changes.id IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：2957881605869253（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.member_balance_changes.tenant_member_id IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：2799212845565701（样例对照）；JSON字段：tenant_member_id';
COMMENT ON COLUMN billiards_ods.member_balance_changes.tenant_member_card_id IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：2799219999295237（样例对照）；JSON字段：tenant_member_card_id';
COMMENT ON COLUMN billiards_ods.member_balance_changes.system_member_id IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：2799212844549893（样例对照）；JSON字段：system_member_id';
COMMENT ON COLUMN billiards_ods.member_balance_changes.memberName IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：曾丹烨（样例对照）；JSON字段：memberName';
COMMENT ON COLUMN billiards_ods.member_balance_changes.memberMobile IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：13922213242（样例对照）；JSON字段：memberMobile';
COMMENT ON COLUMN billiards_ods.member_balance_changes.card_type_id IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：2793249295533893（样例对照）；JSON字段：card_type_id';
COMMENT ON COLUMN billiards_ods.member_balance_changes.memberCardTypeName IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：储值卡（样例对照）；JSON字段：memberCardTypeName';
COMMENT ON COLUMN billiards_ods.member_balance_changes.account_data IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：-120.0（样例对照）；JSON字段：account_data';
COMMENT ON COLUMN billiards_ods.member_balance_changes.before IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：816.3（样例对照）；JSON字段：before';
COMMENT ON COLUMN billiards_ods.member_balance_changes.after IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：696.3（样例对照）；JSON字段：after';
COMMENT ON COLUMN billiards_ods.member_balance_changes.refund_amount IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：0.0（样例对照）；JSON字段：refund_amount';
COMMENT ON COLUMN billiards_ods.member_balance_changes.from_type IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：1（样例对照）；JSON字段：from_type';
COMMENT ON COLUMN billiards_ods.member_balance_changes.payment_method IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：0（样例对照）；JSON字段：payment_method';
COMMENT ON COLUMN billiards_ods.member_balance_changes.relate_id IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：2957881518788421（样例对照）；JSON字段：relate_id';
COMMENT ON COLUMN billiards_ods.member_balance_changes.remark IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：（样例对照）；JSON字段：remark';
COMMENT ON COLUMN billiards_ods.member_balance_changes.operator_id IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：2790687322443013（样例对照）；JSON字段：operator_id';
COMMENT ON COLUMN billiards_ods.member_balance_changes.operator_name IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：收银员:郑丽珊（样例对照）；JSON字段：operator_name';
COMMENT ON COLUMN billiards_ods.member_balance_changes.is_delete IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：0（样例对照）；JSON字段：is_delete';
COMMENT ON COLUMN billiards_ods.member_balance_changes.create_time IS '说明：同名 JSON 字段，业务含义详见 member_balance_changes-Analysis.md；示例：2025-11-09 22:52:48（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.member_balance_changes.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：member_balance_changes.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.member_balance_changes.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.member_balance_changes.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.member_balance_changes.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.member_stored_value_cards (
    tenant_id                         BIGINT,
    tenant_member_id                  BIGINT,
    system_member_id                  BIGINT,
    register_site_id                  BIGINT,
    site_name                         TEXT,
    id                                BIGINT PRIMARY KEY,
    member_card_grade_code            BIGINT,
    member_card_grade_code_name       TEXT,
    member_card_type_name             TEXT,
    member_name                       TEXT,
    member_mobile                     TEXT,
    card_type_id                      BIGINT,
    card_no                           TEXT,
    card_physics_type                 TEXT,
    balance                           NUMERIC(18,2),
    denomination                      NUMERIC(18,2),
    table_discount                    NUMERIC(10,4),
    goods_discount                    NUMERIC(10,4),
    assistant_discount                NUMERIC(10,4),
    assistant_reward_discount         NUMERIC(10,4),
    table_service_discount            NUMERIC(10,4),
    assistant_service_discount        NUMERIC(10,4),
    coupon_discount                   NUMERIC(10,4),
    goods_service_discount            NUMERIC(10,4),
    assistant_discount_sub_switch     INT,
    table_discount_sub_switch         INT,
    goods_discount_sub_switch         INT,
    assistant_reward_discount_sub_switch INT,
    table_service_deduct_radio        NUMERIC(10,4),
    assistant_service_deduct_radio    NUMERIC(10,4),
    goods_service_deduct_radio        NUMERIC(10,4),
    assistant_deduct_radio            NUMERIC(10,4),
    table_deduct_radio                NUMERIC(10,4),
    goods_deduct_radio                NUMERIC(10,4),
    coupon_deduct_radio               NUMERIC(10,4),
    assistant_reward_deduct_radio     NUMERIC(10,4),
    tableCardDeduct                   NUMERIC(18,2),
    tableServiceCardDeduct            NUMERIC(18,2),
    goodsCarDeduct                    NUMERIC(18,2),
    goodsServiceCardDeduct            NUMERIC(18,2),
    assistantCardDeduct               NUMERIC(18,2),
    assistantServiceCardDeduct        NUMERIC(18,2),
    assistantRewardCardDeduct         NUMERIC(18,2),
    cardSettleDeduct                  NUMERIC(18,2),
    couponCardDeduct                  NUMERIC(18,2),
    deliveryFeeDeduct                 NUMERIC(18,2),
    use_scene                         INT,
    able_cross_site                   INT,
    able_site_transfer                INT,
    is_allow_give                     INT,
    is_allow_order_deduct             INT,
    is_delete                         INT,
    bind_password                     TEXT,
    goods_discount_range_type         INT,
    goodsCategoryId                   BIGINT,
    tableAreaId                       BIGINT,
    effect_site_id                    BIGINT,
    start_time                        TIMESTAMP,
    end_time                          TIMESTAMP,
    disable_start_time                TIMESTAMP,
    disable_end_time                  TIMESTAMP,
    last_consume_time                 TIMESTAMP,
    create_time                       TIMESTAMP,
    status                            INT,
    sort                              INT,
    tenantAvatar                      TEXT,
    tenantName                        TEXT,
    pdAssisnatLevel                   TEXT,
    cxAssisnatLevel                   TEXT,
    source_file                       TEXT,
    source_endpoint                   TEXT,
    fetched_at                        TIMESTAMPTZ DEFAULT now(),
    payload                           JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.member_stored_value_cards IS '表用途：ODS 原始明细，对应 JSON 文件 member_stored_value_cards.json，详见 member_stored_value_cards-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.tenant_id IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：2790683160709957（样例对照）；JSON字段：tenant_id';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.tenant_member_id IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：2955204541320325（样例对照）；JSON字段：tenant_member_id';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.system_member_id IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：2955204540009605（样例对照）；JSON字段：system_member_id';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.register_site_id IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：2790685415443269（样例对照）；JSON字段：register_site_id';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.site_name IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：朗朗桌球（样例对照）；JSON字段：site_name';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.id IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：2955206162843781（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.member_card_grade_code IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：2790683528022856（样例对照）；JSON字段：member_card_grade_code';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.member_card_grade_code_name IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：活动抵用券（样例对照）；JSON字段：member_card_grade_code_name';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.member_card_type_name IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：活动抵用券（样例对照）；JSON字段：member_card_type_name';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.member_name IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：胡先生（样例对照）；JSON字段：member_name';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.member_mobile IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：18620043391（样例对照）；JSON字段：member_mobile';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.card_type_id IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：2793266846533445（样例对照）；JSON字段：card_type_id';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.card_no IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：（样例对照）；JSON字段：card_no';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.card_physics_type IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：1（样例对照）；JSON字段：card_physics_type';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.balance IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0.0（样例对照）；JSON字段：balance';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.denomination IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0.0（样例对照）；JSON字段：denomination';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.table_discount IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：10.0（样例对照）；JSON字段：table_discount';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goods_discount IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：10.0（样例对照）；JSON字段：goods_discount';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_discount IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：10.0（样例对照）；JSON字段：assistant_discount';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_reward_discount IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：10.0（样例对照）；JSON字段：assistant_reward_discount';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.table_service_discount IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：10.0（样例对照）；JSON字段：table_service_discount';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_service_discount IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：10.0（样例对照）；JSON字段：assistant_service_discount';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.coupon_discount IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：10.0（样例对照）；JSON字段：coupon_discount';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goods_service_discount IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：10.0（样例对照）；JSON字段：goods_service_discount';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_discount_sub_switch IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：2（样例对照）；JSON字段：assistant_discount_sub_switch';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.table_discount_sub_switch IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：2（样例对照）；JSON字段：table_discount_sub_switch';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goods_discount_sub_switch IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：2（样例对照）；JSON字段：goods_discount_sub_switch';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_reward_discount_sub_switch IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：2（样例对照）；JSON字段：assistant_reward_discount_sub_switch';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.table_service_deduct_radio IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：100.0（样例对照）；JSON字段：table_service_deduct_radio';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_service_deduct_radio IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：100.0（样例对照）；JSON字段：assistant_service_deduct_radio';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goods_service_deduct_radio IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：100.0（样例对照）；JSON字段：goods_service_deduct_radio';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_deduct_radio IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：100.0（样例对照）；JSON字段：assistant_deduct_radio';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.table_deduct_radio IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：100.0（样例对照）；JSON字段：table_deduct_radio';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goods_deduct_radio IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：100.0（样例对照）；JSON字段：goods_deduct_radio';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.coupon_deduct_radio IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：100.0（样例对照）；JSON字段：coupon_deduct_radio';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_reward_deduct_radio IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：100.0（样例对照）；JSON字段：assistant_reward_deduct_radio';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.tableCardDeduct IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0.0（样例对照）；JSON字段：tableCardDeduct';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.tableServiceCardDeduct IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0.0（样例对照）；JSON字段：tableServiceCardDeduct';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goodsCarDeduct IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0.0（样例对照）；JSON字段：goodsCarDeduct';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goodsServiceCardDeduct IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0.0（样例对照）；JSON字段：goodsServiceCardDeduct';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistantCardDeduct IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0.0（样例对照）；JSON字段：assistantCardDeduct';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistantServiceCardDeduct IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0.0（样例对照）；JSON字段：assistantServiceCardDeduct';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistantRewardCardDeduct IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0.0（样例对照）；JSON字段：assistantRewardCardDeduct';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.cardSettleDeduct IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0.0（样例对照）；JSON字段：cardSettleDeduct';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.couponCardDeduct IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0.0（样例对照）；JSON字段：couponCardDeduct';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.deliveryFeeDeduct IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0.0（样例对照）；JSON字段：deliveryFeeDeduct';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.use_scene IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：（样例对照）；JSON字段：use_scene';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.able_cross_site IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：1（样例对照）；JSON字段：able_cross_site';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.able_site_transfer IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：无样例（样例对照）；JSON字段：able_site_transfer';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.is_allow_give IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0（样例对照）；JSON字段：is_allow_give';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.is_allow_order_deduct IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0（样例对照）；JSON字段：is_allow_order_deduct';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.is_delete IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0（样例对照）；JSON字段：is_delete';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.bind_password IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：（样例对照）；JSON字段：bind_password';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goods_discount_range_type IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：1（样例对照）；JSON字段：goods_discount_range_type';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goodsCategoryId IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：[]（样例对照）；JSON字段：goodsCategoryId';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.tableAreaId IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：[]（样例对照）；JSON字段：tableAreaId';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.effect_site_id IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0（样例对照）；JSON字段：effect_site_id';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.start_time IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：2025-11-08 01:31:12（样例对照）；JSON字段：start_time';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.end_time IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：2225-01-01 00:00:00（样例对照）；JSON字段：end_time';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.disable_start_time IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0001-01-01 00:00:00（样例对照）；JSON字段：disable_start_time';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.disable_end_time IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：0001-01-01 00:00:00（样例对照）；JSON字段：disable_end_time';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.last_consume_time IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：2025-11-09 07:48:23（样例对照）；JSON字段：last_consume_time';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.create_time IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：2025-11-08 01:31:12（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.status IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：1（样例对照）；JSON字段：status';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.sort IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：1（样例对照）；JSON字段：sort';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.tenantAvatar IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：（样例对照）；JSON字段：tenantAvatar';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.tenantName IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：（样例对照）；JSON字段：tenantName';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.pdAssisnatLevel IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：[]（样例对照）；JSON字段：pdAssisnatLevel';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.cxAssisnatLevel IS '说明：同名 JSON 字段，业务含义详见 member_stored_value_cards-Analysis.md；示例：[]（样例对照）；JSON字段：cxAssisnatLevel';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：member_stored_value_cards.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.recharge_settlements (
    id                    BIGINT PRIMARY KEY,
    tenantid              BIGINT,
    siteid                BIGINT,
    sitename              TEXT,
    balanceamount         NUMERIC(18,2),
    cardamount            NUMERIC(18,2),
    cashamount            NUMERIC(18,2),
    couponamount          NUMERIC(18,2),
    createtime            TIMESTAMPTZ,
    memberid              BIGINT,
    membername            TEXT,
    tenantmembercardid    BIGINT,
    membercardtypename    TEXT,
    memberphone           TEXT,
    tableid               BIGINT,
    consumemoney          NUMERIC(18,2),
    onlineamount          NUMERIC(18,2),
    operatorid            BIGINT,
    operatorname          TEXT,
    revokeorderid         BIGINT,
    revokeordername       TEXT,
    revoketime            TIMESTAMPTZ,
    payamount             NUMERIC(18,2),
    pointamount           NUMERIC(18,2),
    refundamount          NUMERIC(18,2),
    settlename            TEXT,
    settlerelateid        BIGINT,
    settlestatus          INT,
    settletype            INT,
    paytime               TIMESTAMPTZ,
    roundingamount        NUMERIC(18,2),
    paymentmethod         INT,
    adjustamount          NUMERIC(18,2),
    assistantcxmoney      NUMERIC(18,2),
    assistantpdmoney      NUMERIC(18,2),
    couponsaleamount      NUMERIC(18,2),
    memberdiscountamount  NUMERIC(18,2),
    tablechargemoney      NUMERIC(18,2),
    goodsmoney            NUMERIC(18,2),
    realgoodsmoney        NUMERIC(18,2),
    servicemoney          NUMERIC(18,2),
    prepaymoney           NUMERIC(18,2),
    salesmanname          TEXT,
    orderremark           TEXT,
    salesmanuserid        BIGINT,
    canberevoked          BOOLEAN,
    pointdiscountprice    NUMERIC(18,2),
    pointdiscountcost     NUMERIC(18,2),
    activitydiscount      NUMERIC(18,2),
    serialnumber          BIGINT,
    assistantmanualdiscount NUMERIC(18,2),
    allcoupondiscount     NUMERIC(18,2),
    goodspromotionmoney   NUMERIC(18,2),
    assistantpromotionmoney NUMERIC(18,2),
    isusecoupon           BOOLEAN,
    isusediscount         BOOLEAN,
    isactivity            BOOLEAN,
    isbindmember          BOOLEAN,
    isfirst               INT,
    rechargecardamount    NUMERIC(18,2),
    giftcardamount        NUMERIC(18,2),
    source_file           TEXT,
    source_endpoint       TEXT,
    fetched_at            TIMESTAMPTZ DEFAULT now(),
    payload               JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.recharge_settlements IS '表用途：ODS 原始明细，对应 JSON 文件 recharge_settlements.json，详见 recharge_settlements-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.recharge_settlements.id IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.recharge_settlements.tenantid IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：tenantid';
COMMENT ON COLUMN billiards_ods.recharge_settlements.siteid IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：siteid';
COMMENT ON COLUMN billiards_ods.recharge_settlements.sitename IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：sitename';
COMMENT ON COLUMN billiards_ods.recharge_settlements.balanceamount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：balanceamount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.cardamount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：cardamount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.cashamount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：cashamount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.couponamount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：couponamount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.createtime IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：createtime';
COMMENT ON COLUMN billiards_ods.recharge_settlements.memberid IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：memberid';
COMMENT ON COLUMN billiards_ods.recharge_settlements.membername IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：membername';
COMMENT ON COLUMN billiards_ods.recharge_settlements.tenantmembercardid IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：tenantmembercardid';
COMMENT ON COLUMN billiards_ods.recharge_settlements.membercardtypename IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：membercardtypename';
COMMENT ON COLUMN billiards_ods.recharge_settlements.memberphone IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：memberphone';
COMMENT ON COLUMN billiards_ods.recharge_settlements.tableid IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：tableid';
COMMENT ON COLUMN billiards_ods.recharge_settlements.consumemoney IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：consumemoney';
COMMENT ON COLUMN billiards_ods.recharge_settlements.onlineamount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：onlineamount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.operatorid IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：operatorid';
COMMENT ON COLUMN billiards_ods.recharge_settlements.operatorname IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：operatorname';
COMMENT ON COLUMN billiards_ods.recharge_settlements.revokeorderid IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：revokeorderid';
COMMENT ON COLUMN billiards_ods.recharge_settlements.revokeordername IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：revokeordername';
COMMENT ON COLUMN billiards_ods.recharge_settlements.revoketime IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：revoketime';
COMMENT ON COLUMN billiards_ods.recharge_settlements.payamount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：payamount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.pointamount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：pointamount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.refundamount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：refundamount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.settlename IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：settlename';
COMMENT ON COLUMN billiards_ods.recharge_settlements.settlerelateid IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：settlerelateid';
COMMENT ON COLUMN billiards_ods.recharge_settlements.settlestatus IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：settlestatus';
COMMENT ON COLUMN billiards_ods.recharge_settlements.settletype IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：settletype';
COMMENT ON COLUMN billiards_ods.recharge_settlements.paytime IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：paytime';
COMMENT ON COLUMN billiards_ods.recharge_settlements.roundingamount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：roundingamount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.paymentmethod IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：paymentmethod';
COMMENT ON COLUMN billiards_ods.recharge_settlements.adjustamount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：adjustamount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.assistantcxmoney IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：assistantcxmoney';
COMMENT ON COLUMN billiards_ods.recharge_settlements.assistantpdmoney IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：assistantpdmoney';
COMMENT ON COLUMN billiards_ods.recharge_settlements.couponsaleamount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：couponsaleamount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.memberdiscountamount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：memberdiscountamount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.tablechargemoney IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：tablechargemoney';
COMMENT ON COLUMN billiards_ods.recharge_settlements.goodsmoney IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：goodsmoney';
COMMENT ON COLUMN billiards_ods.recharge_settlements.realgoodsmoney IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：realgoodsmoney';
COMMENT ON COLUMN billiards_ods.recharge_settlements.servicemoney IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：servicemoney';
COMMENT ON COLUMN billiards_ods.recharge_settlements.prepaymoney IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：prepaymoney';
COMMENT ON COLUMN billiards_ods.recharge_settlements.salesmanname IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：salesmanname';
COMMENT ON COLUMN billiards_ods.recharge_settlements.orderremark IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：orderremark';
COMMENT ON COLUMN billiards_ods.recharge_settlements.salesmanuserid IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：salesmanuserid';
COMMENT ON COLUMN billiards_ods.recharge_settlements.canberevoked IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：canberevoked';
COMMENT ON COLUMN billiards_ods.recharge_settlements.pointdiscountprice IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：pointdiscountprice';
COMMENT ON COLUMN billiards_ods.recharge_settlements.pointdiscountcost IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：pointdiscountcost';
COMMENT ON COLUMN billiards_ods.recharge_settlements.activitydiscount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：activitydiscount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.serialnumber IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：serialnumber';
COMMENT ON COLUMN billiards_ods.recharge_settlements.assistantmanualdiscount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：assistantmanualdiscount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.allcoupondiscount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：allcoupondiscount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.goodspromotionmoney IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：goodspromotionmoney';
COMMENT ON COLUMN billiards_ods.recharge_settlements.assistantpromotionmoney IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：assistantpromotionmoney';
COMMENT ON COLUMN billiards_ods.recharge_settlements.isusecoupon IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：isusecoupon';
COMMENT ON COLUMN billiards_ods.recharge_settlements.isusediscount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：isusediscount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.isactivity IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：isactivity';
COMMENT ON COLUMN billiards_ods.recharge_settlements.isbindmember IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：isbindmember';
COMMENT ON COLUMN billiards_ods.recharge_settlements.isfirst IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：isfirst';
COMMENT ON COLUMN billiards_ods.recharge_settlements.rechargecardamount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：rechargecardamount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.giftcardamount IS '说明：同名 JSON 字段，业务含义详见 recharge_settlements-Analysis.md；示例：无样例（样例对照）；JSON字段：giftcardamount';
COMMENT ON COLUMN billiards_ods.recharge_settlements.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：recharge_settlements.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.recharge_settlements.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.recharge_settlements.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.recharge_settlements.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.settlement_records (
    id                    BIGINT PRIMARY KEY,
    tenantid              BIGINT,
    siteid                BIGINT,
    sitename              TEXT,
    balanceamount         NUMERIC(18,2),
    cardamount            NUMERIC(18,2),
    cashamount            NUMERIC(18,2),
    couponamount          NUMERIC(18,2),
    createtime            TIMESTAMPTZ,
    memberid              BIGINT,
    membername            TEXT,
    tenantmembercardid    BIGINT,
    membercardtypename    TEXT,
    memberphone           TEXT,
    tableid               BIGINT,
    consumemoney          NUMERIC(18,2),
    onlineamount          NUMERIC(18,2),
    operatorid            BIGINT,
    operatorname          TEXT,
    revokeorderid         BIGINT,
    revokeordername       TEXT,
    revoketime            TIMESTAMPTZ,
    payamount             NUMERIC(18,2),
    pointamount           NUMERIC(18,2),
    refundamount          NUMERIC(18,2),
    settlename            TEXT,
    settlerelateid        BIGINT,
    settlestatus          INT,
    settletype            INT,
    paytime               TIMESTAMPTZ,
    roundingamount        NUMERIC(18,2),
    paymentmethod         INT,
    adjustamount          NUMERIC(18,2),
    assistantcxmoney      NUMERIC(18,2),
    assistantpdmoney      NUMERIC(18,2),
    couponsaleamount      NUMERIC(18,2),
    memberdiscountamount  NUMERIC(18,2),
    tablechargemoney      NUMERIC(18,2),
    goodsmoney            NUMERIC(18,2),
    realgoodsmoney        NUMERIC(18,2),
    servicemoney          NUMERIC(18,2),
    prepaymoney           NUMERIC(18,2),
    salesmanname          TEXT,
    orderremark           TEXT,
    salesmanuserid        BIGINT,
    canberevoked          BOOLEAN,
    pointdiscountprice    NUMERIC(18,2),
    pointdiscountcost     NUMERIC(18,2),
    activitydiscount      NUMERIC(18,2),
    serialnumber          BIGINT,
    assistantmanualdiscount NUMERIC(18,2),
    allcoupondiscount     NUMERIC(18,2),
    goodspromotionmoney   NUMERIC(18,2),
    assistantpromotionmoney NUMERIC(18,2),
    isusecoupon           BOOLEAN,
    isusediscount         BOOLEAN,
    isactivity            BOOLEAN,
    isbindmember          BOOLEAN,
    isfirst               INT,
    rechargecardamount    NUMERIC(18,2),
    giftcardamount        NUMERIC(18,2),
    source_file           TEXT,
    source_endpoint       TEXT,
    fetched_at            TIMESTAMPTZ DEFAULT now(),
    payload               JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.settlement_records IS '表用途：ODS 原始明细，对应 JSON 文件 settlement_records.json，详见 settlement_records-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.settlement_records.id IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.settlement_records.tenantid IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：tenantid';
COMMENT ON COLUMN billiards_ods.settlement_records.siteid IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：siteid';
COMMENT ON COLUMN billiards_ods.settlement_records.sitename IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：sitename';
COMMENT ON COLUMN billiards_ods.settlement_records.balanceamount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：balanceamount';
COMMENT ON COLUMN billiards_ods.settlement_records.cardamount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：cardamount';
COMMENT ON COLUMN billiards_ods.settlement_records.cashamount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：cashamount';
COMMENT ON COLUMN billiards_ods.settlement_records.couponamount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：couponamount';
COMMENT ON COLUMN billiards_ods.settlement_records.createtime IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：createtime';
COMMENT ON COLUMN billiards_ods.settlement_records.memberid IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：memberid';
COMMENT ON COLUMN billiards_ods.settlement_records.membername IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：membername';
COMMENT ON COLUMN billiards_ods.settlement_records.tenantmembercardid IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：tenantmembercardid';
COMMENT ON COLUMN billiards_ods.settlement_records.membercardtypename IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：membercardtypename';
COMMENT ON COLUMN billiards_ods.settlement_records.memberphone IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：memberphone';
COMMENT ON COLUMN billiards_ods.settlement_records.tableid IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：tableid';
COMMENT ON COLUMN billiards_ods.settlement_records.consumemoney IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：consumemoney';
COMMENT ON COLUMN billiards_ods.settlement_records.onlineamount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：onlineamount';
COMMENT ON COLUMN billiards_ods.settlement_records.operatorid IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：operatorid';
COMMENT ON COLUMN billiards_ods.settlement_records.operatorname IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：operatorname';
COMMENT ON COLUMN billiards_ods.settlement_records.revokeorderid IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：revokeorderid';
COMMENT ON COLUMN billiards_ods.settlement_records.revokeordername IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：revokeordername';
COMMENT ON COLUMN billiards_ods.settlement_records.revoketime IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：revoketime';
COMMENT ON COLUMN billiards_ods.settlement_records.payamount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：payamount';
COMMENT ON COLUMN billiards_ods.settlement_records.pointamount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：pointamount';
COMMENT ON COLUMN billiards_ods.settlement_records.refundamount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：refundamount';
COMMENT ON COLUMN billiards_ods.settlement_records.settlename IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：settlename';
COMMENT ON COLUMN billiards_ods.settlement_records.settlerelateid IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：settlerelateid';
COMMENT ON COLUMN billiards_ods.settlement_records.settlestatus IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：settlestatus';
COMMENT ON COLUMN billiards_ods.settlement_records.settletype IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：settletype';
COMMENT ON COLUMN billiards_ods.settlement_records.paytime IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：paytime';
COMMENT ON COLUMN billiards_ods.settlement_records.roundingamount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：roundingamount';
COMMENT ON COLUMN billiards_ods.settlement_records.paymentmethod IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：paymentmethod';
COMMENT ON COLUMN billiards_ods.settlement_records.adjustamount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：adjustamount';
COMMENT ON COLUMN billiards_ods.settlement_records.assistantcxmoney IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：assistantcxmoney';
COMMENT ON COLUMN billiards_ods.settlement_records.assistantpdmoney IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：assistantpdmoney';
COMMENT ON COLUMN billiards_ods.settlement_records.couponsaleamount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：couponsaleamount';
COMMENT ON COLUMN billiards_ods.settlement_records.memberdiscountamount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：memberdiscountamount';
COMMENT ON COLUMN billiards_ods.settlement_records.tablechargemoney IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：tablechargemoney';
COMMENT ON COLUMN billiards_ods.settlement_records.goodsmoney IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：goodsmoney';
COMMENT ON COLUMN billiards_ods.settlement_records.realgoodsmoney IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：realgoodsmoney';
COMMENT ON COLUMN billiards_ods.settlement_records.servicemoney IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：servicemoney';
COMMENT ON COLUMN billiards_ods.settlement_records.prepaymoney IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：prepaymoney';
COMMENT ON COLUMN billiards_ods.settlement_records.salesmanname IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：salesmanname';
COMMENT ON COLUMN billiards_ods.settlement_records.orderremark IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：orderremark';
COMMENT ON COLUMN billiards_ods.settlement_records.salesmanuserid IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：salesmanuserid';
COMMENT ON COLUMN billiards_ods.settlement_records.canberevoked IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：canberevoked';
COMMENT ON COLUMN billiards_ods.settlement_records.pointdiscountprice IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：pointdiscountprice';
COMMENT ON COLUMN billiards_ods.settlement_records.pointdiscountcost IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：pointdiscountcost';
COMMENT ON COLUMN billiards_ods.settlement_records.activitydiscount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：activitydiscount';
COMMENT ON COLUMN billiards_ods.settlement_records.serialnumber IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：serialnumber';
COMMENT ON COLUMN billiards_ods.settlement_records.assistantmanualdiscount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：assistantmanualdiscount';
COMMENT ON COLUMN billiards_ods.settlement_records.allcoupondiscount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：allcoupondiscount';
COMMENT ON COLUMN billiards_ods.settlement_records.goodspromotionmoney IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：goodspromotionmoney';
COMMENT ON COLUMN billiards_ods.settlement_records.assistantpromotionmoney IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：assistantpromotionmoney';
COMMENT ON COLUMN billiards_ods.settlement_records.isusecoupon IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：isusecoupon';
COMMENT ON COLUMN billiards_ods.settlement_records.isusediscount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：isusediscount';
COMMENT ON COLUMN billiards_ods.settlement_records.isactivity IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：isactivity';
COMMENT ON COLUMN billiards_ods.settlement_records.isbindmember IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：isbindmember';
COMMENT ON COLUMN billiards_ods.settlement_records.isfirst IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：isfirst';
COMMENT ON COLUMN billiards_ods.settlement_records.rechargecardamount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：rechargecardamount';
COMMENT ON COLUMN billiards_ods.settlement_records.giftcardamount IS '说明：同名 JSON 字段，业务含义详见 settlement_records-Analysis.md；示例：无样例（样例对照）；JSON字段：giftcardamount';
COMMENT ON COLUMN billiards_ods.settlement_records.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：settlement_records.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.settlement_records.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.settlement_records.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.settlement_records.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.assistant_cancellation_records (
    id                     BIGINT PRIMARY KEY,
    siteId                 BIGINT,
    siteProfile            JSONB,
    assistantName          TEXT,
    assistantAbolishAmount NUMERIC(18,2),
    assistantOn            INT,
    pdChargeMinutes        INT,
    tableAreaId            BIGINT,
    tableArea              TEXT,
    tableId                BIGINT,
    tableName              TEXT,
    trashReason            TEXT,
    createTime             TIMESTAMP,
    source_file            TEXT,
    source_endpoint        TEXT,
    fetched_at             TIMESTAMPTZ DEFAULT now(),
    payload                JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.assistant_cancellation_records IS '表用途：ODS 原始明细，对应 JSON 文件 assistant_cancellation_records.json，详见 assistant_cancellation_records-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.id IS '说明：同名 JSON 字段，业务含义详见 assistant_cancellation_records-Analysis.md；示例：2957675849518789（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.siteId IS '说明：同名 JSON 字段，业务含义详见 assistant_cancellation_records-Analysis.md；示例：2790685415443269（样例对照）；JSON字段：siteId';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.siteProfile IS '说明：同名 JSON 字段，业务含义详见 assistant_cancellation_records-Analysis.md；示例：{"id": 2790685415443269, "org_id": 2790684179467077, "shop_name": "朗朗桌球", "av…（样例对照）；JSON字段：siteProfile';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.assistantName IS '说明：同名 JSON 字段，业务含义详见 assistant_cancellation_records-Analysis.md；示例：泡芙（样例对照）；JSON字段：assistantName';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.assistantAbolishAmount IS '说明：同名 JSON 字段，业务含义详见 assistant_cancellation_records-Analysis.md；示例：5.83（样例对照）；JSON字段：assistantAbolishAmount';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.assistantOn IS '说明：同名 JSON 字段，业务含义详见 assistant_cancellation_records-Analysis.md；示例：27（样例对照）；JSON字段：assistantOn';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.pdChargeMinutes IS '说明：同名 JSON 字段，业务含义详见 assistant_cancellation_records-Analysis.md；示例：214（样例对照）；JSON字段：pdChargeMinutes';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.tableAreaId IS '说明：同名 JSON 字段，业务含义详见 assistant_cancellation_records-Analysis.md；示例：2791963816579205（样例对照）；JSON字段：tableAreaId';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.tableArea IS '说明：同名 JSON 字段，业务含义详见 assistant_cancellation_records-Analysis.md；示例：C区（样例对照）；JSON字段：tableArea';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.tableId IS '说明：同名 JSON 字段，业务含义详见 assistant_cancellation_records-Analysis.md；示例：2793016660660357（样例对照）；JSON字段：tableId';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.tableName IS '说明：同名 JSON 字段，业务含义详见 assistant_cancellation_records-Analysis.md；示例：C1（样例对照）；JSON字段：tableName';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.trashReason IS '说明：同名 JSON 字段，业务含义详见 assistant_cancellation_records-Analysis.md；示例：（样例对照）；JSON字段：trashReason';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.createTime IS '说明：同名 JSON 字段，业务含义详见 assistant_cancellation_records-Analysis.md；示例：2025-11-09 19:23:29（样例对照）；JSON字段：createTime';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：assistant_cancellation_records.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.assistant_accounts_master (
    id                     BIGINT PRIMARY KEY,
    tenant_id              BIGINT,
    site_id                BIGINT,
    assistant_no           TEXT,
    nickname               TEXT,
    real_name              TEXT,
    mobile                 TEXT,
    team_id                BIGINT,
    team_name              TEXT,
    user_id                BIGINT,
    level                  TEXT,
    assistant_status       INT,
    work_status            INT,
    leave_status           INT,
    entry_time             TIMESTAMP,
    resign_time            TIMESTAMP,
    start_time             TIMESTAMP,
    end_time               TIMESTAMP,
    create_time            TIMESTAMP,
    update_time            TIMESTAMP,
    order_trade_no         TEXT,
    staff_id               BIGINT,
    staff_profile_id       BIGINT,
    system_role_id         BIGINT,
    avatar                 TEXT,
    birth_date             TIMESTAMP,
    gender                 INT,
    height                 NUMERIC(18,2),
    weight                 NUMERIC(18,2),
    job_num                TEXT,
    show_status            INT,
    show_sort              INT,
    sum_grade              NUMERIC(18,2),
    assistant_grade        NUMERIC(18,2),
    get_grade_times        INT,
    introduce              TEXT,
    video_introduction_url TEXT,
    group_id               BIGINT,
    group_name             TEXT,
    shop_name              TEXT,
    charge_way             INT,
    entry_type             INT,
    allow_cx               INT,
    is_guaranteed          INT,
    salary_grant_enabled   INT,
    light_status           INT,
    online_status          INT,
    is_delete              INT,
    cx_unit_price          NUMERIC(18,2),
    pd_unit_price          NUMERIC(18,2),
    last_table_id          BIGINT,
    last_table_name        TEXT,
    person_org_id          BIGINT,
    serial_number          BIGINT,
    is_team_leader         INT,
    criticism_status       INT,
    last_update_name       TEXT,
    ding_talk_synced       INT,
    site_light_cfg_id      BIGINT,
    light_equipment_id     TEXT,
    entry_sign_status      INT,
    resign_sign_status     INT,
    source_file            TEXT,
    source_endpoint        TEXT,
    fetched_at             TIMESTAMPTZ DEFAULT now(),
    payload                JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.assistant_accounts_master IS '表用途：ODS 原始明细，对应 JSON 文件 assistant_accounts_master.json，详见 assistant_accounts_master-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.id IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2947562271297029（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.tenant_id IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2790683160709957（样例对照）；JSON字段：tenant_id';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.site_id IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2790685415443269（样例对照）；JSON字段：site_id';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.assistant_no IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：31（样例对照）；JSON字段：assistant_no';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.nickname IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：小然（样例对照）；JSON字段：nickname';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.real_name IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：张静然（样例对照）；JSON字段：real_name';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.mobile IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：15119679931（样例对照）；JSON字段：mobile';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.team_id IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2792011585884037（样例对照）；JSON字段：team_id';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.team_name IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：1组（样例对照）；JSON字段：team_name';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.user_id IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2947562270838277（样例对照）；JSON字段：user_id';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.level IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：20（样例对照）；JSON字段：level';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.assistant_status IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：1（样例对照）；JSON字段：assistant_status';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.work_status IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2（样例对照）；JSON字段：work_status';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.leave_status IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：1（样例对照）；JSON字段：leave_status';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.entry_time IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2025-11-02 08:00:00（样例对照）；JSON字段：entry_time';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.resign_time IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2025-11-03 08:00:00（样例对照）；JSON字段：resign_time';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.start_time IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2025-11-01 08:00:00（样例对照）；JSON字段：start_time';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.end_time IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2025-12-01 08:00:00（样例对照）；JSON字段：end_time';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.create_time IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2025-11-02 15:55:26（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.update_time IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2025-11-03 18:32:07（样例对照）；JSON字段：update_time';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.order_trade_no IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0（样例对照）；JSON字段：order_trade_no';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.staff_id IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0（样例对照）；JSON字段：staff_id';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.staff_profile_id IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0（样例对照）；JSON字段：staff_profile_id';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.system_role_id IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：10（样例对照）；JSON字段：system_role_id';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.avatar IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：https://oss.ficoo.vip/maUiImages/images/defaultAvatar.png（样例对照）；JSON字段：avatar';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.birth_date IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0001-01-01 00:00:00（样例对照）；JSON字段：birth_date';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.gender IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0（样例对照）；JSON字段：gender';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.height IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0.0（样例对照）；JSON字段：height';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.weight IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0.0（样例对照）；JSON字段：weight';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.job_num IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：（样例对照）；JSON字段：job_num';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.show_status IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：1（样例对照）；JSON字段：show_status';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.show_sort IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：31（样例对照）；JSON字段：show_sort';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.sum_grade IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0.0（样例对照）；JSON字段：sum_grade';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.assistant_grade IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0.0（样例对照）；JSON字段：assistant_grade';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.get_grade_times IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0（样例对照）；JSON字段：get_grade_times';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.introduce IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：（样例对照）；JSON字段：introduce';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.video_introduction_url IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：（样例对照）；JSON字段：video_introduction_url';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.group_id IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0（样例对照）；JSON字段：group_id';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.group_name IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：（样例对照）；JSON字段：group_name';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.shop_name IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：朗朗桌球（样例对照）；JSON字段：shop_name';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.charge_way IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2（样例对照）；JSON字段：charge_way';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.entry_type IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：1（样例对照）；JSON字段：entry_type';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.allow_cx IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：1（样例对照）；JSON字段：allow_cx';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.is_guaranteed IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：1（样例对照）；JSON字段：is_guaranteed';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.salary_grant_enabled IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2（样例对照）；JSON字段：salary_grant_enabled';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.light_status IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2（样例对照）；JSON字段：light_status';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.online_status IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：1（样例对照）；JSON字段：online_status';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.is_delete IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0（样例对照）；JSON字段：is_delete';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.cx_unit_price IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0.0（样例对照）；JSON字段：cx_unit_price';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.pd_unit_price IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0.0（样例对照）；JSON字段：pd_unit_price';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.last_table_id IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0（样例对照）；JSON字段：last_table_id';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.last_table_name IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：（样例对照）；JSON字段：last_table_name';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.person_org_id IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：2947562271215109（样例对照）；JSON字段：person_org_id';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.serial_number IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0（样例对照）；JSON字段：serial_number';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.is_team_leader IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0（样例对照）；JSON字段：is_team_leader';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.criticism_status IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：1（样例对照）；JSON字段：criticism_status';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.last_update_name IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：无样例（样例对照）；JSON字段：last_update_name';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.ding_talk_synced IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：1（样例对照）；JSON字段：ding_talk_synced';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.site_light_cfg_id IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0（样例对照）；JSON字段：site_light_cfg_id';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.light_equipment_id IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：（样例对照）；JSON字段：light_equipment_id';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.entry_sign_status IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0（样例对照）；JSON字段：entry_sign_status';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.resign_sign_status IS '说明：同名 JSON 字段，业务含义详见 assistant_accounts_master-Analysis.md；示例：0（样例对照）；JSON字段：resign_sign_status';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：assistant_accounts_master.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.assistant_service_records (
    id                       BIGINT PRIMARY KEY,
    tenant_id                BIGINT,
    site_id                  BIGINT,
    siteProfile              JSONB,
    site_table_id            BIGINT,
    order_settle_id          BIGINT,
    order_trade_no           TEXT,
    order_pay_id             BIGINT,
    order_assistant_id       BIGINT,
    order_assistant_type     INT,
    assistantName            TEXT,
    assistantNo              TEXT,
    assistant_level          TEXT,
    levelname                TEXT,
    site_assistant_id        BIGINT,
    skill_id                 BIGINT,
    skillname                TEXT,
    system_member_id         BIGINT,
    tablename                TEXT,
    tenant_member_id         BIGINT,
    user_id                  BIGINT,
    assistant_team_id        BIGINT,
    nickname                 TEXT,
    ledger_name              TEXT,
    ledger_group_name        TEXT,
    ledger_amount            NUMERIC(18,2),
    ledger_count             NUMERIC(18,4),
    ledger_unit_price        NUMERIC(18,4),
    ledger_status            INT,
    ledger_start_time        TIMESTAMP,
    ledger_end_time          TIMESTAMP,
    manual_discount_amount   NUMERIC(18,2),
    member_discount_amount   NUMERIC(18,2),
    coupon_deduct_money      NUMERIC(18,2),
    service_money            NUMERIC(18,2),
    projected_income         NUMERIC(18,2),
    real_use_seconds         INT,
    income_seconds           INT,
    start_use_time           TIMESTAMP,
    last_use_time            TIMESTAMP,
    create_time              TIMESTAMP,
    is_single_order          INT,
    is_delete                INT,
    is_trash                 INT,
    trash_reason             TEXT,
    trash_applicant_id       BIGINT,
    trash_applicant_name     TEXT,
    operator_id              BIGINT,
    operator_name            TEXT,
    salesman_name            TEXT,
    salesman_org_id          BIGINT,
    salesman_user_id         BIGINT,
    person_org_id            BIGINT,
    add_clock                INT,
    returns_clock            INT,
    composite_grade          NUMERIC(10,2),
    composite_grade_time     TIMESTAMP,
    skill_grade              NUMERIC(10,2),
    service_grade            NUMERIC(10,2),
    sum_grade                NUMERIC(10,2),
    grade_status             INT,
    get_grade_times          INT,
    is_not_responding        INT,
    is_confirm               INT,
    payload                  JSONB NOT NULL,
    source_file              TEXT,
    source_endpoint          TEXT,
    fetched_at               TIMESTAMPTZ DEFAULT now()
);

COMMENT ON TABLE billiards_ods.assistant_service_records IS '表用途：ODS 原始明细，对应 JSON 文件 assistant_service_records.json，详见 assistant_service_records-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.assistant_service_records.id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2957913441292165（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.tenant_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2790683160709957（样例对照）；JSON字段：tenant_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.site_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2790685415443269（样例对照）；JSON字段：site_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.siteProfile IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：{"id": 2790685415443269, "org_id": 2790684179467077, "shop_name": "朗朗桌球", "av…（样例对照）；JSON字段：siteProfile';
COMMENT ON COLUMN billiards_ods.assistant_service_records.site_table_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2793020259897413（样例对照）；JSON字段：site_table_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.order_settle_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2957913171693253（样例对照）；JSON字段：order_settle_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.order_trade_no IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2957784612605829（样例对照）；JSON字段：order_trade_no';
COMMENT ON COLUMN billiards_ods.assistant_service_records.order_pay_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0（样例对照）；JSON字段：order_pay_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.order_assistant_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2957788717240005（样例对照）；JSON字段：order_assistant_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.order_assistant_type IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：1（样例对照）；JSON字段：order_assistant_type';
COMMENT ON COLUMN billiards_ods.assistant_service_records.assistantName IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：何海婷（样例对照）；JSON字段：assistantName';
COMMENT ON COLUMN billiards_ods.assistant_service_records.assistantNo IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：27（样例对照）；JSON字段：assistantNo';
COMMENT ON COLUMN billiards_ods.assistant_service_records.assistant_level IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：10（样例对照）；JSON字段：assistant_level';
COMMENT ON COLUMN billiards_ods.assistant_service_records.levelname IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：初级（样例对照）；JSON字段：levelname';
COMMENT ON COLUMN billiards_ods.assistant_service_records.site_assistant_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2946266869435205（样例对照）；JSON字段：site_assistant_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.skill_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2790683529513797（样例对照）；JSON字段：skill_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.skillname IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：基础课（样例对照）；JSON字段：skillname';
COMMENT ON COLUMN billiards_ods.assistant_service_records.system_member_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0（样例对照）；JSON字段：system_member_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.tablename IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：S1（样例对照）；JSON字段：tablename';
COMMENT ON COLUMN billiards_ods.assistant_service_records.tenant_member_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0（样例对照）；JSON字段：tenant_member_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.user_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2946266868976453（样例对照）；JSON字段：user_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.assistant_team_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2792011585884037（样例对照）；JSON字段：assistant_team_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.nickname IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：泡芙（样例对照）；JSON字段：nickname';
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_name IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：27-泡芙（样例对照）；JSON字段：ledger_name';
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_group_name IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：（样例对照）；JSON字段：ledger_group_name';
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_amount IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：206.67（样例对照）；JSON字段：ledger_amount';
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_count IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：7592（样例对照）；JSON字段：ledger_count';
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_unit_price IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：98.0（样例对照）；JSON字段：ledger_unit_price';
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_status IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：1（样例对照）；JSON字段：ledger_status';
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_start_time IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2025-11-09 21:18:18（样例对照）；JSON字段：ledger_start_time';
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_end_time IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2025-11-09 23:24:50（样例对照）；JSON字段：ledger_end_time';
COMMENT ON COLUMN billiards_ods.assistant_service_records.manual_discount_amount IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0.0（样例对照）；JSON字段：manual_discount_amount';
COMMENT ON COLUMN billiards_ods.assistant_service_records.member_discount_amount IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0.0（样例对照）；JSON字段：member_discount_amount';
COMMENT ON COLUMN billiards_ods.assistant_service_records.coupon_deduct_money IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0.0（样例对照）；JSON字段：coupon_deduct_money';
COMMENT ON COLUMN billiards_ods.assistant_service_records.service_money IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0.0（样例对照）；JSON字段：service_money';
COMMENT ON COLUMN billiards_ods.assistant_service_records.projected_income IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：168.0（样例对照）；JSON字段：projected_income';
COMMENT ON COLUMN billiards_ods.assistant_service_records.real_use_seconds IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：7592（样例对照）；JSON字段：real_use_seconds';
COMMENT ON COLUMN billiards_ods.assistant_service_records.income_seconds IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：7560（样例对照）；JSON字段：income_seconds';
COMMENT ON COLUMN billiards_ods.assistant_service_records.start_use_time IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2025-11-09 21:18:18（样例对照）；JSON字段：start_use_time';
COMMENT ON COLUMN billiards_ods.assistant_service_records.last_use_time IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2025-11-09 23:24:50（样例对照）；JSON字段：last_use_time';
COMMENT ON COLUMN billiards_ods.assistant_service_records.create_time IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2025-11-09 23:25:11（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.assistant_service_records.is_single_order IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：1（样例对照）；JSON字段：is_single_order';
COMMENT ON COLUMN billiards_ods.assistant_service_records.is_delete IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0（样例对照）；JSON字段：is_delete';
COMMENT ON COLUMN billiards_ods.assistant_service_records.is_trash IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0（样例对照）；JSON字段：is_trash';
COMMENT ON COLUMN billiards_ods.assistant_service_records.trash_reason IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：（样例对照）；JSON字段：trash_reason';
COMMENT ON COLUMN billiards_ods.assistant_service_records.trash_applicant_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0（样例对照）；JSON字段：trash_applicant_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.trash_applicant_name IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：（样例对照）；JSON字段：trash_applicant_name';
COMMENT ON COLUMN billiards_ods.assistant_service_records.operator_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2790687322443013（样例对照）；JSON字段：operator_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.operator_name IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：收银员:郑丽珊（样例对照）；JSON字段：operator_name';
COMMENT ON COLUMN billiards_ods.assistant_service_records.salesman_name IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：（样例对照）；JSON字段：salesman_name';
COMMENT ON COLUMN billiards_ods.assistant_service_records.salesman_org_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0（样例对照）；JSON字段：salesman_org_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.salesman_user_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0（样例对照）；JSON字段：salesman_user_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.person_org_id IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2946266869336901（样例对照）；JSON字段：person_org_id';
COMMENT ON COLUMN billiards_ods.assistant_service_records.add_clock IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0（样例对照）；JSON字段：add_clock';
COMMENT ON COLUMN billiards_ods.assistant_service_records.returns_clock IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0（样例对照）；JSON字段：returns_clock';
COMMENT ON COLUMN billiards_ods.assistant_service_records.composite_grade IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0.0（样例对照）；JSON字段：composite_grade';
COMMENT ON COLUMN billiards_ods.assistant_service_records.composite_grade_time IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0001-01-01 00:00:00（样例对照）；JSON字段：composite_grade_time';
COMMENT ON COLUMN billiards_ods.assistant_service_records.skill_grade IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0（样例对照）；JSON字段：skill_grade';
COMMENT ON COLUMN billiards_ods.assistant_service_records.service_grade IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0（样例对照）；JSON字段：service_grade';
COMMENT ON COLUMN billiards_ods.assistant_service_records.sum_grade IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0.0（样例对照）；JSON字段：sum_grade';
COMMENT ON COLUMN billiards_ods.assistant_service_records.grade_status IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：1（样例对照）；JSON字段：grade_status';
COMMENT ON COLUMN billiards_ods.assistant_service_records.get_grade_times IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0（样例对照）；JSON字段：get_grade_times';
COMMENT ON COLUMN billiards_ods.assistant_service_records.is_not_responding IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：0（样例对照）；JSON字段：is_not_responding';
COMMENT ON COLUMN billiards_ods.assistant_service_records.is_confirm IS '说明：同名 JSON 字段，业务含义详见 assistant_service_records-Analysis.md；示例：2（样例对照）；JSON字段：is_confirm';
COMMENT ON COLUMN billiards_ods.assistant_service_records.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';
COMMENT ON COLUMN billiards_ods.assistant_service_records.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：assistant_service_records.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.assistant_service_records.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.assistant_service_records.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';

CREATE TABLE IF NOT EXISTS billiards_ods.site_tables_master (
    id                       BIGINT PRIMARY KEY,
    site_id                  BIGINT,
    siteName                 TEXT,
    "appletQrCodeUrl"        TEXT,
    areaName                 TEXT,
    audit_status             INT,
    charge_free              INT,
    create_time              TIMESTAMP,
    delay_lights_time        INT,
    is_online_reservation    INT,
    is_rest_area             INT,
    light_status             INT,
    only_allow_groupon       INT,
    order_delay_time         INT,
    self_table               INT,
    show_status              INT,
    site_table_area_id       BIGINT,
    tableStatusName          TEXT,
    table_cloth_use_Cycle    INT,
    table_cloth_use_time     TIMESTAMP,
    table_name               TEXT,
    table_price              NUMERIC(18,2),
    table_status             INT,
    temporary_light_second   INT,
    virtual_table            INT,
    source_file              TEXT,
    source_endpoint          TEXT,
    fetched_at               TIMESTAMPTZ DEFAULT now(),
    payload                  JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.site_tables_master IS '表用途：ODS 原始明细，对应 JSON 文件 site_tables_master.json，详见 site_tables_master-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.site_tables_master.id IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：2791964216463493（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.site_tables_master.site_id IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：2790685415443269（样例对照）；JSON字段：site_id';
COMMENT ON COLUMN billiards_ods.site_tables_master.siteName IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：朗朗桌球（样例对照）；JSON字段：siteName';
COMMENT ON COLUMN billiards_ods.site_tables_master."appletQrCodeUrl" IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：https://pc-we.ficoo.vip/rootwww/prodwx38a48dd2bc3c1642?env=prod&type=1&id=279…（样例对照）；JSON字段：appletQrCodeUrl';
COMMENT ON COLUMN billiards_ods.site_tables_master.areaName IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：A区（样例对照）；JSON字段：areaName';
COMMENT ON COLUMN billiards_ods.site_tables_master.audit_status IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：2（样例对照）；JSON字段：audit_status';
COMMENT ON COLUMN billiards_ods.site_tables_master.charge_free IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：0（样例对照）；JSON字段：charge_free';
COMMENT ON COLUMN billiards_ods.site_tables_master.create_time IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：2025-07-15 17:52:54（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.site_tables_master.delay_lights_time IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：0（样例对照）；JSON字段：delay_lights_time';
COMMENT ON COLUMN billiards_ods.site_tables_master.is_online_reservation IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：2（样例对照）；JSON字段：is_online_reservation';
COMMENT ON COLUMN billiards_ods.site_tables_master.is_rest_area IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：0（样例对照）；JSON字段：is_rest_area';
COMMENT ON COLUMN billiards_ods.site_tables_master.light_status IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：2（样例对照）；JSON字段：light_status';
COMMENT ON COLUMN billiards_ods.site_tables_master.only_allow_groupon IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：2（样例对照）；JSON字段：only_allow_groupon';
COMMENT ON COLUMN billiards_ods.site_tables_master.order_delay_time IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：0（样例对照）；JSON字段：order_delay_time';
COMMENT ON COLUMN billiards_ods.site_tables_master.self_table IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：1（样例对照）；JSON字段：self_table';
COMMENT ON COLUMN billiards_ods.site_tables_master.show_status IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：1（样例对照）；JSON字段：show_status';
COMMENT ON COLUMN billiards_ods.site_tables_master.site_table_area_id IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：2791963794329671（样例对照）；JSON字段：site_table_area_id';
COMMENT ON COLUMN billiards_ods.site_tables_master.tableStatusName IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：空闲中（样例对照）；JSON字段：tableStatusName';
COMMENT ON COLUMN billiards_ods.site_tables_master.table_cloth_use_Cycle IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：0（样例对照）；JSON字段：table_cloth_use_Cycle';
COMMENT ON COLUMN billiards_ods.site_tables_master.table_cloth_use_time IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：1863727（样例对照）；JSON字段：table_cloth_use_time';
COMMENT ON COLUMN billiards_ods.site_tables_master.table_name IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：A1（样例对照）；JSON字段：table_name';
COMMENT ON COLUMN billiards_ods.site_tables_master.table_price IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：0.0（样例对照）；JSON字段：table_price';
COMMENT ON COLUMN billiards_ods.site_tables_master.table_status IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：1（样例对照）；JSON字段：table_status';
COMMENT ON COLUMN billiards_ods.site_tables_master.temporary_light_second IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：0（样例对照）；JSON字段：temporary_light_second';
COMMENT ON COLUMN billiards_ods.site_tables_master.virtual_table IS '说明：同名 JSON 字段，业务含义详见 site_tables_master-Analysis.md；示例：0（样例对照）；JSON字段：virtual_table';
COMMENT ON COLUMN billiards_ods.site_tables_master.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：site_tables_master.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.site_tables_master.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.site_tables_master.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.site_tables_master.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.table_fee_discount_records (
    id                  BIGINT PRIMARY KEY,
    tenant_id           BIGINT,
    site_id             BIGINT,
    siteProfile         JSONB,
    site_table_id       BIGINT,
    tableProfile        JSONB,
    tenant_table_area_id BIGINT,
    adjust_type         INT,
    ledger_amount       NUMERIC(18,2),
    ledger_count        NUMERIC(18,4),
    ledger_name         TEXT,
    ledger_status       INT,
    applicant_id        BIGINT,
    applicant_name      TEXT,
    operator_id         BIGINT,
    operator_name       TEXT,
    order_settle_id     BIGINT,
    order_trade_no      TEXT,
    is_delete           INT,
    create_time         TIMESTAMP,
    source_file         TEXT,
    source_endpoint     TEXT,
    fetched_at          TIMESTAMPTZ DEFAULT now(),
    payload             JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.table_fee_discount_records IS '表用途：ODS 原始明细，对应 JSON 文件 table_fee_discount_records.json，详见 table_fee_discount_records-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.id IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：2957913441881989（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.tenant_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：2790683160709957（样例对照）；JSON字段：tenant_id';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.site_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：2790685415443269（样例对照）；JSON字段：site_id';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.siteProfile IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：{"id": 2790685415443269, "org_id": 2790684179467077, "shop_name": "朗朗桌球", "av…（样例对照）；JSON字段：siteProfile';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.site_table_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：2793020259897413（样例对照）；JSON字段：site_table_id';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.tableProfile IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：{"id": 2793020259897413, "tenant_id": 2790683160709957, "tenant_name": "", "s…（样例对照）；JSON字段：tableProfile';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.tenant_table_area_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：2791961347968901（样例对照）；JSON字段：tenant_table_area_id';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.adjust_type IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：1（样例对照）；JSON字段：adjust_type';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.ledger_amount IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：148.15（样例对照）；JSON字段：ledger_amount';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.ledger_count IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：1（样例对照）；JSON字段：ledger_count';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.ledger_name IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：（样例对照）；JSON字段：ledger_name';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.ledger_status IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：1（样例对照）；JSON字段：ledger_status';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.applicant_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：2790687322443013（样例对照）；JSON字段：applicant_id';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.applicant_name IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：收银员:郑丽珊（样例对照）；JSON字段：applicant_name';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.operator_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：2790687322443013（样例对照）；JSON字段：operator_id';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.operator_name IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：收银员:郑丽珊（样例对照）；JSON字段：operator_name';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.order_settle_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：2957913171693253（样例对照）；JSON字段：order_settle_id';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.order_trade_no IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：2957784612605829（样例对照）；JSON字段：order_trade_no';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.is_delete IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：0（样例对照）；JSON字段：is_delete';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.create_time IS '说明：同名 JSON 字段，业务含义详见 table_fee_discount_records-Analysis.md；示例：2025-11-09 23:25:11（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：table_fee_discount_records.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.table_fee_transactions (
    id                       BIGINT PRIMARY KEY,
    tenant_id                BIGINT,
    site_id                  BIGINT,
    siteProfile              JSONB,
    site_table_id            BIGINT,
    site_table_area_id       BIGINT,
    site_table_area_name     TEXT,
    tenant_table_area_id     BIGINT,
    order_trade_no           TEXT,
    order_pay_id             BIGINT,
    order_settle_id          BIGINT,
    ledger_name              TEXT,
    ledger_amount            NUMERIC(18,2),
    ledger_count             NUMERIC(18,4),
    ledger_unit_price        NUMERIC(18,4),
    ledger_status            INT,
    ledger_start_time        TIMESTAMP,
    ledger_end_time          TIMESTAMP,
    start_use_time           TIMESTAMP,
    last_use_time            TIMESTAMP,
    real_table_use_seconds   INT,
    real_table_charge_money  NUMERIC(18,2),
    add_clock_seconds        INT,
    adjust_amount            NUMERIC(18,2),
    coupon_promotion_amount  NUMERIC(18,2),
    member_discount_amount   NUMERIC(18,2),
    used_card_amount         NUMERIC(18,2),
    mgmt_fee                 NUMERIC(18,2),
    service_money            NUMERIC(18,2),
    fee_total                NUMERIC(18,2),
    is_single_order          INT,
    is_delete                INT,
    member_id                BIGINT,
    operator_id              BIGINT,
    operator_name            TEXT,
    salesman_name            TEXT,
    salesman_org_id          BIGINT,
    salesman_user_id         BIGINT,
    create_time              TIMESTAMP,
    payload                  JSONB NOT NULL,
    source_file              TEXT,
    source_endpoint          TEXT,
    fetched_at               TIMESTAMPTZ DEFAULT now()
);

COMMENT ON TABLE billiards_ods.table_fee_transactions IS '表用途：ODS 原始明细，对应 JSON 文件 table_fee_transactions.json，详见 table_fee_transactions-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.id IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：2957924029058885（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.tenant_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：2790683160709957（样例对照）；JSON字段：tenant_id';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.site_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：2790685415443269（样例对照）；JSON字段：site_id';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.siteProfile IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：{"id": 2790685415443269, "org_id": 2790684179467077, "shop_name": "朗朗桌球", "av…（样例对照）；JSON字段：siteProfile';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.site_table_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：2793003705192517（样例对照）；JSON字段：site_table_id';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.site_table_area_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：2791963794329671（样例对照）；JSON字段：site_table_area_id';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.site_table_area_name IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：A区（样例对照）；JSON字段：site_table_area_name';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.tenant_table_area_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：2791960001957765（样例对照）；JSON字段：tenant_table_area_id';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.order_trade_no IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：2957858167230149（样例对照）；JSON字段：order_trade_no';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.order_pay_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：0（样例对照）；JSON字段：order_pay_id';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.order_settle_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：2957922914357125（样例对照）；JSON字段：order_settle_id';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.ledger_name IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：A17（样例对照）；JSON字段：ledger_name';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.ledger_amount IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：48.0（样例对照）；JSON字段：ledger_amount';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.ledger_count IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：3600（样例对照）；JSON字段：ledger_count';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.ledger_unit_price IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：48.0（样例对照）；JSON字段：ledger_unit_price';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.ledger_status IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：1（样例对照）；JSON字段：ledger_status';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.ledger_start_time IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：2025-11-09 22:28:57（样例对照）；JSON字段：ledger_start_time';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.ledger_end_time IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：2025-11-09 23:28:57（样例对照）；JSON字段：ledger_end_time';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.start_use_time IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：2025-11-09 22:28:57（样例对照）；JSON字段：start_use_time';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.last_use_time IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：2025-11-09 23:28:57（样例对照）；JSON字段：last_use_time';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.real_table_use_seconds IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：3600（样例对照）；JSON字段：real_table_use_seconds';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.real_table_charge_money IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：0.0（样例对照）；JSON字段：real_table_charge_money';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.add_clock_seconds IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：0（样例对照）；JSON字段：add_clock_seconds';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.adjust_amount IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：0.0（样例对照）；JSON字段：adjust_amount';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.coupon_promotion_amount IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：48.0（样例对照）；JSON字段：coupon_promotion_amount';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.member_discount_amount IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：0.0（样例对照）；JSON字段：member_discount_amount';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.used_card_amount IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：0.0（样例对照）；JSON字段：used_card_amount';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.mgmt_fee IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：0.0（样例对照）；JSON字段：mgmt_fee';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.service_money IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：0.0（样例对照）；JSON字段：service_money';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.fee_total IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：0.0（样例对照）；JSON字段：fee_total';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.is_single_order IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：1（样例对照）；JSON字段：is_single_order';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.is_delete IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：0（样例对照）；JSON字段：is_delete';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.member_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：0（样例对照）；JSON字段：member_id';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.operator_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：2790687322443013（样例对照）；JSON字段：operator_id';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.operator_name IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：收银员:郑丽珊（样例对照）；JSON字段：operator_name';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.salesman_name IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：（样例对照）；JSON字段：salesman_name';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.salesman_org_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：0（样例对照）；JSON字段：salesman_org_id';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.salesman_user_id IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：0（样例对照）；JSON字段：salesman_user_id';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.create_time IS '说明：同名 JSON 字段，业务含义详见 table_fee_transactions-Analysis.md；示例：2025-11-09 23:35:57（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：table_fee_transactions.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.table_fee_transactions.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';

CREATE TABLE IF NOT EXISTS billiards_ods.goods_stock_movements (
    siteGoodsStockId     BIGINT PRIMARY KEY,
    tenantId             BIGINT,
    siteId               BIGINT,
    siteGoodsId          BIGINT,
    goodsName            TEXT,
    goodsCategoryId      BIGINT,
    goodsSecondCategoryId BIGINT,
    unit                 TEXT,
    price                NUMERIC(18,4),
    stockType            INT,
    changeNum            NUMERIC(18,4),
    startNum             NUMERIC(18,4),
    endNum               NUMERIC(18,4),
    changeNumA           NUMERIC(18,4),
    startNumA            NUMERIC(18,4),
    endNumA              NUMERIC(18,4),
    remark               TEXT,
    operatorName         TEXT,
    createTime           TIMESTAMP,
    source_file          TEXT,
    source_endpoint      TEXT,
    fetched_at           TIMESTAMPTZ DEFAULT now(),
    payload              JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.goods_stock_movements IS '表用途：ODS 原始明细，对应 JSON 文件 goods_stock_movements.json，详见 goods_stock_movements-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.siteGoodsStockId IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：2957911857581957（样例对照）；JSON字段：siteGoodsStockId';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.tenantId IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：2790683160709957（样例对照）；JSON字段：tenantId';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.siteId IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：2790685415443269（样例对照）；JSON字段：siteId';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.siteGoodsId IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：2793026183532613（样例对照）；JSON字段：siteGoodsId';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.goodsName IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：阿萨姆（样例对照）；JSON字段：goodsName';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.goodsCategoryId IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：2790683528350539（样例对照）；JSON字段：goodsCategoryId';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.goodsSecondCategoryId IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：2790683528350540（样例对照）；JSON字段：goodsSecondCategoryId';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.unit IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：瓶（样例对照）；JSON字段：unit';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.price IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：8.0（样例对照）；JSON字段：price';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.stockType IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：1（样例对照）；JSON字段：stockType';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.changeNum IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：-1（样例对照）；JSON字段：changeNum';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.startNum IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：28（样例对照）；JSON字段：startNum';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.endNum IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：27（样例对照）；JSON字段：endNum';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.changeNumA IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：0（样例对照）；JSON字段：changeNumA';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.startNumA IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：0（样例对照）；JSON字段：startNumA';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.endNumA IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：0（样例对照）；JSON字段：endNumA';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.remark IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：（样例对照）；JSON字段：remark';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.operatorName IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：收银员:郑丽珊（样例对照）；JSON字段：operatorName';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.createTime IS '说明：同名 JSON 字段，业务含义详见 goods_stock_movements-Analysis.md；示例：2025-11-09 23:23:34（样例对照）；JSON字段：createTime';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：goods_stock_movements.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.goods_stock_movements.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.stock_goods_category_tree (
    id                       BIGINT PRIMARY KEY,
    tenant_id                BIGINT,
    category_name            TEXT,
    alias_name               TEXT,
    pid                      BIGINT,
    business_name            TEXT,
    tenant_goods_business_id BIGINT,
    open_salesman            INT,
    categoryBoxes            JSONB,
    sort                     INT,
    is_warehousing           INT,
    source_file              TEXT,
    source_endpoint          TEXT,
    fetched_at               TIMESTAMPTZ DEFAULT now(),
    payload                  JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.stock_goods_category_tree IS '表用途：ODS 原始明细，对应 JSON 文件 stock_goods_category_tree.json，详见 stock_goods_category_tree-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.id IS '说明：同名 JSON 字段，业务含义详见 stock_goods_category_tree-Analysis.md；示例：2790683528350533（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.tenant_id IS '说明：同名 JSON 字段，业务含义详见 stock_goods_category_tree-Analysis.md；示例：2790683160709957（样例对照）；JSON字段：tenant_id';
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.category_name IS '说明：同名 JSON 字段，业务含义详见 stock_goods_category_tree-Analysis.md；示例：槟榔（样例对照）；JSON字段：category_name';
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.alias_name IS '说明：同名 JSON 字段，业务含义详见 stock_goods_category_tree-Analysis.md；示例：（样例对照）；JSON字段：alias_name';
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.pid IS '说明：同名 JSON 字段，业务含义详见 stock_goods_category_tree-Analysis.md；示例：0（样例对照）；JSON字段：pid';
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.business_name IS '说明：同名 JSON 字段，业务含义详见 stock_goods_category_tree-Analysis.md；示例：槟榔（样例对照）；JSON字段：business_name';
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.tenant_goods_business_id IS '说明：同名 JSON 字段，业务含义详见 stock_goods_category_tree-Analysis.md；示例：2790683528317766（样例对照）；JSON字段：tenant_goods_business_id';
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.open_salesman IS '说明：同名 JSON 字段，业务含义详见 stock_goods_category_tree-Analysis.md；示例：2（样例对照）；JSON字段：open_salesman';
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.categoryBoxes IS '说明：同名 JSON 字段，业务含义详见 stock_goods_category_tree-Analysis.md；示例：[{"id": 2790683528350534, "tenant_id": 2790683160709957, "category_name": "槟榔…（样例对照）；JSON字段：categoryBoxes';
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.sort IS '说明：同名 JSON 字段，业务含义详见 stock_goods_category_tree-Analysis.md；示例：1（样例对照）；JSON字段：sort';
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.is_warehousing IS '说明：同名 JSON 字段，业务含义详见 stock_goods_category_tree-Analysis.md；示例：1（样例对照）；JSON字段：is_warehousing';
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：stock_goods_category_tree.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.goods_stock_summary (
    siteGoodsId           BIGINT PRIMARY KEY,
    goodsName             TEXT,
    goodsUnit             TEXT,
    goodsCategoryId       BIGINT,
    goodsCategorySecondId BIGINT,
    categoryName          TEXT,
    rangeStartStock       NUMERIC(18,4),
    rangeEndStock         NUMERIC(18,4),
    rangeIn               NUMERIC(18,4),
    rangeOut              NUMERIC(18,4),
    rangeSale             NUMERIC(18,4),
    rangeSaleMoney        NUMERIC(18,2),
    rangeInventory        NUMERIC(18,4),
    currentStock          NUMERIC(18,4),
    source_file           TEXT,
    source_endpoint       TEXT,
    fetched_at            TIMESTAMPTZ DEFAULT now(),
    payload               JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.goods_stock_summary IS '表用途：ODS 原始明细，对应 JSON 文件 goods_stock_summary.json，详见 goods_stock_summary-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.siteGoodsId IS '说明：同名 JSON 字段，业务含义详见 goods_stock_summary-Analysis.md；示例：无样例（样例对照）；JSON字段：siteGoodsId';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.goodsName IS '说明：同名 JSON 字段，业务含义详见 goods_stock_summary-Analysis.md；示例：无样例（样例对照）；JSON字段：goodsName';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.goodsUnit IS '说明：同名 JSON 字段，业务含义详见 goods_stock_summary-Analysis.md；示例：无样例（样例对照）；JSON字段：goodsUnit';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.goodsCategoryId IS '说明：同名 JSON 字段，业务含义详见 goods_stock_summary-Analysis.md；示例：无样例（样例对照）；JSON字段：goodsCategoryId';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.goodsCategorySecondId IS '说明：同名 JSON 字段，业务含义详见 goods_stock_summary-Analysis.md；示例：无样例（样例对照）；JSON字段：goodsCategorySecondId';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.categoryName IS '说明：同名 JSON 字段，业务含义详见 goods_stock_summary-Analysis.md；示例：无样例（样例对照）；JSON字段：categoryName';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.rangeStartStock IS '说明：同名 JSON 字段，业务含义详见 goods_stock_summary-Analysis.md；示例：无样例（样例对照）；JSON字段：rangeStartStock';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.rangeEndStock IS '说明：同名 JSON 字段，业务含义详见 goods_stock_summary-Analysis.md；示例：无样例（样例对照）；JSON字段：rangeEndStock';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.rangeIn IS '说明：同名 JSON 字段，业务含义详见 goods_stock_summary-Analysis.md；示例：无样例（样例对照）；JSON字段：rangeIn';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.rangeOut IS '说明：同名 JSON 字段，业务含义详见 goods_stock_summary-Analysis.md；示例：无样例（样例对照）；JSON字段：rangeOut';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.rangeSale IS '说明：同名 JSON 字段，业务含义详见 goods_stock_summary-Analysis.md；示例：无样例（样例对照）；JSON字段：rangeSale';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.rangeSaleMoney IS '说明：同名 JSON 字段，业务含义详见 goods_stock_summary-Analysis.md；示例：无样例（样例对照）；JSON字段：rangeSaleMoney';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.rangeInventory IS '说明：同名 JSON 字段，业务含义详见 goods_stock_summary-Analysis.md；示例：无样例（样例对照）；JSON字段：rangeInventory';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.currentStock IS '说明：同名 JSON 字段，业务含义详见 goods_stock_summary-Analysis.md；示例：无样例（样例对照）；JSON字段：currentStock';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：goods_stock_summary.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.goods_stock_summary.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.payment_transactions (
    id                 BIGINT PRIMARY KEY,
    site_id            BIGINT,
    siteProfile        JSONB,
    relate_type        INT,
    relate_id          BIGINT,
    pay_amount         NUMERIC(18,2),
    pay_status         INT,
    pay_time           TIMESTAMP,
    create_time        TIMESTAMP,
    payment_method     INT,
    online_pay_channel INT,
    source_file        TEXT,
    source_endpoint    TEXT,
    fetched_at         TIMESTAMPTZ DEFAULT now(),
    payload            JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.payment_transactions IS '表用途：ODS 原始明细，对应 JSON 文件 payment_transactions.json，详见 payment_transactions-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.payment_transactions.id IS '说明：同名 JSON 字段，业务含义详见 payment_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.payment_transactions.site_id IS '说明：同名 JSON 字段，业务含义详见 payment_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：site_id';
COMMENT ON COLUMN billiards_ods.payment_transactions.siteProfile IS '说明：同名 JSON 字段，业务含义详见 payment_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：siteProfile';
COMMENT ON COLUMN billiards_ods.payment_transactions.relate_type IS '说明：同名 JSON 字段，业务含义详见 payment_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：relate_type';
COMMENT ON COLUMN billiards_ods.payment_transactions.relate_id IS '说明：同名 JSON 字段，业务含义详见 payment_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：relate_id';
COMMENT ON COLUMN billiards_ods.payment_transactions.pay_amount IS '说明：同名 JSON 字段，业务含义详见 payment_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：pay_amount';
COMMENT ON COLUMN billiards_ods.payment_transactions.pay_status IS '说明：同名 JSON 字段，业务含义详见 payment_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：pay_status';
COMMENT ON COLUMN billiards_ods.payment_transactions.pay_time IS '说明：同名 JSON 字段，业务含义详见 payment_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：pay_time';
COMMENT ON COLUMN billiards_ods.payment_transactions.create_time IS '说明：同名 JSON 字段，业务含义详见 payment_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.payment_transactions.payment_method IS '说明：同名 JSON 字段，业务含义详见 payment_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：payment_method';
COMMENT ON COLUMN billiards_ods.payment_transactions.online_pay_channel IS '说明：同名 JSON 字段，业务含义详见 payment_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：online_pay_channel';
COMMENT ON COLUMN billiards_ods.payment_transactions.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：payment_transactions.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.payment_transactions.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.payment_transactions.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.payment_transactions.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.refund_transactions (
    id                   BIGINT PRIMARY KEY,
    tenant_id            BIGINT,
    tenantName           TEXT,
    site_id              BIGINT,
    siteProfile          JSONB,
    relate_type          INT,
    relate_id            BIGINT,
    pay_sn               TEXT,
    pay_amount           NUMERIC(18,2),
    refund_amount        NUMERIC(18,2),
    round_amount         NUMERIC(18,2),
    pay_status           INT,
    pay_time             TIMESTAMP,
    create_time          TIMESTAMP,
    payment_method       INT,
    pay_terminal         INT,
    pay_config_id        BIGINT,
    online_pay_channel   INT,
    online_pay_type      INT,
    channel_fee          NUMERIC(18,2),
    channel_payer_id     TEXT,
    channel_pay_no       TEXT,
    member_id            BIGINT,
    member_card_id       BIGINT,
    cashier_point_id     BIGINT,
    operator_id          BIGINT,
    action_type          INT,
    check_status         INT,
    is_revoke            INT,
    is_delete            INT,
    balance_frozen_amount NUMERIC(18,2),
    card_frozen_amount    NUMERIC(18,2),
    source_file          TEXT,
    source_endpoint      TEXT,
    fetched_at           TIMESTAMPTZ DEFAULT now(),
    payload              JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.refund_transactions IS '表用途：ODS 原始明细，对应 JSON 文件 refund_transactions.json，详见 refund_transactions-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.refund_transactions.id IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.refund_transactions.tenant_id IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：tenant_id';
COMMENT ON COLUMN billiards_ods.refund_transactions.tenantName IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：tenantName';
COMMENT ON COLUMN billiards_ods.refund_transactions.site_id IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：site_id';
COMMENT ON COLUMN billiards_ods.refund_transactions.siteProfile IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：siteProfile';
COMMENT ON COLUMN billiards_ods.refund_transactions.relate_type IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：relate_type';
COMMENT ON COLUMN billiards_ods.refund_transactions.relate_id IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：relate_id';
COMMENT ON COLUMN billiards_ods.refund_transactions.pay_sn IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：pay_sn';
COMMENT ON COLUMN billiards_ods.refund_transactions.pay_amount IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：pay_amount';
COMMENT ON COLUMN billiards_ods.refund_transactions.refund_amount IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：refund_amount';
COMMENT ON COLUMN billiards_ods.refund_transactions.round_amount IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：round_amount';
COMMENT ON COLUMN billiards_ods.refund_transactions.pay_status IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：pay_status';
COMMENT ON COLUMN billiards_ods.refund_transactions.pay_time IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：pay_time';
COMMENT ON COLUMN billiards_ods.refund_transactions.create_time IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.refund_transactions.payment_method IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：payment_method';
COMMENT ON COLUMN billiards_ods.refund_transactions.pay_terminal IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：pay_terminal';
COMMENT ON COLUMN billiards_ods.refund_transactions.pay_config_id IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：pay_config_id';
COMMENT ON COLUMN billiards_ods.refund_transactions.online_pay_channel IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：online_pay_channel';
COMMENT ON COLUMN billiards_ods.refund_transactions.online_pay_type IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：online_pay_type';
COMMENT ON COLUMN billiards_ods.refund_transactions.channel_fee IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：channel_fee';
COMMENT ON COLUMN billiards_ods.refund_transactions.channel_payer_id IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：channel_payer_id';
COMMENT ON COLUMN billiards_ods.refund_transactions.channel_pay_no IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：channel_pay_no';
COMMENT ON COLUMN billiards_ods.refund_transactions.member_id IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：member_id';
COMMENT ON COLUMN billiards_ods.refund_transactions.member_card_id IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：member_card_id';
COMMENT ON COLUMN billiards_ods.refund_transactions.cashier_point_id IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：cashier_point_id';
COMMENT ON COLUMN billiards_ods.refund_transactions.operator_id IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：operator_id';
COMMENT ON COLUMN billiards_ods.refund_transactions.action_type IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：action_type';
COMMENT ON COLUMN billiards_ods.refund_transactions.check_status IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：check_status';
COMMENT ON COLUMN billiards_ods.refund_transactions.is_revoke IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：is_revoke';
COMMENT ON COLUMN billiards_ods.refund_transactions.is_delete IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：is_delete';
COMMENT ON COLUMN billiards_ods.refund_transactions.balance_frozen_amount IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：balance_frozen_amount';
COMMENT ON COLUMN billiards_ods.refund_transactions.card_frozen_amount IS '说明：同名 JSON 字段，业务含义详见 refund_transactions-Analysis.md；示例：无样例（样例对照）；JSON字段：card_frozen_amount';
COMMENT ON COLUMN billiards_ods.refund_transactions.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：refund_transactions.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.refund_transactions.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.refund_transactions.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.refund_transactions.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.platform_coupon_redemption_records (
    id                BIGINT PRIMARY KEY,
    verify_id         BIGINT,
    certificate_id    TEXT,
    coupon_code       TEXT,
    coupon_name       TEXT,
    coupon_channel    INT,
    groupon_type      INT,
    group_package_id  BIGINT,
    sale_price        NUMERIC(18,2),
    coupon_money      NUMERIC(18,2),
    coupon_free_time  NUMERIC(18,2),
    coupon_cover      TEXT,
    coupon_remark     TEXT,
    use_status        INT,
    consume_time      TIMESTAMP,
    create_time       TIMESTAMP,
    deal_id           TEXT,
    channel_deal_id   TEXT,
    site_id           BIGINT,
    site_order_id     BIGINT,
    table_id          BIGINT,
    tenant_id         BIGINT,
    operator_id       BIGINT,
    operator_name     TEXT,
    is_delete         INT,
    siteProfile       JSONB,
    source_file       TEXT,
    source_endpoint   TEXT,
    fetched_at        TIMESTAMPTZ DEFAULT now(),
    payload           JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.platform_coupon_redemption_records IS '表用途：ODS 原始明细，对应 JSON 文件 platform_coupon_redemption_records.json，详见 platform_coupon_redemption_records-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.id IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.verify_id IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：verify_id';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.certificate_id IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：certificate_id';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.coupon_code IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：coupon_code';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.coupon_name IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：coupon_name';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.coupon_channel IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：coupon_channel';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.groupon_type IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：groupon_type';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.group_package_id IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：group_package_id';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.sale_price IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：sale_price';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.coupon_money IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：coupon_money';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.coupon_free_time IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：coupon_free_time';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.coupon_cover IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：coupon_cover';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.coupon_remark IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：coupon_remark';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.use_status IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：use_status';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.consume_time IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：consume_time';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.create_time IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.deal_id IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：deal_id';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.channel_deal_id IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：channel_deal_id';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.site_id IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：site_id';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.site_order_id IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：site_order_id';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.table_id IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：table_id';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.tenant_id IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：tenant_id';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.operator_id IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：operator_id';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.operator_name IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：operator_name';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.is_delete IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：is_delete';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.siteProfile IS '说明：同名 JSON 字段，业务含义详见 platform_coupon_redemption_records-Analysis.md；示例：无样例（样例对照）；JSON字段：siteProfile';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：platform_coupon_redemption_records.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.tenant_goods_master (
    id                      BIGINT PRIMARY KEY,
    tenant_id               BIGINT,
    goods_name              TEXT,
    goods_bar_code          TEXT,
    goods_category_id       BIGINT,
    goods_second_category_id BIGINT,
      categoryName            TEXT,
      unit                    TEXT,
      goods_number            TEXT,
      out_goods_id            TEXT,
      goods_state             INT,
    sale_channel            INT,
    able_discount           INT,
    able_site_transfer      INT,
    is_delete               INT,
    is_warehousing          INT,
    isInSite                INT,
    cost_price              NUMERIC(18,4),
    cost_price_type         INT,
    market_price            NUMERIC(18,4),
    min_discount_price      NUMERIC(18,4),
    common_sale_royalty     NUMERIC(18,4),
    point_sale_royalty      NUMERIC(18,4),
    pinyin_initial          TEXT,
    commodityCode           TEXT,
    commodity_code          TEXT,
    goods_cover             TEXT,
    supplier_id             BIGINT,
    remark_name             TEXT,
    create_time             TIMESTAMP,
    update_time             TIMESTAMP,
    payload                 JSONB NOT NULL,
    source_file             TEXT,
    source_endpoint         TEXT,
    fetched_at              TIMESTAMPTZ DEFAULT now()
);

COMMENT ON TABLE billiards_ods.tenant_goods_master IS '表用途：ODS 原始明细，对应 JSON 文件 tenant_goods_master.json，详见 tenant_goods_master-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.id IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：2791925230096261（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.tenant_id IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：2790683160709957（样例对照）；JSON字段：tenant_id';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.goods_name IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：东方树叶（样例对照）；JSON字段：goods_name';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.goods_bar_code IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：（样例对照）；JSON字段：goods_bar_code';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.goods_category_id IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：2790683528350539（样例对照）；JSON字段：goods_category_id';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.goods_second_category_id IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：2790683528350540（样例对照）；JSON字段：goods_second_category_id';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.categoryName IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：饮料（样例对照）；JSON字段：categoryName';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.unit IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：瓶（样例对照）；JSON字段：unit';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.goods_number IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：1（样例对照）；JSON字段：goods_number';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.out_goods_id IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：0（样例对照）；JSON字段：out_goods_id';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.goods_state IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：1（样例对照）；JSON字段：goods_state';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.sale_channel IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：1（样例对照）；JSON字段：sale_channel';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.able_discount IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：1（样例对照）；JSON字段：able_discount';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.able_site_transfer IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：2（样例对照）；JSON字段：able_site_transfer';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.is_delete IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：0（样例对照）；JSON字段：is_delete';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.is_warehousing IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：1（样例对照）；JSON字段：is_warehousing';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.isInSite IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：false（样例对照）；JSON字段：isInSite';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.cost_price IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：0.0（样例对照）；JSON字段：cost_price';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.cost_price_type IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：1（样例对照）；JSON字段：cost_price_type';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.market_price IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：8.0（样例对照）；JSON字段：market_price';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.min_discount_price IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：0.0（样例对照）；JSON字段：min_discount_price';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.common_sale_royalty IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：0（样例对照）；JSON字段：common_sale_royalty';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.point_sale_royalty IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：0（样例对照）；JSON字段：point_sale_royalty';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.pinyin_initial IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：DFSY,DFSX（样例对照）；JSON字段：pinyin_initial';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.commodityCode IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：["10000028"]（样例对照）；JSON字段：commodityCode';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.commodity_code IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：10000028（样例对照）；JSON字段：commodity_code';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.goods_cover IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：https://oss.ficoo.vip/admin/ZwS8fj_1753175129443.jpg（样例对照）；JSON字段：goods_cover';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.supplier_id IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：0（样例对照）；JSON字段：supplier_id';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.remark_name IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：（样例对照）；JSON字段：remark_name';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.create_time IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：2025-07-15 17:13:15（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.update_time IS '说明：同名 JSON 字段，业务含义详见 tenant_goods_master-Analysis.md；示例：2025-10-29 23:51:38（样例对照）；JSON字段：update_time';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：tenant_goods_master.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.tenant_goods_master.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';

CREATE TABLE IF NOT EXISTS billiards_ods.group_buy_packages (
    id                          BIGINT PRIMARY KEY,
    package_id                  BIGINT,
    package_name                TEXT,
    selling_price               NUMERIC(18,2),
    coupon_money                NUMERIC(18,2),
    date_type                   INT,
    date_info                   TEXT,
    start_time                  TIMESTAMP,
    end_time                    TIMESTAMP,
    start_clock                 TEXT,
    end_clock                   TEXT,
    add_start_clock             TEXT,
    add_end_clock               TEXT,
    duration                    INT,
    usable_count                INT,
    usable_range                INT,
    table_area_id               BIGINT,
    table_area_name             TEXT,
    table_area_id_list          JSONB,
    tenant_table_area_id        BIGINT,
    tenant_table_area_id_list   JSONB,
    site_id                     BIGINT,
    site_name                   TEXT,
    tenant_id                   BIGINT,
    card_type_ids               JSONB,
    group_type                  INT,
    system_group_type           INT,
    type                        INT,
    effective_status            INT,
    is_enabled                  INT,
    is_delete                   INT,
    max_selectable_categories   INT,
    area_tag_type               INT,
    creator_name                TEXT,
    create_time                 TIMESTAMP,
    source_file                 TEXT,
    source_endpoint             TEXT,
    fetched_at                  TIMESTAMPTZ DEFAULT now(),
    payload                     JSONB NOT NULL
);

COMMENT ON TABLE billiards_ods.group_buy_packages IS '表用途：ODS 原始明细，对应 JSON 文件 group_buy_packages.json，详见 group_buy_packages-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.group_buy_packages.id IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：2939215004469573（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.group_buy_packages.package_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：1814707240811572（样例对照）；JSON字段：package_id';
COMMENT ON COLUMN billiards_ods.group_buy_packages.package_name IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：早场特惠一小时（样例对照）；JSON字段：package_name';
COMMENT ON COLUMN billiards_ods.group_buy_packages.selling_price IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：0.0（样例对照）；JSON字段：selling_price';
COMMENT ON COLUMN billiards_ods.group_buy_packages.coupon_money IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：0.0（样例对照）；JSON字段：coupon_money';
COMMENT ON COLUMN billiards_ods.group_buy_packages.date_type IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：1（样例对照）；JSON字段：date_type';
COMMENT ON COLUMN billiards_ods.group_buy_packages.date_info IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：（样例对照）；JSON字段：date_info';
COMMENT ON COLUMN billiards_ods.group_buy_packages.start_time IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：2025-10-27 00:00:00（样例对照）；JSON字段：start_time';
COMMENT ON COLUMN billiards_ods.group_buy_packages.end_time IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：2026-10-28 00:00:00（样例对照）；JSON字段：end_time';
COMMENT ON COLUMN billiards_ods.group_buy_packages.start_clock IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：00:00:00（样例对照）；JSON字段：start_clock';
COMMENT ON COLUMN billiards_ods.group_buy_packages.end_clock IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：1.00:00:00（样例对照）；JSON字段：end_clock';
COMMENT ON COLUMN billiards_ods.group_buy_packages.add_start_clock IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：00:00:00（样例对照）；JSON字段：add_start_clock';
COMMENT ON COLUMN billiards_ods.group_buy_packages.add_end_clock IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：1.00:00:00（样例对照）；JSON字段：add_end_clock';
COMMENT ON COLUMN billiards_ods.group_buy_packages.duration IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：3600（样例对照）；JSON字段：duration';
COMMENT ON COLUMN billiards_ods.group_buy_packages.usable_count IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：9999999（样例对照）；JSON字段：usable_count';
COMMENT ON COLUMN billiards_ods.group_buy_packages.usable_range IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：（样例对照）；JSON字段：usable_range';
COMMENT ON COLUMN billiards_ods.group_buy_packages.table_area_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：0（样例对照）；JSON字段：table_area_id';
COMMENT ON COLUMN billiards_ods.group_buy_packages.table_area_name IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：A区（样例对照）；JSON字段：table_area_name';
COMMENT ON COLUMN billiards_ods.group_buy_packages.table_area_id_list IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：（样例对照）；JSON字段：table_area_id_list';
COMMENT ON COLUMN billiards_ods.group_buy_packages.tenant_table_area_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：0（样例对照）；JSON字段：tenant_table_area_id';
COMMENT ON COLUMN billiards_ods.group_buy_packages.tenant_table_area_id_list IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：2791960001957765（样例对照）；JSON字段：tenant_table_area_id_list';
COMMENT ON COLUMN billiards_ods.group_buy_packages.site_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：2790685415443269（样例对照）；JSON字段：site_id';
COMMENT ON COLUMN billiards_ods.group_buy_packages.site_name IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：朗朗桌球（样例对照）；JSON字段：site_name';
COMMENT ON COLUMN billiards_ods.group_buy_packages.tenant_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：2790683160709957（样例对照）；JSON字段：tenant_id';
COMMENT ON COLUMN billiards_ods.group_buy_packages.card_type_ids IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：0（样例对照）；JSON字段：card_type_ids';
COMMENT ON COLUMN billiards_ods.group_buy_packages.group_type IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：1（样例对照）；JSON字段：group_type';
COMMENT ON COLUMN billiards_ods.group_buy_packages.system_group_type IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：1（样例对照）；JSON字段：system_group_type';
COMMENT ON COLUMN billiards_ods.group_buy_packages.type IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：2（样例对照）；JSON字段：type';
COMMENT ON COLUMN billiards_ods.group_buy_packages.effective_status IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：1（样例对照）；JSON字段：effective_status';
COMMENT ON COLUMN billiards_ods.group_buy_packages.is_enabled IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：1（样例对照）；JSON字段：is_enabled';
COMMENT ON COLUMN billiards_ods.group_buy_packages.is_delete IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：0（样例对照）；JSON字段：is_delete';
COMMENT ON COLUMN billiards_ods.group_buy_packages.max_selectable_categories IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：0（样例对照）；JSON字段：max_selectable_categories';
COMMENT ON COLUMN billiards_ods.group_buy_packages.area_tag_type IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：1（样例对照）；JSON字段：area_tag_type';
COMMENT ON COLUMN billiards_ods.group_buy_packages.creator_name IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：店长:郑丽珊（样例对照）；JSON字段：creator_name';
COMMENT ON COLUMN billiards_ods.group_buy_packages.create_time IS '说明：同名 JSON 字段，业务含义详见 group_buy_packages-Analysis.md；示例：2025-10-27 18:24:09（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.group_buy_packages.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：group_buy_packages.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.group_buy_packages.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.group_buy_packages.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.group_buy_packages.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';

CREATE TABLE IF NOT EXISTS billiards_ods.group_buy_redemption_records (
    id                              BIGINT PRIMARY KEY,
    tenant_id                       BIGINT,
    site_id                         BIGINT,
    siteName                        TEXT,
    table_id                        BIGINT,
    tableName                       TEXT,
    tableAreaName                   TEXT,
    tenant_table_area_id            BIGINT,
    order_trade_no                  TEXT,
    order_settle_id                 BIGINT,
    order_pay_id                    BIGINT,
    order_coupon_id                 BIGINT,
    order_coupon_channel            INT,
    coupon_code                     TEXT,
    coupon_money                    NUMERIC(18,2),
    coupon_origin_id                BIGINT,
    ledger_name                     TEXT,
    ledger_group_name               TEXT,
    ledger_amount                   NUMERIC(18,2),
    ledger_count                    NUMERIC(18,4),
    ledger_unit_price               NUMERIC(18,4),
    ledger_status                   INT,
    table_charge_seconds            INT,
    promotion_activity_id           BIGINT,
    promotion_coupon_id             BIGINT,
    promotion_seconds               INT,
    offer_type                      INT,
    assistant_promotion_money       NUMERIC(18,2),
    assistant_service_promotion_money NUMERIC(18,2),
    table_service_promotion_money   NUMERIC(18,2),
    goods_promotion_money           NUMERIC(18,2),
    recharge_promotion_money        NUMERIC(18,2),
    reward_promotion_money          NUMERIC(18,2),
    goodsOptionPrice                NUMERIC(18,2),
    salesman_name                   TEXT,
    sales_man_org_id                BIGINT,
    salesman_role_id                BIGINT,
    salesman_user_id                BIGINT,
    operator_id                     BIGINT,
    operator_name                   TEXT,
    is_single_order                 INT,
    is_delete                       INT,
    create_time                     TIMESTAMP,
    payload                         JSONB NOT NULL,
    source_file                     TEXT,
    source_endpoint                 TEXT,
    fetched_at                      TIMESTAMPTZ DEFAULT now()
);

COMMENT ON TABLE billiards_ods.group_buy_redemption_records IS '表用途：ODS 原始明细，对应 JSON 文件 group_buy_redemption_records.json，详见 group_buy_redemption_records-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.id IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：2957924029615941（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.tenant_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：2790683160709957（样例对照）；JSON字段：tenant_id';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.site_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：2790685415443269（样例对照）；JSON字段：site_id';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.siteName IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：朗朗桌球（样例对照）；JSON字段：siteName';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.table_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：2793003705192517（样例对照）；JSON字段：table_id';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.tableName IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：A17（样例对照）；JSON字段：tableName';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.tableAreaName IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：A区（样例对照）；JSON字段：tableAreaName';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.tenant_table_area_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：2791960001957765（样例对照）；JSON字段：tenant_table_area_id';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.order_trade_no IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：2957858167230149（样例对照）；JSON字段：order_trade_no';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.order_settle_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：2957922914357125（样例对照）；JSON字段：order_settle_id';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.order_pay_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：0（样例对照）；JSON字段：order_pay_id';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.order_coupon_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：2957858168229573（样例对照）；JSON字段：order_coupon_id';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.order_coupon_channel IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：1（样例对照）；JSON字段：order_coupon_channel';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.coupon_code IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：0107892475999（样例对照）；JSON字段：coupon_code';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.coupon_money IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：48.0（样例对照）；JSON字段：coupon_money';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.coupon_origin_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：2957858168229573（样例对照）；JSON字段：coupon_origin_id';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.ledger_name IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：全天A区中八一小时（样例对照）；JSON字段：ledger_name';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.ledger_group_name IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：（样例对照）；JSON字段：ledger_group_name';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.ledger_amount IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：48.0（样例对照）；JSON字段：ledger_amount';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.ledger_count IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：3600（样例对照）；JSON字段：ledger_count';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.ledger_unit_price IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：29.9（样例对照）；JSON字段：ledger_unit_price';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.ledger_status IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：1（样例对照）；JSON字段：ledger_status';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.table_charge_seconds IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：3600（样例对照）；JSON字段：table_charge_seconds';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.promotion_activity_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：2957858166460101（样例对照）；JSON字段：promotion_activity_id';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.promotion_coupon_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：2798727423528005（样例对照）；JSON字段：promotion_coupon_id';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.promotion_seconds IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：3600（样例对照）；JSON字段：promotion_seconds';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.offer_type IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：1（样例对照）；JSON字段：offer_type';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.assistant_promotion_money IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：0.0（样例对照）；JSON字段：assistant_promotion_money';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.assistant_service_promotion_money IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：0.0（样例对照）；JSON字段：assistant_service_promotion_money';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.table_service_promotion_money IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：0.0（样例对照）；JSON字段：table_service_promotion_money';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.goods_promotion_money IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：0.0（样例对照）；JSON字段：goods_promotion_money';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.recharge_promotion_money IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：0.0（样例对照）；JSON字段：recharge_promotion_money';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.reward_promotion_money IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：0.0（样例对照）；JSON字段：reward_promotion_money';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.goodsOptionPrice IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：0.0（样例对照）；JSON字段：goodsOptionPrice';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.salesman_name IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：（样例对照）；JSON字段：salesman_name';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.sales_man_org_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：0（样例对照）；JSON字段：sales_man_org_id';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.salesman_role_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：0（样例对照）；JSON字段：salesman_role_id';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.salesman_user_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：0（样例对照）；JSON字段：salesman_user_id';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.operator_id IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：2790687322443013（样例对照）；JSON字段：operator_id';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.operator_name IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：收银员:郑丽珊（样例对照）；JSON字段：operator_name';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.is_single_order IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：1（样例对照）；JSON字段：is_single_order';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.is_delete IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：0（样例对照）；JSON字段：is_delete';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.create_time IS '说明：同名 JSON 字段，业务含义详见 group_buy_redemption_records-Analysis.md；示例：2025-11-09 23:35:57（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：group_buy_redemption_records.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.group_buy_redemption_records.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';

CREATE TABLE IF NOT EXISTS billiards_ods.settlement_ticket_details (
    orderSettleId         BIGINT PRIMARY KEY,
    actualPayment         NUMERIC(18,2),
    adjustAmount          NUMERIC(18,2),
    assistantManualDiscount NUMERIC(18,2),
    balanceAmount         NUMERIC(18,2),
    cashierName           TEXT,
    consumeMoney          NUMERIC(18,2),
    couponAmount          NUMERIC(18,2),
    deliveryAddress       TEXT,
    deliveryFee           NUMERIC(18,2),
    ledgerAmount          NUMERIC(18,2),
    memberDeductAmount    NUMERIC(18,2),
    memberOfferAmount     NUMERIC(18,2),
    onlineReturnAmount    NUMERIC(18,2),
    orderRemark           TEXT,
    orderSettleNumber     BIGINT,
    payMemberBalance      NUMERIC(18,2),
    payTime               TIMESTAMP,
    paymentMethod         INT,
    pointDiscountCost     NUMERIC(18,2),
    pointDiscountPrice    NUMERIC(18,2),
    prepayMoney           NUMERIC(18,2),
    refundAmount          NUMERIC(18,2),
    returnGoodsAmount     NUMERIC(18,2),
    rewardName            TEXT,
    settleType            TEXT,
    siteAddress           TEXT,
    siteBusinessTel       TEXT,
    siteId                BIGINT,
    siteName              TEXT,
    tenantId              BIGINT,
    tenantName            TEXT,
    ticketCustomContent   TEXT,
    ticketRemark          TEXT,
    voucherMoney          NUMERIC(18,2),
    memberProfile         JSONB,
    orderItem             JSONB,
    tenantMemberCardLogs  JSONB,
    payload               JSONB NOT NULL,
    source_file           TEXT,
    source_endpoint       TEXT,
    fetched_at            TIMESTAMPTZ DEFAULT now()
);

COMMENT ON TABLE billiards_ods.settlement_ticket_details IS '表用途：ODS 原始明细，对应 JSON 文件 settlement_ticket_details.json，详见 settlement_ticket_details-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.orderSettleId IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：2957922914357125（样例对照）；JSON字段：orderSettleId';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.actualPayment IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：actualPayment';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.adjustAmount IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：adjustAmount';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.assistantManualDiscount IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：assistantManualDiscount';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.balanceAmount IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：balanceAmount';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.cashierName IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：cashierName';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.consumeMoney IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：consumeMoney';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.couponAmount IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：couponAmount';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.deliveryAddress IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：deliveryAddress';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.deliveryFee IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：deliveryFee';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.ledgerAmount IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：ledgerAmount';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.memberDeductAmount IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：memberDeductAmount';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.memberOfferAmount IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：memberOfferAmount';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.onlineReturnAmount IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：onlineReturnAmount';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.orderRemark IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：orderRemark';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.orderSettleNumber IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：orderSettleNumber';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.payMemberBalance IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：payMemberBalance';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.payTime IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：payTime';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.paymentMethod IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：paymentMethod';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.pointDiscountCost IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：pointDiscountCost';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.pointDiscountPrice IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：pointDiscountPrice';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.prepayMoney IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：prepayMoney';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.refundAmount IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：refundAmount';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.returnGoodsAmount IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：returnGoodsAmount';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.rewardName IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：rewardName';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.settleType IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：settleType';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.siteAddress IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：siteAddress';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.siteBusinessTel IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：siteBusinessTel';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.siteId IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：siteId';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.siteName IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：siteName';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.tenantId IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：tenantId';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.tenantName IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：tenantName';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.ticketCustomContent IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：ticketCustomContent';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.ticketRemark IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：ticketRemark';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.voucherMoney IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：voucherMoney';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.memberProfile IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：memberProfile';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.orderItem IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：orderItem';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.tenantMemberCardLogs IS '说明：同名 JSON 字段，业务含义详见 settlement_ticket_details-Analysis.md；示例：无样例（样例对照）；JSON字段：tenantMemberCardLogs';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：settlement_ticket_details.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';

CREATE TABLE IF NOT EXISTS billiards_ods.store_goods_master (
    id                  BIGINT PRIMARY KEY,
    tenant_id           BIGINT,
    site_id             BIGINT,
    siteName            TEXT,
    tenant_goods_id     BIGINT,
    goods_name          TEXT,
    goods_bar_code      TEXT,
    goods_category_id   BIGINT,
    goods_second_category_id BIGINT,
    oneCategoryName     TEXT,
    twoCategoryName     TEXT,
    unit                TEXT,
    sale_price          NUMERIC(18,4),
    cost_price          NUMERIC(18,4),
    cost_price_type     INT,
    min_discount_price  NUMERIC(18,4),
    safe_stock          NUMERIC(18,4),
    stock               NUMERIC(18,4),
    stock_A             NUMERIC(18,4),
      sale_num            NUMERIC(18,4),
      total_purchase_cost NUMERIC(18,4),
      total_sales         NUMERIC(18,4),
      average_monthly_sales NUMERIC(18,4),
      batch_stock_quantity NUMERIC(18,2),
      days_available      INT,
      provisional_total_cost NUMERIC(18,2),
      enable_status       INT,
    audit_status        INT,
    goods_state         INT,
    is_delete           INT,
    is_warehousing      INT,
    able_discount       INT,
    able_site_transfer  INT,
    forbid_sell_status  INT,
    "freeze"            INT,
    send_state          INT,
    custom_label_type   INT,
    option_required     INT,
    sale_channel        INT,
    sort                INT,
    remark              TEXT,
    pinyin_initial      TEXT,
    goods_cover         TEXT,
    create_time         TIMESTAMP,
    update_time         TIMESTAMP,
    payload             JSONB NOT NULL,
    source_file         TEXT,
    source_endpoint     TEXT,
    fetched_at          TIMESTAMPTZ DEFAULT now()
);

COMMENT ON TABLE billiards_ods.store_goods_master IS '表用途：ODS 原始明细，对应 JSON 文件 store_goods_master.json，详见 store_goods_master-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.store_goods_master.id IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：2793025851560005（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.store_goods_master.tenant_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：2790683160709957（样例对照）；JSON字段：tenant_id';
COMMENT ON COLUMN billiards_ods.store_goods_master.site_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：2790685415443269（样例对照）；JSON字段：site_id';
COMMENT ON COLUMN billiards_ods.store_goods_master.siteName IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：朗朗桌球（样例对照）；JSON字段：siteName';
COMMENT ON COLUMN billiards_ods.store_goods_master.tenant_goods_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：2792178593255301（样例对照）；JSON字段：tenant_goods_id';
COMMENT ON COLUMN billiards_ods.store_goods_master.goods_name IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：合味道泡面（样例对照）；JSON字段：goods_name';
COMMENT ON COLUMN billiards_ods.store_goods_master.goods_bar_code IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：（样例对照）；JSON字段：goods_bar_code';
COMMENT ON COLUMN billiards_ods.store_goods_master.goods_category_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：2791941988405125（样例对照）；JSON字段：goods_category_id';
COMMENT ON COLUMN billiards_ods.store_goods_master.goods_second_category_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：2793236829620037（样例对照）；JSON字段：goods_second_category_id';
COMMENT ON COLUMN billiards_ods.store_goods_master.oneCategoryName IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：零食（样例对照）；JSON字段：oneCategoryName';
COMMENT ON COLUMN billiards_ods.store_goods_master.twoCategoryName IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：面（样例对照）；JSON字段：twoCategoryName';
COMMENT ON COLUMN billiards_ods.store_goods_master.unit IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：桶（样例对照）；JSON字段：unit';
COMMENT ON COLUMN billiards_ods.store_goods_master.sale_price IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：12.0（样例对照）；JSON字段：sale_price';
COMMENT ON COLUMN billiards_ods.store_goods_master.cost_price IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：0.0（样例对照）；JSON字段：cost_price';
COMMENT ON COLUMN billiards_ods.store_goods_master.cost_price_type IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：1（样例对照）；JSON字段：cost_price_type';
COMMENT ON COLUMN billiards_ods.store_goods_master.min_discount_price IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：7.0（样例对照）；JSON字段：min_discount_price';
COMMENT ON COLUMN billiards_ods.store_goods_master.safe_stock IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：0（样例对照）；JSON字段：safe_stock';
COMMENT ON COLUMN billiards_ods.store_goods_master.stock IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：18（样例对照）；JSON字段：stock';
COMMENT ON COLUMN billiards_ods.store_goods_master.stock_A IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：0（样例对照）；JSON字段：stock_A';
COMMENT ON COLUMN billiards_ods.store_goods_master.sale_num IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：104（样例对照）；JSON字段：sale_num';
COMMENT ON COLUMN billiards_ods.store_goods_master.total_purchase_cost IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：0.0（样例对照）；JSON字段：total_purchase_cost';
COMMENT ON COLUMN billiards_ods.store_goods_master.total_sales IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：104（样例对照）；JSON字段：total_sales';
COMMENT ON COLUMN billiards_ods.store_goods_master.average_monthly_sales IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：1.32（样例对照）；JSON字段：average_monthly_sales';
COMMENT ON COLUMN billiards_ods.store_goods_master.batch_stock_quantity IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：43（样例对照）；JSON字段：batch_stock_quantity';
COMMENT ON COLUMN billiards_ods.store_goods_master.days_available IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：13（样例对照）；JSON字段：days_available';
COMMENT ON COLUMN billiards_ods.store_goods_master.provisional_total_cost IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：0.0（样例对照）；JSON字段：provisional_total_cost';
COMMENT ON COLUMN billiards_ods.store_goods_master.enable_status IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：1（样例对照）；JSON字段：enable_status';
COMMENT ON COLUMN billiards_ods.store_goods_master.audit_status IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：2（样例对照）；JSON字段：audit_status';
COMMENT ON COLUMN billiards_ods.store_goods_master.goods_state IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：1（样例对照）；JSON字段：goods_state';
COMMENT ON COLUMN billiards_ods.store_goods_master.is_delete IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：0（样例对照）；JSON字段：is_delete';
COMMENT ON COLUMN billiards_ods.store_goods_master.is_warehousing IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：1（样例对照）；JSON字段：is_warehousing';
COMMENT ON COLUMN billiards_ods.store_goods_master.able_discount IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：1（样例对照）；JSON字段：able_discount';
COMMENT ON COLUMN billiards_ods.store_goods_master.able_site_transfer IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：2（样例对照）；JSON字段：able_site_transfer';
COMMENT ON COLUMN billiards_ods.store_goods_master.forbid_sell_status IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：1（样例对照）；JSON字段：forbid_sell_status';
COMMENT ON COLUMN billiards_ods.store_goods_master."freeze" IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：0（样例对照）；JSON字段：freeze';
COMMENT ON COLUMN billiards_ods.store_goods_master.send_state IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：1（样例对照）；JSON字段：send_state';
COMMENT ON COLUMN billiards_ods.store_goods_master.custom_label_type IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：2（样例对照）；JSON字段：custom_label_type';
COMMENT ON COLUMN billiards_ods.store_goods_master.option_required IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：1（样例对照）；JSON字段：option_required';
COMMENT ON COLUMN billiards_ods.store_goods_master.sale_channel IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：1（样例对照）；JSON字段：sale_channel';
COMMENT ON COLUMN billiards_ods.store_goods_master.sort IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：100（样例对照）；JSON字段：sort';
COMMENT ON COLUMN billiards_ods.store_goods_master.remark IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：（样例对照）；JSON字段：remark';
COMMENT ON COLUMN billiards_ods.store_goods_master.pinyin_initial IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：HWDPM,GWDPM（样例对照）；JSON字段：pinyin_initial';
COMMENT ON COLUMN billiards_ods.store_goods_master.goods_cover IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：https://oss.ficoo.vip/admin/8M1WM7_1753204221337.jpg（样例对照）；JSON字段：goods_cover';
COMMENT ON COLUMN billiards_ods.store_goods_master.create_time IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：2025-07-16 11:52:51（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.store_goods_master.update_time IS '说明：同名 JSON 字段，业务含义详见 store_goods_master-Analysis.md；示例：2025-11-09 07:23:47（样例对照）；JSON字段：update_time';
COMMENT ON COLUMN billiards_ods.store_goods_master.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';
COMMENT ON COLUMN billiards_ods.store_goods_master.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：store_goods_master.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.store_goods_master.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.store_goods_master.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';

CREATE TABLE IF NOT EXISTS billiards_ods.store_goods_sales_records (
      id                         BIGINT PRIMARY KEY,
      tenant_id                  BIGINT,
      site_id                    BIGINT,
      siteid                     BIGINT,
      sitename                   TEXT,
      site_goods_id              BIGINT,
      tenant_goods_id            BIGINT,
      order_settle_id            BIGINT,
      order_trade_no             TEXT,
      order_goods_id             BIGINT,
      ordergoodsid               BIGINT,
      order_pay_id               BIGINT,
    order_coupon_id            BIGINT,
    ledger_name                TEXT,
    ledger_group_name          TEXT,
    ledger_amount              NUMERIC(18,2),
      ledger_count               NUMERIC(18,4),
      ledger_unit_price          NUMERIC(18,4),
      ledger_status              INT,
      discount_money             NUMERIC(18,2),
      discount_price             NUMERIC(18,2),
      coupon_deduct_money        NUMERIC(18,2),
    member_discount_amount     NUMERIC(18,2),
    option_coupon_deduct_money NUMERIC(18,2),
    option_member_discount_money NUMERIC(18,2),
    point_discount_money       NUMERIC(18,2),
    point_discount_money_cost  NUMERIC(18,2),
    real_goods_money           NUMERIC(18,2),
    cost_money                 NUMERIC(18,2),
    push_money                 NUMERIC(18,2),
    sales_type                 INT,
    is_single_order            INT,
    is_delete                  INT,
    goods_remark               TEXT,
    option_price               NUMERIC(18,2),
    option_value_name          TEXT,
    option_name                TEXT,
    member_coupon_id           BIGINT,
    package_coupon_id          BIGINT,
    sales_man_org_id           BIGINT,
      salesman_name              TEXT,
      salesman_role_id           BIGINT,
      salesman_user_id           BIGINT,
      operator_id                BIGINT,
      operator_name              TEXT,
      openSalesman               TEXT,
      returns_number             INT,
      site_table_id              BIGINT,
    tenant_goods_business_id   BIGINT,
    tenant_goods_category_id   BIGINT,
    create_time                TIMESTAMP,
    payload                    JSONB NOT NULL,
    source_file                TEXT,
    source_endpoint            TEXT,
    fetched_at                 TIMESTAMPTZ DEFAULT now()
);

COMMENT ON TABLE billiards_ods.store_goods_sales_records IS '表用途：ODS 原始明细，对应 JSON 文件 store_goods_sales_records.json，详见 store_goods_sales_records-Analysis.md；payload 保留原始记录便于追溯。';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：2957924029550406（样例对照）；JSON字段：id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.tenant_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：2790683160709957（样例对照）；JSON字段：tenant_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.site_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：2790685415443269（样例对照）；JSON字段：site_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.siteid IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0（样例对照）；JSON字段：siteid';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.sitename IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：朗朗桌球（样例对照）；JSON字段：sitename';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.site_goods_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：2793026176012357（样例对照）；JSON字段：site_goods_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.tenant_goods_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：2792115932417925（样例对照）；JSON字段：tenant_goods_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.order_settle_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：2957922914357125（样例对照）；JSON字段：order_settle_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.order_trade_no IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：2957858167230149（样例对照）；JSON字段：order_trade_no';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.order_goods_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：2957858456391557（样例对照）；JSON字段：order_goods_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.ordergoodsid IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0（样例对照）；JSON字段：ordergoodsid';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.order_pay_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0（样例对照）；JSON字段：order_pay_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.order_coupon_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0（样例对照）；JSON字段：order_coupon_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.ledger_name IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：哇哈哈矿泉水（样例对照）；JSON字段：ledger_name';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.ledger_group_name IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：酒水（样例对照）；JSON字段：ledger_group_name';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.ledger_amount IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：5.0（样例对照）；JSON字段：ledger_amount';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.ledger_count IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：1（样例对照）；JSON字段：ledger_count';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.ledger_unit_price IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：5.0（样例对照）；JSON字段：ledger_unit_price';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.ledger_status IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：1（样例对照）；JSON字段：ledger_status';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.discount_money IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0.0（样例对照）；JSON字段：discount_money';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.discount_price IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：5.0（样例对照）；JSON字段：discount_price';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.coupon_deduct_money IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0.0（样例对照）；JSON字段：coupon_deduct_money';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.member_discount_amount IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0.0（样例对照）；JSON字段：member_discount_amount';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.option_coupon_deduct_money IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0.0（样例对照）；JSON字段：option_coupon_deduct_money';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.option_member_discount_money IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0.0（样例对照）；JSON字段：option_member_discount_money';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.point_discount_money IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0.0（样例对照）；JSON字段：point_discount_money';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.point_discount_money_cost IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0.0（样例对照）；JSON字段：point_discount_money_cost';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.real_goods_money IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：5.0（样例对照）；JSON字段：real_goods_money';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.cost_money IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0.01（样例对照）；JSON字段：cost_money';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.push_money IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0.0（样例对照）；JSON字段：push_money';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.sales_type IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：1（样例对照）；JSON字段：sales_type';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.is_single_order IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：1（样例对照）；JSON字段：is_single_order';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.is_delete IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0（样例对照）；JSON字段：is_delete';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.goods_remark IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：哇哈哈矿泉水（样例对照）；JSON字段：goods_remark';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.option_price IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0.0（样例对照）；JSON字段：option_price';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.option_value_name IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：（样例对照）；JSON字段：option_value_name';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.option_name IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：无样例（样例对照）；JSON字段：option_name';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.member_coupon_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0（样例对照）；JSON字段：member_coupon_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.package_coupon_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0（样例对照）；JSON字段：package_coupon_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.sales_man_org_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0（样例对照）；JSON字段：sales_man_org_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.salesman_name IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：（样例对照）；JSON字段：salesman_name';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.salesman_role_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0（样例对照）；JSON字段：salesman_role_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.salesman_user_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0（样例对照）；JSON字段：salesman_user_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.operator_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：2790687322443013（样例对照）；JSON字段：operator_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.operator_name IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：收银员:郑丽珊（样例对照）；JSON字段：operator_name';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.openSalesman IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：2（样例对照）；JSON字段：openSalesman';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.returns_number IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：0（样例对照）；JSON字段：returns_number';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.site_table_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：2793003705192517（样例对照）；JSON字段：site_table_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.tenant_goods_business_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：2790683528317768（样例对照）；JSON字段：tenant_goods_business_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.tenant_goods_category_id IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：2790683528350540（样例对照）；JSON字段：tenant_goods_category_id';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.create_time IS '说明：同名 JSON 字段，业务含义详见 store_goods_sales_records-Analysis.md；示例：2025-11-09 23:35:57（样例对照）；JSON字段：create_time';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.payload IS '说明：完整原始 JSON 记录快照；示例：原文 JSON（样例对照）；JSON字段：整条记录';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.source_file IS '说明：ETL 元数据，记录原始导出文件名；示例：store_goods_sales_records.json（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.source_endpoint IS '说明：ETL 元数据，记录采集接口或下载 URL；示例：/api/xxx（样例对照）；JSON字段：无（ETL元数据）';
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.fetched_at IS '说明：ETL 入库时间戳；示例：2025-11-10 00:00:00+08（样例对照）；JSON字段：无（ETL元数据）';

