2026-05-18 09:46:11 +08:00
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2026-02-27 16:44:41 +08:00
|
|
|
import api from './index'
|
2026-03-27 14:55:41 +08:00
|
|
|
import type { IdType } from '@/utils/id'
|
2026-02-27 16:44:41 +08:00
|
|
|
|
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-02-27 16:44:41 +08:00
|
|
|
interface CreateOrderRequest {
|
2026-03-27 14:55:41 +08:00
|
|
|
couponId?: IdType
|
2026-03-20 12:24:56 +08:00
|
|
|
couponSourceType?: string
|
2026-03-19 14:10:59 +08:00
|
|
|
items: OrderItem[]
|
2026-02-27 16:44:41 +08:00
|
|
|
}
|
|
|
|
|
|
2026-05-18 09:46:11 +08:00
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2026-02-27 16:44:41 +08:00
|
|
|
export const orderApi = {
|
|
|
|
|
// 创建订单
|
2026-05-18 09:46:11 +08:00
|
|
|
/**
|
|
|
|
|
* `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`
|
|
|
|
|
*/
|
2026-02-27 16:44:41 +08:00
|
|
|
createOrder: (data: CreateOrderRequest) => {
|
|
|
|
|
return api.post('/order/create', data)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 获取订单列表
|
2026-03-26 10:28:28 +08:00
|
|
|
getOrderList: async (): Promise<any[]> => {
|
|
|
|
|
return await api.get<any[]>('/order/list') as unknown as any[]
|
2026-02-27 16:44:41 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 获取订单详情
|
2026-05-18 09:46:11 +08:00
|
|
|
/**
|
|
|
|
|
* `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) => {
|
2026-02-27 16:44:41 +08:00
|
|
|
return api.get(`/order/detail/${orderId}`)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 取消订单
|
2026-05-18 09:46:11 +08:00
|
|
|
/**
|
|
|
|
|
* `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) => {
|
2026-02-27 16:44:41 +08:00
|
|
|
return api.put(`/order/cancel/${orderId}`)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 后台获取所有订单
|
2026-05-18 09:46:11 +08:00
|
|
|
/**
|
|
|
|
|
* `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.
|
|
|
|
|
*/
|
2026-02-27 16:44:41 +08:00
|
|
|
getAllOrders: () => {
|
|
|
|
|
return api.get('/order/admin/list')
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 后台处理订单
|
2026-05-18 09:46:11 +08:00
|
|
|
/**
|
|
|
|
|
* `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) => {
|
2026-02-27 16:44:41 +08:00
|
|
|
return api.put(`/order/admin/process/${orderId}`, {}, {
|
|
|
|
|
params: { status }
|
|
|
|
|
})
|
2026-03-19 14:10:59 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 美甲师查看自己的订单
|
2026-05-18 09:46:11 +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
|
|
|
},
|
|
|
|
|
|
2026-05-18 09:46:11 +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}`)
|
2026-05-18 09:46:11 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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[]
|
2026-02-27 16:44:41 +08:00
|
|
|
}
|
|
|
|
|
}
|