feat(dev-mock): 新增斗鱼履约 Mock 与分页控制台
- 增加斗鱼客户履约 Mock 订单与角色绑定联调能力 - 重构开发 Mock 控制台为可切换分页界面 - 补充斗鱼履约 Mock 集成测试
This commit is contained in:
@@ -3,6 +3,7 @@ import { Router } from 'express'
|
|||||||
import {
|
import {
|
||||||
buildOpen91QueryMock,
|
buildOpen91QueryMock,
|
||||||
createAffiliateDashMockClaim,
|
createAffiliateDashMockClaim,
|
||||||
|
createDouyuFulfillmentMock,
|
||||||
createKuaishouIndustryVoucherMockData,
|
createKuaishouIndustryVoucherMockData,
|
||||||
createSemiAutoIntegrationMock,
|
createSemiAutoIntegrationMock,
|
||||||
createSemiAutoMock,
|
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(
|
router.post(
|
||||||
'/dev-mock/semi-auto',
|
'/dev-mock/semi-auto',
|
||||||
createJsonHandler((req) => createSemiAutoMock(req.body || {}), {
|
createJsonHandler((req) => createSemiAutoMock(req.body || {}), {
|
||||||
|
|||||||
@@ -93,6 +93,20 @@ export type DevSemiAutoIntegrationResult = DevMockSemiAutoResult & {
|
|||||||
mappingId: number
|
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() {
|
export function getDevMockStatus() {
|
||||||
const enabled = isDevMockEnabled()
|
const enabled = isDevMockEnabled()
|
||||||
return {
|
return {
|
||||||
@@ -113,6 +127,12 @@ export function getDevMockStatus() {
|
|||||||
'创建人工渠道半自动测试单;可选择仅 Mock 订单,登录、绑定和票据注入走真实 Connector',
|
'创建人工渠道半自动测试单;可选择仅 Mock 订单,登录、绑定和票据注入走真实 Connector',
|
||||||
steps: ['create_order', 'login', 'binding', 'browser_ticket', 'complete'],
|
steps: ['create_order', 'login', 'binding', 'browser_ticket', 'complete'],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'douyu_fulfillment',
|
||||||
|
name: '斗鱼直播账号履约',
|
||||||
|
description: '创建正式人工渠道测试单,供 live-hub 直播账号履约工作台读取',
|
||||||
|
steps: ['create_order', 'sync_livehub', 'map_commodity'],
|
||||||
|
},
|
||||||
]
|
]
|
||||||
: [],
|
: [],
|
||||||
defaultUid: '10001',
|
defaultUid: '10001',
|
||||||
@@ -531,86 +551,59 @@ export async function createSemiAutoMock(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
type PersistManualIntegrationOrderInput = {
|
||||||
* 真实履约链路集成测试单。
|
orderNo: string
|
||||||
*
|
skuKey: string
|
||||||
* 订单必须通过正式 upsertOrderFromSource 入库,再走 SKU 映射、渠道判定和
|
externalSkuCode: string
|
||||||
* Carrier 补偿;不直接写 order/order_item/fulfillment。
|
provider: string
|
||||||
*/
|
sourcePlatform: string
|
||||||
export async function createSemiAutoIntegrationMock(
|
shopId: string
|
||||||
input: {
|
shopName: string
|
||||||
platform?: unknown
|
buyerId: string
|
||||||
orderNo?: unknown
|
buyerName: string
|
||||||
skuName?: unknown
|
sourceTag: string
|
||||||
quantity?: unknown
|
rawPayload: Record<string, unknown>
|
||||||
pageTitle?: unknown
|
itemSnapshot: Record<string, unknown>
|
||||||
browserTargetUrl?: unknown
|
configNote: string
|
||||||
connectorMode?: unknown
|
quantity?: number
|
||||||
} = {},
|
semiAuto?: {
|
||||||
): Promise<DevSemiAutoIntegrationResult> {
|
platform: 'huya' | 'weibo'
|
||||||
assertDevMockEnabled()
|
config: Record<string, unknown>
|
||||||
|
|
||||||
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 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({
|
const config = await saveManualFulfillmentConfig({
|
||||||
skuKey,
|
skuKey: input.skuKey,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
note: '开发集成测试:真实订单履约链路',
|
note: input.configNote,
|
||||||
channels: [{ platformKey: 'fund_cash', creditQuantity: 100, enabled: true }],
|
channels: [{ platformKey: 'fund_cash', creditQuantity: 100, enabled: true }],
|
||||||
semiAutoEnabled: true,
|
semiAutoEnabled: Boolean(input.semiAuto),
|
||||||
semiAutoPlatform: platform,
|
...(input.semiAuto
|
||||||
semiAutoConfig: {
|
? {
|
||||||
pageTitle,
|
semiAutoPlatform: input.semiAuto.platform,
|
||||||
pageDescription: '真实入库链路测试订单:登录与 CK 获取使用当前 Connector。',
|
semiAutoConfig: input.semiAuto.config,
|
||||||
loginInstructions: '请使用本人账号完成登录授权,客服后续人工处理。',
|
}
|
||||||
loginMethods: ['sms', 'qr'],
|
: {}),
|
||||||
browserTargets: [
|
|
||||||
{
|
|
||||||
key: platform,
|
|
||||||
label: platform === 'weibo' ? '微博' : '虎牙',
|
|
||||||
url: browserTargetUrl,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
const configId = Number(config.id || 0)
|
const configId = Number(config.id || 0)
|
||||||
if (!configId) {
|
if (!configId) {
|
||||||
@@ -620,53 +613,47 @@ export async function createSemiAutoIntegrationMock(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
const mappingId = await upsertInternalSkuMapping({
|
const mappingId = await upsertInternalSkuMapping({
|
||||||
provider,
|
provider: input.provider,
|
||||||
shopId,
|
shopId: input.shopId,
|
||||||
matchType: 'sku_code',
|
matchType: 'sku_code',
|
||||||
matchValue: externalSkuCode,
|
matchValue: input.externalSkuCode,
|
||||||
internalSku: skuKey,
|
internalSku: input.skuKey,
|
||||||
priority: 1000,
|
priority: 1000,
|
||||||
source: 'dev_integration',
|
source: input.sourceTag,
|
||||||
note: `订单 ${orderNo}`,
|
note: `订单 ${input.orderNo}`,
|
||||||
})
|
})
|
||||||
|
|
||||||
const now = nowIso()
|
const now = nowIso()
|
||||||
const upserted = await upsertOrderFromSource(
|
const upserted = await upsertOrderFromSource(
|
||||||
{
|
{
|
||||||
provider,
|
provider: input.provider,
|
||||||
platform: sourcePlatform,
|
platform: input.sourcePlatform,
|
||||||
shopId,
|
shopId: input.shopId,
|
||||||
shopName: '半自动真实链路测试店',
|
shopName: input.shopName,
|
||||||
platformOrderId: orderNo,
|
platformOrderId: input.orderNo,
|
||||||
orderStatus: 'paid',
|
orderStatus: 'paid',
|
||||||
payStatus: 'paid',
|
payStatus: 'paid',
|
||||||
buyerId: `integration-buyer-${suffix}`,
|
buyerId: input.buyerId,
|
||||||
buyerName: '集成测试客户',
|
buyerName: input.buyerName,
|
||||||
receiverContact: '',
|
receiverContact: '',
|
||||||
totalAmount: 100 * quantity,
|
totalAmount: 100 * quantity,
|
||||||
currency: 'CNY',
|
currency: 'CNY',
|
||||||
rawPayload: {
|
rawPayload: {
|
||||||
source: 'dev_integration',
|
...input.rawPayload,
|
||||||
orderNo,
|
|
||||||
skuKey,
|
|
||||||
platform,
|
|
||||||
createdAt: now,
|
createdAt: now,
|
||||||
},
|
},
|
||||||
paidAt: now,
|
paidAt: now,
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
quantity,
|
quantity,
|
||||||
skuCode: externalSkuCode,
|
skuCode: input.externalSkuCode,
|
||||||
skuName: skuKey,
|
skuName: input.skuKey,
|
||||||
spec: {},
|
spec: {},
|
||||||
snapshot: {
|
snapshot: input.itemSnapshot,
|
||||||
source: 'dev_integration',
|
|
||||||
semiAuto: { platform },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{ sourceLabel: 'dev_semi_auto_integration' },
|
{ sourceLabel: input.sourceTag },
|
||||||
)
|
)
|
||||||
if (upserted.ignored || !upserted.order) {
|
if (upserted.ignored || !upserted.order) {
|
||||||
throw createHttpError(upserted.ignoreReason || '真实链路订单入库失败', {
|
throw createHttpError(upserted.ignoreReason || '真实链路订单入库失败', {
|
||||||
@@ -727,38 +714,167 @@ export async function createSemiAutoIntegrationMock(
|
|||||||
expected: { status: 'assigned', channel: 'manual' },
|
expected: { status: 'assigned', channel: 'manual' },
|
||||||
onlyWhenConfigNull: true,
|
onlyWhenConfigNull: true,
|
||||||
})
|
})
|
||||||
await ensureSemiAutoTasksForOrderItems([orderItemId])
|
|
||||||
|
|
||||||
const resolved = await query<{
|
const resolved = await query<{
|
||||||
fulfillment_id: number
|
fulfillment_id: number
|
||||||
fulfillment_channel: string
|
fulfillment_channel: string
|
||||||
fulfillment_status: string
|
fulfillment_status: string
|
||||||
task_id: number
|
|
||||||
}>(
|
}>(
|
||||||
`
|
`
|
||||||
SELECT
|
SELECT
|
||||||
f.id AS fulfillment_id,
|
f.id AS fulfillment_id,
|
||||||
f.channel AS fulfillment_channel,
|
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
|
task.id AS task_id
|
||||||
FROM fulfillments f
|
FROM fulfillments f
|
||||||
LEFT JOIN semi_auto_tasks task ON task.order_item_id = f.order_item_id
|
LEFT JOIN semi_auto_tasks task ON task.order_item_id = f.order_item_id
|
||||||
WHERE f.order_item_id = $1
|
WHERE f.order_item_id = $1
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
`,
|
`,
|
||||||
[orderItemId],
|
[persisted.orderItemId],
|
||||||
)
|
)
|
||||||
const row = resolved.rows[0]
|
const row = resolved.rows[0]
|
||||||
if (
|
if (!row || !Number(row.task_id)) {
|
||||||
!row ||
|
throw createHttpError('真实链路未生成半自动任务', {
|
||||||
row.fulfillment_channel !== 'manual' ||
|
statusCode: 500,
|
||||||
row.fulfillment_status !== 'assigned' ||
|
errorCode: 'dev_integration_semi_auto_task_failed',
|
||||||
!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' },
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await query('UPDATE semi_auto_tasks SET connector_mode = $2, updated_at = NOW() WHERE id = $1', [
|
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',
|
platform: 'semi_auto',
|
||||||
semiAutoPlatform: platform,
|
semiAutoPlatform: platform,
|
||||||
pipeline: 'order_service',
|
pipeline: 'order_service',
|
||||||
orderId: Number(upserted.order.id),
|
orderId: persisted.orderId,
|
||||||
orderNo,
|
orderNo: persisted.orderNo,
|
||||||
orderItemId,
|
orderItemId: persisted.orderItemId,
|
||||||
fulfillmentId: Number(row.fulfillment_id),
|
fulfillmentId: persisted.fulfillmentId,
|
||||||
configId,
|
configId: persisted.configId,
|
||||||
taskId: Number(row.task_id),
|
taskId: Number(row.task_id),
|
||||||
skuKey,
|
skuKey: persisted.skuKey,
|
||||||
connectorMode,
|
connectorMode,
|
||||||
connectorConfigured,
|
connectorConfigured,
|
||||||
mappingId,
|
mappingId: persisted.mappingId,
|
||||||
customerPath: buildMockCustomerPath(platform, orderNo),
|
customerPath: buildMockCustomerPath(platform, persisted.orderNo),
|
||||||
adminPath: `/admin/semi-auto-tasks?keyword=${encodeURIComponent(orderNo)}`,
|
adminPath: `/admin/semi-auto-tasks?keyword=${encodeURIComponent(orderNo)}`,
|
||||||
tips: [
|
tips: [
|
||||||
'订单通过正式 upsertOrderFromSource 入库。',
|
'订单通过正式 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' {
|
function normalizeMockSemiAutoPlatform(value: unknown): 'huya' | 'weibo' {
|
||||||
return String(value || '')
|
return String(value || '')
|
||||||
.trim()
|
.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()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|||||||
@@ -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 {
|
import {
|
||||||
Alert,
|
Alert,
|
||||||
App,
|
App,
|
||||||
@@ -6,13 +15,17 @@ import {
|
|||||||
Card,
|
Card,
|
||||||
Col,
|
Col,
|
||||||
Divider,
|
Divider,
|
||||||
|
Empty,
|
||||||
Form,
|
Form,
|
||||||
Input,
|
Input,
|
||||||
InputNumber,
|
InputNumber,
|
||||||
Result,
|
Result,
|
||||||
Row,
|
Row,
|
||||||
|
Segmented,
|
||||||
Select,
|
Select,
|
||||||
Space,
|
Space,
|
||||||
|
Tabs,
|
||||||
|
Tag,
|
||||||
Typography,
|
Typography,
|
||||||
} from 'antd'
|
} from 'antd'
|
||||||
import { useMutation, useQuery } from '@tanstack/react-query'
|
import { useMutation, useQuery } from '@tanstack/react-query'
|
||||||
@@ -23,6 +36,7 @@ import PageHeader from '@/components/admin/PageHeader'
|
|||||||
import {
|
import {
|
||||||
buildOpen91QueryDevMock,
|
buildOpen91QueryDevMock,
|
||||||
createAffiliateDashDevMock,
|
createAffiliateDashDevMock,
|
||||||
|
createDouyuFulfillmentDevMock,
|
||||||
createKuaishouIndustryVoucherDevMock,
|
createKuaishouIndustryVoucherDevMock,
|
||||||
createSemiAutoDevMock,
|
createSemiAutoDevMock,
|
||||||
createSemiAutoIntegrationDevMock,
|
createSemiAutoIntegrationDevMock,
|
||||||
@@ -31,16 +45,24 @@ import {
|
|||||||
type DevMockKuaishouIndustryVoucherResult,
|
type DevMockKuaishouIndustryVoucherResult,
|
||||||
type DevMockOpen91QueryResult,
|
type DevMockOpen91QueryResult,
|
||||||
type DevMockSemiAutoResult,
|
type DevMockSemiAutoResult,
|
||||||
|
type DevDouyuFulfillmentMockResult,
|
||||||
type DevSemiAutoIntegrationResult,
|
type DevSemiAutoIntegrationResult,
|
||||||
} from '@/services/admin'
|
} from '@/services/admin'
|
||||||
import { buildCustomerFulfillmentPath } from '@/utils/customer-fulfillment-link'
|
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() {
|
export default function AdminDevMockPage() {
|
||||||
const { message } = App.useApp()
|
const { message } = App.useApp()
|
||||||
|
const [activeTab, setActiveTab] = useState<MockTabKey>('douyu')
|
||||||
|
const [semiAutoMode, setSemiAutoMode] = useState<SemiAutoMode>('integration')
|
||||||
const [lastCreate, setLastCreate] = useState<DevMockCreateResult | null>(null)
|
const [lastCreate, setLastCreate] = useState<DevMockCreateResult | null>(null)
|
||||||
const [lastVoucherCreate, setLastVoucherCreate] =
|
const [lastVoucherCreate, setLastVoucherCreate] =
|
||||||
useState<DevMockKuaishouIndustryVoucherResult | null>(null)
|
useState<DevMockKuaishouIndustryVoucherResult | null>(null)
|
||||||
const [lastQuery, setLastQuery] = useState<DevMockOpen91QueryResult | null>(null)
|
const [lastQuery, setLastQuery] = useState<DevMockOpen91QueryResult | null>(null)
|
||||||
|
const [lastDouyuFulfillment, setLastDouyuFulfillment] =
|
||||||
|
useState<DevDouyuFulfillmentMockResult | null>(null)
|
||||||
const [lastSemiAuto, setLastSemiAuto] = useState<
|
const [lastSemiAuto, setLastSemiAuto] = useState<
|
||||||
DevMockSemiAutoResult | DevSemiAutoIntegrationResult | null
|
DevMockSemiAutoResult | DevSemiAutoIntegrationResult | null
|
||||||
>(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])
|
const defaultOrderNo = useMemo(() => lastCreate?.orderNo || '', [lastCreate?.orderNo])
|
||||||
// 页面展示按平台重新生成规范路径,避免历史 Mock 响应里的 customerPath 仍是 /c。
|
|
||||||
const semiAutoCustomerPath = lastSemiAuto
|
const semiAutoCustomerPath = lastSemiAuto
|
||||||
? buildCustomerFulfillmentPath(lastSemiAuto.orderNo, lastSemiAuto.semiAutoPlatform) ||
|
? buildCustomerFulfillmentPath(lastSemiAuto.orderNo, lastSemiAuto.semiAutoPlatform) ||
|
||||||
lastSemiAuto.customerPath
|
lastSemiAuto.customerPath
|
||||||
@@ -148,314 +180,561 @@ export default function AdminDevMockPage() {
|
|||||||
<section className="page-stack">
|
<section className="page-stack">
|
||||||
<PageHeader
|
<PageHeader
|
||||||
title="开发 Mock"
|
title="开发 Mock"
|
||||||
description="一键造单与测试数据;半自动履约可选择只 Mock 订单,登录、绑定走真实 Connector。"
|
description="按场景切换测试工具,只展示当前模块,减少长页面和误操作。"
|
||||||
extra={
|
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
|
<Alert
|
||||||
type="info"
|
type="warning"
|
||||||
showIcon
|
showIcon
|
||||||
icon={<BugOutlined />}
|
icon={<BugOutlined />}
|
||||||
message="Mock 会写入开发库真实订单/任务;除订单外,登录、绑定、票据注入和完成确认都可以走真实流程。"
|
message="仅用于开发环境"
|
||||||
description="默认使用 order_site 内置真实 Connector,不依赖 live-hub-py;只有显式选择内置 Mock 时才会 Mock 登录和绑定。"
|
description="Mock 会向当前开发库写入真实订单和任务。请先确认当前环境,再切换对应业务模块生成测试数据。"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Row gutter={[16, 16]}>
|
<Tabs
|
||||||
<Col xs={24} xl={12}>
|
className="dev-mock-tabs"
|
||||||
<Card title="1. affiliate-dash 领取(mock 二维码/提交发货)" bordered={false}>
|
type="card"
|
||||||
<AffiliateDashMockForm
|
activeKey={activeTab}
|
||||||
loading={affiliateDashMutation.isPending}
|
onChange={(key) => setActiveTab(key as MockTabKey)}
|
||||||
onSubmit={(values) => affiliateDashMutation.mutate(values)}
|
items={[
|
||||||
/>
|
{
|
||||||
</Card>
|
key: 'douyu',
|
||||||
</Col>
|
label: (
|
||||||
|
<Space size={6}>
|
||||||
<Col xs={24} xl={12}>
|
<ThunderboltOutlined />
|
||||||
<Card title="2. 半自动真实履约链路测试单" bordered={false}>
|
斗鱼履约
|
||||||
<Alert
|
</Space>
|
||||||
type="success"
|
),
|
||||||
showIcon
|
children: (
|
||||||
style={{ marginBottom: 12 }}
|
<Row gutter={[16, 16]}>
|
||||||
message="正式订单入口"
|
<Col xs={24} xl={14}>
|
||||||
description="订单走 upsertOrderFromSource,随后执行 SKU 映射、渠道判定、Carrier 补偿和半自动任务生成。"
|
<Card title="创建斗鱼履约测试单" extra={<Tag color="blue">正式订单链路</Tag>}>
|
||||||
/>
|
<Alert
|
||||||
<SemiAutoMockForm
|
type="success"
|
||||||
loading={semiAutoIntegrationMutation.isPending}
|
showIcon
|
||||||
submitText="生成真实链路测试单"
|
style={{ marginBottom: 16 }}
|
||||||
defaultConnectorMode={status?.semiAuto?.defaultConnectorMode}
|
message="供 live-hub 直播账号履约工作台读取"
|
||||||
externalConnectorConfigured={status?.semiAuto?.externalConnectorConfigured}
|
description="生成 manual + assigned 履约和内部 SKU 映射,不创建 huya/weibo 半自动任务。"
|
||||||
mockConnectorAvailable={status?.semiAuto?.mockConnectorAvailable}
|
/>
|
||||||
onSubmit={(values) => semiAutoIntegrationMutation.mutate(values)}
|
<DouyuFulfillmentMockForm
|
||||||
/>
|
loading={douyuFulfillmentMutation.isPending}
|
||||||
</Card>
|
onSubmit={(values) => douyuFulfillmentMutation.mutate(values)}
|
||||||
</Col>
|
/>
|
||||||
|
</Card>
|
||||||
<Col xs={24} xl={12}>
|
</Col>
|
||||||
<Card title="3. 半自动直连 Mock(页面联调)" bordered={false}>
|
<Col xs={24} xl={10}>
|
||||||
<SemiAutoMockForm
|
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
||||||
loading={semiAutoMutation.isPending}
|
{lastDouyuFulfillment ? (
|
||||||
defaultConnectorMode={status?.semiAuto?.defaultConnectorMode}
|
<DouyuFulfillmentResultCard result={lastDouyuFulfillment} />
|
||||||
externalConnectorConfigured={status?.semiAuto?.externalConnectorConfigured}
|
) : (
|
||||||
mockConnectorAvailable={status?.semiAuto?.mockConnectorAvailable}
|
<MockResultEmpty description="生成后显示订单号、内部 SKU 和履约 ID" />
|
||||||
onSubmit={(values) => semiAutoMutation.mutate(values)}
|
)}
|
||||||
/>
|
<Card size="small" title="联调口径">
|
||||||
</Card>
|
<ul style={{ margin: 0, paddingLeft: 18 }}>
|
||||||
</Col>
|
<li>订单走正式 upsertOrderFromSource 入库。</li>
|
||||||
|
<li>工作台同步后使用返回的内部 SKU 配置斗鱼商品映射。</li>
|
||||||
<Col xs={24} xl={12}>
|
<li>不生成半自动任务,客户绑定和人工兑换都在 live-hub 完成。</li>
|
||||||
<Card title="4. 快手电子凭证测试数据" bordered={false}>
|
</ul>
|
||||||
<KuaishouIndustryVoucherMockForm
|
</Card>
|
||||||
loading={voucherMutation.isPending}
|
</Space>
|
||||||
onSubmit={(values) => voucherMutation.mutate(values)}
|
</Col>
|
||||||
/>
|
</Row>
|
||||||
</Card>
|
),
|
||||||
</Col>
|
},
|
||||||
|
{
|
||||||
<Col xs={24}>
|
key: 'semi-auto',
|
||||||
<Card title="5. 模拟 91 查单(open-91/query)" bordered={false}>
|
label: (
|
||||||
<Form
|
<Space size={6}>
|
||||||
layout="inline"
|
<ApiOutlined />
|
||||||
initialValues={{ orderNo: defaultOrderNo, execute: '1' }}
|
半自动履约
|
||||||
key={defaultOrderNo}
|
</Space>
|
||||||
onFinish={(values) =>
|
),
|
||||||
open91Mutation.mutate({
|
children: (
|
||||||
orderNo: values.orderNo,
|
<Space direction="vertical" size={16} style={{ width: '100%' }}>
|
||||||
execute: values.execute === '1',
|
<Segmented
|
||||||
})
|
block
|
||||||
}
|
value={semiAutoMode}
|
||||||
>
|
onChange={(value) => setSemiAutoMode(value as SemiAutoMode)}
|
||||||
<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 }}
|
|
||||||
options={[
|
options={[
|
||||||
{ value: '1', label: '生成并请求本机' },
|
{ label: '正式订单链路', value: 'integration' },
|
||||||
{ value: '0', label: '仅生成请求体' },
|
{ label: '直连 Mock', value: 'direct' },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
<Row gutter={[16, 16]}>
|
||||||
<Form.Item>
|
<Col xs={24} xl={14}>
|
||||||
<Button type="primary" htmlType="submit" loading={open91Mutation.isPending}>
|
<Card
|
||||||
模拟 91 查单
|
title={semiAutoMode === 'integration' ? '正式链路测试单' : '页面直连 Mock'}
|
||||||
</Button>
|
extra={
|
||||||
</Form.Item>
|
<Tag color={semiAutoMode === 'integration' ? 'blue' : 'orange'}>
|
||||||
</Form>
|
{semiAutoMode === 'integration' ? 'upsertOrderFromSource' : '直连造单'}
|
||||||
<Typography.Paragraph type="secondary" style={{ marginTop: 12, marginBottom: 0 }}>
|
</Tag>
|
||||||
对应日志:POST /api/v1/open/91/orders/query。需配置 KAQUAN91_SECRET(32 位)。
|
}
|
||||||
</Typography.Paragraph>
|
>
|
||||||
</Card>
|
<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>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
</Card>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
{lastCreate ? (
|
function SemiAutoResultCard({
|
||||||
<Card
|
result,
|
||||||
title="最近生成结果"
|
customerUrl,
|
||||||
extra={
|
}: {
|
||||||
<Space>
|
result: DevMockSemiAutoResult | DevSemiAutoIntegrationResult
|
||||||
<Link to={`/admin/orders/${lastCreate.orderId}`}>订单 #{lastCreate.orderId}</Link>
|
customerUrl: string
|
||||||
<Link to={`/admin/tasks/${lastCreate.taskId}`}>任务 #{lastCreate.taskId}</Link>
|
}) {
|
||||||
</Space>
|
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'
|
||||||
}
|
}
|
||||||
>
|
showIcon
|
||||||
<Row gutter={[16, 12]}>
|
message={
|
||||||
<Col xs={24} md={12}>
|
result.connectorMode === 'mock'
|
||||||
<Typography.Text type="secondary">平台</Typography.Text>
|
? '当前使用内置 Mock Connector'
|
||||||
<div>
|
: result.connectorConfigured
|
||||||
<Typography.Text strong>{lastCreate.platform}</Typography.Text>
|
? result.connectorMode === 'external'
|
||||||
</div>
|
? '当前使用远程真实 Connector'
|
||||||
</Col>
|
: '当前使用 order_site 内置真实 Connector'
|
||||||
<Col xs={24} md={12}>
|
: '当前选择远程真实 Connector,但尚未配置'
|
||||||
<Typography.Text type="secondary">步骤 / UID</Typography.Text>
|
}
|
||||||
<div>
|
description={
|
||||||
<Typography.Text strong>
|
<ul style={{ margin: 0, paddingLeft: 18 }}>
|
||||||
{lastCreate.step} / {lastCreate.expectedUid}
|
{result.tips.map((tip) => (
|
||||||
</Typography.Text>
|
<li key={tip}>{tip}</li>
|
||||||
</div>
|
))}
|
||||||
</Col>
|
</ul>
|
||||||
<Col xs={24} md={12}>
|
}
|
||||||
<Typography.Text type="secondary">91 订单号</Typography.Text>
|
/>
|
||||||
<div>
|
</Space>
|
||||||
<Typography.Text copyable>{lastCreate.orderNo}</Typography.Text>
|
</Card>
|
||||||
</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}
|
|
||||||
|
|
||||||
{lastSemiAuto ? (
|
function KuaishouVoucherResultCard({ result }: { result: DevMockKuaishouIndustryVoucherResult }) {
|
||||||
<Card
|
return (
|
||||||
title="最近生成的半自动测试单"
|
<Card
|
||||||
extra={<Link to={lastSemiAuto.adminPath}>打开后台任务</Link>}
|
size="small"
|
||||||
>
|
title="最近结果"
|
||||||
<Row gutter={[16, 12]}>
|
extra={<Link to="/admin/kuaishou-industry">查看电子凭证</Link>}
|
||||||
<Col xs={24} md={12}>
|
>
|
||||||
<Typography.Text type="secondary">订单号</Typography.Text>
|
<Typography.Paragraph type="secondary">
|
||||||
<div>
|
已为店铺 {result.sellerId} 写入 {result.createdCount} 条测试券码。
|
||||||
<Typography.Text copyable strong>
|
</Typography.Paragraph>
|
||||||
{lastSemiAuto.orderNo}
|
<Space direction="vertical" size={6}>
|
||||||
</Typography.Text>
|
{result.vouchers.map((voucher) => (
|
||||||
</div>
|
<Typography.Text key={voucher.voucherCode} copyable>
|
||||||
</Col>
|
{voucher.status} · {voucher.voucherCode} · {voucher.oid}
|
||||||
<Col xs={24} md={12}>
|
</Typography.Text>
|
||||||
<Typography.Text type="secondary">内部 SKU / 任务</Typography.Text>
|
))}
|
||||||
<div>
|
</Space>
|
||||||
{lastSemiAuto.semiAutoPlatform === 'weibo' ? '微博' : '虎牙'} ·{' '}
|
</Card>
|
||||||
{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}
|
|
||||||
|
|
||||||
{lastVoucherCreate ? (
|
function Open91ResultCard({ result }: { result: DevMockOpen91QueryResult }) {
|
||||||
<Card
|
return (
|
||||||
title="最近生成的电子凭证 Mock"
|
<Card size="small" title="查单结果">
|
||||||
extra={<Link to="/admin/kuaishou-industry">查看电子凭证</Link>}
|
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
||||||
>
|
<div>
|
||||||
<Typography.Paragraph type="secondary">
|
<Typography.Text type="secondary">Endpoint</Typography.Text>
|
||||||
已为店铺 {lastVoucherCreate.sellerId} 写入 {lastVoucherCreate.createdCount} 条测试券码。
|
<div>
|
||||||
</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>
|
|
||||||
<Typography.Text code copyable>
|
<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.Text>
|
||||||
</Typography.Paragraph>
|
</Typography.Paragraph>
|
||||||
<Typography.Paragraph>
|
</div>
|
||||||
<Typography.Text type="secondary">Request:</Typography.Text>
|
{result.response ? (
|
||||||
</Typography.Paragraph>
|
<>
|
||||||
<pre className="dev-mock-pre">{JSON.stringify(lastQuery.requestBody, null, 2)}</pre>
|
<Divider style={{ margin: 0 }} />
|
||||||
<Typography.Paragraph>
|
<div>
|
||||||
<Typography.Text type="secondary">curl:</Typography.Text>
|
<Typography.Text type="secondary">Response</Typography.Text>
|
||||||
<Typography.Text code copyable>
|
<pre className="dev-mock-pre" style={{ marginTop: 6 }}>
|
||||||
{lastQuery.curl}
|
{JSON.stringify(result.response, null, 2)}
|
||||||
</Typography.Text>
|
</pre>
|
||||||
</Typography.Paragraph>
|
</div>
|
||||||
{lastQuery.response ? (
|
</>
|
||||||
<>
|
) : null}
|
||||||
<Divider />
|
</Space>
|
||||||
<Typography.Paragraph>
|
</Card>
|
||||||
<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>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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({
|
function SemiAutoMockForm({
|
||||||
loading,
|
loading,
|
||||||
submitText,
|
submitText,
|
||||||
|
|||||||
@@ -73,6 +73,20 @@ export type DevSemiAutoIntegrationResult = DevMockSemiAutoResult & {
|
|||||||
mappingId: number
|
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() {
|
export function fetchDevMockStatus() {
|
||||||
return apiGet<DevMockStatus>('/api/v1/admin/dev-mock/status')
|
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: {
|
export function buildOpen91QueryDevMock(payload: {
|
||||||
orderNo: string
|
orderNo: string
|
||||||
execute?: boolean
|
execute?: boolean
|
||||||
|
|||||||
@@ -123,6 +123,18 @@ select {
|
|||||||
line-height: 1.5;
|
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 {
|
.total-badge {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
Reference in New Issue
Block a user