Files
JayuCloud/JC-ArtList-Frontend/src/api/order.ts
T

399 lines
13 KiB
TypeScript

/**
* 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'
import type { IdType } from '@/utils/id'
/**
* 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.
*/
export interface OrderItem {
productId: IdType
quantity: number
artistId?: IdType
appointmentTime?: string
}
/**
* 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.
*/
export interface CreateOrderRequest {
couponId?: IdType
couponSourceType?: string
remark?: string
clientRequestId?: string
items: OrderItem[]
}
export type CheckoutPreviewRequest = CreateOrderRequest
export interface CheckoutCouponPreview {
id: IdType
couponId?: IdType
userCouponId?: IdType
sourceType?: string
couponName: string
couponType: number
couponTypeName?: string
discountValue?: number
minAmount?: number
reduceAmount?: number
discountAmount?: number
available?: boolean
best?: boolean
vipAuto?: boolean
displayText?: string
savingText?: string
unavailableReason?: string
startTime?: string
endTime?: string
}
export interface CheckoutIssue {
code: string
message: string
itemId?: IdType
productId?: IdType
productTitle?: string
}
export interface CheckoutPreview {
subtotalAmount: number
savedAmount: number
payableAmount: number
bestCoupon?: CheckoutCouponPreview
availableCoupons: CheckoutCouponPreview[]
unavailableCoupons: CheckoutCouponPreview[]
bookingAvailable?: boolean
bookingIssues?: CheckoutIssue[]
vipTip?: string
summaryText?: string
}
export interface PaymentOrderVO {
id: IdType
payNo?: string
orderId: IdType
orderNo?: string
userId?: IdType
shopId?: IdType
channel?: string
status?: string
payAmount?: number
paidAmount?: number
payTime?: string
expireTime?: string
remark?: string
}
export interface OrderQuoteItem {
orderItemId: IdType
quotedPrice?: number
}
export interface OrderQuoteSubmitRequest {
remark?: string
items: OrderQuoteItem[]
}
export interface OrderQuoteReplyRequest {
remark?: string
}
export interface OrderQuoteMessage {
id: IdType
orderId: IdType
actorId?: IdType
actorType?: string
actorTypeText?: string
action?: string
actionText?: string
remark?: string
items?: any[]
createTime?: string
}
export interface AfterSaleApplyRequest {
orderId: IdType
orderItemId?: IdType
type: string
reason: string
refundAmount?: number
}
export interface AfterSaleVO {
id: IdType
afterSaleNo?: string
orderId: IdType
orderItemId?: IdType
userId?: IdType
shopId?: IdType
type?: string
reason?: string
refundAmount?: number
status?: string
auditReason?: string
auditTime?: string
createTime?: string
}
export interface PageResult<T> {
list: T[]
total: number
page: number
size: number
}
export interface GrowthSummaryVO {
userId?: IdType
growthValue?: number
levelName?: string
appointmentCount?: number
reviewCount?: number
}
export const paymentApi = {
prepareOrderPayment: async (orderId: IdType): Promise<PaymentOrderVO> => {
return await api.post<PaymentOrderVO>(`/payment/order/${orderId}/prepare`) as unknown as PaymentOrderVO
},
mockSuccess: async (orderId: IdType): Promise<PaymentOrderVO> => {
return await api.post<PaymentOrderVO>(`/payment/order/${orderId}/mock-success`) as unknown as PaymentOrderVO
}
}
export const afterSaleApi = {
apply: async (data: AfterSaleApplyRequest): Promise<AfterSaleVO> => {
return await api.post<AfterSaleVO>('/after-sale/apply', data) as unknown as AfterSaleVO
},
listMy: async (params: { page: number; size: number }): Promise<PageResult<AfterSaleVO>> => {
return await api.get<PageResult<AfterSaleVO>>('/after-sale/my', { params }) as unknown as PageResult<AfterSaleVO>
}
}
export const growthApi = {
getSummary: async (): Promise<GrowthSummaryVO> => {
return await api.get<GrowthSummaryVO>('/growth/summary') as unknown as GrowthSummaryVO
}
}
/**
* 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.
*/
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
reviewTime?: string
createTime?: string
}
/**
* 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.
*/
export interface OrderArtistReviewSubmitRequest {
rating: number
content?: string
imageFileIds: IdType[]
}
/**
* 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.
*/
export interface OrderArtistChangeOptionsVO {
orderId: IdType
orderItemId: IdType
currentArtistId?: IdType
currentArtistName?: string
artists: Array<{
artistId: IdType
artistName: string
artistAvatar?: string
userType?: number
participateProduction?: boolean
}>
}
/**
* 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.
*/
export interface OrderArtistChangeRequestVO {
id: IdType
orderId: IdType
orderItemId: IdType
productId?: IdType
productTitle?: string
shopId?: IdType
userId?: IdType
customerId?: IdType
originalArtistId?: IdType
originalArtistName?: string
requestedArtistId?: IdType
requestedArtistName?: string
fromArtistId?: IdType
fromArtistName?: string
toArtistId?: IdType
toArtistName?: string
requesterId?: IdType
requesterName?: string
status?: string
statusText?: string
reason?: string
rejectReason?: string
appointmentTime?: string
timeAffected?: boolean
timeImpactText?: string
originalPrice?: number | string
newPrice?: number | string
priceAffected?: boolean
priceImpactText?: string
reviewerId?: IdType
messageId?: IdType
reviewTime?: string
approvedTime?: string
rejectedTime?: string
expireTime?: string
createTime?: string
}
/**
* 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.
*/
export interface OrderArtistChangeRequestSubmitRequest {
orderId: IdType
orderItemId: IdType
requestedArtistId: IdType
reason: string
}
/**
* 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.
*/
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)
},
createInquiryAppointment: (data: CreateOrderRequest) => {
return api.post('/order/create', data)
},
checkoutPreview: async (data: CheckoutPreviewRequest): Promise<CheckoutPreview> => {
return await api.post<CheckoutPreview>('/order/checkout-preview', data) as unknown as CheckoutPreview
},
replyQuote: async (orderId: IdType, data?: OrderQuoteReplyRequest): Promise<any> => {
return await api.post(`/order/${orderId}/quote/reply`, data || {}) as unknown as any
},
confirmUserQuote: async (orderId: IdType): Promise<any> => {
return await api.put(`/order/${orderId}/quote/confirm`) as unknown as any
},
submitShopQuote: async (orderId: IdType, data: OrderQuoteSubmitRequest): Promise<any> => {
return await api.post(`/order/${orderId}/quote/shop`, data) as unknown as any
},
confirmShopQuote: async (orderId: IdType): Promise<any> => {
return await api.put(`/order/${orderId}/quote/shop/confirm`) as unknown as any
},
// 获取订单列表
getOrderList: async (): Promise<any[]> => {
return await api.get<any[]>('/order/list') as unknown as any[]
},
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[]
},
getOrderArtistChangeRequests: async (orderId: IdType): Promise<OrderArtistChangeRequestVO[]> => {
return await api.get<OrderArtistChangeRequestVO[]>(`/order/${orderId}/artist-change/requests`) 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`
*/
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`
*/
cancelOrder: (orderId: IdType) => {
return api.put(`/order/cancel/${orderId}`)
},
}