/** * 订单管理相关API */ import { get, post } from '@/utils/request'; export interface OrderQueryParams { page?: number; pageSize?: number; orderNo?: string; deviceId?: string; payStatus?: string; status?: number; statusList?: number[]; startDate?: string; endDate?: string; } export interface OrderListResponse { list: any[]; total: number; page: number; pageSize: number; } /** * 获取订单列表 */ export async function getOrderList(params: OrderQueryParams = {}): Promise { const query = { ...params }; if (query.status === -1) { delete (query as any).status; } return get('/order/list', query); } /** * 获取订单详情 */ export async function getOrderDetail(orderId: string): Promise { return get(`/order/${orderId}`); } /** * 获取订单统计 */ export async function getOrderStats(params?: { startDate?: string; endDate?: string }): Promise { return get('/order/statistics', params || {}); } /** * 处理退款(支持部分退款、自定义金额、全额退款) */ export async function handleRefund( orderId: string, reason: string, data?: { products?: { productId: string; productName: string; quantity: number; price: number }[]; refundAmount?: number } ): Promise { const body: any = { reason }; if (data?.products?.length) body.products = data.products; if (data?.refundAmount) body.refundAmount = data.refundAmount; return post(`/order/${orderId}/refund`, body); }