|
|
@@ -1,13 +1,16 @@
|
|
1
|
1
|
import { resolveFileUrl } from '@/utils/image'
|
|
2
|
2
|
import { formatPrice } from '@/utils/format'
|
|
3
|
3
|
import { parseCartSpecText } from '@/utils/cartSpec'
|
|
|
4
|
+import { listAftersales } from '@/api/orderAftersale'
|
|
4
|
5
|
import {
|
|
5
|
6
|
ORDER_ACTION,
|
|
6
|
7
|
ORDER_ACTION_LABEL,
|
|
7
|
8
|
REVIEW_ITEM_STATUS,
|
|
8
|
9
|
AFTERSALE_APPLY_TYPE_OPTIONS,
|
|
|
10
|
+ AFTERSALE_TAB,
|
|
9
|
11
|
ORDER_STATUS,
|
|
10
|
|
- ORDER_AFTERSALE_CARD_LABEL
|
|
|
12
|
+ ORDER_AFTERSALE_CARD_LABEL,
|
|
|
13
|
+ ORDER_AFTERSALE_CARD_STATUS
|
|
11
|
14
|
} from '@/constants/order'
|
|
12
|
15
|
|
|
13
|
16
|
/** 订单级不再展示的评价按钮(改在商品行) */
|
|
|
@@ -82,9 +85,20 @@ function mapOrderItemRow(row) {
|
|
82
|
85
|
}
|
|
83
|
86
|
}
|
|
84
|
87
|
|
|
85
|
|
-function mapActions(actions) {
|
|
|
88
|
+/** 订单已有进行中/已完结售后时,不再展示「申请售后」 */
|
|
|
89
|
+export function hasOrderAftersale(aftersaleStatus) {
|
|
|
90
|
+ const status = aftersaleStatus != null ? String(aftersaleStatus) : ''
|
|
|
91
|
+ return (
|
|
|
92
|
+ status === ORDER_AFTERSALE_CARD_STATUS.IN_PROGRESS ||
|
|
|
93
|
+ status === ORDER_AFTERSALE_CARD_STATUS.FINISHED
|
|
|
94
|
+ )
|
|
|
95
|
+}
|
|
|
96
|
+
|
|
|
97
|
+function mapActions(actions, aftersaleStatus) {
|
|
|
98
|
+ const hideAftersale = hasOrderAftersale(aftersaleStatus)
|
|
86
|
99
|
return (actions || [])
|
|
87
|
100
|
.filter((code) => !ORDER_LEVEL_REVIEW_CODES.includes(code))
|
|
|
101
|
+ .filter((code) => !(hideAftersale && code === ORDER_ACTION.AFTERSALE))
|
|
88
|
102
|
.map((code) => ({
|
|
89
|
103
|
code,
|
|
90
|
104
|
label: ORDER_ACTION_LABEL[code] || code
|
|
|
@@ -92,6 +106,34 @@ function mapActions(actions) {
|
|
92
|
106
|
.filter((item) => item.label)
|
|
93
|
107
|
}
|
|
94
|
108
|
|
|
|
109
|
+/** 详情页补查订单售后态(列表接口有 aftersaleStatus,详情接口暂无) */
|
|
|
110
|
+export async function resolveOrderAftersaleStatus(orderId) {
|
|
|
111
|
+ if (!orderId) return null
|
|
|
112
|
+ try {
|
|
|
113
|
+ const inProgressRes = await listAftersales({
|
|
|
114
|
+ tab: AFTERSALE_TAB.IN_PROGRESS,
|
|
|
115
|
+ pageNum: 1,
|
|
|
116
|
+ pageSize: 100
|
|
|
117
|
+ })
|
|
|
118
|
+ const inProgressRows = inProgressRes.rows || []
|
|
|
119
|
+ if (inProgressRows.some((row) => String(row.orderId) === String(orderId))) {
|
|
|
120
|
+ return ORDER_AFTERSALE_CARD_STATUS.IN_PROGRESS
|
|
|
121
|
+ }
|
|
|
122
|
+ const finishedRes = await listAftersales({
|
|
|
123
|
+ tab: AFTERSALE_TAB.FINISHED,
|
|
|
124
|
+ pageNum: 1,
|
|
|
125
|
+ pageSize: 100
|
|
|
126
|
+ })
|
|
|
127
|
+ const finishedRows = finishedRes.rows || []
|
|
|
128
|
+ if (finishedRows.some((row) => String(row.orderId) === String(orderId))) {
|
|
|
129
|
+ return ORDER_AFTERSALE_CARD_STATUS.FINISHED
|
|
|
130
|
+ }
|
|
|
131
|
+ } catch (e) {
|
|
|
132
|
+ // 查询失败时不阻断详情展示
|
|
|
133
|
+ }
|
|
|
134
|
+ return null
|
|
|
135
|
+}
|
|
|
136
|
+
|
|
95
|
137
|
/** 交易成功商品行:待评价→评价,已评价→查看评价 */
|
|
96
|
138
|
export function getItemReviewAction(item) {
|
|
97
|
139
|
if (!item || !item.reviewStatus) return null
|
|
|
@@ -154,13 +196,20 @@ function trimText(text, maxLen, emptyFallback = '') {
|
|
154
|
196
|
}
|
|
155
|
197
|
|
|
156
|
198
|
/**
|
|
157
|
|
- * 列表卡片状态文案(MO-L4)
|
|
158
|
|
- * 有 aftersaleStatus 时优先展示售后态,否则用订单主状态文案
|
|
|
199
|
+ * 列表卡片状态文案(MO-L4 调整)
|
|
|
200
|
+ * 仅「售后处理中」覆盖主状态;售后已完结后订单应变已关闭,列表不再展示「售后已完成」
|
|
159
|
201
|
*/
|
|
160
|
|
-export function mapOrderCardStatusText(orderStatusText, aftersaleStatus) {
|
|
161
|
|
- if (aftersaleStatus && ORDER_AFTERSALE_CARD_LABEL[aftersaleStatus]) {
|
|
|
202
|
+export function mapOrderCardStatusText(orderStatusText, aftersaleStatus, orderStatus) {
|
|
|
203
|
+ if (aftersaleStatus === ORDER_AFTERSALE_CARD_STATUS.IN_PROGRESS) {
|
|
162
|
204
|
return ORDER_AFTERSALE_CARD_LABEL[aftersaleStatus]
|
|
163
|
205
|
}
|
|
|
206
|
+ if (aftersaleStatus === ORDER_AFTERSALE_CARD_STATUS.FINISHED) {
|
|
|
207
|
+ if (orderStatus === ORDER_STATUS.CLOSED) {
|
|
|
208
|
+ return orderStatusText || '已关闭'
|
|
|
209
|
+ }
|
|
|
210
|
+ // 售后已完结但订单主状态未同步(异常数据)时,仍按已关闭展示
|
|
|
211
|
+ return '已关闭'
|
|
|
212
|
+ }
|
|
164
|
213
|
return orderStatusText || ''
|
|
165
|
214
|
}
|
|
166
|
215
|
|
|
|
@@ -182,8 +231,8 @@ export function mapOrderListRow(row) {
|
|
182
|
231
|
orderStatus: row.orderStatus,
|
|
183
|
232
|
orderStatusText,
|
|
184
|
233
|
aftersaleStatus,
|
|
185
|
|
- statusText: mapOrderCardStatusText(orderStatusText, aftersaleStatus),
|
|
186
|
|
- statusIsAftersale: !!aftersaleStatus,
|
|
|
234
|
+ statusText: mapOrderCardStatusText(orderStatusText, aftersaleStatus, row.orderStatus),
|
|
|
235
|
+ statusIsAftersale: aftersaleStatus === ORDER_AFTERSALE_CARD_STATUS.IN_PROGRESS,
|
|
187
|
236
|
amountLabel: row.orderStatus === ORDER_STATUS.PENDING_PAY ? '应付' : '实付',
|
|
188
|
237
|
shopId: row.shopId,
|
|
189
|
238
|
shopName: row.shopName || '',
|
|
|
@@ -198,15 +247,16 @@ export function mapOrderListRow(row) {
|
|
198
|
247
|
firstItem,
|
|
199
|
248
|
payRemainSeconds: row.payRemainSeconds,
|
|
200
|
249
|
reviewStatus: row.reviewStatus,
|
|
201
|
|
- actions: mapActions(row.actions)
|
|
|
250
|
+ actions: mapActions(row.actions, aftersaleStatus)
|
|
202
|
251
|
}
|
|
203
|
252
|
}
|
|
204
|
253
|
|
|
205
|
|
-/** 详情 VO → 页面模型 */
|
|
206
|
|
-export function mapOrderDetail(data) {
|
|
|
254
|
+/** 详情 VO → 页面模型;options.aftersaleStatus 用于补全售后态并过滤操作按钮 */
|
|
|
255
|
+export function mapOrderDetail(data, options = {}) {
|
|
207
|
256
|
if (!data) return null
|
|
208
|
257
|
const items = (data.items || []).map(mapOrderItemRow).filter(Boolean)
|
|
209
|
258
|
const latestTrace = data.latestTrace || null
|
|
|
259
|
+ const aftersaleStatus = data.aftersaleStatus || options.aftersaleStatus || null
|
|
210
|
260
|
return {
|
|
211
|
261
|
orderId: data.orderId,
|
|
212
|
262
|
orderNo: data.orderNo || '',
|
|
|
@@ -253,7 +303,8 @@ export function mapOrderDetail(data) {
|
|
253
|
303
|
items,
|
|
254
|
304
|
reviewStatus: data.reviewStatus,
|
|
255
|
305
|
reviewId: data.reviewId,
|
|
256
|
|
- actions: mapActions(data.actions)
|
|
|
306
|
+ aftersaleStatus,
|
|
|
307
|
+ actions: mapActions(data.actions, aftersaleStatus)
|
|
257
|
308
|
}
|
|
258
|
309
|
}
|
|
259
|
310
|
|