diff --git a/apps/backend/src/routes/admin/cost-center-catalog.ts b/apps/backend/src/routes/admin/cost-center-catalog.ts index 25872e4c..d6f6e473 100644 --- a/apps/backend/src/routes/admin/cost-center-catalog.ts +++ b/apps/backend/src/routes/admin/cost-center-catalog.ts @@ -23,19 +23,14 @@ import { updateAdminProduct, } from '../../services/cost-center/product-catalog-service.js' import { - backfillAdminAffiliateDashSkus, importAdminAffiliateDashPricesBaseline, setAdminAffiliateProductPrice, - syncAdminAffiliateDashProducts, } from '../../services/cost-center/affiliate-product-service.js' import { applyAdminTemplateProductBootstrap, previewAdminTemplateProductBootstrap, } from '../../services/cost-center/template-bootstrap-service.js' -import { - backfillAdminWorkOrderProductSkus, - syncAdminWorkOrderTemplateCostVersions, -} from '../../services/cost-center/work-order-product-service.js' +import { syncAdminWorkOrderTemplateCostVersions } from '../../services/cost-center/work-order-product-service.js' import type { JsonObject } from '../../types/json.js' import { BATCH_STATEMENT_TIMEOUT_MS, runWithStatementTimeout } from '../../db/client.js' import { bodyOf, idOf, sessionOf } from './request-helpers.js' @@ -84,38 +79,6 @@ router.post( ), ) -router.post( - '/cost-center/affiliate-products/sync', - requireAdminPermission('finance.config'), - createJsonHandler(() => syncAdminAffiliateDashProducts(), { - successMessage: '自动发货商品已同步', - errorMessage: '同步自动发货商品失败', - scope: '[admin/cost-center/affiliate-products/sync]', - audit: (_req, data) => ({ - action: 'cost_affiliate_products_synced', - targetType: 'product_catalog', - targetId: '', - data: data as Record, - }), - }), -) - -router.post( - '/cost-center/affiliate-products/backfill', - requireAdminPermission('finance.config'), - createJsonHandler(() => backfillAdminAffiliateDashSkus(), { - successMessage: '自动发货 SKU 已回填', - errorMessage: '回填自动发货 SKU 失败', - scope: '[admin/cost-center/affiliate-products/backfill]', - audit: (_req, data) => ({ - action: 'cost_affiliate_skus_backfilled', - targetType: 'order_items', - targetId: '', - data: data as Record, - }), - }), -) - router.post( '/cost-center/affiliate-products/price-baseline', requireAdminPermission('finance.config'), @@ -151,25 +114,6 @@ router.post( ), ) -router.post( - '/cost-center/work-order-products/backfill', - requireAdminPermission('finance.config'), - createJsonHandler( - (req) => withBatchTimeout(() => backfillAdminWorkOrderProductSkus(bodyOf(req))), - { - successMessage: '接单平台商品已回填', - errorMessage: '回填接单平台商品失败', - scope: '[admin/cost-center/work-order-products/backfill]', - audit: (_req, data) => ({ - action: 'cost_work_order_products_backfilled', - targetType: 'order_items', - targetId: '', - data: data as Record, - }), - }, - ), -) - router.post( '/cost-center/work-order-template-costs/sync', requireAdminPermission('finance.config'), diff --git a/apps/frontend/src/pages/admin/cost-center/AffiliateSkuPanel.tsx b/apps/frontend/src/pages/admin/cost-center/AffiliateSkuPanel.tsx index aa74147e..8c1cd347 100644 --- a/apps/frontend/src/pages/admin/cost-center/AffiliateSkuPanel.tsx +++ b/apps/frontend/src/pages/admin/cost-center/AffiliateSkuPanel.tsx @@ -28,12 +28,9 @@ import dayjs from 'dayjs' import { useState } from 'react' import { - backfillAdminAffiliateDashSkus, fetchAdminProductCatalog, importAdminAffiliateDashPricesBaseline, setAdminAffiliateProductPrice, - syncAdminAffiliateDashCostSnapshots, - syncAdminAffiliateDashProducts, updateAdminProductCatalog, } from '@/services/admin' import type { ProductCatalogItem } from '@/types/admin' @@ -57,10 +54,7 @@ export function AffiliateSkuPanel() { const [page, setPage] = useState(1) const [pageSize, setPageSize] = useState(ADMIN_DEFAULT_PAGE_SIZE) const [statusUpdatingId, setStatusUpdatingId] = useState(null) - const [syncing, setSyncing] = useState(false) - const [backfilling, setBackfilling] = useState(false) const [importingBaseline, setImportingBaseline] = useState(false) - const [syncingSnapshots, setSyncingSnapshots] = useState(false) // 价格弹窗状态 const [priceModalOpen, setPriceModalOpen] = useState(false) @@ -81,44 +75,6 @@ export function AffiliateSkuPanel() { const products = productsQuery.data?.data.items || [] const total = productsQuery.data?.data.pagination.total || 0 - async function syncProducts() { - setSyncing(true) - try { - const result = await syncAdminAffiliateDashProducts() - message.success( - `已同步 ${result.data.productCount} 个自动发货商品(新增 ${result.data.createdCount},更新 ${result.data.updatedCount})`, - ) - refreshAll() - } catch (error) { - message.error(error instanceof Error ? error.message : '同步自动发货商品失败') - } finally { - setSyncing(false) - } - } - - async function backfillSkus() { - setBackfilling(true) - try { - const response = await backfillAdminAffiliateDashSkus() - const result = response.data - const factsText = result.factsRebuild - ? `;已重算 ${result.factsRebuild.fromDate} ~ ${result.factsRebuild.toDate} 的销售事实` - : '' - const remainingText = - result.remainingCount > 0 - ? `;仍有 ${result.remainingCount} 个订单项缺少可匹配的自动发货 SKU` - : '' - message.success( - `已回填 ${result.updatedCount} 个订单项,${result.skippedCount} 个已是归一状态${factsText}${remainingText}`, - ) - refreshAll() - } catch (error) { - message.error(error instanceof Error ? error.message : '回填自动发货 SKU 失败') - } finally { - setBackfilling(false) - } - } - function handleImportBaseline() { modal.confirm({ title: '导入上游采购成本基线', @@ -143,31 +99,6 @@ export function AffiliateSkuPanel() { }) } - function handleSyncSnapshots() { - modal.confirm({ - title: '重算自动发货预估成本快照', - content: - '将为最近一个月的自动发货订单重新计算预估成本快照,自动消除因缺少采购价导致的 cost_missing 异常,并重算对应周期的销售事实。确定执行?', - okText: '确认重算', - cancelText: '取消', - onOk: async () => { - setSyncingSnapshots(true) - try { - const res = await syncAdminAffiliateDashCostSnapshots() - const snap = res.data.snapshotResult - message.success( - `重算完成!已生成成本快照 ${snap.createdCount} 条,已消除/解决异常 ${snap.resolvedExceptionCount} 条`, - ) - refreshAll() - } catch (error) { - message.error(error instanceof Error ? error.message : '重算成本快照失败') - } finally { - setSyncingSnapshots(false) - } - }, - }) - } - function openPriceModal(product: ProductCatalogItem) { setSelectedProduct(product) const currentYuan = @@ -255,23 +186,6 @@ export function AffiliateSkuPanel() { > 导入基线价格 - - - - - - ) : productSourceFilter === 'manual' ? ( + {productSourceFilter !== 'affiliate_dash' ? ( - ) : productSourceFilter === 'work_order' ? ( - <> - - - - ) : ( - <> - - - - - )} + ) : null}