关闭旧商品匹配默认回退

This commit is contained in:
yml2213
2026-08-18 13:50:56 +08:00
parent 79990066f0
commit c2305d419e
10 changed files with 186 additions and 25 deletions
@@ -26,16 +26,19 @@ import {
deleteAdminWorkProductRuleMapping,
fetchAdminKuaishouIndustryShops,
fetchAdminKuaishouMatchSources,
fetchAdminWorkerProductMatchConfig,
fetchAdminWorkProductMatchLogs,
fetchAdminWorkProductRuleMappings,
fetchAdminWorkProductRules,
saveAdminWorkProductRuleMapping,
saveAdminWorkerProductMatchConfig,
testAdminKuaishouProductMatch,
} from '@/services/admin'
import type {
KuaishouMatchSource,
WorkProductMatchLog,
WorkProductRuleMapping,
WorkerProductMatchConfig,
} from '@/types/worker-platform'
import type { AdminKuaishouIndustryShopOption } from '@/types/admin'
import { formatAdminDateTime } from '@/utils/admin-time'
@@ -89,12 +92,17 @@ export default function ProductMatchPanel() {
queryKey: ['admin-worker-platform-product-match-logs'],
queryFn: () => fetchAdminWorkProductMatchLogs(100),
})
const matchConfigQuery = useQuery({
queryKey: ['admin-worker-platform-product-match-config'],
queryFn: fetchAdminWorkerProductMatchConfig,
})
const rules = rulesQuery.data?.data.items || []
const mappings = mappingsQuery.data?.data.items || []
const sources = sourcesQuery.data?.data.items || []
const logs = logsQuery.data?.data.items || []
const shops = shopsQuery.data?.data.shops || []
const matchConfig = matchConfigQuery.data?.data
const shopNameBySellerId = createShopNameBySellerId(shops)
const sellerIds = new Set([
...shops.map((shop) => shop.sellerId),
@@ -209,6 +217,19 @@ export default function ProductMatchPanel() {
}
}
async function updateLegacyFallback(legacyFallbackEnabled: boolean) {
const nextConfig: WorkerProductMatchConfig = { legacyFallbackEnabled }
try {
await saveAdminWorkerProductMatchConfig(nextConfig)
message.success(legacyFallbackEnabled ? '旧规则兼容匹配已开启' : '旧规则兼容匹配已关闭')
await queryClient.invalidateQueries({
queryKey: ['admin-worker-platform-product-match-config'],
})
} catch (error) {
message.error(error instanceof Error ? error.message : '保存商品匹配配置失败')
}
}
const mappingColumns: TableColumnsType<WorkProductRuleMapping> = [
{
title: '店铺 / 商品',
@@ -391,6 +412,15 @@ export default function ProductMatchPanel() {
return (
<Card bordered={false} title="商品匹配">
<Space align="center" style={{ marginBottom: 16 }}>
<Switch
checked={matchConfig?.legacyFallbackEnabled === true}
loading={matchConfigQuery.isLoading || matchConfigQuery.isFetching}
onChange={updateLegacyFallback}
/>
<Typography.Text></Typography.Text>
<Typography.Text type="secondary"></Typography.Text>
</Space>
<Tabs
items={[
{
@@ -14,6 +14,7 @@ import type {
WorkerFinanceConfig,
WorkerFinanceRequest,
WorkerPlatformNotificationConfig,
WorkerProductMatchConfig,
WorkerLevel,
WorkerListResponse,
WorkerUser,
@@ -168,6 +169,17 @@ export function deleteAdminWorkProductRuleMapping(mappingId: number) {
)
}
export function fetchAdminWorkerProductMatchConfig() {
return apiGet<WorkerProductMatchConfig>('/api/v1/admin/worker-platform/product-match-config')
}
export function saveAdminWorkerProductMatchConfig(payload: WorkerProductMatchConfig) {
return apiPost<WorkerProductMatchConfig>(
'/api/v1/admin/worker-platform/product-match-config',
payload,
)
}
export function fetchAdminKuaishouMatchSources(limit = 100) {
return apiGet<{ items: KuaishouMatchSource[] }>(
'/api/v1/admin/worker-platform/product-match-sources',
@@ -137,6 +137,10 @@ export type WorkerPlatformNotificationConfig = {
>
}
export type WorkerProductMatchConfig = {
legacyFallbackEnabled: boolean
}
export type WorkerWithdrawalAccount = {
accountChannel: string
accountName: string