oms/frontend/src/api/externalSendSync.ts
liufumingren e1e3bb638f feat(order): 拉单任务、外部发货同步与取号记录
- 拉单任务:新增 order_sync_tasks 异步任务池,按店铺逐店拉取外部打单平台订单,前端轮询进度
- 外部发货同步:配送后把发货结果同步回店管家,提供数量统计与批量重试(externalSendSync)
- 取号:新增 waybill_fetch_records 记录取号过程,外部快递接口补充菜鸟授权信息
- 补齐相关迁移、订单页同步入口/状态展示,并新增对接说明文档

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-04 20:53:35 +08:00

50 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import request from '@/utils/request'
/**
* 外部打单平台「同步发货」相关接口
*
* 配送后 OMS 需要把发货结果同步回店管家(NewOrder/OnlineSendBatch):
* 失败自动重试,3 次后转异常,人工可在配送视图批量重试。
*/
/** 各同步状态数量 */
export interface ExternalSendCounts {
pending: number
retry: number
exception: number
synced: number
total: number
}
/** 批量重试结果 */
export interface ExternalSendRetryResult {
reset: number
success: number
failed: number
}
/** 同步状态枚举(与后端 SEND_STATUS 对齐) */
export const EXTERNAL_SEND_STATUS_OPTIONS = [
{ value: 0, label: '待同步' },
{ value: 1, label: '已同步' },
{ value: 2, label: '同步失败待重试' },
{ value: 3, label: '同步异常' },
]
/**
* 查询同步状态数量
* @returns 各状态数量
*/
export function getExternalSendCounts() {
return request.get<{ data: ExternalSendCounts }>('/external-send/counts')
}
/**
* 批量重试同步外部发货
* @param ids 订单ID数组(为空时按 statuses 筛选)
* @param statuses 状态筛选(默认 [2,3]:待重试 + 异常)
*/
export function retryExternalSend(ids?: number[], statuses?: number[]) {
return request.post<{ data: ExternalSendRetryResult }>('/external-send/retry', { ids, statuses })
}