Files
todo-frontend/api/order.js
2026-03-20 04:59:03 +00:00

63 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import api from './index'
/**
* 订单相关API
* 核心业务:
* - 订单创建:计算原价(total_amount)、优惠金额(discount_amount)、实付金额(actual_amount)
* - 订单原价 = 商品标价 × 数量之和
* - 实付金额 = 原价 - 优惠金额
*/
export default {
/**
* 创建订单
* 请求参数示例:
* {
* customer_id: "CUS001",
* items: [
* { product_id: "PROD001", quantity: 10, price: 50.00 }
* ],
* discount_rate: 90,
* remark: "客户要求送货上门",
* payment_method: "wechat"
* }
*/
createOrder(data) {
return api.request('/orders', 'POST', data)
},
/**
* 获取订单列表
*/
getOrders(params) {
return api.request('/orders', 'GET', params)
},
/**
* 获取订单详情(含明细)
*/
getOrderDetail(id) {
return api.request(`/orders/${id}`, 'GET')
},
/**
* 取消订单
*/
cancelOrder(id) {
return api.request(`/orders/${id}/cancel`, 'PUT')
},
/**
* 退款
*/
refundOrder(id) {
return api.request(`/orders/${id}/refund`, 'PUT')
},
/**
* 订单统计
*/
getStatistics(params) {
return api.request('/orders/statistics', 'GET', params)
}
}