-- 支付订单表
CREATE TABLE IF NOT EXISTS payment_order (
    id BIGSERIAL PRIMARY KEY,
    order_no VARCHAR(64) NOT NULL UNIQUE,
    member_id BIGINT,
    order_type VARCHAR(32),
    goods_desc VARCHAR(256),
    trans_amt DECIMAL(12, 2),
    trade_type VARCHAR(32),
    pay_status VARCHAR(16) DEFAULT 'PENDING',
    huifu_id VARCHAR(64),
    req_seq_id VARCHAR(64),
    req_date VARCHAR(16),
    hf_seq_id VARCHAR(64),
    pay_info TEXT,
    qr_code TEXT,
    pay_url TEXT,
    remark VARCHAR(512),
    notify_url VARCHAR(512),
    pay_time TIMESTAMP,
    expire_time TIMESTAMP,
    error_code VARCHAR(64),
    error_msg VARCHAR(512),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    deleted_at TIMESTAMP
);

CREATE INDEX IF NOT EXISTS idx_payment_order_order_no ON payment_order(order_no);
CREATE INDEX IF NOT EXISTS idx_payment_order_member_id ON payment_order(member_id);
CREATE INDEX IF NOT EXISTS idx_payment_order_req_seq_id ON payment_order(req_seq_id);
CREATE INDEX IF NOT EXISTS idx_payment_order_status ON payment_order(pay_status);
CREATE INDEX IF NOT EXISTS idx_payment_order_expire_time ON payment_order(expire_time);
