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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
| import { getRefundDetailById, refundAudit } from '../service';
| import { Modal, Descriptions, Image, Table, Typography, Form, Input, Button, Radio, message } from 'antd';
| import { useEffect, useState } from 'react';
| import moment from 'moment';
|
| const { Text } = Typography;
|
| const RefundDetailModal = ({ visible, onCancel, id, onRefresh }) => {
| const [orderDetail, setOrderDetail] = useState(null);
| const [loading, setLoading] = useState(false);
| const [auditForm] = Form.useForm();
| const [auditLoading, setAuditLoading] = useState(false);
|
| // 订单状态映射
| const statusMap = {
| 1: '待付款',
| 2: '已付订金',
| 3: '完成支付',
| 4: '确认收货',
| 5: '已退款',
| };
|
| // 审核状态映射
| const auditStatusMap = {
| 1: '待审核',
| 2: '审核通过',
| 3: '审核驳回',
| };
|
| // 支付类型映射
| const paymentTypeMap = {
| 1: '订金+尾款',
| 2: '全款',
| };
|
| // 获取订单详情
| const fetchOrderDetail = async () => {
| if (!id) return;
|
| setLoading(true);
| try {
| const res = await getRefundDetailById(id);
| if (res.code === 200 && res.data) {
| setOrderDetail(res.data);
| }
| } catch (error) {
| console.error('获取订单详情失败:', error);
| } finally {
| setLoading(false);
| }
| };
|
| // 审核提交
| const handleAuditSubmit = async () => {
| try {
| const values = await auditForm.validateFields();
| setAuditLoading(true);
|
| const params = {
| id,
| auditStatus: values.auditStatus,
| auditRemark: values.auditRemark,
| };
|
| const res = await refundAudit(params);
|
| if (res.code === 200) {
| message.success('审核成功');
| // 关闭弹窗
| onCancel();
| // 触发父组件刷新列表
| if (onRefresh) {
| onRefresh();
| }
| } else {
| message.error(res.msg || '审核失败');
| }
| } finally {
| setAuditLoading(false);
| }
| };
|
| useEffect(() => {
| if (visible && id) {
| fetchOrderDetail();
| }
| }, [visible, id]);
|
| // 渲染商品信息表格
| const renderProductTable = () => {
| const columns = [
| {
| title: '商品名称',
| dataIndex: 'bigGiftPackageName',
| width: 200,
| },
| {
| title: '封面图',
| dataIndex: 'bigGiftPackageCover',
| width: 100,
| render: (text) => (
| <Image
| width={60}
| height={60}
| src={text ? IMAGE_URL + text : null}
| style={{ objectFit: 'cover' }}
| placeholder={<div style={{ width: 60, height: 60, background: '#f5f5f5' }} />}
| fallback="/images/default-image.png"
| />
| ),
| },
| {
| title: '商品价格',
| dataIndex: 'bigGiftPackagePrice',
| width: 120,
| render: (text) => `¥${text || 0}`,
| },
| {
| title: '商品简介',
| dataIndex: 'bigGiftPackageIntro',
| ellipsis: true,
| },
| {
| title: '销量',
| dataIndex: 'bigGiftPackageSales',
| width: 80,
| },
| ];
|
| const dataSource = [{
| key: orderDetail?.id,
| ...orderDetail,
| }];
|
| return (
| <Table
| columns={columns}
| dataSource={dataSource}
| pagination={false}
| size="small"
| />
| );
| };
|
| // 渲染详情内容
| const renderDetailContent = () => {
| if (!orderDetail) return null;
|
| const { status, paymentType, refundStatus } = orderDetail;
|
| // 基础字段(所有状态都显示)
| const baseItems = [
| {
| label: '订单编号',
| children: orderDetail.code || '-',
| },
| {
| label: '下单时间',
| children: orderDetail.createTime ? moment(orderDetail.createTime).format('YYYY-MM-DD HH:mm:ss') : '-',
| },
| {
| label: '用户昵称',
| children: orderDetail.userName || '-',
| },
| {
| label: '用户手机号',
| children: orderDetail.phone || '-',
| },
| {
| label: '订单状态',
| children: statusMap[status] || '-',
| },
| {
| label: '审核状态',
| children: auditStatusMap[refundStatus] || '-',
| },
| {
| label: '订单金额',
| children: `¥${orderDetail.orderPrice || 0}`,
| },
| {
| label: '支付方式',
| children: paymentTypeMap[paymentType] || '-',
| },
| ];
|
| // 根据不同状态添加特定字段
| let specificItems = [];
|
| if (status >= 2) {
| // 已付定金或更高级状态
| specificItems = [
| {
| label: '定金',
| children: `¥${orderDetail.deposit || 0}`,
| },
| {
| label: '定金支付方式',
| children: '微信支付',
| },
| {
| label: '定金支付时间',
| children: orderDetail.depositTime ? moment(orderDetail.depositTime).format('YYYY-MM-DD HH:mm:ss') : '-',
| },
| ];
| }
|
| if (status === 3 && paymentType === 1) {
| // 已支付定金+尾款
| specificItems = [
| ...specificItems,
| {
| label: '已付尾款',
| children: `¥${orderDetail.finalPayment || 0}`,
| },
| {
| label: '尾款支付方式',
| children: '微信支付',
| },
| {
| label: '尾款支付时间',
| children: orderDetail.finalPaymentTime ? moment(orderDetail.finalPaymentTime).format('YYYY-MM-DD HH:mm:ss') : '-',
| },
| ];
| } else if (status === 3 && paymentType === 2) {
| // 已支付全款
| specificItems = [
| {
| label: '支付金额',
| children: `¥${orderDetail.paymentPrice || 0}`,
| },
| {
| label: '支付时间',
| children: orderDetail.depositTime ? moment(orderDetail.depositTime).format('YYYY-MM-DD HH:mm:ss') : '-',
| },
| {
| label: '支付方式',
| children: '微信支付',
| },
| ];
| }
|
| // 退款相关字段
| const refundItems = [
| {
| label: '退款金额',
| children: `¥${orderDetail.refundAmount || '0.00'}`,
| },
| {
| label: '申请退款原因',
| children: orderDetail.refundReason || '-',
| },
| ];
|
| // 审核相关字段
| const auditItems = [];
| if (refundStatus == 2) {
| auditItems.push(
| {
| label: '审核结果',
| children: refundStatus === 2 ? '审核通过' : '审核驳回',
| },
| {
| label: '审核时间',
| children: orderDetail.auditTime ? moment(orderDetail.auditTime).format('YYYY-MM-DD HH:mm:ss') : '-',
| },
| );
| }
| if (refundStatus == 3) {
| auditItems.push(
| {
| label: '驳回原因',
| children: orderDetail.auditRemark || '-',
| }
| );
| }
|
| return (
| <div>
| <Descriptions column={2} bordered loading={loading}>
| {[...baseItems, ...specificItems, ...refundItems, ...auditItems].map((item, index) => (
| <Descriptions.Item key={index} label={item.label}>
| {item.children}
| </Descriptions.Item>
| ))}
| </Descriptions>
|
| {/* 商品信息 */}
| <div style={{ marginTop: 24 }}>
| <Text strong>商品信息</Text>
| <div style={{ marginTop: 8 }}>
| {renderProductTable()}
| </div>
| </div>
|
| {/* 备注 */}
| {orderDetail.remark && (
| <div style={{ marginTop: 24 }}>
| <Text strong>备注</Text>
| <div style={{ marginTop: 8 }}>
| {orderDetail.remark}
| </div>
| </div>
| )}
|
| {/* 图片凭证 */}
| {orderDetail.refundImages && (
| <div style={{ marginTop: 24 }}>
| <Text strong>图片凭证</Text>
| <div style={{ marginTop: 8, display: 'flex', gap: 8, flexWrap: 'wrap' }}>
| {orderDetail.refundImages.split(',').map((img, index) => (
| <Image
| key={index}
| width={80}
| height={80}
| src={img}
| alt={`凭证${index + 1}`}
| style={{ objectFit: 'cover' }}
| fallback="/images/default-image.png"
| />
| ))}
| </div>
| </div>
| )}
|
| {/* 审核表单(仅待审核状态显示) */}
| {orderDetail?.refundStatus === 1 && (
| <div style={{ marginTop: 24 }}>
| <Text strong>审核操作</Text>
| <Form
| form={auditForm}
| style={{ marginTop: 16 }}
| >
| <Form.Item
| name="auditStatus"
| label="审核结果"
| rules={[
| { required: true, message: '请选择审核结果' },
| ]}
| >
| <Radio.Group>
| <Radio value={2}>审核通过</Radio>
| <Radio value={3}>审核驳回</Radio>
| </Radio.Group>
| </Form.Item>
| <Form.Item
| noStyle
| shouldUpdate={(prevValues, currentValues) =>
| prevValues.auditStatus !== currentValues.auditStatus
| }
| >
| {() => (
| auditForm.getFieldValue('auditStatus') === 3 && (
| <Form.Item
| name="auditRemark"
| label="驳回原因"
| rules={[
| { required: true, message: '请输入驳回原因' },
| ]}
| >
| <Input.TextArea />
| </Form.Item>
| )
| )}
| </Form.Item>
|
| <Form.Item>
| <Button
| type="primary"
| loading={auditLoading}
| onClick={handleAuditSubmit}
| style={{ marginRight: 8 }}
| >
| 提交审核
| </Button>
| </Form.Item>
| </Form>
| </div>
| )}
| </div>
| );
| };
|
| return (
| <Modal
| title="订单详情"
| open={visible}
| onCancel={onCancel}
| footer={[
| <Button key="close" onClick={onCancel}>
| 关闭
| </Button>,
| ]}
| width={800}
| destroyOnHidden
| >
| {renderDetailContent()}
| </Modal>
| );
| };
|
| export default RefundDetailModal;
|
|