feat(mobile): 接入订单支付交接结账与申诉操作
This commit is contained in:
@@ -2,7 +2,15 @@ import { useInfiniteQuery, useQuery } from '@tanstack/react-query'
|
||||
|
||||
import { apiClient, unwrapData } from '@/shared/api/client'
|
||||
import type { ApiResponse } from '@/shared/api/types'
|
||||
import type { UserOrderDetail, UserOrderPage } from '@/features/orders/types'
|
||||
import type {
|
||||
CounterCheckoutPayload,
|
||||
CreateDisputePayload,
|
||||
SubmitCheckoutPayload,
|
||||
UserHandoffRecord,
|
||||
UserOrderDetail,
|
||||
UserOrderPage,
|
||||
UserPayment,
|
||||
} from '@/features/orders/types'
|
||||
|
||||
export const MY_ORDER_PAGE_SIZE = 20
|
||||
|
||||
@@ -45,3 +53,66 @@ export function useMyOrder(id?: string, enabled = true) {
|
||||
export async function cancelMyOrder(id: number | string) {
|
||||
await apiClient.post(`/orders/${id}/cancel`)
|
||||
}
|
||||
|
||||
export async function startOrderPayment(id: number | string, payWay: 'WXZF' | 'ZFBZF') {
|
||||
return unwrapData<UserPayment>(
|
||||
apiClient.post<ApiResponse<UserPayment>>(`/orders/${id}/start-payment`, {
|
||||
pay_way: payWay,
|
||||
jspay_flag: '',
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
export async function queryOrderPayment(id: number | string) {
|
||||
return unwrapData<UserPayment>(
|
||||
apiClient.get<ApiResponse<UserPayment>>(`/orders/${id}/query-payment`)
|
||||
)
|
||||
}
|
||||
|
||||
export async function submitHandoff(id: number | string, content: string) {
|
||||
return unwrapData<UserHandoffRecord>(
|
||||
apiClient.post<ApiResponse<UserHandoffRecord>>(`/orders/${id}/handoff`, { content })
|
||||
)
|
||||
}
|
||||
|
||||
export async function confirmReceive(id: number | string) {
|
||||
await apiClient.post(`/orders/${id}/confirm-receive`)
|
||||
}
|
||||
|
||||
export function fetchHandoffRecords(id: number | string) {
|
||||
return unwrapData<{ items?: UserHandoffRecord[] }>(
|
||||
apiClient.get<ApiResponse<{ items?: UserHandoffRecord[] }>>(`/orders/${id}/handoff-records`)
|
||||
).then(data => data.items ?? [])
|
||||
}
|
||||
|
||||
export function useHandoffRecords(id?: string, enabled = true) {
|
||||
return useQuery({
|
||||
queryKey: ['my-order-handoffs', id],
|
||||
queryFn: () => fetchHandoffRecords(id as string),
|
||||
enabled: Boolean(id) && enabled,
|
||||
})
|
||||
}
|
||||
|
||||
export async function submitCheckout(id: number | string, payload: SubmitCheckoutPayload) {
|
||||
await apiClient.post(`/orders/${id}/checkout`, payload)
|
||||
}
|
||||
|
||||
export async function confirmCheckout(id: number | string) {
|
||||
await apiClient.post(`/orders/${id}/checkout/confirm`)
|
||||
}
|
||||
|
||||
export async function counterCheckout(id: number | string, payload: CounterCheckoutPayload) {
|
||||
await apiClient.post(`/orders/${id}/checkout/counter`, payload)
|
||||
}
|
||||
|
||||
export async function acceptCheckout(id: number | string) {
|
||||
await apiClient.post(`/orders/${id}/checkout/accept`)
|
||||
}
|
||||
|
||||
export async function createOrderDispute(id: number | string, payload: CreateDisputePayload) {
|
||||
await apiClient.post(`/orders/${id}/dispute`, payload)
|
||||
}
|
||||
|
||||
export async function cancelOrderDispute(id: number | string) {
|
||||
await apiClient.post(`/orders/${id}/dispute/cancel`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user