Files
JayuCloud/YumiNail-Frontend/src/api/order.ts
T

277 lines
11 KiB
TypeScript
Raw Normal View History

/**
* Front-end API wrapper for this module.
* Call guide: import the named API object, then call the matching method from a Vue page or composable.
*/
import api from './index'
2026-03-27 14:55:41 +08:00
import type { IdType } from '@/utils/id'
2026-05-23 18:44:57 +08:00
/**
* Purpose: OrderItem supports order.ts by holding or executing the order item page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-03-19 14:10:59 +08:00
interface OrderItem {
2026-03-27 14:55:41 +08:00
productId: IdType
2026-03-19 14:10:59 +08:00
quantity: number
2026-03-27 14:55:41 +08:00
artistId?: IdType
2026-03-19 20:19:41 +08:00
appointmentTime?: string
2026-03-19 14:10:59 +08:00
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: CreateOrderRequest supports order.ts by holding or executing the create order request page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
interface CreateOrderRequest {
2026-03-27 14:55:41 +08:00
couponId?: IdType
couponSourceType?: string
2026-03-19 14:10:59 +08:00
items: OrderItem[]
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: ArtistCalendarAppointment supports order.ts by holding or executing the artist calendar appointment page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
export interface ArtistCalendarAppointment {
orderId: IdType
orderNo: string
totalAmount?: number
actualAmount?: number
orderStatus: number
orderStatusText: string
orderItemId: IdType
productId: IdType
productTitle: string
artistId: IdType
artistName?: string
customerNickname?: string
customerPhoneMasked?: string
shopId?: IdType
shopName?: string
appointmentStartTime: string
appointmentEndTime: string
quantity: number
durationMinutes: number
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: OrderArtistReviewVO supports order.ts by holding or executing the order artist review vo page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-23 15:16:40 +08:00
export interface OrderArtistReviewVO {
id: IdType
orderId: IdType
orderItemId: IdType
productId?: IdType
productTitle?: string
artistId?: IdType
artistName?: string
artistAvatar?: string
userId?: IdType
rating?: number
content?: string
imageFileIds?: IdType[]
status?: number
statusText?: string
submitTime?: string
createTime?: string
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: OrderArtistReviewSubmitRequest supports order.ts by holding or executing the order artist review submit request page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-23 15:16:40 +08:00
export interface OrderArtistReviewSubmitRequest {
rating: number
content?: string
imageFileIds: IdType[]
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: OrderArtistChangeOptionsVO supports order.ts by holding or executing the order artist change options vo page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-23 15:16:40 +08:00
export interface OrderArtistChangeOptionsVO {
orderId: IdType
orderItemId: IdType
currentArtistId?: IdType
currentArtistName?: string
artists: Array<{
artistId: IdType
artistName: string
artistAvatar?: string
userType?: number
participateProduction?: boolean
}>
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: OrderArtistChangeRequestVO supports order.ts by holding or executing the order artist change request vo page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-23 15:16:40 +08:00
export interface OrderArtistChangeRequestVO {
id: IdType
orderId: IdType
orderItemId: IdType
productId?: IdType
productTitle?: string
shopId?: IdType
userId?: IdType
originalArtistId?: IdType
originalArtistName?: string
requestedArtistId?: IdType
requestedArtistName?: string
status?: string
statusText?: string
reason?: string
rejectReason?: string
reviewerId?: IdType
reviewTime?: string
createTime?: string
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: OrderArtistChangeRequestSubmitRequest supports order.ts by holding or executing the order artist change request submit request page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-23 15:16:40 +08:00
export interface OrderArtistChangeRequestSubmitRequest {
orderId: IdType
orderItemId: IdType
requestedArtistId: IdType
reason: string
}
2026-05-23 18:44:57 +08:00
/**
* Purpose: OrderArtistChangeRejectRequest supports order.ts by holding or executing the order artist change reject request page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-23 15:16:40 +08:00
export interface OrderArtistChangeRejectRequest {
rejectReason?: string
}
/**
* orderApi groups all API calls for this page domain.
* Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script.
*/
export const orderApi = {
// 创建订单
/**
* `createOrder` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
* @param data: CreateOrderRequest caller-supplied value for `data: CreateOrderRequest`
*/
createOrder: (data: CreateOrderRequest) => {
return api.post('/order/create', data)
},
// 获取订单列表
getOrderList: async (): Promise<any[]> => {
return await api.get<any[]>('/order/list') as unknown as any[]
},
2026-05-23 15:16:40 +08:00
getMyPendingReviews: async (): Promise<OrderArtistReviewVO[]> => {
return await api.get<OrderArtistReviewVO[]>('/order/review/my-pending') as unknown as OrderArtistReviewVO[]
},
getOrderReviews: async (orderId: IdType): Promise<OrderArtistReviewVO[]> => {
return await api.get<OrderArtistReviewVO[]>(`/order/${orderId}/reviews`) as unknown as OrderArtistReviewVO[]
},
submitArtistReview: async (reviewId: IdType, data: OrderArtistReviewSubmitRequest): Promise<OrderArtistReviewVO> => {
return await api.post<OrderArtistReviewVO>(`/order/review/${reviewId}/submit`, data) as unknown as OrderArtistReviewVO
},
getArtistChangeOptions: async (orderId: IdType, orderItemId: IdType): Promise<OrderArtistChangeOptionsVO> => {
return await api.get<OrderArtistChangeOptionsVO>(`/order/${orderId}/artist-change/options`, {
params: { orderItemId }
}) as unknown as OrderArtistChangeOptionsVO
},
requestArtistChange: async (data: OrderArtistChangeRequestSubmitRequest): Promise<OrderArtistChangeRequestVO> => {
return await api.post<OrderArtistChangeRequestVO>('/order/artist-change/request', data) as unknown as OrderArtistChangeRequestVO
},
getMyPendingArtistChangeRequests: async (): Promise<OrderArtistChangeRequestVO[]> => {
return await api.get<OrderArtistChangeRequestVO[]>('/order/artist-change/my-pending') as unknown as OrderArtistChangeRequestVO[]
},
approveArtistChange: async (requestId: IdType): Promise<OrderArtistChangeRequestVO> => {
return await api.put<OrderArtistChangeRequestVO>(`/order/artist-change/${requestId}/approve`) as unknown as OrderArtistChangeRequestVO
},
rejectArtistChange: async (requestId: IdType, data?: OrderArtistChangeRejectRequest): Promise<OrderArtistChangeRequestVO> => {
return await api.put<OrderArtistChangeRequestVO>(`/order/artist-change/${requestId}/reject`, data || {}) as unknown as OrderArtistChangeRequestVO
},
// 获取订单详情
/**
* `getOrderDetail` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
* @param orderId: IdType caller-supplied value for `orderId: IdType`
*/
2026-03-27 14:55:41 +08:00
getOrderDetail: (orderId: IdType) => {
return api.get(`/order/detail/${orderId}`)
},
// 取消订单
/**
* `cancelOrder` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
* @param orderId: IdType caller-supplied value for `orderId: IdType`
*/
2026-03-27 14:55:41 +08:00
cancelOrder: (orderId: IdType) => {
return api.put(`/order/cancel/${orderId}`)
},
// 后台获取所有订单
/**
* `getAllOrders` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
*/
getAllOrders: () => {
return api.get('/order/admin/list')
},
// 后台处理订单
/**
* `processOrder` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
* @param orderId: IdType caller-supplied value for `orderId: IdType`
* @param status: number caller-supplied value for `status: number`
*/
2026-03-27 14:55:41 +08:00
processOrder: (orderId: IdType, status: number) => {
return api.put(`/order/admin/process/${orderId}`, {}, {
params: { status }
})
2026-03-19 14:10:59 +08:00
},
// 美甲师查看自己的订单
/**
* `getArtistOrders` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
*/
2026-03-19 14:10:59 +08:00
getArtistOrders: () => {
return api.get('/order/artist/list')
2026-03-19 20:19:41 +08:00
},
// 预约日历:recent 取未来 7 天概览,day 传 yyyy-MM-dd 查某天明细。
/**
* `completeArtistOrder` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
* @param orderId: IdType caller-supplied value for `orderId: IdType`
*/
2026-03-27 14:55:41 +08:00
completeArtistOrder: (orderId: IdType) => {
2026-03-19 20:19:41 +08:00
return api.put(`/order/artist/complete/${orderId}`)
},
getArtistCalendarRecent: async (days = 7): Promise<ArtistCalendarAppointment[]> => {
return await api.get<ArtistCalendarAppointment[]>('/order/artist/calendar/recent', {
params: { days }
}) as unknown as ArtistCalendarAppointment[]
},
getArtistCalendarDay: async (date: string): Promise<ArtistCalendarAppointment[]> => {
return await api.get<ArtistCalendarAppointment[]>('/order/artist/calendar/day', {
params: { date }
}) as unknown as ArtistCalendarAppointment[]
}
}