-- Clerk payee QR profile and withdrawal snapshot

CREATE TABLE IF NOT EXISTS `play_clerk_payee_profile` (
  `id` varchar(32) NOT NULL COMMENT 'UUID',
  `tenant_id` varchar(32) NOT NULL COMMENT '租户ID',
  `clerk_id` varchar(32) NOT NULL COMMENT '店员ID',
  `channel` varchar(32) NOT NULL DEFAULT 'ALIPAY_QR' COMMENT '收款渠道（例如：ALIPAY_QR）',
  `qr_code_url` varchar(512) NOT NULL COMMENT '收款二维码地址',
  `display_name` varchar(64) DEFAULT NULL COMMENT '收款码显示名称',
  `last_confirmed_at` datetime DEFAULT NULL COMMENT '最近确认时间',
  `created_by` varchar(32) DEFAULT NULL,
  `created_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `updated_by` varchar(32) DEFAULT NULL,
  `updated_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT '逻辑删除 1已删除 0未删除',
  `version` int NOT NULL DEFAULT '1' COMMENT '数据版本',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `uk_clerk_payee` (`tenant_id`, `clerk_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ROW_FORMAT=DYNAMIC COMMENT='店员提现收款码档案';

ALTER TABLE `play_withdrawal_request`
  ADD COLUMN `payee_snapshot` text COMMENT '提现时的收款码快照（JSON）';
