MVP底座②:四域十八对象声明 —— 流转归项目,沉淀归客户/情报/供应商

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
This commit is contained in:
2026-07-27 22:41:25 +08:00
co-authored by Claude Fable 5
parent 3edd133230
commit d00e29091e
2 changed files with 207 additions and 0 deletions
+180
View File
@@ -0,0 +1,180 @@
/**
* 四域十八对象(docs/MVP示例工作流.html · 动态数据 + 静态底座;定价审批表落审批机制,不入台账)。
*
* 划分原则(产品决策,2026-07-27):**流转单据(过程)归 project;沉淀资产按内容归
* customer / intel / supplier**。声明只写活动**要用**的字段;物化走安装通道的声明合并
* (最大化合并、只增不破坏),这里不建表 —— 建表是 ledger 的事。
*/
import { objectDeclarationSchema } from '@contracts';
import type { LedgerFieldType, ObjectDeclaration } from '@contracts';
const f = (name: string, type: LedgerFieldType, label: string, primaryKey = false) => ({
name,
type,
label,
primaryKey,
masked: false,
});
const obj = (domain: string, object: string, label: string, fields: ReturnType<typeof f>[]) =>
objectDeclarationSchema.parse({ domain, object, label, fields });
export const MVP_OBJECTS: readonly ObjectDeclaration[] = [
/* ── project:每一单的流转单据(位置签 输入/过程/输出) ─────────────── */
obj('project', 'rfq_file', 'RFQ/BOM文件', [
f('rfq_ref', 'text', '询价单号', true),
f('pn', 'text', 'PN', true),
f('qty_eau', 'text', '数量/EAU'),
f('brand', 'text', '厂牌'),
f('analog_flag', 'boolean', 'Analog'),
f('aec_cert', 'text', 'AEC认证'),
f('target_price', 'number', '目标价'),
f('lead_time', 'text', '交期'),
]),
obj('project', 'intake_record', '统一受理记录', [
f('customer_code', 'text', '客户码', true),
f('pn', 'text', 'PN', true),
f('brand', 'text', '厂牌'),
f('eau', 'text', 'EAU'),
f('type_tag', 'text', 'Type标'),
f('target_price', 'number', '目标价'),
f('status', 'text', '状态'),
]),
obj('project', 'pn_class', '料号分类表', [
f('pn', 'text', 'PN', true),
f('type_tag', 'text', 'Type标'),
f('basis', 'text', '分级依据'),
f('history_hit', 'boolean', '历史价命中'),
f('review_note', 'text', '复核结论'),
]),
obj('project', 'alt_request', '替代评估请求', [
f('material', 'text', '初选物料', true),
f('chip_type', 'text', '芯片类型'),
f('spec_params', 'text', '参数规格'),
f('scenario', 'text', '应用场景'),
f('requester', 'text', '需求人'),
]),
obj('project', 'inquiry_request', '询价请求', [
f('pn', 'text', 'PN', true),
f('brand', 'text', 'Brand'),
f('era', 'text', 'ERA'),
f('project_stage', 'text', '项目阶段'),
f('accept_alt', 'boolean', '接受替代'),
f('unit_usage', 'text', '单机用量'),
f('tp', 'number', 'TP'),
f('scenario', 'text', '场景'),
]),
obj('project', 'supplier_floor', '供应商底价表', [
f('pn', 'text', 'PN', true),
f('supplier', 'text', '供应商', true),
f('floor_price', 'number', '底价'),
f('moq', 'text', 'MOQ'),
f('lead_time', 'text', '交期'),
]),
obj('project', 'alt_benchmark', '替代对标表', [
f('original_pn', 'text', '原型号', true),
f('candidate_pn', 'text', '候选型号', true),
f('alt_grade', 'text', '替代等级'),
f('param_diff', 'text', '参数差异项'),
f('diff_risk', 'text', '差异风险'),
f('mod_eval', 'text', '改动评估'),
f('verify_advice', 'text', '验证建议'),
]),
obj('project', 'sourcing_compare', '寻源比价表', [
f('pn', 'text', 'PN', true),
f('supplier', 'text', '供应商', true),
f('quote_price', 'number', '报价'),
f('moq', 'text', 'MOQ'),
f('lead_time', 'text', '交期'),
f('channel_grade', 'text', '渠道等级'),
f('condition', 'text', '成色'),
f('verdict', 'text', '结论'),
]),
obj('project', 'quote_draft', '报价草案', [
f('pn', 'text', 'PN', true),
f('proposed_price', 'number', '拟报单价'),
f('margin', 'number', '毛利率'),
f('deviation', 'number', '偏离度'),
]),
obj('project', 'formal_quote', '正式报价单', [
f('pn', 'text', 'PN', true),
f('unit_price_cny', 'number', '单价CNY'),
f('lead_time', 'text', '交期'),
f('spq', 'text', 'SPQ'),
f('moq', 'text', 'MOQ'),
f('trade_terms', 'text', '贸易条款'),
f('valid_until', 'date', '有效期'),
]),
obj('project', 'followup', '跟进提醒', [
f('quote_no', 'text', '报价单号', true),
f('customer_code', 'text', '客户'),
f('d3', 'date', 'D+3'),
f('d7', 'date', 'D+7'),
f('reply_status', 'text', '回复状态'),
]),
obj('project', 'landing_stats', '报价落地率统计', [
f('period', 'text', '期', true),
f('landing_rate', 'number', '落地率'),
f('type_a_hit', 'number', 'TypeA命中'),
f('d3_reply_rate', 'number', 'D+3回复率'),
f('return_rate', 'number', '退回率'),
]),
/* ── customer:客户信息 ────────────────────────────────────────────── */
obj('customer', 'profile', '客户资料库', [
f('customer_code', 'text', '客户码', true),
f('grade', 'text', '客户等级'),
f('tags', 'text', '画像标签'),
f('payment_terms', 'text', '付款条款'),
f('industry', 'text', '行业属性'),
f('risk_level', 'text', '风险等级'),
f('annual_purchase', 'number', '年采购额'),
]),
/* ── intel:市场与销售情报 ─────────────────────────────────────────── */
obj('intel', 'history_price', '历史价格情报', [
f('pn', 'text', 'PN', true),
f('quoted_at', 'timestamp', '报价日期', true),
f('brand', 'text', '厂牌'),
f('unit_price_cny', 'number', '单价CNY'),
f('lead_time', 'text', '交期'),
f('moq', 'text', 'MOQ'),
f('valid_until', 'date', '有效期'),
]),
obj('intel', 'chip_spec', '芯片规格书', [
f('pn', 'text', 'PN', true),
f('key_params', 'text', '关键参数'),
f('package', 'text', '封装'),
f('version_date', 'date', '版本日期'),
]),
obj('intel', 'public_select', '公网选型库', [
f('alt_relation', 'text', '替代关系', true),
f('param_compare', 'text', '参数对比'),
f('spec_ref', 'text', '规格书'),
f('lifecycle', 'text', '生命周期'),
f('price_ref', 'text', '价格参考'),
]),
/* ── supplier:供应商信息 ─────────────────────────────────────────── */
obj('supplier', 'channel_dir', '供应商渠道目录', [
f('supplier', 'text', '供应商', true),
f('channel_type', 'text', '渠道类型'),
f('brand_lines', 'text', '品牌线'),
f('contact', 'text', '联系人'),
]),
obj('supplier', 'dead_stock', '呆滞库存表', [
f('pn', 'text', 'PN', true),
f('stock_qty', 'number', '库存量'),
f('stock_age', 'text', '库龄'),
f('cost_price', 'number', '成本价'),
]),
];
export function declarationsFor(objects: readonly `${string}.${string}`[]): ObjectDeclaration[] {
return objects.map((key) => {
const [domain, object] = key.split('.');
const hit = MVP_OBJECTS.find((o) => o.domain === domain && o.object === object);
if (hit === undefined) throw new Error(`未知对象:${key} —— 先在 MVP_OBJECTS 登记`);
return hit;
});
}