// 管理后台操作类型定义

export type AdminOperationType =
  // 产品管理
  | 'product.query'
  | 'product.create'
  | 'product.update'
  | 'product.delete'
  | 'product.updateStock'
  | 'product.updatePrice'
  | 'product.toggleStatus'
  
  // 订单管理
  | 'order.query'
  | 'order.update'
  | 'order.updateStatus'
  | 'order.addTracking'
  | 'order.cancel'
  | 'order.refund'
  
  // 用户管理
  | 'user.query'
  | 'user.update'
  | 'user.updateRole'
  | 'user.block'
  | 'user.unblock'
  
  // 售后管理
  | 'afterSales.query'
  | 'afterSales.update'
  | 'afterSales.approve'
  | 'afterSales.reject'
  | 'afterSales.addNotes'
  
  // 分类管理
  | 'category.query'
  | 'category.create'
  | 'category.update'
  | 'category.delete'
  
  // 品牌管理
  | 'brand.query'
  | 'brand.queryWithProducts'
  | 'brand.create'
  | 'brand.update'
  | 'brand.delete'
  
  // 横幅管理
  | 'banner.query'
  | 'banner.create'
  | 'banner.update'
  | 'banner.delete'
  
  // 优惠券管理
  | 'coupon.query'
  | 'coupon.create'
  | 'coupon.update'
  | 'coupon.delete'
  
  // 营销活动管理
  | 'campaign.query'
  | 'campaign.create'
  | 'campaign.update'
  | 'campaign.delete'
  | 'campaign.approve'
  | 'campaign.reject'
  | 'campaign.pause'
  | 'campaign.resume'
  
  // 秒杀/限时折扣管理
  | 'flashSale.query'
  | 'flashSale.create'
  | 'flashSale.update'
  | 'flashSale.delete'
  | 'flashSale.start'
  | 'flashSale.stop'
  
  // 支付有礼管理
  | 'paymentGift.query'
  | 'paymentGift.create'
  | 'paymentGift.update'
  | 'paymentGift.delete'
  | 'paymentGift.toggleStatus'
  
  // 团购活动管理
  | 'groupBuy.query'
  | 'groupBuy.create'
  | 'groupBuy.update'
  | 'groupBuy.delete'
  | 'groupBuy.queryOrders'
  | 'groupBuy.cancelOrder'
  
  // 会员储值管理
  | 'recharge.queryPlans'
  | 'recharge.createPlan'
  | 'recharge.updatePlan'
  | 'recharge.deletePlan'
  | 'recharge.queryBalances'
  | 'recharge.queryTransactions'
  | 'recharge.adjustBalance'
  
  // 数据分析
  | 'analytics.sales'
  | 'analytics.products'
  | 'analytics.users'
  | 'analytics.orders'
  | 'analytics.campaigns'
  | 'analytics.marketing'
  
  // Agent配置管理
  | 'agent.query'
  | 'agent.update'
  | 'agent.setAutoExecute'
  | 'agent.setMaxAmount'
  | 'agent.setGoals'
  | 'agent.setNotifications'
  | 'agent.setApprovalTypes'
  
  // 目标管理
  | 'goal.query'
  | 'goal.create'
  | 'goal.update'
  | 'goal.updateProgress'
  | 'goal.delete';

export interface AdminOperation {
  type: AdminOperationType;
  name: string;
  description: string;
  category: string;
  params: {
    name: string;
    type: string;
    required: boolean;
    description: string;
  }[];
  examples: {
    description: string;
    params: Record<string, any>;
  }[];
  permissions: string[];
}

export interface AdminOperationRequest {
  operation: AdminOperationType;
  params: Record<string, any>;
}

export interface AdminOperationResponse {
  success: boolean;
  data?: any;
  error?: string;
  message?: string;
}

// 完整的管理功能配置表
export const ADMIN_OPERATIONS: Record<AdminOperationType, AdminOperation> = {
  // 产品管理
  'product.query': {
    type: 'product.query',
    name: '查询产品',
    description: '根据条件查询产品列表',
    category: '产品管理',
    params: [
      { name: 'keyword', type: 'string', required: false, description: '搜索关键词' },
      { name: 'category', type: 'string', required: false, description: '产品分类' },
      { name: 'brand', type: 'string', required: false, description: '产品品牌' },
      { name: 'minPrice', type: 'number', required: false, description: '最低价格' },
      { name: 'maxPrice', type: 'number', required: false, description: '最高价格' },
      { name: 'isActive', type: 'boolean', required: false, description: '是否上架' }
    ],
    examples: [
      { description: '查询所有手机', params: { category: '手机' } },
      { description: '查询价格在2000-5000的产品', params: { minPrice: 2000, maxPrice: 5000 } }
    ],
    permissions: ['admin']
  },
  'product.create': {
    type: 'product.create',
    name: '创建产品',
    description: '创建新产品',
    category: '产品管理',
    params: [
      { name: 'name', type: 'string', required: true, description: '产品名称' },
      { name: 'price', type: 'number', required: true, description: '产品价格' },
      { name: 'description', type: 'string', required: false, description: '产品描述' },
      { name: 'category', type: 'string', required: false, description: '产品分类' },
      { name: 'brand', type: 'string', required: false, description: '产品品牌' },
      { name: 'stock_quantity', type: 'number', required: false, description: '库存数量' }
    ],
    examples: [
      { description: '创建iPhone产品', params: { name: 'iPhone 15 Pro', price: 7999, category: '手机', brand: 'Apple', stock_quantity: 100 } }
    ],
    permissions: ['admin']
  },
  'product.update': {
    type: 'product.update',
    name: '更新产品',
    description: '更新产品信息',
    category: '产品管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '产品ID' },
      { name: 'name', type: 'string', required: false, description: '产品名称' },
      { name: 'price', type: 'number', required: false, description: '产品价格' },
      { name: 'description', type: 'string', required: false, description: '产品描述' },
      { name: 'stock_quantity', type: 'number', required: false, description: '库存数量' }
    ],
    examples: [
      { description: '更新产品价格', params: { id: 'xxx-xxx', price: 6999 } }
    ],
    permissions: ['admin']
  },
  'product.delete': {
    type: 'product.delete',
    name: '删除产品',
    description: '删除产品',
    category: '产品管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '产品ID' }
    ],
    examples: [
      { description: '删除产品', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },
  'product.updateStock': {
    type: 'product.updateStock',
    name: '更新库存',
    description: '更新产品库存数量',
    category: '产品管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '产品ID' },
      { name: 'stock_quantity', type: 'number', required: true, description: '库存数量' }
    ],
    examples: [
      { description: '设置库存为50', params: { id: 'xxx-xxx', stock_quantity: 50 } }
    ],
    permissions: ['admin']
  },
  'product.updatePrice': {
    type: 'product.updatePrice',
    name: '更新价格',
    description: '更新产品价格',
    category: '产品管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '产品ID' },
      { name: 'price', type: 'number', required: true, description: '新价格' }
    ],
    examples: [
      { description: '调整价格', params: { id: 'xxx-xxx', price: 5999 } }
    ],
    permissions: ['admin']
  },
  'product.toggleStatus': {
    type: 'product.toggleStatus',
    name: '切换上架状态',
    description: '切换产品上架/下架状态',
    category: '产品管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '产品ID' },
      { name: 'is_active', type: 'boolean', required: true, description: '是否上架' }
    ],
    examples: [
      { description: '下架产品', params: { id: 'xxx-xxx', is_active: false } }
    ],
    permissions: ['admin']
  },

  // 订单管理
  'order.query': {
    type: 'order.query',
    name: '查询订单',
    description: '根据条件查询订单',
    category: '订单管理',
    params: [
      { name: 'status', type: 'string', required: false, description: '订单状态' },
      { name: 'userId', type: 'string', required: false, description: '用户ID' },
      { name: 'orderNumber', type: 'string', required: false, description: '订单号' },
      { name: 'startDate', type: 'string', required: false, description: '开始日期' },
      { name: 'endDate', type: 'string', required: false, description: '结束日期' }
    ],
    examples: [
      { description: '查询待处理订单', params: { status: 'pending' } }
    ],
    permissions: ['admin']
  },
  'order.update': {
    type: 'order.update',
    name: '更新订单',
    description: '更新订单信息',
    category: '订单管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '订单ID' },
      { name: 'status', type: 'string', required: false, description: '订单状态' },
      { name: 'notes', type: 'string', required: false, description: '订单备注' }
    ],
    examples: [
      { description: '更新订单状态', params: { id: 'xxx-xxx', status: 'processing' } }
    ],
    permissions: ['admin']
  },
  'order.updateStatus': {
    type: 'order.updateStatus',
    name: '更新订单状态',
    description: '更新订单状态',
    category: '订单管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '订单ID' },
      { name: 'status', type: 'string', required: true, description: '订单状态' }
    ],
    examples: [
      { description: '标记为已发货', params: { id: 'xxx-xxx', status: 'shipped' } }
    ],
    permissions: ['admin']
  },
  'order.addTracking': {
    type: 'order.addTracking',
    name: '添加物流单号',
    description: '添加订单物流追踪号',
    category: '订单管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '订单ID' },
      { name: 'tracking_number', type: 'string', required: true, description: '物流单号' }
    ],
    examples: [
      { description: '添加顺丰快递单号', params: { id: 'xxx-xxx', tracking_number: 'SF1234567890' } }
    ],
    permissions: ['admin']
  },
  'order.cancel': {
    type: 'order.cancel',
    name: '取消订单',
    description: '取消订单',
    category: '订单管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '订单ID' },
      { name: 'reason', type: 'string', required: false, description: '取消原因' }
    ],
    examples: [
      { description: '取消订单', params: { id: 'xxx-xxx', reason: '库存不足' } }
    ],
    permissions: ['admin']
  },
  'order.refund': {
    type: 'order.refund',
    name: '退款订单',
    description: '处理订单退款',
    category: '订单管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '订单ID' },
      { name: 'amount', type: 'number', required: true, description: '退款金额' },
      { name: 'reason', type: 'string', required: false, description: '退款原因' }
    ],
    examples: [
      { description: '全额退款', params: { id: 'xxx-xxx', amount: 7999, reason: '商品质量问题' } }
    ],
    permissions: ['admin']
  },

  // 用户管理
  'user.query': {
    type: 'user.query',
    name: '查询用户',
    description: '根据条件查询用户',
    category: '用户管理',
    params: [
      { name: 'keyword', type: 'string', required: false, description: '搜索关键词（姓名、邮箱）' },
      { name: 'role', type: 'string', required: false, description: '用户角色' },
      { name: 'emailVerified', type: 'boolean', required: false, description: '邮箱是否验证' }
    ],
    examples: [
      { description: '查询管理员用户', params: { role: 'admin' } }
    ],
    permissions: ['admin']
  },
  'user.update': {
    type: 'user.update',
    name: '更新用户',
    description: '更新用户信息',
    category: '用户管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '用户ID' },
      { name: 'display_name', type: 'string', required: false, description: '显示名称' },
      { name: 'phone', type: 'string', required: false, description: '手机号' },
      { name: 'bio', type: 'string', required: false, description: '个人简介' }
    ],
    examples: [
      { description: '更新用户手机号', params: { id: 'xxx-xxx', phone: '13800138000' } }
    ],
    permissions: ['admin']
  },
  'user.updateRole': {
    type: 'user.updateRole',
    name: '更新用户角色',
    description: '更新用户角色权限',
    category: '用户管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '用户ID' },
      { name: 'role', type: 'string', required: true, description: '角色（admin/user）' }
    ],
    examples: [
      { description: '设置为管理员', params: { id: 'xxx-xxx', role: 'admin' } }
    ],
    permissions: ['admin']
  },
  'user.block': {
    type: 'user.block',
    name: '封禁用户',
    description: '封禁用户账号',
    category: '用户管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '用户ID' },
      { name: 'reason', type: 'string', required: false, description: '封禁原因' }
    ],
    examples: [
      { description: '封禁违规用户', params: { id: 'xxx-xxx', reason: '发布违规内容' } }
    ],
    permissions: ['admin']
  },
  'user.unblock': {
    type: 'user.unblock',
    name: '解封用户',
    description: '解除用户封禁',
    category: '用户管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '用户ID' }
    ],
    examples: [
      { description: '解封用户', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },

  // 售后管理
  'afterSales.query': {
    type: 'afterSales.query',
    name: '查询售后',
    description: '查询售后请求',
    category: '售后管理',
    params: [
      { name: 'status', type: 'string', required: false, description: '售后状态' },
      { name: 'type', type: 'string', required: false, description: '售后类型' },
      { name: 'userId', type: 'string', required: false, description: '用户ID' }
    ],
    examples: [
      { description: '查询待处理售后', params: { status: 'pending' } }
    ],
    permissions: ['admin']
  },
  'afterSales.update': {
    type: 'afterSales.update',
    name: '更新售后',
    description: '更新售后请求信息',
    category: '售后管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '售后ID' },
      { name: 'status', type: 'string', required: false, description: '售后状态' },
      { name: 'admin_notes', type: 'string', required: false, description: '管理员备注' }
    ],
    examples: [
      { description: '更新售后状态', params: { id: 'xxx-xxx', status: 'processing' } }
    ],
    permissions: ['admin']
  },
  'afterSales.approve': {
    type: 'afterSales.approve',
    name: '批准售后',
    description: '批准售后请求',
    category: '售后管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '售后ID' },
      { name: 'refund_amount', type: 'number', required: false, description: '退款金额' },
      { name: 'admin_notes', type: 'string', required: false, description: '管理员备注' }
    ],
    examples: [
      { description: '批准退款', params: { id: 'xxx-xxx', refund_amount: 7999 } }
    ],
    permissions: ['admin']
  },
  'afterSales.reject': {
    type: 'afterSales.reject',
    name: '拒绝售后',
    description: '拒绝售后请求',
    category: '售后管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '售后ID' },
      { name: 'reason', type: 'string', required: true, description: '拒绝原因' }
    ],
    examples: [
      { description: '拒绝售后', params: { id: 'xxx-xxx', reason: '不符合退款条件' } }
    ],
    permissions: ['admin']
  },
  'afterSales.addNotes': {
    type: 'afterSales.addNotes',
    name: '添加备注',
    description: '添加售后处理备注',
    category: '售后管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '售后ID' },
      { name: 'notes', type: 'string', required: true, description: '备注内容' }
    ],
    examples: [
      { description: '添加处理记录', params: { id: 'xxx-xxx', notes: '已联系客户确认' } }
    ],
    permissions: ['admin']
  },

  // 分类管理
  'category.query': {
    type: 'category.query',
    name: '查询分类',
    description: '查询产品分类',
    category: '分类管理',
    params: [
      { name: 'parentId', type: 'string', required: false, description: '父分类ID' },
      { name: 'isActive', type: 'boolean', required: false, description: '是否启用' }
    ],
    examples: [
      { description: '查询所有一级分类', params: { parentId: null } }
    ],
    permissions: ['admin']
  },
  'category.create': {
    type: 'category.create',
    name: '创建分类',
    description: '创建新分类',
    category: '分类管理',
    params: [
      { name: 'name', type: 'string', required: true, description: '分类名称' },
      { name: 'description', type: 'string', required: false, description: '分类描述' },
      { name: 'parent_id', type: 'string', required: false, description: '父分类ID' }
    ],
    examples: [
      { description: '创建手机分类', params: { name: '手机', description: '智能手机' } }
    ],
    permissions: ['admin']
  },
  'category.update': {
    type: 'category.update',
    name: '更新分类',
    description: '更新分类信息',
    category: '分类管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '分类ID' },
      { name: 'name', type: 'string', required: false, description: '分类名称' },
      { name: 'description', type: 'string', required: false, description: '分类描述' }
    ],
    examples: [
      { description: '更新分类名称', params: { id: 'xxx-xxx', name: '智能手机' } }
    ],
    permissions: ['admin']
  },
  'category.delete': {
    type: 'category.delete',
    name: '删除分类',
    description: '删除分类',
    category: '分类管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '分类ID' }
    ],
    examples: [
      { description: '删除分类', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },

  // 品牌管理
  'brand.query': {
    type: 'brand.query',
    name: '查询品牌',
    description: '查询品牌列表，支持关键词搜索',
    category: '品牌管理',
    params: [
      { name: 'keyword', type: 'string', required: false, description: '搜索关键词（品牌名称）' },
      { name: 'isActive', type: 'boolean', required: false, description: '是否启用' }
    ],
    examples: [
      { description: '查询所有品牌', params: {} },
      { description: '搜索Apple品牌', params: { keyword: 'Apple' } }
    ],
    permissions: ['admin']
  },
  'brand.queryWithProducts': {
    type: 'brand.queryWithProducts',
    name: '查询品牌及其商品',
    description: '查询品牌信息并返回该品牌下的所有商品',
    category: '品牌管理',
    params: [
      { name: 'brandName', type: 'string', required: true, description: '品牌名称（精确或模糊匹配）' }
    ],
    examples: [
      { description: '查询Apple品牌及其商品', params: { brandName: 'Apple' } },
      { description: '查询华为品牌及其商品', params: { brandName: '华为' } }
    ],
    permissions: ['admin']
  },
  'brand.create': {
    type: 'brand.create',
    name: '创建品牌',
    description: '创建新品牌',
    category: '品牌管理',
    params: [
      { name: 'name', type: 'string', required: true, description: '品牌名称' },
      { name: 'description', type: 'string', required: false, description: '品牌描述' },
      { name: 'logo_url', type: 'string', required: false, description: '品牌Logo URL' }
    ],
    examples: [
      { description: '创建Apple品牌', params: { name: 'Apple', description: '美国科技公司' } }
    ],
    permissions: ['admin']
  },
  'brand.update': {
    type: 'brand.update',
    name: '更新品牌',
    description: '更新品牌信息',
    category: '品牌管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '品牌ID' },
      { name: 'name', type: 'string', required: false, description: '品牌名称' },
      { name: 'description', type: 'string', required: false, description: '品牌描述' }
    ],
    examples: [
      { description: '更新品牌信息', params: { id: 'xxx-xxx', name: 'Apple Inc.' } }
    ],
    permissions: ['admin']
  },
  'brand.delete': {
    type: 'brand.delete',
    name: '删除品牌',
    description: '删除品牌',
    category: '品牌管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '品牌ID' }
    ],
    examples: [
      { description: '删除品牌', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },

  // 横幅管理
  'banner.query': {
    type: 'banner.query',
    name: '查询横幅',
    description: '查询横幅列表',
    category: '横幅管理',
    params: [
      { name: 'isActive', type: 'boolean', required: false, description: '是否启用' }
    ],
    examples: [
      { description: '查询所有横幅', params: {} }
    ],
    permissions: ['admin']
  },
  'banner.create': {
    type: 'banner.create',
    name: '创建横幅',
    description: '创建新横幅',
    category: '横幅管理',
    params: [
      { name: 'title', type: 'string', required: true, description: '横幅标题' },
      { name: 'subtitle', type: 'string', required: false, description: '副标题' },
      { name: 'image_url', type: 'string', required: false, description: '图片URL' },
      { name: 'link_url', type: 'string', required: false, description: '跳转链接' }
    ],
    examples: [
      { description: '创建促销横幅', params: { title: '新年大促', subtitle: '全场5折' } }
    ],
    permissions: ['admin']
  },
  'banner.update': {
    type: 'banner.update',
    name: '更新横幅',
    description: '更新横幅信息',
    category: '横幅管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '横幅ID' },
      { name: 'title', type: 'string', required: false, description: '横幅标题' },
      { name: 'is_active', type: 'boolean', required: false, description: '是否启用' }
    ],
    examples: [
      { description: '更新横幅', params: { id: 'xxx-xxx', title: '春节特惠' } }
    ],
    permissions: ['admin']
  },
  'banner.delete': {
    type: 'banner.delete',
    name: '删除横幅',
    description: '删除横幅',
    category: '横幅管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '横幅ID' }
    ],
    examples: [
      { description: '删除横幅', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },

  // 优惠券管理
  'coupon.query': {
    type: 'coupon.query',
    name: '查询优惠券',
    description: '查询优惠券列表',
    category: '优惠券管理',
    params: [
      { name: 'status', type: 'string', required: false, description: '状态 (active/inactive/expired)' },
      { name: 'type', type: 'string', required: false, description: '类型 (percentage/fixed)' },
      { name: 'keyword', type: 'string', required: false, description: '搜索关键词' }
    ],
    examples: [
      { description: '查询所有有效优惠券', params: { status: 'active' } }
    ],
    permissions: ['admin']
  },
  'coupon.create': {
    type: 'coupon.create',
    name: '创建优惠券',
    description: '创建新优惠券活动',
    category: '优惠券管理',
    params: [
      { name: 'name', type: 'string', required: true, description: '优惠券名称' },
      { name: 'code', type: 'string', required: false, description: '优惠券码（不填自动生成）' },
      { name: 'type', type: 'string', required: true, description: '类型: percentage(百分比折扣) 或 fixed(固定金额)' },
      { name: 'discount_value', type: 'number', required: true, description: '折扣值（百分比为0-100，固定金额为具体金额）' },
      { name: 'min_purchase_amount', type: 'number', required: false, description: '最低消费金额' },
      { name: 'max_discount_amount', type: 'number', required: false, description: '最大折扣金额（仅百分比类型有效）' },
      { name: 'start_date', type: 'string', required: true, description: '开始日期 (ISO格式)' },
      { name: 'end_date', type: 'string', required: true, description: '结束日期 (ISO格式)' },
      { name: 'total_quantity', type: 'number', required: true, description: '发放总量' },
      { name: 'per_user_limit', type: 'number', required: false, description: '每人限领数量' },
      { name: 'scope', type: 'string', required: false, description: '适用范围 (all/category/product/brand)' },
      { name: 'description', type: 'string', required: false, description: '优惠券描述' }
    ],
    examples: [
      { 
        description: '创建新年8折优惠券', 
        params: { 
          name: '新年8折优惠', 
          type: 'percentage', 
          discount_value: 20, 
          start_date: '2025-01-01T00:00:00Z', 
          end_date: '2025-01-31T23:59:59Z', 
          total_quantity: 1000 
        } 
      },
      { 
        description: '创建满100减20优惠券', 
        params: { 
          name: '满100减20', 
          type: 'fixed', 
          discount_value: 20, 
          min_purchase_amount: 100,
          start_date: '2025-01-01T00:00:00Z', 
          end_date: '2025-02-28T23:59:59Z', 
          total_quantity: 500 
        } 
      }
    ],
    permissions: ['admin']
  },
  'coupon.update': {
    type: 'coupon.update',
    name: '更新优惠券',
    description: '更新优惠券信息',
    category: '优惠券管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '优惠券ID' },
      { name: 'name', type: 'string', required: false, description: '优惠券名称' },
      { name: 'status', type: 'string', required: false, description: '状态' },
      { name: 'total_quantity', type: 'number', required: false, description: '总数量' }
    ],
    examples: [
      { description: '增加优惠券数量', params: { id: 'xxx-xxx', total_quantity: 2000 } }
    ],
    permissions: ['admin']
  },
  'coupon.delete': {
    type: 'coupon.delete',
    name: '删除优惠券',
    description: '删除优惠券',
    category: '优惠券管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '优惠券ID' }
    ],
    examples: [
      { description: '删除优惠券', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },

  // 数据分析
  'analytics.sales': {
    type: 'analytics.sales',
    name: '销售分析',
    description: '分析销售数据',
    category: '数据分析',
    params: [
      { name: 'startDate', type: 'string', required: false, description: '开始日期' },
      { name: 'endDate', type: 'string', required: false, description: '结束日期' },
      { name: 'groupBy', type: 'string', required: false, description: '分组方式（day/week/month）' }
    ],
    examples: [
      { description: '分析本月销售', params: { startDate: '2025-01-01', endDate: '2025-01-31' } }
    ],
    permissions: ['admin']
  },
  'analytics.products': {
    type: 'analytics.products',
    name: '产品分析',
    description: '分析产品数据',
    category: '数据分析',
    params: [
      { name: 'sortBy', type: 'string', required: false, description: '排序字段（sales/views/stock）' },
      { name: 'limit', type: 'number', required: false, description: '返回数量' }
    ],
    examples: [
      { description: '查看热销产品', params: { sortBy: 'sales', limit: 10 } }
    ],
    permissions: ['admin']
  },
  'analytics.users': {
    type: 'analytics.users',
    name: '用户分析',
    description: '分析用户数据',
    category: '数据分析',
    params: [
      { name: 'startDate', type: 'string', required: false, description: '开始日期' },
      { name: 'endDate', type: 'string', required: false, description: '结束日期' }
    ],
    examples: [
      { description: '分析用户增长', params: { startDate: '2025-01-01' } }
    ],
    permissions: ['admin']
  },
  'analytics.orders': {
    type: 'analytics.orders',
    name: '订单分析',
    description: '分析订单数据',
    category: '数据分析',
    params: [
      { name: 'startDate', type: 'string', required: false, description: '开始日期' },
      { name: 'endDate', type: 'string', required: false, description: '结束日期' },
      { name: 'status', type: 'string', required: false, description: '订单状态' }
    ],
    examples: [
      { description: '分析订单状态分布', params: {} }
    ],
    permissions: ['admin']
  },

  // 营销活动管理
  'campaign.query': {
    type: 'campaign.query',
    name: '查询营销活动',
    description: '查询营销活动列表',
    category: '营销活动',
    params: [
      { name: 'status', type: 'string', required: false, description: '状态 (draft/active/paused/completed/rejected)' },
      { name: 'type', type: 'string', required: false, description: '活动类型' },
      { name: 'created_by', type: 'string', required: false, description: '创建者 (AI/manual)' },
      { name: 'keyword', type: 'string', required: false, description: '搜索关键词' },
      { name: 'startDate', type: 'string', required: false, description: '开始日期' },
      { name: 'endDate', type: 'string', required: false, description: '结束日期' }
    ],
    examples: [
      { description: '查询所有进行中的活动', params: { status: 'active' } },
      { description: '查询AI创建的活动', params: { created_by: 'AI' } }
    ],
    permissions: ['admin']
  },
  'campaign.create': {
    type: 'campaign.create',
    name: '创建营销活动',
    description: '创建新的营销活动',
    category: '营销活动',
    params: [
      { name: 'name', type: 'string', required: true, description: '活动名称' },
      { name: 'description', type: 'string', required: false, description: '活动描述' },
      { name: 'type', type: 'string', required: true, description: '活动类型 (promotion/flash_sale/discount/group_buy)' },
      { name: 'start_date', type: 'string', required: true, description: '开始日期 (ISO格式)' },
      { name: 'end_date', type: 'string', required: true, description: '结束日期 (ISO格式)' },
      { name: 'config', type: 'object', required: false, description: '活动配置' },
      { name: 'ai_strategy', type: 'string', required: false, description: 'AI策略说明' },
      { name: 'related_coupon_id', type: 'string', required: false, description: '关联优惠券ID' },
      { name: 'created_by', type: 'string', required: false, description: '创建者 (AI/manual)' }
    ],
    examples: [
      { description: '创建双十一促销活动', params: { name: '双十一大促', type: 'promotion', start_date: '2025-11-01T00:00:00Z', end_date: '2025-11-11T23:59:59Z' } }
    ],
    permissions: ['admin']
  },
  'campaign.update': {
    type: 'campaign.update',
    name: '更新营销活动',
    description: '更新营销活动信息',
    category: '营销活动',
    params: [
      { name: 'id', type: 'string', required: true, description: '活动ID' },
      { name: 'name', type: 'string', required: false, description: '活动名称' },
      { name: 'description', type: 'string', required: false, description: '活动描述' },
      { name: 'config', type: 'object', required: false, description: '活动配置' }
    ],
    examples: [
      { description: '更新活动名称', params: { id: 'xxx-xxx', name: '双十一超级大促' } }
    ],
    permissions: ['admin']
  },
  'campaign.delete': {
    type: 'campaign.delete',
    name: '删除营销活动',
    description: '删除营销活动',
    category: '营销活动',
    params: [
      { name: 'id', type: 'string', required: true, description: '活动ID' }
    ],
    examples: [
      { description: '删除活动', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },
  'campaign.approve': {
    type: 'campaign.approve',
    name: '审批通过活动',
    description: '审批通过营销活动',
    category: '营销活动',
    params: [
      { name: 'id', type: 'string', required: true, description: '活动ID' },
      { name: 'review_notes', type: 'string', required: false, description: '审核备注' }
    ],
    examples: [
      { description: '通过活动审核', params: { id: 'xxx-xxx', review_notes: '活动方案可行' } }
    ],
    permissions: ['admin']
  },
  'campaign.reject': {
    type: 'campaign.reject',
    name: '拒绝活动',
    description: '拒绝营销活动',
    category: '营销活动',
    params: [
      { name: 'id', type: 'string', required: true, description: '活动ID' },
      { name: 'review_notes', type: 'string', required: true, description: '拒绝原因' }
    ],
    examples: [
      { description: '拒绝活动', params: { id: 'xxx-xxx', review_notes: '预算超标' } }
    ],
    permissions: ['admin']
  },
  'campaign.pause': {
    type: 'campaign.pause',
    name: '暂停活动',
    description: '暂停营销活动',
    category: '营销活动',
    params: [
      { name: 'id', type: 'string', required: true, description: '活动ID' }
    ],
    examples: [
      { description: '暂停活动', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },
  'campaign.resume': {
    type: 'campaign.resume',
    name: '恢复活动',
    description: '恢复已暂停的营销活动',
    category: '营销活动',
    params: [
      { name: 'id', type: 'string', required: true, description: '活动ID' }
    ],
    examples: [
      { description: '恢复活动', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },

  // 秒杀/限时折扣管理
  'flashSale.query': {
    type: 'flashSale.query',
    name: '查询秒杀活动',
    description: '查询秒杀/限时折扣活动列表',
    category: '秒杀管理',
    params: [
      { name: 'status', type: 'string', required: false, description: '状态 (draft/active/ended/cancelled)' },
      { name: 'type', type: 'string', required: false, description: '类型 (flash_sale/time_limited)' },
      { name: 'product_id', type: 'string', required: false, description: '商品ID' },
      { name: 'startDate', type: 'string', required: false, description: '开始日期' },
      { name: 'endDate', type: 'string', required: false, description: '结束日期' }
    ],
    examples: [
      { description: '查询进行中的秒杀', params: { status: 'active' } },
      { description: '查询某商品的秒杀', params: { product_id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },
  'flashSale.create': {
    type: 'flashSale.create',
    name: '创建秒杀活动',
    description: '创建秒杀/限时折扣活动',
    category: '秒杀管理',
    params: [
      { name: 'name', type: 'string', required: true, description: '活动名称' },
      { name: 'product_id', type: 'string', required: true, description: '商品ID' },
      { name: 'flash_price', type: 'number', required: true, description: '秒杀价格' },
      { name: 'original_price', type: 'number', required: true, description: '原价' },
      { name: 'stock_limit', type: 'number', required: true, description: '限购数量' },
      { name: 'start_time', type: 'string', required: true, description: '开始时间 (ISO格式)' },
      { name: 'end_time', type: 'string', required: true, description: '结束时间 (ISO格式)' },
      { name: 'type', type: 'string', required: false, description: '类型 (flash_sale/time_limited)' },
      { name: 'per_user_limit', type: 'number', required: false, description: '每人限购数量' },
      { name: 'description', type: 'string', required: false, description: '活动描述' },
      { name: 'ai_strategy', type: 'string', required: false, description: 'AI策略说明' }
    ],
    examples: [
      { description: '创建iPhone秒杀', params: { name: 'iPhone限时秒杀', product_id: 'xxx', flash_price: 5999, original_price: 7999, stock_limit: 100, start_time: '2025-01-15T10:00:00Z', end_time: '2025-01-15T12:00:00Z' } }
    ],
    permissions: ['admin']
  },
  'flashSale.update': {
    type: 'flashSale.update',
    name: '更新秒杀活动',
    description: '更新秒杀活动信息',
    category: '秒杀管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '活动ID' },
      { name: 'name', type: 'string', required: false, description: '活动名称' },
      { name: 'flash_price', type: 'number', required: false, description: '秒杀价格' },
      { name: 'stock_limit', type: 'number', required: false, description: '限购数量' },
      { name: 'status', type: 'string', required: false, description: '状态' }
    ],
    examples: [
      { description: '调整秒杀价格', params: { id: 'xxx-xxx', flash_price: 5499 } }
    ],
    permissions: ['admin']
  },
  'flashSale.delete': {
    type: 'flashSale.delete',
    name: '删除秒杀活动',
    description: '删除秒杀活动',
    category: '秒杀管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '活动ID' }
    ],
    examples: [
      { description: '删除秒杀活动', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },
  'flashSale.start': {
    type: 'flashSale.start',
    name: '开始秒杀',
    description: '立即开始秒杀活动',
    category: '秒杀管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '活动ID' }
    ],
    examples: [
      { description: '开始秒杀', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },
  'flashSale.stop': {
    type: 'flashSale.stop',
    name: '停止秒杀',
    description: '立即停止秒杀活动',
    category: '秒杀管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '活动ID' }
    ],
    examples: [
      { description: '停止秒杀', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },

  // 支付有礼管理
  'paymentGift.query': {
    type: 'paymentGift.query',
    name: '查询支付有礼活动',
    description: '查询支付有礼活动列表',
    category: '支付有礼',
    params: [
      { name: 'status', type: 'string', required: false, description: '状态 (draft/active/ended)' },
      { name: 'gift_type', type: 'string', required: false, description: '礼品类型 (coupon/points/product/cashback)' },
      { name: 'min_amount', type: 'number', required: false, description: '最低支付金额' }
    ],
    examples: [
      { description: '查询进行中的活动', params: { status: 'active' } }
    ],
    permissions: ['admin']
  },
  'paymentGift.create': {
    type: 'paymentGift.create',
    name: '创建支付有礼活动',
    description: '创建支付有礼活动',
    category: '支付有礼',
    params: [
      { name: 'name', type: 'string', required: true, description: '活动名称' },
      { name: 'min_payment_amount', type: 'number', required: true, description: '最低支付金额' },
      { name: 'gift_type', type: 'string', required: true, description: '礼品类型 (coupon/points/product/cashback)' },
      { name: 'gift_value', type: 'object', required: true, description: '礼品值 (如 {coupon_id: xxx} 或 {points: 100} 或 {amount: 10})' },
      { name: 'probability', type: 'number', required: false, description: '中奖概率 (0-100)' },
      { name: 'start_date', type: 'string', required: true, description: '开始日期' },
      { name: 'end_date', type: 'string', required: true, description: '结束日期' },
      { name: 'total_quantity', type: 'number', required: false, description: '奖品总数' },
      { name: 'description', type: 'string', required: false, description: '活动描述' },
      { name: 'ai_strategy', type: 'string', required: false, description: 'AI策略说明' }
    ],
    examples: [
      { description: '创建满100送优惠券活动', params: { name: '满100送券', min_payment_amount: 100, gift_type: 'coupon', gift_value: { coupon_id: 'xxx' }, start_date: '2025-01-01T00:00:00Z', end_date: '2025-01-31T23:59:59Z' } },
      { description: '创建支付返现活动', params: { name: '支付返5元', min_payment_amount: 50, gift_type: 'cashback', gift_value: { amount: 5 }, probability: 30, start_date: '2025-01-01T00:00:00Z', end_date: '2025-01-31T23:59:59Z' } }
    ],
    permissions: ['admin']
  },
  'paymentGift.update': {
    type: 'paymentGift.update',
    name: '更新支付有礼活动',
    description: '更新支付有礼活动信息',
    category: '支付有礼',
    params: [
      { name: 'id', type: 'string', required: true, description: '活动ID' },
      { name: 'name', type: 'string', required: false, description: '活动名称' },
      { name: 'probability', type: 'number', required: false, description: '中奖概率' },
      { name: 'status', type: 'string', required: false, description: '状态' }
    ],
    examples: [
      { description: '调整中奖概率', params: { id: 'xxx-xxx', probability: 50 } }
    ],
    permissions: ['admin']
  },
  'paymentGift.delete': {
    type: 'paymentGift.delete',
    name: '删除支付有礼活动',
    description: '删除支付有礼活动',
    category: '支付有礼',
    params: [
      { name: 'id', type: 'string', required: true, description: '活动ID' }
    ],
    examples: [
      { description: '删除活动', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },
  'paymentGift.toggleStatus': {
    type: 'paymentGift.toggleStatus',
    name: '切换活动状态',
    description: '切换支付有礼活动的启用/禁用状态',
    category: '支付有礼',
    params: [
      { name: 'id', type: 'string', required: true, description: '活动ID' },
      { name: 'status', type: 'string', required: true, description: '状态 (active/paused)' }
    ],
    examples: [
      { description: '暂停活动', params: { id: 'xxx-xxx', status: 'paused' } }
    ],
    permissions: ['admin']
  },

  // 团购活动管理
  'groupBuy.query': {
    type: 'groupBuy.query',
    name: '查询团购活动',
    description: '查询团购活动列表',
    category: '团购管理',
    params: [
      { name: 'status', type: 'string', required: false, description: '状态 (draft/active/ended)' },
      { name: 'product_id', type: 'string', required: false, description: '商品ID' },
      { name: 'startDate', type: 'string', required: false, description: '开始日期' },
      { name: 'endDate', type: 'string', required: false, description: '结束日期' }
    ],
    examples: [
      { description: '查询进行中的团购', params: { status: 'active' } }
    ],
    permissions: ['admin']
  },
  'groupBuy.create': {
    type: 'groupBuy.create',
    name: '创建团购活动',
    description: '创建团购活动',
    category: '团购管理',
    params: [
      { name: 'name', type: 'string', required: true, description: '活动名称' },
      { name: 'product_id', type: 'string', required: true, description: '商品ID' },
      { name: 'group_price', type: 'number', required: true, description: '团购价格' },
      { name: 'original_price', type: 'number', required: true, description: '原价' },
      { name: 'min_group_size', type: 'number', required: true, description: '最小成团人数' },
      { name: 'max_group_size', type: 'number', required: false, description: '最大成团人数' },
      { name: 'duration_hours', type: 'number', required: true, description: '成团时限(小时)' },
      { name: 'start_date', type: 'string', required: true, description: '开始日期' },
      { name: 'end_date', type: 'string', required: true, description: '结束日期' },
      { name: 'stock_limit', type: 'number', required: false, description: '库存限制' },
      { name: 'description', type: 'string', required: false, description: '活动描述' },
      { name: 'ai_strategy', type: 'string', required: false, description: 'AI策略说明' }
    ],
    examples: [
      { description: '创建3人团购', params: { name: '3人拼团享优惠', product_id: 'xxx', group_price: 299, original_price: 399, min_group_size: 3, duration_hours: 24, start_date: '2025-01-01T00:00:00Z', end_date: '2025-01-31T23:59:59Z' } }
    ],
    permissions: ['admin']
  },
  'groupBuy.update': {
    type: 'groupBuy.update',
    name: '更新团购活动',
    description: '更新团购活动信息',
    category: '团购管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '活动ID' },
      { name: 'name', type: 'string', required: false, description: '活动名称' },
      { name: 'group_price', type: 'number', required: false, description: '团购价格' },
      { name: 'status', type: 'string', required: false, description: '状态' }
    ],
    examples: [
      { description: '调整团购价格', params: { id: 'xxx-xxx', group_price: 279 } }
    ],
    permissions: ['admin']
  },
  'groupBuy.delete': {
    type: 'groupBuy.delete',
    name: '删除团购活动',
    description: '删除团购活动',
    category: '团购管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '活动ID' }
    ],
    examples: [
      { description: '删除团购活动', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },
  'groupBuy.queryOrders': {
    type: 'groupBuy.queryOrders',
    name: '查询拼团订单',
    description: '查询拼团订单和参与情况',
    category: '团购管理',
    params: [
      { name: 'activity_id', type: 'string', required: false, description: '活动ID' },
      { name: 'status', type: 'string', required: false, description: '状态 (pending/completed/expired/cancelled)' },
      { name: 'leader_user_id', type: 'string', required: false, description: '团长用户ID' }
    ],
    examples: [
      { description: '查询某活动的拼团订单', params: { activity_id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },
  'groupBuy.cancelOrder': {
    type: 'groupBuy.cancelOrder',
    name: '取消拼团订单',
    description: '取消拼团订单',
    category: '团购管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '拼团订单ID' },
      { name: 'reason', type: 'string', required: false, description: '取消原因' }
    ],
    examples: [
      { description: '取消拼团', params: { id: 'xxx-xxx', reason: '商品缺货' } }
    ],
    permissions: ['admin']
  },

  // 会员储值管理
  'recharge.queryPlans': {
    type: 'recharge.queryPlans',
    name: '查询储值方案',
    description: '查询会员储值方案列表',
    category: '会员储值',
    params: [
      { name: 'is_active', type: 'boolean', required: false, description: '是否启用' }
    ],
    examples: [
      { description: '查询所有启用的方案', params: { is_active: true } }
    ],
    permissions: ['admin']
  },
  'recharge.createPlan': {
    type: 'recharge.createPlan',
    name: '创建储值方案',
    description: '创建会员储值方案',
    category: '会员储值',
    params: [
      { name: 'name', type: 'string', required: true, description: '方案名称' },
      { name: 'recharge_amount', type: 'number', required: true, description: '充值金额' },
      { name: 'bonus_amount', type: 'number', required: true, description: '赠送金额' },
      { name: 'description', type: 'string', required: false, description: '方案描述' },
      { name: 'display_order', type: 'number', required: false, description: '显示顺序' }
    ],
    examples: [
      { description: '创建充100送20方案', params: { name: '充100送20', recharge_amount: 100, bonus_amount: 20 } }
    ],
    permissions: ['admin']
  },
  'recharge.updatePlan': {
    type: 'recharge.updatePlan',
    name: '更新储值方案',
    description: '更新会员储值方案',
    category: '会员储值',
    params: [
      { name: 'id', type: 'string', required: true, description: '方案ID' },
      { name: 'name', type: 'string', required: false, description: '方案名称' },
      { name: 'bonus_amount', type: 'number', required: false, description: '赠送金额' },
      { name: 'is_active', type: 'boolean', required: false, description: '是否启用' }
    ],
    examples: [
      { description: '调整赠送金额', params: { id: 'xxx-xxx', bonus_amount: 30 } }
    ],
    permissions: ['admin']
  },
  'recharge.deletePlan': {
    type: 'recharge.deletePlan',
    name: '删除储值方案',
    description: '删除会员储值方案',
    category: '会员储值',
    params: [
      { name: 'id', type: 'string', required: true, description: '方案ID' }
    ],
    examples: [
      { description: '删除方案', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  },
  'recharge.queryBalances': {
    type: 'recharge.queryBalances',
    name: '查询会员余额',
    description: '查询会员余额列表',
    category: '会员储值',
    params: [
      { name: 'user_id', type: 'string', required: false, description: '用户ID' },
      { name: 'min_balance', type: 'number', required: false, description: '最低余额' },
      { name: 'max_balance', type: 'number', required: false, description: '最高余额' }
    ],
    examples: [
      { description: '查询高余额会员', params: { min_balance: 1000 } }
    ],
    permissions: ['admin']
  },
  'recharge.queryTransactions': {
    type: 'recharge.queryTransactions',
    name: '查询余额交易',
    description: '查询余额交易记录',
    category: '会员储值',
    params: [
      { name: 'user_id', type: 'string', required: false, description: '用户ID' },
      { name: 'type', type: 'string', required: false, description: '交易类型 (recharge/consume/bonus/refund/adjust)' },
      { name: 'startDate', type: 'string', required: false, description: '开始日期' },
      { name: 'endDate', type: 'string', required: false, description: '结束日期' }
    ],
    examples: [
      { description: '查询充值记录', params: { type: 'recharge' } }
    ],
    permissions: ['admin']
  },
  'recharge.adjustBalance': {
    type: 'recharge.adjustBalance',
    name: '调整会员余额',
    description: '手动调整会员余额',
    category: '会员储值',
    params: [
      { name: 'user_id', type: 'string', required: true, description: '用户ID' },
      { name: 'amount', type: 'number', required: true, description: '调整金额 (正数增加,负数减少)' },
      { name: 'description', type: 'string', required: true, description: '调整原因' }
    ],
    examples: [
      { description: '补偿用户余额', params: { user_id: 'xxx', amount: 50, description: '客诉补偿' } }
    ],
    permissions: ['admin']
  },

  // 数据分析 - 营销相关
  'analytics.campaigns': {
    type: 'analytics.campaigns',
    name: '营销活动分析',
    description: '分析营销活动数据',
    category: '数据分析',
    params: [
      { name: 'startDate', type: 'string', required: false, description: '开始日期' },
      { name: 'endDate', type: 'string', required: false, description: '结束日期' },
      { name: 'type', type: 'string', required: false, description: '活动类型' },
      { name: 'limit', type: 'number', required: false, description: '返回数量' }
    ],
    examples: [
      { description: '分析本月活动', params: { startDate: '2025-01-01', endDate: '2025-01-31' } }
    ],
    permissions: ['admin']
  },
  'analytics.marketing': {
    type: 'analytics.marketing',
    name: '营销综合分析',
    description: '综合分析所有营销数据',
    category: '数据分析',
    params: [
      { name: 'startDate', type: 'string', required: false, description: '开始日期' },
      { name: 'endDate', type: 'string', required: false, description: '结束日期' }
    ],
    examples: [
      { description: '分析营销效果', params: { startDate: '2025-01-01', endDate: '2025-01-31' } }
    ],
    permissions: ['admin']
  },

  // Agent配置管理
  'agent.query': {
    type: 'agent.query',
    name: '查询Agent配置',
    description: '查询AI Agent的配置信息',
    category: 'Agent管理',
    params: [
      { name: 'agentType', type: 'string', required: false, description: 'Agent类型（manager/product/marketing/service/finance）' }
    ],
    examples: [
      { description: '查询所有Agent配置', params: {} },
      { description: '查询营销Agent配置', params: { agentType: 'marketing' } }
    ],
    permissions: ['admin']
  },
  'agent.update': {
    type: 'agent.update',
    name: '更新Agent配置',
    description: '更新AI Agent的完整配置',
    category: 'Agent管理',
    params: [
      { name: 'agentType', type: 'string', required: true, description: 'Agent类型' },
      { name: 'isActive', type: 'boolean', required: false, description: '是否激活' },
      { name: 'autoExecuteEnabled', type: 'boolean', required: false, description: '是否允许自动执行' },
      { name: 'maxAutoAmount', type: 'number', required: false, description: '自动执行额度上限' },
      { name: 'responseStyle', type: 'string', required: false, description: '响应风格' },
      { name: 'tone', type: 'string', required: false, description: '语气风格' }
    ],
    examples: [
      { description: '更新营销Agent配置', params: { agentType: 'marketing', autoExecuteEnabled: true, maxAutoAmount: 5000 } }
    ],
    permissions: ['admin']
  },
  'agent.setAutoExecute': {
    type: 'agent.setAutoExecute',
    name: '设置自动执行',
    description: '设置Agent是否允许自动执行操作',
    category: 'Agent管理',
    params: [
      { name: 'agentType', type: 'string', required: true, description: 'Agent类型' },
      { name: 'enabled', type: 'boolean', required: true, description: '是否启用自动执行' }
    ],
    examples: [
      { description: '开启营销Agent自动执行', params: { agentType: 'marketing', enabled: true } },
      { description: '关闭商品Agent自动执行', params: { agentType: 'product', enabled: false } }
    ],
    permissions: ['admin']
  },
  'agent.setMaxAmount': {
    type: 'agent.setMaxAmount',
    name: '设置自动执行额度',
    description: '设置Agent自动执行的金额上限',
    category: 'Agent管理',
    params: [
      { name: 'agentType', type: 'string', required: true, description: 'Agent类型' },
      { name: 'maxAmount', type: 'number', required: true, description: '金额上限' }
    ],
    examples: [
      { description: '设置营销Agent额度为5000', params: { agentType: 'marketing', maxAmount: 5000 } },
      { description: '设置财务Agent额度为10000', params: { agentType: 'finance', maxAmount: 10000 } }
    ],
    permissions: ['admin']
  },
  'agent.setGoals': {
    type: 'agent.setGoals',
    name: '设置Agent目标',
    description: '设置Agent的月度业务目标',
    category: 'Agent管理',
    params: [
      { name: 'agentType', type: 'string', required: true, description: 'Agent类型' },
      { name: 'goals', type: 'object', required: true, description: '目标配置' }
    ],
    examples: [
      { description: '设置营销Agent目标', params: { agentType: 'marketing', goals: { gmv: 100000, newUsers: 500, conversionRate: 3.5 } } },
      { description: '设置商品Agent目标', params: { agentType: 'product', goals: { newProducts: 20, stockTurnover: 4 } } }
    ],
    permissions: ['admin']
  },
  'agent.setNotifications': {
    type: 'agent.setNotifications',
    name: '设置Agent通知',
    description: '设置Agent的通知偏好',
    category: 'Agent管理',
    params: [
      { name: 'agentType', type: 'string', required: true, description: 'Agent类型' },
      { name: 'notifyOnInsights', type: 'boolean', required: false, description: '洞察提醒' },
      { name: 'notifyOnApprovals', type: 'boolean', required: false, description: '审批提醒' },
      { name: 'notifyOnErrors', type: 'boolean', required: false, description: '错误提醒' }
    ],
    examples: [
      { description: '开启营销Agent所有通知', params: { agentType: 'marketing', notifyOnInsights: true, notifyOnApprovals: true, notifyOnErrors: true } }
    ],
    permissions: ['admin']
  },
  'agent.setApprovalTypes': {
    type: 'agent.setApprovalTypes',
    name: '设置需审批类型',
    description: '设置Agent哪些操作需要人工审批',
    category: 'Agent管理',
    params: [
      { name: 'agentType', type: 'string', required: true, description: 'Agent类型' },
      { name: 'approvalTypes', type: 'array', required: true, description: '需要审批的操作类型列表' }
    ],
    examples: [
      { description: '设置营销Agent需审批的操作', params: { agentType: 'marketing', approvalTypes: ['create_campaign', 'high_value_discount'] } },
      { description: '清除商品Agent审批要求', params: { agentType: 'product', approvalTypes: [] } }
    ],
    permissions: ['admin']
  },

  // 目标管理
  'goal.query': {
    type: 'goal.query',
    name: '查询目标',
    description: '查询业务目标列表',
    category: '目标管理',
    params: [
      { name: 'agentType', type: 'string', required: false, description: 'Agent类型筛选' },
      { name: 'status', type: 'string', required: false, description: '目标状态(active/completed/cancelled)' },
      { name: 'assignedTo', type: 'string', required: false, description: '分配给谁' }
    ],
    examples: [
      { description: '查询营销部门目标', params: { agentType: 'marketing' } },
      { description: '查询所有活跃目标', params: { status: 'active' } }
    ],
    permissions: ['admin']
  },
  'goal.create': {
    type: 'goal.create',
    name: '创建目标',
    description: '创建新的业务目标',
    category: '目标管理',
    params: [
      { name: 'title', type: 'string', required: true, description: '目标标题' },
      { name: 'description', type: 'string', required: false, description: '目标描述' },
      { name: 'targetValue', type: 'number', required: true, description: '目标值' },
      { name: 'currentValue', type: 'number', required: false, description: '当前值' },
      { name: 'unit', type: 'string', required: false, description: '单位(默认:元)' },
      { name: 'deadline', type: 'string', required: true, description: '截止日期' },
      { name: 'priority', type: 'string', required: false, description: '优先级(low/medium/high)' },
      { name: 'agentType', type: 'string', required: true, description: '所属Agent(marketing/product/service/finance/manager)' },
      { name: 'assignedBy', type: 'string', required: false, description: '分配者' },
      { name: 'assignedTo', type: 'string', required: false, description: '执行者' }
    ],
    examples: [
      { description: '设置营销GMV目标', params: { title: '本月营销GMV目标', targetValue: 350000, unit: '元', deadline: '2024-12-31', agentType: 'marketing', priority: 'high', assignedBy: '经理AI · 小管' } },
      { description: '设置新客获取目标', params: { title: '新客户增长目标', targetValue: 500, unit: '人', deadline: '2024-12-31', agentType: 'marketing' } }
    ],
    permissions: ['admin']
  },
  'goal.update': {
    type: 'goal.update',
    name: '更新目标',
    description: '更新目标信息',
    category: '目标管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '目标ID' },
      { name: 'title', type: 'string', required: false, description: '目标标题' },
      { name: 'description', type: 'string', required: false, description: '目标描述' },
      { name: 'targetValue', type: 'number', required: false, description: '目标值' },
      { name: 'currentValue', type: 'number', required: false, description: '当前值' },
      { name: 'deadline', type: 'string', required: false, description: '截止日期' },
      { name: 'priority', type: 'string', required: false, description: '优先级' },
      { name: 'status', type: 'string', required: false, description: '状态' }
    ],
    examples: [
      { description: '更新目标进度', params: { id: 'xxx-xxx', currentValue: 186000 } },
      { description: '标记目标完成', params: { id: 'xxx-xxx', status: 'completed' } }
    ],
    permissions: ['admin']
  },
  'goal.updateProgress': {
    type: 'goal.updateProgress',
    name: '更新目标进度',
    description: '更新目标的当前完成值',
    category: '目标管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '目标ID' },
      { name: 'currentValue', type: 'number', required: true, description: '当前完成值' }
    ],
    examples: [
      { description: '更新GMV进度', params: { id: 'xxx-xxx', currentValue: 250000 } }
    ],
    permissions: ['admin']
  },
  'goal.delete': {
    type: 'goal.delete',
    name: '删除目标',
    description: '删除业务目标',
    category: '目标管理',
    params: [
      { name: 'id', type: 'string', required: true, description: '目标ID' }
    ],
    examples: [
      { description: '删除目标', params: { id: 'xxx-xxx' } }
    ],
    permissions: ['admin']
  }
};

// 导出工具函数
export function getOperationsByCategory() {
  const categories: Record<string, AdminOperation[]> = {};
  
  Object.values(ADMIN_OPERATIONS).forEach(operation => {
    if (!categories[operation.category]) {
      categories[operation.category] = [];
    }
    categories[operation.category].push(operation);
  });
  
  return categories;
}

export function getOperationByType(type: AdminOperationType): AdminOperation | undefined {
  return ADMIN_OPERATIONS[type];
}
