store.ts
2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// 门店上架业务接口(PRD §5/§6,端点以实际后端为准)
// 继承 ApiClient,共享 http 与 RSA 加签/验签。
import { ApiClient } from '../core/client';
import type { PageResult } from '../core/types';
// ---------- 门店列表(PRD §5.3 已生效门店) ----------
export interface StoreListingRow {
id: string;
storeName: string;
merchantNo: string;
city?: string;
businessScene?: string;
status?: string;
owner?: string;
}
export interface ListingPageParams {
pageNum?: number;
pageSize?: number;
storeName?: string;
merchantNo?: string;
status?: string;
businessScene?: string;
}
// ---------- 门店导入(PRD §5.1 四步:下载→校验→确认→提交审批) ----------
/** 模板下载(免签,浏览器直链 / 网关暴露,§4.3) */
export const STORE_IMPORT_TEMPLATE_URL = '/api/store/import/template';
export interface ImportSubmitPayload {
taskId: string;
storeName: string;
businessScene: string;
[key: string]: unknown;
}
// ---------- 门店审批(PRD §5.2 三页签) ----------
export type ApproveTab = 'todo' | 'done' | 'mine';
export interface ApproveRow {
id: string;
storeName: string;
merchantNo: string;
categories: string[];
scene: string;
cost: number | null;
submitter: string;
submittedAt: string;
stayHours: number;
}
class Store extends ApiClient {
listStores(params: ListingPageParams = {}) {
return this.get<PageResult<StoreListingRow>>(
'/store/listing/page',
params as Record<string, unknown>,
);
}
/** 上传模板文件做五级校验(FormData,请求体不参与签名,§3.1/§9.6) */
uploadImport(file: File, templateVersion = 'V1.0.1') {
const form = new FormData();
form.append('file', file);
form.append('templateVersion', templateVersion);
return this.post<{ taskId: string }>('/store/import/check', form);
}
/** 提交导入审批(单级审批,通过后生效,§4.3) */
submitImport(payload: ImportSubmitPayload) {
return this.post<{ approveId: string }>('/store/import/submit', payload);
}
listApprovals(tab: ApproveTab, params: Record<string, unknown> = {}) {
return this.get<PageResult<ApproveRow>>('/store/approve/page', { tab, ...params });
}
approve(id: string, action: 'pass' | 'reject', comment?: string) {
return this.post<null>(`/store/approve/${id}/${action}`, { comment });
}
}
export const store = new Store();