客服增加电子凭证冲正
This commit is contained in:
@@ -119,6 +119,7 @@ export default function AdminKuaishouIndustryPage() {
|
|||||||
const [voucherLoading, setVoucherLoading] = useState(false)
|
const [voucherLoading, setVoucherLoading] = useState(false)
|
||||||
const [actionLoading, setActionLoading] = useState('')
|
const [actionLoading, setActionLoading] = useState('')
|
||||||
const [consumingVoucherId, setConsumingVoucherId] = useState<number | null>(null)
|
const [consumingVoucherId, setConsumingVoucherId] = useState<number | null>(null)
|
||||||
|
const [reversingVoucherId, setReversingVoucherId] = useState<number | null>(null)
|
||||||
const [vouchers, setVouchers] = useState<AdminKuaishouIndustryVoucher[]>([])
|
const [vouchers, setVouchers] = useState<AdminKuaishouIndustryVoucher[]>([])
|
||||||
const [selectedVoucher, setSelectedVoucher] = useState<AdminKuaishouIndustryVoucher | null>(null)
|
const [selectedVoucher, setSelectedVoucher] = useState<AdminKuaishouIndustryVoucher | null>(null)
|
||||||
const [voucherTotal, setVoucherTotal] = useState(0)
|
const [voucherTotal, setVoucherTotal] = useState(0)
|
||||||
@@ -327,11 +328,13 @@ export default function AdminKuaishouIndustryPage() {
|
|||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
fixed: 'right' as const,
|
fixed: 'right' as const,
|
||||||
width: isSupportOnly ? 88 : 72,
|
width: isSupportOnly ? 164 : 72,
|
||||||
render: (_: unknown, row: AdminKuaishouIndustryVoucher) => {
|
render: (_: unknown, row: AdminKuaishouIndustryVoucher) => {
|
||||||
if (isSupportOnly) {
|
if (isSupportOnly) {
|
||||||
const canConsume = row.status === 'UNUSED'
|
const canConsume = row.status === 'UNUSED'
|
||||||
|
const canReverse = row.status === 'CONSUMED'
|
||||||
return (
|
return (
|
||||||
|
<Space size={4}>
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title="确认核销该券码?"
|
title="确认核销该券码?"
|
||||||
description={row.voucherCode}
|
description={row.voucherCode}
|
||||||
@@ -350,6 +353,25 @@ export default function AdminKuaishouIndustryPage() {
|
|||||||
核销
|
核销
|
||||||
</Button>
|
</Button>
|
||||||
</Popconfirm>
|
</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>>>(
|
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() {
|
async function runResendCode() {
|
||||||
setActionLoading('resend')
|
setActionLoading('resend')
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user