客服增加电子凭证冲正
This commit is contained in:
@@ -119,6 +119,7 @@ export default function AdminKuaishouIndustryPage() {
|
||||
const [voucherLoading, setVoucherLoading] = useState(false)
|
||||
const [actionLoading, setActionLoading] = useState('')
|
||||
const [consumingVoucherId, setConsumingVoucherId] = useState<number | null>(null)
|
||||
const [reversingVoucherId, setReversingVoucherId] = useState<number | null>(null)
|
||||
const [vouchers, setVouchers] = useState<AdminKuaishouIndustryVoucher[]>([])
|
||||
const [selectedVoucher, setSelectedVoucher] = useState<AdminKuaishouIndustryVoucher | null>(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 (
|
||||
<Popconfirm
|
||||
title="确认核销该券码?"
|
||||
description={row.voucherCode}
|
||||
okText="核销"
|
||||
cancelText="取消"
|
||||
disabled={!canConsume}
|
||||
onConfirm={() => consumeVoucherRow(row)}
|
||||
>
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
icon={<CheckCircleOutlined />}
|
||||
<Space size={4}>
|
||||
<Popconfirm
|
||||
title="确认核销该券码?"
|
||||
description={row.voucherCode}
|
||||
okText="核销"
|
||||
cancelText="取消"
|
||||
disabled={!canConsume}
|
||||
loading={consumingVoucherId === row.id}
|
||||
onConfirm={() => consumeVoucherRow(row)}
|
||||
>
|
||||
核销
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
icon={<CheckCircleOutlined />}
|
||||
disabled={!canConsume}
|
||||
loading={consumingVoucherId === row.id}
|
||||
>
|
||||
核销
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm
|
||||
title="确认冲正该券码?"
|
||||
description="冲正后券码将恢复为未使用状态。"
|
||||
okText="冲正"
|
||||
cancelText="取消"
|
||||
disabled={!canReverse}
|
||||
onConfirm={() => reverseVoucherRow(row)}
|
||||
>
|
||||
<Button
|
||||
size="small"
|
||||
danger
|
||||
icon={<RollbackOutlined />}
|
||||
disabled={!canReverse}
|
||||
loading={reversingVoucherId === row.id}
|
||||
>
|
||||
冲正
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -367,7 +389,13 @@ export default function AdminKuaishouIndustryPage() {
|
||||
},
|
||||
},
|
||||
],
|
||||
[consumingVoucherId, isSupportOnly, selectedVoucher?.id, shopNameBySellerId],
|
||||
[
|
||||
consumingVoucherId,
|
||||
isSupportOnly,
|
||||
reversingVoucherId,
|
||||
selectedVoucher?.id,
|
||||
shopNameBySellerId,
|
||||
],
|
||||
)
|
||||
|
||||
const refundColumns = useMemo<TableColumnsType<Record<string, unknown>>>(
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user