NAV
4077745864 870-309-5457

介绍

本文档是ikcrm_api项目的RESTful接口文档

注意:登录成功后,可以在请求参数中携带身份验证信息(即在请求参数中传access_token、user_token、version_code、device),也可以将身份信息放到请求头的Authorization里,即在每个请求头中都加入如下参数:

Authorization: Token token="{{user_token}}",version_code="{{version_code}}",device="{{device}}"

全局参数

API 统一返回的格式:

正确结果:


   { "code": 0, "data": {} }

错误结果:


   { "code": 10000, "message": "" }

全局输入参数说明

字段名 是否必填 描述
user_token true 必须要有的(除了登陆接口)
version_code true 必须要有的
device true 设备类型(ios, android)

全局返回参数说明

字段名 数据类型 描述
code int 返回代码,0 表示返回结果正常,其它值表示出错
message string 错误消息(当code不为0时,返回该字段)
data json 实际数据(当code为0时,返回该字段)
total_count int 数据总条数(非当前结果集条数,data字段中的值)
per_page int 每页的数量(data字段中的值)
page int 页码(data字段中的值)

(347) 612-2934.

时间传入统一格式

all, today, yestoday, tomorrow, week, month, quarter, year,

prev_week, prev_month, prev_quarter, prev_year,

next_week, next_month, next_quarter, next_year,

custom_week, custom_month, custom_quarter, custom_year,

other

other 的时候, 需要传入 start_date, end_date

custom_* 的时候需要传入 start_date

其他则不需要传入 start_date, end_date

释义:

[
  {label: '全部', name: 'all'},
  {label: '今天', name: 'today'},
  {label: '昨天', name: 'yestoday'},
  {label: '明天', name: 'tomorrow'},
  {label: '本周', name: 'week'},
  {label: '本月', name: 'month'},
  {label: '本季度', name: 'quarter'},
  {label: '今年', name: 'year'},
  {label: '上周', name: 'prev_week'},
  {label: '上月', name: 'prev_month'},
  {label: '上季度', name: 'prev_quarter'},
  {label: '去年', name: 'prev_year'},
  {label: '自定义年', name: 'custom_year'},
  {label: '自定义季度', name: 'custom_quarter'},
  {label: '自定义月', name: 'custom_month'},
  {label: '自定义周', name: 'custom_week'},
  {label: '自定义', name: 'other'}
]

A登陆模块接口

登录3.0版本

HTTP Request

POST /api/v2/auth/login

URL Parameters

字段名 是否必填 描述
access_token true 必须要有的
version_code true 必须要有的
login true 用户名
password true 密码

返回数据:

{
  "code": 0,
  "data": {
    "user_id": 1,
    "avatar_url": "头像url",
    "user_token": "f3f58e2e70b91034b9070d6a6116a43c",
    "is_expired": false, / (是否过期)
    "confirmed_phone": false,/ 手机认证
    "set_password": false, / 设置密码
    "fill_user_info": false / 用户信息
  }
}

退出登录

HTTP Request

POST /api/v2/auth/logout

返回数据:

{
  "code": 0,
  "data": {}
}

A公告模块

公告列表

HTTP Request

GET /api/v2/announcements

URL Parameters

字段名 是否必填 描述
page false 页码
per_page false 每页的数量
query false 查询

示例: /ikstaging.api.ikcrm.com/api/v2/announcements?version_code=2.4.0&user_token=50514a621d1ca98aa4bc363b4b04d54b& access_token=25efd0968dad94a3151fe0426af00013fb735f92c2affa766c594537c81947e79fe340e201207a6eae9402

返回数据


{
    "code": 0,
    "data": {
    "announcements": [
        {
            "id": 102,
            "title": "test@qq",
            "content": "这是content",
            "user": {
                "id": 682,
                "email": "251552116@qq.com",
                "created_at": "2014-12-09T18:43:06.000+08:00",
                "updated_at": "2015-09-17T19:50:05.000+08:00",
                "name": "曾琪-staging",
                "organization_id": 190,
                "phone": "18608833101",
                "role_id": null,
                "otp_secret_key": "psqzkth3d3m3l46m",
                "workflow_state": "organization_owner",
                "job": "总经理",
                "tel": "",
                "gender": "male",
                "confirmed_phone_at": "2015-09-17T19:50:05.000+08:00",
                "pending_report": true,
                "superior_id": null,
                "password_set_at": "2015-05-12T10:16:00.000+08:00",
                "otp_secret_counter": 11,
                "deleted_at": null,
                "role": "超级管理员",
                "department_name": "总裁办",
                "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/2245/header.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
                "departments_manager": true,
                "organization_name": "爱客CRM",
                "superior_name": null,
                "is_super_user": true
            },
            "attachment":[
                {"id": 9465,
                "name": "技术笔记.img",
                "attachmentable_id": 5292,
                "attachmentable_type": "ScheduleReport::Daily",
                "created_at": "2015-09-19T21:36:05.000+08:00",
                "updated_at": "2015-09-19T21:36:07.000+08:00",
                "file_file_name": "技术笔记.txt",
                "file_content_type": "text/plain",
                "file_file_size": 83,
                "file_updated_at": "2015-09-19T21:36:05.000+08:00",
                "user_id": 3386,
                "organization_id": 190,
                "deleted_at": null,
                "note": null,
                "sub_type": "summary",
                "attachment_position": null,
                "qiniu_persistent_id": null,
                "file_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/9465/%E6%8A%80%E6%9C%AF%E7%AC%94%E8%AE%B0.txt"
                }
            ],
            "created_at":"2015-01-20 14:40",
            "read": true
            }
        ],
        "total_count": 1,
        "per_page": 15,
        "page": 1
    }

}

公告详情

HTTP Request

GET /api/v2/announcements/:id

URL Parameters

字段名 是否必填 描述
id true url的 :id 替换成 公告id即可

返回数据

{

    "code": 0,
    "data": {
        "id": 102,
        "title": "test@qq",
        "content": "<正常添加一条线索,且鼠标放在跟进记录一栏时,会弹出新建记录的按钮,点击添加,正常添加一条跟进记录!",
        "user": {
            "id": 682,
            "email": "251552116@qq.com",
            "created_at": "2014-12-09T18:43:06.000+08:00",
            "updated_at": "2015-09-17T19:50:05.000+08:00",
            "name": "曾琪-staging",
            "organization_id": 190,
            "phone": "18608833101",
            "role_id": null,
            "otp_secret_key": "psqzkth3d3m3l46m",
            "workflow_state": "organization_owner",
            "job": "总经理",
            "tel": "",
            "gender": "male",
            "confirmed_phone_at": "2015-09-17T19:50:05.000+08:00",
            "pending_report": true,
            "superior_id": null,
            "password_set_at": "2015-05-12T10:16:00.000+08:00",
            "otp_secret_counter": 11,
            "deleted_at": null,
            "role": "超级管理员",
            "department_name": "总裁办",
            "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/2245/header.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
            "departments_manager": true,
            "organization_name": "爱客CRM",
            "superior_name": null,
            "is_super_user": true
        },
        "attachment":[
            {"id": 9465,
            "name": "技术笔记.img",
            "attachmentable_id": 5292,
            "attachmentable_type": "ScheduleReport::Daily",
            "created_at": "2015-09-19T21:36:05.000+08:00",
            "updated_at": "2015-09-19T21:36:07.000+08:00",
            "file_file_name": "技术笔记.txt",
            "file_content_type": "text/plain",
            "file_file_size": 83,
            "file_updated_at": "2015-09-19T21:36:05.000+08:00",
            "user_id": 3386,
            "organization_id": 190,
            "deleted_at": null,
            "note": null,
            "sub_type": "summary",
            "attachment_position": null,
            "qiniu_persistent_id": null,
            "file_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/9465/%E6%8A%80%E6%9C%AF%E7%AC%94%E8%AE%B0.txt"
            }
        ],
        "created_at": "2015-01-20 14:40",
        "read": true
    }

}

新增公告

HTTP Request

POST /api/v2/announcements

URL Parameters

字段名 是否必填 描述
attachment_ids false 图片id
announcement[title] false 公告标题
announcement[content] false 公告内容
announcement[visible_category] false 值in [all departments],然后departments则需要传入 visible_ids
announcement[visible_ids] false 公告内容

返回数据

{

    "code": 0,
    "data": {
        "id": 102,
        "title": "test@qq",
        "content": "<正常添加一条线索,且鼠标放在跟进记录一栏时,会弹出新建记录的按钮,点击添加,正常添加一条跟进记录!",
        "user": {
            "id": 682,
            "email": "251552116@qq.com",
            "created_at": "2014-12-09T18:43:06.000+08:00",
            "updated_at": "2015-09-17T19:50:05.000+08:00",
            "name": "曾琪-staging",
            "organization_id": 190,
            "phone": "18608833101",
            "role_id": null,
            "otp_secret_key": "psqzkth3d3m3l46m",
            "workflow_state": "organization_owner",
            "job": "总经理",
            "tel": "",
            "gender": "male",
            "confirmed_phone_at": "2015-09-17T19:50:05.000+08:00",
            "pending_report": true,
            "superior_id": null,
            "password_set_at": "2015-05-12T10:16:00.000+08:00",
            "otp_secret_counter": 11,
            "deleted_at": null,
            "role": "超级管理员",
            "department_name": "总裁办",
            "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/2245/header.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
            "departments_manager": true,
            "organization_name": "爱客CRM",
            "superior_name": null,
            "is_super_user": true
        },
        "attachment":[
            {"id": 9465,
            "name": "技术笔记.img",
            "attachmentable_id": 5292,
            "attachmentable_type": "ScheduleReport::Daily",
            "created_at": "2015-09-19T21:36:05.000+08:00",
            "updated_at": "2015-09-19T21:36:07.000+08:00",
            "file_file_name": "技术笔记.txt",
            "file_content_type": "text/plain",
            "file_file_size": 83,
            "file_updated_at": "2015-09-19T21:36:05.000+08:00",
            "user_id": 3386,
            "organization_id": 190,
            "deleted_at": null,
            "note": null,
            "sub_type": "summary",
            "attachment_position": null,
            "qiniu_persistent_id": null,
            "file_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/9465/%E6%8A%80%E6%9C%AF%E7%AC%94%E8%AE%B0.txt"
            }
        ],
        "created_at": "2015-01-20 14:40",
        "read": true
    }

}

删除公告

HTTP Request

DELETE /api/v2/announcements/:id

URL Parameters

字段名 是否必填 描述
id true 公告id,替换url的:id

返回数据

{
    "code": 0
}

A审批中心

待审批列表页

HTTP Request

GET /api/v2/approval_centers/applying

URL Parameters

字段名 是否必填 描述
page false 页码
per_page false 每页的数量
applying_type false 单独的某类审批[‘contract’, 'received_payment’],不传就是全部

Response data

返回数据applyings中的字段说明

字段名 描述
title 提交了合同审批或回款审批请求
applied_at 提交审批请求的时间
approvable_type 提交审批对象的类型,Contract为合同,ReceivedPayment为回款
approvable_id 和approvable_type对应,表示合同id或回款id
extra 扩展字段,当approvable_type为ReceivedPayment时,extra包含contract_id字段

返回数据

{
  "code": 0,
  "data": {
    "applyings": [{
      "title": "ifool提交了合同回款审批请求",
      "applied_at": "2015-09-12 16:00",
      "approvable_type": "ReceivedPayment",
      "approvable_id": 620,
      "extra":{"contract_id":1,"contract_title":"签约麦德龙"}
    }, {
      "title": "ifool提交了合同审批请求",
      "applied_at": "2015-07-29 19:00",
      "approvable_type": "Contract",
      "approvable_id": 1997,
      "extra":{}
    }],
    "total_count": 2,
    "per_page": 15,
    "page": 1
  }
}

已审批列表页

HTTP Request

PUT /api/v2/approval_centers/approvals

URL Parameters

字段名 是否必填 描述
page false 页码
per_page false 每页的数量
applying_type false 单独的某类审批['contract’, 'received_payment’],不传就是全部

Response data

返回数据approvals中的字段说明

字段名 描述
title 已审批的合同或回款的标题
approved_at 审批通过的时间
approvable_type 审批对象的类型,Contract表示合同审批,ReceivedPayment表示回款审批
approvable_id 和approvable_type对应,表示合同id或回款id
approve_status 审批状态,已否决 或 已通过
extra 扩展字段,当approvable_type为ReceivedPayment时,extra包含contract_id字段

返回数据

{
  "code": 0,
  "data": {
    "approvals": [{
      "title": "有产品的合同1期(2015-10-16)",
      "approved_at": "2015-10-16 14:31",
      "approvable_type": "ReceivedPayment",
      "approvable_id": 621,
      "approve_status": "已否决",
      "extra":{"contract_id":1,"contract_title":"签约麦德龙"}
    }, {
      "title": "有产品的合同",
      "approved_at": "2015-10-16 14:09",
      "approvable_type": "Contract",
      "approvable_id": 2023,
      "approve_status": "已通过",
      "extra":{}
    }],
    "total_count": 2,
    "per_page": 15,
    "page": 1
  }
}

A客户、合同、报销单审批

审批通过接口

HTTP Request

PUT /api/v2/approvals/:id/approve

URL Parameters

字段名 是否必填 描述
key true 审批的类型,customer为客户审批,contract为合同审批,expense_account为报销单审批
id true key为customer,id为客户id,key为contract,id为合同id
key为customer
customer[step] true 当前客户审批的层级(need_approve_step)
customer[approve_description] false 客户审批通过原因
customer[notify_user_ids] false 客户提醒他人用户id集合
key为contract
contract[step] true 当前合同审批的层级(need_approve_step)
contract[approve_description] false 合同审批通过原因
contract[notify_user_ids] false 合同提醒他人用户id集合
key为expense_account
expense_account[step] true 当前报销单审批的层级(need_approve_step)
expense_account[approve_description] false 报销单审批通过原因
expense_account[notify_user_ids] false 报销单提醒他人用户id集合

返回数据

{
  "code": 0,
  "data": {
    "customer": {
      id: 1
    }
  }
}

审批否决、驳回接口

HTTP Request

PUT /api/v2/approvals/:id/deny

URL Parameters

字段名 是否必填 描述
key true 审批的类型,customer为客户审批,contract为合同审批,expense_account为报销单审批
id true key为customer,id为客户id,key为contract,id为合同id,key为expense_account,id为报销单id
key为customer
customer[step] false 驳回时step为空,否决时step必填,step代表当前需要否决的层级(need_approve_step)
customer[approve_description] true 否决或驳回原因
key为contract
contract[step] false 驳回时step为空,否决时step必填,step代表当前需要否决的层级(need_approve_step)
contract[approve_description] true 否决或驳回原因
key为expense_account
expense_account[step] false 驳回时step为空,否决时step必填,step代表当前需要否决的层级(need_approve_step)
expense_account[approve_description] true 否决或驳回原因

返回数据

{
  "code": 0,
  "data": {
    "customer": {
      id: 1
    }
  }
}

审批撤销接口

HTTP Request

PUT /api/v2/approvals/:id/revert

URL Parameters

字段名 是否必填 描述
key true 审批的类型,customer为客户审批,contract为合同审批
id true key为customer,id为客户id,key为contract,id为合同id
key为customer
customer[approve_description] true 撤销原因
key为contract
contract[approve_description] true 撤销原因

返回数据

{
  "code": 0,
  "data": {
    "customer": {
      id: 1
    }
  }
}

更新提醒他人

HTTP Request

PUT /api/v2/approvals/:id/update_notify_users

URL Parameters

字段名 是否必填 描述
key true 审批的类型,customer为客户审批,contract为合同审批
id true key为customer,id为客户id,key为contract,id为合同id
key为customer
contract[notify_user_ids] true 用户id集合,数据类型为Array
key为contract
contract[notify_user_ids] true 用户id集合,数据类型为Array

返回数据

{
  "code": 0,
  "data": {
    "notify_users": [
      {id: 1, name: '1'},
      {id: 2, name: '2'}
    ]
  }
}

审批流程详细信息

HTTP Request

GET /api/v2/approvals/:id/approves

URL Parameters

字段名 是否必填 描述
key true 审批的类型,customer为客户审批,contract为合同审批
id true key为customer,id为客户id,key为contract,id为合同id

返回数据字段说明(data)

字段名 描述
approve_status 合同当前状态
notify_users 提醒他人用户信息
step 合同当前层级
submit_applying_at 合同提交时间
user 合同提交人
approves 多级审批所有步骤信息集合

data[approves]字段具体说明

字段名 描述
i代表数组索引
data[approves][i][step] 审批的层级
data[approves][i][type] 类型:
{
    superior: 负责人主管
    specified: 指定用户(任意一人)
    specified_jointly: 指定用户(多人会签)
    previous_superior: 上一级审批人主管
}
data[approves][i][approve_users] 层级允许审批的用户
data[approves][i][approves] 层级已经审批过的具体信息:
{
    user_name: 审批用户名称
    approve_at: 审批时间
}
data[approves][i][status] 审批状态:
{
    applying: 待审批
    approved: 审批通过
}

返回数据

{
  "code": 0
  "data": {
    "id": 1,
    "approve_status": "applying",
    "notify_users": [{id: 1, email: ''}],
    "step": 0,
    "submit_applying_at": "2016-11-29 09:37",
    "user": {id: 1, name: 'xxx'},
    "approves": [
      {
        "step": 1,
        "type": "specified",
        "approve_users": [
          {id: 1, name: 'xxx'}
        ],
        "approves": [
          {
            "id": 115,
            "user_id": 1,
            "step": 1,
            "status": "approved",
            "approve_at": "2017-04-12 15:59",
            "content": "ddd",
            "user_name": "lra"
          }
        ],
        "approve_at": "2017-04-12 15:59",
        "status": "applying"
        "user": {id: 1, email: ""}
        "user_id": 1
      }
    ]
  }
}

A附件相关

列表页

HTTP Request

GET /api/v2/attachments

URL Parameters

字段名 是否必填 描述
page false 页码
per_page false 每页的数量
attachmentable_id false 实体id
attachmentable_type false 实体(schedule_report, customer, opportunity, contract, product)
sub_type false 类型

返回数据


{
  "code": 0,
  "data": {
    "attachments": [
      {
        "id": 14,
        "file_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/14/change_positoin2_2015-05-06_12_33_10.png",
        "name": "change_positoin2_2015-05-06_12_33_10.png",
        "file_file_name": "change_positoin2_2015-05-06_12_33_10.png",
        "file_content_type": "application/octet-stream",
        "file_file_size": 254843,
        "attachmentable_id": 12,
        "attachmentable_type": "Product"
      },
    ],
    "total_count": 1,
    "per_page": 15,
    "page": 1
  }
}

给实体传附件

HTTP Request

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

URL Parameters

字段名 是否必填 描述
entity true 实体名(customer,contact,contract,lead,opportunity,product等)
id true 实体id
attachment_ids[] true 上传附件id数组
sub_type true 附件类型(customer为"“)

返回数据


{
  "code": 0
}

删除实体附件

HTTP Request

Delete /api/v2/attachments/:id/destroy_attachment

URL Parameters

字段名 是否必填 描述
id true 附件id 替换url的 :id
entity_type true 实体名(customer,contact,contract,lead,opportunity,product等)
entity_id true 实体id

返回数据


{
  "code": 0
}

附件详情

HTTP Request

GET /api/v2/attachments/:id(.:format)

URL Parameters

字段名 是否必填 描述
id true 替换url中的 :id

返回数据


{
  "code": 0,
  "data": {
    "attachment": {
      "id": 2,
      "file_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/2/crafty-min_%281%29.js",
      "name": "crafty-min_(1).js",
      "file_file_name": "crafty-min_(1).js",
      "file_content_type": "application/octet-stream",
      "file_file_size": 99174,
      "user": {
        "id": 1,
        "email": "test@qq.com",
        "created_at": "2015-06-09T15:46:06.000+08:00",
        "updated_at": "2015-10-21T09:32:38.000+08:00",
        "name": "default",
        "organization_id": 1,
        "phone": null,
        "role_id": null,
        "otp_secret_key": "6ilunxhadujri6ne",
        "workflow_state": "new",
        "job": "Shgsg",
        "tel": null,
        "gender": "male",
        "confirmed_phone_at": null,
        "pending_report": false,
        "superior_id": null,
        "password_set_at": "2015-06-09T15:47:18.000+08:00",
        "otp_secret_counter": 1,
        "deleted_at": null,
        "role": "超级管理员",
        "department_name": "总裁办",
        "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/30/avatar.?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
        "departments_manager": true,
        "organization_name": "王国平有限公司",
        "superior_name": null,
        "is_super_user": true
      },
      "attachmentable_id": 21,
      "attachmentable_type": "DataReportContent",
      "upload_time": "2015-07-31 15:46"
    }
  }
}

Resource url生成附件

HTTP Request

POST /api/v2/attachments/create_for_url

URL Parameters

字段名 是否必填 描述
resource_url true 资源文件的url
file_name false 文件名称
file_type false 文件类型

返回数据


{
  "code": 0,
  "data": {
    "attachment": {
      "id": 2,
      "file_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/2/crafty-min_%281%29.js",
      "name": "crafty-min_(1).js",
      "file_file_name": "crafty-min_(1).js",
      "file_content_type": "application/octet-stream",
      "file_file_size": 99174,
      "user": {
        "id": 1,
        "email": "test@qq.com",
        "created_at": "2015-06-09T15:46:06.000+08:00",
        "updated_at": "2015-10-21T09:32:38.000+08:00",
        "name": "default",
        "organization_id": 1,
        "phone": null,
        "role_id": null,
        "otp_secret_key": "6ilunxhadujri6ne",
        "workflow_state": "new",
        "job": "Shgsg",
        "tel": null,
        "gender": "male",
        "confirmed_phone_at": null,
        "pending_report": false,
        "superior_id": null,
        "password_set_at": "2015-06-09T15:47:18.000+08:00",
        "otp_secret_counter": 1,
        "deleted_at": null,
        "role": "超级管理员",
        "department_name": "总裁办",
        "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/30/avatar.?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
        "departments_manager": true,
        "organization_name": "王国平有限公司",
        "superior_name": null,
        "is_super_user": true
      },
      "attachmentable_id": 21,
      "attachmentable_type": "DataReportContent",
      "upload_time": "2015-07-31 15:46"
    }
  }
}

下载微信附件

HTTP Request

Post /api/v2/attachments/create_from_wx

URL Parameters

字段名 是否必填 描述
medias true [{id: “xxxxxxx”}]

返回数据

{
  "code": 0
  data: {
    attachments: [{
      id: "123",
      created_at: "2017-01-20 08:00:00"
    }]
  }
}

修改备注

HTTP Request

PUT /api/v2/attachments/:id

URL Parameters

字段名 是否必填 描述
id true 替换url中的 :id
attachment[note] false 备注

返回数据


{
  "code": 0
}

工商查询

工商查询query

HTTP Request

GET /api/v2/business_queries/query?key=上海

URL Parameters

字段名 是否必填 描述
key true 模糊匹配关键字
is_filter_subscription false 传 true, 没有的不要传,是否过滤已经订阅过的工商信息

返回数据:

{
    "code": "0",
    "msg": "查询成功",
    "data": [
        {
            "name": "上海铁路局"
            "entName": "上海铁路局"
        },
        {
            "name": "国网上海市电力公司"
            "entName": "国网上海市电力公司"
        }
    ]
}

工商查询验证

HTTP Request

GET /api/v2/business_queries/verify

URL Parameters

字段名 是否必填 描述
name true 公司名字

返回数据:

{
    "code": 0,
    "message": "success",
    "remark": "请求数据成功",
    "data": {
        "name": "重庆市测试网申审批内资二号个人独资公司",
        "legalname": "周一",
        "regno": "500105212877312",
        "esdate": "2016-03-31T00:00:00.000Z",
        "pid": "97a8550435ac9069f209179347e5f3df"
    }
}

获取工商查询显示页面

HTTP Request

GET /api/v2/business_queries/base_infoh5

URL Parameters

字段名 是否必填 描述
pid true verify 接口获取的pid

返回数据: text

获取事件显示页面

HTTP Request

GET /api/v2/business_queries/event_infoh5

URL Parameters

字段名 是否必填 描述
event_id true event_id

返回数据: text

风险信息订阅帐户

当前帐户

HTTP Request

GET /api/v2/business_query_accounts/current_account

URL Parameters

字段名 是否必填 描述

返回数据:


{
    "code": 0,
    "data": {
        "business_query_account": {
            "id": 26,
            "count": 0,
            "status": "actived",
            "cio_uid": "EDFD221B20F13AA408662E1C7FF339C0",
            "access_token": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1OWJmOGFhMDJlMzhiYzdmZTViNDBkOWQiLCJyb2xlIjoid3dqX21haW5hY2NvdW50Iiwic2VxdWVuY2UiOjI1Mywic3RhdHVzIjoxLCJkaXNhYmxlIjpmYWxzZSwiaWF0IjoxNTA3NTMyMTAxLCJleHAiOjE1MDc1NjA5MDF9.7uaS8rDGKQmAgWgQvEKrpOaafo59fUWY-eFIx1TvrnM",
            "access_token_expire_at": "2017-10-09 22:55",
            "user_token": "TL8toIRLNjn1TBP4utns4EdNhtjp08uSZcLdPRo4vsY="
        }
    }
}

B风险信息订阅接口

风险信息列表

HTTP Request

GET /api/v2/business_query_subscriptions/subscription

URL Parameters

字段名 是否必填 描述
query false 查询
cio_pid false cio_pid

返回数据


{
    "code": 0,
    "data": {
        "business_query_subscriptions": [
            {
                "id": 26,
                "customer_id": null,
                "cio_pid": "257f62ccee38db23c2709aeeca48bd68",
                "cio_company_name": "上海微问家信息技术有限公司",
                "expire_at": "2019-03-31 23:59",
                "is_renewal": true,
                "user": {
                    "id": 1,
                    "email": "test@qq.com",
                    "created_at": "2017-04-13 00:00",
                    "name": "test@qq.com",
                    "organization_id": 30,
                    "phone": "157214621171",
                    "role_id": 86,
                    "workflow_state": "organization_owner",
                    "job": "6666",
                    "tel": "021-45555555",
                    "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/14088/1.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
                    "department_name": "研发2部"
                },
                "status": "in_use",
                "status_i18n": "在使用",
                "month_unnormal_event_count": 0,
                "created_at": "2017-09-27 09:48",
                "updated_at": "2017-10-25 13:14"
            }
        ],
        "total_count": 1,
        "per_page": 10,
        "page": 0
    }
}


风险信息历史列表

HTTP Request

GET /api/v2/business_query_subscriptions/subscription_history

URL Parameters

字段名 是否必填 描述

返回数据


{
    "code": 0,
    "data": {
        "business_query_subscriptions": [
            {
                "id": 26,
                "customer_id": null,
                "cio_pid": "257f62ccee38db23c2709aeeca48bd68",
                "cio_company_name": "上海微问家信息技术有限公司",
                "expire_at": "2019-03-31 23:59",
                "is_renewal": true,
                "user": {
                    "id": 1,
                    "email": "test@qq.com",
                    "created_at": "2017-04-13 00:00",
                    "name": "test@qq.com",
                    "organization_id": 30,
                    "phone": "157214621171",
                    "role_id": 86,
                    "workflow_state": "organization_owner",
                    "job": "6666",
                    "tel": "021-45555555",
                    "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/14088/1.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
                    "department_name": "研发2部"
                },
                "status": "in_use",
                "status_i18n": "在使用",
                "month_unnormal_event_count": 0,
                "created_at": "2017-09-27 09:48",
                "updated_at": "2017-10-25 13:14"
            }
        ],
        "total_count": 1,
        "per_page": 10,
        "page": 0
    }
}


创建订阅

HTTP Request

POST /api/v2/business_query_subscriptions

URL Parameters

字段名 是否必填 描述
business_query_subscription[cio_company_name] true 公司名字
business_query_subscription[customer_id] true 关联客户
business_query_subscription[cio_pid] true pid
business_query_subscription[subscribers_attributes][][user_id] false user id
business_query_subscription[subscribers_attributes][][category] false (in_station, other) 订阅人传 other 的时候必须要有 user_id, 职位的传 in_station 的时候必须要有 own_type
business_query_subscription[subscribers_attributes][][own_type] false (user(用户), assist_users(协作人) , user_superior(用户主管), assist_superior (协作人主管))

返回数据


{
    "code": 0,
    "data": {
      "business_query_subscriptions":
        {
            "id": 26,
            "customer_id": null,
            "cio_pid": "257f62ccee38db23c2709aeeca48bd68",
            "cio_company_name": "上海微问家信息技术有限公司",
            "expire_at": "2019-03-31 23:59",
            "is_renewal": true,
            "user": {
                "id": 1,
                "email": "test@qq.com",
                "created_at": "2017-04-13 00:00",
                "name": "test@qq.com",
                "organization_id": 30,
                "phone": "157214621171",
                "role_id": 86,
                "workflow_state": "organization_owner",
                "job": "6666",
                "tel": "021-45555555",
                "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/14088/1.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
                "department_name": "研发2部"
            },
            "status": "in_use",
            "status_i18n": "在使用",
            "month_unnormal_event_count": 0,
            "created_at": "2017-09-27 09:48",
            "updated_at": "2017-10-25 13:14"
        }
    }
}

更新订阅

HTTP Request

PUT /api/v2/business_query_subscriptions/:id

URL Parameters

字段名 是否必填 描述
edit_type false edit_history, edit_history的的时候是编辑已经过期的历史纪录
business_query_subscription[cio_company_name] true 公司名字
business_query_subscription[customer_id] true 关联客户
business_query_subscription[cio_pid] true pid
business_query_subscription[subscribers_attributes][][user_id] false user id
business_query_subscription[subscribers_attributes][][category] false (in_station, other) 订阅人传 other 的时候必须要有 user_id, 职位的传 in_station 的时候必须要有 own_type
business_query_subscription[subscribers_attributes][][own_type] false (user(用户), assist_users(协作人) , user_superior(用户主管), assist_superior (协作人主管))
business_query_subscription[subscribers_attributes][][_destroy] false 值为1, 删除标示, 传这个参数的时候改计划就会被删除, 不删除就不要传
business_query_subscription[subscriber_ids] false 删除的时候也可以使用这个, 只需要传 id 的数组

返回数据


{
    "code": 0,
    "data": {
      "business_query_subscriptions":
        {
            "id": 26,
            "customer_id": null,
            "cio_pid": "257f62ccee38db23c2709aeeca48bd68",
            "cio_company_name": "上海微问家信息技术有限公司",
            "expire_at": "2019-03-31 23:59",
            "is_renewal": true,
            "user": {
                "id": 1,
                "email": "test@qq.com",
                "created_at": "2017-04-13 00:00",
                "name": "test@qq.com",
                "organization_id": 30,
                "phone": "157214621171",
                "role_id": 86,
                "workflow_state": "organization_owner",
                "job": "6666",
                "tel": "021-45555555",
                "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/14088/1.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
                "department_name": "研发2部"
            },
            "status": "in_use",
            "status_i18n": "在使用",
            "month_unnormal_event_count": 0,
            "created_at": "2017-09-27 09:48",
            "updated_at": "2017-10-25 13:14"
        }
    }
}

获取订阅详情

HTTP Request

GET /api/v2/business_query_subscriptions/:id

URL Parameters

字段名 是否必填 描述
id true ID

返回数据


{
  "code": 0,
  "data": {
      "business_query_order": {
        "id": 13,
        "organization_id": 30,
        "user_id": 1,
        "status": "unpaid",
        "amount": 1200,
        "count": 150,
        "risk_package_id": 5,
        "risk_package": {
            "id": 5,
            "name": "120送30套餐",
            "status": "active",
            "total_amount": 1200,
            "buy_count": 120,
            "give_count": 30,
            "total_count": 150,
            "buy_price": 10,
            "actual_price": 8
        },
        "order": {
            "id": 15,
            "amount": 1200,
            "subject": "购买风险信息",
            "body": "购买爱客CRM风险信息"
        },
        "dealt_at": "2017-11-07T17:38:52.000+08:00",
        "created_at": "2017-11-07 17:38",
        "updated_at": "2017-11-07 17:38"
      }
  }
}

取消订阅

HTTP Request

PUT /api/v2/business_query_subscriptions/:id/cancel

URL Parameters

字段名 是否必填 描述
id true ID

返回数据



{
    "code": 0,
    "data": {
      "business_query_subscriptions":
        {
            "id": 26,
            "customer_id": null,
            "cio_pid": "257f62ccee38db23c2709aeeca48bd68",
            "cio_company_name": "上海微问家信息技术有限公司",
            "expire_at": "2019-03-31 23:59",
            "is_renewal": true,
            "user": {
                "id": 1,
                "email": "test@qq.com",
                "created_at": "2017-04-13 00:00",
                "name": "test@qq.com",
                "organization_id": 30,
                "phone": "157214621171",
                "role_id": 86,
                "workflow_state": "organization_owner",
                "job": "6666",
                "tel": "021-45555555",
                "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/14088/1.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
                "department_name": "研发2部"
            },
            "status": "in_use",
            "status_i18n": "在使用",
            "month_unnormal_event_count": 0,
            "created_at": "2017-09-27 09:48",
            "updated_at": "2017-10-25 13:14"
        }
    }
}

风险信息消息

风险信息消息列表

HTTP Request

GET /api/v2/business_query_event_notifications

URL Parameters

字段名 是否必填 描述
event_group true [“industry_and_commerce_info”, “administrative_negative_info”, “litigation_risk_info”, “financial_financing_info”, “business_info”]
pid true 风险信息订阅cio_pid
is_read false false 的时候是未读

返回数据:


{
    "code": 0,
    "data": {
        "business_query_event_notifications": [
            {
                "id": 1,
                "pid": "257f62ccee38db23c2709aeeca48bd68",
                "event_name": "ddd",
                "event_content": "sdsds",
                "entname": "",
                "is_read": true,
                "created_at": "2017-11-05 19:25"
            },
            {
                "id": 2,
                "pid": "257f62ccee38db23c2709aeeca48bd68",
                "event_name": "sfasdf",
                "event_content": "aasdfs",
                "entname": "",
                "is_read": true,
                "created_at": "2017-11-05 19:25"
            }
        ],
        "total_count": 2,
        "unread_total_count": 1,
        "per_page": 10,
        "page": 0
    }
}

设置已读

HTTP Request

PUT /api/v2/business_query_event_notifications/mark_as_read

URL Parameters

字段名 是否必填 描述
ids true [] 或者 1,2,3 两种形式

返回数据:

{
    "code": 0
}

B风险信息订阅订单接口

风险信息订阅套餐列表

HTTP Request

GET /api/v2/business_query_orders/risk_packages

URL Parameters

字段名 是否必填 描述

返回数据

{
  "code": 0,
  "data": {
    "risk_packages": [
      {
          "id": 7,
          "name": "1分套餐",
          "status": "active",
          "total_amount": 0.01,
          "buy_count": 100,
          "give_count": 0,
          "total_count": 100,
          "buy_price": 0,
          "actual_price": 0
      }
    ]
  }
}

创建订单

HTTP Request

POST /api/v2/business_query_orders

URL Parameters

字段名 是否必填 描述
amount false 订单金额, 不填就为套餐金额
risk_package_id true 风险信息订阅套餐ID

返回数据


{
    "code": 0,
    "data": {
        "business_query_order": {
            "id": 14,
            "organization_id": 30,
            "user_id": 1,
            "status": "unpaid",
            "amount": 1200,
            "count": 150,
            "risk_package_id": 5,
            "risk_package": {
                "id": 5,
                "name": "120送30套餐",
                "status": "active",
                "total_amount": 1200,
                "buy_count": 120,
                "give_count": 30,
                "total_count": 150,
                "buy_price": 10,
                "actual_price": 8
            },
            "order": {
                "id": 16,
                "amount": 1200,
                "subject": "购买风险信息",
                "body": "购买爱客CRM风险信息"
            },
            "dealt_at": "2017-11-07T17:39:58.978+08:00",
            "created_at": "2017-11-07T17:39:58.982+08:00",
            "updated_at": "2017-11-07T17:39:58.982+08:00"
        }
    }
}

获取订单详情

HTTP Request

GET /api/v2/business_query_orders/:id

URL Parameters

字段名 是否必填 描述
id true 订单ID

返回数据


{
  "code": 0,
  "data": {
      "business_query_order": {
        "id": 13,
        "organization_id": 30,
        "user_id": 1,
        "status": "unpaid",
        "amount": 1200,
        "count": 150,
        "risk_package_id": 5,
        "risk_package": {
            "id": 5,
            "name": "120送30套餐",
            "status": "active",
            "total_amount": 1200,
            "buy_count": 120,
            "give_count": 30,
            "total_count": 150,
            "buy_price": 10,
            "actual_price": 8
        },
        "order": {
            "id": 15,
            "amount": 1200,
            "subject": "购买风险信息",
            "body": "购买爱客CRM风险信息"
        },
        "dealt_at": "2017-11-07T17:38:52.000+08:00",
        "created_at": "2017-11-07 17:38",
        "updated_at": "2017-11-07 17:38"
      }
  }
}

订单列表

HTTP Request

GET /api/v2/business_query_orders

URL Parameters

字段名 是否必填 描述

返回数据


{
    "code": 0,
    "data": {
        "business_query_orders": [
            {
                "id": 12,
                "organization_id": 30,
                "user": {
                    "id": 1,
                    "name": "test@qq.com"
                },
                "status": "unpaid",
                "status_i18n": "待支付",
                "amount": 0,
                "count": 100,
                "risk_package_id": 7,
                "risk_package": {
                    "id": 7,
                    "name": "1分套餐",
                    "status": "active",
                    "total_amount": 0.01,
                    "buy_count": 100,
                    "give_count": 0,
                    "total_count": 100,
                    "buy_price": 0,
                    "actual_price": 0
                },
                "order": {
                    "id": 14,
                    "amount": 0,
                    "subject": "购买风险信息",
                    "body": "购买爱客CRM风险信息"
                },
                "dealt_at": "2017-11-07 17:38",
                "created_at": "2017-11-07 17:38",
                "updated_at": "2017-11-07 17:38"
            }
        ],
        "total_count": 6,
        "per_page": 25,
        "page": 1
    }
}

更改订单

HTTP Request

GET /api/v2/business_query_orders/:id

URL Parameters

字段名 是否必填 描述
amount false 订单金额, 不填就为套餐金额
risk_package_id true 风险信息订阅套餐ID

返回数据


{
  "code": 0,
  "data": {
      "business_query_order": {
        "id": 13,
        "organization_id": 30,
        "user_id": 1,
        "status": "unpaid",
        "amount": 1200,
        "count": 150,
        "risk_package_id": 5,
        "risk_package": {
            "id": 5,
            "name": "120送30套餐",
            "status": "active",
            "total_amount": 1200,
            "buy_count": 120,
            "give_count": 30,
            "total_count": 150,
            "buy_price": 10,
            "actual_price": 8
        },
        "order": {
            "id": 15,
            "amount": 1200,
            "subject": "购买风险信息",
            "body": "购买爱客CRM风险信息"
        },
        "dealt_at": "2017-11-07T17:38:52.000+08:00",
        "created_at": "2017-11-07 17:38",
        "updated_at": "2017-11-07 17:38"
      }
  }
}


删除订单

HTTP Request

DELETE /api/v2/business_query_orders/:id

URL Parameters

字段名 是否必填 描述
id true 订单ID

返回数据


{
  "code": 0,
  "data": {
      "business_query_order": {
        "id": 13,
        "organization_id": 30,
        "user_id": 1,
        "status": "unpaid",
        "amount": 1200,
        "count": 150,
        "risk_package_id": 5,
        "risk_package": {
            "id": 5,
            "name": "120送30套餐",
            "status": "active",
            "total_amount": 1200,
            "buy_count": 120,
            "give_count": 30,
            "total_count": 150,
            "buy_price": 10,
            "actual_price": 8
        },
        "order": {
            "id": 15,
            "amount": 1200,
            "subject": "购买风险信息",
            "body": "购买爱客CRM风险信息"
        },
        "dealt_at": "2017-11-07T17:38:52.000+08:00",
        "created_at": "2017-11-07 17:38",
        "updated_at": "2017-11-07 17:38"
      }
  }
}


业务模版

获取当前企业全部业务模版(根据 is_usable 判断模版是否属于登录用户角色)

HTTP Request

GET /api/v2/business_templates

URL Parameters

字段名 是否必填 描述
entity_type true 类型 (customer, contract)

返回数据字段说明

字段名 描述
status 状态: 0,启用 ;1 禁用
is_usable true:当前模版是所属登录用户角色

返回数据:

{
    "code": 0,
    "data": {
        "business_templates": [
            {
                "id": 7,
                "name": "合同业务类型",
                "position": null,
                "status": 0,
                "is_usable": true
            },
            {
                "id": 8,
                "name": "合同模版测试02",
                "position": null,
                "status": 0,
                "is_usable": true
            }
        ],
        "total_count": 2,
        "per_page": 15,
        "page": 1
    }
}

获取所有业务模版列表

HTTP Request

GET /api/v2/business_templates/list

URL Parameters

字段名 是否必填 描述
entity_type true 类型 (customer, contract)

返回数据字段说明

字段名 描述
status 状态: 0,启用 ;1 禁用

返回数据:

{
    "code": 0,
    "data": {
        "business_templates": [
            {
                "id": 89,
                "name": "全公司模版",
                "position": 1,
                "roles": [
                    {
                        "role_id": 86,
                        "role_name": "总经理"
                    },
                    {
                        "role_id": 87,
                        "role_name": "部门经理"
                    },
                    {
                        "role_id": 88,
                        "role_name": "销售专员"
                    },
                    {
                        "role_id": 187,
                        "role_name": "fengfeng"
                    },
                    {
                        "role_id": 337,
                        "role_name": "超级管理员"
                    },
                    {
                        "role_id": 338,
                        "role_name": "普通管理员"
                    },
                    {
                        "role_id": 339,
                        "role_name": "普通用户"
                    },
                    {
                        "role_id": 1523,
                        "role_name": "普通管理员副本"
                    },
                    {
                        "role_id": 1570,
                        "role_name": "dsfdsf"
                    },
                    {
                        "role_id": 1769,
                        "role_name": "sssss"
                    }
                ],
                "status": 0
            }
        ],
        "total_count": 3,
        "per_page": 0,
        "page": 0
    }
}

没有用户模版, 请联系管理员

HTTP Request

GET /api/v2/business_templates/status

URL Parameters

字段名 是否必填 描述
entity_type true 类型 (customer, contract)

返回数据字段说明

字段名 描述
status true 的时候是: 业务启用了业务模版,但是改用户角色没有可用业务模版

返回数据:


{
    "code": 0,
    "data": {
        "has_open_business_template": false
    }
}


C呼叫中心

获取当前登陆用户坐席信息

HTTP Request

GET /api/v2/call_agents/current

返回数据字段说明

字段名 描述
app_id 呼叫中心登陆appId
login 呼叫中心登陆用户名
password 呼叫中心登陆密码
bind_tel 呼叫中心打电话主叫号码
call_display_number 呼叫中心打电话被叫端显示号码

返回数据:

{
  "code": 0,
  "data": {
    "app_id": "48f6687a558e42b8a44ac13213929801",
    "login": "67279062395749",
    "password": "40ed4689",
    "bind_tel": "13262902619",
    "call_display_number": "13262902619"
  }
}

获取通话记录

HTTP Request

GET /api/v2/call_records(.:format)

URL Parameters

字段名 是否必填 描述
recordable_type true 对象的类名,只能是[‘Lead’, 'Customer’, 'Contact’]其中一个
recordable_id true 对象id
page false 页码
per_page false 每页的数量

返回数据字段说明

字段名 描述
calling_mapped 主叫描述
called_mapped 被叫号码
call_type_mapped 呼叫类型描述(呼入、呼出)
status_mapped 接通状态(接通、未接通)
duration 通话时长(单位:秒)
duration_mapped 通话时长格式化
recordable 通话记录关联对象
recordable_type 通话记录关联对象类型
play_url 通话记录录音地址
created_at 通话记录创建时间

返回数据:

{
  "code": 0,
  "data": {
    "call_records": [
      {
        "id": 31,
        "calling_mapped": "lra",
        "called_mapped": "13262902617",
        "call_type_mapped": "呼出",
        "status_mapped": "接通",
        "duration": 111,
        "duration_mapped": "1分51秒",
        "recordable": "zhang",
        "recordable_type": "Lead",
        "play_url": null,
        "created_at": '2014-07-28 11:28'
      }
    ],
    "total_count": 1,
    "per_page": 0,
    "page": 0
  }
}

SDK呼出 创建通话记录

HTTP Request

POST /api/v2/call_records(.:format)

URL Parameters

字段名 是否必填 描述
call_record[call_id] true SDK呼出时的呼叫中心返回的call_id
call_record[recordable_type] true 通话记录关联对象类型,只能是['Lead’, 'Customer’, 'Contact’]其中一个
call_record[recordable_id] true 通话记录关联对象id

返回数据字段说明

字段名 描述
id 通话记录id
call_id SDK呼出时的呼叫中心返回的call_id
recordable_type 通话记录关联对象类型
recordable_id 通话记录关联对象id

返回数据:

{
  "code": 0,
  "data": {
    "id": 32,
    "call_id": "1111",
    "recordable_type": "Lead",
    "recordable_id": 211
  }
}

回拨(预览式外呼)

HTTP Request

POST /api/v2/call_centers/action(.:format)

URL Parameters

字段名 是否必填 描述
op true 固定为 'preview_call’
call_record[recordable_type] true 创建通话记录时关联对象的类型,只能是['Lead’, 'Customer’, 'Contact’]其中一个
call_record[recordable_id] true 创建通话记录时关联对象对象的id
data[calling_number] true 主叫号码
data[called_number] true 被叫号码
data[calling_display_number] true 主叫侧显示号码
data[called_display_number] true 被叫侧显示号码

返回数据字段说明

字段名 描述
call_id 预览式外呼发起成功后呼叫中心返回的call_id

返回数据:

{
  "code": 0,
  "data": {
    "call_id": "20160912162737290582-bc8b9e7e829dce81-out"
  }
}

挂断(预览式外呼)

HTTP Request

POST /api/v2/call_centers/action(.:format)

URL Parameters

字段名 是否必填 描述
op true 固定为 'hangup’
call_record[recordable_type] true 通话记录时关联对象的类型,只能是['Lead’, 'Customer’, 'Contact’]其中一个
call_record[recordable_id] true 通话记录时关联对象对象的id
data[call_id] true 预览式外呼发起成功后呼叫中心返回的call_id

返回数据字段说明

字段名 描述
call_id 预览式外呼发起成功后呼叫中心返回的call_id

返回数据:

{
  "code": 0,
  "data": {
    "call_id": "20160912162737290582-bc8b9e7e829dce81-out"
  }
}

L来电显示

判断手机号是否为客户/联系人/线索

HTTP Request

GET /api/v2/dial_logs/caller_id(.:format)

URL Parameters

参数名 是否必须 描述
phone 必须 手机号码(String)

返回数据

{
    "code": 0,
    "data": {
        "name": "Gerry"
    }
}

返回数据字段说明

返回值字段 字段类型 字段说明
code int 请求返回信息代码( 成功: 0)
name String 联系人/客户/线索名称,未查询到则传空字符串

获取1000条线索信息(由于按号码唯一标识拆分,接口获取到的数据不是1000条)

HTTP Request

GET /api/v2/leads/fetch_leads(.:format)

URL Parameters

参数名 是否必须 描述
page 必须 页码
timestamp 非必须 时间戳,筛选更新时间大于此时间戳的数据,如不传则筛选所有数据

返回数据

{
    "code": 0,
    "data": {
        "leads": [
            {
                "lead_id": 116,
                "name": "张三",
                "number": "13777777777"
            },
            {
                "lead_id": 116,
                "name": "张三",
                "number": "02114523652"
            },
            {
                "lead_id": 117,
                "name": "李四",
                "number": "13122221111"
            }
        ]
    }
}

返回数据字段说明

返回值字段 字段类型 字段说明
code int 请求返回信息代码( 成功: 0)
lead_id String 线索id
name String 线索名称
number String 线索手机或固话号码

获取1000条联系人信息(由于按号码唯一标识拆分,接口获取到的数据不是1000条)

HTTP Request

GET /api/v2/contacts/fetch_contacts(.:format)

URL Parameters

参数名 是否必须 描述
page 必须 页码
timestamp 非必须 时间戳,筛选更新时间大于此时间戳的数据,如不传则筛选所有数据

返回数据

{
    "code": 0,
    "data": {
        "contacts": [
            {
                "contact_id": 68,
                "name": "张三(京东)",
                "number": "13888888888"
            },
            {
                "contact_id": 68,
                "name": "张三(京东)",
                "number": "1234567"
            },
            {
                "contact_id": 78,
                "name": "李四",
                "number": "15702122152"
            }
        ]
    }
}

返回数据字段说明

返回值字段 字段类型 字段说明
code int 请求返回信息代码( 成功: 0)
contact_id String 联系人id
name String 联系人名称
number String 联系人手机或固话号码

获取1000条客户信息(由于按号码唯一标识拆分,接口获取到的数据不是1000条)

HTTP Request

GET /api/v2/customers/fetch_customers(.:format)

URL Parameters

参数名 是否必须 描述
page 必须 页码
timestamp 非必须 时间戳,筛选更新时间大于此时间戳的数据,如不传则筛选所有数据

返回数据

{
    "code": 0,
    "data": {
        "customers": [
            {
                "customer_id": 61,
                "name": "张三",
                "number": "13275853270"
            },
            {
                "customer_id": 75,
                "name": "李四",
                "number": "15132462214"
            },
            {
                "customer_id": 75,
                "name": "李四",
                "number": "02112345678"
            }
        ]
    }
}

返回数据字段说明

返回值字段 字段类型 字段说明
code int 请求返回信息代码( 成功: 0)
customer_id String 客户id
name String 客户名称
number String 客户手机或固话号码

D拨号记录

拨号记录创建

HTTP Request

POST /api/v2/dial_logs

URL Parameters

字段名 是否必填 描述
dial_log[caller_type] false 拨号的对象,(Customer, Lead, Contact)
dial_log[caller_id] false 拨号对象id, 如caller_type 为 Customer的时候,caller_id就是customer id
dial_log[name] false 拨号姓名
dial_log[number] false 拨号的号码
dial_log[number_type] false 拨号类型, 电话或者手机
audio_ids false 音频id

返回数据:

{
    "code": 0,
    "data": {
        "dial_log": {
            "id": 5,
            "caller_id": 11212,
            "caller_type": "Customer",
            "user_id": 1,
            "organization_id": 30,
            "number": "12121212",
            "created_at": "2017-08-08 10:37",
            "updated_at": "2017-08-08 10:37"
        }
    }
}

图片验证码接口

获取图片验证码

HTTP Request

GET /api/v2/captcha/fetch_captcha

URL Parameters

参数名 参数类型 是否必须 描述
phone String 必须 手机号码

返回数据

验证码图片

C名片扫描

日志采集

HTTP Request

Post /api/v2/cards/logger_collection

URL Parameters

字段名 是否必填 描述
types true in:[‘to_lead’, 'to_customer’]
msg true 内容

返回数据

{
  "code": 0
}

C拜访签到模块

全部列表页

HTTP Request

GET /api/v2/checkins

URL Parameters

字段名 是否必填 描述
page false 页码
per_page false 每页的数量
user_id false 用户id
checkable_type false checkable type(Customer, Opportunity)
checkable_id false checkable id
detail_address false 地址详情
date false [all, today, week, month, quarter, year, other]

返回数据

{
  "code": 0,
  "data": {
    "checkins": [
      {
        "id": 3081,
        "checkin_name": "吧咯",
        "created_at": "2015-09-09 20:20",
        "address": {
          "id": 56329,
          "country": {},
          "province": {},
          "city": {},
          "district": {},
          "tel": "",
          "phone": "",
          "email": "",
          "qq": "",
          "fax": "",
          "wechat": "",
          "wangwang": "",
          "zip": "",
          "url": "",
          "detail_address": "上海市市辖区亮秀路112号",
          "lat": 31.199272,
          "lng": 121.602854,
          "distance": "0m",
          "region_info": "",
          "off_distance": 0,
          "gaode_staticmap": "/restapi.amap.com/v3/staticmap?key=6336624d908c499cace3998613723a3a&location=121.602854%2C31.199272&markers=mid%2C%2CA%3A121.602854%2C31.199272&scale=2&size=262%2A90&zoom=15"
        },
        "attachments": [],
        "checkable": {
          "customer": {
            "id": 15232,
            "name": "吧咯",
            "status": "4021",
            "status_mapped": "成交",
            "note": "",
            "category": "4023",
            "category_mapped": "潜在客户",
            "source": "4028",
            "source_mapped": "电话来访",
            "industry": "4035",
            "industry_mapped": "服务业",
            "parent": {},
            "staff_size": 20878,
            "staff_size_display": "<10人",
            "staff_size_mapped": "<10人",
            "created_at": "2015-08-21 13:47",
            "updated_at": "2015-08-21 13:47",
            "is_own": true,
            "attachments": "暂无附件",
            "company_name": "",
            "text_asset_95310da7": null,
            "address": {
              "id": 51999,
              "country": {
                "id": 4,
                "name": "中国",
                "pinyin": ""
              },
              "province": {
                "id": 17,
                "name": "湖北",
                "pinyin": "hubei",
                "country_id": 4
              },
              "city": {
                "id": 169,
                "name": "武汉市",
                "pinyin": "wuhan",
                "province_id": 17
              },
              "district": {
                "id": 1513,
                "name": "江岸",
                "pinyin": null,
                "city_id": 169
              },
              "tel": "18851321976",
              "phone": "",
              "email": "",
              "qq": "",
              "fax": "",
              "wechat": "",
              "wangwang": "",
              "zip": "",
              "url": "",
              "detail_address": "",
              "lat": 0,
              "lng": 0,
              "distance": "0m",
              "region_info": "中国湖北武汉市江岸",
              "off_distance": 0,
              "gaode_staticmap": ""
            },
            "user": {
              "id": 699,
              "email": "2525@qq.com",
              "created_at": "2015-07-01T18:17:11.000+08:00",
              "name": "刘超-test环境",
              "organization_id": 57,
              "phone": "18851321975",
              "role_id": 0,
              "workflow_state": "organization_staff",
              "job": "安卓开发",
              "tel": "",
              "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/12303/aike_header.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
              "department_name": "总裁办"
            },
            "owned_department": {
              "id": 278,
              "name": "总裁办"
            }
          }
        }
      }
    ],
    "total_count": 278,
    "per_page": 1,
    "page": 1
  }
}

拜访签到详情

HTTP Request

GET /api/v2/checkins/:id(.:format)

URL Parameters

字段名 是否必填 描述
id true checkins 的 id 替换url的:id

返回数据


{
  "code": 0,
  "data": {
    "comments": [],
    "comments_count": 0,
    "id": 592,
    "lat": 0,
    "lng": 0,
    "message": "",
    "category": "",
    "category_display": "",
    "category_i18n": "",
    "created_at": "2015-07-29 17:26",
    "remind_at": "",
    "checkin_at": "",
    "sales_activity": {},
    "checkable_type": "Customer",
    "checkable": {
      "customer": {
        "id": 1,
        "name": "自定义字段",
        "name_pinyin": "zidingyiziduan",
        "user_id": 1,
        "user_name": "default",
        "contacts": [],
        "company_name": "",
        "address": {},
        "revisit_at": "2015-11-25T10:13:34.000+08:00",
        "is_own": true,
        "status": "7",
        "status_mapped": "初访",
        "category": "",
        "category_mapped": ""
      }
    },
    "user": {
      "id": 1,
      "email": "test@qq.com",
      "created_at": "2015-06-09T15:46:06.000+08:00",
      "name": "default",
      "organization_id": 1,
      "phone": "",
      "role_id": 0,
      "workflow_state": "new",
      "job": "Shgsg",
      "tel": "",
      "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/30/avatar.?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
      "department_name": "总裁办"
    },
    "attachments": [],
    "address": {
      "id": 1000,
      "country": {},
      "province": {},
      "city": {},
      "district": {},
      "tel": "010-65880961",
      "phone": "13888001181",
      "email": "zhaoning2@web.com",
      "qq": "88883272",
      "fax": "",
      "wechat": "weix961",
      "wangwang": "888822849",
      "zip": "100960",
      "url": "",
      "detail_address": "北京市朝阳区朝阳门外大街18号丰联广场A座第9层",
      "lat": 0,
      "lng": 0,
      "distance": "0m",
      "region_info": "",
      "off_distance": 0,
      "gaode_staticmap": ""
    }
  }
}

创建拜访签到

HTTP Request

POST /api/v2/checkins(.:format)

URL Parameters

字段名 是否必填 描述
checkin[lat] false 这是 checkin[lat]
checkin[lng] false 这是 checkin[lng]
checkin[checkable_id] true 这是 checkin[checkable_id]
checkin[checkable_type] true 这是 checkin[checkable_type]
checkin[attachments_attributes] false 这是 checkin[attachments_attributes]
checkin[message] false 这是 checkin[message]
checkin[checkin_at] false 这是 checkin[checkin_at]
checkin[category] false 这是 checkin[category]
checkin[device_info] false 签到设备
checkin[address_attributes][detail_address] false 这是 checkin[address_attributes][detail_address]
checkin[address_attributes][email] false 这是 checkin[address_attributes][email]
checkin[address_attributes][tel] false 这是 checkin[address_attributes][tel]
checkin[address_attributes][url] false 这是 checkin[address_attributes][url]
checkin[address_attributes][province_id] false 这是 checkin[address_attributes][province_id]
checkin[address_attributes][city_id] false 这是 checkin[address_attributes][city_id]
checkin[address_attributes][district_id] false 这是 checkin[address_attributes][district_id]
checkin[address_attributes][zip] false 这是 checkin[address_attributes][zip]
checkin[address_attributes][fax] false 这是 checkin[address_attributes][fax]
checkin[address_attributes][wechat] false 这是 checkin[address_attributes][wechat]
checkin[address_attributes][qq] false 这是 checkin[address_attributes][qq]
checkin[address_attributes][lat] false 这是 checkin[address_attributes][lat]
checkin[address_attributes][lng] false 这是 checkin[address_attributes][lng]
checkin[address_attributes][off_distance] false 这是 checkin[address_attributes][off_distance]
checkin[checkable_attributes] false 这是 checkin[checkable_attributes]
checkin[checkable_attributes][status] false 这是 checkin[checkable_attributes][status]
checkin[checkable_attributes][stage] false 这是 checkin[checkable_attributes][stage]
attachment_ids false 这是 attachment_ids
update_customer_address false 这是 update_customer_address

返回数据

{
  "code": 0,
   "data": {
     "comments": [],
     "comments_count": 0,
     "id": 592,
     "lat": 0,
     "lng": 0,
     "message": "",
     "category": "",
     "category_display": "",
     "category_i18n": "",
     "created_at": "2015-07-29 17:26",
     "remind_at": "",
     "checkin_at": "",
     "sales_activity": {},
     "checkable_type": "Customer",
     "checkable": {
       "customer": {
         "id": 1,
         "name": "自定义字段",
         "name_pinyin": "zidingyiziduan",
         "user_id": 1,
         "user_name": "default",
         "contacts": [],
         "company_name": "",
         "address": {},
         "revisit_at": "2015-11-25T10:13:34.000+08:00",
         "is_own": true,
         "status": "7",
         "status_mapped": "初访",
         "category": "",
         "category_mapped": ""
       }
     },
     "user": {
       "id": 1,
       "email": "test@qq.com",
       "created_at": "2015-06-09T15:46:06.000+08:00",
       "name": "default",
       "organization_id": 1,
       "phone": "",
       "role_id": 0,
       "workflow_state": "new",
       "job": "Shgsg",
       "tel": "",
       "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/30/avatar.?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
       "department_name": "总裁办"
     },
     "attachments": [],
     "address": {
       "id": 1000,
       "country": {},
       "province": {},
       "city": {},
       "district": {},
       "tel": "010-65880961",
       "phone": "13888001181",
       "email": "zhaoning2@web.com",
       "qq": "88883272",
       "fax": "",
       "wechat": "weix961",
       "wangwang": "888822849",
       "zip": "100960",
       "url": "",
       "detail_address": "北京市朝阳区朝阳门外大街18号丰联广场A座第9层",
       "lat": 0,
       "lng": 0,
       "distance": "0m",
       "region_info": "",
       "off_distance": 0,
       "gaode_staticmap": ""
     }
   }
 }

D查重接口

查重获取开关

HTTP Request

GET /api/v2/duplicates/setting

URL Parameters

字段名 是否必填 描述

返回数据:

{
  code: 0,
  data: {
    "customer": {
      "enabled": true
    },
    "lead": {
      "enabled": true
    },
    "contact": {
      "enabled": true
    }
  }
}

可以查重的字段

HTTP Request

GET /api/v2/duplicates/field_setting

URL Parameters

字段名 是否必填 描述
entity_type true String 实体类型,可选值[“customer”, “lead”, “contact”]

返回数据:

  "code": 0,
  "data": {
    "duplicate_fields": [
      {
        "name": "name",
        "custom_field_name": "name",
        "label": "姓名",
        "checked": true
      },
      {
        "name": "tel",
        "custom_field_name": "address.tel",
        "label": "电话",
        "checked": true
      },
      {
        "name": "phone",
        "custom_field_name": "address.phone",
        "label": "手机",
        "checked": true
      },
      {
        "name": "wechat",
        "custom_field_name": "address.wechat",
        "label": "微信号",
        "checked": false
      },
      {
        "name": "qq",
        "custom_field_name": "address.qq",
        "label": "QQ号",
        "checked": false
      },
      {
        "name": "wangwang",
        "custom_field_name": "address.wangwang",
        "label": "旺旺号",
        "checked": false
      },
      {
        "name": "email",
        "custom_field_name": "address.email",
        "label": "邮箱",
        "checked": false
      },
      {
        "name": "url",
        "custom_field_name": "address.url",
        "label": "网址",
        "checked": false
      },
      {
        "name": "text_asset_7eec6d5c",
        "custom_field_name": "text_asset_7eec6d5c",
        "label": "手机2",
        "checked": false
      }
    ]
  }
}

查重搜索

HTTP Request

GET /api/v2/duplicates/search

URL Parameters

字段名 是否必填 描述
entity_type true String 实体类型,可选值[“customer”, “lead”, “contact”]
query true String 查询的条件

返回数据:

{
  code: 0,
  data: {
  customers": [
    {
      "id": 82811,
      "name": 'ik'
      "is_common": false,
      "is_own": true,
      "values": [
        {
          "name": "user.name",
          "label": "负责人",
          "value": "test@qq.com"
        },
        {
          "name": "created_at",
          "label": "创建时间",
          "value": "2017-04-28 16:06"
        },
        {
          "name": "address.qq",
          "label": "QQ号",
          "value": ""
        }
      ]
    },
    {
      "id": 82811,
      "is_common": false,
      "is_own": true,
      "values": [
        {
          "name": "name",
          "label": "客户名称",
          "value": "侯德林11111111"
        },
        {
          "name": "user.name",
          "label": "负责人",
          "value": "test@qq.com"
        },
        {
          "name": "created_at",
          "label": "创建时间",
          "value": "2017-04-28 16:06"
        },
        {
          "name": "address.qq",
          "label": "QQ号",
          "value": ""
        }
      ]
    },
    "total_count": 1
  }
}

单个字段查重

HTTP Request

GET|POST

customer模块: /api/v2/customers/check_duplicate_field

lead模块: /api/v2/leads/check_duplicate_field

contact模块: /api/v2/contacts/check_duplicate_field

URL Parameters

字段名 是否必填 描述
field_value true 该字段的值
field true 该字段的名称
model_id false 各模块编辑某个model时的model_id,从哪个接口进入就是哪个model的id

例如:{“field”=>“phone”, “field_value”=>“16812341234”, “model_id”=>“334605”}

返回数据:

{"code":"0", "remark":"未发现相同手机的客户"}

{"code":"1", "remark":"你已经有相同手机的客户"}

{"code":"2", "remark":"公司内已经有相同手机的客户"}

C公海客户

列表页

HTTP Request

GET /api/v2/common_customers

URL Parameters

字段名 是否必填 描述
common_id true 公海id

返回数据

{
  "code": 0,
  "data": {
    "customers": [
      {
        "id": 18,
        "name": "贸易公司",
        "name_pinyin": "maoyigongsi",
        "user_id": 2,
        "user_name": "test",
        "contacts": [
          {
            "id": 6,
            "name": "赵宁",
            "address": {
              "id": 1077,
              "tel": "010-64881989",
              "phone": ""
            }
          },
          {
            "id": 19,
            "name": "ddddddddddd",
            "address": {
              "id": 1319,
              "tel": "21123213213",
              "phone": ""
            }
          }
        ],
        "company_name": "",
        "address": {
          "id": 1076,
          "tel": "010-64881989",
          "phone": ""
        },
        "revisit_at": "2015-08-31T11:30:21.000+08:00",
        "is_own": true,
        "status": "8",
        "status_mapped": "意向",
        "category": "12",
        "category_mapped": "A(重要客户)"
      }
    ],
    "total_count": 22,
    "per_page": 1,
    "page": 1,
    "max_customer_limit_astrict_unsold": true, #是否是未成交客户
    "is_list_exceed_own_category_customer": false, #是否是按类别判断数量
    "list_exceed_own_category_customer_count": [
        {
            "label": "成交",
            "count": 5
        }
    ],
    "is_exceed_own_customer": false, #是否是个人所有客户的最大数量设置
    "exceed_own_customer_count": 0
  }
}

详情页

HTTP Request

GET /api/v2/common_customers/:id

URL Parameters

字段名 是否必填 描述
id true 用户id

返回数据


公海客户联系人

HTTP Request

GET /api/v2/common_customers/:id/contacts

URL Parameters

字段名 是否必填 描述
id true 用户id

返回数据


公海客户跟进

HTTP Request

GET /api/v2/common_customers/:id/revisit_logs

URL Parameters

字段名 是否必填 描述
id true 用户id

返回数据


公海客户相关合同

HTTP Request

GET /api/v2/common_customers/:id/contracts

URL Parameters

字段名 是否必填 描述
id true 用户id

返回数据

{
  "code": 0,
  "data": {
    "contracts": [],
    "total_count": 0,
    "per_page": 0,
    "page": 0
  }
}

公海客户相关商机

HTTP Request

GET /api/v2/common_customers/:id/opportunities

URL Parameters

字段名 是否必填 描述
id true 用户id

返回数据

{
  "code": 0,
  "data": {
    "opportunities": [],
    "total_count": 0,
    "per_page": 0,
    "page": 0
  }
}

公海设置列表

HTTP Request

GET /api/v2/common_customers/common_settings

URL Parameters

返回数据

{
  "code": 0,
  "data": {
    "common_settings": [
      {id: 1, name: '客户公海'}
    ]
  }
}

公海客户成员

HTTP Request

GET /api/v2/common_customers/:id/members(.:format)

URL Parameters

字段名 是否必填 描述
id true common_customer_setting 公海的id,替换掉url的:id

返回数据 “`json

{ "code”: 0, “data”: { “total_count”: 40, “per_page”: 15, “page”: 1, “members”: [ { “id”: 1, “email”: “test@qq.com”, “created_at”: “2017-04-13T00:00:00.000+08:00”, “name”: “test@qq.com”, “organization_id”: 30, “phone”: “157214621171”, “role_id”: 86, “workflow_state”: “organization_owner”, “job”: “6666”, “tel”: “021-45555555”, “avatar_url”: “/dn-ikcrm-files-dev.qbox.me/attachments/files/14088/1.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient”, “department_name”: “研发2部” } ] } }



## 删除公海客户
### HTTP Request
`DELETE  /api/v2/common_customers/:id(.:format)`

### URL Parameters
字段名 | 是否必填 | 描述
--------- | ------- | -----------
id | true | customer 的 id,替换掉url的:id

> 返回数据
```json
{
  "code": 0
}

转移公海客户

HTTP Request

PUT /api/v2/common_customers/:id/transfer

URL Parameters

字段名 是否必填 描述
id true 客户id
user_id true 转移到的用户id

返回数据

{
    "code": 0,
    "data": {
        "id": 77,
        "name": "范甘迪",
        "category": "",
        "source": "",
        "industry": "",
        "staff_size": null,
        "note": "",
        "created_at": "2014-08-22 14:00",
        "updated_at": "2017-10-23T14:03:22.841+08:00",
        "organization_id": 30,
        "user_id": 1,
        "parent_id": null,
        "path": "0/77",
        "status": "3068",
        "status_locked": false,
        "department_id": 44,
        "name_pinyin": "fangandi",
        "revisit_at": "2017-10-23T14:03:22.841+08:00",
        "real_revisit_at": null,
        "revisit_remind_at": null,
        "company_name": null,
        "qixinbao_id": null,
        "creator_id": 1,
        "before_user_id": null,
        "before_department_id": null,
        "flow_into_at": "2014-11-20T18:21:30.000+08:00",
        "status_updated_at": null,
        "customer_common_setting_id": null,
        "before_customer_common_setting_id": 14,
        "approve_status": "approved",
        "approve_deny_type": 0,
        "step": null,
        "submit_applying_at": null,
        "finish_approve_at": null,
        "pending_step": null,
        "industry_category": null,
        "status_mapped": "成交"
    }
}

创建客户

HTTP Request

POST /api/v2/common_customers(.:format)

URL Parameters

字段名 是否必填 描述
customer[user_id] false 负责人id
customer[parent_id] false 上级客户id.
customer[name] false 客户名称
customer[note] false 备注
customer[status] false 跟进状态 值为 /api/v2/field_maps/customer 返回值
customer[category] false 客户类型 值为 /api/v2/field_maps/customer 返回值
customer[source] false 客户来源 值为 /api/v2/field_maps/customer 返回值
customer[industry] false 行业 值为 /api/v2/field_maps/customer 返回值
customer[staff_size] false 员工人数
customer[want_department_id] false 所属部门
customer[custom_field_template_id] false 业务模版id
customer[address_attributes][detail_address] false 地址详情
customer[address_attributes][tel] false 电话
customer[address_attributes][url] false 这是 [url]
customer[address_attributes][country_id] false 国家id
customer[address_attributes][province_id] false 省id
customer[address_attributes][city_id] false 城市id
customer[address_attributes][district_id] false 区域id
customer[address_attributes][zip] false 邮编
customer[address_attributes][fax] false 传真
customer[address_attributes][qq] false qq
customer[address_attributes][wechat] false 微信
customer[address_attributes][wangwang] false wangwang
customer[address_attributes][phone] false 手机
customer[address_attributes][email] false 邮箱
customer[contacts_attributes][name] false 联系人姓名
customer[opportunities_attributes][title] false 商机标题

返回数据:

{
  "code": 0
}

L线索池

获取线索池设置列表

HTTP Request

GET /api/v2/common_leads/common_settings

请求参数说明

字段名 是否必填 字段类型 描述

返回数据字段说明

字段名 参数类型 描述
code Integer 返回状态码,成功为0
data Json 返回数据
common_settings Array 数组中包含所有线索池
id Integer 线索池id
organization_id Integer 企业id
name String 线索池名称
admin_list Json 线索池管理员列表
user_ids Array 线索池管理员id数组
member_list Json 线索池成员列表
all Integer 是否为全部用户
department_ids Array 指定部门的成员
user_ids Array 线索池成员id数组
custom_column_list Json 线索池自定义显示列
super Array 线索池管理员显示列
common Array 线索池成员显示列
filter_column_list Json 线索池筛选列
super Array 线索池管理员筛选列
common Array 线索池成员筛选列
grab_rule String 抢回规则
created_at Time 创建时间
updated_at Time 最近更新时间

返回数据

{
    "code": 0,
    "data": {
        "common_settings": [
            {
                "id": 1,
                "organization_id": 10578,
                "name": "线索池",
                "admin_list": {
                    "user_ids": []
                },
                "member_list": {
                    "all": 1,
                    "department_ids": [
                        "0"
                    ],
                    "user_ids": []
                },
                "custom_column_list": {
                    "super": [
                        "name"
                    ],
                    "common": [
                        "name"
                    ]
                },
                "filter_column_list": {
                    "super": [],
                    "common": []
                },
                "grab_rule": "enable_grab",
                "created_at": "2018-07-18T19:04:13.000+08:00",
                "updated_at": "2018-07-18T19:04:13.000+08:00"
            }
        ]
    }
}

获取线索池成员列表

HTTP Request

GET /api/v2/common_leads/:id/members

请求参数说明

字段名 是否必填 字段类型 描述
id true Integer 要获取成员的线索池id,是url中的:id部分,不以参数形式传递
query false String 搜索关键字
per_page false Integer 单页数量
page false Integer 页码

返回数据字段说明

字段名 参数类型 描述
code Integer 返回状态码,成功为0
data Json 返回数据
total_count Integer 成员总数
per_page Integer 单页数量
page Integer 页码
members Array 数组包含成员详情,字段不一一列举,详见json样例

返回数据

{
    "code": 0,
    "data": {
        "total_count": 26,
        "per_page": 15,
        "page": 1,
        "members": [
            {
                "id": 21992,
                "email": "",
                "created_at": "2017-12-29 11:33",
                "name": "姜河",
                "organization_id": 10578,
                "phone": "",
                "role_id": 1912,
                "workflow_state": "new",
                "job": "",
                "tel": "",
                "avatar_url": "/static.dingtalk.com/media/lADPACOG83_sEE7NAeDNAeA_480_480.jpg",
                "department_name": "牛磺酸室"
            },
            {
                "id": 21993,
                "email": "",
                "created_at": "2017-12-29 11:33",
                "name": "侯德林",
                "organization_id": 10578,
                "phone": "18516501771",
                "role_id": 1912,
                "workflow_state": "new",
                "job": "",
                "tel": "",
                "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
                "department_name": "牛磺酸室"
            },
            {
                "id": 21997,
                "email": "",
                "created_at": "2017-12-29 19:24",
                "name": "guxiaobai",
                "organization_id": 10578,
                "phone": "",
                "role_id": 1912,
                "workflow_state": "new",
                "job": "",
                "tel": "",
                "avatar_url": "/static.dingtalk.com/media/lADOAZoXzs0CbM0CgA_640_620.jpg",
                "department_name": "牛磺酸室"
            },
            {
                "id": 21998,
                "email": "",
                "created_at": "2017-12-29 19:24",
                "name": "胡奕堯",
                "organization_id": 10578,
                "phone": "",
                "role_id": 1912,
                "workflow_state": "new",
                "job": "",
                "tel": "",
                "avatar_url": "/static.dingtalk.com/media/lADOXSw-jc0Cfs0Cfg_638_638.jpg",
                "department_name": "牛磺酸室"
            },
            {
                "id": 21999,
                "email": "",
                "created_at": "2017-12-29 19:24",
                "name": "梅翔",
                "organization_id": 10578,
                "phone": "",
                "role_id": 1912,
                "workflow_state": "new",
                "job": "",
                "tel": "",
                "avatar_url": "/static.dingtalk.com/media/lADO1TOJHc0E180E1w_1239_1239.jpg",
                "department_name": "牛磺酸室"
            },
            {
                "id": 22001,
                "email": "",
                "created_at": "2017-12-29 19:24",
                "name": "杨璇",
                "organization_id": 10578,
                "phone": "",
                "role_id": 1912,
                "workflow_state": "new",
                "job": "",
                "tel": "",
                "avatar_url": "/static.dingtalk.com/media/lADPBbCc1U8NjETNBNrNBNo_1242_1242.jpg",
                "department_name": "牛磺酸室"
            },
            {
                "id": 22002,
                "email": "",
                "created_at": "2017-12-29 19:24",
                "name": "朱传涛",
                "organization_id": 10578,
                "phone": "",
                "role_id": 1912,
                "workflow_state": "new",
                "job": "",
                "tel": "",
                "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
                "department_name": "牛磺酸室"
            },
            {
                "id": 22214,
                "email": "",
                "created_at": "2018-03-24 19:11",
                "name": "郑伟",
                "organization_id": 10578,
                "phone": "",
                "role_id": 1914,
                "workflow_state": "new",
                "job": "",
                "tel": "",
                "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
                "department_name": "牛磺酸室"
            },
            {
                "id": 22215,
                "email": "",
                "created_at": "2018-03-24 19:11",
                "name": "Sean",
                "organization_id": 10578,
                "phone": "",
                "role_id": 1914,
                "workflow_state": "new",
                "job": "",
                "tel": "",
                "avatar_url": "/static.dingtalk.com/media/lADOA8rXdc0CaM0CgA_640_616.jpg",
                "department_name": "牛磺酸室"
            },
            {
                "id": 22217,
                "email": "",
                "created_at": "2018-03-26 09:56",
                "name": "张明举12121ccccccddddd3333",
                "organization_id": 10578,
                "phone": "",
                "role_id": 1914,
                "workflow_state": "new",
                "job": "",
                "tel": "",
                "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
                "department_name": "金银花牛黄片"
            },
            {
                "id": 22218,
                "email": "",
                "created_at": "2018-03-26 10:12",
                "name": "lll",
                "organization_id": 10578,
                "phone": "",
                "role_id": 1912,
                "workflow_state": "new",
                "job": "",
                "tel": "",
                "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
                "department_name": "金银花牛黄片"
            },
            {
                "id": 22236,
                "email": "",
                "created_at": "2018-05-11 14:39",
                "name": "李军超",
                "organization_id": 10578,
                "phone": "",
                "role_id": 1912,
                "workflow_state": "new",
                "job": "",
                "tel": "",
                "avatar_url": "/static.dingtalk.com/media/lADPBbCc1gheEHDNArPNArM_691_691.jpg",
                "department_name": "忍冬科科室"
            },
            {
                "id": 22237,
                "email": "",
                "created_at": "2018-05-11 14:39",
                "name": "魏加朔",
                "organization_id": 10578,
                "phone": "",
                "role_id": 1912,
                "workflow_state": "new",
                "job": "",
                "tel": "",
                "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
                "department_name": "金银花牛黄片"
            },
            {
                "id": 22240,
                "email": "",
                "created_at": "2018-05-14 13:21",
                "name": "闵美如",
                "organization_id": 10578,
                "phone": "",
                "role_id": 1914,
                "workflow_state": "new",
                "job": "",
                "tel": "",
                "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
                "department_name": "金银花牛黄片"
            },
            {
                "id": 22254,
                "email": "",
                "created_at": "2018-06-11 14:24",
                "name": "范翰文",
                "organization_id": 10578,
                "phone": "",
                "role_id": 1912,
                "workflow_state": "new",
                "job": "",
                "tel": "",
                "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
                "department_name": "金银花牛黄片"
            }
        ]
    }
}

获取线索池线索列表页

HTTP Request

GET /api/v2/common_leads

请求参数说明

字段名 是否必填 字段类型 描述
common_id false Integer 线索池id,由于目前只支持单线索池,可以不传
page false Integer 页码
per_page false Integer 单页数量
query false String 搜索关键字
custom_field_name false String 搜索字段
sort false String 排序字段
order false String 排序方式(asc或desc)

返回数据字段说明

字段名 参数类型 描述
code Integer 返回状态码,成功为0
data Json 返回数据
total_count Integer 符合筛选数据的总条数
per_page Integer 单页条数
page Integer 页码
notice String 列表为空时给出的提示语
leads[] Array 数组包含多个线索对象json,json中字段根据企业和用户设置有所不同,不一一列举,具体参考返回json样例
address Json 线索的地址信息
is_common_admin Boolean 当前用户是否为线索池管理员

返回数据

{
    "code": 0,
    "data": {
        "total_count": 2,
        "per_page": 15,
        "page": 1,
        "notice": "来晚了,线索池线索都被抢光了!",
        "leads": [
            {
                "id": 83023,
                "name": "线索池导入978",
                "company_name": "导入公司978",
                "status": "64180",
                "status_mapped": "未处理",
                "turned_to_customer": false,
                "need_hidden_dispose": false,
                "address": {
                    "id": 276674,
                    "addressable_id": 83023,
                    "addressable_type": "Lead",
                    "country_id": null,
                    "province_id": null,
                    "city_id": null,
                    "district_id": null,
                    "tel": "010-25360978",
                    "phone": "1342690978",
                    "email": null,
                    "qq": null,
                    "fax": null,
                    "wechat": null,
                    "wangwang": null,
                    "zip": null,
                    "url": null,
                    "detail_address": "北京市朝阳区朝阳门外大街18号丰联广场A座第9层",
                    "created_at": "2018-07-30T13:33:14.000+08:00",
                    "updated_at": "2018-07-30T13:33:14.000+08:00",
                    "lat": null,
                    "lng": null,
                    "off_distance": null,
                    "region_info": null,
                    "snippet": null,
                    "organization_id": 10578,
                    "mode": "compat",
                    "time_format": "ruby",
                    "use_to_json": true,
                    "tel_hidden_result": "010-25360978",
                    "phone_hidden_result": "1342690978"
                },
                "is_common_admin": true
            },
            {
                "id": 83015,
                "name": "线索池导入970",
                "company_name": "导入公司970",
                "status": "64180",
                "status_mapped": "未处理",
                "turned_to_customer": false,
                "need_hidden_dispose": false,
                "address": {
                    "id": 276666,
                    "addressable_id": 83015,
                    "addressable_type": "Lead",
                    "country_id": null,
                    "province_id": null,
                    "city_id": null,
                    "district_id": null,
                    "tel": "010-25360970",
                    "phone": "1342690970",
                    "email": null,
                    "qq": null,
                    "fax": null,
                    "wechat": null,
                    "wangwang": null,
                    "zip": null,
                    "url": null,
                    "detail_address": "北京市朝阳区朝阳门外大街18号丰联广场A座第9层",
                    "created_at": "2018-07-30T13:33:14.000+08:00",
                    "updated_at": "2018-07-30T13:33:14.000+08:00",
                    "lat": null,
                    "lng": null,
                    "off_distance": null,
                    "region_info": null,
                    "snippet": null,
                    "organization_id": 10578,
                    "mode": "compat",
                    "time_format": "ruby",
                    "use_to_json": true,
                    "tel_hidden_result": "010-25360970",
                    "phone_hidden_result": "1342690970"
                },
                "is_common_admin": true
            }
        ]
    }
}

获取线索池线索详情页

HTTP Request

GET /api/v2/common_leads/:id

请求参数说明

字段名 是否必填 字段类型 描述
id true Integer 线索id,是url中的:id部分,不以参数的形式传递

返回数据字段说明

字段名 参数类型 描述
code Integer 返回状态码,成功为0
data Json 返回数据,详情页返回lead字段根据企业和用户设置有所不同,不一一列举,具体参考返回json样例
is_common_admin Boolean 当前用户是否为线索池管理员
is_allow_grab Boolean 当前用户是否可抢该线索

返回数据

{
    "code": 0,
    "data": {
        "id": 83023,
        "name": "线索池导入978",
        "company_name": "导入公司978",
        "status": "64180",
        "source": "",
        "source_mapped": "",
        "department": "",
        "job": "",
        "note": "主营外贸销售,代理国外一线品牌",
        "created_at": "2018-07-30 13:33",
        "status_mapped": "未处理",
        "updated_at": "2018-07-30 13:33",
        "is_own": true,
        "status_display": "未处理",
        "attachment": {},
        "turned_to_customer": false,
        "revisit_remind_at": "",
        "turned_customer_id": 0,
        "turned_to_customer_name": "",
        "qixinbao_id": "",
        "creator": {
            "id": 22218,
            "email": "",
            "created_at": "2018-03-26 10:12",
            "name": "lll",
            "organization_id": 10578,
            "phone": "",
            "role_id": 1912,
            "workflow_state": "new",
            "job": "",
            "tel": "",
            "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
            "department_name": "金银花牛黄片"
        },
        "is_editable": true,
        "is_user_self": false,
        "card_attachment": {},
        "lead_common_setting_id": 1,
        "before_lead_common_setting_id": null,
        "text_asset_65e11f": "自定义字段",
        "file_asset_7f77c2": [],
        "text_area_asset_a5cbb2": null,
        "text_asset_2baca2": [],
        "need_hidden_dispose": false,
        "text_asset_2baca2_display": "",
        "user": null,
        "address": {
            "id": 276674,
            "country": {},
            "province": {},
            "city": {},
            "district": {},
            "tel": "010-25360978",
            "tel_hidden_result": "010-25360978",
            "phone": "1342690978",
            "phone_hidden_result": "1342690978",
            "email": "",
            "qq": "",
            "fax": "",
            "wechat": "",
            "wangwang": "",
            "zip": "",
            "url": "",
            "detail_address": "北京市朝阳区朝阳门外大街18号丰联广场A座第9层",
            "lat": 0,
            "lng": 0,
            "distance": "未知",
            "region_info": null,
            "off_distance": -1,
            "gaode_staticmap": "",
            "full_address": "北京市朝阳区朝阳门外大街18号丰联广场A座第9层"
        },
        "owned_department": null,
        "before_user": {
            "id": 22218,
            "email": "",
            "created_at": "2018-03-26 10:12",
            "name": "lll",
            "organization_id": 10578,
            "phone": "",
            "role_id": 1912,
            "workflow_state": "new",
            "job": "",
            "tel": "",
            "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
            "department_name": "金银花牛黄片"
        },
        "before_owned_department": {
            "id": 4337,
            "name": "金银花牛黄片"
        },
        "is_common_admin": true,
        "is_allow_grab": false
    }
}

获取线索池线索跟进记录

HTTP Request

GET /api/v2/common_leads/:id/revisit_logs

请求参数说明

字段名 是否必填 字段类型 描述
id true Integer 线索id,是url中的:id部分,不以参数形式传递
page false Integer 页码
per_page false Integer 单页数量

返回数据字段说明

字段名 参数类型 描述
code Integer 返回状态码,成功为0
data Json 返回数据
total_count Integer 跟进记录数量
per_page Integer 单页数量
page Integer 页码
revisit_logs Array 数组中包含跟进记录对象,具体字段不一一列举,详见json样例

返回数据

{
    "code": 0,
    "data": {
        "total_count": 2,
        "per_page": 15,
        "page": 1,
        "revisit_logs": [
            {
                "id": 9311,
                "content": "适当的发疯",
                "loggable_type": "Lead",
                "loggable_id": 83022,
                "loggable": {
                    "id": 83022,
                    "name": "线索池导入977"
                },
                "real_revisit_at": "2018-11-08 15:35",
                "created_at": "2018-11-08 15:36",
                "attachment_files": [],
                "category_display": "电话",
                "category_i18n": "电话",
                "category": "64184",
                "image_attachments": [],
                "audios": [],
                "address": {},
                "timestamp": "2018-11-08 15:36",
                "refer_type_display": "线索",
                "refer_name": "线索池导入977",
                "title": "电话",
                "remind_at": "",
                "is_remind_expired": false,
                "raw_remind_at": "",
                "event_url": "ikcrm:/events?klass_name=RevisitLog&id=",
                "event_identifier": "",
                "at_users": [],
                "user": {
                    "id": 22218,
                    "email": "",
                    "created_at": "2018-03-26 10:12",
                    "name": "lll",
                    "organization_id": 10578,
                    "phone": "",
                    "role_id": 1912,
                    "workflow_state": "new",
                    "job": "",
                    "tel": "",
                    "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
                    "department_name": "金银花牛黄片"
                },
                "sales_activity_id": 517917,
                "comments_count": 0,
                "comments": [],
                "sales_circle_id": 0,
                "like_user": [],
                "contacts": []
            },
            {
                "id": 9312,
                "content": "十二日",
                "loggable_type": "Lead",
                "loggable_id": 83022,
                "loggable": {
                    "id": 83022,
                    "name": "线索池导入977"
                },
                "real_revisit_at": "2018-11-08 15:36",
                "created_at": "2018-11-08 15:36",
                "attachment_files": [],
                "category_display": "电话",
                "category_i18n": "电话",
                "category": "64184",
                "image_attachments": [],
                "audios": [],
                "address": {},
                "timestamp": "2018-11-08 15:36",
                "refer_type_display": "线索",
                "refer_name": "线索池导入977",
                "title": "电话",
                "remind_at": "",
                "is_remind_expired": false,
                "raw_remind_at": "",
                "event_url": "ikcrm:/events?klass_name=RevisitLog&id=",
                "event_identifier": "",
                "at_users": [],
                "user": {
                    "id": 22218,
                    "email": "",
                    "created_at": "2018-03-26 10:12",
                    "name": "lll",
                    "organization_id": 10578,
                    "phone": "",
                    "role_id": 1912,
                    "workflow_state": "new",
                    "job": "",
                    "tel": "",
                    "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
                    "department_name": "金银花牛黄片"
                },
                "sales_activity_id": 517918,
                "comments_count": 0,
                "comments": [],
                "sales_circle_id": 0,
                "like_user": [],
                "contacts": []
            }
        ]
    }
}

删除线索池中线索

HTTP Request

DELETE /api/v2/common_leads/:id

请求参数说明

字段名 是否必填 字段类型 描述
id true Integer 要删除的线索id,是url中的:id部分,不以参数形式传递

返回数据字段说明

字段名 参数类型 描述
code Integer 返回状态码,成功为0
data Json 返回数据,包含被删除的线索信息

返回数据

{
    "code": 0,
    "data": {
        "id": 83024,
        "name": "线索池导入979",
        "company_name": "导入公司979",
        "status": "64180",
        "source": "",
        "source_mapped": "",
        "department": "",
        "job": "",
        "note": "主营外贸销售,代理国外一线品牌",
        "created_at": "2018-07-30 13:33",
        "status_mapped": "未处理",
        "updated_at": "2018-07-30 13:33",
        "is_own": true,
        "status_display": "未处理",
        "attachment": {},
        "turned_to_customer": false,
        "revisit_remind_at": "",
        "turned_customer_id": 0,
        "turned_to_customer_name": "",
        "qixinbao_id": "",
        "creator": {
            "id": 22218,
            "email": "",
            "created_at": "2018-03-26 10:12",
            "name": "lll",
            "organization_id": 10578,
            "phone": "",
            "role_id": 1912,
            "workflow_state": "new",
            "job": "",
            "tel": "",
            "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
            "department_name": "金银花牛黄片"
        },
        "is_editable": true,
        "is_user_self": false,
        "card_attachment": {},
        "text_asset_65e11f": null,
        "file_asset_7f77c2": [],
        "text_area_asset_a5cbb2": null,
        "text_asset_2baca2": [],
        "need_hidden_dispose": false,
        "text_asset_2baca2_display": "",
        "user": null,
        "address": null,
        "owned_department": null,
        "before_user": {
            "id": 21993,
            "email": "",
            "created_at": "2017-12-29 11:33",
            "name": "侯德林",
            "organization_id": 10578,
            "phone": "18516501771",
            "role_id": 1912,
            "workflow_state": "new",
            "job": "",
            "tel": "",
            "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
            "department_name": "牛磺酸室"
        },
        "before_owned_department": {
            "id": 4351,
            "name": "牛磺酸室"
        }
    }
}

抢线索池中线索

HTTP Request

POST /api/v2/leads/:id/take

请求参数说明

字段名 是否必填 字段类型 描述
id true Integer 要抢的线索id,是url中的:id部分,不以参数形式传递

返回数据字段说明

字段名 参数类型 描述
code Integer 返回状态码,成功为0
data Json 返回数据,包含抢到的线索的详细信息,字段不一一列举,详见json样例
message String 返回信息,是抢到的线索名称

返回数据

{
    "code": 0,
    "data": {
        "id": 83022,
        "name": "线索池导入977",
        "company_name": "导入公司977",
        "status": "64180",
        "source": "",
        "source_mapped": "",
        "department": "",
        "job": "",
        "note": "主营外贸销售,代理国外一线品牌",
        "created_at": "2018-07-30 13:33",
        "status_mapped": "未处理",
        "updated_at": "2018-07-30 13:33",
        "is_own": true,
        "status_display": "未处理",
        "attachment": {},
        "turned_to_customer": false,
        "revisit_remind_at": "",
        "turned_customer_id": 0,
        "turned_to_customer_name": "",
        "qixinbao_id": "",
        "creator": {
            "id": 22218,
            "email": "",
            "created_at": "2018-03-26 10:12",
            "name": "lll",
            "organization_id": 10578,
            "phone": "",
            "role_id": 1912,
            "workflow_state": "new",
            "job": "",
            "tel": "",
            "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
            "department_name": "金银花牛黄片"
        },
        "is_editable": true,
        "is_user_self": true,
        "card_attachment": {},
        "text_asset_65e11f": "自定义字段",
        "file_asset_7f77c2": [],
        "text_area_asset_a5cbb2": null,
        "text_asset_2baca2": [],
        "need_hidden_dispose": false,
        "text_asset_2baca2_display": "",
        "user": {
            "id": 22218,
            "email": "",
            "created_at": "2018-03-26 10:12",
            "name": "lll",
            "organization_id": 10578,
            "phone": "",
            "role_id": 1912,
            "workflow_state": "new",
            "job": "",
            "tel": "",
            "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
            "department_name": "金银花牛黄片"
        },
        "address": {
            "id": 276673,
            "country": {},
            "province": {},
            "city": {},
            "district": {},
            "tel": "010-25360977",
            "tel_hidden_result": "010-25360977",
            "phone": "1342690977",
            "phone_hidden_result": "1342690977",
            "email": "",
            "qq": "",
            "fax": "",
            "wechat": "",
            "wangwang": "",
            "zip": "",
            "url": "",
            "detail_address": "北京市朝阳区朝阳门外大街18号丰联广场A座第9层",
            "lat": 0,
            "lng": 0,
            "distance": "未知",
            "region_info": null,
            "off_distance": -1,
            "gaode_staticmap": "",
            "full_address": "北京市朝阳区朝阳门外大街18号丰联广场A座第9层"
        },
        "owned_department": {
            "id": 4337,
            "name": "金银花牛黄片"
        },
        "before_user": {
            "id": 22218,
            "email": "",
            "created_at": "2018-03-26 10:12",
            "name": "lll",
            "organization_id": 10578,
            "phone": "",
            "role_id": 1912,
            "workflow_state": "new",
            "job": "",
            "tel": "",
            "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
            "department_name": "金银花牛黄片"
        },
        "before_owned_department": {
            "id": 4337,
            "name": "金银花牛黄片"
        }
    },
    "message": "线索池导入977"
}

将线索转移至线索池

HTTP Request

PUT /api/v2/leads/:id/turn_common

请求参数说明

字段名 是否必填 字段类型 描述
id true Integer 要转移至线索池的线索id,是url中的:id部分,不以参数形式传递
common_id false Integer 要转移至的线索池id,目前只支持单线索池,可以不传,支持多线索池之后则为必填字段

返回数据字段说明

字段名 参数类型 描述
code Integer 返回状态码,成功为0
data Json 返回数据,包含转移的线索的详细信息,字段不一一列举,详见json样例

返回数据

{
    "code": 0,
    "data": {
        "id": 83022,
        "name": "线索池导入977",
        "company_name": "导入公司977",
        "status": "64180",
        "source": "",
        "source_mapped": "",
        "department": "",
        "job": "",
        "note": "主营外贸销售,代理国外一线品牌",
        "created_at": "2018-07-30 13:33",
        "status_mapped": "未处理",
        "updated_at": "2018-11-08 15:36",
        "is_own": true,
        "status_display": "未处理",
        "attachment": {},
        "turned_to_customer": false,
        "revisit_remind_at": "",
        "turned_customer_id": 0,
        "turned_to_customer_name": "",
        "qixinbao_id": "",
        "creator": {
            "id": 22218,
            "email": "",
            "created_at": "2018-03-26 10:12",
            "name": "lll",
            "organization_id": 10578,
            "phone": "",
            "role_id": 1912,
            "workflow_state": "new",
            "job": "",
            "tel": "",
            "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
            "department_name": "金银花牛黄片"
        },
        "is_editable": true,
        "is_user_self": false,
        "card_attachment": {},
        "text_asset_65e11f": "自定义字段",
        "file_asset_7f77c2": [],
        "text_area_asset_a5cbb2": null,
        "text_asset_2baca2": [],
        "need_hidden_dispose": false,
        "text_asset_2baca2_display": "",
        "user": null,
        "address": {
            "id": 276673,
            "country": {},
            "province": {},
            "city": {},
            "district": {},
            "tel": "010-25360977",
            "tel_hidden_result": "010-25360977",
            "phone": "1342690977",
            "phone_hidden_result": "1342690977",
            "email": "",
            "qq": "",
            "fax": "",
            "wechat": "",
            "wangwang": "",
            "zip": "",
            "url": "",
            "detail_address": "北京市朝阳区朝阳门外大街18号丰联广场A座第9层",
            "lat": 0,
            "lng": 0,
            "distance": "未知",
            "region_info": null,
            "off_distance": -1,
            "gaode_staticmap": "",
            "full_address": "北京市朝阳区朝阳门外大街18号丰联广场A座第9层"
        },
        "owned_department": null,
        "before_user": {
            "id": 22218,
            "email": "",
            "created_at": "2018-03-26 10:12",
            "name": "lll",
            "organization_id": 10578,
            "phone": "",
            "role_id": 1912,
            "workflow_state": "new",
            "job": "",
            "tel": "",
            "avatar_url": "/ding-dev.ikcrm.com/assets/male.jpg",
            "department_name": "金银花牛黄片"
        },
        "before_owned_department": {
            "id": 4337,
            "name": "金银花牛黄片"
        }
    }
}

C联系人模块

全部列表页

HTTP Request

GET /api/v2/contacts

URL Parameters

字段名 是否必填 参数类型 描述
page false Long 页码
per_page false Int 每页的数量
query false String 搜索关键字
custom_field_name false String 搜索字段
entity false String 实体(customer, opportunity)
entity_id false Long 实体id
tab_type false String 值为[my, sub, my_assist, sub_assist]或不传
has_phone false String 是否去除无电话的 去除传 true
all_phone_number false String true: 返回联系人的所有电话号码

返回数据字段说明

字段名 参数类型 描述
id Long 联系人id
name String 姓名
name_pinyin String 姓名拼音
job String 工作
customer_id Long 客户id
customer_name String 客户姓名
turned_to_customer Boolean 转换客户状态
have_image Boolean 是否有图片
address[id] Long 地址id
address[addressable_id] Long 地址关联对象id
address[addressable_type] String 地址关联对象类型
address[country_id] Long 国家id
address[province_id] Long 省id
address[city_id] Long 城市id
address[district_id] Long 区域id
address[tel] String 电话
address[phone] String 手机
address[email] String 邮箱
address[qq] String qq
address[fax] String 传真
address[wechat] String 微信号
address[wangwang] String 旺旺
address[zip] String 邮编
address[url] String url
address[detail_address] String 地址详情
address[created_at] String 创建时间
address[updated_at] String 更新时间
address[lat] Float 纬度
address[lng] Float 经度
address[off_distance] Float 距离
address[region_info] String 区域信息
address[snippet] String 片区
address[tel_hidden_result] String 隐藏处理后电话
need_hidden_dispose Boolean 是否需要掩藏客户资料号码(用于呼叫中心)
is_user_self Boolean 是否是自己的联系人
updated_at String 更新时间
created_at String 创建时间
wx_external_userid String 企业微信外部联系人userid
wx_contact_type String 企业微信外部联系人类型 wx_chat_work(企业微信), wx_chat(微信)

返回数据

{
    "code": 0,
    "data": {
        "contacts": [
            {
                "id": 20507,
                "name": "唇动",
                "name_pinyin": "chundong",
                "job": "",
                "customer_id": 73593,
                "customer_name": "唇动",
                "have_image": false,
                "address": {
                    "id": 19,
                    "addressable_id": 20507,
                    "addressable_type": null,
                    "country_id": null,
                    "province_id": null,
                    "city_id": null,
                    "district_id": null,
                    "tel": null,
                    "phone": null,
                    "email": null,
                    "qq": null,
                    "fax": null,
                    "wechat": null,
                    "wangwang": null,
                    "zip": null,
                    "url": null,
                    "detail_address": null,
                    "created_at": "2017-05-15T10:48:07.000+08:00",
                    "updated_at": "2017-05-15T10:48:07.000+08:00",
                    "lat": null,
                    "lng": null,
                    "off_distance": null,
                    "region_info": null,
                    "snippet": null,
                    "organization_id": null,
                    "tel_hidden_result": "",
                    "phone_hidden_result": ""
                },
                "need_hidden_dispose": false,
                "updated_at": "2017-05-15 10:48",
                "is_user_self": false,
                "wx_external_userid": "xxxx",
                "wx_contact_type": "wx_chat"
            }
        ],
        "total_count": 1,
        "per_page": 15,
        "page": 1
    }
}

simplest联系人列表

HTTP Request

GET /api/v2/contacts/simplest(.:format)

URL Parameters

字段名 是否必填 描述
page false 这是 page
per_page false 这是 per_page
customer_id false 传入则值显示用户下面的联系人
lastest_updated_at false 传入则值显示updated_at大于传入时间lastest_updated_at的联系人

返回数据


{
  "code": 0,
  "data": {
    "contacts": [
      {
        "id": 1,
        "name": "陈赫",
        "user_id": 1,
        "customer_id": 3,
        "customer_name": "自定义字段1",
        "address": {
          "phone": "13888888888"
        }
      }
    ],
    "total_count": 17,
    "per_page": 1,
    "page": 1
  }
}

返回具有有效电话号码的联系人列表

HTTP Request

GET /api/v2/contacts/valid_mobile_contacts(.:format)

字段名 是否必填 描述
page false 页码
per_page false 每页的数量
query false 搜索关键字
entity false 实体(customer, opportunity)
entity_id false 实体id
tab_type false 值为[my,sub]或不传
has_phone false 是否去除无电话的 去除传 true
all_phone_number false true: 返回联系人的所有电话号码

返回数据


{
  "code": 0,
  "data": {
  "contacts": [
    {
      "id": 19930,
      "name": "dfsdlk j",
      "job": "",
      "customer_name": "customer 1",
      "have_image": false,
      "address": {
        "id": 174390,
        "addressable_id": 19930,
        "addressable_type": "Contact",
        "country_id": 4,
        "province_id": 1,
        "city_id": 1,
        "district_id": 1,
        "tel": null,
        "phone": "13817828680",
        "email": null,
        "qq": null,
        "fax": null,
        "wechat": null,
        "wangwang": null,
        "zip": null,
        "url": null,
        "detail_address": null,
        "created_at": "2016-01-28T13:40:41.000+08:00",
        "updated_at": "2017-03-13T16:55:37.000+08:00",
        "lat": null,
        "lng": null,
        "off_distance": null,
        "region_info": "北京北京市东城区",
        "snippet": null,
        "tel_hidden_result": "",
        "phone_hidden_result": "13817828680"
      },
      "need_hidden_dispose": false,
      "tel_and_mobiles": [
        "13817828680"
      ],
    }
  ]
}

新建联系人

HTTP Request

POST /api/v2/contacts(.:format)

URL Parameters

字段名 是否必填 描述
contact[name] true 姓名
contact[customer_id] true 对应客户
contact[department] false 部门
contact[gender] false 性别
contact[birth_date] false 生日
contact[note] false 备注
contact[category] false 类别
contact[job] false 工作
contact[address_attributes][detail_address] false 地址详情
contact[wx_external_contact_map_attributes][external_userid] false 外部联系人userid
contact[wx_external_contact_map_attributes][contact_type] false 外部联系人类型

返回数据字段说明

字段名 参数类型 描述
id Long 线索id
name String 姓名
department String 部门
job String 工作
category Long 类别
category_mapped String 类别名称
gender String 性别
note String 备注
birth_date String 生日
gender_i18n String 性别i18n
attachment Array 附件
customer Hash 客户
user Hash 所属用户
address Hash 地址
is_own Boolean 是否自己拥有
creator Hash 创建人
need_hidden_dispose Boolean 是否需要掩藏客户资料号码(用于呼叫中心)
is_user_self Boolean 是否是自己的联系人
updated_at String 更新时间
created_at String 创建时间

返回数据


{
    "code": 0,
    "data": {
        "id": 20507,
        "name": "唇动",
        "department": "",
        "job": "",
        "category": "",
        "category_mapped": "",
        "gender": "male",
        "note": "",
        "birth_date": "1989-07-08",
        "gender_i18n": "男",
        "created_at": "2016-05-26 15:25",
        "updated_at": "2017-05-15 10:48",
        "attachment": {},
        "customer": {
            "id": 73593,
            "name": "唇动",
            "name_pinyin": "chundong",
            "user_id": 49,
            "user_name": "秋水",
            "contacts": [
                {
                    "id": 20507,
                    "name": "唇动",
                    "address": {
                        "id": 19,
                        "tel": "",
                        "tel_hidden_result": "",
                        "phone": "",
                        "phone_hidden_result": "",
                        "qq": "",
                        "email": "",
                        "lng": 0,
                        "lat": 0,
                        "detail_address": "",
                        "off_distance": -1,
                        "url": "",
                        "gaode_staticmap": "",
                        "full_address": ""
                    }
                }
            ],
            "company_name": "",
            "address": {},
            "revisit_at": "2016-06-28T15:39:50.000+08:00",
            "is_own": true,
            "status": "3068",
            "status_mapped": "成交",
            "category": "6022",
            "category_mapped": "A(重要客户)2",
            "qixinbao_id": "",
            "created_at": "2016-05-26 15:25",
            "creator": {
                "id": 81,
                "email": "vincent@163.com",
                "created_at": "2014-09-15T17:01:21.000+08:00",
                "name": "【vincent】",
                "organization_id": 30,
                "phone": "13666666666",
                "role_id": 0,
                "workflow_state": "organization_staff",
                "job": "",
                "tel": "11111111",
                "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/15100/scratchfileaike_header.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
                "department_name": "测试部"
            },
            "is_user_self": false,
            "approve_status": "approved",
            "approve_status_i18n": "已通过"
        },
        "user": {
            "id": 49,
            "email": "123@qq.com",
            "created_at": "2014-08-21T15:13:21.000+08:00",
            "name": "秋水",
            "organization_id": 30,
            "phone": "13052371907",
            "role_id": 0,
            "workflow_state": "organization_staff",
            "job": "打酱油",
            "tel": "12345678",
            "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/14798/scratchfileaike_header.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
            "department_name": "研发中心"
        },
        "address": {
            "id": 19,
            "country": {},
            "province": {},
            "city": {},
            "district": {},
            "tel": "",
            "tel_hidden_result": "",
            "phone": "",
            "phone_hidden_result": "",
            "email": "",
            "qq": "",
            "fax": "",
            "wechat": "",
            "wangwang": "",
            "zip": "",
            "url": "",
            "detail_address": "",
            "lat": 0,
            "lng": 0,
            "distance": "未知",
            "region_info": null,
            "off_distance": -1,
            "gaode_staticmap": "",
            "full_address": ""
        },
        "is_own": true,
        "creator": {
            "id": 49,
            "email": "123@qq.com",
            "created_at": "2014-08-21T15:13:21.000+08:00",
            "name": "秋水",
            "organization_id": 30,
            "phone": "13052371907",
            "role_id": 0,
            "workflow_state": "organization_staff",
            "job": "打酱油",
            "tel": "12345678",
            "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/14798/scratchfileaike_header.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
            "department_name": "研发中心"
        },
        "need_hidden_dispose": false,
        "is_user_self": false,
        "text_asset_8f920e66": "select_803765b98203",
        "text_asset_d5cab06f": null,
        "text_asset_7eec6d5c": null,
        "text_asset_3259c1": null,
        "text_asset_7eec6d5c_hidden_result": "",
        "text_asset_8f920e66_display": "旅游"
    }
}

更新联系人

HTTP Request

PUT /api/v2/contacts/:id(.:format)

URL Parameters

字段名 是否必填 描述
id true 这是 id
contact[name] true Your contact name.
contact[customer_id] true Your contact customer.
contact[department] false Your contact department
contact[gender] false Your contact note
contact[birth_date] false Your contact note
contact[note] false Your contact note
contact[category] false Your contact note
contact[job] false Your contact note
contact[address_attributes][detail_address] false 这是 contact[address_attributes][detail_address]
contact[address_attributes][email] false 这是 contact[address_attributes][email]
contact[address_attributes][tel] false 这是 contact[address_attributes][tel]
contact[address_attributes][phone] false 这是 contact[address_attributes][phone]
contact[address_attributes][url] false 这是 contact[address_attributes][url]
contact[address_attributes][province_id] false 这是 contact[address_attributes][province_id]
contact[address_attributes][city_id] false 这是 contact[address_attributes][city_id]
contact[address_attributes][district_id] false 这是 contact[address_attributes][district_id]
contact[address_attributes][zip] false 这是 contact[address_attributes][zip]
contact[address_attributes][fax] false 这是 contact[address_attributes][fax]
contact[address_attributes][wechat] false 这是 contact[address_attributes][wechat]
contact[address_attributes][qq] false 这是 contact[address_attributes][qq]

返回数据字段说明

字段名 参数类型 描述
id Long 线索id
name String 姓名
department String 部门
job String 工作
category Long 类别
category_mapped String 类别名称
gender String 性别
note String 备注
birth_date String 生日
gender_i18n String 性别i18n
attachment Array 附件
customer Hash 客户
user Hash 所属用户
address Hash 地址
is_own Boolean 是否自己拥有
creator Hash 创建人
need_hidden_dispose Boolean 是否需要掩藏客户资料号码(用于呼叫中心)
is_user_self Boolean 是否是自己的联系人
updated_at String 更新时间
created_at String 创建时间

返回数据

{
    "code": 0,
    "data": {
        "id": 20507,
        "name": "唇动",
        "department": "",
        "job": "",
        "category": "",
        "category_mapped": "",
        "gender": "male",
        "note": "",
        "birth_date": "1989-07-08",
        "gender_i18n": "男",
        "created_at": "2016-05-26 15:25",
        "updated_at": "2017-05-15 10:48",
        "attachment": {},
        "customer": {
            "id": 73593,
            "name": "唇动",
            "name_pinyin": "chundong",
            "user_id": 49,
            "user_name": "秋水",
            "contacts": [
                {
                    "id": 20507,
                    "name": "唇动",
                    "address": {
                        "id": 19,
                        "tel": "",
                        "tel_hidden_result": "",
                        "phone": "",
                        "phone_hidden_result": "",
                        "qq": "",
                        "email": "",
                        "lng": 0,
                        "lat": 0,
                        "detail_address": "",
                        "off_distance": -1,
                        "url": "",
                        "gaode_staticmap": "",
                        "full_address": ""
                    }
                }
            ],
            "company_name": "",
            "address": {},
            "revisit_at": "2016-06-28T15:39:50.000+08:00",
            "is_own": true,
            "status": "3068",
            "status_mapped": "成交",
            "category": "6022",
            "category_mapped": "A(重要客户)2",
            "qixinbao_id": "",
            "created_at": "2016-05-26 15:25",
            "creator": {
                "id": 81,
                "email": "vincent@163.com",
                "created_at": "2014-09-15T17:01:21.000+08:00",
                "name": "【vincent】",
                "organization_id": 30,
                "phone": "13666666666",
                "role_id": 0,
                "workflow_state": "organization_staff",
                "job": "",
                "tel": "11111111",
                "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/15100/scratchfileaike_header.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
                "department_name": "测试部"
            },
            "is_user_self": false,
            "approve_status": "approved",
            "approve_status_i18n": "已通过"
        },
        "user": {
            "id": 49,
            "email": "123@qq.com",
            "created_at": "2014-08-21T15:13:21.000+08:00",
            "name": "秋水",
            "organization_id": 30,
            "phone": "13052371907",
            "role_id": 0,
            "workflow_state": "organization_staff",
            "job": "打酱油",
            "tel": "12345678",
            "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/14798/scratchfileaike_header.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
            "department_name": "研发中心"
        },
        "address": {
            "id": 19,
            "country": {},
            "province": {},
            "city": {},
            "district": {},
            "tel": "",
            "tel_hidden_result": "",
            "phone": "",
            "phone_hidden_result": "",
            "email": "",
            "qq": "",
            "fax": "",
            "wechat": "",
            "wangwang": "",
            "zip": "",
            "url": "",
            "detail_address": "",
            "lat": 0,
            "lng": 0,
            "distance": "未知",
            "region_info": null,
            "off_distance": -1,
            "gaode_staticmap": "",
            "full_address": ""
        },
        "is_own": true,
        "creator": {
            "id": 49,
            "email": "123@qq.com",
            "created_at": "2014-08-21T15:13:21.000+08:00",
            "name": "秋水",
            "organization_id": 30,
            "phone": "13052371907",
            "role_id": 0,
            "workflow_state": "organization_staff",
            "job": "打酱油",
            "tel": "12345678",
            "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/14798/scratchfileaike_header.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
            "department_name": "研发中心"
        },
        "need_hidden_dispose": false,
        "is_user_self": false,
        "text_asset_8f920e66": "select_803765b98203",
        "text_asset_d5cab06f": null,
        "text_asset_7eec6d5c": null,
        "text_asset_3259c1": null,
        "text_asset_7eec6d5c_hidden_result": "",
        "text_asset_8f920e66_display": "旅游"
    }
}

联系人详情

HTTP Request

GET /api/v2/contacts/:id(.:format)

URL Parameters

字段名 是否必填 描述
id true Long

返回数据字段说明

字段名 参数类型 描述
id Long 线索id
name String 姓名
department String 部门
job String 工作
category Long 类别
category_mapped String 类别名称
gender String 性别
note String 备注
birth_date String 生日
gender_i18n String 性别i18n
attachment Array 附件
customer Hash 客户
user Hash 所属用户
address Hash 地址
is_own Boolean 是否自己拥有
creator Hash 创建人
need_hidden_dispose Boolean 是否需要掩藏客户资料号码(用于呼叫中心)
is_user_self Boolean 是否是自己的联系人
updated_at String 更新时间
created_at String 创建时间

返回数据

{
    "code": 0,
    "data": {
        "id": 20507,
        "name": "唇动",
        "department": "",
        "job": "",
        "category": "",
        "category_mapped": "",
        "gender": "male",
        "note": "",
        "birth_date": "1989-07-08",
        "gender_i18n": "男",
        "created_at": "2016-05-26 15:25",
        "updated_at": "2017-05-15 10:48",
        "attachment": {},
        "customer": {
            "id": 73593,
            "name": "唇动",
            "name_pinyin": "chundong",
            "user_id": 49,
            "user_name": "秋水",
            "contacts": [
                {
                    "id": 20507,
                    "name": "唇动",
                    "address": {
                        "id": 19,
                        "tel": "",
                        "tel_hidden_result": "",
                        "phone": "",
                        "phone_hidden_result": "",
                        "qq": "",
                        "email": "",
                        "lng": 0,
                        "lat": 0,
                        "detail_address": "",
                        "off_distance": -1,
                        "url": "",
                        "gaode_staticmap": "",
                        "full_address": ""
                    }
                }
            ],
            "company_name": "",
            "address": {},
            "revisit_at": "2016-06-28T15:39:50.000+08:00",
            "is_own": true,
            "status": "3068",
            "status_mapped": "成交",
            "category": "6022",
            "category_mapped": "A(重要客户)2",
            "qixinbao_id": "",
            "created_at": "2016-05-26 15:25",
            "creator": {
                "id": 81,
                "email": "vincent@163.com",
                "created_at": "2014-09-15T17:01:21.000+08:00",
                "name": "【vincent】",
                "organization_id": 30,
                "phone": "13666666666",
                "role_id": 0,
                "workflow_state": "organization_staff",
                "job": "",
                "tel": "11111111",
                "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/15100/scratchfileaike_header.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
                "department_name": "测试部"
            },
            "is_user_self": false,
            "approve_status": "approved",
            "approve_status_i18n": "已通过"
        },
        "user": {
            "id": 49,
            "email": "123@qq.com",
            "created_at": "2014-08-21T15:13:21.000+08:00",
            "name": "秋水",
            "organization_id": 30,
            "phone": "13052371907",
            "role_id": 0,
            "workflow_state": "organization_staff",
            "job": "打酱油",
            "tel": "12345678",
            "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/14798/scratchfileaike_header.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
            "department_name": "研发中心"
        },
        "address": {
            "id": 19,
            "country": {},
            "province": {},
            "city": {},
            "district": {},
            "tel": "",
            "tel_hidden_result": "",
            "phone": "",
            "phone_hidden_result": "",
            "email": "",
            "qq": "",
            "fax": "",
            "wechat": "",
            "wangwang": "",
            "zip": "",
            "url": "",
            "detail_address": "",
            "lat": 0,
            "lng": 0,
            "distance": "未知",
            "region_info": null,
            "off_distance": -1,
            "gaode_staticmap": "",
            "full_address": ""
        },
        "is_own": true,
        "creator": {
            "id": 49,
            "email": "123@qq.com",
            "created_at": "2014-08-21T15:13:21.000+08:00",
            "name": "秋水",
            "organization_id": 30,
            "phone": "13052371907",
            "role_id": 0,
            "workflow_state": "organization_staff",
            "job": "打酱油",
            "tel": "12345678",
            "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/14798/scratchfileaike_header.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
            "department_name": "研发中心"
        },
        "need_hidden_dispose": false,
        "is_user_self": false,
        "text_asset_8f920e66": "select_803765b98203",
        "text_asset_d5cab06f": null,
        "text_asset_7eec6d5c": null,
        "text_asset_3259c1": null,
        "text_asset_7eec6d5c_hidden_result": "",
        "text_asset_8f920e66_display": "旅游"
    }
}

推送来电通知

HTTP Request

PUT /api/v2/contacts/:id/miss_call_notify(.:format)

URL Parameters

字段名 是否必填 描述
id true 这是 id
status false 这是 status

返回数据


{
  "code": 0,
  "data": {}
}

删除联系人

HTTP Request

DELETE /api/v2/contacts/:id(.:format)

URL Parameters

字段名 是否必填 描述
id true 联系人id,加入url

返回数据


{
  "code": 0,
  "data": {
      "id": 18,
      "name": "111",
      "department": "",
      "job": "",
      "category": "",
      "category_mapped": "",
      "gender": "",
      "note": "",
      "birth_date": "",
      "gender_i18n": "",
      "created_at": "2015-09-10 10:37",
      "updated_at": "2015-09-10 10:37",
      "attachment": {},
      "customer": {
        "id": 29,
        "name": "weed",
        "name_pinyin": "weed",
        "user_id": 1,
        "user_name": "default",
        "contacts": [
          {
            "id": 18,
            "name": "111",
            "address": {
              "id": 1317,
              "tel": "",
              "phone": "",
              "qq": "",
              "lng": 0,
              "lat": 0,
              "detail_address": ""
            }
          }
        ],
        "company_name": "",
        "address": {
          "id": 1316,
          "tel": "1213123213",
          "phone": "",
          "qq": "",
          "lng": 0,
          "lat": 0,
          "detail_address": ""
        },
        "revisit_at": "2015-09-23T19:08:40.000+08:00",
        "is_own": true,
        "status": "10",
        "status_mapped": "成交",
        "category": "",
        "category_mapped": ""
      },
      "user": {
        "id": 1,
        "email": "test@qq.com",
        "created_at": "2015-06-09T15:46:06.000+08:00",
        "name": "default",
        "organization_id": 1,
        "phone": "",
        "role_id": 0,
        "workflow_state": "new",
        "job": "Shgsg",
        "tel": "",
        "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/30/avatar.?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
        "department_name": "总裁办"
      },
      "address": {
        "id": 1317,
        "country": {},
        "province": {},
        "city": {},
        "district": {},
        "tel": "",
        "phone": "",
        "email": "",
        "qq": "",
        "fax": "",
        "wechat": "",
        "wangwang": "",
        "zip": "",
        "url": "",
        "detail_address": "",
        "lat": 0,
        "lng": 0,
        "distance": "0m",
        "region_info": "",
        "off_distance": 0
      },
      "is_own": true
    }
}

C合同模块

全部列表页

HTTP Request

GET /api/v2/contracts

URL Parameters

字段名 是否必填 描述
page false 页码
per_page false 每页的数量
query false 搜索关键字
custom_field_name false String
status false 状态
approve_status false 审批状态
sort false 排序类型(created_at )
order false 排序方式(asc desc)
entity false 实体(customer, opportunity)
entity_id false 实体id
tab_type false 值为[my,sub]或不传
customer_id false 值为customer id

customer, opportunity等实体详细页面的联系人tab传入 entity, entity_id

返回数据


{
  "code": 0,
  "data": {
    "contracts": [
      {
        "id": 13604,
        "user_id": 1,
        "user_name": "test@qq.com",
        "customer_id": 82847,
        "customer_name": "l111",
        "title": "ccccccc",
        "total_amount": 1000,
        "unreceived_amount": 1000,
        "approve_status": "approved",
        "approve_status_i18n": "已通过",
        "status": "2026",
        "status_mapped": "新建",
        "updated_at": "2017-06-07 16:55",
        "is_user_self": true
      }
    ],
    "total_count": 13,
    "per_page": 1,
    "page": 1
  }
}

合同列表by_title

HTTP Request

GET /api/v2/contracts/by_name(.:format)

URL Parameters

字段名 是否必填 描述
page false 这是 page
per_page false 这是 per_page
approve_status false 这是 approve_status
query false 这是 query

返回数据


{
  "code": 0,
  "data": {
    "contracts": [
      {
        "id": 5,
        "category": "43",
        "category_mapped": "直销合同",
        "payment_type": "48",
        "payment_type_mapped": "支票",
        "status": "52",
        "status_mapped": "未开始",
        "organization_id": 1,
        "user_id": 1,
        "user_name": "default",
        "title": "123",
        "customer_id": 16,
        "customer_name": "华谊兄弟20",
        "opportunity_id": 0,
        "opportunity_title": null,
        "total_amount": "12.0",
        "start_at": "2015-06-26",
        "end_at": "",
        "customer_signer": "",
        "our_signer": "",
        "special_terms": "",
        "received_payments_amount": "0.0",
        "unreceived_amount": 12,
        "checking_payments_amount": "0.0",
        "approve_status": "approved",
        "approve_deny_type": 0,
        "updated_at": "2015-06-26 19:25:52"
      }
    ],
    "total_count": 13,
    "per_page": 1,
    "page": 1
  }
}

合同筛选条件

HTTP Request

GET /api/v2/contracts/filter_sort_group(.:format)

URL Parameters

字段名 是否必填 描述

返回数据


{
  "code": 0,
  "data": {
    "filters": [
      {
        "label": "合同状态",
        "field_name": "status",
        "filter_field_type": "select"
      },
      {
        "label": "合同到期",
        "field_name": "end_at",
        "filter_field_type": "select"
      },
      {
        "label": "产品筛选",
        "field_name": "product_id",
        "filter_field_type": "select"
      },
      {
        "label": "付款方式",
        "field_name": "payment_type",
        "filter_field_type": "field_map_field"
      },
      {
        "label": "合同审批",
        "field_name": "approve_status",
        "filter_field_type": "select"
      },
      {
        "label": "部门",
        "field_name": "department_id",
        "filter_field_type": "select",
        "filters": [
          {
            "label": "全部用户",
            "field_name": "user_id",
            "filter_field_type": "query_select"
          }
        ]
      }
    ],
    "sorts": [
      {
        "name": "sort",
        "label": "默认排序",
        "value": "",
        "order": ""
      },
      {
        "name": "sort",
        "label": "到期时间排序",
        "value": "end_at",
        "order": "desc"
      }
    ]
  }
}

合同筛选条件选项

HTTP Request

GET /api/v2/contracts/:field_name/filter_options(.:format)

URL Parameters

字段名 是否必填 描述
field_name true 这是 field_name
department_id false 这是 department_id
page false 这是 page
per_page false 这是 per_page
query false 这是 query

返回数据


{
  "code": 0,
  "data": {
    "options": [
      {
        "label": "全部跟进状态",
        "name": "status",
        "value": ""
      },
      {
        "label": "未开始",
        "value": "52",
        "name": "status"
      },
      {
        "label": "执行中",
        "value": "53",
        "name": "status"
      },
      {
        "label": "成功结束",
        "value": "54",
        "name": "status"
      },
      {
        "label": "意外终止",
        "value": "55",
        "name": "status"
      }
    ],
    "total_count": 5,
    "per_page": 5,
    "page": 1
  }
}

合同详情

HTTP Request

GET /api/v2/contracts/:id(.:format)

URL Parameters

字段名 是否必填 描述
id true url的id

返回数据字段说明

字段名 描述
step 合同当前审批到的层级(v3.13之前使用)
step_can_approve 当前用户对合同当下是否具有审批和驳回的权限
can_approve 当前用户是否为客户所有审批人中的某一个
notify_users 提醒他人集合
can_revert_applying 是否允许撤销合同(true或false)
need_approve_step 当前需要审批的层级
attachments_count 合同详情附件数
file_attachments_count 合同tab附件数

返回数据


{
  "code": 0,
  "data": {
    "id": 16,
    "category": "43",
    "category_mapped": "直销合同",
    "payment_type": "48",
    "payment_type_mapped": "支票",
    "status": "52",
    "status_mapped": "未开始",
    "organization_id": 1,
    "user": {
      "id": 1,
      "email": "test@qq.com",
      "created_at": "2015-06-09T15:46:06.000+08:00",
      "name": "default",
      "organization_id": 1,
      "phone": "",
      "role_id": 0,
      "workflow_state": "new",
      "job": "Shgsg",
      "tel": "",
      "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/30/avatar.?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
      "department_name": "总裁办"
    },
    "title": "edsfsf",
    "customer": {
      "id": 29,
      "name": "weed",
      "name_pinyin": "weed",
      "user_id": 1,
      "user_name": "default",
      "contacts": [
        {
          "id": 18,
          "name": "111",
          "address": {
            "id": 1317,
            "tel": "",
            "phone": "",
            "qq": "",
            "lng": 0,
            "lat": 0,
            "detail_address": ""
          }
        }
      ],
      "company_name": "",
      "address": {
        "id": 1316,
        "tel": "1213123213",
        "phone": "",
        "qq": "",
        "lng": 0,
        "lat": 0,
        "detail_address": ""
      },
      "revisit_at": "2015-09-23T19:08:40.000+08:00",
      "is_own": true,
      "status": "10",
      "status_mapped": "成交",
      "category": "",
      "category_mapped": ""
    },
    "opportunity": {},
    "total_amount": "2132.0",
    "start_at": "2015-09-23",
    "end_at": "",
    "customer_signer": "",
    "our_signer": "",
    "special_terms": "",
    "received_payments_amount": "0.0",
    "attachments": "暂无附件",
    "unreceived_amount": 2132,
    "sn": "",
    "created_at": "2015-09-23 19:07",
    "updated_at": "2015-10-20 09:58",
    "sign_date": "",
    "times": "2015-09-23 - ",
    "times_display": "2015-09-23 - ",
    "checking_payments_amount": "0.0",
    "approve_status": "approved",
    "approve_deny_type": 0,
    "all_attachments": [],
    "owned_department": {
      "id": 1,
      "name": "总裁办"
    },
    "is_own": true,
    "text_asset_942b812b": "",
    "text_asset_b435f866": "number 1",
    "text_asset_98d7529c": null,
    "text_asset_b435f866_display": "number 1",
    "text_asset_98d7529c_display": null,
    "is_has_policy_for_assist_user": true
  }
}

转移给他人

HTTP Request

PUT /api/v2/contracts/:id/update_user(.:format)

URL Parameters

字段名 是否必填 描述
id true 这是合同,替换url的 :id
user_id true 这是 user_id

返回数据


{
  "code": 0,
  "data": {
    "id": 16,
    "category": "43",
    "category_mapped": "直销合同",
    "payment_type": "48",
    "payment_type_mapped": "支票",
    "status": "52",
    "status_mapped": "未开始",
    "organization_id": 1,
    "user": {
      "id": 1,
      "email": "test@qq.com",
      "created_at": "2015-06-09T15:46:06.000+08:00",
      "name": "default",
      "organization_id": 1,
      "phone": "",
      "role_id": 0,
      "workflow_state": "new",
      "job": "Shgsg",
      "tel": "",
      "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/30/avatar.?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
      "department_name": "总裁办"
    },
    "title": "edsfsf",
    "customer": {
      "id": 29,
      "name": "weed",
      "name_pinyin": "weed",
      "user_id": 1,
      "user_name": "default",
      "contacts": [
        {
          "id": 18,
          "name": "111",
          "address": {
            "id": 1317,
            "tel": "",
            "phone": "",
            "qq": "",
            "lng": 0,
            "lat": 0,
            "detail_address": ""
          }
        }
      ],
      "company_name": "",
      "address": {
        "id": 1316,
        "tel": "1213123213",
        "phone": "",
        "qq": "",
        "lng": 0,
        "lat": 0,
        "detail_address": ""
      },
      "revisit_at": "2015-09-23T19:08:40.000+08:00",
      "is_own": true,
      "status": "10",
      "status_mapped": "成交",
      "category": "",
      "category_mapped": ""
    },
    "opportunity": {},
    "total_amount": "2132.0",
    "start_at": "2015-09-23",
    "end_at": "",
    "customer_signer": "",
    "our_signer": "",
    "special_terms": "",
    "received_payments_amount": "0.0",
    "attachments": "暂无附件",
    "unreceived_amount": 2132,
    "sn": "",
    "created_at": "2015-09-23 19:07",
    "updated_at": "2015-10-20 09:58",
    "sign_date": "",
    "times": "2015-09-23 - ",
    "times_display": "2015-09-23 - ",
    "checking_payments_amount": "0.0",
    "approve_status": "approved",
    "approve_deny_type": 0,
    "all_attachments": [],
    "owned_department": {
      "id": 1,
      "name": "总裁办"
    },
    "is_own": true,
    "text_asset_942b812b": "",
    "text_asset_b435f866": "number 1",
    "text_asset_98d7529c": null,
    "text_asset_b435f866_display": "number 1",
    "text_asset_98d7529c_display": null
  }
}

合同提交审批

HTTP Request

POST /api/v2/contracts/submit_approval?id=:id

URL Parameters

字段名 是否必填 描述
id true 合同id

返回数据


{
  "code": 0,
  "data": {
    "id": 16,
    "category": "43",
    "category_mapped": "直销合同",
    "payment_type": "48",
    "payment_type_mapped": "支票",
    "status": "52",
    "status_mapped": "未开始",
    "organization_id": 1,
    "user": {
      "id": 1,
      "email": "test@qq.com",
      "created_at": "2015-06-09T15:46:06.000+08:00",
      "name": "default",
      "organization_id": 1,
      "phone": "",
      "role_id": 0,
      "workflow_state": "new",
      "job": "Shgsg",
      "tel": "",
      "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/30/avatar.?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
      "department_name": "总裁办"
    },
    "title": "edsfsf",
    "customer": {
      "id": 29,
      "name": "weed",
      "name_pinyin": "weed",
      "user_id": 1,
      "user_name": "default",
      "contacts": [
        {
          "id": 18,
          "name": "111",
          "address": {
            "id": 1317,
            "tel": "",
            "phone": "",
            "qq": "",
            "lng": 0,
            "lat": 0,
            "detail_address": ""
          }
        }
      ],
      "company_name": "",
      "address": {
        "id": 1316,
        "tel": "1213123213",
        "phone": "",
        "qq": "",
        "lng": 0,
        "lat": 0,
        "detail_address": ""
      },
      "revisit_at": "2015-09-23T19:08:40.000+08:00",
      "is_own": true,
      "status": "10",
      "status_mapped": "成交",
      "category": "",
      "category_mapped": ""
    },
    "opportunity": {},
    "total_amount": "2132.0",
    "start_at": "2015-09-23",
    "end_at": "",
    "customer_signer": "",
    "our_signer": "",
    "special_terms": "",
    "received_payments_amount": "0.0",
    "attachments": "暂无附件",
    "unreceived_amount": 2132,
    "sn": "",
    "created_at": "2015-09-23 19:07",
    "updated_at": "2015-10-20 09:58",
    "sign_date": "",
    "times": "2015-09-23 - ",
    "times_display": "2015-09-23 - ",
    "checking_payments_amount": "0.0",
    "approve_status": "approved",
    "approve_deny_type": 0,
    "all_attachments": [],
    "owned_department": {
      "id": 1,
      "name": "总裁办"
    },
    "is_own": true,
    "text_asset_942b812b": "",
    "text_asset_b435f866": "number 1",
    "text_asset_98d7529c": null,
    "text_asset_b435f866_display": "number 1",
    "text_asset_98d7529c_display": null
  }
}

合同审批通过接口

HTTP Request

PUT /api/v2/contracts/:id/approve

URL Parameters

字段名 是否必填 描述
id true 合同id,url的:id 替换成id
contract[step] true 当前审批的层级(need_approve_step)
contract[approve_description] false 合同通过原因
contract[notify_user_ids] false 提醒他人用户id集合

返回数据

{
  "code": 0,
  "data": {
    "id": 2013,
    "category": "24",
    "category_mapped": "直销合同",
    "payment_type": "29",
    "payment_type_mapped": "支票",
    "status": "38",
    "status_mapped": "意外终止",
    "organization_id": 1,
    "step": 1,
    "user": {
      "id": 1,
      "email": "test@qq.com",
      "created_at": "2014-07-23T18:43:54.000+08:00",
      "name": "ifool",
      "organization_id": 1,
      "phone": "15821940127",
      "role_id": 1023,
      "workflow_state": "organization_owner",
      "job": " 我们自己",
      "tel": "45874554",
      "gender": "male",
      "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/7189/bower-logo.png?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient"
    },
    "title": "草稿合同",
    "customer": {
      "id": 50532,
      "name": "张三李四",
      "name_pinyin": "zhangsanlisi",
      "user_id": 1419,
      "user_name": "yuan.y",
      "contacts": [],
      "company_name": "",
      "address": {
        "id": 101318,
        "tel": "",
        "phone": "",
        "qq": "",
        "lng": 0.0,
        "lat": 0.0
      },
      "revisit_at": "",
      "is_own": true,
      "status": "528",
      "status_mapped": "成交",
      "category": "1",
      "category_mapped": "潜在客户"
    },
    "opportunity": {},
    "total_amount": "88.0",
    "start_at": "2015-08-17",
    "end_at": "2015-08-27",
    "customer_signer": "",
    "our_signer": "",
    "special_terms": "",
    "received_payments_amount": "0.0",
    "attachments": "1个附件",
    "unreceived_amount": 88.0,
    "sn": "",
    "created_at": "2015-08-17 16:13",
    "updated_at": "2015-08-25 19:28",
    "sign_date": "",
    "times": "2015-08-17 - 2015-08-27",
    "times_display": "2015-08-17 - 2015-08-27",
    "checking_payments_amount": "0.0",
    "approve_status": "approved",
    "approve_deny_type": 0,
    "all_attachments": [{
      "id": 3064,
      "name": "fontawesome-webfont_(2).woff",
      "attachmentable_id": 2013,
      "attachmentable_type": "Contract",
      "created_at": "2015-05-19T17:45:37.000+08:00",
      "updated_at": "2015-10-03T10:13:53.000+08:00",
      "file_file_name": "fontawesome-webfont_(2).woff",
      "file_content_type": "application/octet-stream",
      "file_file_size": 83760,
      "file_updated_at": "2015-05-19T17:45:37.000+08:00",
      "user_id": 1,
      "organization_id": 1,
      "deleted_at": null,
      "note": null,
      "sub_type": null,
      "attachment_position": null,
      "qiniu_persistent_id": null,
      "file_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/3064/fontawesome-webfont_%282%29.woff"
    }],
    "owned_department": {
      "id": 6,
      "name": "销售部"
    },
    "is_own": true
  }
}

合同审批否决接口

否决和驳回都调用该接口

HTTP Request

PUT /api/v2/contracts/:id/reject

URL Parameters

字段名 是否必填 描述
id true 合同id,url的:id 替换成id
contract[step] false 驳回时step为空,否决时step必填,step代表当前需要否决的层级(need_approve_step)
contract[approve_description] true 否决或驳回原因

返回数据

{
  "code": 0,
  "data": {
    "id": 2013,
    "category": "24",
    "category_mapped": "直销合同",
    "payment_type": "29",
    "payment_type_mapped": "支票",
    "status": "38",
    "status_mapped": "意外终止",
    "organization_id": 1,
    "user": {
      "id": 1,
      "email": "test@qq.com",
      "created_at": "2014-07-23T18:43:54.000+08:00",
      "name": "ifool",
      "organization_id": 1,
      "phone": "15821940127",
      "role_id": 1023,
      "workflow_state": "organization_owner",
      "job": " 我们自己",
      "tel": "45874554",
      "gender": "male",
      "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/7189/bower-logo.png?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient"
    },
    "title": "草稿合同",
    "customer": {
      "id": 50532,
      "name": "张三李四",
      "name_pinyin": "zhangsanlisi",
      "user_id": 1419,
      "user_name": "yuan.y",
      "contacts": [],
      "company_name": "",
      "address": {
        "id": 101318,
        "tel": "",
        "phone": "",
        "qq": "",
        "lng": 0.0,
        "lat": 0.0
      },
      "revisit_at": "",
      "is_own": true,
      "status": "528",
      "status_mapped": "成交",
      "category": "1",
      "category_mapped": "潜在客户"
    },
    "opportunity": {},
    "total_amount": "88.0",
    "start_at": "2015-08-17",
    "end_at": "2015-08-27",
    "customer_signer": "",
    "our_signer": "",
    "special_terms": "",
    "received_payments_amount": "0.0",
    "attachments": "1个附件",
    "unreceived_amount": 88.0,
    "sn": "",
    "created_at": "2015-08-17 16:13",
    "updated_at": "2015-08-25 19:28",
    "sign_date": "",
    "times": "2015-08-17 - 2015-08-27",
    "times_display": "2015-08-17 - 2015-08-27",
    "checking_payments_amount": "0.0",
    "approve_status": "approved",
    "approve_deny_type": 0,
    "all_attachments": [{
      "id": 3064,
      "name": "fontawesome-webfont_(2).woff",
      "attachmentable_id": 2013,
      "attachmentable_type": "Contract",
      "created_at": "2015-05-19T17:45:37.000+08:00",
      "updated_at": "2015-10-03T10:13:53.000+08:00",
      "file_file_name": "fontawesome-webfont_(2).woff",
      "file_content_type": "application/octet-stream",
      "file_file_size": 83760,
      "file_updated_at": "2015-05-19T17:45:37.000+08:00",
      "user_id": 1,
      "organization_id": 1,
      "deleted_at": null,
      "note": null,
      "sub_type": null,
      "attachment_position": null,
      "qiniu_persistent_id": null,
      "file_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/3064/fontawesome-webfont_%282%29.woff"
    }],
    "owned_department": {
      "id": 6,
      "name": "销售部"
    },
    "is_own": true
  }
}

合同审批撤销接口

HTTP Request

PUT /api/v2/contracts/:id/revert

URL Parameters

字段名 是否必填 描述
id true 合同id,url的:id 替换成id
contract[approve_description] true 撤销原因

返回数据

{
  "code": 0,
  "data": {
    "id": 2013,
    "category": "24",
    "category_mapped": "直销合同",
    "payment_type": "29",
    "payment_type_mapped": "支票",
    "status": "38",
    "status_mapped": "意外终止",
    "organization_id": 1,
    "user": {
      "id": 1,
      "email": "test@qq.com",
      "created_at": "2014-07-23T18:43:54.000+08:00",
      "name": "ifool",
      "organization_id": 1,
      "phone": "15821940127",
      "role_id": 1023,
      "workflow_state": "organization_owner",
      "job": " 我们自己",
      "tel": "45874554",
      "gender": "male",
      "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/7189/bower-logo.png?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient"
    },
    "title": "草稿合同",
    "customer": {
      "id": 50532,
      "name": "张三李四",
      "name_pinyin": "zhangsanlisi",
      "user_id": 1419,
      "user_name": "yuan.y",
      "contacts": [],
      "company_name": "",
      "address": {
        "id": 101318,
        "tel": "",
        "phone": "",
        "qq": "",
        "lng": 0.0,
        "lat": 0.0
      },
      "revisit_at": "",
      "is_own": true,
      "status": "528",
      "status_mapped": "成交",
      "category": "1",
      "category_mapped": "潜在客户"
    },
    "opportunity": {},
    "total_amount": "88.0",
    "start_at": "2015-08-17",
    "end_at": "2015-08-27",
    "customer_signer": "",
    "our_signer": "",
    "special_terms": "",
    "received_payments_amount": "0.0",
    "attachments": "1个附件",
    "unreceived_amount": 88.0,
    "sn": "",
    "created_at": "2015-08-17 16:13",
    "updated_at": "2015-08-25 19:28",
    "sign_date": "",
    "times": "2015-08-17 - 2015-08-27",
    "times_display": "2015-08-17 - 2015-08-27",
    "checking_payments_amount": "0.0",
    "approve_status": "approved",
    "approve_deny_type": 0,
    "all_attachments": [{
      "id": 3064,
      "name": "fontawesome-webfont_(2).woff",
      "attachmentable_id": 2013,
      "attachmentable_type": "Contract",
      "created_at": "2015-05-19T17:45:37.000+08:00",
      "updated_at": "2015-10-03T10:13:53.000+08:00",
      "file_file_name": "fontawesome-webfont_(2).woff",
      "file_content_type": "application/octet-stream",
      "file_file_size": 83760,
      "file_updated_at": "2015-05-19T17:45:37.000+08:00",
      "user_id": 1,
      "organization_id": 1,
      "deleted_at": null,
      "note": null,
      "sub_type": null,
      "attachment_position": null,
      "qiniu_persistent_id": null,
      "file_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/3064/fontawesome-webfont_%282%29.woff"
    }],
    "owned_department": {
      "id": 6,
      "name": "销售部"
    },
    "is_own": true
  }
}

更新提醒他人

HTTP Request

PUT /api/v2/contracts/:id/update_notify_users

URL Parameters

字段名 是否必填 描述
id true 这是 id
contract[notify_user_ids] true 用户id集合,数据类型为Array

返回数据

{
  "code": 0
  "data": {
    "notify_users": []
  }
}

审批流程详细信息

HTTP Request

GET /api/v2/contracts/:id/approves

URL Parameters

字段名 是否必填 描述
id true 这是 id

返回数据字段说明(data)

字段名 描述
approve_status 合同当前状态
notify_users 提醒他人用户信息
step 合同当前层级
submit_applying_at 合同提交时间
user 合同提交人
approves 多级审批所有步骤信息集合

data[approves]字段具体说明

字段名 描述
version_code <= 3.13,i代表数组索引
data[approves][i][step] 审批的层级
data[approves][i][approve_users] 层级允许审批的用户
data[approves][i][status] 审批状态
data[approves][i][user] 审批的用户
data[approves][i][user_id] 审批的用户id
data[approves][i][approve_at] 审批时间
version_code > 3.13
data[approves][i][step] 审批的层级
data[approves][i][type] 类型:
{
    superior: 负责人主管
    specified: 指定用户(任意一人)
    specified_jointly: 指定用户(多人会签)
}
data[approves][i][approve_users] 层级允许审批的用户
data[approves][i][approves] 层级已经审批过的具体信息:
{
    user_name: 审批用户名称
    approve_at: 审批时间
}
data[approves][i][status] 审批状态:
{
    applying: 待审批
    approved: 审批通过
}

返回数据

{
  "code": 0
  "data": {
    "id": 1,
    "approve_status": "applying",
    "notify_users": [{id: 1, email: ''}],
    "step": 0,
    "submit_applying_at": "2016-11-29 09:37",
    "user": {id: 1, name: 'xxx'},
    "approves": [
      {
        "step": 1,
        "type": "specified",
        "approve_users": [
          {id: 1, name: 'xxx'}
        ],
        "approves": [
          {
            "id": 115,
            "user_id": 1,
            "step": 1,
            "status": "approved",
            "approve_at": "2017-04-12 15:59",
            "content": "ddd",
            "user_name": "lra"
          }
        ],
        "approve_at": "2017-04-12 15:59",
        "status": "applying"
        "user": {id: 1, email: ""}
        "user_id": 1
      }
    ]
  }
}

创建合同关联产品

HTTP Request

POST /api/v2/contracts/:id/product_assets(.:format)

URL Parameters

字段名 是否必填 描述
id true 这是 id
product_asset[product_id] true 这是 product_asset[product_id]
product_asset[quantity] true 这是 product_asset[quantity]
product_asset[recommended_unit_price] true 这是 product_asset[recommended_unit_price]

返回数据

{
  "code": 0
}

更新合同关联产品

HTTP Request

PUT /api/v2/contracts/:id/product_assets/:product_asset_id(.:format)

URL Parameters

字段名 是否必填 描述
id true 这是 id
product_asset_id true 这是 product_asset_id
product_asset[quantity] true 这是 product_asset[quantity]
product_asset[recommended_unit_price] true 这是 product_asset[recommended_unit_price]

返回数据

{
  "code": 0
}

删除合同关联产品

HTTP Request

DELETE /api/v2/contracts/:id/product_assets/:product_asset_id(.:format)

URL Parameters

字段名 是否必填 描述
id true 这是 id
product_asset_id true 这是 product_asset_id

返回数据

{
  "code": 0
}

合同销售动态

HTTP Request

GET /api/v2/contracts/:id/sales_activities

URL Parameters

字段名 是否必填 描述
id true 合同的 id,替换掉url的:id

返回数据:

{
  "code": 0,
  "data": {
    / 按日期分组的销售动态json数据,日期格式:YYYY-MM-DD
    "sales_activities": [{
      "date":"2015-09-22",
      "activities": [{
        "id": 139249,
        "user": {
          "id": 1,
          "email": "test@qq.com",
          "created_at": "2014-07-23T18:43:54.000+08:00",
          "name": "ifool",
          "organization_id": 1,
          "phone": "15821940120",
          "role_id": 1023,
          "workflow_state": "organization_owner",
          "job": " 我们自己",
          "tel": "45874554",
          "gender": "male",
          "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/7189/bower-logo.png?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
          "confirmed_phone_at": ""
        },
        "title": "IKCRM_contracts_20150922.xlsx", / 销售动态标题
        "timestamp": "2015-09-22 16:22",
        "description": "新增附件 IKCRM_contracts_20150922.xlsx", / 销售动态描述
        "comments_count": 0, / 销售动态评论数
        "refer_type_display": "客户",
        "comments": [], / 销售动态评论
        "refer_type": "Customer",
        "refer_name": "客户-联系人2",
        "refer_id": 50535,
        "attachments": [],
        "address": {},
        "remind_at": "",
        "remind_at_display": "",
        "saleable_name": "IKCRM_contracts_20150922.xlsx",
        "saleable_id": 7226,
        "saleable_type": "Attachment",
        "saleable_type_display": "文件附件",
        "activity_type_display": "更新",
        "activity_type": "update",
        "audios": [],
        "app": "",
        "created_at": ""
      }]}, ...]
    },
    "total_count": 38,
    "per_page": 15,
    "page": 1
  }
}

合同tab页数量

HTTP Request

GET /api/v2/contracts/:id/util_counts

URL Parameters

字段名 是否必填 描述
id true contract 的 id,替换掉url的:id

返回数据:


{
  "code": 0,
  "data": [
    {
      "name": "activity" / 销售动态
    },
    {
      "name": "received_payment_plan", / 回款计划
      "count": 0
    },
    {
      "name": "received_payment", / 合同回款
      "count": 0
    },
    {
      "name": "product", / 产品
      "count": 0
    },
    {
      "name": "attachment", / 附件
      "count": 0
    }
  ]
}

协作人列表

HTTP Request

GET /api/v2/contracts/:id/assist_users

URL Parameters

字段名 是否必填 描述
id true 这是 合同id, 替换url里的 :id
query false name查询
page false 这是 page
per_page false 这是 per_page

返回数据


{
  "code": 0,
  "data": {
    "assist_users": [
      {
        "id": 2,
        "email": "wp@qq.com",
        "created_at": "2015-06-10T11:06:45.000+08:00",
        "name": "test",
        "organization_id": 1,
        "phone": "15921076830",
        "role_id": 0,
        "workflow_state": "organization_staff",
        "job": "",
        "tel": "",
        "avatar_url": "/localhost:3000/assets/male.jpg",
        "department_name": "销售部"
      }
    ],
    "total_count": 2,
    "per_page": 1,
    "page": 1
  }
}

添加协作人

HTTP Request

PUT /api/v2/contracts/:id/update_assist_user

URL Parameters

字段名 是否必填 描述
id true 这是 合同id, 替换url里的 :id
contract[assist_user_ids] true 用户id数组

返回数据


{
  "code": 0
}

创建合同

HTTP Request

POST /api/v2/contracts

URL Parameters

字段名 是否必填 描述
contract[approve_status] true 合同审批状态 必填项. 审批状态(applying, approved),开启审批填写 审批状态 applying, 未开启填写 approved
contract[title] true 合同标题
contract[sn] true 合同编号
contract[user_id] false 负责人id
contract[opportunity_id] false 商机id
contract[customer_id] true 客户id
contract[total_amount] false 总金额
contract[start_at] true 开始时间
contract[end_at] true 结束时间
contract[category] false 类别, 调用 GET /api/v2/field_maps/contract 获取对应的值
contract[payment_type] false 付款方式 调用 GET /api/v2/field_maps/contract 获取对应的值
contract[customer_signer] false 客户签约人( 例如 小七)
contract[our_signer] false 我方签约人( 例如 小强)
contract[sign_date] false 签约日期
contract[status] false 合同状态 调用 GET /api/v2/field_maps/contract 获取对应的值
contract[special_terms] false 特别条款
contract[want_department_id] false 所属部门
contract[attachments_attributes] false 附件
contract[product_assets_attributes] false 关联产品
contract[received_payment_plans_attributes] false 关联回款计划
contract_action_name false 当值为 turn_to_contract 商机转合同

返回数据

{
    "code":0,
    "data":{
        "id":18,
        "category":"43",
        "category_mapped":"直销合同",
        "payment_type":"48",
        "payment_type_mapped":"支票",
        "status":"52",
        "status_mapped":"未开始",
        "organization_id":1,
        "user":{
            "id":26,
            "email":"",
            "created_at":"2016-02-24T17:15:09.000+08:00",
            "name":"User 25",
            "organization_id":1,
            "phone":"13000000026",
            "role_id":0,
            "workflow_state":"new",
            "job":"",
            "tel":"",
            "avatar_url":"/localhost:3000/assets/male.jpg",
            "department_name":""
        },
        "title":"test",
        "customer":{
            "id":19,
            "name":"customer_19",
            "name_pinyin":"customer",
            "user_id":26,
            "user_name":"User 25",
            "contacts":[

            ],
            "company_name":"",
            "address":{
                "id":19,
                "tel":"",
                "phone":"",
                "qq":"",
                "lng":0,
                "lat":0,
                "detail_address":"",
                "off_distance":0,
                "gaode_staticmap":"",
                "full_address":""
            },
            "revisit_at":"",
            "is_own":true,
            "status":"7",
            "status_mapped":"初访",
            "category":"",
            "category_mapped":""
        },
        "opportunity":{
        },
        "total_amount":"122.0",
        "start_at":"2016-02-24",
        "end_at":"",
        "customer_signer":"",
        "our_signer":"",
        "special_terms":"",
        "received_payments_amount":"0.0",
        "attachments":"暂无附件",
        "unreceived_amount":122,
        "sn":"",
        "created_at":"2016-02-24 17:15",
        "updated_at":"2016-02-24 17:15",
        "sign_date":"",
        "times":"2016-02-24 - ",
        "times_display":"2016-02-24 - ",
        "checking_payments_amount":"0.0",
        "approve_status":"approved",
        "approve_deny_type":0,
        "all_attachments":[

        ],
        "owned_department":{

        },
        "is_own":true
    }
}

更新合同

HTTP Request

PUT /api/v2/contracts/:id

URL Parameters

字段名 是否必填 描述
id true 替换url里面的 :id
contract[approve_status] true 合同审批状态 必填项.
contract[title] true 标题
contract[user_id] false 负责人id
contract[customer_id] true 客户id
contract[total_amount] false 总金额
contract[start_at] true 开始时间
contract[end_at] true 结束时间
contract[category] false 类别, 调用 GET /api/v2/field_maps/contract 获取对应的值
contract[payment_type] false 付款方式 调用 GET /api/v2/field_maps/contract 获取对应的值
contract[customer_signer] false 客户签约人( 例如 小七)
contract[our_signer] false 我方签约人( 例如 小强)
contract[status] false 合同状态 调用 GET /api/v2/field_maps/contract 获取对应的值
contract[special_terms] false 特别条款
contract[want_department_id] false 所属部门
contract[attachments_attributes] false 附件
contract[product_assets_attributes] false 关联产品
contract[received_payment_plans_attributes] false 关联回款计划

返回数据

{
    "code":0,
    "data":{
        "id":18,
        "category":"43",
        "category_mapped":"直销合同",
        "payment_type":"48",
        "payment_type_mapped":"支票",
        "status":"52",
        "status_mapped":"未开始",
        "organization_id":1,
        "user":{
            "id":26,
            "email":"",
            "created_at":"2016-02-24T17:15:09.000+08:00",
            "name":"User 25",
            "organization_id":1,
            "phone":"13000000026",
            "role_id":0,
            "workflow_state":"new",
            "job":"",
            "tel":"",
            "avatar_url":"/localhost:3000/assets/male.jpg",
            "department_name":""
        },
        "title":"test",
        "customer":{
            "id":19,
            "name":"customer_19",
            "name_pinyin":"customer",
            "user_id":26,
            "user_name":"User 25",
            "contacts":[

            ],
            "company_name":"",
            "address":{
                "id":19,
                "tel":"",
                "phone":"",
                "qq":"",
                "lng":0,
                "lat":0,
                "detail_address":"",
                "off_distance":0,
                "gaode_staticmap":"",
                "full_address":""
            },
            "revisit_at":"",
            "is_own":true,
            "status":"7",
            "status_mapped":"初访",
            "category":"",
            "category_mapped":""
        },
        "opportunity":{
        },
        "total_amount":"122.0",
        "start_at":"2016-02-24",
        "end_at":"",
        "customer_signer":"",
        "our_signer":"",
        "special_terms":"",
        "received_payments_amount":"0.0",
        "attachments":"暂无附件",
        "unreceived_amount":122,
        "sn":"",
        "created_at":"2016-02-24 17:15",
        "updated_at":"2016-02-24 17:15",
        "sign_date":"",
        "times":"2016-02-24 - ",
        "times_display":"2016-02-24 - ",
        "checking_payments_amount":"0.0",
        "approve_status":"approved",
        "approve_deny_type":0,
        "all_attachments":[

        ],
        "owned_department":{

        },
        "is_own":true
    }
}

合同 new 从商机来的

HTTP Request

GET /api/v2/contracts/new_from_opportunity

URL Parameters

字段名 是否必填 描述
opportunity_id true 商机id

返回数据


{
  "code": 0,
  "data": {
    "id": null,
    "category": "43",
    "category_mapped": "直销合同",
    "payment_type": "48",
    "payment_type_mapped": "支票",
    "status": "52",
    "status_mapped": "未开始",
    "organization_id": 1,
    "user": {
      "id": 1,
      "email": "test@qq.com",
      "created_at": "2015-06-09T15:46:06.000+08:00",
      "name": "default",
      "organization_id": 1,
      "phone": "",
      "role_id": 0,
      "workflow_state": "new",
      "job": "Shgsg",
      "tel": "",
      "avatar_url": "/localhost:3000/assets/male.jpg",
      "department_name": "总裁办"
    },
    "title": "1111111111111111111111111111111111111111111111",
    "customer": {
      "id": 29,
      "name": "weed",
      "name_pinyin": "weed",
      "user_id": 1,
      "user_name": "default",
      "contacts": [
        {
          "id": 18,
          "name": "111",
          "address": {
            "id": 1317,
            "tel": "",
            "phone": "",
            "qq": "",
            "email": "",
            "lng": 0,
            "lat": 0,
            "detail_address": "",
            "off_distance": -1,
            "gaode_staticmap": "",
            "full_address": ""
          }
        }
      ],
      "company_name": "",
      "address": {
        "id": 1316,
        "tel": "1213123213",
        "phone": "",
        "qq": "",
        "email": "",
        "lng": 0,
        "lat": 0,
        "detail_address": "",
        "off_distance": -1,
        "gaode_staticmap": "",
        "full_address": "中国 "
      },
      "revisit_at": "2016-05-27T10:52:08.000+08:00",
      "is_own": true,
      "status": "10",
      "status_mapped": "成交",
      "category": "",
      "category_mapped": "",
      "qixinbao_id": "",
      "created_at": "2015-09-10 10:37"
    },
    "opportunity": {
    },
    "total_amount": "11111.0",
    "start_at": "2016-05-27",
    "end_at": null,
    "customer_signer": null,
    "our_signer": null,
    "special_terms": "",
    "received_payments_amount": 0,
    "attachments": "暂无附件",
    "unreceived_amount": 11111,
    "sn": null,
    "created_at": "",
    "updated_at": "",
    "sign_date": "",
    "times": "2016-05-27 - ",
    "times_display": "2016-05-27 - ",
    "checking_payments_amount": 0,
    "approve_status": "applying",
    "approve_status_i18n": "待审批",
    "approve_deny_type": 0,
    "all_attachments": [],
    "owned_department": {},
    "is_own": true,
    "is_has_policy_for_assist_user": false,
    "is_my_assist_entity": false,
    "product_assets": "折叠旅行双肩包2",
    "product_assets_for_new_record": [
          {
            "id": 0,
            "quantity": 1,
            "product": {
              "id": 3,
              "name": "折叠旅行双肩包2",
              "product_no": "1151600032",
              "category": null,
              "category_mapped": null,
              "standard_unit_price": "61.0",
              "sale_unit": "个",
              "introduction": "折叠前43*31*14CM(折叠后21.5*27*4CM)",
              "attachment": {},
              "gross_margin": 0,
              "unit_cost": 22,
              "created_at": "2015-06-11 16:01",
              "updated_at": "2015-06-11 16:01",
              "is_edit": true,
              "product_category": {
                "id": 1,
                "name": "默认分类",
                "self_and_parents_name": "默认分类",
                "product_count": 0
              },
              "text_asset_85293fd0": null,
              "text_asset_85293fd0_display": null
            },
            "standard_unit_price": "61.0",
            "total_price": "61.0",
            "sale_unit": "个",
            "discount": "100.0%",
            "recommended_unit_price": "61.0",
            "remark": ""
          }
        ],
    "text_asset_942b812b": null,
    "text_asset_b435f866": null,
    "text_asset_98d7529c": null,
    "text_asset_2c0199eb": null,
    "text_asset_b435f866_display": null,
    "text_asset_98d7529c_display": null,
    "before_user": null,
    "before_owned_department": null,
    "creator": null
  }
}

全景

HTTP Request

GET /api/v2/contract/:id/panorama

URL Parameters

字段名 是否必填 描述
id true lead 的 id,替换掉url的:id

返回数据字段说明

字段名 描述
attachments_count 合同详情附件数
file_attachments_count 合同tab附件数

返回数据:

{
  "code": 0,
  "data": {
    "contract": {
      "id": 24,
      "title": "xdscxzczasxc",
      "total_amount": "111111.0",
      "status": "54",
      "status_mapped": "成功结束",
      "date_str": "2015-12-05~",
      "customer_id": "test_6_20",
      "customer_name": 34,
      "reminders_count": 1
    },
    "revisit_logs": {},
    "products": {
      "count": 1,
      "details": [
        {
          "name": "折叠旅行双肩包2",
          "product_no": "1151600032"
        }
      ]
    },
    "received_payments": {
      "count": 0,
      "plan_amount": "Â¥ 0.00",
      "amount": "Â¥ 0.00",
      "total_amount": "Â¥ 0.00",
      "total_unreceived_amount": "Â¥ 111,111.00"
    },
    "sales_team": {
      "own_department": "总裁办",
      "user": "default",
      "assist_users": "暂无协作人"
    },
    "other": {
      "attachment_count": 0,
      "operation_log_count": 3
    }
  }
}

销售团队

HTTP Request

GET /api/v2/contracts/:id/sales_team

URL Parameters

字段名 是否必填 描述
id true contract 的 id,替换掉url的:id

返回数据:


{
  "code": 0,
  "data": {
    "own_department": "销售部",
    "user": {
      "id": 2,
      "email": "wp@qq.com",
      "created_at": "2015-06-10T11:06:45.000+08:00",
      "name": "test2",
      "organization_id": 1,
      "phone": "15921076830",
      "role_id": 0,
      "workflow_state": "new",
      "job": "",
      "tel": "",
      "avatar_url": "/localhost:3000/assets/male.jpg",
      "department_name": "销售部"
    },
    "assist_users": []
  }
}

C自定义业务

自定义业务列表

HTTP Request

GET /api/v2/custom_features

URL Parameters

字段名 是否必填 描述

返回数据


{
    "code": 0,
    "custom_features": {
        "lead": {
            "class_name": "Lead",
            "origin_label": "线索",
            "label": "线索",
            "enabled": true
        },
        "customer": {
            "class_name": "Customer",
            "origin_label": "客户",
            "label": "客户",
            "enabled": true
        },
        "customer_common": {
            "class_name": "CustomerCommon",
            "origin_label": "客户公海",
            "label": "客户公海",
            "enabled": true
        },
        "contact": {
            "class_name": "Contact",
            "origin_label": "联系人",
            "label": "联系人",
            "enabled": true
        },
        "opportunity": {
            "class_name": "Opportunity",
            "origin_label": "商机",
            "label": "商机",
            "enabled": true
        },
        "contract": {
            "class_name": "Contract",
            "origin_label": "合同",
            "label": "合同",
            "enabled": true
        },
        "product": {
            "class_name": "Product",
            "origin_label": "产品",
            "label": "产品",
            "enabled": true
        },
        "schedule_report": {
            "class_name": "ScheduleReport",
            "origin_label": "工作报告",
            "label": "工作报告",
            "enabled": true
        },
        "schedule_report_daily": {
            "class_name": "ScheduleReport::Daily",
            "origin_label": "日报",
            "label": "日报",
            "enabled": true
        },
        "schedule_report_weekly": {
            "class_name": "ScheduleReport::Weekly",
            "origin_label": "周报",
            "label": "周报",
            "enabled": false
        },
        "schedule_report_monthly": {
            "class_name": "ScheduleReport::Monthly",
            "origin_label": "月报",
            "label": "月报",
            "enabled": false
        }
    }
}


C自定义字段接口

详情列表字段(全部返回)

HTTP Request

GET /api/v2/custom_fields/by_group_all

返回数据:

{
  "code": 0,
  "data": {
    "product": [
      {
        "id": 9,
        "label": "基本信息",
        "position": 1,
        "status": "enable",
        "custom_field_setting_id": 3,
        "custom_fields": [
          {
            "id": 51,
            "name": "customer",
            "label": "对应客户", # 标签
            "field_type": "select2_field", # select
            "category": "common", #类型
            "position": 2, #位置
            "label_html_options": {},
            "custom_column_name": "customer.name", # 列名
            "input_field_options": {}, # 选项
            "status": "enable", #是否可用
            "required": true, #是否必填
            "cannot_edit": false # 为true则不能编辑
          }
        ]
      }
    ]
    "customer": [
      {
        "id": 9,
        "label": "基本信息",
        "position": 1,
        "status": "enable",
        "custom_field_setting_id": 3,
        "custom_fields": [
          {
            "id": 51,
            "name": "customer",
            "label": "对应客户", # 标签
            "field_type": "select2_field", # select
            "category": "common", #类型
            "position": 2, #位置
            "label_html_options": {},
            "custom_column_name": "customer.name", # 列名
            "input_field_options": {}, # 选项
            "status": "enable", #是否可用
            "required": true, #是否必填
            "cannot_edit": false # 为true则不能编辑
          }
        ]
      }
    ]
  }
}

详情列表字段(单个返回)

HTTP Request

GET /api/v2/custom_fields/:entity_type/by_group

URL Parameters

字段名 是否必填 描述
entity_type true 实体名(customer,contact,contract,lead,opportunity,product, schedule_report, received_payment expense)
cycle false schedule_report 的时候需要传(daily weekly monthly)
custom_field_template_id false 业务模版的id

返回数据字段说明

字段名 描述
custom_fields[i][input_field_options] regular: 数字、空格、加号及中划线, onlyNum: 数字, only11Num: 11位数字

返回数据:

{
  "code": 0,
  "data": {
    "custom_field_groups": [
      {
        "id": 9,
        "label": "基本信息",
        "position": 1,
        "status": "enable",
        "custom_field_setting_id": 3,
        "custom_fields": [
          {
            "id": 51,
            "name": "customer",
            "label": "对应客户", # 标签
            "field_type": "select2_field", # select
            "category": "common", #类型
            "position": 2, #位置
            "label_html_options": {},
            "custom_column_name": "customer.name", # 列名
            "input_field_options": {}, # 选项
            "status": "enable", #是否可用
            "required": true, #是否必填
            "cannot_edit": false # 为true则不能编辑
          }
        ]
      }
    ]
  }
}

创建自定义字段

HTTP Request

POST /api/v2/custom_fields

filed_type(字段类型)说明

值 描述
text_field 文本
integer_field 整数
float_field 小数
datetime_field 时间
select 单选下拉列表
custom_field_group 区块

URL Parameters

字段名 是否必填 描述
custom_field_setting_id true 自定义字段设置id
custom_field[label] true 自定义字段名称
custom_field[field_type] true 自定义字段类型
custom_field[category] false 内置类型,可选值: common, uncommon, system
custom_field[required] false 是否必填,可选值: true, false
custom_field[position] false 排序位置,整数
custom_field[select_options] false 下拉选项数组,field_type为select时,该字段需要传值
custom_field[status] false 是否启用, enable: 是,disable: 否, 默认enable

返回数据:

{
  "code": 0,
  "data": {
    "id": 1,
    "name": "name",
    "label": "客户名称",
    "field_type": "text_field",
    "category": "common",
    "position": 1,
    "label_html_options": {},
    "custom_column_name": "name",
    "input_field_options": {},
    "status": "enable",
    "required": true,
    "cannot_edit": false,
    "is_special_column": true
  }
}

更新自定义字段

HTTP Request

PUT /api/v2/custom_fields/:id

URL Parameters

字段名 是否必填 描述
custom_field_setting_id true 自定义字段设置id
id true 自定义字段id
custom_field[label] false 自定义字段名称
custom_field[field_type] false 自定义字段类型
custom_field[category] false 内置类型,可选值: common, uncommon, system
custom_field[required] false 是否必填,可选值: true, false
custom_field[position] false 排序位置,整数
custom_field[select_options] false 下拉选项数组,field_type为select时,该字段需要传值
custom_field[status] false 是否启用, enable: 是,disable: 否, 默认enable

返回数据:

{
  "code": 0,
  "data": {
    "id": 1,
    "name": "name",
    "label": "客户名称",
    "field_type": "text_field",
    "category": "common",
    "position": 1,
    "label_html_options": {},
    "custom_column_name": "name",
    "input_field_options": {},
    "status": "enable",
    "required": true,
    "cannot_edit": false,
    "is_special_column": true
  }
}

自定义字段排序

HTTP Request

PUT /api/v2/custom_field_groups/:id

URL Parameters

字段名 是否必填 描述
custom_field_setting_id true 自定义字段设置id
custom_field_group[custom_field_attributes][0][id] false 自定义字段id
custom_field_group[custom_field_attributes][0][position] false 排序位置,整数
custom_field_group[custom_field_attributes][1][id] false 自定义字段id
custom_field_group[custom_field_attributes][1][position] false 排序位置,整数
custom_field_group[custom_field_attributes][n][id] false 排序位置,整数
custom_field_group[custom_field_attributes][n][position] false 排序位置,整数

返回数据:

{
  "code": 0,
  "data": {
    "id": 1,
    "name": "name",
    "label": "客户名称",
    "field_type": "text_field",
    "category": "common",
    "position": 1,
    "label_html_options": {},
    "custom_column_name": "name",
    "input_field_options": {},
    "status": "enable",
    "required": true,
    "cannot_edit": false,
    "is_special_column": true
  }
}

自定义字段权限设置详情

HTTP Request

GET /api/v2/custom_fields/permission_setting

返回数据字段说明

字段名 描述
grant_scope all_data: 对所有数据生效, expect_self: 仅对负责人不是自己的数据生效
setting 包含客户和联系人的字段权限设置详情, customer: 客户, contact: 联系人
setting[entity][name] entity代表的模块(customer/contact)的自定义字段的name
setting[entity][status] entity代表的模块(customer/contact)的自定义字段是否可见, 1: 不可见, -1: 可见

返回数据


{
  "code": 0,
  "data": {
    "grant_scope": "all_data",
    "setting": {
      "customer": [
        {
          "name": "address.tel",
          "status": "1"
        },
        {
          "name": "address.fax",
          "status": "-1"
        },
        {
          "name": "address.url",
          "status": "-1"
        },
        {
          "name": "address.detail_address",
          "status": "-1"
        },
        {
          "name": "address.zip",
          "status": "-1"
        },
        {
          "name": "address.phone",
          "status": "-1"
        },
        {
          "name": "address.wechat",
          "status": "1"
        },
        {
          "name": "address.qq",
          "status": "1"
        },
        {
          "name": "address.wangwang",
          "status": "-1"
        },
        {
          "name": "address.email",
          "status": "-1"
        },
        {
          "name": "text_asset_120487e4",
          "status": "-1"
        },
        {
          "name": "text_asset_d8d81e8f",
          "status": "-1"
        },
        {
          "name": "text_asset_58e3f9a8",
          "status": "-1"
        },
        {
          "name": "text_asset_9a4b5806",
          "status": "-1"
        },
        {
          "name": "number",
          "status": "-1"
        },
        {
          "name": "beginning_payments_amount",
          "status": "-1"
        }
      ],
      "contact": [
        {
          "name": "text_asset_6b2c1b36",
          "status": "-1"
        },
        {
          "name": "text_asset_31639425",
          "status": "-1"
        },
        {
          "name": "text_asset_6a481548",
          "status": "-1"
        }
      ]
    }
  }
}

受限字段

HTTP Request

GET /api/v2/custom_fields/limited

返回数据字段说明

字段名 描述
field_permission_grant_scope 字段权限范围(all_data: 对所有数据生效, expect_self: 仅对负责人不是自己的数据生效)
invisible[lead] 线索不可见字段
invisible[customer] 客户不可见字段
invisible[contact] 联系人不可见字段
invisible[opportunity] 商机不可见字段
invisible[contract] 合同不可见字段
invisible[product] 产品不可见字段
approve_cannot_edit[customer] 客户审批通过或不允许编辑的字段
approve_cannot_edit[contract] 合同审批通过或不允许编辑的字段

返回数据:

{
  "code": 0,
  "data": {
    "field_permission_grant_scope": "all_data",
    "invisible": {
      "contact": [
        "address.phone",
        "text_asset_6b2c1b36"
      ],
      "customer": [
        "address.tel",
        "address.phone"
      ]
    },
    "approve_cannot_edit": {
      "customer": [
        "name",
        "category"
      ],
      "contract": [
        "title"
      ]
    }
  }
}

查询搜索字段

HTTP Request

GET /api/v2/custom_fields/query_fields

URL Parameters

字段名 是否必填 描述
entity_type true 实体名(customer opportunity contact contract lead product social_share expense expense_account customer_common)
custom_field_template_id false 业务模版id
common_id false 公海id

返回数据字段说明

字段名 描述
name 自定义字段名称
label 自定义字段label

返回数据:

{
    "code": 0,
    "data": {
        "query_fields": [
            {
                "label": "姓名",
                "name": "name"
            },
            {
                "label": "部门",
                "name": "department"
            },
            {
                "label": "手机",
                "name": "address.phone"
            },
            {
                "label": "电话",
                "name": "address.tel"
            },
            {
                "label": "微信号",
                "name": "address.wechat"
            },
            {
                "label": "phone",
                "name": "text_asset_57542b"
            }
        ]
    }
}

C客户模块接口

全部客户列表

HTTP Request

GET /api/v2/customers

URL Parameters

字段名 是否必填 参数类型 描述
page false Long 页码
per_page false Int 每页的数量
query false String 搜索关键字
custom_field_name false String 搜索字段
department_id false Long 部门id
sort false String 排序类型(created_at ), api/v2/customers/filter_sort_group 返回值中sorts的value
order false String 排序方式(asc desc)
tab_type false String 值为[my, sub, common, assist]或不传
user_id false Long 员工筛选
status false Long 状态, 值为 api/v2/customers/status/filter_options返回值
category false Long 分类
real_revisit_at false String 实际跟进时间
product_id false Long product筛选

返回数据字段说明

字段名 参数类型 描述
id Long 线索id
name String 姓名
company_name String 公司名称
status Long id
status_mapped String 状态名称
category Long 类别id
category_mapped String 类别名称
approve_status String 审批状态(applying: 待审批, rejected: 已驳回, approved: 已通过, reverted: 已撤销)
approve_status_i18n String 审批状态说明(待审批/已驳回/已通过/已撤销)
contacts Array 联系人数组
address[id] Long 地址id
address[addressable_id] Long 地址关联对象id
address[addressable_type] String 地址关联对象类型
address[country_id] Long 国家id
address[province_id] Long 省id
address[city_id] Long 城市id
address[district_id] Long 区域id
address[tel] String 电话
address[phone] String 手机
address[email] String 邮箱
address[qq] String qq
address[fax] String 传真
address[wechat] String 微信号
address[wangwang] String 旺旺
address[zip] String 邮编
address[url] String url
address[detail_address] String 地址详情
address[created_at] String 创建时间
address[updated_at] String 更新时间
address[lat] Float 纬度
address[lng] Float 经度
address[off_distance] Float 距离
address[region_info] String 区域信息
address[snippet] String 片区
address[tel_hidden_result] String 隐藏处理后电话
need_hidden_dispose Boolean 是否需要掩藏客户资料号码(用于呼叫中心)
is_user_self Boolean 是否是自己的线索
updated_at String 更新时间
created_at String 创建时间
wx_external_userid String 企业微信外部联系人userid
wx_contact_type String 企业微信外部联系人类型 wx_chat_work(企业微信), wx_chat(微信)

返回数据字段说明

字段名 描述
approve_status 审批状态(applying: 待审批, rejected: 已驳回, approved: 已通过, reverted: 已撤销)
approve_status_i18n 审批状态说明(待审批/已驳回/已通过/已撤销)

返回数据:

{
    "code": 0,
    "data": {
        "customers": [
            {
                "id": 82833,
                "name": "哀乐忧",
                "status": "3065",
                "status_mapped": "初访",
                "category": "",
                "category_mapped": "",
                "need_hidden_dispose": false,
                "updated_at": "2017-05-12 10:28",
                "approve_status": "approved",
                "approve_status_i18n": "已通过",
                "is_user_self": true,
                "wx_external_userid": "xxxx",
                "wx_contact_type": "wx_chat",
                "address": {
                    "id": 31,
                    "addressable_id": 82833,
                    "addressable_type": "Customer",
                    "country_id": null,
                    "province_id": null,
                    "city_id": null,
                    "district_id": null,
                    "tel": null,
                    "phone": null,
                    "email": null,
                    "qq": null,
                    "fax": null,
                    "wechat": null,
                    "wangwang": null,
                    "zip": null,
                    "url": null,
                    "detail_address": null,
                    "created_at": "2017-05-12T10:28:06.000+08:00",
                    "updated_at": "2017-05-12T10:28:06.000+08:00",
                    "lat": null,
                    "lng": null,
                    "off_distance": null,
                    "region_info": null,
                    "snippet": null,
                    "organization_id": null,
                    "tel_hidden_result": "",
                    "phone_hidden_result": ""
                },
                "contacts": []
            }
        ],
        "total_count": 33,
        "per_page": 15,
        "page": 1
    }
}

列出客户名

HTTP Request

GET /api/v2/customers/by_name

URL Parameters

字段名 是否必填 参数类型 描述
page false Long 页码
per_page false Int 每页的数量
query false String 搜索关键字
department_id false Long 部门id
sort false String 排序类型(created_at ), api/v2/customers/filter_sort_group 返回值中sorts的value
order false String 排序方式(asc desc)
user_id false Long 员工筛选
status false Long 状态, 值为 api/v2/customers/status/filter_options返回值
category false Long 分类
last_revisit_at false String 实际跟进时间
product_id false Long product筛选

返回数据:

{
    "code": 0,
    "data": {
        "customers": [
            {
                "id": 82833,
                "name": "哀乐忧",
                "status": "3065",
                "status_mapped": "初访",
                "category": "",
                "category_mapped": "",
                "need_hidden_dispose": false,
                "updated_at": "2017-05-12 10:28",
                "approve_status": "approved",
                "approve_status_i18n": "已通过",
                "is_user_self": true,
                "address": {
                    "id": 31,
                    "addressable_id": 82833,
                    "addressable_type": "Customer",
                    "country_id": null,
                    "province_id": null,
                    "city_id": null,
                    "district_id": null,
                    "tel": null,
                    "phone": null,
                    "email": null,
                    "qq": null,
                    "fax": null,
                    "wechat": null,
                    "wangwang": null,
                    "zip": null,
                    "url": null,
                    "detail_address": null,
                    "created_at": "2017-05-12T10:28:06.000+08:00",
                    "updated_at": "2017-05-12T10:28:06.000+08:00",
                    "lat": null,
                    "lng": null,
                    "off_distance": null,
                    "region_info": null,
                    "snippet": null,
                    "organization_id": null,
                    "tel_hidden_result": "",
                    "phone_hidden_result": ""
                },
                "contacts": []
            }
        ],
        "total_count": 33,
        "per_page": 15,
        "page": 1
    }
}

附近客户

HTTP Request

GET /api/v2/customers/nearby

URL Parameters

字段名 是否必填 参数类型 描述
page false Long 页码
per_page false Int 每页的数量
lat true Float 经度
lng true Float 纬度
bounds false Array 边界
scope false string 客户类型
common_id false Int 公海id

返回数据:

{
  "code": 0,
  "data": {
    "customers": [
      {
        "id": 2354,
        "name": "浙大网新科技股份有限公司",
        "user_id": 470,
        "status": "13398",
        "status_mapped": "成交",
        "address": {
          "id": 11756,
          "tel": "057189813202",
          "phone": ""
        },
        "contacts": [
          {
            "id": 1867,
            "name": "崔玉增",
            "user_id": 470,
            "category": "",
            "category_mapped": "",
            "gender": null,
            "customer_id": 2354,
            "gender_i18n": "",
            "is_own": true
          },
          {
            "id": 1943,
            "name": "胡伟",
            "user_id": 470,
            "category": "13428",
            "category_mapped": "评估者",
            "gender": "male",
            "customer_id": 2354,
            "gender_i18n": "男",
            "is_own": true
          }
        ]
      }
    ],
    "total_count": 1,
    "per_page": 15,
    "page": 1,
    "notice": ""
  }
}

附近协作客户

HTTP Request

GET /api/v2/customers/nearby_assist

URL Parameters

字段名 是否必填 描述
lat true 经度
lng true 纬度
page false 页码
per_page false 每页的数量
bounds false 边界

返回数据:

{
  "code": 0,
  "data": {
    "customers": [
      {
        "id": 2354,
        "name": "浙大网新科技股份有限公司",
        "user_id": 470,
        "status": "13398",
        "status_mapped": "成交",
        "address": {
          "id": 11756,
          "tel": "057189813202",
          "phone": ""
        },
        "contacts": [
          {
            "id": 1867,
            "name": "崔玉增",
            "user_id": 470,
            "category": "",
            "category_mapped": "",
            "gender": null,
            "customer_id": 2354,
            "gender_i18n": "",
            "is_own": true
          },
          {
            "id": 1943,
            "name": "胡伟",
            "user_id": 470,
            "category": "13428",
            "category_mapped": "评估者",
            "gender": "male",
            "customer_id": 2354,
            "gender_i18n": "男",
            "is_own": true
          }
        ]
      }
    ],
    "total_count": 1,
    "per_page": 15,
    "page": 1,
    "notice": ""
  }
}

附近客户+客户列表

HTTP Request

GET /api/v2/customers/nearby_and_index

URL Parameters

字段名 是否必填 描述
lat true 经度
lng true 纬度
distance true 距离
page false 页码
per_page false 每页的数量

返回数据:

{
  "code": 0,
  "data": {
    "nearby_customers": [
      {
        "id": 7,
        "name": "华谊兄弟11",
        "user_id": 1,
        "status": "7",
        "status_mapped": "初访",
        "address": {
          "id": 5,
          "country": {},
          "province": {},
          "city": {},
          "district": {},
          "tel": "010-65881997",
          "phone": "",
          "qq": "",
          "fax": "",
          "wechat": "",
          "wangwang": "",
          "zip": "",
          "url": "",
          "detail_address": "",
          "lat": 32,
          "lng": 121,
          "distance": "2.22m",
          "region_info": "",
          "off_distance": 0,
          "gaode_staticmap": "/restapi.amap.com/v3/staticmap?key=6336624d908c499cace3998613723a3a&location=121.0%2C32.0&markers=mid%2C%2CA%3A121.0%2C32.0&scale=2&size=524%2A180&zoom=16",
          "full_address": " "
        },
        "contacts": [],
        "customer_revisit_log_count": 2,
        "customer_revisit_log_last_at": "2015-06-17 16:44"
      }
    ],
    "customers": [
      {
        "id": 25,
        "name": "ddddsdfs",
        "name_pinyin": "ddddsdfs",
        "user_id": 1,
        "user_name": "default",
        "status": "7",
        "status_mapped": "初访",
        "company_name": "",
        "address": {
          "id": 1312,
          "tel": "12313123123",
          "phone": "",
          "qq": "",
          "lng": 0,
          "lat": 0,
          "detail_address": "",
          "off_distance": 0,
          "gaode_staticmap": "",
          "full_address": "中国 "
        }
      },
      {
        "id": 9,
        "name": "华谊兄弟13",
        "name_pinyin": "huayixiongdi13",
        "user_id": 1,
        "user_name": "default",
        "status": "7",
        "status_mapped": "初访",
        "company_name": "",
        "address": {
          "id": 31,
          "tel": "010-65882995",
          "phone": "13888888890",
          "qq": "88888890",
          "lng": 0,
          "lat": 0,
          "detail_address": "北京市朝阳区朝阳门外大街18号丰联广场A座第9层",
          "off_distance": 0,
          "gaode_staticmap": "",
          "full_address": " 北京市朝阳区朝阳门外大街18号丰联广场A座第9层"
        }
      }
    ],
    "total_count": 20,
    "per_page": 15,
    "page": 1,
    "notice": ""
  }
}

从公海抢客户

HTTP Request

POST /api/v2/customers/:id/take

URL Parameters

字段名 是否必填 描述
id true customer 的 id,替换掉url的:id

返回数据:


{
  "code": 0,
  "data": {
    "id": 18,
    "name": "贸易公司",
    "status": "7",
    "status_mapped": "初访",
    "note": "主营外贸销售,代理国外一线品牌",
    "category": "",
    "category_mapped": "",
    "source": "",
    "source_mapped": "",
    "industry": "",
    "industry_mapped": "",
    "staff_size": 0,
    "staff_size_display": "",
    "staff_size_mapped": "",
    "created_at": "2015-07-03 17:31",
    "updated_at": "2015-09-24 16:48",
    "is_own": true,
    "attachments": "暂无附件",
    "company_name": "",
    "text_asset_9320d8d7": "",
    "text_asset_22503a16": "",
    "numeric_asset_e2955b70": 123,
    "numeric_asset_8ea55cf0": 1.1,
    "address": {},
    "user": {},
    "owned_department": {
      "id": 2,
      "name": "销售部"
    }
  }
}

客户查重

HTTP Request

GET /api/v2/customers/search_duplicates

URL Parameters

字段名 是否必填 描述
page false 页码
per_page false 每页的数量
query true 查重字段

返回数据:

{
  "code": 0,
  "data": {
    "customers": [
      {
        "id": 6855,
        "name": "房管局看",
        "name_pinyin": "fangguanjukan",
        "user_id": 1290,
        "user_name": "管理员",
        "is_common": false,
        "is_own": true
      }
    ]
  },
  "total_count": 1206,
  "per_page": 1,
  "page": 1
}

客户转移他人

HTTP Request

PUT /api/v2/customers/:id/update_user

URL Parameters

字段名 是否必填 描述
id true customer 的 id,替换掉url的:id
user_id true transfer user id
transfer_contracts false 是否转合同
transfer_opportunities false 是否转商机

返回数据:


{
  "code": 0,
  "data": {
    "id": 18,
    "name": "贸易公司",
    "status": "7",
    "status_mapped": "初访",
    "note": "主营外贸销售,代理国外一线品牌",
    "category": "",
    "category_mapped": "",
    "source": "",
    "source_mapped": "",
    "industry": "",
    "industry_mapped": "",
    "staff_size": 0,
    "staff_size_display": "",
    "staff_size_mapped": "",
    "created_at": "2015-07-03 17:31",
    "updated_at": "2015-09-24 16:48",
    "is_own": true,
    "attachments": "暂无附件",
    "company_name": "",
    "text_asset_9320d8d7": "",
    "text_asset_22503a16": "",
    "numeric_asset_e2955b70": 123,
    "numeric_asset_8ea55cf0": 1.1,
    "address": { "Address模型" },
    "user": { "User模型" },
    "owned_department": {
      "id": 2,
      "name": "销售部"
    }
  }
}

客户转移到公海

HTTP Request

PUT /api/v2/customers/:id/turn_common

URL Parameters

字段名 是否必填 描述
id true customer 的 id,替换掉url的:id
common_id true 公海id

返回数据:


{
  "code": 0,
  "data": {
    "customers": [
      {
        "id": 2354,
        "name": "浙大网新科技股份有限公司",
        "user_id": 470,
        "status": "13398",
        "status_mapped": "成交",
        "address": {
          "id": 11756,
          "tel": "057189813202",
          "phone": ""
        },
        "contacts": [
          {
            "id": 1867,
            "name": "崔玉增",
            "user_id": 470,
            "category": "",
            "category_mapped": "",
            "gender": null,
            "customer_id": 2354,
            "gender_i18n": "",
            "is_own": true
          },
          {
            "id": 1943,
            "name": "胡伟",
            "user_id": 470,
            "category": "13428",
            "category_mapped": "评估者",
            "gender": "male",
            "customer_id": 2354,
            "gender_i18n": "男",
            "is_own": true
          }
        ]
      }
    ],
    "total_count": 1,
    "per_page": 15,
    "page": 1,
    "notice": ""
  }
}

附近客户筛选条件分组

HTTP Request

GET /api/v2/customers/filter_sort_group_of_nearby

返回数据:

{
  "code": 0,
  "data": {
    "filters": [
      {
        "label": "跟进状态",
        "field_name": "status",
        "filter_field_type": "select"
      },
      {
        "label": "最新跟进时间",
        "field_name": "last_revisit_at",
        "filter_field_type": "select"
      },
      {
        "label": "客户类型",
        "field_name": "category",
        "filter_field_type": "select"
      },
      {
        "label": "产品筛选",
        "field_name": "product_id",
        "filter_field_type": "select"
      },
      {
        "label": "部门",
        "field_name": "department_id",
        "filter_field_type": "select",
        "filters": [
          {
            "label": "全部用户",
            "field_name": "user_id",
            "filter_field_type": "query_select"
          }
        ]
      }
    ],
    "sorts": [
      {
        "name": "sort",
        "label": "默认排序",
        "value": "",
        "order": ""
      },
      {
        "name": "sort",
        "label": "按客户名称顺序",
        "value": "name_pinyin",
        "order": "asc"
      },
      {
        "name": "sort",
        "label": "按跟进时间倒序",
        "value": "activity",
        "order": "desc"
      }
    ],
    "visible_tabs": [
      {
          "subject": "customer",
          "label": "全部客户",
          "value": "all_own"
      },
      {
          "subject": "customer",
          "label": "我的客户",
          "value": "my_own"
      },
      {
          "subject": "customer",
          "label": "下属客户",
          "value": "sub_own"
      },
      {
          "subject": "customer",
          "label": "我协作的客户",
          "value": "my_assist"
      },
      {
          "subject": "customer",
          "label": "我下属协作的客户",
          "value": "sub_assist"
      },
      {
          "subject": "customer",
          "label": "公海No01",
          "value": "common",
          "common_id": 1
      },
      {
          "subject": "customer",
          "label": "公海No02",
          "value": "common",
          "common_id": 3
      },
      {
          "subject": "customer",
          "label": "公海No03",
          "value": "common",
          "common_id": 4
      }
    ]
  }
}

客户筛选条件分组

HTTP Request

GET /api/v2/customers/filter_sort_group

URL Parameters

字段名 是否必填 描述
common_id false 公海id, 当tab 是common 的时候需要传这个

返回数据:

{
  "code": 0,
  "data": {
    "filters": [
      {
        "label": "跟进状态",
        "field_name": "status",
        "filter_field_type": "select"
      },
      {
        "label": "最新跟进时间",
        "field_name": "last_revisit_at",
        "filter_field_type": "select"
      },
      {
        "label": "客户类型",
        "field_name": "category",
        "filter_field_type": "select"
      },
      {
        "label": "产品筛选",
        "field_name": "product_id",
        "filter_field_type": "select"
      },
      {
        "label": "部门",
        "field_name": "department_id",
        "filter_field_type": "select",
        "filters": [
          {
            "label": "全部用户",
            "field_name": "user_id",
            "filter_field_type": "query_select"
          }
        ]
      }
    ],
    "sorts": [
      {
        "name": "sort",
        "label": "默认排序",
        "value": "",
        "order": ""
      },
      {
        "name": "sort",
        "label": "按客户名称顺序",
        "value": "name_pinyin",
        "order": "asc"
      },
      {
        "name": "sort",
        "label": "按跟进时间倒序",
        "value": "activity",
        "order": "desc"
      }
    ]
  }
}

客户筛选选项

HTTP Request

GET /api/v2/customers/:field_name/filter_options

URL Parameters

字段名 是否必填 描述
field_name true customer 的 field_name(status等),替换掉url的:field_name

返回数据:


{
  "code": 0,
  "data": {
    "options": [
      {
        "label": "全部跟进状态",
        "name": "status",
        "value": ""
      },
      {
        "label": "初访",
        "value": "7",
        "name": "status"
      },
      {
        "label": "意向",
        "value": "8",
        "name": "status"
      },
      {
        "label": "报价",
        "value": "9",
        "name": "status"
      },
      {
        "label": "成交",
        "value": "10",
        "name": "status"
      },
      {
        "label": "暂时搁置",
        "value": "11",
        "name": "status"
      }
    ],
    "total_count": 6,
    "per_page": 6,
    "page": 1
  }
}

客户详情

HTTP Request

GET /api/v2/customers/:id

URL Parameters

字段名 是否必填 描述
id true customer 的 id,替换掉url的:id

返回数据字段说明

字段名 描述
expect_flow_at 预计流入公海时间
step_can_approve 当前用户对客户当下是否具有审批和驳回的权限
can_approve 当前用户是否为客户所有审批人中的某一个
notify_users 提醒他人集合
can_revert_applying 是否允许撤销客户审批(true或false)
need_approve_step 当前需要审批的层级

返回数据:


{
    "code": 0,
    "data": {
        "id": 82823,
        "name": "桑格拉",
        "status": "3065",
        "status_mapped": "初访",
        "note": "",
        "category": "1",
        "category_mapped": "重要",
        "source": "",
        "source_mapped": "",
        "industry": "",
        "industry_mapped": "",
        "parent": {},
        "staff_size": 0,
        "staff_size_display": "",
        "staff_size_mapped": "",
        "created_at": "2017-05-11 12:50",
        "updated_at": "2017-06-30 11:36",
        "is_own": true,
        "attachments": "暂无附件",
        "company_name": "",
        "is_has_policy_for_assist_user": true,
        "is_my_assist_entity": false,
        "qixinbao_id": "",
        "creator": {
            "id": 1,
            "email": "test@qq.com",
            "created_at": "2017-04-13T00:00:00.000+08:00",
            "name": "test@qq.com",
            "organization_id": 30,
            "phone": "157214621171",
            "role_id": 86,
            "workflow_state": "organization_owner",
            "job": "6666",
            "tel": "021-45555555",
            "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/14088/1.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
            "department_name": "研发2部"
        },
        "before_user": {},
        "before_owned_department": {},
        "not_revisit_at_time_str": "88天未跟进",
        "history_contarct_money": 0,
        "total_have_receive_pay": 0,
        "total_not_receive_pay": 0,
        "is_editable": true,
        "flow_into_at": "",
        "contacts": [
            {
                "id": 28339,
                "name": "阿琳",
                "address": {
                    "id": 10,
                    "tel": null,
                    "tel_hidden_result": "",
                    "phone": null,
                    "phone_hidden_result": ""
                }
            }
        ],
        "expect_flow_at": "",
        "need_hidden_dispose": false,
        "revisit_remind_at": "",
        "customer_common_setting_id": null,
        "before_customer_common_setting": {},
        "is_user_self": true,
        "step_can_approve": false,
        "step": 0,
        "notify_users": [],
        "can_revert_applying": false,
        "need_approve_step": 1,
        "approve_status": "approved",
        "approve_status_i18n": "已通过",
        "can_approve": true,
        "text_asset_120487e4": "text_asset_120487e4",
        "text_asset_d8d81e8f": null,
        "text_asset_d5dc57d3": null,
        "text_asset_dfde0b37": null,
        "text_asset_dfde0b37_hidden_result": "",
        "text_asset_d5dc57d3_display": null,
        "address": {
            "id": 21,
            "country": {},
            "province": {},
            "city": {},
            "district": {},
            "tel": "",
            "tel_hidden_result": "",
            "phone": "",
            "phone_hidden_result": "",
            "email": "",
            "qq": "",
            "fax": "",
            "wechat": "",
            "wangwang": "",
            "zip": "",
            "url": "",
            "detail_address": "",
            "lat": 0,
            "lng": 0,
            "distance": "未知",
            "region_info": null,
            "off_distance": -1,
            "gaode_staticmap": "",
            "full_address": ""
        },
        "user": {
            "id": 1,
            "email": "test@qq.com",
            "created_at": "2017-04-13T00:00:00.000+08:00",
            "name": "test@qq.com",
            "organization_id": 30,
            "phone": "157214621171",
            "role_id": 86,
            "workflow_state": "organization_owner",
            "job": "6666",
            "tel": "021-45555555",
            "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/14088/1.jpg?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
            "department_name": "研发2部"
        },
        "owned_department": {
            "id": 44,
            "name": "研发2部"
        }
    }
}

创建客户

HTTP Request

POST /api/v2/customers(.:format)

URL Parameters

字段名 是否必填 描述
customer[approve_status] false 开启客户审批时为applying, 未开启为approved, 是否开启审批查看 GET /api/v2/permissions 接口里的customer_approve
customer[user_id] false 负责人id
customer[parent_id] false 上级客户id.
customer[name] false 客户名称
customer[note] false 备注
customer[status] false 跟进状态 值为 /api/v2/field_maps/customer 返回值
customer[category] false 客户类型 值为 /api/v2/field_maps/customer 返回值
customer[source] false 客户来源 值为 /api/v2/field_maps/customer 返回值
customer[industry] false 行业 值为 /api/v2/field_maps/customer 返回值
customer[staff_size] false 员工人数
customer[want_department_id] false 所属部门
customer[custom_field_template_id] false 业务模版id
customer[address_attributes][detail_address] false 地址详情
customer[address_attributes][tel] false 电话
customer[address_attributes][url] false 这是 [url]
customer[address_attributes][country_id] false 国家id
customer[address_attributes][province_id] false 省id
customer[address_attributes][city_id] false 城市id
customer[address_attributes][district_id] false 区域id
customer[address_attributes][zip] false 邮编
customer[address_attributes][fax] false 传真
customer[address_attributes][qq] false qq
customer[address_attributes][wechat] false 微信
customer[address_attributes][wangwang] false wangwang
customer[address_attributes][phone] false 手机
customer[address_attributes][email] false 邮箱
customer[contacts_attributes][name] false 联系人姓名
customer[opportunities_attributes][title] false 商机标题
customer[wx_external_contact_map_attributes][external_userid] false 外部联系人userid
customer[wx_external_contact_map_attributes][contact_type] false 外部联系人类型

返回数据:

{
  "code": 0
}

客户更新

HTTP Request

PUT /api/v2/customers/:id(.:format)

URL Parameters

字段名 是否必填 描述
id true 替换url的 :id
check_duplicates false 是否需要查重 ä¼  字符串 ‘true’ 'flase’
customer[approve_status] false 开启客户审批时(当前合同为已撤销或已驳回,则更新时approve_status为applying), 未开启为approved
customer[user_id] false 负责人id
customer[parent_id] false 上级客户id.
customer[status] false 跟进状态
customer[note] false Your customer note
customer[category] false Your customer note
customer[source] false Your customer note
customer[industry] false Your customer note
customer[staff_size] false Your customer note
customer[want_department_id] false 这是 所属部门
customer[address_attributes] false 这是 customer[address_attributes]
customer[address_attributes][detail_address] false 这是 customer[address_attributes][detail_address]
customer[address_attributes][tel] false 这是 customer[address_attributes][tel]
customer[address_attributes][url] false 这是 customer[address_attributes][url]
customer[address_attributes][country_id] false 这是 customer[address_attributes][country_id]
customer[address_attributes][province_id] false 这是 customer[address_attributes][province_id]
customer[address_attributes][city_id] false 这是 customer[address_attributes][city_id]
customer[address_attributes][district_id] false 这是 customer[address_attributes][district_id]
customer[address_attributes][zip] false 这是 customer[address_attributes][zip]
customer[address_attributes][fax] false 这是 customer[address_attributes][fax]
customer[address_attributes][qq] false 这是 customer[address_attributes][qq]
customer[address_attributes][wechat] false 这是 customer[address_attributes][wechat]
customer[address_attributes][wangwang] false 这是 customer[address_attributes][wangwang]
customer[address_attributes][phone] false 这是 customer[address_attributes][phone]
customer[address_attributes][email] false 这是 customer[address_attributes][email]

返回数据:

{
  "code": 0
}

客户销售动态

HTTP Request

GET /api/v2/customers/:id/sales_activities

URL Parameters

字段名 是否必填 描述
id true customer 的 id,替换掉url的:id
saleable_type false 可选值 ['checkin’, 'revisit_log’]

返回数据:

{
  "code": 0,
  "data": {
    / 按日期分组的销售动态json数据,日期格式:YYYY-MM-DD
    "sales_activities": [{
      "date":"2015-09-22",
      "activities": [{
        "id": 139249,
        "user": {
          "id": 1,
          "email": "test@qq.com",
          "created_at": "2014-07-23T18:43:54.000+08:00",
          "name": "ifool",
          "organization_id": 1,
          "phone": "15821940120",
          "role_id": 1023,
          "workflow_state": "organization_owner",
          "job": " 我们自己",
          "tel": "45874554",
          "gender": "male",
          "avatar_url": "/dn-ikcrm-files-dev.qbox.me/attachments/files/7189/bower-logo.png?imageMogr2/thumbnail/!100x100r/crop/!100x100/format/jpg/auto-orient",
          "confirmed_phone_at": ""
        },
        "title": "IKCRM_contracts_20150922.xlsx", / 销售动态标题
        "timestamp": "2015-09-22 16:22",
        "description": "新增附件 IKCRM_contracts_20150922.xlsx", / 销售动态描述
        "comments_count": 0, / 销售动态评论数
        "refer_type_display": "客户",
        "comments": [], / 销售动态评论
        "refer_type": "Customer",
        "refer_name": "客户-联系人2",
        "refer_id": 50535,
        "attachments": [],
        "address": {},
        "remind_at": "",
        "remind_at_display": "",
        "saleable_name": "IKCRM_contracts_20150922.xlsx",
        "saleable_id": 7226,
        "saleable_type": "Attachment",
        "saleable_type_display": "文件附件",
        "activity_type_display": "更新",
        "activity_type": "update",
        "audios": [],
        "app": "",
        "created_at": ""
      }]}, ...]
    },
    "total_count": 38,
    "per_page": 15,
    "page": 1
  }
}

删除客户

HTTP Request

DELETE /api/v2/customers/:id(.:format)

URL Parameters

字段名 是否必填 描述
id true customer 的 id,替换掉url的:id

返回数据 json { "code": 0 }

客户tab页数量

HTTP Request

GET /api/v2/customers/:id/util_counts

URL Parameters

字段名 是否必填 描述
id true customer 的 id,替换掉url的:id

返回数据:

{
  "code": 0,
  "data": [
    {
      "name": "activity"
    },
    {
      "name": "contact",
      "count": 1
    },
    {
      "name": "contract",
      "count": 1
    },
    {
      "name": "opportunity",
      "count": 1
    },
    {
      "name": "attachment",
      "count": 1
    },
    {
      "name": "reminder",
      "count": 3
    },
    {
     "name": "children",
     "count": 3
    }
  ]
}

下级客户

HTTP Request

GET /api/v2/customers/:id/children

URL Parameters

字段名 是否必填 描述
id true customer 的 id,替换掉url的:id
page false 页码
per_page false 每页的数量

返回数据:

{
  "code": 0,
  "data": {
    "customers": [
      {
        "id": 18,
        "name": "贸易公司",
        "name_pinyin": "maoyigongsi",
        "user_id": 2,
        "user_name": "test",
        "contacts": [
          {
            "id": 6,
            "name": "赵宁",
            "address": {
              "id": 1077,
              "tel": "010-64881989",
              "phone": ""
            }
          },
          {
            "id": 19,
            "name": "ddddddddddd",
            "address": {
              "id": 1319,
              "tel": "21123213213",
              "phone": ""
            }
          }
        ],
        "company_name": "",
        "address": {
          "id": 1076,
          "tel": "010-64881989",
          "phone": ""
        },
        "revisit_at": "2015-08-31T11:30:21.000+08:00",
        "is_own": true,
        "status": "8",
        "status_mapped": "意向",
        "category": "12",
        "category_mapped": "A(重要客户)"
      }
    ],
    "total_count": 22,
    "per_page": 1,
    "page": 1
  }
}

客户选择器

HTTP Request

GET /api/v2/customers/selector

URL Parameters

字段名 是否必填 描述
page false 页码
per_page false 每页的数量
id flase 用户id
exclude_ids flase 不包括的用户
base_customer_id flase 特定用户id
policy flase 当base_customer_id存在的时候可选,取值范围[“self”,“self_and_descendants”,“self_and_descendants_by_tree_depth”]
tree_depth flase 数字类型 深度 当 policy为self_and_descendants_by_tree_depth的时候可选
name flase 客户name
user_name flase 客户所属的用户name
exact_name flase 客户所属的用户name 确切匹配

返回数据:

{
  "code": 0,
  "data": {
    "customers": [
      {
        "id": 18,
        "name": "贸易公司",
        "name_pinyin": "maoyigongsi",
        "user_id": 2,
        "user_name": "test",
        "contacts": [
          {
            "id": 6,
            "name": "赵宁",
            "address": {
              "id": 1077,
              "tel": "010-64881989",
              "phone": ""
            }
          },
          {
            "id": 19,
            "name": "ddddddddddd",
            "address": {
              "id": 1319,
              "tel": "21123213213",
              "phone": ""
            }
          }
        ],
        "company_name": "",
        "address": {
          "id": 1076,
          "tel": "010-64881989",
          "phone": ""
        },
        "revisit_at": "2015-08-31T11:30:21.000+08:00",
        "is_own": true,
        "status": "8",
        "status_mapped": "意向",
        "category": "12",
        "category_mapped": "A(重要客户)"
      }
    ],
    "total_count": 22,
    "per_page": 1,
    "page": 1
  }
}

客户联系人

HTTP Request

GET /api/v2/customers/:id/contacts(.:format)

URL Parameters

字段名 是否必填 描述
id true 这是 id
page false 这是 page
per_page false 这是 per_page
opportunity_id false 商机id

返回数据


{
  "code": 0,
  "data": {
    "contacts": [
      {
        "id": 18,
        "name": "111",
        "user_id": 1,
        "user_name": "default",
        "category": "",
        "category_mapped": "",
        "gender": null,
        "customer_id": 29,
        "customer_name": "weed",
        "birth_date": "",
        "gender_i18n": "",
        "job": "",
        "address": {
          "id": 1317,
          "tel": "",
          "phone": "",
          "qq": "",
          "email": "",
          "lng": 0,
          "lat": 0,
          "detail_address": ""
        },
        "is_own": true
      }
    ],
    "total_count": 1,
    "per_page": 15,
    "page": 1
  }
}

客户下面合同(老版本使用,现在直接用合同列表页传入参数)

HTTP Request

GET /api/v2/customers/:id/contracts(.:format)

URL Parameters

字段名 是否必填 描述
id true 这是 客户id, 替换url里的 :id
page false 这是 page
per_page false 这是 per_page

返回数据

{
  "code": 0,
  "data": {
    "contracts": [
      {
        "id": 16,
        "category": "43",
        "category_mapped": "直销合同",
        "payment_type": "48",
        "payment_type_mapped": "支票",
        "status": "52",
        "status_mapped": "未开始",
        "organization_id": 1,
        "user_id": 1,
        "user_name": "default",
        "title": "edsfsf",
        "customer_id": 29,
        "customer_name": "weed",
        "opportunity_id": 0,
        "opportunity_title": null,
        "total_amount": "2132.0",
        "start_at": "2015-09-23",
        "end_at": "",
        "customer_signer": "",
        "our_signer": "",
        "special_terms": "",
        "received_payments_amount": "0.0",
        "unreceived_amount": 2132,
        "checking_payments_amount": "0.0",
        "approve_status": "applying",
        "approve_deny_type": 0,
        "updated_at": "2015-09-23 19:07:39",
        "sn": "",
        "created_at": "",
        "sign_date": "",
        "times": "",
        "times_display": ""
      }
    ],
    "total_count": 13,
    "per_page": 1,
    "page": 1
  }
}

客户下面商机

HTTP Request

GET /api/v2/customers/:id/opportunities

URL Parameters

字段名 是否必填 描述
id true 这是 客户id, 替换url里的 :id
page false 这是 page
per_page false 这是 per_page

返回数据


{
  "code": 0,
  "data": {
    "opportunities": [
      {
        "id": 25,
        "title": "sdfsdasf",
        "title_pinyin": "sdfsdasf",
        "user_id": 1,
        "user_name": "default",
        "expect_amount": "12.0",
        "sign_possibility": "10%",
        "get_time": "2015-09-28",
        "stage": "64",
        "stage_mapped": "初步接洽",
        "expect_sign_date": "2015-09-28",
        "customer_requirement": "",
        "source": "",
        "source_mapped": "",
        "kind": "",
        "kind_mapped": "",
        "customer_id": 18,
        "customer_name": "贸易公司",
        "sign_possibility_display": "",
        "note": "",
        "created_at": "",
        "updated_at": ""
      }
    ],
    "total_count": 2,
    "per_page": 1,
    "page": 1
  }
}

协作人列表

HTTP Request

GET /api/v2/customers/:id/assist_users

URL Parameters

字段名 是否必填 描述
id true 这是 客户id, 替换url里的 :id
query false name查询
page false 这是 page
per_page false 这是 per_page

返回数据


{
  "code": 0,
  "data": {
    "assist_users": [
      {
        "id": 2,
        "email": "wp@qq.com",
        "created_at": "2015-06-10T11:06:45.000+08:00",
        "name": "test",
        "organization_id": 1,
        "phone": "15921076830",
        "role_id": 0,
        "workflow_state": "organization_staff",
        "job": "",
        "tel": "",
        "avatar_url": "/localhost:3000/assets/male.jpg",