feat(cost-center): 统一商品成本中心为全系统唯一标准价格源并闭环改价与工单同步

- 核心架构:将商品与成本中心确立为全系统唯一标准价格源,接单模板价格在接单平台禁止编辑并提示收敛至成本中心,后端 saveAdminWorkProductRule 严格拦截价格篡改
- 改价与同步:标准商品目录与自动发货专属面板提供统一改价弹窗,支持追溯/立即生效/指定时间;改价后自动或手动将新价格同步至接单大厅待抢单工单,保持下游业务一致
- 缺陷修复:修复 cost_versions 追溯改价时因同生效时间违反 chk_cost_versions_period 检查约束及 uq_cost_versions_scope 唯一索引冲突的问题,采用 active 版本就地更新机制
- 分类树优化:工单二级分类树限定仅在工单来源展示,自动发货与人工客服彻底隐藏分类树并重置过滤条件
- 验证方式:通过后端 784 项全量测试、前后端 tsc 类型检查及前端生产构建打包
This commit is contained in:
yml2213
2026-10-25 15:21:34 +08:00
parent 55a3e0df9c
commit b7ad69831a
11 changed files with 1824 additions and 236 deletions
@@ -18,11 +18,16 @@ import {
listAdminChannelMappings,
listAdminProducts,
listAdminUnmappedMappingGroups,
setAdminProductPrice,
syncAdminProductPrice,
updateAdminChannelMapping,
updateAdminProduct,
} from '../../services/cost-center/product-catalog-service.js'
import {
backfillAdminAffiliateDashSkus,
importAdminAffiliateDashPricesBaseline,
setAdminAffiliateProductPrice,
syncAdminAffiliateDashCostSnapshots,
syncAdminAffiliateDashProducts,
} from '../../services/cost-center/affiliate-product-service.js'
import {
@@ -97,6 +102,58 @@ router.post(
}),
)
router.post(
'/cost-center/affiliate-products/price-baseline',
requireAdminPermission('finance.config'),
createJsonHandler((req) => importAdminAffiliateDashPricesBaseline(sessionOf(req)), {
successMessage: '已从上游基线导入自动发货采购成本',
errorMessage: '导入自动发货采购成本基线失败',
scope: '[admin/cost-center/affiliate-products/price-baseline]',
audit: (_req, data) => ({
action: 'cost_affiliate_prices_baseline_imported',
targetType: 'cost_versions',
targetId: '',
data: data as Record<string, unknown>,
}),
}),
)
router.post(
'/cost-center/affiliate-products/:productId/price',
requireAdminPermission('finance.config'),
createJsonHandler(
(req) => setAdminAffiliateProductPrice(idOf(req, 'productId'), bodyOf(req), sessionOf(req)),
{
successMessage: '自动发货采购成本已配置',
errorMessage: '配置自动发货采购成本失败',
scope: '[admin/cost-center/affiliate-products/:productId/price]',
audit: (req, data) => ({
action: 'cost_affiliate_product_price_set',
targetType: 'cost_versions',
targetId: String(req.params.productId || ''),
data: data as Record<string, unknown>,
}),
},
),
)
router.post(
'/cost-center/affiliate-products/sync-snapshots',
requireAdminPermission('finance.config'),
createJsonHandler(() => syncAdminAffiliateDashCostSnapshots(), {
successMessage: '已重算自动发货预估成本快照与销售事实',
errorMessage: '重算自动发货成本快照失败',
scope: '[admin/cost-center/affiliate-products/sync-snapshots]',
audit: (_req, data) => ({
action: 'cost_affiliate_snapshots_synced',
targetType: 'cost_snapshots',
targetId: '',
data: data as Record<string, unknown>,
}),
}),
)
router.post(
'/cost-center/work-order-products/backfill',
requireAdminPermission('finance.config'),
@@ -201,6 +258,41 @@ router.patch(
}),
)
router.post(
'/cost-center/products/:productId/price',
requireAdminPermission('finance.config'),
createJsonHandler(
(req) => setAdminProductPrice(idOf(req, 'productId'), bodyOf(req), sessionOf(req)),
{
successMessage: '商品标准价格已更新',
errorMessage: '更新商品标准价格失败',
scope: '[admin/cost-center/products/:productId/price]',
audit: (req, data) => ({
action: 'cost_product_price_set',
targetType: 'cost_versions',
targetId: String(req.params.productId || ''),
data: data as Record<string, unknown>,
}),
},
),
)
router.post(
'/cost-center/products/:productId/sync-price',
requireAdminPermission('finance.config'),
createJsonHandler((req) => syncAdminProductPrice(idOf(req, 'productId'), sessionOf(req)), {
successMessage: '标准价格已同步到下游',
errorMessage: '同步标准价格失败',
scope: '[admin/cost-center/products/:productId/sync-price]',
audit: (req, data) => ({
action: 'cost_product_price_synced',
targetType: 'product_catalog',
targetId: String(req.params.productId || ''),
data: data as Record<string, unknown>,
}),
}),
)
router.delete(
'/cost-center/products/:productId',
requireAdminPermission('finance.config'),