feat(dev-mock): 新增斗鱼履约 Mock 与分页控制台

- 增加斗鱼客户履约 Mock 订单与角色绑定联调能力
- 重构开发 Mock 控制台为可切换分页界面
- 补充斗鱼履约 Mock 集成测试
This commit is contained in:
yml
2026-11-18 11:00:28 +08:00
parent 4abc8b39d0
commit d0ec21ce16
6 changed files with 1076 additions and 410 deletions
+594 -289
View File
@@ -1,4 +1,13 @@
import { BugOutlined, CopyOutlined, LinkOutlined } from '@ant-design/icons'
import {
ApiOutlined,
BugOutlined,
CopyOutlined,
GiftOutlined,
LinkOutlined,
SearchOutlined,
ThunderboltOutlined,
WalletOutlined,
} from '@ant-design/icons'
import {
Alert,
App,
@@ -6,13 +15,17 @@ import {
Card,
Col,
Divider,
Empty,
Form,
Input,
InputNumber,
Result,
Row,
Segmented,
Select,
Space,
Tabs,
Tag,
Typography,
} from 'antd'
import { useMutation, useQuery } from '@tanstack/react-query'
@@ -23,6 +36,7 @@ import PageHeader from '@/components/admin/PageHeader'
import {
buildOpen91QueryDevMock,
createAffiliateDashDevMock,
createDouyuFulfillmentDevMock,
createKuaishouIndustryVoucherDevMock,
createSemiAutoDevMock,
createSemiAutoIntegrationDevMock,
@@ -31,16 +45,24 @@ import {
type DevMockKuaishouIndustryVoucherResult,
type DevMockOpen91QueryResult,
type DevMockSemiAutoResult,
type DevDouyuFulfillmentMockResult,
type DevSemiAutoIntegrationResult,
} from '@/services/admin'
import { buildCustomerFulfillmentPath } from '@/utils/customer-fulfillment-link'
type MockTabKey = 'douyu' | 'semi-auto' | 'affiliate-dash' | 'kuaishou-voucher' | 'open91'
type SemiAutoMode = 'integration' | 'direct'
export default function AdminDevMockPage() {
const { message } = App.useApp()
const [activeTab, setActiveTab] = useState<MockTabKey>('douyu')
const [semiAutoMode, setSemiAutoMode] = useState<SemiAutoMode>('integration')
const [lastCreate, setLastCreate] = useState<DevMockCreateResult | null>(null)
const [lastVoucherCreate, setLastVoucherCreate] =
useState<DevMockKuaishouIndustryVoucherResult | null>(null)
const [lastQuery, setLastQuery] = useState<DevMockOpen91QueryResult | null>(null)
const [lastDouyuFulfillment, setLastDouyuFulfillment] =
useState<DevDouyuFulfillmentMockResult | null>(null)
const [lastSemiAuto, setLastSemiAuto] = useState<
DevMockSemiAutoResult | DevSemiAutoIntegrationResult | null
>(null)
@@ -109,8 +131,18 @@ export default function AdminDevMockPage() {
},
})
const douyuFulfillmentMutation = useMutation({
mutationFn: createDouyuFulfillmentDevMock,
onSuccess: (response) => {
setLastDouyuFulfillment(response.data)
message.success('斗鱼直播账号履约测试单已生成')
},
onError: (error) => {
message.error(error instanceof Error ? error.message : '生成失败')
},
})
const defaultOrderNo = useMemo(() => lastCreate?.orderNo || '', [lastCreate?.orderNo])
// 页面展示按平台重新生成规范路径,避免历史 Mock 响应里的 customerPath 仍是 /c。
const semiAutoCustomerPath = lastSemiAuto
? buildCustomerFulfillmentPath(lastSemiAuto.orderNo, lastSemiAuto.semiAutoPlatform) ||
lastSemiAuto.customerPath
@@ -148,314 +180,561 @@ export default function AdminDevMockPage() {
<section className="page-stack">
<PageHeader
title="开发 Mock"
description="一键造单与测试数据;半自动履约可选择只 Mock 订单,登录、绑定走真实 Connector。"
description="按场景切换测试工具,只展示当前模块,减少长页面和误操作。"
extra={
<Typography.Text type="secondary">NODE_ENV={status?.nodeEnv || '-'}</Typography.Text>
<Space size={8}>
<Tag color="green">Mock 已开启</Tag>
<Typography.Text type="secondary">NODE_ENV={status?.nodeEnv || '-'}</Typography.Text>
</Space>
}
/>
<Alert
type="info"
type="warning"
showIcon
icon={<BugOutlined />}
message="Mock 会写入开发库真实订单/任务;除订单外,登录、绑定、票据注入和完成确认都可以走真实流程。"
description="默认使用 order_site 内置真实 Connector,不依赖 live-hub-py;只有显式选择内置 Mock 时才会 Mock 登录和绑定。"
message="仅用于开发环境"
description="Mock 会向当前开发库写入真实订单和任务。请先确认当前环境,再切换对应业务模块生成测试数据。"
/>
<Row gutter={[16, 16]}>
<Col xs={24} xl={12}>
<Card title="1. affiliate-dash 领取(mock 二维码/提交发货)" bordered={false}>
<AffiliateDashMockForm
loading={affiliateDashMutation.isPending}
onSubmit={(values) => affiliateDashMutation.mutate(values)}
/>
</Card>
</Col>
<Col xs={24} xl={12}>
<Card title="2. 半自动真实履约链路测试单" bordered={false}>
<Alert
type="success"
showIcon
style={{ marginBottom: 12 }}
message="正式订单入口"
description="订单走 upsertOrderFromSource,随后执行 SKU 映射、渠道判定、Carrier 补偿和半自动任务生成。"
/>
<SemiAutoMockForm
loading={semiAutoIntegrationMutation.isPending}
submitText="生成真实链路测试单"
defaultConnectorMode={status?.semiAuto?.defaultConnectorMode}
externalConnectorConfigured={status?.semiAuto?.externalConnectorConfigured}
mockConnectorAvailable={status?.semiAuto?.mockConnectorAvailable}
onSubmit={(values) => semiAutoIntegrationMutation.mutate(values)}
/>
</Card>
</Col>
<Col xs={24} xl={12}>
<Card title="3. 半自动直连 Mock(页面联调)" bordered={false}>
<SemiAutoMockForm
loading={semiAutoMutation.isPending}
defaultConnectorMode={status?.semiAuto?.defaultConnectorMode}
externalConnectorConfigured={status?.semiAuto?.externalConnectorConfigured}
mockConnectorAvailable={status?.semiAuto?.mockConnectorAvailable}
onSubmit={(values) => semiAutoMutation.mutate(values)}
/>
</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="5. 模拟 91 查单(open-91/query)" bordered={false}>
<Form
layout="inline"
initialValues={{ orderNo: defaultOrderNo, execute: '1' }}
key={defaultOrderNo}
onFinish={(values) =>
open91Mutation.mutate({
orderNo: values.orderNo,
execute: values.execute === '1',
})
}
>
<Form.Item
label="orderNo"
name="orderNo"
rules={[{ required: true, message: '填写上方生成的订单号' }]}
>
<Input style={{ width: 280 }} placeholder="MOCK91…" />
</Form.Item>
<Form.Item label="执行" name="execute">
<Select
style={{ width: 180 }}
<Tabs
className="dev-mock-tabs"
type="card"
activeKey={activeTab}
onChange={(key) => setActiveTab(key as MockTabKey)}
items={[
{
key: 'douyu',
label: (
<Space size={6}>
<ThunderboltOutlined />
斗鱼履约
</Space>
),
children: (
<Row gutter={[16, 16]}>
<Col xs={24} xl={14}>
<Card title="创建斗鱼履约测试单" extra={<Tag color="blue">正式订单链路</Tag>}>
<Alert
type="success"
showIcon
style={{ marginBottom: 16 }}
message="供 live-hub 直播账号履约工作台读取"
description="生成 manual + assigned 履约和内部 SKU 映射,不创建 huya/weibo 半自动任务。"
/>
<DouyuFulfillmentMockForm
loading={douyuFulfillmentMutation.isPending}
onSubmit={(values) => douyuFulfillmentMutation.mutate(values)}
/>
</Card>
</Col>
<Col xs={24} xl={10}>
<Space direction="vertical" size={16} style={{ width: '100%' }}>
{lastDouyuFulfillment ? (
<DouyuFulfillmentResultCard result={lastDouyuFulfillment} />
) : (
<MockResultEmpty description="生成后显示订单号、内部 SKU 和履约 ID" />
)}
<Card size="small" title="联调口径">
<ul style={{ margin: 0, paddingLeft: 18 }}>
<li>订单走正式 upsertOrderFromSource 入库。</li>
<li>工作台同步后使用返回的内部 SKU 配置斗鱼商品映射。</li>
<li>不生成半自动任务,客户绑定和人工兑换都在 live-hub 完成。</li>
</ul>
</Card>
</Space>
</Col>
</Row>
),
},
{
key: 'semi-auto',
label: (
<Space size={6}>
<ApiOutlined />
半自动履约
</Space>
),
children: (
<Space direction="vertical" size={16} style={{ width: '100%' }}>
<Segmented
block
value={semiAutoMode}
onChange={(value) => setSemiAutoMode(value as SemiAutoMode)}
options={[
{ value: '1', label: '生成并请求本机' },
{ value: '0', label: '仅生成请求体' },
{ label: '正式订单链路', value: 'integration' },
{ label: '直连 Mock', value: 'direct' },
]}
/>
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit" loading={open91Mutation.isPending}>
模拟 91 查单
</Button>
</Form.Item>
</Form>
<Typography.Paragraph type="secondary" style={{ marginTop: 12, marginBottom: 0 }}>
对应日志:POST /api/v1/open/91/orders/query。需配置 KAQUAN91_SECRET(32 位)。
</Typography.Paragraph>
</Card>
<Row gutter={[16, 16]}>
<Col xs={24} xl={14}>
<Card
title={semiAutoMode === 'integration' ? '正式链路测试单' : '页面直连 Mock'}
extra={
<Tag color={semiAutoMode === 'integration' ? 'blue' : 'orange'}>
{semiAutoMode === 'integration' ? 'upsertOrderFromSource' : '直连造单'}
</Tag>
}
>
<Alert
type={semiAutoMode === 'integration' ? 'success' : 'warning'}
showIcon
style={{ marginBottom: 16 }}
message={
semiAutoMode === 'integration'
? '订单走正式订单、渠道和半自动任务链路'
: '仅适合半自动页面联调,不经过正式订单入口'
}
/>
<SemiAutoMockForm
loading={
semiAutoMode === 'integration'
? semiAutoIntegrationMutation.isPending
: semiAutoMutation.isPending
}
submitText={
semiAutoMode === 'integration' ? '生成真实链路测试单' : '生成直连 Mock'
}
integration={semiAutoMode === 'integration'}
defaultConnectorMode={status?.semiAuto?.defaultConnectorMode}
externalConnectorConfigured={status?.semiAuto?.externalConnectorConfigured}
mockConnectorAvailable={status?.semiAuto?.mockConnectorAvailable}
onSubmit={(values) => {
if (semiAutoMode === 'integration') {
semiAutoIntegrationMutation.mutate(values)
return
}
semiAutoMutation.mutate(values)
}}
/>
</Card>
</Col>
<Col xs={24} xl={10}>
<Space direction="vertical" size={16} style={{ width: '100%' }}>
{lastSemiAuto &&
(semiAutoMode === 'integration'
? 'pipeline' in lastSemiAuto
: !('pipeline' in lastSemiAuto)) ? (
<SemiAutoResultCard
result={lastSemiAuto}
customerUrl={semiAutoCustomerUrl}
/>
) : (
<MockResultEmpty description="当前模式生成后显示任务和客户履约入口" />
)}
<Card size="small" title="两种模式的区别">
<ul style={{ margin: 0, paddingLeft: 18 }}>
<li>正式订单链路会经过 SKU 映射、渠道判定和 Carrier 补偿。</li>
<li>直连 Mock 只用于半自动页面联调,验证页面和 Connector 状态。</li>
<li>微博固定使用内置 Connector,虎牙可按环境选择。</li>
</ul>
</Card>
</Space>
</Col>
</Row>
</Space>
),
},
{
key: 'affiliate-dash',
label: (
<Space size={6}>
<GiftOutlined />
affiliate-dash
</Space>
),
children: (
<Row gutter={[16, 16]}>
<Col xs={24} xl={14}>
<Card title="affiliate-dash 领取 Mock">
<Typography.Paragraph type="secondary">
生成领取订单、任务和二维码上下文,用于领取页的填写 UID、绑定、提交和完成流程。
</Typography.Paragraph>
<AffiliateDashMockForm
loading={affiliateDashMutation.isPending}
onSubmit={(values) => affiliateDashMutation.mutate(values)}
/>
</Card>
</Col>
<Col xs={24} xl={10}>
{lastCreate ? (
<AffiliateDashResultCard result={lastCreate} />
) : (
<MockResultEmpty description="生成后显示领取链接和操作提示" />
)}
</Col>
</Row>
),
},
{
key: 'kuaishou-voucher',
label: (
<Space size={6}>
<WalletOutlined />
快手凭证
</Space>
),
children: (
<Row gutter={[16, 16]}>
<Col xs={24} xl={14}>
<Card title="快手电子凭证测试数据">
<Typography.Paragraph type="secondary">
一次生成 6 条不同状态的测试券码,覆盖待使用、已核销、已销毁和回调异常。
</Typography.Paragraph>
<KuaishouIndustryVoucherMockForm
loading={voucherMutation.isPending}
onSubmit={(values) => voucherMutation.mutate(values)}
/>
</Card>
</Col>
<Col xs={24} xl={10}>
{lastVoucherCreate ? (
<KuaishouVoucherResultCard result={lastVoucherCreate} />
) : (
<MockResultEmpty description="生成后显示店铺和测试券码" />
)}
</Col>
</Row>
),
},
{
key: 'open91',
label: (
<Space size={6}>
<SearchOutlined />
91 查单
</Space>
),
children: (
<Row gutter={[16, 16]}>
<Col xs={24} xl={14}>
<Card title="模拟 91 查单">
<Form
layout="vertical"
initialValues={{ orderNo: defaultOrderNo, execute: '1' }}
key={defaultOrderNo}
onFinish={(values) =>
open91Mutation.mutate({
orderNo: values.orderNo,
execute: values.execute === '1',
})
}
>
<Row gutter={12}>
<Col xs={24} md={14}>
<Form.Item
label="orderNo"
name="orderNo"
rules={[{ required: true, message: '填写要查询的订单号' }]}
>
<Input placeholder="MOCK91…" />
</Form.Item>
</Col>
<Col xs={24} md={10}>
<Form.Item label="执行方式" name="execute">
<Select
options={[
{ value: '1', label: '生成并请求本机' },
{ value: '0', label: '仅生成请求体' },
]}
/>
</Form.Item>
</Col>
</Row>
<Typography.Paragraph type="secondary">
对应日志:POST /api/v1/open/91/orders/query。需配置 KAQUAN91_SECRET(32
位)。
</Typography.Paragraph>
<Button type="primary" htmlType="submit" loading={open91Mutation.isPending}>
模拟 91 查单
</Button>
</Form>
</Card>
</Col>
<Col xs={24} xl={10}>
{lastQuery ? (
<Open91ResultCard result={lastQuery} />
) : (
<MockResultEmpty description="生成后显示请求体、curl 和响应" />
)}
</Col>
</Row>
),
},
]}
/>
</section>
)
}
function MockResultEmpty({ description }: { description: string }) {
return (
<Card size="small" title="最近结果">
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={description} />
</Card>
)
}
function AffiliateDashResultCard({ result }: { result: DevMockCreateResult }) {
const { message } = App.useApp()
return (
<Card
size="small"
title="最近结果"
extra={
<Space>
<Link to={`/admin/orders/${result.orderId}`}>订单 #{result.orderId}</Link>
<Link to={`/admin/tasks/${result.taskId}`}>任务 #{result.taskId}</Link>
</Space>
}
>
<Space direction="vertical" size={12} style={{ width: '100%' }}>
<div>
<Typography.Text type="secondary">平台 / 步骤</Typography.Text>
<div>
<Typography.Text strong>
{result.platform} · {result.step}
</Typography.Text>
</div>
</div>
<div>
<Typography.Text type="secondary">订单号</Typography.Text>
<div>
<Typography.Text copyable>{result.orderNo}</Typography.Text>
</div>
</div>
<div>
<Typography.Text type="secondary">商品 / UID</Typography.Text>
<div>
{result.productName} · {result.expectedUid}
</div>
</div>
<div>
<Typography.Text type="secondary">领取链接</Typography.Text>
<Typography.Paragraph style={{ margin: '4px 0 0' }}>
<Typography.Link href={result.claimUrl} target="_blank" rel="noreferrer">
<LinkOutlined /> {result.claimUrl}
</Typography.Link>
</Typography.Paragraph>
</div>
<Space wrap>
<Button
icon={<CopyOutlined />}
onClick={async () => {
await navigator.clipboard.writeText(result.claimUrl)
message.success('已复制领取链接')
}}
>
复制链接
</Button>
<Button type="primary" href={result.claimUrl} target="_blank">
打开领取页
</Button>
</Space>
<Alert
type="success"
showIcon
message="操作提示"
description={
<ul style={{ margin: 0, paddingLeft: 18 }}>
{result.tips.map((tip) => (
<li key={tip}>{tip}</li>
))}
<li>{result.open91QueryHint}</li>
</ul>
}
/>
</Space>
</Card>
)
}
function DouyuFulfillmentResultCard({ result }: { result: DevDouyuFulfillmentMockResult }) {
return (
<Card size="small" title="最近结果" extra={<Link to={result.adminPath}>打开订单</Link>}>
<Row gutter={[12, 12]}>
<Col span={24}>
<Typography.Text type="secondary">订单号</Typography.Text>
<div>
<Typography.Text copyable strong>
{result.orderNo}
</Typography.Text>
</div>
</Col>
<Col span={24}>
<Typography.Text type="secondary">内部 SKU</Typography.Text>
<div>
<Typography.Text copyable>{result.skuKey}</Typography.Text>
</div>
</Col>
<Col span={12}>
<Typography.Text type="secondary">订单项</Typography.Text>
<div>#{result.orderItemId}</div>
</Col>
<Col span={12}>
<Typography.Text type="secondary">履约单</Typography.Text>
<div>#{result.fulfillmentId}</div>
</Col>
<Col span={24}>
<Alert
type="success"
showIcon
message="下一步"
description={
<ul style={{ margin: 0, paddingLeft: 18 }}>
{result.tips.map((tip) => (
<li key={tip}>{tip}</li>
))}
</ul>
}
/>
</Col>
</Row>
</Card>
)
}
{lastCreate ? (
<Card
title="最近生成结果"
extra={
<Space>
<Link to={`/admin/orders/${lastCreate.orderId}`}>订单 #{lastCreate.orderId}</Link>
<Link to={`/admin/tasks/${lastCreate.taskId}`}>任务 #{lastCreate.taskId}</Link>
</Space>
function SemiAutoResultCard({
result,
customerUrl,
}: {
result: DevMockSemiAutoResult | DevSemiAutoIntegrationResult
customerUrl: string
}) {
const { message } = App.useApp()
return (
<Card size="small" title="最近结果" extra={<Link to={result.adminPath}>打开后台任务</Link>}>
<Space direction="vertical" size={12} style={{ width: '100%' }}>
<div>
<Typography.Text type="secondary">订单号</Typography.Text>
<div>
<Typography.Text copyable strong>
{result.orderNo}
</Typography.Text>
</div>
</div>
<div>
<Typography.Text type="secondary">内部 SKU / 任务</Typography.Text>
<div>
{result.semiAutoPlatform === 'weibo' ? '微博' : '虎牙'} · {result.skuKey} · 任务 #
{result.taskId}
</div>
</div>
<div>
<Typography.Text type="secondary">客户履约入口</Typography.Text>
<Typography.Paragraph style={{ margin: '4px 0 0' }}>
<Typography.Link href={customerUrl} target="_blank" rel="noreferrer">
<LinkOutlined /> {customerUrl}
</Typography.Link>
</Typography.Paragraph>
</div>
<Space wrap>
<Button
icon={<CopyOutlined />}
onClick={async () => {
await navigator.clipboard.writeText(customerUrl)
message.success('已复制客户履约链接')
}}
>
复制客户链接
</Button>
<Button type="primary" href={customerUrl} target="_blank">
打开客户页
</Button>
</Space>
<Alert
type={
result.connectorMode === 'mock'
? 'warning'
: result.connectorConfigured
? 'success'
: 'error'
}
>
<Row gutter={[16, 12]}>
<Col xs={24} md={12}>
<Typography.Text type="secondary">平台</Typography.Text>
<div>
<Typography.Text strong>{lastCreate.platform}</Typography.Text>
</div>
</Col>
<Col xs={24} md={12}>
<Typography.Text type="secondary">步骤 / UID</Typography.Text>
<div>
<Typography.Text strong>
{lastCreate.step} / {lastCreate.expectedUid}
</Typography.Text>
</div>
</Col>
<Col xs={24} md={12}>
<Typography.Text type="secondary">91 订单号</Typography.Text>
<div>
<Typography.Text copyable>{lastCreate.orderNo}</Typography.Text>
</div>
</Col>
<Col xs={24} md={12}>
<Typography.Text type="secondary">商品</Typography.Text>
<div>{lastCreate.productName}</div>
</Col>
<Col span={24}>
<Typography.Text type="secondary">领取链接</Typography.Text>
<div>
<Typography.Link href={lastCreate.claimUrl} target="_blank" rel="noreferrer">
<LinkOutlined /> {lastCreate.claimUrl}
</Typography.Link>
</div>
<Space style={{ marginTop: 8 }} wrap>
<Button
icon={<CopyOutlined />}
onClick={async () => {
await navigator.clipboard.writeText(lastCreate.claimUrl)
message.success('已复制领取链接')
}}
>
复制链接
</Button>
<Button type="primary" href={lastCreate.claimUrl} target="_blank">
打开领取页
</Button>
</Space>
</Col>
<Col span={24}>
<Alert
type="success"
showIcon
message="操作提示"
description={
<ul style={{ margin: 0, paddingLeft: 18 }}>
{lastCreate.tips.map((tip) => (
<li key={tip}>{tip}</li>
))}
<li>{lastCreate.open91QueryHint}</li>
</ul>
}
/>
</Col>
</Row>
</Card>
) : null}
showIcon
message={
result.connectorMode === 'mock'
? '当前使用内置 Mock Connector'
: result.connectorConfigured
? result.connectorMode === 'external'
? '当前使用远程真实 Connector'
: '当前使用 order_site 内置真实 Connector'
: '当前选择远程真实 Connector,但尚未配置'
}
description={
<ul style={{ margin: 0, paddingLeft: 18 }}>
{result.tips.map((tip) => (
<li key={tip}>{tip}</li>
))}
</ul>
}
/>
</Space>
</Card>
)
}
{lastSemiAuto ? (
<Card
title="最近生成的半自动测试单"
extra={<Link to={lastSemiAuto.adminPath}>打开后台任务</Link>}
>
<Row gutter={[16, 12]}>
<Col xs={24} md={12}>
<Typography.Text type="secondary">订单号</Typography.Text>
<div>
<Typography.Text copyable strong>
{lastSemiAuto.orderNo}
</Typography.Text>
</div>
</Col>
<Col xs={24} md={12}>
<Typography.Text type="secondary">内部 SKU / 任务</Typography.Text>
<div>
{lastSemiAuto.semiAutoPlatform === 'weibo' ? '微博' : '虎牙'} ·{' '}
{lastSemiAuto.skuKey} · 任务 #{lastSemiAuto.taskId}
{'pipeline' in lastSemiAuto ? ' · 正式订单链路' : ' · 直连 Mock'}
</div>
</Col>
<Col span={24}>
<Typography.Text type="secondary">客户履约入口</Typography.Text>
<div>
<Typography.Link href={semiAutoCustomerUrl} target="_blank" rel="noreferrer">
<LinkOutlined /> {window.location.origin}
{semiAutoCustomerPath}
</Typography.Link>
</div>
<Space style={{ marginTop: 8 }} wrap>
<Button
icon={<CopyOutlined />}
onClick={async () => {
await navigator.clipboard.writeText(semiAutoCustomerUrl)
message.success('已复制客户履约链接')
}}
>
复制客户链接
</Button>
<Button type="primary" href={semiAutoCustomerUrl} target="_blank">
打开客户页
</Button>
</Space>
</Col>
<Col span={24}>
<Alert
type={
lastSemiAuto.connectorMode === 'mock'
? 'warning'
: lastSemiAuto.connectorConfigured
? 'success'
: 'error'
}
showIcon
message={
lastSemiAuto.connectorMode === 'mock'
? '当前使用内置 Mock Connector'
: lastSemiAuto.connectorConfigured
? lastSemiAuto.connectorMode === 'external'
? '当前使用远程真实 Connector'
: '当前使用 order_site 内置真实 Connector'
: '当前选择远程真实 Connector,但尚未配置'
}
description={
<ul style={{ margin: 0, paddingLeft: 18 }}>
{lastSemiAuto.tips.map((tip) => (
<li key={tip}>{tip}</li>
))}
</ul>
}
/>
</Col>
</Row>
</Card>
) : null}
function KuaishouVoucherResultCard({ result }: { result: DevMockKuaishouIndustryVoucherResult }) {
return (
<Card
size="small"
title="最近结果"
extra={<Link to="/admin/kuaishou-industry">查看电子凭证</Link>}
>
<Typography.Paragraph type="secondary">
已为店铺 {result.sellerId} 写入 {result.createdCount} 条测试券码。
</Typography.Paragraph>
<Space direction="vertical" size={6}>
{result.vouchers.map((voucher) => (
<Typography.Text key={voucher.voucherCode} copyable>
{voucher.status} · {voucher.voucherCode} · {voucher.oid}
</Typography.Text>
))}
</Space>
</Card>
)
}
{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>
<Typography.Text type="secondary">Endpoint:</Typography.Text>
function Open91ResultCard({ result }: { result: DevMockOpen91QueryResult }) {
return (
<Card size="small" title="查单结果">
<Space direction="vertical" size={12} style={{ width: '100%' }}>
<div>
<Typography.Text type="secondary">Endpoint</Typography.Text>
<div>
<Typography.Text code copyable>
{lastQuery.endpoint}
{result.endpoint}
</Typography.Text>
</div>
</div>
<div>
<Typography.Text type="secondary">Request</Typography.Text>
<pre className="dev-mock-pre" style={{ marginTop: 6 }}>
{JSON.stringify(result.requestBody, null, 2)}
</pre>
</div>
<div>
<Typography.Text type="secondary">curl</Typography.Text>
<Typography.Paragraph style={{ margin: '4px 0 0' }}>
<Typography.Text code copyable>
{result.curl}
</Typography.Text>
</Typography.Paragraph>
<Typography.Paragraph>
<Typography.Text type="secondary">Request:</Typography.Text>
</Typography.Paragraph>
<pre className="dev-mock-pre">{JSON.stringify(lastQuery.requestBody, null, 2)}</pre>
<Typography.Paragraph>
<Typography.Text type="secondary">curl:</Typography.Text>
<Typography.Text code copyable>
{lastQuery.curl}
</Typography.Text>
</Typography.Paragraph>
{lastQuery.response ? (
<>
<Divider />
<Typography.Paragraph>
<Typography.Text type="secondary">Response:</Typography.Text>
</Typography.Paragraph>
<pre className="dev-mock-pre">{JSON.stringify(lastQuery.response, null, 2)}</pre>
</>
) : null}
</Card>
) : null}
</section>
</div>
{result.response ? (
<>
<Divider style={{ margin: 0 }} />
<div>
<Typography.Text type="secondary">Response</Typography.Text>
<pre className="dev-mock-pre" style={{ marginTop: 6 }}>
{JSON.stringify(result.response, null, 2)}
</pre>
</div>
</>
) : null}
</Space>
</Card>
)
}
@@ -549,6 +828,32 @@ function KuaishouIndustryVoucherMockForm({
)
}
function DouyuFulfillmentMockForm({
loading,
onSubmit,
}: {
loading: boolean
onSubmit: (values: { orderNo?: string; skuName?: string }) => void
}) {
return (
<Form layout="vertical" onFinish={onSubmit}>
<Form.Item
label="内部 SKU 名称(可空)"
name="skuName"
extra="留空自动生成“斗鱼精英宝典联调-时间戳”;必须包含中文,live-hub 将用它配置斗鱼商品映射。"
>
<Input allowClear placeholder="斗鱼精英宝典联调" />
</Form.Item>
<Form.Item label="订单号 orderNo(可空)" name="orderNo" extra="留空自动生成 LIVEHUBDOUYU…">
<Input allowClear placeholder="LIVEHUBDOUYU…" />
</Form.Item>
<Button type="primary" htmlType="submit" loading={loading} block>
生成斗鱼履约测试单
</Button>
</Form>
)
}
function SemiAutoMockForm({
loading,
submitText,
@@ -73,6 +73,20 @@ export type DevSemiAutoIntegrationResult = DevMockSemiAutoResult & {
mappingId: number
}
export type DevDouyuFulfillmentMockResult = {
platform: 'douyu'
pipeline: 'order_service'
orderId: number
orderNo: string
orderItemId: number
fulfillmentId: number
configId: number
mappingId: number
skuKey: string
adminPath: string
tips: string[]
}
export function fetchDevMockStatus() {
return apiGet<DevMockStatus>('/api/v1/admin/dev-mock/status')
}
@@ -122,6 +136,10 @@ export function createSemiAutoIntegrationDevMock(payload: {
)
}
export function createDouyuFulfillmentDevMock(payload: { orderNo?: string; skuName?: string }) {
return apiPost<DevDouyuFulfillmentMockResult>('/api/v1/admin/dev-mock/douyu-fulfillment', payload)
}
export function buildOpen91QueryDevMock(payload: {
orderNo: string
execute?: boolean
+12
View File
@@ -123,6 +123,18 @@ select {
line-height: 1.5;
}
.dev-mock-tabs > .ant-tabs-nav {
margin-bottom: 0;
}
.dev-mock-tabs > .ant-tabs-content-holder {
margin-top: 16px;
}
.dev-mock-tabs > .ant-tabs-nav .ant-tabs-tab {
padding-inline: 18px;
}
.total-badge {
display: inline-flex;
align-items: center;