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`)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,12 @@ export interface UserCheckout {
|
||||
status: string
|
||||
round_count: number
|
||||
max_rounds: number
|
||||
turn?: string
|
||||
proposed_by?: number
|
||||
can_counter?: boolean
|
||||
can_accept?: boolean
|
||||
content: string
|
||||
evidence_urls?: string[]
|
||||
consumable_amount_cent: number
|
||||
coin_consumed_m: number
|
||||
other_amount_cent: number
|
||||
@@ -51,7 +56,9 @@ export interface UserActiveDispute {
|
||||
id: number
|
||||
type: string
|
||||
status: string
|
||||
initiator_id: number
|
||||
initiator_type: string
|
||||
initiator_admin_id?: number | null
|
||||
}
|
||||
|
||||
export interface UserOrderDetail {
|
||||
@@ -87,3 +94,51 @@ export interface UserOrderDetail {
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface UserHandoffRecord {
|
||||
id: number
|
||||
order_id: number
|
||||
from_user_id: number
|
||||
to_user_id: number
|
||||
type: string
|
||||
content: string
|
||||
confirmed_by_renter_at?: string | null
|
||||
confirmed_by_owner_at?: string | null
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface UserPayment {
|
||||
id: number
|
||||
payment_no: string
|
||||
order_id: number
|
||||
order_no: string
|
||||
provider: string
|
||||
pay_way: string
|
||||
amount_cent: number
|
||||
status: string
|
||||
td_code?: string
|
||||
jspay_url?: string
|
||||
jspay_info?: string
|
||||
paid: boolean
|
||||
paid_at?: string | null
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export interface SubmitCheckoutPayload {
|
||||
content: string
|
||||
consumable_amount_cent: number
|
||||
coin_consumed_m: number
|
||||
other_amount_cent: number
|
||||
evidence_urls: string[]
|
||||
}
|
||||
|
||||
export interface CounterCheckoutPayload extends SubmitCheckoutPayload {
|
||||
deposit_deduct_amount_cent: number
|
||||
reason: string
|
||||
}
|
||||
|
||||
export interface CreateDisputePayload {
|
||||
type: string
|
||||
description: string
|
||||
evidence_urls: string[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user