CREATE TABLE IF NOT EXISTS mci_conversation_create_task (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    tenant_code VARCHAR(64) NOT NULL COMMENT '所属租户',
    task_type TINYINT NOT NULL DEFAULT 1 COMMENT '任务类型：1创建群聊 2邀请成员',
    channel_type VARCHAR(32) NOT NULL COMMENT '渠道：wecom / wechat_personal / dingtalk / feishu',
    account_id BIGINT COMMENT '使用哪个账号创建',
    conversation_id BIGINT COMMENT '创建成功后回填的会话 ID',
    participant_ids JSON COMMENT '参与者人员 ID 列表',
    task_status TINYINT NOT NULL DEFAULT 0 COMMENT '任务状态：0待执行 1执行中 2成功 3失败',
    channel_result JSON COMMENT '渠道返回结果',
    retry_count INT NOT NULL DEFAULT 0 COMMENT '重试次数',
    finish_time DATETIME COMMENT '完成时间',
    create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    deleted TINYINT NOT NULL DEFAULT 0,
    KEY idx_tenant_status (tenant_code, task_status),
    KEY idx_conversation_id (conversation_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='建群任务表';
