|
|
@@ -0,0 +1,566 @@
|
|
|
+# lead-detail 板块与 ltc-nanchi 复用映射
|
|
|
+
|
|
|
+> 本文档根据 `nanchi/ltc-nanchi` 的数据模型和接口,为 demo-nanchi 的 `lead-detail` 各板块提供精准数据获取的复用方案。
|
|
|
+> 目标:每个板块的数据应来自 ltc-nanchi 的真实模型与 API,而非 mock 或本地推断。
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+## 一、lead-detail 板块概览
|
|
|
+
|
|
|
+| 板块 | 位置 | 当前 demo 数据来源 | 应复用的 ltc-nanchi 能力 |
|
|
|
+|------|------|-------------------|--------------------------|
|
|
|
+| 1. 客户画像分析 | 左列 | `lead.quickScreenResult`(快速筛选) | EmailAnalysis.customerProfile + requirementExtraction |
|
|
|
+| 2. 快速筛选结果(公司/联系人) | 左列 | `lead.quickScreenResult` | EmailAnalysis + Enterprise + ContactInfo |
|
|
|
+| 3. 需求摘要 | 左列 | `getDemandSnapshot()`(基于 suggestedProducts 推断) | EmailAnalysis.requirementExtraction + Brainwork productDemands |
|
|
|
+| 4. 原始邮件信息 | 左列 | `getEmailForLead(lead)` → Email | Parse `Email` 表 |
|
|
|
+| 5. 推荐产品 | 右列 | `lead.quickScreenResult.suggestedProducts` | EmailAnalysis + 产品匹配服务 |
|
|
|
+| 6. 可信度 / 评分 / AI 下一步 | 右列 | 本地 `getCredibilityLevel()` / `getScores()` 推断 | Enterprise.enterpriseProfile + AgentValueAnalysisService |
|
|
|
+| 7. 销售验证 | 右列 | `lead.personaVerified` / `lead.salesFeedback` | Lead 表 + 人工反馈 |
|
|
|
+| 8. 深度调研 / 背调报告 | 右列 | `lead.aiResearchReport` / `lead.backgroundCheckReport` | LeadBackgroundCheckService + reportData |
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+## 二、Parse 表与模型复用
|
|
|
+
|
|
|
+### 2.1 Email 表
|
|
|
+
|
|
|
+| Parse 字段 | 对应 demo Email 字段 | lead-detail 使用场景 |
|
|
|
+|------------|----------------------|----------------------|
|
|
|
+| `messageId` | `id` | 唯一标识 |
|
|
|
+| `fromEmail` | `from` | 发件人,用于 `getEmailForLead(lead)` 匹配 |
|
|
|
+| `fromName` | `fromName` | 原始邮件板块 |
|
|
|
+| `toEmails` | `to` | 原始邮件板块 |
|
|
|
+| `ccEmails` | `cc` | 原始邮件板块 |
|
|
|
+| `subject` | `subject` | 原始邮件板块 |
|
|
|
+| `content` / `html` | `body` | 原始邮件板块 |
|
|
|
+| `receivedAt` | `receivedAt` | 原始邮件板块 |
|
|
|
+| `attachments` | `attachments` | 原始邮件板块 |
|
|
|
+| `aiAnalysis` | Pointer→EmailAnalysis | 关联分析结果 |
|
|
|
+| `leadId` | `leadId` | 创建 Lead 后写入,用于关联 |
|
|
|
+| `customerEmail`, `customerCompany` | 用于关联 Enterprise/Contact | 查询时辅助匹配 |
|
|
|
+
|
|
|
+**复用接口:**
|
|
|
+
|
|
|
+- 查询:`new Parse.Query('Email').equalTo('messageId', id).first()` 或 `.equalTo('leadId', leadId)`
|
|
|
+- 服务参考:`EmailImportWorkflowService` 保存 Email 后建立 `aiAnalysis` 关联
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 2.2 EmailAnalysis 表
|
|
|
+
|
|
|
+| Parse 字段 | 对应 demo 板块 | 说明 |
|
|
|
+|------------|----------------|------|
|
|
|
+| `email` | - | Pointer→Email |
|
|
|
+| `summary` | 客户画像 / 快速筛选 | 摘要 |
|
|
|
+| `intent` | 客户画像 | 意图分类 |
|
|
|
+| `requirementExtraction` | 需求摘要、推荐产品 | 见下表 |
|
|
|
+| `customerProfile` | 客户画像、可信度 | companyType, country, buyingPower 等 |
|
|
|
+| `verificationInfo` | 可信度、评分 | 联网验证结果 |
|
|
|
+| `comprehensiveAnalysis` | 综合评估 | 含 verification、nextSteps |
|
|
|
+| `confidence`, `leadPotential` | 评分详情 | 0-100 |
|
|
|
+| `nextSteps` | AI 推荐下一步 | 建议行动数组 |
|
|
|
+| `attachmentAnalysis` | 需求摘要 | 附件中的产品需求 |
|
|
|
+
|
|
|
+**requirementExtraction 结构(EmailAnalysisWorkflowService):**
|
|
|
+
|
|
|
+```ts
|
|
|
+interface RequirementExtractionResult {
|
|
|
+ productCategory: string[]; // 产品类别 → 需求摘要 products、推荐产品
|
|
|
+ quantity: string; // 数量 → 需求摘要 quantity
|
|
|
+ budget: string; // 预算
|
|
|
+ urgency: 'urgent' | 'normal' | 'flexible';
|
|
|
+ targetMarket: string;
|
|
|
+ certifications: string[]; // → quickScreenResult.certRequirements
|
|
|
+ keyRequirements: string[];
|
|
|
+ mustHaveComponents: string[];
|
|
|
+ colorPreference: string[];
|
|
|
+ sizeRequirement: string;
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+**Brainwork 扩展 `_rawDemands`:**
|
|
|
+
|
|
|
+- 来源:`EmlImportService` 将 Brainwork `productDemands` 写入 `requirementExtraction._rawDemands`
|
|
|
+- 结构:`{ productName, quantity, unitPrice, totalPrice, moq, specifications }[]`
|
|
|
+- 用途:需求摘要中的「产品 × 数量」、预估年采购额
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 2.3 Enterprise 表
|
|
|
+
|
|
|
+| Parse 字段 | 对应 demo 板块 | 说明 |
|
|
|
+|------------|----------------|------|
|
|
|
+| `email` | - | 唯一标识(客户邮箱域名对应公司) |
|
|
|
+| `name` | 公司信息 | 公司名称 |
|
|
|
+| `industry` | 公司信息 | 行业 |
|
|
|
+| `basic_info` | 公司信息 | domain, country, address, foundedYear, employeeCount, revenue |
|
|
|
+| `enterpriseProfile` | 可信度、评分 | credibilityScore, companyScale, certifications |
|
|
|
+| `verificationData` | 可信度信号 | companyVerified, sources, keyFindings, lastVerified |
|
|
|
+| `marketIntelligence` | 可选 | 市场情报 |
|
|
|
+
|
|
|
+**enterpriseProfile 示例:**
|
|
|
+
|
|
|
+```ts
|
|
|
+{
|
|
|
+ companyScale: { employeeCount, employeeRange },
|
|
|
+ establishment: { foundedYear },
|
|
|
+ financialStrength: { purchasePower },
|
|
|
+ certifications: { certList, hasCertifications },
|
|
|
+ credibilityScore: { overall, dimensions }
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 2.4 ContactInfo 表
|
|
|
+
|
|
|
+| Parse 字段 | 对应 demo 板块 | 说明 |
|
|
|
+|------------|----------------|------|
|
|
|
+| `name`, `realname` | 联系人信息 | 姓名 |
|
|
|
+| `data.email` | 联系人信息 | 邮箱 |
|
|
|
+| `data.title` | 联系人信息 | 职位 |
|
|
|
+| `data.companyName` | 公司信息 | 关联公司 |
|
|
|
+| `mobile` | 联系人信息 | 电话 |
|
|
|
+| `enterprise` | - | Pointer→Enterprise |
|
|
|
+| `contactProfile` | 可信度 | position.level, decisionMaker, linkedinVerified |
|
|
|
+| `verificationData` | 可信度信号 | 联网验证结果 |
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 2.5 Lead 表(ltc-nanchi)
|
|
|
+
|
|
|
+| Parse 字段 | 对应 demo Lead | 说明 |
|
|
|
+|------------|----------------|------|
|
|
|
+| `leadNumber` | `leadNumber` | 线索编号 |
|
|
|
+| `contactName`, `contactEmail` | 同 | 联系人 |
|
|
|
+| `companyName`, `country` | 同 | 公司 |
|
|
|
+| `persona`, `valueGrade` | 同 | 画像、价值等级 |
|
|
|
+| `quickScreenResult` | 同 | 快速筛选结果(可存 JSON) |
|
|
|
+| `followUpStage` | 同 | 跟进阶段 |
|
|
|
+| `entityId`, `domainKey`, `emailKey` | 同 | 主体关联 |
|
|
|
+| `enterprise` | - | Pointer→Enterprise |
|
|
|
+| `contact` | - | Pointer→ContactInfo |
|
|
|
+| `investigationSummary` | 背调 / 可信度 | enterprise/contact 的可信度汇总 |
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+## 三、AI 模型与接口
|
|
|
+
|
|
|
+### 3.1 模型概览
|
|
|
+
|
|
|
+| 模型 | 来源 | 用途 | lead-detail 对应板块 |
|
|
|
+|------|------|------|----------------------|
|
|
|
+| **fmode-1.6-cn** | fmode-ng 内部 | 轻量级任务、线索价值分析、综合评级 | 客户画像、可信度、评分、AI 下一步、背调综合评级 |
|
|
|
+| **gemini-2.5-flash** | server.fmode.cn | 搜索增强、深度分析、联网验证、战略分析 | 可信度/联网验证、推荐产品、背调维度分析 |
|
|
|
+| **fmode-4.5-1m-tiny** | fmode-ng 内部 | 公司背调结构化提取、长上下文 | 背调报告 |
|
|
|
+| **gemini-1.5-flash-latest** | server.fmode.cn | 长上下文分析(备用) | 背调等 |
|
|
|
+
|
|
|
+**模型选型策略(AiTaskFlowService):**
|
|
|
+
|
|
|
+- 轻量级(预处理、提取)→ `fmode-1.6-cn`(中文优化、快速、低成本)
|
|
|
+- 搜索增强(验证、情报)→ `google-search` + `firecrawl` + `gemini-2.5-flash`
|
|
|
+- 深度分析(战略、方案)→ `gemini-2.5-flash`
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 3.2 Generate API(server.fmode.cn)
|
|
|
+
|
|
|
+**Base URL**:`https://server.fmode.cn`
|
|
|
+**认证**:`Authorization: Bearer <token>`,token 来自 `localStorage.fmode_auth_token` 或 `Parse.User.current().get('sessionToken')`
|
|
|
+
|
|
|
+| 接口 | 路径 | 方法 | 模型/插件 | 用途 |
|
|
|
+|------|------|------|-----------|------|
|
|
|
+| **Google 搜索** | `/api/apig/generate/plugin/google-search` | POST | - | 公司验证、市场情报、竞品分析 |
|
|
|
+| **AI 模型** | `/api/apig/generate/minor/{model}` | POST | gemini-2.5-flash 等 | 深度分析、联网验证、战略评估 |
|
|
|
+| **Firecrawl 批量抓取** | `/api/apig/firecrawl/batch/scrape` | POST | - | 抓取官网/社媒等网页 Markdown 或 JSON |
|
|
|
+
|
|
|
+**Google Search 请求:**
|
|
|
+
|
|
|
+```json
|
|
|
+{ "query": "string", "num": 5, "page": 1 }
|
|
|
+```
|
|
|
+
|
|
|
+**AI Model 请求:**
|
|
|
+
|
|
|
+```json
|
|
|
+{ "content": "用户消息", "role_content": "系统角色" }
|
|
|
+```
|
|
|
+
|
|
|
+**Firecrawl 批量抓取请求:**
|
|
|
+
|
|
|
+```json
|
|
|
+{
|
|
|
+ "urls": ["https://example.com"],
|
|
|
+ "formats": ["markdown", { "type": "json", "prompt": "...", "schema": {...} }],
|
|
|
+ "pollInterval": 2,
|
|
|
+ "timeout": 120
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 3.3 内部 AI 接口(fmode-ng)
|
|
|
+
|
|
|
+| 接口 | 来源 | 默认模型 | 用途 |
|
|
|
+|------|------|----------|------|
|
|
|
+| **completionJSON** | `fmode-ng/core` | fmode-1.6-cn | 结构化 JSON 输出,用于价值分析、提取等 |
|
|
|
+| **FmodeChatCompletion** | `fmode-ng/core` | fmode-1.6-cn | 对话式补全,支持流式 |
|
|
|
+| **executeSingleAITask** | AiTaskFlowService | 按任务类型选型 | 统一任务编排,自动选模型 |
|
|
|
+
|
|
|
+**completionJSON 用法:**
|
|
|
+
|
|
|
+```ts
|
|
|
+import { completionJSON } from 'fmode-ng/core';
|
|
|
+
|
|
|
+const result = await completionJSON(prompt, schema, onStream?);
|
|
|
+// 返回 schema 定义的结构化对象
|
|
|
+```
|
|
|
+
|
|
|
+**executeSingleAITask 用法:**
|
|
|
+
|
|
|
+```ts
|
|
|
+const result = await aiTaskFlowService.executeSingleAITask<OutputType>(
|
|
|
+ taskType, // 如 'requirement_extraction' | 'company_verification' | 'strategic_analysis'
|
|
|
+ { message, schema, searchQueries?, ... }
|
|
|
+);
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 3.4 Brainwork EML 解析 API
|
|
|
+
|
|
|
+| 项目 | 值 |
|
|
|
+|------|-----|
|
|
|
+| URL | `https://eml.brainwork.club:8900/api/parse` |
|
|
|
+| 方法 | POST(FormData,字段 `file` = .eml 文件) |
|
|
|
+| 认证 | Header: `X-API-Key: fmode_cb_tgUyPSUXWZeLCgXVoLoCfOBingKQ9yAp` |
|
|
|
+| 参数 | Query: `analyze_attachments=true` |
|
|
|
+
|
|
|
+**返回**:含 `productDemands`、`cleanedBody`、`senderEmail`、`companyDomain` 等,映射到 requirementExtraction._rawDemands。
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 3.5 官网爬虫 API
|
|
|
+
|
|
|
+| 项目 | 值 |
|
|
|
+|------|-----|
|
|
|
+| URL | `https://scraper.brainwork.club:8445/api/ecommerce` |
|
|
|
+| 方法 | POST |
|
|
|
+| Body | `{ "url": "https://example.com" }` |
|
|
|
+
|
|
|
+**返回**:`products[]`(name, price, category, certifications)、`socialLinks` 等,用于推荐产品、需求补充。
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 3.6 板块与 AI 模型 / 接口映射
|
|
|
+
|
|
|
+| lead-detail 板块 | 使用的 AI 模型 | 调用的 API / 服务 |
|
|
|
+|------------------|----------------|-------------------|
|
|
|
+| 客户画像分析 | fmode-1.6-cn、gemini-2.5-flash | EmailAnalysisWorkflowService、AiTaskFlowService |
|
|
|
+| 快速筛选结果 | fmode-1.6-cn、gemini-2.5-flash | EmailAnalysisWorkflowService、loadEnterpriseAndContactInfo |
|
|
|
+| 需求摘要 | Brainwork、fmode-1.6-cn | Brainwork parse、requirementExtraction、_rawDemands |
|
|
|
+| 原始邮件信息 | 无 | Parse Email 表查询 |
|
|
|
+| 推荐产品 | fmode-1.6-cn、gemini-2.5-flash | generateProductSuggestions、官网爬虫 API |
|
|
|
+| 可信度 / 评分 | gemini-2.5-flash | GenerateApiService.callAIModel、firecrawlBatchScrape、googleSearch |
|
|
|
+| AI 推荐下一步 | fmode-1.6-cn | AgentValueAnalysisService(completionJSON)、EmailAnalysis.nextSteps |
|
|
|
+
|
|
|
+**demo-nanchi 实现**:
|
|
|
+- `AiScreenService`:有联网背调数据时用 gemini-2.5-flash,否则用 fmode-1.6-cn(completionJSON)
|
|
|
+- `CredibilityAnalysisService`:独立可信度/评分分析,使用 gemini-2.5-flash
|
|
|
+- 所有提示词已统一为**南驰(Nanchi)**
|
|
|
+| 背调报告 | fmode-1.6-cn、gemini-2.5-flash、fmode-4.5-1m-tiny | LeadBackgroundCheckService、AiTaskFlowService |
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+## 四、服务与接口复用
|
|
|
+
|
|
|
+### 4.1 EnterpriseContactService
|
|
|
+
|
|
|
+**路径**:`ltc-nanchi/shared/services/enterprise-contact.service.ts`
|
|
|
+
|
|
|
+| 方法 | 用途 | lead-detail 调用场景 |
|
|
|
+|------|------|----------------------|
|
|
|
+| `loadEnterpriseAndContactInfo(message)` | 按邮件加载 Enterprise + ContactInfo + verificationInfo | 进入详情页时,用 `email` 或 `lead.contactEmail` 查 Email,再传入 message 获取 enterpriseInfo、contactInfo、verificationInfo |
|
|
|
+| `createOrUpdateEnterprise(params, aiAnalysisData)` | 创建/更新企业 | EML 导入、联网验证后 |
|
|
|
+| `createOrUpdateContact(params, aiAnalysisData)` | 创建/更新联系人 | EML 导入、联网验证后 |
|
|
|
+| `getEnterpriseAndContact(email, companyName)` | 直接查 Enterprise/Contact | 已有 lead 时,用 contactEmail 查 |
|
|
|
+| `buildInvestigationSummary(enterprise, contact)` | 构建背调维度摘要 | 可信度板块 |
|
|
|
+
|
|
|
+**loadEnterpriseAndContactInfo 返回:**
|
|
|
+
|
|
|
+```ts
|
|
|
+{
|
|
|
+ enterpriseInfo?: {
|
|
|
+ name, industry, status,
|
|
|
+ basic_info: { domain, country, address, foundedYear, employeeCount, revenue },
|
|
|
+ verificationData,
|
|
|
+ enterpriseProfile,
|
|
|
+ marketIntelligence,
|
|
|
+ needsVerification, verificationAge
|
|
|
+ };
|
|
|
+ contactInfo?: {
|
|
|
+ name, realname, mobile,
|
|
|
+ data: { email, title, companyName, ... },
|
|
|
+ verificationData,
|
|
|
+ contactProfile
|
|
|
+ };
|
|
|
+ verificationInfo?: {
|
|
|
+ companyVerified,
|
|
|
+ dataSources: { url, title, snippet, credibility }[],
|
|
|
+ keyFindings, companyProfile, recentActivity,
|
|
|
+ verifiedInfo: { country, employeeCount, foundedYear, certifications }
|
|
|
+ };
|
|
|
+}
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 4.2 EmailAnalysisWorkflowService
|
|
|
+
|
|
|
+**路径**:`ltc-nanchi/shared/services/agent/email-analysis-workflow.service.ts`
|
|
|
+
|
|
|
+| 产出 | 对应 lead-detail 板块 |
|
|
|
+|------|------------------------|
|
|
|
+| `requirementExtraction` | 需求摘要、推荐产品、certRequirements |
|
|
|
+| `customerProfile` | 客户画像、mainBusiness、country |
|
|
|
+| `strategicAnalysis`(leadScore, priorityLevel, responseTime) | 评分、AI 下一步 |
|
|
|
+| `suggestedProducts` | 推荐产品列表 |
|
|
|
+| `summary`, `intent` | 客户画像摘要 |
|
|
|
+
|
|
|
+**调用方式**:通常由 Email 导入/分析流程触发,结果写入 EmailAnalysis 表。demo 侧通过查询 `Email.aiAnalysis` 或 `EmailAnalysis` 获取。
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 4.3 AgentValueAnalysisService
|
|
|
+
|
|
|
+**路径**:`ltc-nanchi/shared/services/agent/agent-value-analysis.service.ts`
|
|
|
+
|
|
|
+| 产出 | 对应 lead-detail 板块 |
|
|
|
+|------|------------------------|
|
|
|
+| `dimensions` | 评分详情(match, opportunity, urgency, credibility, risk) |
|
|
|
+| `quickBgCheck` | 可信度信号(companyVerified, riskLevel, certifications) |
|
|
|
+| `nextActions` | AI 推荐下一步 |
|
|
|
+| `reportMarkdown` | 背调报告摘要 |
|
|
|
+| `recommendation` | 是否继续跟进 |
|
|
|
+
|
|
|
+**映射到 demo 五维评分:**
|
|
|
+
|
|
|
+| demo 评分 | AgentValueAnalysis 维度 |
|
|
|
+|-----------|-------------------------|
|
|
|
+| 需求明确度 | dimensions.match |
|
|
|
+| 可信度 | dimensions.credibility |
|
|
|
+| 商业规模 | dimensions.opportunity |
|
|
|
+| 供需匹配 | dimensions.match / productFit |
|
|
|
+| (未单独) | dimensions.urgency, dimensions.risk |
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 4.4 EmailImportWorkflowService
|
|
|
+
|
|
|
+**路径**:`ltc-nanchi/shared/services/agent/email-import-workflow.service.ts`
|
|
|
+
|
|
|
+- 负责:解析 → 保存 Email + EmailAnalysis → 联网验证 → 创建/更新 Enterprise + ContactInfo
|
|
|
+- demo 复用:EML 导入时调用等价流程,确保 Email、EmailAnalysis、Enterprise、ContactInfo 四表数据完整
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 4.5 LeadBackgroundCheckService(背调)
|
|
|
+
|
|
|
+**路径**:`ltc-nanchi/shared/services/background-check/lead-background-check.service.ts`
|
|
|
+
|
|
|
+- 产出:`reportData`(dimension1/2/3, rating, risk, strategy)
|
|
|
+- 对应 demo:`lead.backgroundCheckReport`(BackgroundCheckReport 结构)
|
|
|
+- 保存:reportData 写入 Lead,Enterprise 表更新 social_media 等
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+## 五、板块级数据获取流程
|
|
|
+
|
|
|
+### 5.1 客户画像分析
|
|
|
+
|
|
|
+**数据来源:**
|
|
|
+
|
|
|
+- `EmailAnalysis.customerProfile`:companyType, country, buyingPower, companyScale
|
|
|
+- `EmailAnalysis.requirementExtraction`:productCategory, certifications
|
|
|
+- `lead.quickScreenResult`:persona, personaLabel, matchedKeywords(可由 requirementExtraction + customerProfile 映射)
|
|
|
+
|
|
|
+**复用:**
|
|
|
+
|
|
|
+1. 查询 `Email` → `Email.aiAnalysis`(Pointer EmailAnalysis)
|
|
|
+2. 读取 `customerProfile`、`requirementExtraction`
|
|
|
+3. 若 Lead 已有 `quickScreenResult`,可优先用;否则从 EmailAnalysis 映射生成
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 5.2 快速筛选结果(公司信息 / 联系人信息)
|
|
|
+
|
|
|
+**公司信息:**
|
|
|
+
|
|
|
+- `Enterprise`:name, basic_info.domain, basic_info.country, industry, enterpriseProfile
|
|
|
+- `EmailAnalysis`:customerProfile.country, requirementExtraction
|
|
|
+- `Email`:customerCompany, companyDomain
|
|
|
+
|
|
|
+**联系人信息:**
|
|
|
+
|
|
|
+- `ContactInfo`:name, data.email, data.title, mobile
|
|
|
+- `Email`:fromEmail, fromName, customerEmail, contactName
|
|
|
+
|
|
|
+**复用:**
|
|
|
+
|
|
|
+1. `loadEnterpriseAndContactInfo(emailMessage)` 获取 enterpriseInfo、contactInfo
|
|
|
+2. 合并到 `quickScreenResult` 或单独展示
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 5.3 需求摘要
|
|
|
+
|
|
|
+**数据来源:**
|
|
|
+
|
|
|
+- `EmailAnalysis.requirementExtraction`:productCategory, quantity, budget, certifications
|
|
|
+- `requirementExtraction._rawDemands`(Brainwork):productName, quantity, unitPrice, totalPrice
|
|
|
+- `lead.quickScreenResult.demandSnapshot`:若快速筛选已生成则直接用
|
|
|
+
|
|
|
+**映射:**
|
|
|
+
|
|
|
+```ts
|
|
|
+// 从 requirementExtraction 构建 demandSnapshot
|
|
|
+demandSnapshot = {
|
|
|
+ products: (requirementExtraction._rawDemands || []).map(d => ({
|
|
|
+ name: d.productName,
|
|
|
+ quantity: parseQuantity(d.quantity),
|
|
|
+ unit: d.unit || '/年'
|
|
|
+ })),
|
|
|
+ estimatedAnnualValue: 从 totalPrice / budget 推算,
|
|
|
+ certifications: requirementExtraction.certifications || []
|
|
|
+};
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 5.4 原始邮件信息
|
|
|
+
|
|
|
+**数据来源:** Parse `Email` 表
|
|
|
+
|
|
|
+**复用:**
|
|
|
+
|
|
|
+1. `getEmailForLead(lead)`:`emails.find(e => e.leadId === lead.id)` 或 `e.from === lead.contactEmail`
|
|
|
+2. 若内存无,则 `Parse.Query('Email').equalTo('leadId', lead.id).first()` 或 `.equalTo('customerEmail', lead.contactEmail)`
|
|
|
+3. 返回字段按 DEMO_NANCHI_REUSE_SPEC 的 Email 契约
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 5.5 推荐产品
|
|
|
+
|
|
|
+**数据来源:**
|
|
|
+
|
|
|
+- `EmailAnalysisWorkflowService.generateProductSuggestions(requirementExtraction)`:基于 productCategory
|
|
|
+- 产品目录服务:按 productCategory 匹配 SKU、name、price
|
|
|
+- `lead.quickScreenResult.suggestedProducts`:若快速筛选已生成
|
|
|
+
|
|
|
+**复用:**
|
|
|
+
|
|
|
+1. 优先用 `lead.quickScreenResult.suggestedProducts`
|
|
|
+2. 若无,从 `requirementExtraction.productCategory` + 产品目录匹配
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 5.6 可信度 / 评分 / AI 推荐下一步
|
|
|
+
|
|
|
+**可信度:**
|
|
|
+
|
|
|
+- `Enterprise.enterpriseProfile.credibilityScore`
|
|
|
+- `Enterprise.verificationData`:companyVerified, sources
|
|
|
+- `verificationInfo`:dataSources, verifiedInfo
|
|
|
+
|
|
|
+**评分:**
|
|
|
+
|
|
|
+- `AgentValueAnalysisService.analyze()` → dimensions
|
|
|
+- 或 `EmailAnalysis` 的 confidence、leadPotential、strategicAnalysis.leadScore
|
|
|
+
|
|
|
+**AI 下一步:**
|
|
|
+
|
|
|
+- `AgentValueAnalysisResult.nextActions`
|
|
|
+- `EmailAnalysis.nextSteps`
|
|
|
+- `lead.quickScreenResult.recommendedActions`(timeframe, filesToSend, keyPoints)
|
|
|
+
|
|
|
+**复用:**
|
|
|
+
|
|
|
+1. 有 Lead 且已做价值分析:用 AgentValueAnalysis 结果
|
|
|
+2. 否则用 `loadEnterpriseAndContactInfo` 的 verificationInfo + enterpriseProfile 推断
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### 5.7 深度调研 / 背调报告
|
|
|
+
|
|
|
+**数据来源:**
|
|
|
+
|
|
|
+- `LeadBackgroundCheckService`:reportData → dimension1/2/3, rating, risk, strategy
|
|
|
+- `Enterprise`:enterpriseProfile, verificationData
|
|
|
+- `ContactInfo`:contactProfile
|
|
|
+
|
|
|
+**复用:**
|
|
|
+
|
|
|
+1. 背调完成后,reportData 写入 `lead.backgroundCheckReport`
|
|
|
+2. 结构已与 demo `BackgroundCheckReport` 兼容,可直接展示
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+## 六、实现优先级建议
|
|
|
+
|
|
|
+| 优先级 | 板块 | 复用内容 | 复杂度 |
|
|
|
+|--------|------|----------|--------|
|
|
|
+| P0 | 原始邮件信息 | Parse Email 表查询 | 低 |
|
|
|
+| P0 | 需求摘要 | EmailAnalysis.requirementExtraction + _rawDemands | 中 |
|
|
|
+| P1 | 快速筛选结果(公司/联系人) | loadEnterpriseAndContactInfo | 中 |
|
|
|
+| P1 | 客户画像 | EmailAnalysis.customerProfile + requirementExtraction | 中 |
|
|
|
+| P2 | 可信度 / 评分 | Enterprise.enterpriseProfile + verificationInfo | 中 |
|
|
|
+| P2 | AI 推荐下一步 | AgentValueAnalysis 或 EmailAnalysis.nextSteps | 中 |
|
|
|
+| P3 | 背调报告 | LeadBackgroundCheckService + reportData | 高 |
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+## 七、相关文件路径
|
|
|
+
|
|
|
+| 用途 | ltc-nanchi 路径 | demo-nanchi 路径 |
|
|
|
+|------|-----------------|------------------|
|
|
|
+| **AI / Generate API** | `shared/services/agent/generate-api.service.ts` | 可复制或封装调用 |
|
|
|
+| AI 任务流 | `shared/services/agent/ai-task-flow.service.ts` | executeSingleAITask 等 |
|
|
|
+| 企业/联系人服务 | `shared/services/enterprise-contact.service.ts` | 可复制或封装调用 |
|
|
|
+| 邮件分析工作流 | `shared/services/agent/email-analysis-workflow.service.ts` | 参考产出结构 |
|
|
|
+| 价值分析 | `shared/services/agent/agent-value-analysis.service.ts` | 可复制或封装调用 |
|
|
|
+| 邮件导入工作流 | `shared/services/agent/email-import-workflow.service.ts` | 参考完整流程 |
|
|
|
+| 分析类型定义 | `shared/services/agent/email-analysis.types.ts` | 可复制 RequirementExtractionResult 等 |
|
|
|
+| 背调服务 | `shared/services/background-check/lead-background-check.service.ts` | 参考 reportData 结构 |
|
|
|
+| fmode-ng 能力 | `fmode-ng/core`(completionJSON, FmodeChatCompletion) | 复用同包 |
|
|
|
+| lead-detail 页面 | `lead-discovery/src/app/pages/lead-detail/` | 待接入上述数据源 |
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+## 八、数据流小结
|
|
|
+
|
|
|
+```
|
|
|
+Email (Parse)
|
|
|
+ ├── aiAnalysis → EmailAnalysis
|
|
|
+ │ ├── requirementExtraction → 需求摘要、推荐产品、certRequirements
|
|
|
+ │ ├── customerProfile → 客户画像、公司信息
|
|
|
+ │ ├── verificationInfo → 可信度信号
|
|
|
+ │ └── nextSteps → AI 推荐下一步
|
|
|
+ ├── customerEmail / fromEmail → 关联
|
|
|
+ └── leadId → Lead
|
|
|
+
|
|
|
+Enterprise (Parse) ← loadEnterpriseAndContactInfo
|
|
|
+ ├── enterpriseProfile → 可信度、评分
|
|
|
+ ├── verificationData → 联网验证
|
|
|
+ └── basic_info → 公司信息
|
|
|
+
|
|
|
+ContactInfo (Parse) ← loadEnterpriseAndContactInfo
|
|
|
+ ├── data → 联系人信息
|
|
|
+ └── contactProfile → 可信度
|
|
|
+
|
|
|
+Lead (Parse)
|
|
|
+ ├── quickScreenResult → 快速筛选(可含 demandSnapshot, scores, recommendedActions)
|
|
|
+ ├── backgroundCheckReport → 背调报告
|
|
|
+ └── enterprise, contact → 关联 Enterprise/ContactInfo
|
|
|
+
|
|
|
+AgentValueAnalysisService.analyze() → dimensions, nextActions, quickBgCheck
|
|
|
+```
|