feat: add self-operated analytics and enforce Lastleg module boundaries

This commit is contained in:
2026-10-12 20:27:35 +08:00
parent c06e788b0f
commit a1f1d93902
174 changed files with 13514 additions and 490 deletions
@@ -0,0 +1,115 @@
openapi: 3.0.3
info:
title: Self-operated Analytics Internal Egress Authority
version: 1.0.0
paths:
/internal/lastleg/self-operated-analytics/egress/authorize:
post:
operationId: authorizeSelfoperatedEgressAttempt
summary: 一次性消费已持久预留的领星请求许可
description: >-
仅内部服务令牌。客户端已登记的 context 和 operation 必须完全匹配;
requestHash 是 Integration 对 OMP 路径和有序业务 JSON 的摘要,首次消费绑定,
后续完成必须完全匹配。同 attemptId 再次消费拒绝。allowedAttempts 固定 1,
expiresAt 最多 30 秒且不超过验证根截止或人工独占窗口。OFF 默认拒绝,
非 production 环境拒绝 BUSINESS。独占交接证明及接续预算由服务端配置核验。
security: [{ internalServiceToken: [] }]
requestBody:
required: true
content:
application/json:
schema: { $ref: '#/components/schemas/AuthorizationRequest' }
responses:
'200':
description: HTTP 200;许可 code=200,正常拒绝 code=B0001,data 为显式预算决策
content:
application/json:
schema:
type: object
properties:
code: { type: string }
data:
oneOf:
- { $ref: '#/components/schemas/AttemptPermit' }
- { $ref: '#/components/schemas/AuthorizationDenial' }
'401': { description: 内部令牌无效 }
'503': { description: 内部令牌未配置 }
/internal/lastleg/self-operated-analytics/egress/complete:
post:
operationId: completeSelfoperatedEgressAttempt
summary: 记录真实尝试次数和账号冷却
description: >-
回调 context、operation、requestHash 必须匹配已消费许可。actualHttpAttempts 仅 0 或 1;
即使 0 也不退回预留,响应丢失同样保留保守消耗。重复已确认完成为幂等成功。
429 对账号全部采集族持久冷却;验证根 DEAD、run FAILED、禁止自动续跑。
未确认结果的许可到期后保守冷却,不使用换日、换仓、重试或重启清零预算。
security: [{ internalServiceToken: [] }]
requestBody:
required: true
content:
application/json:
schema: { $ref: '#/components/schemas/CompletionRequest' }
responses:
'200':
description: ApiResponse code 字符串 200,data 为布尔 true
content:
application/json:
schema:
type: object
properties:
code: { type: string }
data: { type: boolean, enum: [true] }
'401': { description: 内部令牌无效 }
components:
securitySchemes:
internalServiceToken: { type: apiKey, in: header, name: X-Internal-Service-Token }
schemas:
EgressContext:
type: object
required: [sourceAccount, executionPurpose, rootTaskId, sessionId, attemptId, exclusiveGrantId]
properties:
sourceAccount: { type: string, maxLength: 64 }
executionPurpose: { type: string, enum: [VALIDATION, BUSINESS] }
rootTaskId: { type: string, pattern: '^[0-9]+$' }
sessionId: { type: string, maxLength: 128 }
attemptId: { type: string, maxLength: 128 }
exclusiveGrantId: { type: string, maxLength: 128 }
Operation:
type: string
enum: [WAREHOUSES, OUTBOUND_QUERY, OUTBOUND_LOCATE, OUTBOUND_DETAIL, PRODUCT_INVENTORY]
AuthorizationRequest:
type: object
required: [context, operation, requestHash]
properties:
context: { $ref: '#/components/schemas/EgressContext' }
operation: { $ref: '#/components/schemas/Operation' }
requestHash: { type: string, pattern: '^[a-f0-9]{64}$' }
AuthorizationDenial:
type: object
required: [errorCode, sampleDone, waitUntil]
properties:
errorCode: { type: string, pattern: '^[A-Z][A-Z0-9_]{0,63}$' }
sampleDone: { type: boolean }
waitUntil: { type: string, format: date-time, nullable: true, description: UTC Instant 或显式 null }
AttemptPermit:
allOf:
- { $ref: '#/components/schemas/AuthorizationRequest' }
- type: object
required: [allowedAttempts, expiresAt, exclusiveConfirmed, budgetConsumed]
properties:
allowedAttempts: { type: integer, enum: [1] }
expiresAt: { type: string, format: date-time }
exclusiveConfirmed: { type: boolean, enum: [true] }
budgetConsumed: { type: boolean, enum: [true] }
CompletionRequest:
allOf:
- { $ref: '#/components/schemas/AuthorizationRequest' }
- type: object
required: [actualHttpAttempts, accountPaused]
properties:
actualHttpAttempts: { type: integer, minimum: 0, maximum: 1 }
errorCode: { type: string, nullable: true }
upstreamStatus: { type: integer, nullable: true }
sourceCode: { type: integer, nullable: true }
accountPaused: { type: boolean }
cooldownUntil: { type: string, format: date-time, nullable: true }
@@ -0,0 +1,62 @@
openapi: 3.0.3
info:
title: Platform Self-operated Analytics Sync Commands
version: 1.0.0
paths:
/api/platform/v1/last-leg/self-operated-analytics/sync-tasks:
post:
operationId: requestSelfoperatedAnalyticsSyncTask
summary: 创建人工采集、复查、重建或恢复任务
description: >-
仅平台账号且须 platform:self-operated-analytics:sync 权限。命令先持久化,
不在 HTTP 请求内运行历史采集。collectionMode 默认 OFF;VALIDATION 仅用于持久预算内的样本暂存,
BUSINESS 仅允许生产环境,并要求真实出口取得服务端核验的人工独占许可。
出库来源时间及业务时间统一 Asia/Shanghai;首次正式目标固定为 E0 前两个滚动月。
BACKFILL 单片不超过一天。RETRY 使用 taskNo 和非空 reason 恢复原分仓逻辑任务,
保留半归并屏障及旧尝试,拒绝验证会话复活、账号共享任务伪装单仓、有效执行租约及上游未齐;
requestKey 同键异载荷拒绝。成功受理只表示排队,不表示采集或发布成功。
security:
- bearerAuth: []
x-required-authorities:
- platform:self-operated-analytics:sync
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/SyncCommand'
responses:
'200':
description: 平台 ApiResponse 包络,成功 code 为字符串 200;返回稳定业务任务号与 ACCEPTED
content:
application/json:
schema:
type: object
properties:
code: { type: string }
message: { type: string }
data:
type: object
properties:
taskNo: { type: string }
warehouseCode: { type: string }
status: { type: string, enum: [ACCEPTED] }
'401': { description: 未认证 }
'403': { description: 非平台身份或无独立写权限 }
components:
securitySchemes:
bearerAuth: { type: http, scheme: bearer, bearerFormat: JWT }
schemas:
SyncCommand:
type: object
required: [requestKey, warehouseCode, action]
properties:
requestKey: { type: string, minLength: 1, maxLength: 100 }
warehouseCode: { type: string, minLength: 1, maxLength: 64 }
action: { type: string, enum: [INVENTORY, BACKFILL, RECHECK, REBUILD, RETRY, VALIDATION] }
taskNo: { type: string, minLength: 1, maxLength: 64, description: RETRY 必填,原始分仓业务任务号 }
reason: { type: string, minLength: 1, maxLength: 500, description: RETRY 必填,随操作人和原任务审计保存 }
sourceFrom: { type: string, example: '2026-10-11T00:00:00' }
sourceUntil: { type: string, example: '2026-10-12T00:00:00' }
customerCode: { type: string, maxLength: 64, description: RECHECK 必填 }
deliveryNo: { type: string, maxLength: 128, description: RECHECK 必填 }
@@ -0,0 +1,700 @@
openapi: 3.0.3
info:
title: 平台自营出库销量库存及采集运行只读接口
version: 1.0.0
description: >-
全部GET要求PLATFORM身份、tenantId=0、非代登录及独立platform:self-operated-analytics:list权限。
来源及业务时区Asia/Shanghai,单位PCS,账号和仓库由服务端已配置范围校验。
经营查询首屏生成context,包含版本对、独立范围摘要、queryAsOf/queryExpiresAt。
后续列表、图表、榜单和库存复用完整上下文,版本0保持不可用,不偷偷补入新版本。
上下文最多30分钟且不超过旧销量版superseded_at_utc+7天;queryAsOf不得未来或早于所选版本发布时间。
过期/范围不符明确要求刷新整页,不能静默切版;各请求在同一REPEATABLE_READ快照内校验和读取。
五周期包含今日,CUSTOM两端包含且endDate不晚于anchorDate;只有CUSTOM接受startDate/endDate。
默认maxQueryDays366,粒度DAY。正式outboundQuantity与observedQuantity独立,全部未知仍为空。
每日COMPLETE仅证明全天覆盖及有效日行或可靠SKU存在;今日/部分日正式量空,观察量可用,未知日期保持空。
SKU区间正式量仅全部日完整才输出;observedQuantity为可靠点合计,完整/部分/未知日数独立。
切换图表不改变完整7/30日榜单及30日日均分母;不触发领星请求。
运行接口不受经营context限制。动态库存时效、重建和修订待核对独立返回。
阶段进度区分ACCOUNT_SHARED/WAREHOUSE及TASK_CUMULATIVE/ATTEMPT_ONLY,不伪造总百分比。
total未知为空、计数不能跨PAGE/ORDER/INVENTORY_ROW/BUSINESS_KEY/SKU/BATCH单位求和,NONE为非计数阶段且completed/total为空、totalKnown=false;阶段检查点与心跳分开。
任务号稳定,内部诊断ID不作为业务编号回退。SKU订单数不可相加为仓总单数。
重试沿既有POST sync-tasks,action=RETRY/requestKey/warehouseCode/taskNo/reason,使用独立sync权限并最终复核资格。
security: [{bearerAuth: []}]
paths:
/api/platform/v1/last-leg/self-operated-analytics/sku-sales-summary:
get:
summary: SKU五周期或历史累计清单
description: '候选为两版profile并集,SQL按选定日期聚合后按observedQuantity降序空值末尾、SKU及货主升序,再分页。未知日不填零。 权限platform:self-operated-analytics:list。'
parameters:
- {$ref: '#/components/parameters/sourceAccount'}
- {$ref: '#/components/parameters/warehouseCode'}
- {$ref: '#/components/parameters/customerCode'}
- {$ref: '#/components/parameters/sku'}
- {$ref: '#/components/parameters/salesRunId'}
- {$ref: '#/components/parameters/inventoryRunId'}
- {$ref: '#/components/parameters/salesScopeHash'}
- {$ref: '#/components/parameters/inventoryScopeHash'}
- {$ref: '#/components/parameters/queryAsOf'}
- {$ref: '#/components/parameters/rangePreset'}
- {$ref: '#/components/parameters/startDate'}
- {$ref: '#/components/parameters/endDate'}
- {$ref: '#/components/parameters/bucket'}
- {$ref: '#/components/parameters/current'}
- {$ref: '#/components/parameters/size'}
responses:
'200':
description: '统一ApiResponse,业务失败HTTP200且code非200。'
content:
application/json:
schema:
type: object
properties:
code: {type: string}
message: {type: string}
data: {$ref: '#/components/schemas/SalesPage'}
'401': {description: 缺少可信认证身份}
'403': {description: 非平台身份或缺少独立只读权限}
/api/platform/v1/last-leg/self-operated-analytics/sku-daily-sales:
get:
summary: 精确单SKU日趋势
description: 'customerCode和sku必填,精确原始业务键匹配。最多366日且返回完整升序日期轴,不分页。无候选明确业务错误。 权限platform:self-operated-analytics:list。'
parameters:
- {$ref: '#/components/parameters/sourceAccount'}
- {$ref: '#/components/parameters/warehouseCode'}
- {$ref: '#/components/parameters/customerCodeRequired'}
- {$ref: '#/components/parameters/skuRequired'}
- {$ref: '#/components/parameters/salesRunId'}
- {$ref: '#/components/parameters/inventoryRunId'}
- {$ref: '#/components/parameters/salesScopeHash'}
- {$ref: '#/components/parameters/inventoryScopeHash'}
- {$ref: '#/components/parameters/queryAsOf'}
- {$ref: '#/components/parameters/rangePreset'}
- {$ref: '#/components/parameters/startDate'}
- {$ref: '#/components/parameters/endDate'}
- {$ref: '#/components/parameters/bucket'}
responses:
'200':
description: '统一ApiResponse,业务失败HTTP200且code非200。'
content:
application/json:
schema:
type: object
properties:
code: {type: string}
message: {type: string}
data: {$ref: '#/components/schemas/Trend'}
'401': {description: 缺少可信认证身份}
'403': {description: 非平台身份或缺少独立只读权限}
/api/platform/v1/last-leg/self-operated-analytics/hot-skus:
get:
summary: 完整7/30日热销Top100
description: '独立截至queryAsOf昨日的完整窗口,数量大于零,数量降序、SKU单数降序、SKU及货主升序,先Top100再分页;当前缺货仍可入榜。 权限platform:self-operated-analytics:list。'
parameters:
- {$ref: '#/components/parameters/sourceAccount'}
- {$ref: '#/components/parameters/warehouseCode'}
- {$ref: '#/components/parameters/customerCode'}
- {$ref: '#/components/parameters/sku'}
- {$ref: '#/components/parameters/salesRunId'}
- {$ref: '#/components/parameters/inventoryRunId'}
- {$ref: '#/components/parameters/salesScopeHash'}
- {$ref: '#/components/parameters/inventoryScopeHash'}
- {$ref: '#/components/parameters/queryAsOf'}
- {$ref: '#/components/parameters/windowDays'}
- {$ref: '#/components/parameters/current'}
- {$ref: '#/components/parameters/size'}
responses:
'200':
description: '统一ApiResponse,业务失败HTTP200且code非200。'
content:
application/json:
schema:
type: object
properties:
code: {type: string}
message: {type: string}
data: {$ref: '#/components/schemas/MetricPage'}
'401': {description: 缺少可信认证身份}
'403': {description: 非平台身份或缺少独立只读权限}
/api/platform/v1/last-leg/self-operated-analytics/slow-skus:
get:
summary: 固定完整30日有库存低出库Top100
description: '固定30天,不接受windowDays或rangePreset。正品有效新鲜可售量大于零、完整窗口且起点前可靠存在。数量升序、可售量降序、SKU及货主升序。 权限platform:self-operated-analytics:list。'
parameters:
- {$ref: '#/components/parameters/sourceAccount'}
- {$ref: '#/components/parameters/warehouseCode'}
- {$ref: '#/components/parameters/customerCode'}
- {$ref: '#/components/parameters/sku'}
- {$ref: '#/components/parameters/salesRunId'}
- {$ref: '#/components/parameters/inventoryRunId'}
- {$ref: '#/components/parameters/salesScopeHash'}
- {$ref: '#/components/parameters/inventoryScopeHash'}
- {$ref: '#/components/parameters/queryAsOf'}
- {$ref: '#/components/parameters/current'}
- {$ref: '#/components/parameters/size'}
responses:
'200':
description: '统一ApiResponse,业务失败HTTP200且code非200。'
content:
application/json:
schema:
type: object
properties:
code: {type: string}
message: {type: string}
data: {$ref: '#/components/schemas/MetricPage'}
'401': {description: 缺少可信认证身份}
'403': {description: 非平台身份或缺少独立只读权限}
/api/platform/v1/last-leg/self-operated-analytics/inventory-coverage:
get:
summary: 正品库存与固定30日可售天数
description: '固定30天,不接受图表周期。可售仅品质0可用量,不扣冻结或加在途次品。先UNKNOWN/INVALID/STALE,再有效零库存为0,再校验正库存单位、窗口、观察期;零销量天数为空。 权限platform:self-operated-analytics:list。'
parameters:
- {$ref: '#/components/parameters/attention'}
- {$ref: '#/components/parameters/sortBy'}
- {$ref: '#/components/parameters/coverageDaysThreshold'}
- {$ref: '#/components/parameters/sourceAccount'}
- {$ref: '#/components/parameters/warehouseCode'}
- {$ref: '#/components/parameters/customerCode'}
- {$ref: '#/components/parameters/sku'}
- {$ref: '#/components/parameters/salesRunId'}
- {$ref: '#/components/parameters/inventoryRunId'}
- {$ref: '#/components/parameters/salesScopeHash'}
- {$ref: '#/components/parameters/inventoryScopeHash'}
- {$ref: '#/components/parameters/queryAsOf'}
- {$ref: '#/components/parameters/current'}
- {$ref: '#/components/parameters/size'}
responses:
'200':
description: '统一ApiResponse,业务失败HTTP200且code非200。'
content:
application/json:
schema:
type: object
properties:
code: {type: string}
message: {type: string}
data: {$ref: '#/components/schemas/MetricPage'}
'401': {description: 缺少可信认证身份}
'403': {description: 非平台身份或缺少独立只读权限}
/api/platform/v1/last-leg/self-operated-analytics/sync-overview:
get:
summary: 各仓任务族运行概览
description: 'warehouseCode可选。轻量读取scope/task/run/账号保护。无发布版和OFF仍返回配置任务。首采COMPLETE须正式发布覆盖且无rebuild或未闭合归并。共享上游明确账号共享范围。 权限platform:self-operated-analytics:list。'
parameters:
- {$ref: '#/components/parameters/sourceAccount'}
- {$ref: '#/components/parameters/warehouseCodeOptional'}
- {$ref: '#/components/parameters/dataFamily'}
responses:
'200':
description: '统一ApiResponse,业务失败HTTP200且code非200。'
content:
application/json:
schema:
type: object
properties:
code: {type: string}
message: {type: string}
data: {$ref: '#/components/schemas/Overview'}
'401': {description: 缺少可信认证身份}
'403': {description: 非平台身份或缺少独立只读权限}
/api/platform/v1/last-leg/self-operated-analytics/sync-tasks:
get:
summary: 本仓逻辑采集任务
description: '任务按创建时间及稳定键倒序。首屏返回listUpperCreatedAt/listUpperId,后页完整重传;新插入不挤移页。只读有限检查点,不展开stage或大manifest。 权限platform:self-operated-analytics:list。'
parameters:
- {$ref: '#/components/parameters/sourceAccount'}
- {$ref: '#/components/parameters/warehouseCode'}
- {$ref: '#/components/parameters/dataFamily'}
- {$ref: '#/components/parameters/taskType'}
- {$ref: '#/components/parameters/status'}
- {$ref: '#/components/parameters/taskNo'}
- {$ref: '#/components/parameters/dateFrom'}
- {$ref: '#/components/parameters/dateUntil'}
- {$ref: '#/components/parameters/current'}
- {$ref: '#/components/parameters/size'}
- {$ref: '#/components/parameters/listUpperCreatedAt'}
- {$ref: '#/components/parameters/listUpperId'}
responses:
'200':
description: '统一ApiResponse,业务失败HTTP200且code非200。'
content:
application/json:
schema:
type: object
properties:
code: {type: string}
message: {type: string}
data: {$ref: '#/components/schemas/TaskPage'}
'401': {description: 缺少可信认证身份}
'403': {description: 非平台身份或缺少独立只读权限}
/api/platform/v1/last-leg/self-operated-analytics/sync-tasks/{taskNo}:
get:
summary: 本仓业务任务号详情
description: '路径taskNo为稳定业务任务号,实际归属与请求账号仓必须一致。不以内部ID回退。详情含最新尝试和关联共享上游。 权限platform:self-operated-analytics:list。'
parameters:
- {$ref: '#/components/parameters/sourceAccount'}
- {$ref: '#/components/parameters/warehouseCode'}
- {name: taskNo, in: path, required: true, schema: {type: string, maxLength: 64}}
responses:
'200':
description: '统一ApiResponse,业务失败HTTP200且code非200。'
content:
application/json:
schema:
type: object
properties:
code: {type: string}
message: {type: string}
data: {$ref: '#/components/schemas/TaskDetail'}
'401': {description: 缺少可信认证身份}
'403': {description: 非平台身份或缺少独立只读权限}
/api/platform/v1/last-leg/self-operated-analytics/sync-runs:
get:
summary: 本仓或任务号的尝试历史
description: '纯运行元数据分页。当前尝试读同一attemptNo的task进度,终态尝试只读run冻结快照;心跳过期UNCONFIRMED,不自动改判成功失败。 权限platform:self-operated-analytics:list。'
parameters:
- {$ref: '#/components/parameters/sourceAccount'}
- {$ref: '#/components/parameters/warehouseCode'}
- {$ref: '#/components/parameters/dataFamily'}
- {$ref: '#/components/parameters/taskType'}
- {$ref: '#/components/parameters/status'}
- {$ref: '#/components/parameters/taskNo'}
- {$ref: '#/components/parameters/dateFrom'}
- {$ref: '#/components/parameters/dateUntil'}
- {$ref: '#/components/parameters/current'}
- {$ref: '#/components/parameters/size'}
- {$ref: '#/components/parameters/listUpperCreatedAt'}
- {$ref: '#/components/parameters/listUpperId'}
responses:
'200':
description: '统一ApiResponse,业务失败HTTP200且code非200。'
content:
application/json:
schema:
type: object
properties:
code: {type: string}
message: {type: string}
data: {$ref: '#/components/schemas/AttemptPage'}
'401': {description: 缺少可信认证身份}
'403': {description: 非平台身份或缺少独立只读权限}
/api/platform/v1/last-leg/self-operated-analytics/owners:
get:
summary: 已采集货主编码分页
description: 固定同屏版本,只读权限platform:self-operated-analytics:list。不调用外部API。概览不接受SKU/attention/sortBy/分页/图表范围,候选不存在data为空。
parameters:
- {$ref: '#/components/parameters/sourceAccount'}
- {$ref: '#/components/parameters/warehouseCode'}
- {$ref: '#/components/parameters/salesRunId'}
- {$ref: '#/components/parameters/inventoryRunId'}
- {$ref: '#/components/parameters/salesScopeHash'}
- {$ref: '#/components/parameters/inventoryScopeHash'}
- {$ref: '#/components/parameters/queryAsOf'}
- {$ref: '#/components/parameters/keyword'}
- {$ref: '#/components/parameters/current'}
- {$ref: '#/components/parameters/size'}
responses:
'200':
description: 统一ApiResponse
content:
application/json:
schema:
type: object
properties:
code: {type: string}
message: {type: string}
data: {$ref: '#/components/schemas/OwnerPage'}
'401': {description: 缺少可信认证身份}
'403': {description: 非平台身份或缺少独立只读权限}
/api/platform/v1/last-leg/self-operated-analytics/owner-overview:
get:
summary: 单货主完整候选30日经营概览
description: 固定同屏版本,只读权限platform:self-operated-analytics:list。不调用外部API。概览不接受SKU/attention/sortBy/分页/图表范围,候选不存在data为空。
parameters:
- {$ref: '#/components/parameters/sourceAccount'}
- {$ref: '#/components/parameters/warehouseCode'}
- {$ref: '#/components/parameters/salesRunId'}
- {$ref: '#/components/parameters/inventoryRunId'}
- {$ref: '#/components/parameters/salesScopeHash'}
- {$ref: '#/components/parameters/inventoryScopeHash'}
- {$ref: '#/components/parameters/queryAsOf'}
- {$ref: '#/components/parameters/customerCodeRequired'}
- {$ref: '#/components/parameters/coverageDaysThreshold'}
responses:
'200':
description: 统一ApiResponse
content:
application/json:
schema:
type: object
properties:
code: {type: string}
message: {type: string}
data: {$ref: '#/components/schemas/OwnerOverview'}
'401': {description: 缺少可信认证身份}
'403': {description: 非平台身份或缺少独立只读权限}
components:
securitySchemes:
bearerAuth: {type: http, scheme: bearer, bearerFormat: JWT}
parameters:
keyword: {name: keyword, in: query, schema: {type: string, minLength: 1, maxLength: 64}, description: 区分大小写的货主编码字面前缀,先过滤去重再分页}
attention: {name: attention, in: query, schema: {type: string, default: ALL, enum: [ALL, NO_OUTBOUND_30D, COVERAGE_GT_THRESHOLD, FROZEN_STOCK, DEFECTIVE_STOCK, UNASSESSABLE]}}
sortBy: {name: sortBy, in: query, schema: {type: string, default: AVAILABLE_DESC, enum: [AVAILABLE_DESC, COVERAGE_DAYS_DESC, PHYSICAL_DESC, OUTBOUND_30D_ASC]}, description: 完整候选先筛选后按未舍入值排序分页,未知末尾,同值SKU和货主升序}
coverageDaysThreshold: {name: coverageDaysThreshold, in: query, schema: {type: integer, minimum: 1}, description: COVERAGE_GT_THRESHOLD必填,严格大于且未舍入比较,不设置默认经营政策}
sourceAccount: {name: sourceAccount, in: query, required: true, schema: {type: string, minLength: 1, maxLength: 64}}
warehouseCode: {name: warehouseCode, in: query, required: true, schema: {type: string, minLength: 1, maxLength: 64}}
customerCode: {name: customerCode, in: query, required: false, schema: {type: string, minLength: 1, maxLength: 64}}
sku: {name: sku, in: query, required: false, schema: {type: string, minLength: 1, maxLength: 128}}
rangePreset: {name: rangePreset, in: query, required: false, schema: {type: string, enum: [TODAY, LAST_3_DAYS, THIS_WEEK, LAST_15_DAYS, THIS_MONTH, CUSTOM], default: TODAY}}
startDate: {name: startDate, in: query, required: false, schema: {type: string, format: date}}
endDate: {name: endDate, in: query, required: false, schema: {type: string, format: date}}
bucket: {name: bucket, in: query, required: false, schema: {type: string, enum: [DAY], default: DAY}}
windowDays: {name: windowDays, in: query, required: false, schema: {type: integer, enum: [7, 30], default: 30}}
current: {name: current, in: query, required: false, schema: {type: integer, minimum: 1, default: 1}}
size: {name: size, in: query, required: false, schema: {type: integer, minimum: 1, maximum: 100, default: 20}}
salesRunId: {name: salesRunId, in: query, required: false, schema: {type: string, pattern: '^[0-9]+$'}}
inventoryRunId: {name: inventoryRunId, in: query, required: false, schema: {type: string, pattern: '^[0-9]+$'}}
salesScopeHash: {name: salesScopeHash, in: query, required: false, schema: {type: string, pattern: '^[0-9a-f]{64}$'}}
inventoryScopeHash: {name: inventoryScopeHash, in: query, required: false, schema: {type: string, pattern: '^[0-9a-f]{64}$'}}
queryAsOf: {name: queryAsOf, in: query, required: false, schema: {type: string, format: date-time}}
dataFamily: {name: dataFamily, in: query, required: false, schema: {type: string, enum: [OUTBOUND, INVENTORY]}}
taskType: {name: taskType, in: query, required: false, schema: {type: string}}
status: {name: status, in: query, required: false, schema: {type: string}}
taskNo: {name: taskNo, in: query, required: false, schema: {type: string, maxLength: 64}}
dateFrom: {name: dateFrom, in: query, required: false, schema: {type: string, format: date}}
dateUntil: {name: dateUntil, in: query, required: false, schema: {type: string, format: date}}
listUpperCreatedAt: {name: listUpperCreatedAt, in: query, required: false, schema: {type: string, format: date-time}}
listUpperId: {name: listUpperId, in: query, required: false, schema: {type: string, pattern: '^[0-9]+$'}}
warehouseCodeOptional: {name: warehouseCode, in: query, schema: {type: string, minLength: 1, maxLength: 64}}
customerCodeRequired: {name: customerCode, in: query, required: true, schema: {type: string, minLength: 1, maxLength: 64}}
skuRequired: {name: sku, in: query, required: true, schema: {type: string, minLength: 1, maxLength: 128}}
schemas:
OwnerOption:
type: object
properties:
customerCode: {type: string}
customerName: {type: string, nullable: true}
OwnerPage:
type: object
properties:
context: {$ref: '#/components/schemas/Context'}
records: {type: array, items: {$ref: '#/components/schemas/OwnerOption'}}
current: {type: integer}
size: {type: integer}
total: {type: string}
pages: {type: string}
excludedReasons: {type: object, additionalProperties: {type: string}}
QuantityTotal:
type: object
properties:
overallTotal: {type: number, nullable: true}
knownSubtotal: {type: number, nullable: true}
unknownSkuCount: {type: string}
dataStatus: {type: string, enum: [COMPLETE, PARTIAL, UNKNOWN]}
reasonCodes: {type: array, items: {type: string}}
RiskShare:
type: object
description: 分母为同一OwnerOverview的physicalQuantity。未知时正式命中与比例为空。未设置阈值返回THRESHOLD_NOT_SET。
properties:
matchedSkuCount: {type: string, nullable: true}
matchedPhysicalQuantity: {type: number, nullable: true}
physicalQuantityRatio: {type: number, minimum: 0, maximum: 1, nullable: true}
knownMatchedSkuCount: {type: string, nullable: true}
knownMatchedPhysicalQuantity: {type: number, nullable: true}
unassessableSkuCount: {type: string}
unassessableKnownPhysicalQuantity: {type: number, nullable: true}
reasonCodes: {type: array, items: {type: string}}
OwnerOverview:
type: object
nullable: true
properties:
context: {$ref: '#/components/schemas/Context'}
customerCode: {type: string}
customerName: {type: string, nullable: true}
skuCount: {type: string, nullable: true}
physicalSkuCount: {$ref: '#/components/schemas/QuantityTotal'}
physicalQuantity: {$ref: '#/components/schemas/QuantityTotal'}
availableQuantity: {$ref: '#/components/schemas/QuantityTotal'}
frozenQuantity: {$ref: '#/components/schemas/QuantityTotal'}
defectivePhysicalQuantity: {$ref: '#/components/schemas/QuantityTotal'}
transitQuantity: {$ref: '#/components/schemas/QuantityTotal'}
outboundQuantity30d: {$ref: '#/components/schemas/QuantityTotal'}
averageDailyOutboundQuantity: {$ref: '#/components/schemas/QuantityTotal'}
noOutbound30d: {$ref: '#/components/schemas/RiskShare'}
coverageAboveThreshold: {$ref: '#/components/schemas/RiskShare'}
Context:
type: object
properties:
salesRunId: {type: string, nullable: true}
inventoryRunId: {type: string, nullable: true}
salesScopeHash: {type: string, nullable: true}
inventoryScopeHash: {type: string, nullable: true}
queryAsOf: {type: string, format: date-time, nullable: true}
queryExpiresAt: {type: string, format: date-time, nullable: true}
businessTimezone: {type: string, nullable: true}
anchorDate: {type: string, format: date, nullable: true}
rangeStartDate: {type: string, format: date, nullable: true}
rangeEndDateExclusive: {type: string, format: date, nullable: true}
calculationWindowDays: {type: integer, nullable: true}
completeDayFrom: {type: string, format: date, nullable: true}
completeDayUntil: {type: string, format: date, nullable: true}
salesCoveredFrom: {type: string, format: date-time, nullable: true}
salesCoveredUntil: {type: string, format: date-time, nullable: true}
salesPublishedAt: {type: string, format: date-time, nullable: true}
inventoryObservedFrom: {type: string, format: date-time, nullable: true}
inventoryObservedUntil: {type: string, format: date-time, nullable: true}
salesStatus: {type: string, nullable: true}
inventoryStatus: {type: string, nullable: true}
rebuildRequired: {type: boolean, nullable: true}
revisionReviewStatus: {type: string, nullable: true}
reasonCodes: {type: array, items: {type: string}}
SalesSummary:
type: object
properties:
sourceAccount: {type: string, nullable: true}
warehouseCode: {type: string, nullable: true}
customerCode: {type: string, nullable: true}
sku: {type: string, nullable: true}
productName: {type: string, nullable: true}
quantityUnit: {type: string, nullable: true}
outboundQuantity: {type: number, nullable: true}
observedQuantity: {type: number, nullable: true}
dataStatus: {type: string, nullable: true}
reasonCodes: {type: array, items: {type: string}}
completeDayCount: {type: integer, nullable: true}
partialDayCount: {type: integer, nullable: true}
unknownDayCount: {type: integer, nullable: true}
Point:
type: object
properties:
businessDate: {type: string, format: date, nullable: true}
outboundQuantity: {type: number, nullable: true}
observedQuantity: {type: number, nullable: true}
dataStatus: {type: string, nullable: true}
reasonCodes: {type: array, items: {type: string}}
quantityUnit: {type: string, nullable: true}
coveredFrom: {type: string, format: date-time, nullable: true}
coveredUntil: {type: string, format: date-time, nullable: true}
Trend:
type: object
properties:
context: {$ref: '#/components/schemas/Context'}
summary: {$ref: '#/components/schemas/SalesSummary'}
points: {type: array, items: {$ref: '#/components/schemas/Point'}}
Metric:
type: object
properties:
customerName: {type: string, nullable: true}
defectivePhysicalQuantity: {type: number, nullable: true}
outboundQuantity30d: {type: number, nullable: true}
lastObservedOutboundDate: {type: string, format: date, nullable: true}
observedHistoryStartDate: {type: string, format: date, nullable: true}
attentionReasons: {type: array, items: {type: string}}
quantityStatuses: {type: object, additionalProperties: {type: string, enum: [VALID, UNKNOWN, STALE]}}
sourceAccount: {type: string, nullable: true}
customerCode: {type: string, nullable: true}
warehouseCode: {type: string, nullable: true}
sku: {type: string, nullable: true}
productName: {type: string, nullable: true}
quantityUnit: {type: string, nullable: true}
outboundQuantity: {type: number, nullable: true}
skuOutboundOrderCount: {type: string, nullable: true}
todayObservedQuantity: {type: number, nullable: true}
physicalQuantity: {type: number, nullable: true}
availableQuantity: {type: number, nullable: true}
frozenQuantity: {type: number, nullable: true}
transitQuantity: {type: number, nullable: true}
inventoryObservedAt: {type: string, format: date-time, nullable: true}
averageDailyOutboundQuantity: {type: number, nullable: true}
inventoryCoverageDays: {type: number, nullable: true}
inventoryQuality: {type: string, nullable: true}
salesCoverage: {type: string, nullable: true}
observationEligible: {type: boolean, nullable: true}
earliestReliableEvidenceAt: {type: string, format: date-time, nullable: true}
status: {type: string, nullable: true}
reasonCodes: {type: array, items: {type: string}}
Protection:
type: object
properties:
accountCooldownUntil: {type: string, format: date-time, nullable: true}
accountPauseReason: {type: string, nullable: true}
dailyRequestBudget: {type: integer, nullable: true}
reservedHttpRequests: {type: string, nullable: true}
confirmedHttpRequests: {type: string, nullable: true}
budgetDate: {type: string, format: date, nullable: true}
Validation:
type: object
properties:
validationSessionNo: {type: string, nullable: true}
budgetLimits: {type: object, additionalProperties: {type: string, nullable: true}}
budgetConsumed: {type: object, additionalProperties: {type: string, nullable: true}}
deadlineAt: {type: string, format: date-time, nullable: true}
stopReason: {type: string, nullable: true}
Attempt:
type: object
properties:
runId: {type: string, nullable: true}
taskNo: {type: string, nullable: true}
attemptNo: {type: integer, nullable: true}
status: {type: string, nullable: true}
phase: {type: string, nullable: true}
executionPurpose: {type: string, nullable: true}
startedAt: {type: string, format: date-time, nullable: true}
finishedAt: {type: string, format: date-time, nullable: true}
phaseStartedAt: {type: string, format: date-time, nullable: true}
progressUpdatedAt: {type: string, format: date-time, nullable: true}
heartbeatAt: {type: string, format: date-time, nullable: true}
executionHealth: {type: string, nullable: true}
elapsedSeconds: {type: string, nullable: true}
errorCode: {type: string, nullable: true}
failureSummary: {type: string, nullable: true}
retryable: {type: boolean, nullable: true}
coverageStatus: {type: string, nullable: true}
coveredFrom: {type: string, format: date-time, nullable: true}
coveredUntil: {type: string, format: date-time, nullable: true}
publishedAt: {type: string, format: date-time, nullable: true}
progress: {$ref: '#/components/schemas/Progress'}
Task:
type: object
properties:
taskNo: {type: string, nullable: true}
taskType: {type: string, nullable: true}
dataFamily: {type: string, nullable: true}
warehouseCode: {type: string, nullable: true}
taskRole: {type: string, nullable: true}
executionPurpose: {type: string, nullable: true}
queryFrom: {type: string, format: date-time, nullable: true}
queryUntil: {type: string, format: date-time, nullable: true}
taskStatus: {type: string, nullable: true}
applyState: {type: string, nullable: true}
attemptCount: {type: integer, nullable: true}
latestAttemptNo: {type: integer, nullable: true}
resultPublicationState: {type: string, nullable: true}
resultPublishedRunId: {type: string, nullable: true}
nextRetryAt: {type: string, format: date-time, nullable: true}
allowedActions: {type: array, items: {type: string}}
actionBlockReason: {type: string, nullable: true}
progressUpdatedAt: {type: string, format: date-time, nullable: true}
progress: {$ref: '#/components/schemas/Progress'}
validation: {$ref: '#/components/schemas/Validation'}
latestAttempt: {$ref: '#/components/schemas/Attempt'}
TaskDetail:
type: object
properties:
task: {$ref: '#/components/schemas/Task'}
sharedUpstream: {$ref: '#/components/schemas/Task'}
protection: {$ref: '#/components/schemas/Protection'}
observedAt: {type: string, format: date-time, nullable: true}
InventoryDailySamples:
type: object
nullable: true
description: 仅库存任务族提供。北京时间近30个完整日的正式日代表积累;缺日不补零或沿用旧批次,不是周转率。
required: [windowFrom, windowUntil, expectedDays, sampleCount, missingDates]
properties:
windowFrom: {type: string, format: date, description: 包含起日}
windowUntil: {type: string, format: date, description: 排他上界,即北京时间今日}
expectedDays: {type: integer, enum: [30]}
sampleCount: {type: integer, minimum: 0, maximum: 30}
missingDates: {type: array, items: {type: string, format: date}}
accumulationStartedOn: {type: string, format: date, nullable: true, description: 本仓最早正式日代表日期,无样本时为空}
Warehouse:
type: object
properties:
warehouseCode: {type: string, nullable: true}
warehouseName: {type: string, nullable: true}
dataFamily: {type: string, nullable: true}
executionEnabled: {type: boolean, nullable: true}
publicationEnabled: {type: boolean, nullable: true}
disabledReason: {type: string, nullable: true}
nextScheduledAt: {type: string, format: date-time, nullable: true}
observedAt: {type: string, format: date-time, nullable: true}
initialFrom: {type: string, format: date-time, nullable: true}
initialUntil: {type: string, format: date-time, nullable: true}
initialCoverageStatus: {type: string, nullable: true}
salesCoveredFrom: {type: string, format: date-time, nullable: true}
salesCoveredUntil: {type: string, format: date-time, nullable: true}
lastSuccessfulTaskNo: {type: string, nullable: true}
lastSucceededAt: {type: string, format: date-time, nullable: true}
lastPublishedAt: {type: string, format: date-time, nullable: true}
inventoryObservedFrom: {type: string, format: date-time, nullable: true}
inventoryObservedUntil: {type: string, format: date-time, nullable: true}
dataFreshness: {type: string, nullable: true}
rebuildRequired: {type: boolean, nullable: true}
revisionReviewStatus: {type: string, nullable: true}
inventoryDailySamples: {$ref: '#/components/schemas/InventoryDailySamples'}
currentTask: {$ref: '#/components/schemas/Task'}
sharedUpstream: {$ref: '#/components/schemas/Task'}
protection: {$ref: '#/components/schemas/Protection'}
Overview:
type: object
properties:
sourceAccount: {type: string, nullable: true}
environmentLabel: {type: string, nullable: true}
collectionMode: {type: string, nullable: true}
observedAt: {type: string, format: date-time, nullable: true}
warehouses: {type: array, items: {$ref: '#/components/schemas/Warehouse'}}
Progress:
type: object
properties:
progressScope: {type: string, nullable: true}
countBasis: {type: string, nullable: true}
attemptNo: {type: string, nullable: true}
scanRound: {type: string, nullable: true}
phase: {type: string, nullable: true}
completed: {type: string, nullable: true}
total: {type: string, nullable: true}
totalKnown: {type: boolean, nullable: true}
unit: {type: string, nullable: true}
sliceFrom: {type: string, format: date-time, nullable: true}
sliceUntil: {type: string, format: date-time, nullable: true}
stageStartedAt: {type: string, format: date-time, nullable: true}
stageFinishedAt: {type: string, format: date-time, nullable: true}
validationState: {type: string, nullable: true}
invalidCount: {type: string, nullable: true}
unknownCount: {type: string, nullable: true}
pendingReviewCount: {type: string, nullable: true}
countUnit: {type: string, nullable: true}
summaryAsOf: {type: string, format: date-time, nullable: true}
directoryComplete: {type: boolean, nullable: true}
stages: {type: array, items: {$ref: '#/components/schemas/Progress'}}
SalesPage:
type: object
properties:
context: {$ref: '#/components/schemas/Context'}
records: {type: array, items: {$ref: '#/components/schemas/SalesSummary'}}
current: {type: integer, nullable: true}
size: {type: integer, nullable: true}
total: {type: string, nullable: true}
pages: {type: string, nullable: true}
excludedReasons: {type: object, additionalProperties: {type: string, nullable: true}}
MetricPage:
type: object
properties:
context: {$ref: '#/components/schemas/Context'}
records: {type: array, items: {$ref: '#/components/schemas/Metric'}}
current: {type: integer, nullable: true}
size: {type: integer, nullable: true}
total: {type: string, nullable: true}
pages: {type: string, nullable: true}
excludedReasons: {type: object, additionalProperties: {type: string, nullable: true}}
TaskPage:
type: object
properties:
records: {type: array, items: {$ref: '#/components/schemas/Task'}}
current: {type: integer, nullable: true}
size: {type: integer, nullable: true}
total: {type: string, nullable: true}
listUpperCreatedAt: {type: string, format: date-time, nullable: true}
listUpperId: {type: string, nullable: true}
observedAt: {type: string, format: date-time, nullable: true}
AttemptPage:
type: object
properties:
records: {type: array, items: {$ref: '#/components/schemas/Attempt'}}
current: {type: integer, nullable: true}
size: {type: integer, nullable: true}
total: {type: string, nullable: true}
listUpperCreatedAt: {type: string, format: date-time, nullable: true}
listUpperId: {type: string, nullable: true}
observedAt: {type: string, format: date-time, nullable: true}