feat(phase-5): 后管京东数据库接口与页面+用户端采集入口——v1.4 Phase 5

This commit is contained in:
2026-11-14 12:47:08 +08:00
parent 6ce995f19e
commit ff859d25bc
42 changed files with 4839 additions and 37 deletions
+6
View File
@@ -204,6 +204,12 @@ export const API_ENDPOINTS = {
collectRouting: {
get: '/api/collect-routing',
},
/** 京东店铺商品采集(v1.4):建单走 LOCAL 通道,由本机客户端在已登录京麦的窗口内执行。 */
jdCollect: {
create: '/api/jd-collect/tasks',
heartbeat: '/api/jd-collect/tasks/{taskId}/heartbeat',
chunk: '/api/jd-collect/tasks/{taskId}/chunk',
},
userSecret: {
bundle: '/api/user-secrets',
save: '/api/user-secrets/{moduleKey}',
@@ -0,0 +1,30 @@
import { post, type JavaApiResponse, unwrapJavaResponse } from '../../http.ts'
import { buildJavaUrl } from '../../url.ts'
import { getCurrentUserId } from '../../user.ts'
import { API_ENDPOINTS } from '../../endpoints.ts'
/** 京东店铺采集建单回执(蓝图 §3.2):任务落 PENDING、执行通道固定 LOCAL,由本机客户端领取执行。 */
export interface JdCollectTaskVo {
taskId: number;
taskNo?: string;
collectChannel?: string;
}
/** 可选采集 Tab(京麦商品列表页签):在售中 / 已下架。 */
export type JdListTab = 'ONSALE' | 'OFFSALE'
/**
* 建单(v1.4 AC-1):选择店铺 + 商品 Tab + 采集范围。未选店铺 / 未登记京麦登录态时
* 服务端按蓝图 §3.2 拒绝并返回点名文案(业务码信封,unwrapJavaResponse 抛出)。
*/
export function createJdCollectTask(shopName: string, listTabs: JdListTab[], maxProducts = 0) {
return unwrapJavaResponse(post<JavaApiResponse<JdCollectTaskVo>, Record<string, unknown>>(
buildJavaUrl(API_ENDPOINTS.jdCollect.create),
{
user_id: getCurrentUserId(),
shopName,
listTabs,
maxProducts,
},
))
}