﻿-- 鏂囦欢璇存槑锛歄DS 灞?DDL锛屾寜绀鸿寖 JSON锛圕:\dev\LLTQ\export\temp\source-data-doc锛夌敓鎴愶紝瀛楁鍚嶄笌婧?JSON 涓€鑷翠究浜庤拷婧€?
-- 澶囨敞鍧囦娇鐢ㄤ腑鏂囷紝鏍囨敞鏉ユ簮瀛楁璺緞鍙婂惈涔夛紱鏈睍寮€鐨勫祵濂楀瓧娈典互 JSONB 鍏ㄩ噺淇濈暀銆?
-- 鎵€鏈夊瓧娈靛娉ㄥ潎鏍囨敞鏉ユ簮JSON璺緞涓庝腑鏂囧惈涔夛紙鍚箟鍙傝€冨搴旂殑鈥滃瓧娈典笌鍏崇郴鍒嗘瀽鈥滿D锛夈€?

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

-- ========== 浼氬憳妗ｆ锛堜細鍛樻。妗?json -> data.tenantMemberInfos锛?==========
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 '鏉ユ簮锛氫細鍛樻。妗?json -> data.tenantMemberInfos锛涙瘡鏉¤褰曟槸浼氬憳鍦ㄧ鎴蜂笅鐨勫崱妗ｆ锛堜細鍛樏楀崱绉嶏級銆?;
COMMENT ON COLUMN billiards_ods.member_profiles.tenant_id IS '鏉ユ簮:data.tenantMemberInfos.tenant_id锛涚鎴?鍝佺墝ID銆?;
COMMENT ON COLUMN billiards_ods.member_profiles.register_site_id IS '鏉ユ簮:data.tenantMemberInfos.register_site_id锛涗細鍛樻敞鍐岄棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.member_profiles.site_name IS '鏉ユ簮:data.tenantMemberInfos.site_name锛涙敞鍐岄棬搴楀悕绉板揩鐓с€?;
COMMENT ON COLUMN billiards_ods.member_profiles.id IS '鏉ユ簮:data.tenantMemberInfos.id锛涗細鍛樿处鎴蜂富閿紙绉熸埛鍐呬竴寮犲崱/涓€涓处鎴凤級銆?;
COMMENT ON COLUMN billiards_ods.member_profiles.system_member_id IS '鏉ユ簮:data.tenantMemberInfos.system_member_id锛涘钩鍙扮骇浼氬憳ID锛岀敤浜庤法搴?璺ㄥ崱鑱氬悎鍚屼竴浼氬憳銆?;
COMMENT ON COLUMN billiards_ods.member_profiles.member_card_grade_code IS '鏉ユ簮:data.tenantMemberInfos.member_card_grade_code锛涗細鍛樺崱绉?绛夌骇缂栫爜锛堝鍌ㄥ€煎崱/鍙拌垂鍗＄瓑锛夈€?;
COMMENT ON COLUMN billiards_ods.member_profiles.member_card_grade_name IS '鏉ユ簮:data.tenantMemberInfos.member_card_grade_name锛涗細鍛樺崱绉?绛夌骇鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.member_profiles.mobile IS '鏉ユ簮:data.tenantMemberInfos.mobile锛涗細鍛樻墜鏈哄彿銆?;
COMMENT ON COLUMN billiards_ods.member_profiles.nickname IS '鏉ユ簮:data.tenantMemberInfos.nickname锛涗細鍛樻樀绉?灞曠ず鍚嶃€?;
COMMENT ON COLUMN billiards_ods.member_profiles.point IS '鏉ユ簮:data.tenantMemberInfos.point锛涘綋鍓嶇Н鍒嗕綑棰濄€?;
COMMENT ON COLUMN billiards_ods.member_profiles.growth_value IS '鏉ユ簮:data.tenantMemberInfos.growth_value锛涙垚闀垮€?缁忛獙鍊笺€?;
COMMENT ON COLUMN billiards_ods.member_profiles.referrer_member_id IS '鏉ユ簮:data.tenantMemberInfos.referrer_member_id锛涙帹鑽愪汉浼氬憳ID锛? 琛ㄧず鏃狅級銆?;
COMMENT ON COLUMN billiards_ods.member_profiles.status IS '鏉ユ簮:data.tenantMemberInfos.status锛涘崱璐︽埛鐘舵€佹灇涓俱€?;
COMMENT ON COLUMN billiards_ods.member_profiles.user_status IS '鏉ユ簮:data.tenantMemberInfos.user_status锛涚敤鎴风姸鎬佹灇涓俱€?;
COMMENT ON COLUMN billiards_ods.member_profiles.create_time IS '鏉ユ簮:data.tenantMemberInfos.create_time锛涜处鎴峰垱寤烘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.member_profiles.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.member_profiles.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.member_profiles.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.member_profiles.payload IS '鍘熷JSON鏁存潯璁板綍锛屼繚鐣欐湭灞曞紑瀛楁銆?;

-- ========== 浣欓鍙樻洿璁板綍锛堜綑棰濆彉鏇磋褰?json -> data.tenantMemberCardLogs锛?==========
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 '鏉ユ簮锛氫綑棰濆彉鏇磋褰?json -> data.tenantMemberCardLogs锛涜褰曚細鍛樺崱浣欓姣忔鍙樻洿銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.tenant_id IS '鏉ユ簮:data.tenantMemberCardLogs.tenant_id锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.site_id IS '鏉ユ簮:data.tenantMemberCardLogs.site_id锛涘彂鐢熷彉鏇寸殑闂ㄥ簵ID銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.register_site_id IS '鏉ユ簮:data.tenantMemberCardLogs.register_site_id锛涘紑鍗?娉ㄥ唽闂ㄥ簵ID銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.registerSiteName IS '鏉ユ簮:data.tenantMemberCardLogs.registerSiteName锛涙敞鍐岄棬搴楀悕绉般€?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.paySiteName IS '鏉ユ簮:data.tenantMemberCardLogs.paySiteName锛涙敮浠樺彂鐢熼棬搴楀悕绉般€?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.id IS '鏉ユ簮:data.tenantMemberCardLogs.id锛涗綑棰濆彉鏇磋褰曚富閿€?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.tenant_member_id IS '鏉ユ簮:data.tenantMemberCardLogs.tenant_member_id锛涚鎴峰唴浼氬憳ID銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.tenant_member_card_id IS '鏉ユ簮:data.tenantMemberCardLogs.tenant_member_card_id锛涗細鍛樺崱璐︽埛ID銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.system_member_id IS '鏉ユ簮:data.tenantMemberCardLogs.system_member_id锛涘钩鍙颁細鍛業D銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.memberName IS '鏉ユ簮:data.tenantMemberCardLogs.memberName锛涗細鍛樺鍚?鏄电О蹇収銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.memberMobile IS '鏉ユ簮:data.tenantMemberCardLogs.memberMobile锛涗細鍛樻墜鏈哄彿蹇収銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.card_type_id IS '鏉ユ簮:data.tenantMemberCardLogs.card_type_id锛涘崱绉岻D銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.memberCardTypeName IS '鏉ユ簮:data.tenantMemberCardLogs.memberCardTypeName锛涘崱绉嶅悕绉般€?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.account_data IS '鏉ユ簮:data.tenantMemberCardLogs.account_data锛涙湰娆″彉鍔ㄩ噾棰濓紝姝ｄ负澧炲姞銆佽礋涓哄噺灏戙€?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.before IS '鏉ユ簮:data.tenantMemberCardLogs.before锛涘彉鏇村墠浣欓銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.after IS '鏉ユ簮:data.tenantMemberCardLogs.after锛涘彉鏇村悗浣欓銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.refund_amount IS '鏉ユ簮:data.tenantMemberCardLogs.refund_amount锛涙湰娆℃秹鍙婇€€娆鹃噾棰濄€?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.from_type IS '鏉ユ簮:data.tenantMemberCardLogs.from_type锛涘彉鏇存潵婧愮被鍨嬫灇涓俱€?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.payment_method IS '鏉ユ簮:data.tenantMemberCardLogs.payment_method锛涙敮浠樻柟寮忔灇涓俱€?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.relate_id IS '鏉ユ簮:data.tenantMemberCardLogs.relate_id锛涗笟鍔″叧鑱擨D锛堝璁㈠崟/缁撶畻鍗曪級銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.remark IS '鏉ユ簮:data.tenantMemberCardLogs.remark锛涘娉ㄣ€?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.operator_id IS '鏉ユ簮:data.tenantMemberCardLogs.operator_id锛涙搷浣滀汉ID銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.operator_name IS '鏉ユ簮:data.tenantMemberCardLogs.operator_name锛涙搷浣滀汉鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.is_delete IS '鏉ユ簮:data.tenantMemberCardLogs.is_delete锛涢€昏緫鍒犻櫎鏍囪瘑銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.create_time IS '鏉ユ簮:data.tenantMemberCardLogs.create_time锛涜褰曞垱寤烘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.member_balance_changes.payload IS '鍘熷JSON鏁存潯璁板綍锛屼繚鐣欐湭灞曞紑瀛楁銆?;

-- ========== 鍌ㄥ€煎崱鍒楄〃锛堝偍鍊煎崱鍒楄〃.json -> data.tenantMemberCards锛?==========
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 '鏉ユ簮锛氬偍鍊煎崱鍒楄〃.json -> data.tenantMemberCards锛涘寘鍚偍鍊煎崱/鍙拌垂鍗?娲诲姩鍒哥瓑鍗″畾涔夊強鎶樻墸閰嶇疆銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.tenant_id IS '鏉ユ簮:data.tenantMemberCards.tenant_id锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.tenant_member_id IS '鏉ユ簮:data.tenantMemberCards.tenant_member_id锛涚鎴峰唴浼氬憳ID銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.system_member_id IS '鏉ユ簮:data.tenantMemberCards.system_member_id锛涘钩鍙颁細鍛業D銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.register_site_id IS '鏉ユ簮:data.tenantMemberCards.register_site_id锛涘紑鍗￠棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.site_name IS '鏉ユ簮:data.tenantMemberCards.site_name锛涘紑鍗￠棬搴楀悕绉般€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.id IS '鏉ユ簮:data.tenantMemberCards.id锛涗細鍛樺崱璐︽埛ID銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.member_card_grade_code IS '鏉ユ簮:data.tenantMemberCards.member_card_grade_code锛涘崱绉?绛夌骇缂栫爜銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.member_card_grade_code_name IS '鏉ユ簮:data.tenantMemberCards.member_card_grade_code_name锛涘崱绉?绛夌骇鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.member_card_type_name IS '鏉ユ簮:data.tenantMemberCards.member_card_type_name锛涘崱绫诲瀷鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.member_name IS '鏉ユ簮:data.tenantMemberCards.member_name锛涗細鍛樺鍚嶅揩鐓с€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.member_mobile IS '鏉ユ簮:data.tenantMemberCards.member_mobile锛涗細鍛樻墜鏈哄彿蹇収銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.card_type_id IS '鏉ユ簮:data.tenantMemberCards.card_type_id锛涘崱绫诲瀷ID銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.card_no IS '鏉ユ簮:data.tenantMemberCards.card_no锛涘疄浣?铏氭嫙鍗″彿銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.card_physics_type IS '鏉ユ簮:data.tenantMemberCards.card_physics_type锛涚墿鐞嗗崱绫诲瀷鏍囪瘑銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.balance IS '鏉ユ簮:data.tenantMemberCards.balance锛涘崱鍐呭綋鍓嶄綑棰濄€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.denomination IS '鏉ユ簮:data.tenantMemberCards.denomination锛涘崱闈㈤/鍒濆鍌ㄥ€奸噾棰濄€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.table_discount IS '鏉ユ簮:data.tenantMemberCards.table_discount锛涘彴璐规姌鎵ｏ紝10琛ㄧず涓嶆墦鎶樸€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goods_discount IS '鏉ユ簮:data.tenantMemberCards.goods_discount锛涘晢鍝佹姌鎵ｃ€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_discount IS '鏉ユ簮:data.tenantMemberCards.assistant_discount锛涘姪鏁欐湇鍔℃姌鎵ｃ€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_reward_discount IS '鏉ユ簮:data.tenantMemberCards.assistant_reward_discount锛涘姪鏁欏鍔遍噾鎶樻墸銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.table_service_discount IS '鏉ユ簮:data.tenantMemberCards.table_service_discount锛涘彴鐞冩湇鍔℃姌鎵ｃ€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_service_discount IS '鏉ユ簮:data.tenantMemberCards.assistant_service_discount锛涘姪鏁欐湇鍔℃姌鎵ｏ紙鍙︿竴鍙ｅ緞锛夈€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.coupon_discount IS '鏉ユ簮:data.tenantMemberCards.coupon_discount锛涘埜绫绘姌鎵ｃ€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goods_service_discount IS '鏉ユ簮:data.tenantMemberCards.goods_service_discount锛涘晢鍝佹湇鍔℃姌鎵ｃ€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_discount_sub_switch IS '鏉ユ簮:data.tenantMemberCards.assistant_discount_sub_switch锛涘姪鏁欐姌鎵ｅ紑鍏炽€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.table_discount_sub_switch IS '鏉ユ簮:data.tenantMemberCards.table_discount_sub_switch锛涘彴璐规姌鎵ｅ紑鍏炽€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goods_discount_sub_switch IS '鏉ユ簮:data.tenantMemberCards.goods_discount_sub_switch锛涘晢鍝佹姌鎵ｅ紑鍏炽€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_reward_discount_sub_switch IS '鏉ユ簮:data.tenantMemberCards.assistant_reward_discount_sub_switch锛涘姪鏁欏鍔辨姌鎵ｅ紑鍏炽€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.table_service_deduct_radio IS '鏉ユ簮:data.tenantMemberCards.table_service_deduct_radio锛涘彴璐规姷鎵ｆ瘮渚嬨€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_service_deduct_radio IS '鏉ユ簮:data.tenantMemberCards.assistant_service_deduct_radio锛涘姪鏁欐湇鍔℃姷鎵ｆ瘮渚嬨€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goods_service_deduct_radio IS '鏉ユ簮:data.tenantMemberCards.goods_service_deduct_radio锛涘晢鍝佹湇鍔℃姷鎵ｆ瘮渚嬨€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_deduct_radio IS '鏉ユ簮:data.tenantMemberCards.assistant_deduct_radio锛涘姪鏁欐姷鎵ｆ瘮渚嬨€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.table_deduct_radio IS '鏉ユ簮:data.tenantMemberCards.table_deduct_radio锛涘彴璐规姷鎵ｆ瘮渚嬨€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goods_deduct_radio IS '鏉ユ簮:data.tenantMemberCards.goods_deduct_radio锛涘晢鍝佹姷鎵ｆ瘮渚嬨€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.coupon_deduct_radio IS '鏉ユ簮:data.tenantMemberCards.coupon_deduct_radio锛涘埜鎶垫墸姣斾緥銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistant_reward_deduct_radio IS '鏉ユ簮:data.tenantMemberCards.assistant_reward_deduct_radio锛涘姪鏁欏鍔辨姷鎵ｆ瘮渚嬨€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.tableCardDeduct IS '鏉ユ簮:data.tenantMemberCards.tableCardDeduct锛涘彴璐规姷鎵ｉ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.tableServiceCardDeduct IS '鏉ユ簮:data.tenantMemberCards.tableServiceCardDeduct锛涘彴鐞冩湇鍔℃姷鎵ｉ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goodsCarDeduct IS '鏉ユ簮:data.tenantMemberCards.goodsCarDeduct锛涘晢鍝佹姷鎵ｉ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goodsServiceCardDeduct IS '鏉ユ簮:data.tenantMemberCards.goodsServiceCardDeduct锛涘晢鍝佹湇鍔℃姷鎵ｉ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistantCardDeduct IS '鏉ユ簮:data.tenantMemberCards.assistantCardDeduct锛涘姪鏁欐姷鎵ｉ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistantServiceCardDeduct IS '鏉ユ簮:data.tenantMemberCards.assistantServiceCardDeduct锛涘姪鏁欐湇鍔℃姷鎵ｉ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.assistantRewardCardDeduct IS '鏉ユ簮:data.tenantMemberCards.assistantRewardCardDeduct锛涘姪鏁欏鍔辨姷鎵ｉ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.cardSettleDeduct IS '鏉ユ簮:data.tenantMemberCards.cardSettleDeduct锛涚粨绠楁姷鎵ｉ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.couponCardDeduct IS '鏉ユ簮:data.tenantMemberCards.couponCardDeduct锛涘埜鎶垫墸閲戦銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.deliveryFeeDeduct IS '鏉ユ簮:data.tenantMemberCards.deliveryFeeDeduct锛涢厤閫佽垂鐢ㄦ姷鎵ｉ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.use_scene IS '鏉ユ簮:data.tenantMemberCards.use_scene锛涗娇鐢ㄥ満鏅灇涓俱€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.able_cross_site IS '鏉ユ簮:data.tenantMemberCards.able_cross_site锛涙槸鍚﹁法搴楅€氱敤銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.able_site_transfer IS '鏉ユ簮:data.tenantMemberCards.able_site_transfer锛涙槸鍚﹀彲闂ㄥ簵杞Щ銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.is_allow_give IS '鏉ユ簮:data.tenantMemberCards.is_allow_give锛涙槸鍚﹀厑璁歌浆璧犮€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.is_allow_order_deduct IS '鏉ユ簮:data.tenantMemberCards.is_allow_order_deduct锛涙槸鍚﹀厑璁歌鍗曟姷鎵ｃ€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.is_delete IS '鏉ユ簮:data.tenantMemberCards.is_delete锛涢€昏緫鍒犻櫎鏍囪瘑銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.bind_password IS '鏉ユ簮:data.tenantMemberCards.bind_password锛涙槸鍚︾粦瀹氬瘑鐮?缁戝畾瀵嗙爜鍐呭銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goods_discount_range_type IS '鏉ユ簮:data.tenantMemberCards.goods_discount_range_type锛涘晢鍝佹姌鎵ｉ€傜敤鑼冨洿绫诲瀷銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goods_discount_sub_switch IS '鏉ユ簮:data.tenantMemberCards.goods_discount_sub_switch锛涘晢鍝佹姌鎵ｅ紑鍏炽€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.goodsCategoryId IS '鏉ユ簮:data.tenantMemberCards.goodsCategoryId锛涘晢鍝佸垎绫籌D銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.tableAreaId IS '鏉ユ簮:data.tenantMemberCards.tableAreaId锛涘彴鐞冨尯鍩烮D銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.effect_site_id IS '鏉ユ簮:data.tenantMemberCards.effect_site_id锛涚敓鏁堥棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.start_time IS '鏉ユ簮:data.tenantMemberCards.start_time锛涙湁鏁堟湡寮€濮嬫椂闂淬€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.end_time IS '鏉ユ簮:data.tenantMemberCards.end_time锛涙湁鏁堟湡缁撴潫鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.disable_start_time IS '鏉ユ簮:data.tenantMemberCards.disable_start_time锛涘仠鐢ㄥ紑濮嬫椂闂淬€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.disable_end_time IS '鏉ユ簮:data.tenantMemberCards.disable_end_time锛涘仠鐢ㄧ粨鏉熸椂闂淬€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.last_consume_time IS '鏉ユ簮:data.tenantMemberCards.last_consume_time锛涙渶杩戞秷璐规椂闂淬€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.create_time IS '鏉ユ簮:data.tenantMemberCards.create_time锛涘崱鍒涘缓鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.status IS '鏉ユ簮:data.tenantMemberCards.status锛涘崱鐘舵€併€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.sort IS '鏉ユ簮:data.tenantMemberCards.sort锛涙帓搴忓瓧娈点€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.tenantAvatar IS '鏉ユ簮:data.tenantMemberCards.tenantAvatar锛涚鎴峰ご鍍廢RL銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.tenantName IS '鏉ユ簮:data.tenantMemberCards.tenantName锛涚鎴峰悕绉般€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.pdAssisnatLevel IS '鏉ユ簮:data.tenantMemberCards.pdAssisnatLevel锛涘姪鏁欑瓑绾э紙鍏呭€艰禒閫侀厤缃級銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.cxAssisnatLevel IS '鏉ユ簮:data.tenantMemberCards.cxAssisnatLevel锛涘姪鏁欑瓑绾э紙鎸佺画娑堣垂閰嶇疆锛夈€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.member_stored_value_cards.payload IS '鍘熷JSON鏁存潯璁板綍锛屼繚鐣欐湭灞曞紑瀛楁銆?;

-- ========== 鍏呭€艰褰曪紙鍏呭€艰褰?json -> data.settleList[] = {settleList, siteProfile}锛?==========
CREATE TABLE IF NOT EXISTS billiards_ods.recharge_settlements (
    recharge_order_id         BIGINT PRIMARY KEY,
    tenant_id                 BIGINT,
    site_id                   BIGINT,
    site_name_snapshot        TEXT,
    member_id                 BIGINT,
    member_name_snapshot      TEXT,
    member_phone_snapshot     TEXT,
    tenant_member_card_id     BIGINT,
    member_card_type_name     TEXT,
    settle_relate_id          BIGINT,
    settle_type               INT,
    settle_name               TEXT,
    is_first                  INT,
    settle_status             INT,
    pay_amount                NUMERIC(18,2),
    refund_amount             NUMERIC(18,2),
    point_amount              NUMERIC(18,2),
    cash_amount               NUMERIC(18,2),
    online_amount             NUMERIC(18,2),
    balance_amount            NUMERIC(18,2),
    card_amount               NUMERIC(18,2),
    coupon_amount             NUMERIC(18,2),
    recharge_card_amount      NUMERIC(18,2),
    gift_card_amount          NUMERIC(18,2),
    prepay_money              NUMERIC(18,2),
    consume_money             NUMERIC(18,2),
    goods_money               NUMERIC(18,2),
    real_goods_money          NUMERIC(18,2),
    table_charge_money        NUMERIC(18,2),
    service_money             NUMERIC(18,2),
    activity_discount         NUMERIC(18,2),
    all_coupon_discount       NUMERIC(18,2),
    goods_promotion_money     NUMERIC(18,2),
    assistant_promotion_money NUMERIC(18,2),
    assistant_pd_money        NUMERIC(18,2),
    assistant_cx_money        NUMERIC(18,2),
    assistant_manual_discount NUMERIC(18,2),
    coupon_sale_amount        NUMERIC(18,2),
    member_discount_amount    NUMERIC(18,2),
    point_discount_price      NUMERIC(18,2),
    point_discount_cost       NUMERIC(18,2),
    adjust_amount             NUMERIC(18,2),
    rounding_amount           NUMERIC(18,2),
    payment_method            INT,
    can_be_revoked            BOOLEAN,
    is_bind_member            BOOLEAN,
    is_activity               BOOLEAN,
    is_use_coupon             BOOLEAN,
    is_use_discount           BOOLEAN,
    operator_id               BIGINT,
    operator_name_snapshot    TEXT,
    salesman_user_id          BIGINT,
    salesman_name             TEXT,
    order_remark              TEXT,
    table_id                  BIGINT,
    serial_number             BIGINT,
    revoke_order_id           BIGINT,
    revoke_order_name         TEXT,
    revoke_time               TIMESTAMPTZ,
    create_time               TIMESTAMPTZ,
    pay_time                  TIMESTAMPTZ,
    site_profile              JSONB,
    source_file               TEXT,
    source_endpoint           TEXT,
    fetched_at                TIMESTAMPTZ DEFAULT now(),
    payload                   JSONB NOT NULL
);
COMMENT ON TABLE billiards_ods.recharge_settlements IS '???????.json -> data.settleList[]?? settleList ???????site_profile ???????payload ???????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.recharge_order_id IS '??:settleList.id???/????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.tenant_id IS '??:settleList.tenantId???ID?';
COMMENT ON COLUMN billiards_ods.recharge_settlements.site_id IS '??:settleList.siteId???ID????? siteProfile.id??';
COMMENT ON COLUMN billiards_ods.recharge_settlements.site_name_snapshot IS '??:siteProfile.shop_name ????? settleList.siteName?';
COMMENT ON COLUMN billiards_ods.recharge_settlements.member_id IS '??:settleList.memberId?????ID?';
COMMENT ON COLUMN billiards_ods.recharge_settlements.member_name_snapshot IS '??:settleList.memberName????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.member_phone_snapshot IS '??:settleList.memberPhone?????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.tenant_member_card_id IS '??:settleList.tenantMemberCardId??????ID?';
COMMENT ON COLUMN billiards_ods.recharge_settlements.member_card_type_name IS '??:settleList.memberCardTypeName?????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.settle_relate_id IS '??:settleList.settleRelateId?????ID?';
COMMENT ON COLUMN billiards_ods.recharge_settlements.settle_type IS '??:settleList.settleType?5=?????7=?????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.settle_name IS '??:settleList.settleName????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.is_first IS '??:settleList.isFirst????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.settle_status IS '??:settleList.settleStatus??????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.pay_amount IS '??:settleList.payAmount????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.refund_amount IS '??:settleList.refundAmount??????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.point_amount IS '??:settleList.pointAmount????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.cash_amount IS '??:settleList.cashAmount????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.online_amount IS '??:settleList.onlineAmount????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.balance_amount IS '??:settleList.balanceAmount????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.card_amount IS '??:settleList.cardAmount?????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.coupon_amount IS '??:settleList.couponAmount???????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.recharge_card_amount IS '??:settleList.rechargeCardAmount???????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.gift_card_amount IS '??:settleList.giftCardAmount???????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.prepay_money IS '??:settleList.prepayMoney????/?????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.consume_money IS '??:settleList.consumeMoney??????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.goods_money IS '??:settleList.goodsMoney????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.real_goods_money IS '??:settleList.realGoodsMoney????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.table_charge_money IS '??:settleList.tableChargeMoney??????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.service_money IS '??:settleList.serviceMoney??????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.activity_discount IS '??:settleList.activityDiscount????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.all_coupon_discount IS '??:settleList.allCouponDiscount????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.goods_promotion_money IS '??:settleList.goodsPromotionMoney????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.assistant_promotion_money IS '??:settleList.assistantPromotionMoney????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.assistant_pd_money IS '??:settleList.assistantPdMoney????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.assistant_cx_money IS '??:settleList.assistantCxMoney????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.assistant_manual_discount IS '??:settleList.assistantManualDiscount????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.coupon_sale_amount IS '??:settleList.couponSaleAmount??/???????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.member_discount_amount IS '??:settleList.memberDiscountAmount????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.point_discount_price IS '??:settleList.pointDiscountPrice????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.point_discount_cost IS '??:settleList.pointDiscountCost????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.adjust_amount IS '??:settleList.adjustAmount????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.rounding_amount IS '??:settleList.roundingAmount??????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.payment_method IS '??:settleList.paymentMethod????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.can_be_revoked IS '??:settleList.canBeRevoked???????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.is_bind_member IS '??:settleList.isBindMember??????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.is_activity IS '??:settleList.isActivity????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.is_use_coupon IS '??:settleList.isUseCoupon?????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.is_use_discount IS '??:settleList.isUseDiscount????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.operator_id IS '??:settleList.operatorId????/???ID?';
COMMENT ON COLUMN billiards_ods.recharge_settlements.operator_name_snapshot IS '??:settleList.operatorName?????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.salesman_user_id IS '??:settleList.salesManUserId??????ID?';
COMMENT ON COLUMN billiards_ods.recharge_settlements.salesman_name IS '??:settleList.salesManName???????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.order_remark IS '??:settleList.orderRemark??????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.table_id IS '??:settleList.tableId????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.serial_number IS '??:settleList.serialNumber???/?????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.revoke_order_id IS '??:settleList.revokeOrderId???????ID?';
COMMENT ON COLUMN billiards_ods.recharge_settlements.revoke_order_name IS '??:settleList.revokeOrderName???????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.revoke_time IS '??:settleList.revokeTime??????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.create_time IS '??:settleList.createTime????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.pay_time IS '??:settleList.payTime??????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.site_profile IS '??:siteProfile????????JSON??';
COMMENT ON COLUMN billiards_ods.recharge_settlements.source_file IS '????????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.source_endpoint IS '??????????/???';
COMMENT ON COLUMN billiards_ods.recharge_settlements.fetched_at IS '???????????';
COMMENT ON COLUMN billiards_ods.recharge_settlements.payload IS '??JSON?????? settleList ? siteProfile??';


-- ========== 缁撹处璁板綍锛堢粨璐﹁褰?json -> data.settleList[] = {settleList, siteProfile}锛?==========
CREATE TABLE IF NOT EXISTS billiards_ods.settlement_records (
    settleList        JSONB,
    siteProfile       JSONB,
    source_file       TEXT,
    source_endpoint   TEXT,
    fetched_at        TIMESTAMPTZ DEFAULT now(),
    payload           JSONB NOT NULL
);
COMMENT ON TABLE billiards_ods.settlement_records IS '鏉ユ簮锛氱粨璐﹁褰?json -> data.settleList锛涢棬搴楁秷璐圭粨绠楄褰曪紝settleList鍚噾棰濇槑缁嗐€乻ettleType銆佹敮浠樻柟寮忕瓑锛宻iteProfile涓洪棬搴楀揩鐓с€?;
COMMENT ON COLUMN billiards_ods.settlement_records.settleList IS '鏉ユ簮:data.settleList[].settleList锛涚粨绠椾富瀵硅薄鍘熸牱瀛樺偍銆?;
COMMENT ON COLUMN billiards_ods.settlement_records.siteProfile IS '鏉ユ簮:data.settleList[].siteProfile锛涢棬搴椾俊鎭揩鐓с€?;
COMMENT ON COLUMN billiards_ods.settlement_records.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.settlement_records.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣锛堢粨璐﹁褰曪級銆?;
COMMENT ON COLUMN billiards_ods.settlement_records.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.settlement_records.payload IS '鍘熷JSON鏁存潯璁板綍锛堝惈settleList涓巗iteProfile锛夛紝渚夸簬澶嶅師銆?;

-- ========== 鍔╂暀搴熼櫎锛堝姪鏁欏簾闄?json -> data.abolitionAssistants锛?==========
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 '鏉ユ簮锛氬姪鏁欏簾闄?json -> data.abolitionAssistants锛涜褰曞姪鏁欒搴熼櫎/鍙栨秷鐨勫彴娆′笌閲戦銆?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.id IS '鏉ユ簮:data.abolitionAssistants.id锛涘簾闄よ褰曚富閿€?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.siteId IS '鏉ユ簮:data.abolitionAssistants.siteId锛涢棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.siteProfile IS '鏉ユ簮:data.abolitionAssistants.siteProfile锛涢棬搴椾俊鎭揩鐓с€?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.assistantName IS '鏉ユ簮:data.abolitionAssistants.assistantName锛涘姪鏁欏鍚?鏄电О銆?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.assistantAbolishAmount IS '鏉ユ簮:data.abolitionAssistants.assistantAbolishAmount锛涜搴熼櫎鐨勮垂鐢ㄩ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.assistantOn IS '鏉ユ簮:data.abolitionAssistants.assistantOn锛涘姪鏁欎笂閽熸爣璇嗐€?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.pdChargeMinutes IS '鏉ユ簮:data.abolitionAssistants.pdChargeMinutes锛涜璐瑰垎閽熸暟銆?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.tableAreaId IS '鏉ユ簮:data.abolitionAssistants.tableAreaId锛涘彴鐞冨尯鍩烮D銆?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.tableArea IS '鏉ユ簮:data.abolitionAssistants.tableArea锛涘彴鐞冨尯鍩熷悕绉般€?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.tableId IS '鏉ユ簮:data.abolitionAssistants.tableId锛涘彴妗孖D銆?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.tableName IS '鏉ユ簮:data.abolitionAssistants.tableName锛涘彴妗屽悕绉般€?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.trashReason IS '鏉ユ簮:data.abolitionAssistants.trashReason锛涘簾闄ゅ師鍥犮€?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.createTime IS '鏉ユ簮:data.abolitionAssistants.createTime锛涜褰曟椂闂淬€?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.assistant_cancellation_records.payload IS '鍘熷JSON鏁存潯璁板綍锛屼繚鐣欏叾浠栧瓧娈点€?;

-- ========== 鍔╂暀璐﹀彿锛堝姪鏁欒处鍙?json -> data.assistantInfos锛?==========
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,
    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,
    gender               INT,
    show_status          INT,
    show_sort            INT,
    sum_grade            NUMERIC(18,2),
    get_grade_times      INT,
    video_introduction_url TEXT,
    source_file          TEXT,
    source_endpoint      TEXT,
    fetched_at           TIMESTAMPTZ DEFAULT now(),
    payload              JSONB NOT NULL
);
COMMENT ON TABLE billiards_ods.assistant_accounts_master IS '鏉ユ簮锛氬姪鏁欒处鍙?json -> data.assistantInfos锛涘姪鏁欎汉鍛樻。妗堬紝鍏抽敭瀛楁灞曞紑锛屽叾浣欎繚鎸佸湪payload銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.id IS '鏉ユ簮:data.assistantInfos.id锛涘姪鏁欎富閿€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.tenant_id IS '鏉ユ簮:data.assistantInfos.tenant_id锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.site_id IS '鏉ユ簮:data.assistantInfos.site_id锛涢棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.assistant_no IS '鏉ユ簮:data.assistantInfos.assistant_no锛涘姪鏁欑紪鍙枫€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.nickname IS '鏉ユ簮:data.assistantInfos.nickname锛涘姪鏁欐樀绉般€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.real_name IS '鏉ユ簮:data.assistantInfos.real_name锛涚湡瀹炲鍚嶃€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.mobile IS '鏉ユ簮:data.assistantInfos.mobile锛涙墜鏈哄彿銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.team_id IS '鏉ユ簮:data.assistantInfos.team_id锛涙墍灞炲洟闃烮D銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.team_name IS '鏉ユ簮:data.assistantInfos.team_name锛涙墍灞炲洟闃熷悕绉般€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.level IS '鏉ユ簮:data.assistantInfos.level锛涘姪鏁欑骇鍒€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.assistant_status IS '鏉ユ簮:data.assistantInfos.assistant_status锛涜处鍙风姸鎬?鍦ㄨ亴鐘舵€併€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.work_status IS '鏉ユ簮:data.assistantInfos.work_status锛涘伐浣滅姸鎬侊紙鍦ㄧ嚎/蹇欑绛夛級銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.leave_status IS '鏉ユ簮:data.assistantInfos.leave_status锛涜鍋?绂诲矖鐘舵€併€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.entry_time IS '鏉ユ簮:data.assistantInfos.entry_time锛涘叆鑱屾椂闂淬€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.resign_time IS '鏉ユ簮:data.assistantInfos.resign_time锛涚鑱?鎾ゅ矖鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.start_time IS '鏉ユ簮:data.assistantInfos.start_time锛涜处鍙峰惎鐢ㄦ椂闂淬€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.end_time IS '鏉ユ簮:data.assistantInfos.end_time锛涜处鍙风粨鏉熸椂闂淬€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.create_time IS '鏉ユ簮:data.assistantInfos.create_time锛涘垱寤烘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.update_time IS '鏉ユ簮:data.assistantInfos.update_time锛涙洿鏂版椂闂淬€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.order_trade_no IS '鏉ユ簮:data.assistantInfos.order_trade_no锛涘叧鑱旇鍗曞彿锛堣嫢鏈夛級銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.staff_id IS '鏉ユ簮:data.assistantInfos.staff_id锛涘憳宸D銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.staff_profile_id IS '鏉ユ簮:data.assistantInfos.staff_profile_id锛涘憳宸ユ。妗圛D銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.system_role_id IS '鏉ユ簮:data.assistantInfos.system_role_id锛涚郴缁熻鑹睮D銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.avatar IS '鏉ユ簮:data.assistantInfos.avatar锛涘ご鍍忋€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.gender IS '鏉ユ簮:data.assistantInfos.gender锛涙€у埆銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.show_status IS '鏉ユ簮:data.assistantInfos.show_status锛涙槸鍚﹀睍绀恒€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.show_sort IS '鏉ユ簮:data.assistantInfos.show_sort锛涘睍绀烘帓搴忋€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.sum_grade IS '鏉ユ簮:data.assistantInfos.sum_grade锛涚患鍚堣瘎鍒嗙疮璁°€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.get_grade_times IS '鏉ユ簮:data.assistantInfos.get_grade_times锛涜璇勫垎娆℃暟銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.video_introduction_url IS '鏉ユ簮:data.assistantInfos.video_introduction_url锛涗粙缁嶈棰慤RL銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.assistant_accounts_master.payload IS '鍘熷JSON鏁存潯璁板綍锛屽寘鍚湭灞曞紑鐨勫叾瀹冨瓧娈碉紙allow_cx銆乧harge_way绛夛級銆?;

-- ========== 鍔╂暀娴佹按锛堝姪鏁欐祦姘?json -> data.orderAssistantDetails锛?==========
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,
    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,
    assistant_team_id_dup    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 '鏉ユ簮锛氬姪鏁欐祦姘?json -> data.orderAssistantDetails锛涘姪鏁欐湇鍔¤璐规槑缁嗭紝涓昏瀛楁灞曞紑锛屽叾浣欎繚鐣欏湪payload銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.id IS '鏉ユ簮:data.orderAssistantDetails.id锛涘姪鏁欐祦姘翠富閿€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.tenant_id IS '鏉ユ簮:data.orderAssistantDetails.tenant_id锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.site_id IS '鏉ユ簮:data.orderAssistantDetails.site_id锛涢棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.siteProfile IS '鏉ユ簮:data.orderAssistantDetails.siteProfile锛涢棬搴楀揩鐓с€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.site_table_id IS '鏉ユ簮:data.orderAssistantDetails.site_table_id锛涘彴妗孖D銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.order_settle_id IS '鏉ユ簮:data.orderAssistantDetails.order_settle_id锛涚粨绠楀崟ID銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.order_trade_no IS '鏉ユ簮:data.orderAssistantDetails.order_trade_no锛涜鍗曞彿銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.order_pay_id IS '鏉ユ簮:data.orderAssistantDetails.order_pay_id锛涙敮浠樿褰旾D銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.order_assistant_id IS '鏉ユ簮:data.orderAssistantDetails.order_assistant_id锛涘姪鏁欒鍗曞叧鑱擨D銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.order_assistant_type IS '鏉ユ簮:data.orderAssistantDetails.order_assistant_type锛涘姪鏁欑被鍨嬫灇涓俱€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.assistantName IS '鏉ユ簮:data.orderAssistantDetails.assistantName锛涘姪鏁欏悕绉般€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.assistantNo IS '鏉ユ簮:data.orderAssistantDetails.assistantNo锛涘姪鏁欑紪鍙枫€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.assistant_level IS '鏉ユ簮:data.orderAssistantDetails.assistant_level锛涘姪鏁欑瓑绾с€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.assistant_team_id IS '鏉ユ簮:data.orderAssistantDetails.assistant_team_id锛涘姪鏁欏洟闃烮D銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.nickname IS '鏉ユ簮:data.orderAssistantDetails.nickname锛涘姪鏁欐樀绉般€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_name IS '鏉ユ簮:data.orderAssistantDetails.ledger_name锛涜璐归」鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_group_name IS '鏉ユ簮:data.orderAssistantDetails.ledger_group_name锛涜璐瑰垎缁勩€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_amount IS '鏉ユ簮:data.orderAssistantDetails.ledger_amount锛涜璐归噾棰濄€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_count IS '鏉ユ簮:data.orderAssistantDetails.ledger_count锛涜璐规暟閲?鏃堕暱銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_unit_price IS '鏉ユ簮:data.orderAssistantDetails.ledger_unit_price锛涜璐瑰崟浠枫€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_status IS '鏉ユ簮:data.orderAssistantDetails.ledger_status锛涜璐圭姸鎬併€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_start_time IS '鏉ユ簮:data.orderAssistantDetails.ledger_start_time锛涜璐瑰紑濮嬫椂闂淬€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.ledger_end_time IS '鏉ユ簮:data.orderAssistantDetails.ledger_end_time锛涜璐圭粨鏉熸椂闂淬€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.manual_discount_amount IS '鏉ユ簮:data.orderAssistantDetails.manual_discount_amount锛涗汉宸ヤ紭鎯犻噾棰濄€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.member_discount_amount IS '鏉ユ簮:data.orderAssistantDetails.member_discount_amount锛涗細鍛樻姌鎵ｉ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.coupon_deduct_money IS '鏉ユ簮:data.orderAssistantDetails.coupon_deduct_money锛涘埜鎶垫墸閲戦銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.service_money IS '鏉ユ簮:data.orderAssistantDetails.service_money锛涙湇鍔¤垂閲戦銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.projected_income IS '鏉ユ簮:data.orderAssistantDetails.projected_income锛涢璁℃敹鍏ャ€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.real_use_seconds IS '鏉ユ簮:data.orderAssistantDetails.real_use_seconds锛涘疄闄呬娇鐢ㄧ鏁般€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.income_seconds IS '鏉ユ簮:data.orderAssistantDetails.income_seconds锛涜璐圭鏁般€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.start_use_time IS '鏉ユ簮:data.orderAssistantDetails.start_use_time锛涘紑濮嬩娇鐢ㄦ椂闂淬€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.last_use_time IS '鏉ユ簮:data.orderAssistantDetails.last_use_time锛涙渶鍚庝娇鐢ㄦ椂闂淬€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.create_time IS '鏉ユ簮:data.orderAssistantDetails.create_time锛涙祦姘村垱寤烘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.is_single_order IS '鏉ユ簮:data.orderAssistantDetails.is_single_order锛涙槸鍚﹀崟鐐硅鍗曟爣璇嗐€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.is_delete IS '鏉ユ簮:data.orderAssistantDetails.is_delete锛涢€昏緫鍒犻櫎鏍囪瘑銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.is_trash IS '鏉ユ簮:data.orderAssistantDetails.is_trash锛涘簾闄ゆ爣璇嗐€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.trash_reason IS '鏉ユ簮:data.orderAssistantDetails.trash_reason锛涘簾闄ゅ師鍥犮€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.trash_applicant_id IS '鏉ユ簮:data.orderAssistantDetails.trash_applicant_id锛涘簾闄ょ敵璇蜂汉ID銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.trash_applicant_name IS '鏉ユ簮:data.orderAssistantDetails.trash_applicant_name锛涘簾闄ょ敵璇蜂汉鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.operator_id IS '鏉ユ簮:data.orderAssistantDetails.operator_id锛涙搷浣滀汉ID銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.operator_name IS '鏉ユ簮:data.orderAssistantDetails.operator_name锛涙搷浣滀汉鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.salesman_name IS '鏉ユ簮:data.orderAssistantDetails.salesman_name锛涢攢鍞?鎺ュ緟濮撳悕銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.salesman_org_id IS '鏉ユ簮:data.orderAssistantDetails.salesman_org_id锛涢攢鍞粍缁嘔D銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.salesman_user_id IS '鏉ユ簮:data.orderAssistantDetails.salesman_user_id锛涢攢鍞敤鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.person_org_id IS '鏉ユ簮:data.orderAssistantDetails.person_org_id锛涘憳宸ョ粍缁嘔D銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.assistant_team_id_dup IS '鏉ユ簮:data.orderAssistantDetails.assistant_team_id锛涘洟闃烮D鍐椾綑灞曞紑銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.add_clock IS '鏉ユ簮:data.orderAssistantDetails.add_clock锛涘姞閽熸椂闀挎爣璇嗐€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.returns_clock IS '鏉ユ簮:data.orderAssistantDetails.returns_clock锛涢€€閽熸椂闀挎爣璇嗐€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.composite_grade IS '鏉ユ簮:data.orderAssistantDetails.composite_grade锛涚患鍚堣瘎鍒嗐€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.composite_grade_time IS '鏉ユ簮:data.orderAssistantDetails.composite_grade_time锛涜瘎鍒嗘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.skill_grade IS '鏉ユ簮:data.orderAssistantDetails.skill_grade锛涙妧鑳借瘎鍒嗐€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.service_grade IS '鏉ユ簮:data.orderAssistantDetails.service_grade锛涙湇鍔¤瘎鍒嗐€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.sum_grade IS '鏉ユ簮:data.orderAssistantDetails.sum_grade锛涜瘎鍒嗙疮璁°€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.grade_status IS '鏉ユ簮:data.orderAssistantDetails.grade_status锛涜瘎鍒嗙姸鎬併€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.get_grade_times IS '鏉ユ簮:data.orderAssistantDetails.get_grade_times锛涜璇勫垎娆℃暟銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.is_not_responding IS '鏉ユ簮:data.orderAssistantDetails.is_not_responding锛涙槸鍚︽棤鍝嶅簲銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.is_confirm IS '鏉ユ簮:data.orderAssistantDetails.is_confirm锛涙槸鍚﹀凡纭銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.payload IS '鍘熷JSON鏁存潯璁板綍锛屽叾浣欏瓧娈碉紙濡俵evelName銆乻killName绛夛級淇濈暀銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.assistant_service_records.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;

-- ========== 鍙版鍒楄〃锛堝彴妗屽垪琛?json -> data.siteTables锛?==========
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 '鏉ユ簮锛氬彴妗屽垪琛?json -> data.siteTables锛涢棬搴楀彴妗屽熀纭€淇℃伅銆?;
COMMENT ON COLUMN billiards_ods.site_tables_master.id IS '鏉ユ簮:data.siteTables.id锛涘彴妗屼富閿€?;
COMMENT ON COLUMN billiards_ods.site_tables_master.site_id IS '鏉ユ簮:data.siteTables.site_id锛涢棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.site_tables_master.siteName IS '鏉ユ簮:data.siteTables.siteName锛涢棬搴楀悕绉般€?;
COMMENT ON COLUMN billiards_ods.site_tables_master."appletQrCodeUrl" IS '鏉ユ簮:data.siteTables.appletQrCodeUrl锛涘皬绋嬪簭浜岀淮鐮乁RL銆?;
COMMENT ON COLUMN billiards_ods.site_tables_master.areaName IS '鏉ユ簮:data.siteTables.areaName锛涘尯鍩熷悕绉般€?;
COMMENT ON COLUMN billiards_ods.site_tables_master.audit_status IS '鏉ユ簮:data.siteTables.audit_status锛涘鏍哥姸鎬併€?;
COMMENT ON COLUMN billiards_ods.site_tables_master.charge_free IS '鏉ユ簮:data.siteTables.charge_free锛涙槸鍚﹀厤璐瑰彴銆?;
COMMENT ON COLUMN billiards_ods.site_tables_master.create_time IS '鏉ユ簮:data.siteTables.create_time锛涘垱寤烘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.site_tables_master.delay_lights_time IS '鏉ユ簮:data.siteTables.delay_lights_time锛涘欢鏃跺叧鐏鏁般€?;
COMMENT ON COLUMN billiards_ods.site_tables_master.is_online_reservation IS '鏉ユ簮:data.siteTables.is_online_reservation锛涙槸鍚︽敮鎸佺嚎涓婇绾︺€?;
COMMENT ON COLUMN billiards_ods.site_tables_master.is_rest_area IS '鏉ユ簮:data.siteTables.is_rest_area锛涙槸鍚︿紤鎭尯銆?;
COMMENT ON COLUMN billiards_ods.site_tables_master.light_status IS '鏉ユ簮:data.siteTables.light_status锛涚伅鍏夌姸鎬併€?;
COMMENT ON COLUMN billiards_ods.site_tables_master.only_allow_groupon IS '鏉ユ簮:data.siteTables.only_allow_groupon锛涙槸鍚︿粎鍏佽鍥㈣喘銆?;
COMMENT ON COLUMN billiards_ods.site_tables_master.order_delay_time IS '鏉ユ簮:data.siteTables.order_delay_time锛涘紑鍗曞欢鏃剁銆?;
COMMENT ON COLUMN billiards_ods.site_tables_master.self_table IS '鏉ユ簮:data.siteTables.self_table锛涙槸鍚﹁嚜鍔╁彴銆?;
COMMENT ON COLUMN billiards_ods.site_tables_master.show_status IS '鏉ユ簮:data.siteTables.show_status锛涘睍绀虹姸鎬併€?;
COMMENT ON COLUMN billiards_ods.site_tables_master.site_table_area_id IS '鏉ユ簮:data.siteTables.site_table_area_id锛涘彴妗屽尯鍩烮D銆?;
COMMENT ON COLUMN billiards_ods.site_tables_master.tableStatusName IS '鏉ユ簮:data.siteTables.tableStatusName锛涘彴妗岀姸鎬佸悕绉般€?;
COMMENT ON COLUMN billiards_ods.site_tables_master.table_cloth_use_Cycle IS '鏉ユ簮:data.siteTables.table_cloth_use_Cycle锛涚悆鍙板竷浣跨敤鍛ㄦ湡銆?;
COMMENT ON COLUMN billiards_ods.site_tables_master.table_cloth_use_time IS '鏉ユ簮:data.siteTables.table_cloth_use_time锛涚悆鍙板竷鏈€杩戞洿鎹㈡椂闂淬€?;
COMMENT ON COLUMN billiards_ods.site_tables_master.table_name IS '鏉ユ簮:data.siteTables.table_name锛涘彴妗屽悕绉般€?;
COMMENT ON COLUMN billiards_ods.site_tables_master.table_price IS '鏉ユ簮:data.siteTables.table_price锛涘彴璐瑰崟浠枫€?;
COMMENT ON COLUMN billiards_ods.site_tables_master.table_status IS '鏉ユ簮:data.siteTables.table_status锛涘彴妗岀姸鎬併€?;
COMMENT ON COLUMN billiards_ods.site_tables_master.temporary_light_second IS '鏉ユ簮:data.siteTables.temporary_light_second锛涗复鏃跺紑鐏鏁般€?;
COMMENT ON COLUMN billiards_ods.site_tables_master.virtual_table IS '鏉ユ簮:data.siteTables.virtual_table锛涙槸鍚﹁櫄鎷熷彴銆?;
COMMENT ON COLUMN billiards_ods.site_tables_master.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.site_tables_master.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.site_tables_master.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.site_tables_master.payload IS '鍘熷JSON鏁存潯璁板綍锛屼繚鐣欓澶栧瓧娈点€?;

-- ========== 鍙拌垂鎵撴姌锛堝彴璐规墦鎶?json -> data.taiFeeAdjustInfos锛?==========
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 '鏉ユ簮锛氬彴璐规墦鎶?json -> data.taiFeeAdjustInfos锛涘彴璐规姌鎵?璋冧环璁板綍銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.id IS '鏉ユ簮:data.taiFeeAdjustInfos.id锛涙姌鎵ｈ褰曚富閿€?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.tenant_id IS '鏉ユ簮:data.taiFeeAdjustInfos.tenant_id锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.site_id IS '鏉ユ簮:data.taiFeeAdjustInfos.site_id锛涢棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.siteProfile IS '鏉ユ簮:data.taiFeeAdjustInfos.siteProfile锛涢棬搴楀揩鐓с€?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.site_table_id IS '鏉ユ簮:data.taiFeeAdjustInfos.site_table_id锛涘彴妗孖D銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.tableProfile IS '鏉ユ簮:data.taiFeeAdjustInfos.tableProfile锛涘彴妗屼俊鎭揩鐓с€?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.tenant_table_area_id IS '鏉ユ簮:data.taiFeeAdjustInfos.tenant_table_area_id锛涘彴妗屽尯鍩烮D銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.adjust_type IS '鏉ユ簮:data.taiFeeAdjustInfos.adjust_type锛涜皟浠风被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.ledger_amount IS '鏉ユ簮:data.taiFeeAdjustInfos.ledger_amount锛涜皟浠峰悗閲戦銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.ledger_count IS '鏉ユ簮:data.taiFeeAdjustInfos.ledger_count锛涜皟浠锋暟閲?鏃堕暱銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.ledger_name IS '鏉ユ簮:data.taiFeeAdjustInfos.ledger_name锛涜璐归」鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.ledger_status IS '鏉ユ簮:data.taiFeeAdjustInfos.ledger_status锛涜璐圭姸鎬併€?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.applicant_id IS '鏉ユ簮:data.taiFeeAdjustInfos.applicant_id锛涚敵璇蜂汉ID銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.applicant_name IS '鏉ユ簮:data.taiFeeAdjustInfos.applicant_name锛涚敵璇蜂汉鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.operator_id IS '鏉ユ簮:data.taiFeeAdjustInfos.operator_id锛涙搷浣滀汉ID銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.operator_name IS '鏉ユ簮:data.taiFeeAdjustInfos.operator_name锛涙搷浣滀汉鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.order_settle_id IS '鏉ユ簮:data.taiFeeAdjustInfos.order_settle_id锛涘叧鑱旂粨绠楀崟ID銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.order_trade_no IS '鏉ユ簮:data.taiFeeAdjustInfos.order_trade_no锛涜鍗曞彿銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.is_delete IS '鏉ユ簮:data.taiFeeAdjustInfos.is_delete锛涢€昏緫鍒犻櫎鏍囪瘑銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.create_time IS '鏉ユ簮:data.taiFeeAdjustInfos.create_time锛涜褰曞垱寤烘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.table_fee_discount_records.payload IS '鍘熷JSON鏁存潯璁板綍锛屼繚鐣欏叾浠栧瓧娈点€?;

-- ========== 鍙拌垂娴佹按锛堝彴璐规祦姘?json -> data.siteTableUseDetailsList锛?==========
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 '鏉ユ簮锛氬彴璐规祦姘?json -> data.siteTableUseDetailsList锛涘彴妗屼娇鐢ㄨ璐规祦姘淬€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.id IS '鏉ユ簮:data.siteTableUseDetailsList.id锛涘彴璐规祦姘翠富閿€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.tenant_id IS '鏉ユ簮:data.siteTableUseDetailsList.tenant_id锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.site_id IS '鏉ユ簮:data.siteTableUseDetailsList.site_id锛涢棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.siteProfile IS '鏉ユ簮:data.siteTableUseDetailsList.siteProfile锛涢棬搴楀揩鐓с€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.site_table_id IS '鏉ユ簮:data.siteTableUseDetailsList.site_table_id锛涘彴妗孖D銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.site_table_area_id IS '鏉ユ簮:data.siteTableUseDetailsList.site_table_area_id锛涘彴妗屽尯鍩烮D銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.site_table_area_name IS '鏉ユ簮:data.siteTableUseDetailsList.site_table_area_name锛涘彴妗屽尯鍩熷悕绉般€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.tenant_table_area_id IS '鏉ユ簮:data.siteTableUseDetailsList.tenant_table_area_id锛涚鎴蜂晶鍙版鍖哄煙ID銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.order_trade_no IS '鏉ユ簮:data.siteTableUseDetailsList.order_trade_no锛涜鍗曞彿銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.order_pay_id IS '鏉ユ簮:data.siteTableUseDetailsList.order_pay_id锛涙敮浠樿褰旾D銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.order_settle_id IS '鏉ユ簮:data.siteTableUseDetailsList.order_settle_id锛涚粨绠楀崟ID銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.ledger_name IS '鏉ユ簮:data.siteTableUseDetailsList.ledger_name锛涜璐归」鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.ledger_amount IS '鏉ユ簮:data.siteTableUseDetailsList.ledger_amount锛涜璐归噾棰濄€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.ledger_count IS '鏉ユ簮:data.siteTableUseDetailsList.ledger_count锛涜璐规暟閲?鏃堕暱銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.ledger_unit_price IS '鏉ユ簮:data.siteTableUseDetailsList.ledger_unit_price锛涜璐瑰崟浠枫€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.ledger_status IS '鏉ユ簮:data.siteTableUseDetailsList.ledger_status锛涜璐圭姸鎬併€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.ledger_start_time IS '鏉ユ簮:data.siteTableUseDetailsList.ledger_start_time锛涜璐瑰紑濮嬫椂闂淬€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.ledger_end_time IS '鏉ユ簮:data.siteTableUseDetailsList.ledger_end_time锛涜璐圭粨鏉熸椂闂淬€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.start_use_time IS '鏉ユ簮:data.siteTableUseDetailsList.start_use_time锛涘紑濮嬩娇鐢ㄦ椂闂淬€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.last_use_time IS '鏉ユ簮:data.siteTableUseDetailsList.last_use_time锛涙渶鍚庝娇鐢ㄦ椂闂淬€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.real_table_use_seconds IS '鏉ユ簮:data.siteTableUseDetailsList.real_table_use_seconds锛涘疄闄呬娇鐢ㄧ銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.real_table_charge_money IS '鏉ユ簮:data.siteTableUseDetailsList.real_table_charge_money锛涘疄闄呭彴璐归噾棰濄€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.add_clock_seconds IS '鏉ユ簮:data.siteTableUseDetailsList.add_clock_seconds锛涘姞閽熺鏁般€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.adjust_amount IS '鏉ユ簮:data.siteTableUseDetailsList.adjust_amount锛涜皟鏁撮噾棰濄€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.coupon_promotion_amount IS '鏉ユ簮:data.siteTableUseDetailsList.coupon_promotion_amount锛涗紭鎯犲埜浼樻儬閲戦銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.member_discount_amount IS '鏉ユ簮:data.siteTableUseDetailsList.member_discount_amount锛涗細鍛樻姌鎵ｉ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.used_card_amount IS '鏉ユ簮:data.siteTableUseDetailsList.used_card_amount锛涘崱鎶垫墸閲戦銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.mgmt_fee IS '鏉ユ簮:data.siteTableUseDetailsList.mgmt_fee锛涚鐞嗚垂銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.service_money IS '鏉ユ簮:data.siteTableUseDetailsList.service_money锛涙湇鍔¤垂銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.fee_total IS '鏉ユ簮:data.siteTableUseDetailsList.fee_total锛涘悎璁″彴璐广€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.is_single_order IS '鏉ユ簮:data.siteTableUseDetailsList.is_single_order锛涙槸鍚﹀崟鐐硅鍗曘€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.is_delete IS '鏉ユ簮:data.siteTableUseDetailsList.is_delete锛涢€昏緫鍒犻櫎鏍囪瘑銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.member_id IS '鏉ユ簮:data.siteTableUseDetailsList.member_id锛涗細鍛業D锛堣嫢缁戝畾锛夈€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.operator_id IS '鏉ユ簮:data.siteTableUseDetailsList.operator_id锛涙搷浣滀汉ID銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.operator_name IS '鏉ユ簮:data.siteTableUseDetailsList.operator_name锛涙搷浣滀汉鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.salesman_name IS '鏉ユ簮:data.siteTableUseDetailsList.salesman_name锛涢攢鍞?鎺ュ緟濮撳悕銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.salesman_org_id IS '鏉ユ簮:data.siteTableUseDetailsList.salesman_org_id锛涢攢鍞粍缁嘔D銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.salesman_user_id IS '鏉ユ簮:data.siteTableUseDetailsList.salesman_user_id锛涢攢鍞敤鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.create_time IS '鏉ユ簮:data.siteTableUseDetailsList.create_time锛涜褰曞垱寤烘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.payload IS '鍘熷JSON鏁存潯璁板綍銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.table_fee_transactions.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;

-- ========== 搴撳瓨鍙樺寲璁板綍1锛堝簱瀛樺彉鍖栬褰?.json -> data.queryDeliveryRecordsList锛?==========
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 '鏉ユ簮锛氬簱瀛樺彉鍖栬褰?.json -> data.queryDeliveryRecordsList锛涘簱瀛樺彉鍔ㄦ祦姘达紙鍚富鍓崟浣嶏級銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.siteGoodsStockId IS '鏉ユ簮:data.queryDeliveryRecordsList.siteGoodsStockId锛涘簱瀛樺彉鍔ㄨ褰旾D銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.tenantId IS '鏉ユ簮:data.queryDeliveryRecordsList.tenantId锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.siteId IS '鏉ユ簮:data.queryDeliveryRecordsList.siteId锛涢棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.siteGoodsId IS '鏉ユ簮:data.queryDeliveryRecordsList.siteGoodsId锛涢棬搴楀晢鍝両D銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.goodsName IS '鏉ユ簮:data.queryDeliveryRecordsList.goodsName锛涘晢鍝佸悕绉般€?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.goodsCategoryId IS '鏉ユ簮:data.queryDeliveryRecordsList.goodsCategoryId锛涗竴绾у垎绫籌D銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.goodsSecondCategoryId IS '鏉ユ簮:data.queryDeliveryRecordsList.goodsSecondCategoryId锛涗簩绾у垎绫籌D銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.unit IS '鏉ユ簮:data.queryDeliveryRecordsList.unit锛涜閲忓崟浣嶃€?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.price IS '鏉ユ簮:data.queryDeliveryRecordsList.price锛涘崟浠枫€?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.stockType IS '鏉ユ簮:data.queryDeliveryRecordsList.stockType锛涘彉鍔ㄧ被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.changeNum IS '鏉ユ簮:data.queryDeliveryRecordsList.changeNum锛涗富鍗曚綅鍙樺姩鏁伴噺銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.startNum IS '鏉ユ簮:data.queryDeliveryRecordsList.startNum锛涘彉鍔ㄥ墠搴撳瓨锛堜富鍗曚綅锛夈€?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.endNum IS '鏉ユ簮:data.queryDeliveryRecordsList.endNum锛涘彉鍔ㄥ悗搴撳瓨锛堜富鍗曚綅锛夈€?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.changeNumA IS '鏉ユ簮:data.queryDeliveryRecordsList.changeNumA锛涘壇鍗曚綅鍙樺姩鏁伴噺銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.startNumA IS '鏉ユ簮:data.queryDeliveryRecordsList.startNumA锛涘彉鍔ㄥ墠搴撳瓨锛堝壇鍗曚綅锛夈€?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.endNumA IS '鏉ユ簮:data.queryDeliveryRecordsList.endNumA锛涘彉鍔ㄥ悗搴撳瓨锛堝壇鍗曚綅锛夈€?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.remark IS '鏉ユ簮:data.queryDeliveryRecordsList.remark锛涘娉ㄣ€?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.operatorName IS '鏉ユ簮:data.queryDeliveryRecordsList.operatorName锛涙搷浣滀汉銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.createTime IS '鏉ユ簮:data.queryDeliveryRecordsList.createTime锛涘彉鍔ㄦ椂闂淬€?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_movements.payload IS '鍘熷JSON鏁存潯璁板綍銆?;

-- ========== 搴撳瓨鍙樺寲璁板綍2锛堝簱瀛樺彉鍖栬褰?.json -> data.goodsCategoryList锛?==========
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 '鏉ユ簮锛氬簱瀛樺彉鍖栬褰?.json -> data.goodsCategoryList锛涢棬搴楀晢鍝佸垎绫伙紙鍚瓙绫籧ategoryBoxes锛夈€?;
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.id IS '鏉ユ簮:data.goodsCategoryList.id锛涘垎绫籌D銆?;
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.tenant_id IS '鏉ユ簮:data.goodsCategoryList.tenant_id锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.category_name IS '鏉ユ簮:data.goodsCategoryList.category_name锛涘垎绫诲悕绉般€?;
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.alias_name IS '鏉ユ簮:data.goodsCategoryList.alias_name锛涘埆鍚嶃€?;
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.pid IS '鏉ユ簮:data.goodsCategoryList.pid锛涚埗绾у垎绫籌D銆?;
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.business_name IS '鏉ユ簮:data.goodsCategoryList.business_name锛涗笟鍔＄嚎鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.tenant_goods_business_id IS '鏉ユ簮:data.goodsCategoryList.tenant_goods_business_id锛涗笟鍔＄嚎ID銆?;
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.open_salesman IS '鏉ユ簮:data.goodsCategoryList.open_salesman锛涢攢鍞紑鍏?鏉冮檺銆?;
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.categoryBoxes IS '鏉ユ簮:data.goodsCategoryList.categoryBoxes锛涘瓙鍒嗙被鍒楄〃JSON銆?;
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.sort IS '鏉ユ簮:data.goodsCategoryList.sort锛涙帓搴忓彿銆?;
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.is_warehousing IS '鏉ユ簮:data.goodsCategoryList.is_warehousing锛涙槸鍚﹀叆搴撶鐞嗐€?;
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.stock_goods_category_tree.payload IS '鍘熷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 '鏉ユ簮锛氬簱瀛樻眹鎬?json锛涢棬搴楀晢鍝佸湪缁熻鍖洪棿鍐呯殑搴撳瓨姹囨€汇€?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.siteGoodsId IS '鏉ユ簮:siteGoodsId锛涢棬搴楀晢鍝両D銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.goodsName IS '鏉ユ簮:goodsName锛涘晢鍝佸悕绉般€?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.goodsUnit IS '鏉ユ簮:goodsUnit锛涜閲忓崟浣嶃€?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.goodsCategoryId IS '鏉ユ簮:goodsCategoryId锛涗竴绾у垎绫籌D銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.goodsCategorySecondId IS '鏉ユ簮:goodsCategorySecondId锛涗簩绾у垎绫籌D銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.categoryName IS '鏉ユ簮:categoryName锛涘垎绫诲悕绉般€?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.rangeStartStock IS '鏉ユ簮:rangeStartStock锛涘尯闂存湡鍒濆簱瀛樸€?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.rangeEndStock IS '鏉ユ簮:rangeEndStock锛涘尯闂存湡鏈簱瀛樸€?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.rangeIn IS '鏉ユ簮:rangeIn锛涘尯闂村叆搴撴暟閲忋€?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.rangeOut IS '鏉ユ簮:rangeOut锛涘尯闂村嚭搴撴暟閲忋€?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.rangeSale IS '鏉ユ簮:rangeSale锛涘尯闂撮攢鍞暟閲忋€?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.rangeSaleMoney IS '鏉ユ簮:rangeSaleMoney锛涘尯闂撮攢鍞噾棰濄€?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.rangeInventory IS '鏉ユ簮:rangeInventory锛涚洏鐐瑰樊寮傛暟閲忋€?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.currentStock IS '鏉ユ簮:currentStock锛涘綋鍓嶅簱瀛樸€?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.goods_stock_summary.payload IS '鍘熷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 '鏉ユ簮锛氭敮浠樿褰?json锛涙敮浠樻祦姘达紝鍚嚎涓?绾夸笅娓犻亾銆?;
COMMENT ON COLUMN billiards_ods.payment_transactions.id IS '鏉ユ簮:id锛涙敮浠樿褰曚富閿€?;
COMMENT ON COLUMN billiards_ods.payment_transactions.site_id IS '鏉ユ簮:site_id锛涢棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.payment_transactions.siteProfile IS '鏉ユ簮:siteProfile锛涢棬搴椾俊鎭揩鐓с€?;
COMMENT ON COLUMN billiards_ods.payment_transactions.relate_type IS '鏉ユ簮:relate_type锛涘叧鑱斾笟鍔＄被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.payment_transactions.relate_id IS '鏉ユ簮:relate_id锛涘叧鑱斾笟鍔D銆?;
COMMENT ON COLUMN billiards_ods.payment_transactions.pay_amount IS '鏉ユ簮:pay_amount锛涙敮浠橀噾棰濄€?;
COMMENT ON COLUMN billiards_ods.payment_transactions.pay_status IS '鏉ユ簮:pay_status锛涙敮浠樼姸鎬併€?;
COMMENT ON COLUMN billiards_ods.payment_transactions.pay_time IS '鏉ユ簮:pay_time锛涙敮浠樻椂闂淬€?;
COMMENT ON COLUMN billiards_ods.payment_transactions.create_time IS '鏉ユ簮:create_time锛涘垱寤烘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.payment_transactions.payment_method IS '鏉ユ簮:payment_method锛涙敮浠樻柟寮忔灇涓俱€?;
COMMENT ON COLUMN billiards_ods.payment_transactions.online_pay_channel IS '鏉ユ簮:online_pay_channel锛涚嚎涓婃笭閬撲唬鐮併€?;
COMMENT ON COLUMN billiards_ods.payment_transactions.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.payment_transactions.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.payment_transactions.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.payment_transactions.payload IS '鍘熷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 '鏉ユ簮锛氶€€娆捐褰?json锛涢€€娆惧強鍐荤粨璧勯噾鏄庣粏銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.id IS '鏉ユ簮:id锛涢€€娆捐褰曚富閿€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.tenant_id IS '鏉ユ簮:tenant_id锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.tenantName IS '鏉ユ簮:tenantName锛涚鎴峰悕绉般€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.site_id IS '鏉ユ簮:site_id锛涢棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.siteProfile IS '鏉ユ簮:siteProfile锛涢棬搴楀揩鐓с€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.relate_type IS '鏉ユ簮:relate_type锛涘叧鑱斾笟鍔＄被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.relate_id IS '鏉ユ簮:relate_id锛涘叧鑱斾笟鍔D銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.pay_sn IS '鏉ユ簮:pay_sn锛涙敮浠樻祦姘村彿銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.pay_amount IS '鏉ユ簮:pay_amount锛涘師鏀粯閲戦銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.refund_amount IS '鏉ユ簮:refund_amount锛涢€€娆鹃噾棰濄€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.round_amount IS '鏉ユ簮:round_amount锛涙姽闆堕噾棰濄€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.pay_status IS '鏉ユ簮:pay_status锛涚姸鎬併€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.pay_time IS '鏉ユ簮:pay_time锛涙敮浠?閫€娆炬椂闂淬€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.create_time IS '鏉ユ簮:create_time锛涘垱寤烘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.payment_method IS '鏉ユ簮:payment_method锛涙敮浠樻柟寮忋€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.pay_terminal IS '鏉ユ簮:pay_terminal锛涙敮浠樼粓绔被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.pay_config_id IS '鏉ユ簮:pay_config_id锛涙敮浠橀厤缃甀D銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.online_pay_channel IS '鏉ユ簮:online_pay_channel锛涚嚎涓婃笭閬撱€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.online_pay_type IS '鏉ユ簮:online_pay_type锛涚嚎涓婃敮浠樼被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.channel_fee IS '鏉ユ簮:channel_fee锛涙笭閬撴墜缁垂銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.channel_payer_id IS '鏉ユ簮:channel_payer_id锛涙笭閬撲粯娆句汉鏍囪瘑銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.channel_pay_no IS '鏉ユ簮:channel_pay_no锛涙笭閬撴敮浠樺崟鍙枫€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.member_id IS '鏉ユ簮:member_id锛涗細鍛業D銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.member_card_id IS '鏉ユ簮:member_card_id锛涗細鍛樺崱ID銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.cashier_point_id IS '鏉ユ簮:cashier_point_id锛涙敹閾剁偣ID銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.operator_id IS '鏉ユ簮:operator_id锛涙搷浣滀汉ID銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.action_type IS '鏉ユ簮:action_type锛涘姩浣滅被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.check_status IS '鏉ユ簮:check_status锛涘鏍哥姸鎬併€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.is_revoke IS '鏉ユ簮:is_revoke锛涙槸鍚︽挙閿€銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.is_delete IS '鏉ユ簮:is_delete锛涢€昏緫鍒犻櫎鏍囪瘑銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.balance_frozen_amount IS '鏉ユ簮:balance_frozen_amount锛涗綑棰濆喕缁撻噾棰濄€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.card_frozen_amount IS '鏉ユ簮:card_frozen_amount锛涘崱鍐荤粨閲戦銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.refund_transactions.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.refund_transactions.payload IS '鍘熷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 '鏉ユ簮锛氬钩鍙伴獙鍒歌褰?json锛涚涓夋柟/骞冲彴鍒告牳閿€娴佹按銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.id IS '鏉ユ簮:id锛涙祦姘翠富閿€?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.verify_id IS '鏉ユ簮:verify_id锛涢獙鍒窱D銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.certificate_id IS '鏉ユ簮:certificate_id锛涘埜鍑瘉ID銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.coupon_code IS '鏉ユ簮:coupon_code锛涘埜鐮併€?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.coupon_name IS '鏉ユ簮:coupon_name锛涘埜鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.coupon_channel IS '鏉ユ簮:coupon_channel锛涘埜娓犻亾銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.groupon_type IS '鏉ユ簮:groupon_type锛涘洟璐被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.group_package_id IS '鏉ユ簮:group_package_id锛涘洟璐椁怚D銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.sale_price IS '鏉ユ簮:sale_price锛涘敭鍗栦环銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.coupon_money IS '鏉ユ簮:coupon_money锛涘埜闈㈤/鎶垫墸閲戦銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.coupon_free_time IS '鏉ユ簮:coupon_free_time锛涜禒閫佹椂闀?鍏嶈垂鏃堕暱銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.coupon_cover IS '鏉ユ簮:coupon_cover锛涘埜灏侀潰URL銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.coupon_remark IS '鏉ユ簮:coupon_remark锛涘埜澶囨敞銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.use_status IS '鏉ユ簮:use_status锛涙牳閿€鐘舵€併€?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.consume_time IS '鏉ユ簮:consume_time锛涙牳閿€鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.create_time IS '鏉ユ簮:create_time锛涘垱寤烘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.deal_id IS '鏉ユ簮:deal_id锛涗氦鏄揑D銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.channel_deal_id IS '鏉ユ簮:channel_deal_id锛涙笭閬撲氦鏄揑D銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.site_id IS '鏉ユ簮:site_id锛涢棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.site_order_id IS '鏉ユ簮:site_order_id锛涢棬搴楄鍗旾D銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.table_id IS '鏉ユ簮:table_id锛涘彴妗孖D銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.tenant_id IS '鏉ユ簮:tenant_id锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.operator_id IS '鏉ユ簮:operator_id锛涙搷浣滀汉ID銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.operator_name IS '鏉ユ簮:operator_name锛涙搷浣滀汉鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.is_delete IS '鏉ユ簮:is_delete锛涢€昏緫鍒犻櫎鏍囪瘑銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.siteProfile IS '鏉ユ簮:siteProfile锛涢棬搴楀揩鐓с€?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.platform_coupon_redemption_records.payload IS '鍘熷JSON鏁存潯璁板綍銆?;

-- ========== 鍟嗗搧妗ｆ锛堝晢鍝佹。妗?json -> data.tenantGoodsList锛?==========
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,
    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 '鏉ユ簮锛氬晢鍝佹。妗?json -> data.tenantGoodsList锛涚鎴峰晢鍝佷富鏁版嵁銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.id IS '鏉ユ簮:id锛涘晢鍝両D銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.tenant_id IS '鏉ユ簮:tenant_id锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.goods_name IS '鏉ユ簮:goods_name锛涘晢鍝佸悕绉般€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.goods_bar_code IS '鏉ユ簮:goods_bar_code锛涙潯鐮併€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.goods_category_id IS '鏉ユ簮:goods_category_id锛涗竴绾у垎绫籌D銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.goods_second_category_id IS '鏉ユ簮:goods_second_category_id锛涗簩绾у垎绫籌D銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.categoryName IS '鏉ユ簮:categoryName锛涘垎绫诲悕绉般€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.unit IS '鏉ユ簮:unit锛涜閲忓崟浣嶃€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.goods_number IS '鏉ユ簮:goods_number锛涘晢鍝佺紪鐮併€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.goods_state IS '鏉ユ簮:goods_state锛涘晢鍝佺姸鎬併€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.sale_channel IS '鏉ユ簮:sale_channel锛涢攢鍞笭閬撱€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.able_discount IS '鏉ユ簮:able_discount锛涙槸鍚﹀彲鎶樻墸銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.able_site_transfer IS '鏉ユ簮:able_site_transfer锛涙槸鍚﹀彲璺ㄥ簵銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.is_delete IS '鏉ユ簮:is_delete锛涢€昏緫鍒犻櫎鏍囪瘑銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.is_warehousing IS '鏉ユ簮:is_warehousing锛涙槸鍚︾撼鍏ュ簱瀛樼鐞嗐€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.isInSite IS '鏉ユ簮:isInSite锛涙槸鍚﹂棬搴楀晢鍝佹爣璇嗐€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.cost_price IS '鏉ユ簮:cost_price锛涙垚鏈环銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.cost_price_type IS '鏉ユ簮:cost_price_type锛涙垚鏈环绫诲瀷銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.market_price IS '鏉ユ簮:market_price锛涘競鍦轰环銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.min_discount_price IS '鏉ユ簮:min_discount_price锛涙渶浣庢姌鍚庝环銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.common_sale_royalty IS '鏉ユ簮:common_sale_royalty锛涙櫘閫氶攢鍞彁鎴愩€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.point_sale_royalty IS '鏉ユ簮:point_sale_royalty锛涚Н鍒嗛攢鍞彁鎴愩€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.pinyin_initial IS '鏉ユ簮:pinyin_initial锛涙嫾闊抽瀛楁瘝銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.commodityCode IS '鏉ユ簮:commodityCode锛涘晢鍝佺紪鐮侊紙瀛楁鍒悕锛夈€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.commodity_code IS '鏉ユ簮:commodity_code锛涘晢鍝佺紪鐮侊紙鍙︿竴瀛楁锛夈€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.goods_cover IS '鏉ユ簮:goods_cover锛涘晢鍝佸浘鐗囥€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.supplier_id IS '鏉ユ簮:supplier_id锛涗緵搴斿晢ID銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.remark_name IS '鏉ユ簮:remark_name锛涘娉ㄥ悕銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.create_time IS '鏉ユ簮:create_time锛涘垱寤烘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.update_time IS '鏉ユ簮:update_time锛涙洿鏂版椂闂淬€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.payload IS '鍘熷JSON鏁存潯璁板綍锛屼繚鐣欐湭灞曞紑瀛楁銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.tenant_goods_master.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;

-- ========== 鍥㈣喘濂楅锛堝洟璐椁?json -> data.packageCouponList锛?==========
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 '鏉ユ簮锛氬洟璐椁?json -> data.packageCouponList锛涘洟璐?濂楅瀹氫箟銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.id IS '鏉ユ簮:id锛涘椁愯褰曚富閿€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.package_id IS '鏉ユ簮:package_id锛涘椁怚D銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.package_name IS '鏉ユ簮:package_name锛涘椁愬悕绉般€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.selling_price IS '鏉ユ簮:selling_price锛涘敭鍗栦环銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.coupon_money IS '鏉ユ簮:coupon_money锛涘埜闈㈤/浠峰€笺€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.date_type IS '鏉ユ簮:date_type锛涙棩鏈熺被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.date_info IS '鏉ユ簮:date_info锛涙棩鏈熼檺鍒舵弿杩般€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.start_time IS '鏉ユ簮:start_time锛涙湁鏁堟湡寮€濮嬨€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.end_time IS '鏉ユ簮:end_time锛涙湁鏁堟湡缁撴潫銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.start_clock IS '鏉ユ簮:start_clock锛涙瘡鏃ュ彲鐢ㄥ紑濮嬫椂娈点€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.end_clock IS '鏉ユ簮:end_clock锛涙瘡鏃ュ彲鐢ㄧ粨鏉熸椂娈点€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.add_start_clock IS '鏉ユ簮:add_start_clock锛涢檮鍔犲紑濮嬫椂娈点€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.add_end_clock IS '鏉ユ簮:add_end_clock锛涢檮鍔犵粨鏉熸椂娈点€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.duration IS '鏉ユ簮:duration锛涘彲鐢ㄦ椂闀?鍒嗛挓銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.usable_count IS '鏉ユ簮:usable_count锛涘彲鐢ㄦ鏁般€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.usable_range IS '鏉ユ簮:usable_range锛涘彲鐢ㄨ寖鍥寸被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.table_area_id IS '鏉ユ簮:table_area_id锛涘彴妗屽尯鍩烮D銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.table_area_name IS '鏉ユ簮:table_area_name锛涘彴妗屽尯鍩熷悕绉般€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.table_area_id_list IS '鏉ユ簮:table_area_id_list锛涘彲鐢ㄥ彴妗屽尯鍩熷垪琛↗SON銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.tenant_table_area_id IS '鏉ユ簮:tenant_table_area_id锛涚鎴峰彴妗屽尯鍩烮D銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.tenant_table_area_id_list IS '鏉ユ簮:tenant_table_area_id_list锛涚鎴峰彴妗屽尯鍩熷垪琛↗SON銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.site_id IS '鏉ユ簮:site_id锛涢棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.site_name IS '鏉ユ簮:site_name锛涢棬搴楀悕绉般€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.tenant_id IS '鏉ユ簮:tenant_id锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.card_type_ids IS '鏉ユ簮:card_type_ids锛涘厑璁镐娇鐢ㄧ殑鍗＄被鍨婭D鍒楄〃JSON銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.group_type IS '鏉ユ簮:group_type锛涘洟璐被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.system_group_type IS '鏉ユ簮:system_group_type锛涚郴缁熷洟璐被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.type IS '鏉ユ簮:type锛涘椁愮被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.effective_status IS '鏉ユ簮:effective_status锛涚敓鏁堢姸鎬併€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.is_enabled IS '鏉ユ簮:is_enabled锛涘惎鐢ㄦ爣璇嗐€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.is_delete IS '鏉ユ簮:is_delete锛涢€昏緫鍒犻櫎鏍囪瘑銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.max_selectable_categories IS '鏉ユ簮:max_selectable_categories锛涘彲閫夊垎绫讳笂闄愩€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.area_tag_type IS '鏉ユ簮:area_tag_type锛涘尯鍩熸爣绛剧被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.creator_name IS '鏉ユ簮:creator_name锛涘垱寤轰汉鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.create_time IS '鏉ユ簮:create_time锛涘垱寤烘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages.payload IS '鍘熷JSON鏁存潯璁板綍銆?;

-- ========== 鍥㈣喘濂楅娴佹按锛堝洟璐椁愭祦姘?json -> data.siteTableUseDetailsList锛?==========
CREATE TABLE IF NOT EXISTS billiards_ods.group_buy_packages_ledger (
    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_packages_ledger IS '鏉ユ簮锛氬洟璐椁愭祦姘?json -> data.siteTableUseDetailsList锛涘洟璐埜浣跨敤/鏍搁攢娴佹按銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.id IS '鏉ユ簮:id锛涙祦姘翠富閿€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.tenant_id IS '鏉ユ簮:tenant_id锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.site_id IS '鏉ユ簮:site_id锛涢棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.siteName IS '鏉ユ簮:siteName锛涢棬搴楀悕绉般€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.table_id IS '鏉ユ簮:table_id锛涘彴妗孖D銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.tableName IS '鏉ユ簮:tableName锛涘彴妗屽悕绉般€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.tableAreaName IS '鏉ユ簮:tableAreaName锛涘彴妗屽尯鍩熷悕绉般€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.tenant_table_area_id IS '鏉ユ簮:tenant_table_area_id锛涚鎴峰彴妗屽尯鍩烮D銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.order_trade_no IS '鏉ユ簮:order_trade_no锛涜鍗曞彿銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.order_settle_id IS '鏉ユ簮:order_settle_id锛涚粨绠楀崟ID銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.order_pay_id IS '鏉ユ簮:order_pay_id锛涙敮浠樿褰旾D銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.order_coupon_id IS '鏉ユ簮:order_coupon_id锛涜鍗曞埜ID銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.order_coupon_channel IS '鏉ユ簮:order_coupon_channel锛涘埜娓犻亾銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.coupon_code IS '鏉ユ簮:coupon_code锛涘埜鐮併€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.coupon_money IS '鏉ユ簮:coupon_money锛涘埜閲戦銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.coupon_origin_id IS '鏉ユ簮:coupon_origin_id锛涘埜鏉ユ簮ID銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.ledger_name IS '鏉ユ簮:ledger_name锛涜璐归」鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.ledger_group_name IS '鏉ユ簮:ledger_group_name锛涜璐瑰垎缁勩€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.ledger_amount IS '鏉ユ簮:ledger_amount锛涢噾棰濄€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.ledger_count IS '鏉ユ簮:ledger_count锛涙暟閲?鏃堕暱銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.ledger_unit_price IS '鏉ユ簮:ledger_unit_price锛涘崟浠枫€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.ledger_status IS '鏉ユ簮:ledger_status锛涚姸鎬併€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.table_charge_seconds IS '鏉ユ簮:table_charge_seconds锛涘彴璐硅璐圭鏁般€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.promotion_activity_id IS '鏉ユ簮:promotion_activity_id锛涗績閿€娲诲姩ID銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.promotion_coupon_id IS '鏉ユ簮:promotion_coupon_id锛涗績閿€鍒窱D銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.promotion_seconds IS '鏉ユ簮:promotion_seconds锛涗績閿€璧犻€佹椂闀裤€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.offer_type IS '鏉ユ簮:offer_type锛涗紭鎯犵被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.assistant_promotion_money IS '鏉ユ簮:assistant_promotion_money锛涘姪鏁欎紭鎯犻噾棰濄€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.assistant_service_promotion_money IS '鏉ユ簮:assistant_service_promotion_money锛涘姪鏁欐湇鍔′紭鎯犻噾棰濄€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.table_service_promotion_money IS '鏉ユ簮:table_service_promotion_money锛涘彴璐逛紭鎯犻噾棰濄€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.goods_promotion_money IS '鏉ユ簮:goods_promotion_money锛涘晢鍝佷紭鎯犻噾棰濄€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.recharge_promotion_money IS '鏉ユ簮:recharge_promotion_money锛涘厖鍊间紭鎯犻噾棰濄€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.reward_promotion_money IS '鏉ユ簮:reward_promotion_money锛涘鍔变紭鎯犻噾棰濄€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.goodsOptionPrice IS '鏉ユ簮:goodsOptionPrice锛涘晢鍝佽鏍间环銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.salesman_name IS '鏉ユ簮:salesman_name锛涢攢鍞鍚嶃€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.sales_man_org_id IS '鏉ユ簮:sales_man_org_id锛涢攢鍞粍缁嘔D銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.salesman_role_id IS '鏉ユ簮:salesman_role_id锛涢攢鍞鑹睮D銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.salesman_user_id IS '鏉ユ簮:salesman_user_id锛涢攢鍞敤鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.operator_id IS '鏉ユ簮:operator_id锛涙搷浣滀汉ID銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.operator_name IS '鏉ユ簮:operator_name锛涙搷浣滀汉鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.is_single_order IS '鏉ユ簮:is_single_order锛涙槸鍚﹀崟鐐硅鍗曘€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.is_delete IS '鏉ユ簮:is_delete锛涢€昏緫鍒犻櫎鏍囪瘑銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.create_time IS '鏉ユ簮:create_time锛涘垱寤烘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.payload IS '鍘熷JSON鏁存潯璁板綍銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.group_buy_packages_ledger.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;

-- ========== 灏忕エ璇︽儏锛堝皬绁ㄨ鎯?json -> data.data锛?==========
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 '鏉ユ簮锛氬皬绁ㄨ鎯?json -> data.data锛涘皬绁?缁撶畻璇﹀崟锛屾槑缁嗕笌浼氬憳蹇収瀛楯SON銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.orderSettleId IS '鏉ユ簮:orderSettleId锛涚粨绠楀崟ID銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.actualPayment IS '鏉ユ簮:actualPayment锛涘疄鏀堕噾棰濄€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.adjustAmount IS '鏉ユ簮:adjustAmount锛涙姽闆?璋冩暣閲戦銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.assistantManualDiscount IS '鏉ユ簮:assistantManualDiscount锛涘姪鏁欎汉宸ヤ紭鎯犮€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.balanceAmount IS '鏉ユ簮:balanceAmount锛涗綑棰濇敮浠橀噾棰濄€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.cashierName IS '鏉ユ簮:cashierName锛涙敹閾跺憳銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.consumeMoney IS '鏉ユ簮:consumeMoney锛涙秷璐归噾棰濄€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.couponAmount IS '鏉ユ簮:couponAmount锛涘埜鎶垫墸閲戦銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.deliveryAddress IS '鏉ユ簮:deliveryAddress锛涢厤閫佸湴鍧€銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.deliveryFee IS '鏉ユ簮:deliveryFee锛涢厤閫佽垂銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.ledgerAmount IS '鏉ユ簮:ledgerAmount锛涜处鍗曢噾棰濇眹鎬汇€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.memberDeductAmount IS '鏉ユ簮:memberDeductAmount锛涗細鍛樻姷鎵ｉ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.memberOfferAmount IS '鏉ユ簮:memberOfferAmount锛涗細鍛樹紭鎯犻噾棰濄€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.onlineReturnAmount IS '鏉ユ簮:onlineReturnAmount锛涚嚎涓婇€€杩橀噾棰濄€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.orderRemark IS '鏉ユ簮:orderRemark锛涜鍗曞娉ㄣ€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.orderSettleNumber IS '鏉ユ簮:orderSettleNumber锛涚粨绠楀崟鍙枫€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.payMemberBalance IS '鏉ユ簮:payMemberBalance锛涗細鍛樹綑棰濇敮浠橀噾棰濄€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.payTime IS '鏉ユ簮:payTime锛涙敮浠樻椂闂淬€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.paymentMethod IS '鏉ユ簮:paymentMethod锛涙敮浠樻柟寮忋€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.pointDiscountCost IS '鏉ユ簮:pointDiscountCost锛涚Н鍒嗘姷鎵ｆ垚鏈€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.pointDiscountPrice IS '鏉ユ簮:pointDiscountPrice锛涚Н鍒嗘姷鎵ｉ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.prepayMoney IS '鏉ユ簮:prepayMoney锛涢浠橀噾棰濄€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.refundAmount IS '鏉ユ簮:refundAmount锛涢€€娆鹃噾棰濄€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.returnGoodsAmount IS '鏉ユ簮:returnGoodsAmount锛涢€€璐ч噾棰濄€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.rewardName IS '鏉ユ簮:rewardName锛涘鍔辫鏄庛€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.settleType IS '鏉ユ簮:settleType锛涚粨绠楃被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.siteAddress IS '鏉ユ簮:siteAddress锛涢棬搴楀湴鍧€銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.siteBusinessTel IS '鏉ユ簮:siteBusinessTel锛涢棬搴楃數璇濄€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.siteId IS '鏉ユ簮:siteId锛涢棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.siteName IS '鏉ユ簮:siteName锛涢棬搴楀悕绉般€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.tenantId IS '鏉ユ簮:tenantId锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.tenantName IS '鏉ユ簮:tenantName锛涚鎴峰悕绉般€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.ticketCustomContent IS '鏉ユ簮:ticketCustomContent锛涜嚜瀹氫箟绁ㄩ潰鍐呭銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.ticketRemark IS '鏉ユ簮:ticketRemark锛涘皬绁ㄥ娉ㄣ€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.voucherMoney IS '鏉ユ簮:voucherMoney锛涗唬閲戝埜閲戦銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.memberProfile IS '鏉ユ簮:memberProfile锛涗細鍛樺揩鐓SON銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.orderItem IS '鏉ユ簮:orderItem锛涘晢鍝?鍙版/鍒稿垎椤规槑缁咼SON銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.tenantMemberCardLogs IS '鏉ユ簮:tenantMemberCardLogs锛涘叧鑱斾綑棰濆彉鏇存祦姘碕SON銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.payload IS '鍘熷JSON鏁存潯璁板綍銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.settlement_ticket_details.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;

-- ========== 闂ㄥ簵鍟嗗搧妗ｆ锛堥棬搴楀晢鍝佹。妗?.json -> data.orderGoodsList锛?==========
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),
    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,
    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 '鏉ユ簮锛氶棬搴楀晢鍝佹。妗?.json -> data.orderGoodsList锛涢棬搴楀眰鍟嗗搧妗ｆ锛屽叧閿簱瀛?浠锋牸瀛楁灞曞紑銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.id IS '鏉ユ簮:id锛涢棬搴楀晢鍝佽褰旾D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.tenant_id IS '鏉ユ簮:tenant_id锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.site_id IS '鏉ユ簮:site_id锛涢棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.siteName IS '鏉ユ簮:siteName锛涢棬搴楀悕绉般€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.tenant_goods_id IS '鏉ユ簮:tenant_goods_id锛涚鎴峰晢鍝両D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.goods_name IS '鏉ユ簮:goods_name锛涘晢鍝佸悕绉般€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.goods_bar_code IS '鏉ユ簮:goods_bar_code锛涙潯鐮併€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.goods_category_id IS '鏉ユ簮:goods_category_id锛涗竴绾у垎绫籌D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.goods_second_category_id IS '鏉ユ簮:goods_second_category_id锛涗簩绾у垎绫籌D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.oneCategoryName IS '鏉ユ簮:oneCategoryName锛涗竴绾у垎绫诲悕绉般€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.twoCategoryName IS '鏉ユ簮:twoCategoryName锛涗簩绾у垎绫诲悕绉般€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.unit IS '鏉ユ簮:unit锛涜閲忓崟浣嶃€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.sale_price IS '鏉ユ簮:sale_price锛涢攢鍞环銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.cost_price IS '鏉ユ簮:cost_price锛涙垚鏈环銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.cost_price_type IS '鏉ユ簮:cost_price_type锛涙垚鏈环绫诲瀷銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.min_discount_price IS '鏉ユ簮:min_discount_price锛涙渶浣庢姌鎵ｄ环銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.safe_stock IS '鏉ユ簮:safe_stock锛涘畨鍏ㄥ簱瀛樸€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.stock IS '鏉ユ簮:stock锛涘綋鍓嶅簱瀛樸€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.stock_A IS '鏉ユ簮:stock_A锛涜緟鍗曚綅搴撳瓨銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.sale_num IS '鏉ユ簮:sale_num锛涚疮璁￠攢閲忋€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.total_purchase_cost IS '鏉ユ簮:total_purchase_cost锛涚疮璁￠噰璐垚鏈€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.total_sales IS '鏉ユ簮:total_sales锛涚疮璁￠攢鍞銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.average_monthly_sales IS '鏉ユ簮:average_monthly_sales锛涙湀鍧囬攢閲忋€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.enable_status IS '鏉ユ簮:enable_status锛涘惎鐢ㄧ姸鎬併€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.audit_status IS '鏉ユ簮:audit_status锛涘鏍哥姸鎬併€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.goods_state IS '鏉ユ簮:goods_state锛涘晢鍝佺姸鎬併€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.is_delete IS '鏉ユ簮:is_delete锛涢€昏緫鍒犻櫎銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.is_warehousing IS '鏉ユ簮:is_warehousing锛涙槸鍚︾撼鍏ュ簱瀛樸€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.able_discount IS '鏉ユ簮:able_discount锛涘彲鍚︽姌鎵ｃ€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.able_site_transfer IS '鏉ユ簮:able_site_transfer锛涘彲鍚﹁法搴楄皟鎷ㄣ€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.forbid_sell_status IS '鏉ユ簮:forbid_sell_status锛涚鍞姸鎬併€?;
COMMENT ON COLUMN billiards_ods.store_goods_master."freeze" IS '鏉ユ簮:freeze锛涘喕缁撴爣璁般€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.send_state IS '鏉ユ簮:send_state锛涢厤閫佺姸鎬併€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.custom_label_type IS '鏉ユ簮:custom_label_type锛涜嚜瀹氫箟鏍囩绫诲瀷銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.option_required IS '鏉ユ簮:option_required锛涜鏍煎繀閫夋爣璇嗐€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.sale_channel IS '鏉ユ簮:sale_channel锛涢攢鍞笭閬撱€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.remark IS '鏉ユ簮:remark锛涘娉ㄣ€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.pinyin_initial IS '鏉ユ簮:pinyin_initial锛涙嫾闊抽瀛楁瘝銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.goods_cover IS '鏉ユ簮:goods_cover锛涘晢鍝佸浘鐗囥€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.create_time IS '鏉ユ簮:create_time锛涘垱寤烘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.update_time IS '鏉ユ簮:update_time锛涙洿鏂版椂闂淬€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.payload IS '鍘熷JSON鏁存潯璁板綍銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.store_goods_master.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.store_goods_master.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;

-- ========== 闂ㄥ簵鍟嗗搧閿€鍞褰曪紙闂ㄥ簵鍟嗗搧閿€鍞褰?json -> data.orderGoodsLedgers锛?==========
CREATE TABLE IF NOT EXISTS billiards_ods.store_goods_sales_records (
    id                         BIGINT PRIMARY KEY,
    tenant_id                  BIGINT,
    site_id                    BIGINT,
    site_goods_id              BIGINT,
    tenant_goods_id            BIGINT,
    order_settle_id            BIGINT,
    order_trade_no             TEXT,
    order_goods_id             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),
    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,
    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 '鏉ユ簮锛氶棬搴楀晢鍝侀攢鍞褰?json -> data.orderGoodsLedgers锛涘晢鍝侀攢鍞槑缁嗐€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.id IS '鏉ユ簮:id锛涢攢鍞槑缁咺D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.tenant_id IS '鏉ユ簮:tenant_id锛涚鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.site_id IS '鏉ユ簮:site_id锛涢棬搴桰D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.site_goods_id IS '鏉ユ簮:site_goods_id锛涢棬搴楀晢鍝両D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.tenant_goods_id IS '鏉ユ簮:tenant_goods_id锛涚鎴峰晢鍝両D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.order_settle_id IS '鏉ユ簮:order_settle_id锛涚粨绠楀崟ID銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.order_trade_no IS '鏉ユ簮:order_trade_no锛涜鍗曞彿銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.order_goods_id IS '鏉ユ簮:order_goods_id锛涜鍗曞晢鍝両D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.order_pay_id IS '鏉ユ簮:order_pay_id锛涙敮浠樿褰旾D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.order_coupon_id IS '鏉ユ簮:order_coupon_id锛涜鍗曞埜ID銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.ledger_name IS '鏉ユ簮:ledger_name锛涜璐归」鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.ledger_group_name IS '鏉ユ簮:ledger_group_name锛涜璐瑰垎缁勩€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.ledger_amount IS '鏉ユ簮:ledger_amount锛涢噾棰濄€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.ledger_count IS '鏉ユ簮:ledger_count锛涙暟閲忋€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.ledger_unit_price IS '鏉ユ簮:ledger_unit_price锛涘崟浠枫€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.ledger_status IS '鏉ユ簮:ledger_status锛涚姸鎬併€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.discount_money IS '鏉ユ簮:discount_money锛涙姌鎵ｉ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.coupon_deduct_money IS '鏉ユ簮:coupon_deduct_money锛涘埜鎶垫墸閲戦銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.member_discount_amount IS '鏉ユ簮:member_discount_amount锛涗細鍛樹紭鎯犻噾棰濄€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.option_coupon_deduct_money IS '鏉ユ簮:option_coupon_deduct_money锛涜鏍煎眰绾у埜鎶垫墸銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.option_member_discount_money IS '鏉ユ簮:option_member_discount_money锛涜鏍煎眰绾т細鍛樹紭鎯犮€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.point_discount_money IS '鏉ユ簮:point_discount_money锛涚Н鍒嗘姷鎵ｉ噾棰濄€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.point_discount_money_cost IS '鏉ユ簮:point_discount_money_cost锛涚Н鍒嗘姷鎵ｆ垚鏈€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.real_goods_money IS '鏉ユ簮:real_goods_money锛涘疄浠樺晢鍝侀噾棰濄€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.cost_money IS '鏉ユ簮:cost_money锛涙垚鏈噾棰濄€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.push_money IS '鏉ユ簮:push_money锛涙彁鎴愰噾棰濄€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.sales_type IS '鏉ユ簮:sales_type锛涢攢鍞被鍨嬨€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.is_single_order IS '鏉ユ簮:is_single_order锛涙槸鍚﹀崟鐐硅鍗曘€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.is_delete IS '鏉ユ簮:is_delete锛涢€昏緫鍒犻櫎銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.goods_remark IS '鏉ユ簮:goods_remark锛涘晢鍝佸娉ㄣ€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.option_price IS '鏉ユ簮:option_price锛涜鏍煎姞浠枫€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.option_value_name IS '鏉ユ簮:option_value_name锛涜鏍煎€煎悕绉般€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.option_name IS '鏉ユ簮:option_name锛涜鏍煎悕绉般€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.member_coupon_id IS '鏉ユ簮:member_coupon_id锛涗細鍛樺埜ID銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.package_coupon_id IS '鏉ユ簮:package_coupon_id锛涘椁愬埜ID銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.sales_man_org_id IS '鏉ユ簮:sales_man_org_id锛涢攢鍞粍缁嘔D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.salesman_name IS '鏉ユ簮:salesman_name锛涢攢鍞鍚嶃€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.salesman_role_id IS '鏉ユ簮:salesman_role_id锛涢攢鍞鑹睮D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.salesman_user_id IS '鏉ユ簮:salesman_user_id锛涢攢鍞敤鎴稩D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.operator_id IS '鏉ユ簮:operator_id锛涙搷浣滀汉ID銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.operator_name IS '鏉ユ簮:operator_name锛涙搷浣滀汉鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.openSalesman IS '鏉ユ簮:openSalesman锛涘紑鍗曞憳鍚嶇О銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.site_table_id IS '鏉ユ簮:site_table_id锛涘彴妗孖D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.tenant_goods_business_id IS '鏉ユ簮:tenant_goods_business_id锛涗笟鍔＄嚎ID銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.tenant_goods_category_id IS '鏉ユ簮:tenant_goods_category_id锛涚鎴峰垎绫籌D銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.create_time IS '鏉ユ簮:create_time锛涘垱寤烘椂闂淬€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.payload IS '鍘熷JSON鏁存潯璁板綍銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.source_file IS '閲囬泦鍏冩暟鎹細婧愭枃浠惰矾寰勩€?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.source_endpoint IS '閲囬泦鍏冩暟鎹細鏉ユ簮鎺ュ彛/绔偣銆?;
COMMENT ON COLUMN billiards_ods.store_goods_sales_records.fetched_at IS '閲囬泦鍏冩暟鎹細鍏ユ箹鏃堕棿銆?;

