From 3546036b43d87f3c817ca6e3b4d3889f01507984 Mon Sep 17 00:00:00 2001 From: yml2213 Date: Thu, 20 Aug 2026 11:32:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=9C=8D=E5=A2=9E=E5=8A=A0=E7=94=B5?= =?UTF-8?q?=E5=AD=90=E5=87=AD=E8=AF=81=E5=86=B2=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/admin/AdminKuaishouIndustryPage.tsx | 97 +++++++++++++++---- 1 file changed, 79 insertions(+), 18 deletions(-) diff --git a/apps/frontend/src/pages/admin/AdminKuaishouIndustryPage.tsx b/apps/frontend/src/pages/admin/AdminKuaishouIndustryPage.tsx index 30f10cb3..4d24c107 100644 --- a/apps/frontend/src/pages/admin/AdminKuaishouIndustryPage.tsx +++ b/apps/frontend/src/pages/admin/AdminKuaishouIndustryPage.tsx @@ -119,6 +119,7 @@ export default function AdminKuaishouIndustryPage() { const [voucherLoading, setVoucherLoading] = useState(false) const [actionLoading, setActionLoading] = useState('') const [consumingVoucherId, setConsumingVoucherId] = useState(null) + const [reversingVoucherId, setReversingVoucherId] = useState(null) const [vouchers, setVouchers] = useState([]) const [selectedVoucher, setSelectedVoucher] = useState(null) const [voucherTotal, setVoucherTotal] = useState(0) @@ -327,29 +328,50 @@ export default function AdminKuaishouIndustryPage() { { title: '操作', fixed: 'right' as const, - width: isSupportOnly ? 88 : 72, + width: isSupportOnly ? 164 : 72, render: (_: unknown, row: AdminKuaishouIndustryVoucher) => { if (isSupportOnly) { const canConsume = row.status === 'UNUSED' + const canReverse = row.status === 'CONSUMED' return ( - consumeVoucherRow(row)} - > - - + + + reverseVoucherRow(row)} + > + + + ) } @@ -367,7 +389,13 @@ export default function AdminKuaishouIndustryPage() { }, }, ], - [consumingVoucherId, isSupportOnly, selectedVoucher?.id, shopNameBySellerId], + [ + consumingVoucherId, + isSupportOnly, + reversingVoucherId, + selectedVoucher?.id, + shopNameBySellerId, + ], ) const refundColumns = useMemo>>( @@ -560,6 +588,39 @@ export default function AdminKuaishouIndustryPage() { } } + async function reverseVoucherRow(row: AdminKuaishouIndustryVoucher) { + if (row.status !== 'CONSUMED') { + showError('仅已核销券码可冲正') + return + } + + setReversingVoucherId(row.id) + setActionLoading('reverse') + try { + const response = await reverseAdminKuaishouIndustryVoucher({ + sellerId: row.sellerId, + oid: row.oid, + orderId: row.oid, + taskId: row.taskId || '', + voucherCode: row.voucherCode, + eticketType: row.eticketType || undefined, + reason: '客服手动冲正', + etickets: [{ id: row.voucherCode, code: row.voucherCode, num: 1 }], + }) + if (response.data.success) { + showSuccess(`券码 ${row.voucherCode} 已冲正`) + } else { + showError(response.data.error || '冲正失败') + } + await loadVouchers() + } catch (error) { + showError(error instanceof Error ? error.message : '冲正失败') + } finally { + setReversingVoucherId(null) + setActionLoading('') + } + } + async function runResendCode() { setActionLoading('resend') try {