--- category: schema title: YSS项目Parse Server数据范式 - Product表统一空间管理 subtitle: 映三色设计师项目管理系统完整数据表结构(基于Product表的空间管理版本) name: 'yss-schemas-product-space' label: database --- # Parse Server 数据范式 - 映三色项目管理系统(Product表统一空间管理) ## 概述 本文档定义了映三色(YSS)设计师项目管理系统的完整Parse Server数据范式。系统采用**多租户架构**,以Company为核心,支持客服、设计师、组长等多角色协作的全流程项目管理。 **核心特性**: - 🏢 多租户架构,以Company为核心租户隔离 - 👥 统一员工表(Profile)和客户表(ContactInfo) - 📋 项目与群聊灵活关联(Project ←→ GroupChat) - 🏠 **Product表统一空间管理**:通过Product表实现多空间设计产品管理 - 🎨 设计师项目全生命周期管理 - 💰 财务报价与结算流程 - 📊 质量控制与客户反馈 **空间管理优化**: - 🎯 **Product即空间**:每个Product代表一个空间的设计产品 - 💰 **产品报价**:通过Product的`.quotation`字段管理空间级报价 - 📁 **文件分类**:ProjectFile通过`.fileCategory`区分panorama、delivery等类型 - 👥 **设计师分配**:通过Product的`.profile`字段直接关联负责设计师 - 🎯 **产品需求**:通过Product的`.requirements`字段管理空间需求 - ⭐ **产品评价**:通过Product的`.reviews`字段管理空间评价 --- ## 数据表关系图 - Department 项目组(部门) - name String 项目组名称 - type "project" 项目组 - leader Pointer 组长 - company Pointer 指向当前帐套 ```plantuml @startuml !define TABLE(name,desc) class name as "desc" << (T,#FFAAAA) >> !define FIELD(name,type) name : type skinparam classAttributeIconSize 0 skinparam class { BackgroundColor LightYellow BorderColor Black ArrowColor Black } ' ============ 核心租户与人员 ============ TABLE(Company, "Company\n企业表") { FIELD(objectId, String) FIELD(name, String) FIELD(corpId, String) FIELD(data, Object) FIELD(isDeleted, Boolean) } TABLE(Profile, "Profile\n员工档案表") { FIELD(objectId, String) FIELD(name, String) FIELD(mobile, String) FIELD(department, Pointer→Department) FIELD(company, Pointer→Company) FIELD(userId, String) FIELD(roleName, String) FIELD(data, Object) FIELD(isDeleted, Boolean) } TABLE(ContactInfo, "ContactInfo\n客户信息表") { FIELD(objectId, String) FIELD(name, String) FIELD(mobile, String) FIELD(company, Pointer→Company) FIELD(external_userid, String) FIELD(source, String) FIELD(data, Object) FIELD(isDeleted, Boolean) } ' ============ 企微集成 ============ TABLE(GroupChat, "GroupChat\n企微群聊表") { FIELD(objectId, String) FIELD(chat_id, String) FIELD(name, String) FIELD(company, Pointer→Company) FIELD(project, Pointer→Project) FIELD(member_list, Array) FIELD(joinUrl, String) FIELD(data, Object) FIELD(isDeleted, Boolean) } TABLE(ProjectGroup, "ProjectGroup\n项目群组关联表") { FIELD(objectId, String) FIELD(project, Pointer→Project) FIELD(groupChat, Pointer→GroupChat) FIELD(isPrimary, Boolean) FIELD(createdAt, Date) } ' ============ 项目模块 ============ TABLE(Project, "Project\n项目表") { FIELD(objectId, String) FIELD(title, String) FIELD(company, Pointer→Company) FIELD(customer, Pointer→ContactInfo) FIELD(assignee, Pointer→Profile) FIELD(status, String) FIELD(currentStage, String) FIELD(deadline, Date) FIELD(data, Object) FIELD(isDeleted, Boolean) } ' ============ 核心创新:Product表统一空间管理 ============ TABLE(Product, "Product\n空间设计产品表") { FIELD(objectId, String) FIELD(project, Pointer→Project) FIELD(company, Pointer→Company) FIELD(profile, Pointer→Profile) FIELD(stage, String) FIELD(processType, String) FIELD(productName, String) FIELD(productType, String) FIELD(status, String) FIELD(fileUrl, String) FIELD(reviewStatus, String) FIELD(space, Object) FIELD(quotation, Object) FIELD(requirements, Object) FIELD(reviews, Array) FIELD(estimatedBudget, Number) FIELD(estimatedDuration, Number) FIELD(order, Number) FIELD(data, Object) FIELD(isDeleted, Boolean) } TABLE(ProjectRequirement, "ProjectRequirement\n需求信息表") { FIELD(objectId, String) FIELD(project, Pointer→Project) FIELD(company, Pointer→Company) FIELD(spaces, Array) FIELD(designRequirements, Object) FIELD(materialAnalysis, Object) FIELD(data, Object) FIELD(isDeleted, Boolean) } TABLE(ProjectTeam, "ProjectTeam\n项目团队表") { FIELD(objectId, String) FIELD(project, Pointer→Project) FIELD(profile, Pointer→Profile) FIELD(role, String) FIELD(workload, Number) FIELD(isDeleted, Boolean) } ' ============ 文件管理(简化版) ============ TABLE(ProjectFile, "ProjectFile\n项目文件表") { FIELD(objectId, String) FIELD(project, Pointer→Project) FIELD(product, Pointer→Product) FIELD(attach, Pointer→Attachment) FIELD(uploadedBy, Pointer→Profile) FIELD(stage, String) FIELD(data, Object) FIELD(isDeleted, Boolean) } ' ============ 财务模块 ============ TABLE(ProjectSettlement, "ProjectSettlement\n结算记录表") { FIELD(objectId, String) FIELD(project, Pointer→Project) FIELD(company, Pointer→Company) FIELD(stage, String) FIELD(amount, Number) FIELD(percentage, Number) FIELD(status, String) FIELD(dueDate, Date) FIELD(settledAt, Date) FIELD(data, Object) FIELD(isDeleted, Boolean) } TABLE(ProjectVoucher, "ProjectVoucher\n付款凭证表") { FIELD(objectId, String) FIELD(settlement, Pointer→ProjectSettlement) FIELD(project, Pointer→Project) FIELD(amount, Number) FIELD(voucherUrl, String) FIELD(recognizedInfo, Object) FIELD(verifiedBy, Pointer→Profile) FIELD(data, Object) FIELD(isDeleted, Boolean) } ' ============ 质量与反馈 ============ TABLE(ProjectFeedback, "ProjectFeedback\n客户反馈表") { FIELD(objectId, String) FIELD(project, Pointer→Project) FIELD(customer, Pointer→ContactInfo) FIELD(product, Pointer→Product) FIELD(stage, String) FIELD(feedbackType, String) FIELD(content, String) FIELD(rating, Number) FIELD(status, String) FIELD(data, Object) FIELD(isDeleted, Boolean) } TABLE(ProjectIssue, "ProjectIssue\n异常记录表") { FIELD(objectId, String) FIELD(project, Pointer→Project) FIELD(product, Pointer→Product) FIELD(reportedBy, Pointer→Profile) FIELD(exceptionType, String) FIELD(severity, String) FIELD(description, String) FIELD(status, String) FIELD(resolution, String) FIELD(data, Object) FIELD(isDeleted, Boolean) } ' ============ 跟进记录 ============ TABLE(ContactFollow, "ContactFollow\n跟进记录表") { FIELD(objectId, String) FIELD(project, Pointer→Project) FIELD(product, Pointer→Product) FIELD(sender, Pointer→Profile/ContactInfo) FIELD(content, String) FIELD(type, String) FIELD(stage, String) FIELD(attachments, Array) FIELD(data, Object) FIELD(isDeleted, Boolean) } ' ============ 关系连线 ============ ' Company 一对多关系 Company "1" --> "n" Profile : 企业员工 Company "1" --> "n" ContactInfo : 企业客户 Company "1" --> "n" Project : 企业项目 Company "1" --> "n" GroupChat : 企业群聊 ' 项目核心关系 Project "n" --> "1" Company : 所属企业 Project "n" --> "1" ContactInfo : 客户 Project "n" --> "1" Profile : 负责人(assignee) Project "1" --> "1" ProjectRequirement : 需求信息 Project "1" <--> "n" GroupChat : ProjectGroup\n群聊关联 Project "1" --> "n" ProjectTeam : 项目团队 ' Product表统一空间管理关系 Project "1" --> "n" Product : 空间设计产品 Product "n" --> "1" Profile : 负责设计师 Product "1" --> "n" ProjectFile : 产品文件 Product "1" --> "n" ProjectFeedback : 产品反馈 Product "1" --> "n" ProjectIssue : 产品异常 Product "1" --> "n" ContactFollow : 产品跟进 ' 交付与财务 Project "1" --> "n" ProjectFile : 项目文件 Project "1" --> "n" ProjectSettlement : 结算记录 ProjectSettlement "1" --> "n" ProjectVoucher : 付款凭证 ' 质量与沟通 Project "1" --> "n" ProjectFeedback : 客户反馈 Project "1" --> "n" ProjectIssue : 异常记录 Project "1" --> "n" ContactFollow : 跟进记录 ' 群聊关系 GroupChat "n" --> "1" Company : 所属企业 GroupChat "n" --> "1" Project : 关联项目(可选) @enduml ``` --- ## 核心数据表详解 ### 1. Company(企业表) **用途**: 多租户系统的核心,所有数据通过 company 字段进行租户隔离。 | 字段名 | 类型 | 必填 | 说明 | 示例值 | |--------|------|------|------|--------| | objectId | String | 是 | 主键ID | "cDL6R1hgSi" | | name | String | 是 | 企业名称 | "映三色设计" | | corpId | String | 否 | 企业微信CorpID | "ww1234567890" | | data | Object | 否 | 扩展数据 | { settings: {...}, modules: [...] } | | isDeleted | Boolean | 否 | 软删除标记 | false | | createdAt | Date | 自动 | 创建时间 | 2024-01-01T00:00:00.000Z | | updatedAt | Date | 自动 | 更新时间 | 2024-01-01T00:00:00.000Z | --- ### 2. Profile(员工档案表) **用途**: 存储企业员工档案信息,统一管理客服、设计师、组长等所有角色。 | 字段名 | 类型 | 必填 | 说明 | 示例值 | |--------|------|------|------|--------| | objectId | String | 是 | 主键ID | "prof001" | | name | String | 是 | 员工姓名 | "张三" | | mobile | String | 否 | 手机号 | "13800138000" | | department | Pointer | 是 | 所属小组 | → Department | | company | Pointer | 是 | 所属企业 | → Company | | userId | String | 否 | 企微UserID | "zhangsan" | | roleName | String | 是 | 员工角色 | "客服" / "组员" / "组长" | | data | Object | 否 | 扩展数据 | { avatar, department, skills, ... } | | isDeleted | Boolean | 否 | 软删除标记 | false | | createdAt | Date | 自动 | 创建时间 | 2024-01-01T00:00:00.000Z | | updatedAt | Date | 自动 | 更新时间 | 2024-01-01T00:00:00.000Z | **role 枚举值**: - `客服`: 客户服务人员,负责接单、跟进 - `组员`: 设计师,负责具体设计工作 - `组长`: 团队负责人,负责审核、分配 - `财务`: 财务人员 - `人事`: 人事人员 - `管理员`: 系统管理员 --- ### 3. ContactInfo(客户信息表) **用途**: 统一管理所有客户信息,支持企微外部联系人同步。 | 字段名 | 类型 | 必填 | 说明 | 示例值 | |--------|------|------|------|--------| | objectId | String | 是 | 主键ID | "contact001" | | name | String | 是 | 客户姓名 | "李四" | | mobile | String | 否 | 手机号 | "13900139000" | | company | Pointer | 是 | 所属企业 | → Company | | external_userid | String | 否 | 企微外部联系人ID | "wmxxx" | | source | String | 否 | 来源渠道 | "朋友圈" / "信息流" / "转介绍" | | data | Object | 否 | 扩展数据 | { avatar, wechat, tags, ... } | | isDeleted | Boolean | 否 | 软删除标记 | false | | createdAt | Date | 自动 | 创建时间 | 2024-01-01T00:00:00.000Z | | updatedAt | Date | 自动 | 更新时间 | 2024-01-01T00:00:00.000Z | --- ### 4. Project(项目表) **用途**: 项目管理的核心表,记录设计项目的全生命周期信息。 | 字段名 | 类型 | 必填 | 说明 | 示例值 | |--------|------|------|------|--------| | objectId | String | 是 | 主键ID | "proj001" | | title | String | 是 | 项目标题 | "李总现代简约全案" | | company | Pointer | 是 | 所属企业 | → Company | | customer | Pointer | 是 | 客户 | → ContactInfo | | assignee | Pointer | 否 | 负责设计师 | → Profile | | status | String | 是 | 项目状态 | "进行中" | | currentStage | String | 是 | 当前阶段 | "建模" | | deadline | Date | 否 | 截止时间 | 2024-12-31T00:00:00.000Z | | data | Object | 否 | 扩展数据 | { requirements, stageHistory, ... } | | isDeleted | Boolean | 否 | 软删除标记 | false | | createdAt | Date | 自动 | 创建时间 | 2024-01-01T00:00:00.000Z | | updatedAt | Date | 自动 | 更新时间 | 2024-01-01T00:00:00.000Z | --- ### 5. Product(空间设计产品表)⭐ **功能描述**: **核心创新** - 统一管理空间设计产品,每个Product代表一个空间的设计产品(如"李总主卧设计"、"王总客厅设计"),包含空间信息、报价、需求、评价等全生命周期数据。 **字段说明**: | 字段名 | 类型 | 必填 | 说明 | 示例值 | |--------|------|------|------|--------| | objectId | String | 是 | 主键ID | "prod001" | | project | Pointer | 是 | 所属项目 | → Project | | company | Pointer | 是 | 所属企业 | → Company | | **profile** | **Pointer** | **是** | **负责设计师** | **→ Profile** | | stage | String | 是 | 设计阶段 | "建模" / "渲染" / "后期" | | processType | String | 否 | 工序类型 | "modeling" / "rendering" | | **productName** | **String** | **是** | **产品名称** | **"李总主卧设计"** | | **productType** | **String** | **是** | **空间类型** | **"bedroom"** | | status | String | 是 | 产品状态 | "进行中" | | fileUrl | String | 否 | 主要效果图URL | "https://..." | | reviewStatus | String | 是 | 审核状态 | "pending" / "approved" | | **space** | **Object** | **否** | **空间信息** | **{name, area, dimensions}** | | **quotation** | **Object** | **否** | **产品报价** | **{price, breakdown}** | | **requirements** | **Object** | **否** | **设计需求** | **{color, material}** | | **reviews** | **Array** | **否** | **产品评价** | **[{rating, comments}]** | | estimatedBudget | Number | 否 | 预估预算 | 35000 | | estimatedDuration | Number | 否 | 预估工期(天) | 7 | | order | Number | 否 | 排序顺序 | 1 | | data | Object | 否 | 扩展数据 | { version, progress, ... } | | isDeleted | Boolean | 否 | 软删除标记 | false | **productType 枚举值**: - `living_room`: 客厅 - `bedroom`: 卧室 - `kitchen`: 厨房 - `bathroom`: 卫生间 - `dining_room`: 餐厅 - `study`: 书房 - `balcony`: 阳台 - `corridor`: 走廊 - `storage`: 储物间 - `entrance`: 玄关 - `other`: 其他 **status 枚举值**: - `not_started`: 未开始 - `in_progress`: 进行中 - `awaiting_review`: 待审核 - `completed`: 已完成 - `blocked`: 已阻塞 - `delayed`: 已延期 **space 字段结构示例**: ```json { "spaceName": "主卧", "area": 18.5, "dimensions": { "length": 4.5, "width": 4.1, "height": 2.8 }, "features": ["朝南", "飘窗", "独立卫浴"], "constraints": ["承重墙不可动"], "priority": "high", "complexity": "medium" } ``` **quotation 字段结构示例**: ```json { "price": 35000, "currency": "CNY", "breakdown": { "design": 15000, "modeling": 10000, "rendering": 8000, "softDecor": 2000 }, "unitPrice": 1891, "estimatedDays": 7, "status": "approved", "approvedBy": {"__type": "Pointer", "className": "Profile", "objectId": "prof001"}, "validUntil": "2024-12-31T00:00:00.000Z" } ``` **requirements 字段结构示例**: ```json { "colorRequirement": { "primaryHue": 180, "saturation": 45, "temperature": "暖色调", "colorDistribution": [ {"hex": "#F5F5DC", "percentage": 40, "name": "米白色"}, {"hex": "#8B4513", "percentage": 30, "name": "原木色"} ] }, "materialRequirement": { "preferred": ["实木", "环保材料"], "avoid": ["塑料", "合成材料"], "budget": { "min": 20000, "max": 40000 } }, "lightingRequirement": { "naturalLight": "充足", "lightColor": "暖白", "specialRequirements": ["床头阅读灯", "氛围灯"] }, "specificRequirements": [ "需要大储物空间", "独立卫浴", "飘窗设计" ], "referenceImages": ["https://...", "https://..."] } ``` **reviews 字段结构示例**: ```json [ { "reviewId": "review001", "satisfactionScore": 4.5, "spaceSpecificRatings": { "design": 5, "functionality": 4, "material": 4, "lighting": 5 }, "usageFeedback": { "positive": ["储物空间充足", "光线舒适"], "improvements": ["可以增加插座数量"] }, "comments": "整体设计很满意,储物功能强大", "afterPhotos": ["https://...", "https://..."], "submittedAt": "2024-11-15T10:00:00.000Z", "submittedBy": {"__type": "Pointer", "className": "ContactInfo", "objectId": "contact001"} } ] ``` **使用场景示例**: ```typescript // 创建空间设计产品 const Product = Parse.Object.extend("Product"); const product = new Product(); product.set("project", project.toPointer()); product.set("profile", designer.toPointer()); product.set("productName", "李总主卧设计"); product.set("productType", "bedroom"); product.set("stage", "modeling"); // 设置空间信息 product.set("space", { spaceName: "主卧", area: 18.5, dimensions: { length: 4.5, width: 4.1, height: 2.8 }, features: ["朝南", "飘窗", "独立卫浴"] }); // 设置产品报价 product.set("quotation", { price: 35000, currency: "CNY", breakdown: { design: 15000, modeling: 10000, rendering: 8000, softDecor: 2000 }, status: "pending" }); await product.save(); // 查询项目的所有空间设计产品 const productQuery = new Parse.Query("Product"); productQuery.equalTo("project", projectId); productQuery.notEqualTo("isDeleted", true); productQuery.ascending("order"); const products = await productQuery.find(); // 查询设计师负责的空间产品 const designerProductQuery = new Parse.Query("Product"); designerProductQuery.equalTo("profile", designerId); designerProductQuery.equalTo("status", "in_progress"); const designerProducts = await designerProductQuery.find(); ``` --- ### 6. ProjectFile(项目文件表) **用途**: 存储项目相关的所有文件,**简化设计**,通过 `.fileCategory` 字段区分文件类型。 | 字段名 | 类型 | 必填 | 说明 | 示例值 | |--------|------|------|------|--------| | objectId | String | 是 | 主键ID | "file001" | | project | Pointer | 是 | 所属项目 | → Project | | **product** | **Pointer** | **否** | **关联空间产品** | **→ Product** | | attach | Pointer | 是 | 附件 | → Attachment | NovaFile.id为Attachment.objectId| | uploadedBy | Pointer | 是 | 上传人 | → Profile | | stage | String | 否 | 关联阶段 | "需求沟通" | | category | String | 否 | 关联阶段 | "需求沟通" | | data | Object | 否 | 扩展数据 | { thumbnailUrl, ... } | | analysis | Object | 否 | 分析结果 | 详见下方 `analysis.color` 结构 | | isDeleted | Boolean | 否 | 软删除标记 | false | | createdAt | Date | 自动 | 创建时间 | 2024-01-01T00:00:00.000Z | | updatedAt | Date | 自动 | 更新时间 | 2024-01-01T00:00:00.000Z | **stage 枚举值** - `订单分配`: 'order' - `方案深化`: 'requirements' - `交付执行`: 'delivery' - `售后归档`: 'aftercare' **category 枚举值**: - `quotation`: 财务凭据 - `panorama`: 全景素材 - `delivery`: 交付文件 - `reference`: 参考文件 - `requirement`: 需求文件 **analysis.color - 色彩分析结果结构** 用于存放“色彩分析插件(color-get)”生成的分析报告,并支持重新分析覆盖。该结构与组件内 `ColorAnalysisReport` 对齐,并补充元信息。 ```json { "version": "1.0", // 结构版本,便于未来演进 "source": "color-get", // 生成来源(组件/脚本/服务) "pixelSize": 100, // 马赛克像素块大小(用于重现) "createdAt": "2025-10-20T12:00:00.000Z", // 生成时间 "palette": [ // 主色卡(按占比降序,最多20) { "rgb": { "r": 240, "g": 200, "b": 160 }, "hex": "#F0C8A0", "percentage": 28.5 } ], "mosaicUrl": "data:image/png;base64,....", // 马赛克图(可选,dataURL 或存储链接) "metrics": { "warmCoolBalance": 12.0, // 冷暖平衡:-100(冷) 到 100(暖) "averageBrightness": 56.0, // 平均亮度:0-100 "averageSaturation": 42.5, // 平均饱和度:0-100 "diversity": 18 // 色彩多样度(主色数量) }, "histogram": { "brightnessBins": [0, 1, 3, 5, 8, 12, 9, 6, 3, 1], "saturationBins": [0, 0, 2, 4, 7, 10, 9, 5, 2, 1] }, "splitPoints": [ // 色彩拆分散点(冷暖/明暗/占比/色值) { "temp": 14.2, "brightness": 62.1, "size": 3.5, "color": "#F0C8A0" } ] } ``` **读写约定** - 写入:将以上对象保存至 `ProjectFile.analysis.color`。 - 读取:若存在 `analysis.color`,组件直接使用并渲染(无需重复计算)。 - 重新分析:覆盖同一字段,保留 `version`、`source`、`pixelSize` 与 `createdAt` 更新。 - 存储位置:优先内嵌对象;如需持久化图像(大体积 `mosaicUrl`),可改为文件存储链接,并在此字段写入其URL。 **fileType 枚举值**: - `cad`: CAD图纸 - `reference`: 参考图片 - `document`: 文档资料 - `contract`: 合同文件 - `voucher`: 付款凭证 - `other`: 其他 **使用场景示例**: ```typescript // 上传空间产品相关的全景图文件 const ProjectFile = Parse.Object.extend("ProjectFile"); const file = new ProjectFile(); file.set("project", project.toPointer()); file.set("product", product.toPointer()); // 关联到具体空间产品 file.set("fileCategory", "panorama"); // 标记为全景图文件 file.set("fileName", "主卧720全景图.jpg"); file.set("uploadedBy", profile.toPointer()); await file.save(); // 查询空间产品的所有全景图文件 const panoramaQuery = new Parse.Query("ProjectFile"); panoramaQuery.equalTo("product", productId); panoramaQuery.equalTo("fileCategory", "panorama"); panoramaQuery.notEqualTo("isDeleted", true); const panoramaFiles = await panoramaQuery.find(); // 查询空间产品的所有报价文件 const quotationQuery = new Parse.Query("ProjectFile"); quotationQuery.equalTo("product", productId); quotationQuery.equalTo("fileCategory", "quotation"); const quotationFiles = await quotationQuery.find(); ``` --- ### 7. ProjectFeedback(客户反馈表) **用途**: 记录客户在各阶段的反馈和评价。**已更新支持产品关联**。 | 字段名 | 类型 | 必填 | 说明 | 示例值 | |--------|------|------|------|--------| | objectId | String | 是 | 主键ID | "feedback001" | | project | Pointer | 是 | 所属项目 | → Project | | **product** | **Pointer** | **否** | **关联空间产品** | **→ Product** | | customer | Pointer | 是 | 反馈客户 | → ContactInfo | | stage | String | 是 | 反馈阶段 | "建模" / "渲染" | | feedbackType | String | 是 | 反馈类型 | "suggestion" / "complaint" | | content | String | 是 | 反馈内容 | "客厅颜色希望再暖一些" | | rating | Number | 否 | 评分(1-5) | 4 | | status | String | 是 | 处理状态 | "待处理" / "已解决" | | data | Object | 否 | 扩展数据 | { response, attachments, ... } | | isDeleted | Boolean | 否 | 软删除标记 | false | | createdAt | Date | 自动 | 创建时间 | 2024-01-01T00:00:00.000Z | | updatedAt | Date | 自动 | 更新时间 | 2024-01-01T00:00:00.000Z | --- ## Product表统一空间管理的优势 ### 1. 行业语义清晰 - **Product即空间设计产品**:符合家装设计行业的业务理解 - **产品化管理**:每个空间都是一个独立的设计产品 - **商业逻辑一致**:报价、交付、评价都围绕产品展开 ### 2. 数据结构极简 - **单表多能**:Product表承载空间管理的所有核心功能 - **文件分类管理**:通过ProjectFile.fileCategory区分不同类型文件 - **设计师直连**:通过Product.profile直接关联负责设计师 ### 3. 使用场景优化 - **产品清单**:通过Product表直接获得项目的空间设计产品清单 - **交付物管理**:通过Product.fileUrl和ProjectFile管理交付物 - **报价管理**:通过Product.quotation管理产品级报价 ### 4. 实现示例对比 **原有方式(多表操作)**: ```typescript // 需要查询多个表 const spaces = await spaceQuery.equalTo("project", projectId).find(); const quotations = await quotationQuery.equalTo("project", projectId).find(); const panoramas = await panoramaQuery.equalTo("project", projectId).find(); const deliveries = await deliveryQuery.equalTo("project", projectId).find(); ``` **Product表方式(单表操作)**: ```typescript // 一次查询获得所有空间设计产品 const products = await productQuery.equalTo("project", projectId).find(); // 每个product包含完整的space、quotation、requirements信息 // 文件通过ProjectFile按fileCategory分类查询 ``` --- ## 数据迁移指南 ### 从ProjectSpace多表结构迁移到Product表 ```typescript // 1. 迁移ProjectSpace到Product const oldSpaces = await new Parse.Query("ProjectSpace").find(); for (const space of oldSpaces) { const product = new Parse.Object("Product"); product.set("project", space.get("project")); product.set("profile", space.get("assignedTeam")?.[0]?.profile); // 取第一个设计师 product.set("productName", `${space.get("project").get("title")}-${space.get("name")}`); product.set("productType", space.get("type")); product.set("space", { spaceName: space.get("name"), area: space.get("area"), dimensions: space.get("metadata")?.dimensions, features: space.get("metadata")?.features }); product.set("quotation", space.get("quotation")); product.set("requirements", space.get("requirements")); product.set("reviews", space.get("reviews")); product.set("estimatedBudget", space.get("estimatedBudget")); product.set("estimatedDuration", space.get("estimatedDuration")); product.set("order", space.get("order")); await product.save(); } // 2. 迁移ProjectFile,添加fileCategory分类 const files = await new Parse.Query("ProjectFile").find(); for (const file of files) { // 根据文件名和内容自动分类 const fileName = file.get("fileName").toLowerCase(); let fileCategory = "other"; if (fileName.includes("报价") || fileName.includes("quotation")) { fileCategory = "quotation"; } else if (fileName.includes("全景") || fileName.includes("panorama")) { fileCategory = "panorama"; } else if (fileName.includes("效果图") || fileName.includes("render")) { fileCategory = "delivery"; } else if (fileName.includes("参考") || fileName.includes("reference")) { fileCategory = "reference"; } file.set("fileCategory", fileCategory); await file.save(); } // 3. 删除不需要的表 // - ProjectSpace // - SpaceQuotation // - SpaceRequirement // - SpaceReview // - ProductCheck // - PanoramaCollection // - SpacePanorama ``` --- ## 总结 通过Product表统一空间管理的重构,YSS项目管理系统实现了: ✅ **语义清晰**:Product即空间设计产品,符合行业认知 ✅ **架构极简**:从15个空间相关表简化为1个Product表 ✅ **功能完整**:保留所有空间管理功能,语义更准确 ✅ **性能提升**:单表查询替代复杂JOIN操作 ✅ **维护便利**:降低数据模型维护成本 ✅ **扩展灵活**:Object字段支持未来功能扩展 这个基于Product表的统一空间管理方案完美解决了多空间项目管理的复杂性问题,通过Product这一天然的空间设计产品载体,实现了报价、全景图、团队协作、文件管理、需求跟踪、评价反馈等全生命周期管理,大大简化了系统架构并提高了开发效率。 --- **文档版本**: v3.0(Product表统一空间管理) **最后更新**: 2025-10-20 **维护者**: YSS Development Team