import apiService from './apiClient'; // 地址类型 interface Address { address_id: number; user_id: number; receiver_first_name: string; receiver_last_name: string; country: string; receiver_phone: string; whatsapp_phone: string; province: string | null; city: string | null; district: string | null; detail_address: string | null; is_default: number; create_time: string; update_time: string; } // 订单商品项类型 interface OrderItem { offer_id: number; sku_id: number; product_name: string; sku_image_url: string; product_name_en: string; product_name_fr: string; product_name_ar: string; quantity: number; unit_price: number; total_price: number; attributes:{ attribute_name:string; attribute_name_trans:string, attribute_value:string, attribute_value_trans:string, value:string, value_trans:string, value_trans_ar:string, value_trans_fr:string, }[] } // 订单汇总类型 interface OrderSummary { total_amount: number; shipping_fee: number; discount_amount: number; actual_amount: number; currency: string; } // 完整订单数据类型 export interface OrderData { address: Address; items: OrderItem[]; total_amount: number; shipping_fee: number; discount_amount: number; actual_amount: number; currency: string; shipping_fee_sea: number; shipping_fee_air: number; shipping_fee_sea_time:number shipping_fee_air_time:number } interface CurrentCountryAddress { forwarder_name: string; contact_person: string; phone_number: string; transport_mode: number; shipping_fee: string; status: number; email: string; country: number; country_code: number; province: string; city: string; district: string; detail_address: string; postal_code: string; remarks: string; address_id: number; create_time: string; // or Date if you prefer to use Date objects update_time: string; // or Date if you prefer to use Date objects } export interface AddressDataItem { current_country_address: CurrentCountryAddress; other_addresses: any[]; // or specify a more specific type if you know the structure of other addresses } export interface OrderPreviewData { "items": { "cart_item_id": number }[], } export interface ShippingFeeData { items: { cart_item_id: number }[], country_code?: number } interface CartShippingFeeItem { cart_item_id: number; estimated_shipping_fee_air: number; estimated_shipping_fee_sea: number; shipping_fee_currency: string; } export interface CartShippingFeeData { items: CartShippingFeeItem[]; currency?: string; total_shipping_fee_air: number; total_shipping_fee_sea: number; } export interface DomesticShippingFeeData { currency?: string; total_shipping_fee: number; } export const ordersApi = { getOrders: (data:OrderPreviewData) => apiService.post("/api/orders/preview",data), // 获得价格 freightForwarderAddress: (transport_mode:number | null) => apiService.get(`/api/freight_forwarder_address/?transport_mode=${transport_mode}`), // 获得价格 calcShippingFee: (data:ShippingFeeData) => apiService.post(`/api/orders/calc_shipping_fee`,data), // 获得国内价格 calcDomesticShippingFee: (data:ShippingFeeData) => apiService.post(`/api/orders/calc_domestic_shipping`,data), };