-- Withdrawal logs to track lifecycle and audit
CREATE TABLE IF NOT EXISTS `play_withdrawal_log` (
  `id` varchar(32) NOT NULL COMMENT 'UUID',
  `tenant_id` varchar(32) NOT NULL COMMENT '租户ID',
  `withdrawal_id` varchar(32) NOT NULL COMMENT '提现请求ID',
  `clerk_id` varchar(32) NOT NULL COMMENT '店员ID',
  `event_type` varchar(64) NOT NULL COMMENT '事件类型，如 CREATED/RESERVED/PAYOUT_REQUESTED/PAYOUT_SUCCESS/PAYOUT_FAILED',
  `status_from` varchar(16) DEFAULT NULL COMMENT '原状态',
  `status_to` varchar(16) DEFAULT NULL COMMENT '新状态',
  `message` varchar(512) DEFAULT NULL COMMENT '简要信息',
  `payload` text COMMENT '详细负载（JSON）',
  `created_by` varchar(32) DEFAULT NULL,
  `created_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '逻辑删除',
  `version` int NOT NULL DEFAULT '1' COMMENT '数据版本',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_withdrawal_log_wid` (`withdrawal_id`) USING BTREE,
  KEY `key_tenant_id` (`tenant_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='提现流水日志';

