p-honggang.li
9 天以前 bd125eecd57d2f4e559c6170d20157591300fe3d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import createAxios from '@/utils/axios'
 
// 与其他模块保持一致,经过网关以 /admin/api 为前缀
const url = '/admin/api/order'
 
const orderApi = {
  // 获取一次性防重复提交 Token
  getIdempotencyToken(userId?: number): ApiPromise {
    return createAxios({
      url: `${url}/idempotency/token`,
      method: 'get',
      params: userId ? { userId } : {}
    }) as ApiPromise
  },
 
  // 创建订单(在 headers 中携带 Idempotency-Token)
  createOrder(data: any, token: string): ApiPromise {
    return createAxios({
      url: `${url}/create`,
      method: 'post',
      data,
      headers: { 'Idempotency-Token': token }
    }) as ApiPromise
  },
   getBuyerOrderPage(data: any): ApiPromise {
    return createAxios({
      url: `${url}/buyer/page`,
      method: 'post',
      data
    }) as ApiPromise
  },
  getBuyerOrderPageWithProductConditions(data: any): ApiPromise {
    return createAxios({
      url: `${url}/buyer/page/with-product-conditions`,
      method: 'post',
      data
    }) as ApiPromise
  },
  getSellerOrderPage(data: any): ApiPromise {
    return createAxios({
      url: `${url}/seller/page`,
      method: 'post',
      data
    }) as ApiPromise
  },
  getSellerOrderPageWithProductConditions(data: any): ApiPromise {
    return createAxios({
      url: `${url}/seller/page/with-product-conditions`,
      method: 'post',
      data
    }) as ApiPromise
  },
  getOrderDetail(orderId: string): ApiPromise {
    return createAxios({
      url: `${url}/detail/${orderId}`,
      method: 'get'
    }) as ApiPromise
  },
  generateOrderNo(): ApiPromise {
    return createAxios({
      url: `${url}/no/new`,
      method: 'get'
    }) as ApiPromise
  },
  
  updateOrderDetail(data: any): ApiPromise {
    return createAxios({
      url: `${url}/detail/update`,
      method: 'post',
      data
    }) as ApiPromise
  },
  
  updateOrderDetailRemarksOnly(data: any): ApiPromise {
    return createAxios({
      url: `${url}/detail/remarks/update`,
      method: 'post',
      data
    }) as ApiPromise
  },
  
  confirmTransaction(orderId: string, userId: number): ApiPromise {
    return createAxios({
      url: `${url}/transaction/confirm`,
      method: 'post',
      params: {
        orderId,
        userId
      }
    }) as ApiPromise
  },
  
  submitEvaluation(data: any): ApiPromise {
    return createAxios({
      url: `${url}/evaluation/add`,
      method: 'post',
      params: {
        orderId: data.orderId,
        evaluatorId: data.evaluatorId,
        evaluatorName: data.evaluatorName,
        evaluatorType: '买家', // 默认评价人类型为买家
        content: data.evaluationContent,
        rating: data.overallRating,
        serviceRating: data.serviceRating,
        qualityRating: data.qualityRating,
        deliveryRating: data.speedRating, // 速度评分对应后端的交付评分
        isAnonymous: data.isAnonymous
      }
    }) as ApiPromise
  },
  
  // 取消订单
  cancelOrder(orderId: string): ApiPromise {
    return createAxios({
      url: `${url}/cancel/${orderId}`,
      method: 'delete'
    }) as ApiPromise
  },
  
  checkAgreementPriceType(orderId: string): ApiPromise {
    return createAxios({
      url: `${url}/agreement/check/${orderId}`,
      method: 'get'
    }) as ApiPromise
  },
 
  updateOrderStatusToIsEvaluate(orderId: string): ApiPromise {
    return createAxios({
      url: `${url}/status/isEvaluate`,
      method: 'post',
      params: {
        orderId
      }
    }) as ApiPromise
  },
 
  updateOrderStatusToNext(orderId: string): ApiPromise {
    return createAxios({
      url: `${url}/status/next`,
      method: 'post',
      params: {
        orderId
      }
    }) as ApiPromise
  },
  
  updateOrderStatusToPrevious(orderId: string): ApiPromise {
    return createAxios({
      url: `${url}/status/previous`,
      method: 'post',
      params: {
        orderId
      }
    }) as ApiPromise
  },
 
  // 更新订单的工作流ID
  updateWorkflowId(orderId: string, workflowId: string): ApiPromise {
    return createAxios({
      url: `${url}/workflow/update`,
      method: 'post',
      params: { orderId, workflowId }
    }) as ApiPromise
  }
}
 
export default orderApi