优化电子凭证操作与测试数据

This commit is contained in:
yml2213
2026-08-14 15:14:34 +08:00
parent dffe32e84a
commit 78d6c2f8a1
6 changed files with 264 additions and 13 deletions
@@ -23,15 +23,19 @@ import {
buildOpen91QueryDevMock,
createAffiliateDashDevMock,
createFeifeiDevMock,
createKuaishouIndustryVoucherDevMock,
createLewanDevMock,
fetchDevMockStatus,
type DevMockCreateResult,
type DevMockKuaishouIndustryVoucherResult,
type DevMockOpen91QueryResult,
} from '@/services/admin'
export default function AdminDevMockPage() {
const { message } = App.useApp()
const [lastCreate, setLastCreate] = useState<DevMockCreateResult | null>(null)
const [lastVoucherCreate, setLastVoucherCreate] =
useState<DevMockKuaishouIndustryVoucherResult | null>(null)
const [lastQuery, setLastQuery] = useState<DevMockOpen91QueryResult | null>(null)
const statusQuery = useQuery({
@@ -76,6 +80,17 @@ export default function AdminDevMockPage() {
},
})
const voucherMutation = useMutation({
mutationFn: createKuaishouIndustryVoucherDevMock,
onSuccess: (response) => {
setLastVoucherCreate(response.data)
message.success(`已生成 ${response.data.createdCount} 条电子凭证 Mock`)
},
onError: (error) => {
message.error(error instanceof Error ? error.message : '生成失败')
},
})
const open91Mutation = useMutation({
mutationFn: buildOpen91QueryDevMock,
onSuccess: (response) => {
@@ -166,8 +181,17 @@ export default function AdminDevMockPage() {
</Card>
</Col>
<Col xs={24} xl={12}>
<Card title="4. 快手电子凭证测试数据" bordered={false}>
<KuaishouIndustryVoucherMockForm
loading={voucherMutation.isPending}
onSubmit={(values) => voucherMutation.mutate(values)}
/>
</Card>
</Col>
<Col xs={24}>
<Card title="4. 模拟 91 查单(open-91/query" bordered={false}>
<Card title="5. 模拟 91 查单(open-91/query" bordered={false}>
<Form
layout="inline"
initialValues={{ orderNo: defaultOrderNo, execute: '1' }}
@@ -284,6 +308,24 @@ export default function AdminDevMockPage() {
</Card>
) : null}
{lastVoucherCreate ? (
<Card
title="最近生成的电子凭证 Mock"
extra={<Link to="/admin/kuaishou-industry"></Link>}
>
<Typography.Paragraph type="secondary">
{lastVoucherCreate.sellerId} {lastVoucherCreate.createdCount}
</Typography.Paragraph>
<Space direction="vertical" size={4}>
{lastVoucherCreate.vouchers.map((voucher) => (
<Typography.Text key={voucher.voucherCode} copyable>
{voucher.status} · {voucher.voucherCode} · {voucher.oid}
</Typography.Text>
))}
</Space>
</Card>
) : null}
{lastQuery ? (
<Card title="91 查单结果">
<Typography.Paragraph>
@@ -516,3 +558,26 @@ function AffiliateDashMockForm({
</Form>
)
}
function KuaishouIndustryVoucherMockForm({
loading,
onSubmit,
}: {
loading: boolean
onSubmit: (values: { sellerId?: string }) => void
}) {
return (
<Form layout="vertical" onFinish={onSubmit}>
<Form.Item
label="店铺 ID(可空)"
name="sellerId"
extra="留空时使用快手行业配置中的首个启用店铺;会生成 6 条不同状态的券码。"
>
<Input allowClear placeholder="留空自动选择测试店铺" />
</Form.Item>
<Button type="primary" htmlType="submit" loading={loading} block>
Mock
</Button>
</Form>
)
}