新增接单平台第一期闭环
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import { apiGet, apiPost } from '@/lib/http'
|
||||
import type {
|
||||
CollectField,
|
||||
WorkOrder,
|
||||
WorkerListResponse,
|
||||
WorkerLoginResponse,
|
||||
WorkerUser,
|
||||
} from '@/types/worker-platform'
|
||||
|
||||
export function registerWorker(payload: {
|
||||
username: string
|
||||
password: string
|
||||
displayName?: string
|
||||
phone?: string
|
||||
}) {
|
||||
return apiPost<{ worker: WorkerUser; reviewRequired: boolean }>('/api/v1/worker/auth/register', payload)
|
||||
}
|
||||
|
||||
export function loginWorker(payload: { username: string; password: string }) {
|
||||
return apiPost<WorkerLoginResponse>('/api/v1/worker/auth/login', payload)
|
||||
}
|
||||
|
||||
export function fetchWorkerSession() {
|
||||
return apiGet<{ authenticated: boolean; expiresAt: string; worker: WorkerUser }>('/api/v1/worker/auth/session')
|
||||
}
|
||||
|
||||
export function logoutWorker() {
|
||||
return apiPost<{ success: boolean }>('/api/v1/worker/auth/logout')
|
||||
}
|
||||
|
||||
export function fetchWorkerProfile() {
|
||||
return apiGet<{ worker: WorkerUser; permissions: Record<string, unknown> }>('/api/v1/worker/profile')
|
||||
}
|
||||
|
||||
export function fetchWorkerHallOrders(params?: Record<string, unknown>) {
|
||||
return apiGet<WorkerListResponse<WorkOrder>>('/api/v1/worker/hall/orders', params)
|
||||
}
|
||||
|
||||
export function grabWorkerOrder(workOrderId: number) {
|
||||
return apiPost<{ order: WorkOrder }>(`/api/v1/worker/hall/orders/${workOrderId}/grab`)
|
||||
}
|
||||
|
||||
export function fetchWorkerMyOrders(params?: Record<string, unknown>) {
|
||||
return apiGet<WorkerListResponse<WorkOrder>>('/api/v1/worker/orders', params)
|
||||
}
|
||||
|
||||
export function submitWorkerAcceptance(
|
||||
workOrderId: number,
|
||||
payload: { note?: string; imageUrls?: string[] },
|
||||
) {
|
||||
return apiPost<{ order: WorkOrder }>(`/api/v1/worker/orders/${workOrderId}/submit-acceptance`, payload)
|
||||
}
|
||||
|
||||
export function lookupCollectOrder(orderNo: string) {
|
||||
return apiPost<{
|
||||
order: Pick<WorkOrder, 'workOrderNo' | 'platformOrderId' | 'productName' | 'status'>
|
||||
fields: CollectField[]
|
||||
}>('/api/v1/collect/lookup', { orderNo })
|
||||
}
|
||||
|
||||
export function submitCollectOrder(payload: {
|
||||
orderNo: string
|
||||
fields: Record<string, string>
|
||||
}) {
|
||||
return apiPost<{ complete: boolean; order: Record<string, unknown> }>('/api/v1/collect/submit', payload)
|
||||
}
|
||||
Reference in New Issue
Block a user