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
+22
View File
@@ -3,6 +3,7 @@ import { Router } from 'express'
import {
buildOpen91QueryMock,
createAffiliateDashMockClaim,
createDouyuFulfillmentMock,
createKuaishouIndustryVoucherMockData,
createSemiAutoIntegrationMock,
createSemiAutoMock,
@@ -77,6 +78,27 @@ router.post(
}),
)
router.post(
'/dev-mock/douyu-fulfillment',
createJsonHandler((req) => createDouyuFulfillmentMock(req.body || {}), {
successMessage: '斗鱼直播账号履约测试单已生成',
errorMessage: '生成斗鱼直播账号履约测试单失败',
scope: '[admin/dev-mock/douyu-fulfillment]',
audit: (_req, data) => ({
action: 'dev_mock_create_douyu_fulfillment',
targetType: 'dev_mock',
targetId: String((data as { orderNo?: string })?.orderNo || ''),
data: {
platform: 'douyu',
pipeline: 'order_service',
orderNo: (data as { orderNo?: string })?.orderNo,
orderItemId: (data as { orderItemId?: number })?.orderItemId,
skuKey: (data as { skuKey?: string })?.skuKey,
},
}),
}),
)
router.post(
'/dev-mock/semi-auto',
createJsonHandler((req) => createSemiAutoMock(req.body || {}), {
@@ -93,6 +93,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 getDevMockStatus() {
const enabled = isDevMockEnabled()
return {
@@ -113,6 +127,12 @@ export function getDevMockStatus() {
'创建人工渠道半自动测试单;可选择仅 Mock 订单,登录、绑定和票据注入走真实 Connector',
steps: ['create_order', 'login', 'binding', 'browser_ticket', 'complete'],
},
{
key: 'douyu_fulfillment',
name: '斗鱼直播账号履约',
description: '创建正式人工渠道测试单,供 live-hub 直播账号履约工作台读取',
steps: ['create_order', 'sync_livehub', 'map_commodity'],
},
]
: [],
defaultUid: '10001',
@@ -531,86 +551,59 @@ export async function createSemiAutoMock(
}
}
/**
* 真实履约链路集成测试单。
*
* 订单必须通过正式 upsertOrderFromSource 入库,再走 SKU 映射、渠道判定和
* Carrier 补偿;不直接写 order/order_item/fulfillment。
*/
export async function createSemiAutoIntegrationMock(
input: {
platform?: unknown
orderNo?: unknown
skuName?: unknown
quantity?: unknown
pageTitle?: unknown
browserTargetUrl?: unknown
connectorMode?: unknown
} = {},
): Promise<DevSemiAutoIntegrationResult> {
assertDevMockEnabled()
const platform = normalizeMockSemiAutoPlatform(input.platform)
const suffix = `${Date.now()}_${Math.floor(Math.random() * 1_000_000)}`
const orderNo = String(
input.orderNo || `${platform === 'weibo' ? 'INTWB' : 'INTSA'}${suffix}`,
).trim()
const skuKey = normalizeMockSemiAutoSku(
input.skuName || `${platform === 'weibo' ? '微博' : '虎牙'}真实链路测试-${suffix}`,
platform,
)
const quantity = normalizeMockSemiAutoQuantity(input.quantity)
const connectorMode =
platform === 'weibo' ? 'embedded' : normalizeMockSemiAutoConnectorMode(input.connectorMode)
const provider = 'dev_integration'
const sourcePlatform = 'internal_test'
const shopId = 'dev-integration-shop'
const externalSkuCode = `INTEGRATION-${suffix}`
const pageTitle = String(
input.pageTitle || (platform === 'weibo' ? '微博账号登录授权' : '虎牙账号登录授权'),
)
.trim()
.slice(0, 60)
const browserTargetUrl = String(
input.browserTargetUrl ||
(platform === 'weibo' ? 'https://weibo.com/' : 'https://www.huya.com/'),
)
.trim()
.slice(0, 1000)
const existing = await findOrderByPlatformOrderId({
provider,
platform: sourcePlatform,
shopId,
platformOrderId: orderNo,
})
if (existing) {
throw createHttpError(`订单号已存在:${orderNo},请换一个或留空自动生成`, {
statusCode: 409,
errorCode: 'dev_integration_order_exists',
})
type PersistManualIntegrationOrderInput = {
orderNo: string
skuKey: string
externalSkuCode: string
provider: string
sourcePlatform: string
shopId: string
shopName: string
buyerId: string
buyerName: string
sourceTag: string
rawPayload: Record<string, unknown>
itemSnapshot: Record<string, unknown>
configNote: string
quantity?: number
semiAuto?: {
platform: 'huya' | 'weibo'
config: Record<string, unknown>
}
}
type PersistManualIntegrationOrderResult = {
orderId: number
orderNo: string
orderItemId: number
fulfillmentId: number
configId: number
mappingId: number
skuKey: string
}
/**
* 通过正式订单入口创建人工渠道测试单。
*
* 是否生成旧半自动任务由 semi_auto_enabled 决定,调用方无需直接写订单、
* 履约或任务表。
*/
async function persistManualIntegrationOrder(
input: PersistManualIntegrationOrderInput,
): Promise<PersistManualIntegrationOrderResult> {
const quantity = normalizeMockSemiAutoQuantity(input.quantity)
const config = await saveManualFulfillmentConfig({
skuKey,
skuKey: input.skuKey,
enabled: true,
note: '开发集成测试:真实订单履约链路',
note: input.configNote,
channels: [{ platformKey: 'fund_cash', creditQuantity: 100, enabled: true }],
semiAutoEnabled: true,
semiAutoPlatform: platform,
semiAutoConfig: {
pageTitle,
pageDescription: '真实入库链路测试订单:登录与 CK 获取使用当前 Connector。',
loginInstructions: '请使用本人账号完成登录授权,客服后续人工处理。',
loginMethods: ['sms', 'qr'],
browserTargets: [
{
key: platform,
label: platform === 'weibo' ? '微博' : '虎牙',
url: browserTargetUrl,
},
],
},
semiAutoEnabled: Boolean(input.semiAuto),
...(input.semiAuto
? {
semiAutoPlatform: input.semiAuto.platform,
semiAutoConfig: input.semiAuto.config,
}
: {}),
})
const configId = Number(config.id || 0)
if (!configId) {
@@ -620,53 +613,47 @@ export async function createSemiAutoIntegrationMock(
})
}
const mappingId = await upsertInternalSkuMapping({
provider,
shopId,
provider: input.provider,
shopId: input.shopId,
matchType: 'sku_code',
matchValue: externalSkuCode,
internalSku: skuKey,
matchValue: input.externalSkuCode,
internalSku: input.skuKey,
priority: 1000,
source: 'dev_integration',
note: `订单 ${orderNo}`,
source: input.sourceTag,
note: `订单 ${input.orderNo}`,
})
const now = nowIso()
const upserted = await upsertOrderFromSource(
{
provider,
platform: sourcePlatform,
shopId,
shopName: '半自动真实链路测试店',
platformOrderId: orderNo,
provider: input.provider,
platform: input.sourcePlatform,
shopId: input.shopId,
shopName: input.shopName,
platformOrderId: input.orderNo,
orderStatus: 'paid',
payStatus: 'paid',
buyerId: `integration-buyer-${suffix}`,
buyerName: '集成测试客户',
buyerId: input.buyerId,
buyerName: input.buyerName,
receiverContact: '',
totalAmount: 100 * quantity,
currency: 'CNY',
rawPayload: {
source: 'dev_integration',
orderNo,
skuKey,
platform,
...input.rawPayload,
createdAt: now,
},
paidAt: now,
items: [
{
quantity,
skuCode: externalSkuCode,
skuName: skuKey,
skuCode: input.externalSkuCode,
skuName: input.skuKey,
spec: {},
snapshot: {
source: 'dev_integration',
semiAuto: { platform },
},
snapshot: input.itemSnapshot,
},
],
},
{ sourceLabel: 'dev_semi_auto_integration' },
{ sourceLabel: input.sourceTag },
)
if (upserted.ignored || !upserted.order) {
throw createHttpError(upserted.ignoreReason || '真实链路订单入库失败', {
@@ -727,38 +714,167 @@ export async function createSemiAutoIntegrationMock(
expected: { status: 'assigned', channel: 'manual' },
onlyWhenConfigNull: true,
})
await ensureSemiAutoTasksForOrderItems([orderItemId])
const resolved = await query<{
fulfillment_id: number
fulfillment_channel: string
fulfillment_status: string
task_id: number
}>(
`
SELECT
f.id AS fulfillment_id,
f.channel AS fulfillment_channel,
f.status AS fulfillment_status,
f.status AS fulfillment_status
FROM fulfillments f
WHERE f.order_item_id = $1
LIMIT 1
`,
[orderItemId],
)
const fulfillment = resolved.rows[0]
if (
!fulfillment ||
fulfillment.fulfillment_channel !== 'manual' ||
fulfillment.fulfillment_status !== 'assigned'
) {
throw createHttpError(
`真实链路未生成人工履约:channel=${fulfillment?.fulfillment_channel || ''}, status=${fulfillment?.fulfillment_status || ''}`,
{ statusCode: 500, errorCode: 'dev_integration_manual_fulfillment_failed' },
)
}
return {
orderId: Number(upserted.order.id),
orderNo: input.orderNo,
orderItemId,
fulfillmentId: Number(fulfillment.fulfillment_id),
configId,
mappingId,
skuKey: input.skuKey,
}
}
/**
* 真实履约链路集成测试单。
*
* 订单必须通过正式 upsertOrderFromSource 入库,再走 SKU 映射、渠道判定和
* Carrier 补偿;不直接写 order/order_item/fulfillment。
*/
export async function createSemiAutoIntegrationMock(
input: {
platform?: unknown
orderNo?: unknown
skuName?: unknown
quantity?: unknown
pageTitle?: unknown
browserTargetUrl?: unknown
connectorMode?: unknown
} = {},
): Promise<DevSemiAutoIntegrationResult> {
assertDevMockEnabled()
const platform = normalizeMockSemiAutoPlatform(input.platform)
const suffix = `${Date.now()}_${Math.floor(Math.random() * 1_000_000)}`
const orderNo = String(
input.orderNo || `${platform === 'weibo' ? 'INTWB' : 'INTSA'}${suffix}`,
).trim()
const skuKey = normalizeMockSemiAutoSku(
input.skuName || `${platform === 'weibo' ? '微博' : '虎牙'}真实链路测试-${suffix}`,
platform,
)
const quantity = normalizeMockSemiAutoQuantity(input.quantity)
const connectorMode =
platform === 'weibo' ? 'embedded' : normalizeMockSemiAutoConnectorMode(input.connectorMode)
const provider = 'dev_integration'
const sourcePlatform = 'internal_test'
const shopId = 'dev-integration-shop'
const externalSkuCode = `INTEGRATION-${suffix}`
const pageTitle = String(
input.pageTitle || (platform === 'weibo' ? '微博账号登录授权' : '虎牙账号登录授权'),
)
.trim()
.slice(0, 60)
const browserTargetUrl = String(
input.browserTargetUrl ||
(platform === 'weibo' ? 'https://weibo.com/' : 'https://www.huya.com/'),
)
.trim()
.slice(0, 1000)
const existing = await findOrderByPlatformOrderId({
provider,
platform: sourcePlatform,
shopId,
platformOrderId: orderNo,
})
if (existing) {
throw createHttpError(`订单号已存在:${orderNo},请换一个或留空自动生成`, {
statusCode: 409,
errorCode: 'dev_integration_order_exists',
})
}
const persisted = await persistManualIntegrationOrder({
orderNo,
skuKey,
externalSkuCode,
provider,
sourcePlatform,
shopId,
shopName: '半自动真实链路测试店',
buyerId: `integration-buyer-${suffix}`,
buyerName: '集成测试客户',
sourceTag: 'dev_semi_auto_integration',
rawPayload: {
source: 'dev_integration',
orderNo,
skuKey,
platform,
},
itemSnapshot: {
source: 'dev_integration',
semiAuto: { platform },
},
configNote: '开发集成测试:真实订单履约链路',
quantity,
semiAuto: {
platform,
config: {
pageTitle,
pageDescription: '真实入库链路测试订单:登录与 CK 获取使用当前 Connector。',
loginInstructions: '请使用本人账号完成登录授权,客服后续人工处理。',
loginMethods: ['sms', 'qr'],
browserTargets: [
{
key: platform,
label: platform === 'weibo' ? '微博' : '虎牙',
url: browserTargetUrl,
},
],
},
},
})
await ensureSemiAutoTasksForOrderItems([persisted.orderItemId])
const resolved = await query<{
task_id: number
}>(
`
SELECT
task.id AS task_id
FROM fulfillments f
LEFT JOIN semi_auto_tasks task ON task.order_item_id = f.order_item_id
WHERE f.order_item_id = $1
LIMIT 1
`,
[orderItemId],
[persisted.orderItemId],
)
const row = resolved.rows[0]
if (
!row ||
row.fulfillment_channel !== 'manual' ||
row.fulfillment_status !== 'assigned' ||
!Number(row.task_id)
) {
throw createHttpError(
`真实链路未生成半自动任务:channel=${row?.fulfillment_channel || ''}, status=${row?.fulfillment_status || ''}, task=${row?.task_id || 0}`,
{ statusCode: 500, errorCode: 'dev_integration_semi_auto_task_failed' },
)
if (!row || !Number(row.task_id)) {
throw createHttpError('真实链路未生成半自动任务', {
statusCode: 500,
errorCode: 'dev_integration_semi_auto_task_failed',
})
}
await query('UPDATE semi_auto_tasks SET connector_mode = $2, updated_at = NOW() WHERE id = $1', [
@@ -771,17 +887,17 @@ export async function createSemiAutoIntegrationMock(
platform: 'semi_auto',
semiAutoPlatform: platform,
pipeline: 'order_service',
orderId: Number(upserted.order.id),
orderNo,
orderItemId,
fulfillmentId: Number(row.fulfillment_id),
configId,
orderId: persisted.orderId,
orderNo: persisted.orderNo,
orderItemId: persisted.orderItemId,
fulfillmentId: persisted.fulfillmentId,
configId: persisted.configId,
taskId: Number(row.task_id),
skuKey,
skuKey: persisted.skuKey,
connectorMode,
connectorConfigured,
mappingId,
customerPath: buildMockCustomerPath(platform, orderNo),
mappingId: persisted.mappingId,
customerPath: buildMockCustomerPath(platform, persisted.orderNo),
adminPath: `/admin/semi-auto-tasks?keyword=${encodeURIComponent(orderNo)}`,
tips: [
'订单通过正式 upsertOrderFromSource 入库。',
@@ -794,6 +910,109 @@ export async function createSemiAutoIntegrationMock(
}
}
/**
* 斗鱼直播账号履约专用测试单。
*
* 只生成 live-hub 工作台需要的正式人工履约数据,不启用 order_site 的
* huya/weibo 半自动任务。
*/
export async function createDouyuFulfillmentMock(
input: {
orderNo?: unknown
skuName?: unknown
} = {},
): Promise<DevDouyuFulfillmentMockResult> {
assertDevMockEnabled()
const suffix = `${Date.now()}_${Math.floor(Math.random() * 1_000_000)}`
const orderNo = String(input.orderNo || `LIVEHUBDOUYU${suffix}`).trim()
const requestedSkuKey = String(input.skuName || `斗鱼精英宝典联调-${suffix}`)
.trim()
.slice(0, 48)
if (!requestedSkuKey || !containsCjk(requestedSkuKey)) {
throw createHttpError('内部 SKU 名称必须包含中文', {
statusCode: 400,
errorCode: 'dev_douyu_fulfillment_sku_invalid',
})
}
const provider = 'livehub_douyu_dev'
const sourcePlatform = 'internal_test'
const shopId = 'livehub-douyu-dev-shop'
const existing = await findOrderByPlatformOrderId({
provider,
platform: sourcePlatform,
shopId,
platformOrderId: orderNo,
})
if (existing) {
throw createHttpError(`订单号已存在:${orderNo},请换一个或留空自动生成`, {
statusCode: 409,
errorCode: 'dev_douyu_fulfillment_order_exists',
})
}
const persisted = await persistManualIntegrationOrder({
orderNo,
skuKey: requestedSkuKey,
externalSkuCode: `DOUYU-FULFILLMENT-${suffix}`,
provider,
sourcePlatform,
shopId,
shopName: '直播账号履约联调店',
buyerId: `douyu-fulfillment-buyer-${suffix}`,
buyerName: '斗鱼履约联调客户',
sourceTag: 'dev_douyu_fulfillment',
rawPayload: {
source: 'dev_douyu_fulfillment',
orderNo,
skuKey: requestedSkuKey,
targetPlatform: 'douyu',
},
itemSnapshot: {
source: 'dev_douyu_fulfillment',
targetPlatform: 'douyu',
scope: 'elite',
},
configNote: '开发 Mock:斗鱼直播账号履约',
})
const verification = await query<{
semi_auto_task_count: number
semi_auto_enabled: boolean
}>(
`
SELECT
COUNT(task.id)::int AS semi_auto_task_count,
BOOL_OR(cfg.semi_auto_enabled) AS semi_auto_enabled
FROM fulfillments f
JOIN manual_fulfillment_configs cfg ON cfg.id = f.fulfillment_config_id
LEFT JOIN semi_auto_tasks task ON task.order_item_id = f.order_item_id
WHERE f.id = $1
`,
[persisted.fulfillmentId],
)
const row = verification.rows[0]
if (Number(row?.semi_auto_task_count || 0) > 0 || row?.semi_auto_enabled === true) {
throw createHttpError('斗鱼专用 Mock 不应生成半自动任务', {
statusCode: 500,
errorCode: 'dev_douyu_fulfillment_semi_auto_conflict',
})
}
return {
platform: 'douyu',
pipeline: 'order_service',
...persisted,
adminPath: `/admin/orders/${persisted.orderId}`,
tips: [
'订单已通过 upsertOrderFromSource 正式入库。',
'履约渠道为 manual,状态为 assigned,且不会生成 huya/weibo 半自动任务。',
`在 live-hub 直播账号履约工作台同步后,用内部 SKU「${persisted.skuKey}」配置斗鱼商品映射。`,
],
}
}
function normalizeMockSemiAutoPlatform(value: unknown): 'huya' | 'weibo' {
return String(value || '')
.trim()
@@ -766,3 +766,93 @@ test(
}
},
)
test(
'斗鱼直播账号履约 Mock 只生成正式人工履约,不生成半自动任务',
{ skip: !TEST_DATABASE_URL ? '未设置 SEMI_AUTO_TASK_TEST_DATABASE_URL' : false },
async () => {
process.env.DATABASE_URL = TEST_DATABASE_URL
process.env.ENABLE_DEV_MOCK = '1'
const { closeDb, query, withTransaction } = await import('../../db/client.js')
const { createDouyuFulfillmentMock } = await import('../dev-mock/dev-mock-service.js')
const suffix = `${Date.now()}_${Math.floor(Math.random() * 1_000_000)}`
const orderNo = `IT-DOUYU-FULFILLMENT-${suffix}`
const skuKey = `斗鱼精英宝典联调-${suffix}`
let orderId = 0
let configId = 0
let mappingId = 0
try {
const result = await createDouyuFulfillmentMock({
orderNo,
skuName: skuKey,
})
orderId = result.orderId
configId = result.configId
mappingId = result.mappingId
assert.equal(result.platform, 'douyu')
assert.equal(result.pipeline, 'order_service')
assert.equal(result.orderNo, orderNo)
assert.equal(result.skuKey, skuKey)
assert.ok(result.orderItemId > 0)
assert.ok(result.fulfillmentId > 0)
const stored = await query<{
channel: string
fulfillment_status: string
fulfillment_config_id: number
semi_auto_enabled: boolean
semi_auto_task_count: number
internal_sku: string
}>(
`
SELECT
f.channel,
f.status AS fulfillment_status,
f.fulfillment_config_id,
cfg.semi_auto_enabled,
(
SELECT COUNT(*)::int
FROM semi_auto_tasks task
WHERE task.order_item_id = f.order_item_id
) AS semi_auto_task_count,
resolve_internal_sku(oi.manual_sku_key, oi.sku_name, oi.sku_code) AS internal_sku
FROM fulfillments f
JOIN order_items oi ON oi.id = f.order_item_id
JOIN manual_fulfillment_configs cfg ON cfg.id = f.fulfillment_config_id
WHERE f.id = $1
`,
[result.fulfillmentId],
)
assert.equal(stored.rows[0]?.channel, 'manual')
assert.equal(stored.rows[0]?.fulfillment_status, 'assigned')
assert.equal(Number(stored.rows[0]?.fulfillment_config_id), result.configId)
assert.equal(stored.rows[0]?.semi_auto_enabled, false)
assert.equal(Number(stored.rows[0]?.semi_auto_task_count), 0)
assert.equal(stored.rows[0]?.internal_sku, skuKey)
const mapping = await query<{ internal_sku: string }>(
'SELECT internal_sku FROM internal_sku_mappings WHERE id = $1',
[result.mappingId],
)
assert.equal(mapping.rows[0]?.internal_sku, skuKey)
} finally {
await withTransaction(async (client) => {
await client.query("SET LOCAL session_replication_role = 'replica'")
if (configId > 0) {
await client.query('DELETE FROM manual_fulfillment_configs WHERE id = $1', [configId])
}
if (orderId > 0) {
await client.query('DELETE FROM order_source_snapshots WHERE order_id = $1', [orderId])
await client.query('DELETE FROM orders WHERE id = $1', [orderId])
}
if (mappingId > 0) {
await client.query('DELETE FROM internal_sku_mappings WHERE id = $1', [mappingId])
}
})
delete process.env.ENABLE_DEV_MOCK
await closeDb()
}
},
)
+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;