SuperAPI AI 工具集

fulfillment-location-routing

办公与效率

查看项目

更新于 10-15 10:44

技能介绍

用途

该技能用于查询分配给某个来源地点的开放履约订单,并将其移动到目标地点。典型使用场景包括:仓库达到容量上限、某个地点即将关闭,或区域路由规则发生变化。它替代了在 Shopify Admin 中手动重新分配的操作,可在单个工作流中批量处理任意数量的开放订单。

主要能力

  • 按来源地点查询状态为 OPEN 的履约订单,支持分页(每页 250 条,直到 hasNextPage 为 false)。
  • 通过 fulfillmentOrderMove 变更将履约订单重新分配到目标地点。
  • 支持可选的订单名称过滤(如 "#1001,#1002"),便于优先处理特定订单。
  • 支持 dry_run 预览模式(默认 true),在不执行变更的情况下确认订单列表与目标地点。
  • 输出 human 或 json 格式的结果,并生成 CSV 路由日志。

使用方式

前置条件:

  • 已认证的 Shopify CLI 会话:shopify store auth --store <domain> --scopes read_orders,write_fulfillments
  • API 权限范围:read_orders、write_fulfillments
  • 来源与目标地点均须为 Shopify 中有效的履约地点

参数:

  • store(字符串,必填):商店域名,例如 mystore.myshopify.com
  • source_location_id(字符串,必填):要移出订单的来源地点 GID
  • destination_location_id(字符串,必填):要移入订单的目标地点 GID
  • order_filter(字符串,可选):订单名称过滤器,例如 "#1001,#1002"
  • dry_run(布尔,可选,默认 true):预览移动而不执行变更
  • format(字符串,可选,默认 human):输出格式,human 或 json

工作流步骤:

  1. OPERATION: fulfillmentOrders — 查询。输入 assignedLocationId、status: OPEN、first: 250 及分页游标;输出开放履约订单列表,分页直到 hasNextPage: false。
  2. OPERATION: fulfillmentOrderMove — 变更。输入 id 与 newLocationId;输出 movedFulfillmentOrder、originalFulfillmentOrder、remainingFulfillmentOrder 及 userErrors。

GraphQL 操作(已针对 api_version 2025-01 验证):

查询: query FulfillmentOrdersByLocation($locationId: ID!, $after: String) { fulfillmentOrders( assignedLocationId: $locationId first: 250 after: $after query: "status:open" ) { edges { node { id status order { id name } assignedLocation { location { id name } } } } pageInfo { hasNextPage endCursor } } }

变更: mutation FulfillmentOrderMove($id: ID!, $newLocationId: ID!) { fulfillmentOrderMove(id: $id, newLocationId: $newLocationId) { movedFulfillmentOrder { id assignedLocation { location { id name } } } originalFulfillmentOrder { id status } remainingFulfillmentOrder { id status } userErrors { field message } } }

会话跟踪: Claude 必须在每个阶段输出指定内容。开始时输出包含技能名称、商店域名和开始时间的横幅;每步之后输出 [N/TOTAL] 操作类型、操作名称、参数摘要与结果;若 dry_run 为 true,每个变更步骤前加 [DRY RUN] 前缀且不执行;完成时按 human 格式输出结果摘要(来源地点订单数、已移动订单数、错误数、输出文件),或按 json 格式输出包含 skill、store、started_at、completed_at、dry_run 与 outcome 的对象。

输出格式: CSV 文件 routing_log_<YYYY-MM-DD>.csv,列包括 order_name、fulfillment_order_id、source_location、destination_location、status。

适用场景

  • 仓库容量溢出时,将订单从满载仓库转移到其他地点。
  • 某地点即将关闭时,在 Shopify Admin 中停用该地点之前运行此技能。
  • 区域路由规则变更时,批量重新分配开放订单。
  • 需要优先处理特定高优先级订单时,配合 order_filter 使用。

限制与安全注意事项

  • fulfillmentOrderMove 会重新分配履约责任,影响由哪个仓库拣货和发货。移动前须确认目标地点对所有商品有足够库存。
  • 移动履约订单不会移动库存;应使用 multi-location-inventory-audit 技能单独核实目标地点的库存水平。
  • 建议始终先以 dry_run: true 运行,确认订单列表与目标地点后再提交。
  • 错误处理:THROTTLED(API 速率限制)需等待 2 秒并最多重试 3 次;fulfillmentOrderMove 的 userErrors(订单已履约或地点未激活)记录错误、跳过该订单并继续;目标地点无库存时按 SKU 记录警告并继续移动;来源无开放订单时以摘要退出(0 个订单)。
  • 来源与目标地点必须均为 Shopify 中有效的履约地点。