数据模型

model naming

常用业务模型

名称 类名 解释 描述
address Address 地址信息
city City 城市
country Country 国家
district District 区
province Province 省份
attachment Attachment 附件
audio Audio 语音
permission Permission 权限
supplier_apply SupplierApply 立即体验线索
upgrade_notice UpgradeNotice cms 升级公告
custom_field_group CustomFieldGroup 自定义字段分组
custom_field CustomField 自定义字段
custom_field_setting CustomFieldSetting 每个模块自定义字段设置
data_report_area DataReportArea 数据上报区域
data_report_store DataReportStore 数据上报门店
data_report_content_item DataReportContentItem 数据上报项内容
data_report_item DataReportItem 数据上报项
data_report_content DataReporContent 数据上报内容
data_report DataReport 数据上报
contact Contact 联系人
contact_assetship ContactAssetship 关联联系人
contract Contract 合同
customer Customer 客户
event Event 待办事项
lead Lead 线索
opportunity Opportunity 商机
product_category ProductCategory 产品分类
product Product 产品
product_asset ProductAsset 关联产品
received_payment ReceivedPayment 合同回款
received_payment_plan ReceivedPaymentPlan 合同回款计划
report_cc_user ReportCcUser 工作报告抄送
revisit_log RevisitLog 跟进记录
schedule_report ScheduleReport 工作报告
schedule_report_daliy ScheduleReportDaily 日报
schedule_report_monthly ScheduleReportMonthly 月报
schedule_report_weekly ScheduleReportMonthly 周报
field_map FieldMap 自定义业务参数
knowledge_catalog KnowledgeCatalog 知识库分类
knowledge_entity KnowledgeEntity 知识库条目
notification Notification 消息
reminder Reminder 提醒
report_reminder_config ReportReminderConfig 提醒配置
checkin Checkin 签到
marking Marking 批阅
sales_activity_comment SalesActivityComment 动态评论
sales_activity SalesActivity 销售动态
sales_circle SalesCircle 销售圈
sales_circle_comment SalesCircleComment 销售圈评论
sales_circle_msg SalesCircleMsg 销售圈消息
at At @
like Like 赞
announcement Announcement 系统公告
app_version AppVersion app 版本
faq Faq faq
faq_category FaqCategory faq 分类
feedback FeedBack 反馈
organization Organization 公司
user User 用户
department Department 部门
role Role 角色

模型的使用

参数包装,新建、更新数据时一般需要把需要保存的数据包装在相应的model名称里面

如API传参JSON数据:

{
  //...
  customer: {name: "wangdaye"},
  //...
}

如果需要更新一些关联数据一般有如下更新方式

一个客户拥有一个地址信息

# json 数据
customer: {address_attributes: {id: 1, note: "whosyourdaddy"}}
# form encode
customer[address_attributes][id]=1
customer[address_attributes][note]='whosyourdaddy'

一个客户拥有多个联系人信息

# json 数据
customer: {contacts_attributes: {id: 1, name: "nierye"}}
# form encode
customer[contacts_attributes][id]=1
customer[contacts_attributes][name]='nierye'

在更新操作的时候都推荐传入 关联记录的 id

作为 url Parameter 的传入值

/api/openapi/v2/custom_fields/:entity_type/by_group
/api/openapi/v2/custom_fields/Custoemr/by_group

这里的 Customer 作为 entity_type 的值

/api/openapi/v2/attachments/:entity/:id/upload_attachments

/api/openapi/v2/attachments/Customer/2/upload_attachments

这里的 Customer 作为 entity 的值, 2 作为 id; 整个地址表示更新 id 为 2 的 customer 的附件

在多态 model 中被使用

系统中使用到的多态

model name polymorphic field 描述
address addressable 引用地址的对象
at atable @对象
like likeable 赞的对象
approval approvable 被审批的实体
attachment attachmentable 引用附件的对象
audio audioable 引用语音的对象
checkin checkable 签到关联对象
contact_assetship assetable 关联联系人被关联对象
marking markable 被点评的实体
notification notifiable 引用消息的对象
product_asset assetable 关联产品人被关联对象
reminder remindable 引用提醒的对象
revisit_log loggable 跟进记录关联对象
sales_activities saleable 销售动态关联对象
sales_circle working 销售圈对应的工作类型

所有使用多态的model 在提交参数或者服务端 响应的时候, 均会派生出两个参数 ${#{field_name}_id} 和 ${#{field_name}_type}

如果 字段名叫 addressable 则会有 ${addressable_id} 和 ${addressable_type}

例如 提交表单中

# json 数据
revisit_log: {loggable_id: 2, loggable_type: "Customer"}
# form encode
revisit_log[loggable_id]=2&revisit_log[loggable_type]=Customer

例如 返回数据中

revisit_log: loggable: {name: "wangdaye"}, loggable_id: 2, loggable_type: "Customer"

使用多态的具体模块

Notification#subject_type
Announcement
Checkin
Contact
Contract
Customer
Event
Lead
Opportunity
ReceivedPayment
ReceivedPaymentPlan
RevisitLog
SalesActivity
ScheduleReport::Daily
ScheduleReport::Monthly
ScheduleReport::Weekly
Task
UpgradeNotice
RevisitLog#loggable_type
Contract
Customer
Lead
Opportunity
SalesActivity#saleable_type
Checkin
Lead
Customer
RevisitLog
ScheduleReport::Daily
ReceivedPayment
ScheduleReport::Weekly
ScheduleReport::Monthly
Contract
Contact
Opportunity
Task
DataReportContent
Attachment
  • At

At

atable

RevisitLog
SalesCircle
  • Like

Like

likeable

SalesCircle

Address模型(地址信息)

字段名 解释
tel 电话
phone 手机
email 邮箱
fax 传真
wechat 微信
wangwang 旺旺
zip 邮编
url 网址
detail_address 详细地址

Announcement模型(系统公告)

字段名 解释
title 公告名称
visible_category 可见范围
content 公告内容
read_count 阅读次数
created_at 创建时间
updated_at 更新于

Attachment模型(文件附件)

字段名 解释
id 文件附件ID
name 文件附件名称
file_file_name 文件名
file_content_type 文件类型
file_file_size 文件大小
file_updated_at 文件上传时间
deleted_at 删除时间

Contact模型(联系人)

字段名 解释
name 联系人姓名
department 部门
job 职务
created_at 创建时间
updated_at 更新于
gender 性别
category 联系人角色
deleted_at 删除于
note 备注

ContactAssetship模型(联系人)

字段名 解释
created_at 创建时间
updated_at 更新于
category 联系人角色

Contract模型(合同)

字段名 解释
id 合同ID
category 合同分类
payment_type 付款方式
status 合同状态
created_at 创建时间
updated_at 更新于
deleted_at 删除于
title 合同标题
total_amount 合同总金额
start_at 开始时间
end_at 结束时间
customer_signer 客户签约人
our_signer 我方签约人
special_terms 特别条款
sn 合同编号
approve_status 审批状态

CustomField模型(自定义字段)

字段名 解释
name 字段名
label 字段名称
field_type 字段属性
category 是否常用
created_at 创建时间
updated_at 更新于

CustomReport模型(自定义报表)

字段名 解释
name 报表名称
source 数据来源
description 报表描述
custom_columns 字段

Customer模型(客户)

字段名 解释
name 客户名称
category 客户类型
source 客户来源
industry 所属行业
staff_size 人员规模
note 备注
created_at 创建时间
updated_at 更新于
status 跟进状态

CustomerCommon模型(公海客户)

字段名 解释
name 客户名称
category 客户类型
source 客户来源
industry 所属行业
staff_size 人员规模
note 备注
created_at 创建时间
updated_at 更新于
status 跟进状态
flow_into_at 流入时间

DataReport模型(数据上报模板)

字段名 解释
name 名称

DataReportArea模型(地区节点)

字段名 解释
name 名称

DataReportStore模型(公司)

字段名 解释
name 名称

Department模型(部门)

字段名 解释
name 部门名称

Event模型(日程)

字段名 解释
title 日程内容
start_at 开始时间
due_at 结束时间
note 备注
deleted_at 删除于
created_at 创建时间
updated_at 更新于

Faq模型(常见问题)

字段名 解释
created_at 创建时间
updated_at 更新于
category 分类

FaqCategory模型(常见问题)

字段名 解释

FieldValue模型(数据字典参数)

字段名 解释
field_map_id 数据字典
name 参数名称
value 参数值
status 状态
created_at 创建时间
updated_at 更新于

InvoicedPayment模型(开票)

字段名 解释
contract_id 合同
user_id 用户
invoice_types 票据类型
amount 开票金额
note 备注
invoiced_date 开票日期
invoice_no 发票号码
content 票据内容
broker_user_id 经手人
created_at 创建时间
updated_at 更新时间

KnowledgeEntity模型(知识库文件)

字段名 解释
name 名称
download_count 下载次数
created_at 创建时间
updated_at 更新于
deleted_at 删除于

KnowledgeSection模型(版块)

字段名 解释
name 名称

Lead模型(线索)

字段名 解释
name 姓名
company_name 公司名称
source 线索来源
department 部门
job 职务
note 备注
created_at 创建时间
updated_at 更新于
deleted_at 删除于
status 跟进状态
turned_at 转客户时间

LoginLog模型(登录日志)

字段名 解释

ManualCategory模型(操作类别)

字段名 解释

Marking模型(点评)

字段名 解释

Notification模型(通知)

字段名 解释
notify_type 类别
status 状态
title 标题
created_at 创建时间
updated_at 更新于

OperationLog模型(操作日志)

字段名 解释
user_id 操作人员 ID
organization_id 公司 ID
loggable_id 操作对象
loggable_type 操作对象类型
action 操作类型
created_at 创建时间
updated_at 更新于
operation_changes 操作内容
operate_no 操作编号
trans_no 流水编号
trans_module 所属模块
field_name 字段名
old_val 旧字段值
val 新字段值
note 备注

Opportunity模型(商机)

字段名 解释
id 商机ID
created_at 创建时间
updated_at 更新于
title 商机标题
get_time 商机获取日期
provider 提供人
customer_requirement 客户需求
expect_sign_date 预计签单日期
expect_amount 预计金额
sign_possibility 签单可能性
note 备注
deleted_at 删除于
kind 商机类型
source 商机来源
stage 销售阶段

Organization模型(公司)

字段名 解释
name 公司名称
created_at 创建时间
updated_at 更新于

Product模型(产品)

字段名 解释

ProductAsset模型(关联产品)

字段名 解释
quantity 数量
standard_unit_price 产品原价
recommended_unit_price 建议价格
remark 备注

ReceivedPayment模型(回款)

字段名 解释
contract_id 合同
payment_type 付款方式
amount 回款金额
note 备注
created_at 创建时间
updated_at 更新时间
user_id 用户
receive_date 回款日期
invoice_status 是否开票
receive_user_id 收款人
received_types 回款类型
receive_stage 期数
invoice_amount 开票金额
approve_status 审批状态

ReceivedPaymentPlan模型(回款计划)

字段名 解释
contract_id 合同
receive_stage 期数
receive_date 回款日期
amount 回款金额
invoice_amount 开票金额
received_amount 已回款金额
receive_user_id 收款人
received_types 回款类型
payment_type 付款方式
note 备注
created_at 创建时间
updated_at 更新时间

RevisitLog模型(跟进记录)

字段名 解释
category 跟进类型

Role模型(角色)

字段名 解释
name 角色名称
entity_grant_scope 数据权限

SalesGoalYearly模型(业绩目标)

字段名 解释
goal_amount 总金额
quarter_1_amount 第一季度金额
quarter_2_amount 第二季度金额
quarter_3_amount 第三季度金额
quarter_4_amount 第四季度金额
month_1_amount 1月份金额
month_2_amount 2月份金额
month_3_amount 2月份金额
month_4_amount 2月份金额
month_5_amount 5月份金额
month_6_amount 6月份金额
month_7_amount 7月份金额
month_8_amount 8月份金额
month_9_amount 9月份金额
month_10_amount 10月份金额
month_11_amount 11月份金额
month_12_amount 12月份金额
文档更新时间: 2026-10-21 11:28   作者:明志朋