CREATE TABLE `transaction` (
   `id` BIGINT(20) AUTO_INCREMENT NOT NULL COMMENT '交易流水號',
   `tx_id` VARCHAR(200) NOT NULL COMMENT '交易 ID',
   `order_id` VARCHAR(200) NOT NULL COMMENT '訂單 ID',
   `brand` VARCHAR(50) NOT NULL COMMENT '品牌名稱',
   `uid` VARCHAR(50) NOT NULL COMMENT '發起 UID',
   `to_uid` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '接收方UID',
   `type` TINYINT NOT NULL COMMENT '交易類型: 1=提現, 2=充值',
   `business_type` TINYINT NOT NULL COMMENT '業務類型',
   `currency` VARCHAR(20) NOT NULL COMMENT '幣種',
   `amount` DECIMAL(30, 18) UNSIGNED DEFAULT 0 NOT NULL COMMENT '交易金額',
   `balance` DECIMAL(30, 18) UNSIGNED DEFAULT 0 NOT NULL COMMENT '交易後餘額',
   `before_balance` DECIMAL(30, 18) UNSIGNED DEFAULT 0 NOT NULL COMMENT '交易前餘額',
   `status` TINYINT NOT NULL DEFAULT 0 COMMENT '結算狀態',
   `create_time` BIGINT NOT NULL COMMENT '創建時間（Unix 時間戳，毫秒）',
   PRIMARY KEY (`id`),
   UNIQUE INDEX `uk_order_id_type` (`order_id`, `type`),
   INDEX `idx_uid` (`uid`),
   INDEX `idx_order_id` (`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用戶錢包交異動紀錄';