完善半自动真实履约链路及虎牙账号资料保存
This commit is contained in:
@@ -25,11 +25,13 @@ import {
|
||||
createAffiliateDashDevMock,
|
||||
createKuaishouIndustryVoucherDevMock,
|
||||
createSemiAutoDevMock,
|
||||
createSemiAutoIntegrationDevMock,
|
||||
fetchDevMockStatus,
|
||||
type DevMockCreateResult,
|
||||
type DevMockKuaishouIndustryVoucherResult,
|
||||
type DevMockOpen91QueryResult,
|
||||
type DevMockSemiAutoResult,
|
||||
type DevSemiAutoIntegrationResult,
|
||||
} from '@/services/admin'
|
||||
|
||||
export default function AdminDevMockPage() {
|
||||
@@ -38,7 +40,9 @@ export default function AdminDevMockPage() {
|
||||
const [lastVoucherCreate, setLastVoucherCreate] =
|
||||
useState<DevMockKuaishouIndustryVoucherResult | null>(null)
|
||||
const [lastQuery, setLastQuery] = useState<DevMockOpen91QueryResult | null>(null)
|
||||
const [lastSemiAuto, setLastSemiAuto] = useState<DevMockSemiAutoResult | null>(null)
|
||||
const [lastSemiAuto, setLastSemiAuto] = useState<
|
||||
DevMockSemiAutoResult | DevSemiAutoIntegrationResult | null
|
||||
>(null)
|
||||
|
||||
const statusQuery = useQuery({
|
||||
queryKey: ['admin-dev-mock-status'],
|
||||
@@ -93,6 +97,17 @@ export default function AdminDevMockPage() {
|
||||
},
|
||||
})
|
||||
|
||||
const semiAutoIntegrationMutation = useMutation({
|
||||
mutationFn: createSemiAutoIntegrationDevMock,
|
||||
onSuccess: (response) => {
|
||||
setLastSemiAuto(response.data)
|
||||
message.success('半自动真实履约链路测试单已生成')
|
||||
},
|
||||
onError: (error) => {
|
||||
message.error(error instanceof Error ? error.message : '生成失败')
|
||||
},
|
||||
})
|
||||
|
||||
const defaultOrderNo = useMemo(() => lastCreate?.orderNo || '', [lastCreate?.orderNo])
|
||||
|
||||
if (statusQuery.isLoading) {
|
||||
@@ -149,7 +164,27 @@ export default function AdminDevMockPage() {
|
||||
</Col>
|
||||
|
||||
<Col xs={24} xl={12}>
|
||||
<Card title="2. 半自动履约测试单(可选 Mock 范围)" bordered={false}>
|
||||
<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}
|
||||
@@ -161,7 +196,7 @@ export default function AdminDevMockPage() {
|
||||
</Col>
|
||||
|
||||
<Col xs={24} xl={12}>
|
||||
<Card title="3. 快手电子凭证测试数据" bordered={false}>
|
||||
<Card title="4. 快手电子凭证测试数据" bordered={false}>
|
||||
<KuaishouIndustryVoucherMockForm
|
||||
loading={voucherMutation.isPending}
|
||||
onSubmit={(values) => voucherMutation.mutate(values)}
|
||||
@@ -170,7 +205,7 @@ export default function AdminDevMockPage() {
|
||||
</Col>
|
||||
|
||||
<Col xs={24}>
|
||||
<Card title="4. 模拟 91 查单(open-91/query)" bordered={false}>
|
||||
<Card title="5. 模拟 91 查单(open-91/query)" bordered={false}>
|
||||
<Form
|
||||
layout="inline"
|
||||
initialValues={{ orderNo: defaultOrderNo, execute: '1' }}
|
||||
@@ -289,7 +324,7 @@ export default function AdminDevMockPage() {
|
||||
|
||||
{lastSemiAuto ? (
|
||||
<Card
|
||||
title="最近生成的半自动履约 Mock"
|
||||
title="最近生成的半自动测试单"
|
||||
extra={<Link to={lastSemiAuto.adminPath}>打开后台任务</Link>}
|
||||
>
|
||||
<Row gutter={[16, 12]}>
|
||||
@@ -306,6 +341,7 @@ export default function AdminDevMockPage() {
|
||||
<div>
|
||||
{lastSemiAuto.semiAutoPlatform === 'weibo' ? '微博' : '虎牙'} ·{' '}
|
||||
{lastSemiAuto.skuKey} · 任务 #{lastSemiAuto.taskId}
|
||||
{'pipeline' in lastSemiAuto ? ' · 正式订单链路' : ' · 直连 Mock'}
|
||||
</div>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
@@ -516,12 +552,16 @@ function KuaishouIndustryVoucherMockForm({
|
||||
|
||||
function SemiAutoMockForm({
|
||||
loading,
|
||||
submitText,
|
||||
integration = false,
|
||||
defaultConnectorMode,
|
||||
externalConnectorConfigured,
|
||||
mockConnectorAvailable,
|
||||
onSubmit,
|
||||
}: {
|
||||
loading: boolean
|
||||
submitText?: string
|
||||
integration?: boolean
|
||||
defaultConnectorMode?: 'embedded' | 'external' | 'mock'
|
||||
externalConnectorConfigured?: boolean
|
||||
mockConnectorAvailable?: boolean
|
||||
@@ -564,7 +604,7 @@ function SemiAutoMockForm({
|
||||
<Form.Item
|
||||
label="履约平台"
|
||||
name="platform"
|
||||
extra="微博 Mock 单登录成功即视为授权完成,不再有角色绑定步骤。"
|
||||
extra="当前只负责客户登录和账号 CK 获取;客服在后台人工处理后续履约。"
|
||||
>
|
||||
<Select
|
||||
options={[
|
||||
@@ -582,23 +622,31 @@ function SemiAutoMockForm({
|
||||
</Form.Item>
|
||||
{selectedPlatform === 'huya' ? (
|
||||
<Form.Item
|
||||
label="Mock 范围"
|
||||
label={integration ? 'Connector 模式' : 'Mock 范围'}
|
||||
name="connectorMode"
|
||||
extra="只 Mock 订单时,登录、角色绑定和浏览器票据注入可走内置真实 Connector,也可显式使用远程 Connector。"
|
||||
extra={
|
||||
integration
|
||||
? '订单始终走正式订单与履约链路,这里只选择登录和 CK 获取使用的 Connector。'
|
||||
: '只 Mock 订单时,登录和 CK 获取可走内置真实 Connector,也可显式使用远程 Connector。'
|
||||
}
|
||||
>
|
||||
<Select
|
||||
options={[
|
||||
{
|
||||
value: 'embedded',
|
||||
label: '仅 Mock 订单(内置真实登录 / 绑定 / 注入)',
|
||||
label: integration
|
||||
? '内置真实 Connector'
|
||||
: '仅 Mock 订单(内置真实登录 / CK 获取)',
|
||||
},
|
||||
{
|
||||
value: 'external',
|
||||
label: '仅 Mock 订单(远程真实 Connector)',
|
||||
label: integration ? '远程真实 Connector' : '仅 Mock 订单(远程真实 Connector)',
|
||||
},
|
||||
{
|
||||
value: 'mock',
|
||||
label: '订单 + 登录绑定都 Mock(内置 Connector)',
|
||||
label: integration
|
||||
? '内置 Mock Connector(仅联调登录)'
|
||||
: '订单 + 登录 CK 都 Mock(内置 Connector)',
|
||||
disabled: mockConnectorAvailable === false,
|
||||
},
|
||||
]}
|
||||
@@ -627,7 +675,15 @@ function SemiAutoMockForm({
|
||||
<Form.Item label="订单号 orderNo(可空)" name="orderNo">
|
||||
<Input
|
||||
allowClear
|
||||
placeholder={selectedPlatform === 'weibo' ? '留空自动 MOCKWB…' : '留空自动 MOCKSA…'}
|
||||
placeholder={
|
||||
integration
|
||||
? selectedPlatform === 'weibo'
|
||||
? '留空自动 INTWB…'
|
||||
: '留空自动 INTSA…'
|
||||
: selectedPlatform === 'weibo'
|
||||
? '留空自动 MOCKWB…'
|
||||
: '留空自动 MOCKSA…'
|
||||
}
|
||||
/>
|
||||
</Form.Item>
|
||||
<Space size={12} style={{ display: 'flex' }}>
|
||||
@@ -665,16 +721,22 @@ function SemiAutoMockForm({
|
||||
selectedPlatform === 'weibo'
|
||||
? '微博使用内置真实 Connector:短信验证码会真实发送到客户手机号,扫码需在微博 App 确认;登录成功即视为授权完成。'
|
||||
: selectedMode === 'mock'
|
||||
? '登录和绑定会使用内置 Mock Connector,仅用于联调页面。'
|
||||
? integration
|
||||
? '订单和履约链路是正式的,只有登录与 CK 获取使用内置 Mock Connector。'
|
||||
: '登录和 CK 获取会使用内置 Mock Connector,仅用于联调页面。'
|
||||
: selectedMode === 'external'
|
||||
? externalConnectorConfigured
|
||||
? '远程真实 Connector 已配置;只有订单由 Mock 生成。'
|
||||
? integration
|
||||
? '远程真实 Connector 已配置,订单走正式履约链路。'
|
||||
: '远程真实 Connector 已配置;只有订单由 Mock 生成。'
|
||||
: '远程真实 Connector 未配置:请设置 SEMI_AUTO_CONNECTOR_BASE_URL 和 API_KEY。'
|
||||
: '使用 order_site 内置真实 Connector;无需启动 live-hub-py,只有订单由 Mock 生成。'
|
||||
: integration
|
||||
? '使用 order_site 内置真实 Connector,订单走正式履约链路。'
|
||||
: '使用 order_site 内置真实 Connector;无需启动 live-hub-py,只有订单由 Mock 生成。'
|
||||
}
|
||||
/>
|
||||
<Button type="primary" htmlType="submit" loading={loading} block>
|
||||
生成半自动履约 Mock
|
||||
{submitText || '生成半自动履约 Mock'}
|
||||
</Button>
|
||||
</Form>
|
||||
)
|
||||
|
||||
@@ -68,6 +68,11 @@ export type DevMockSemiAutoResult = {
|
||||
tips: string[]
|
||||
}
|
||||
|
||||
export type DevSemiAutoIntegrationResult = DevMockSemiAutoResult & {
|
||||
pipeline: 'order_service'
|
||||
mappingId: number
|
||||
}
|
||||
|
||||
export function fetchDevMockStatus() {
|
||||
return apiGet<DevMockStatus>('/api/v1/admin/dev-mock/status')
|
||||
}
|
||||
@@ -102,6 +107,21 @@ export function createSemiAutoDevMock(payload: {
|
||||
return apiPost<DevMockSemiAutoResult>('/api/v1/admin/dev-mock/semi-auto', payload)
|
||||
}
|
||||
|
||||
export function createSemiAutoIntegrationDevMock(payload: {
|
||||
platform?: 'huya' | 'weibo'
|
||||
orderNo?: string
|
||||
skuName?: string
|
||||
quantity?: number
|
||||
pageTitle?: string
|
||||
browserTargetUrl?: string
|
||||
connectorMode?: 'embedded' | 'external' | 'mock'
|
||||
}) {
|
||||
return apiPost<DevSemiAutoIntegrationResult>(
|
||||
'/api/v1/admin/dev-mock/semi-auto-integration',
|
||||
payload,
|
||||
)
|
||||
}
|
||||
|
||||
export function buildOpen91QueryDevMock(payload: {
|
||||
orderNo: string
|
||||
execute?: boolean
|
||||
|
||||
Reference in New Issue
Block a user