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 {