客户
客户查询接口
根据关键字(支持客户的名称和编号的查询),得到与之匹配的客户。
curl -i "http://example.com/api/customers.json"
{
"status": {
"code": "200",
"message": "OK"
},
"customers": [
{
"id": 1,
"name": "Fluffums",
"number": "C0001",
"category": "重要客户",
"enable": "启用"
},
{
"id": 2,
"name": "Max",
"number": "C0002",
"category": "普通客户",
"enable" : "禁用"
}
]
}
HTTP 请求
GET http://example.com/api/customers.json
请求参数
参数名 | 是否必填 | 默认值 | 说明 |
---|---|---|---|
keyword | 否 | 无 | 关键字 |
- 返回字段说明
返回值字段 | 字段类型 | 说明 |
---|---|---|
id | int | 客户ID |
name | string | 客户名称 |
number | string | 客户编号 |
category | string | 客户类型 |
balance | decimal | 应收款余额 |
客户详情
根据客户ID,获取客户详细信息。
curl -i "http://example.com/api/customers/2.json"
{
"status": {
"code": "200",
"message": "OK"
},
"customer": {
"id": 2,
"name": "Max",
"number": "C0002",
"category": "普通客户",
"enable": "禁用",
"first payment": "20000",
"current payment": "10000",
"contacts" : [
{
"name": "张经理",
"phone": "021-22839823",
"mobile": "13928399382",
"address": "上海市虹口区嘉兴路267号",
"note": "客户经理",
"is_primary" : true
},
{
"name": "刘经理",
"phone": "021-22839823",
"mobile": "13928399382",
"address": "上海市虹口区嘉兴路264号",
"note": "渠道经理",
"is_primary" : false
}
]
}
}
HTTP 请求
GET http://example.com/api/customers/:id.json
请求参数
参数名 | 是否必须 | 说明 |
---|---|---|
id | 必须 | 客户ID |
- 返回字段说明
返回值字段 | 字段类型 | 说明 |
---|---|---|
id | int | 客户ID |
name | string | 客户名称 |
number | string | 客户编号 |
category | string | 客户类型 |
default_amount | decimal | 期初应收款金额 |
balance | decimal | 应收款余额 |
contacts/name | string | 联系人姓名 |
contacts/phone | string | 联系人电话 |
contacts/mobile | string | 联系人手机 |
contacts/address | string | 联系人地址 |
contacts/note | string | 备注 |
contacts/is_primary | boolean | 是否主要联系人 |
创建客户
curl -i -X POST "http://example.com/api/customers.json"
{
"status": {
"code": "200",
"message": "OK"
},
"customer": {
"id": 2,
"name": "Max",
"number": "C0002",
"category": "普通客户",
"enable": "禁用",
"first payment": "20000",
"current payment": "10000"
}
}
HTTP 请求
POST http://example.com/api/customers/
请求参数
参数名 | 是否必须 | 说明 |
---|---|---|
name | 必须 | 客户名称 |
number | 必须 | 客户编号 |
customer_type_id | 必须 | 客户类型ID |
default_amount | 必须 |期初应收款金额 | |
current_payemnt | 必须 |应收款余额 | |
contact_attributes/name | 必须 | 联系人姓名 |
contact_attributes/phone | 否 | 联系人电话 |
contact_attributes/mobile | 必须 | 联系人手机 |
contact_attributes/address | 否 | 联系人地址 |
contact_attributes/note | 否 | 备注 |
contact_attributes/is_primary | 否 | 是否主要联系人 |
- 返回字段说明
返回值字段 | 字段类型 | 说明 |
---|---|---|
id | int | 客户ID |
name | string | 客户名称 |
number | string | 客户编号 |
category | string | 客户类型 |
default_amount | decimal | 期初应收款金额 |
balance | decimal | 应收款余额 |
编辑客户
curl -i -X PUT "http://example.com/api/customers/ID.json"
{
"status": {
"code": "200",
"message": "OK"
},
"customer": {
"id": 2,
"name": "Max",
"number": "C0002",
"category": "普通客户",
"assignee_name": "超管",
"pre_collect_amount": "20000",
"actual_collect_amount": "10000"
}
}
HTTP 请求
PUT http://example.com/api/customers/ID.json
请求参数
参数名 | 是否必须 | 说明 |
---|---|---|
name | 必须 | 客户名称 |
number | 必须 | 客户编号 |
customer_type_id | 必须 | 客户类型ID |
assignee_id | 否 | 客户负责人 |
assistor_id | 否 | 客户协作人 |
default_amount | 必须 | 期初应收款金额 |
current_payemnt | 必须 | 应收款余额 |
note | 否 | 备注 |
contact_attributes/name | 必须 | 联系人姓名 |
contact_attributes/phone | 否 | 联系人电话 |
contact_attributes/mobile | 必须 | 联系人手机 |
contact_attributes/address | 否 | 联系人地址 |
contact_attributes/note | 否 | 备注 |
contact_attributes/is_primary | 否 | 是否主要联系人 |
- 返回字段说明
返回值字段 | 字段类型 | 说明 |
---|---|---|
id | int | 客户ID |
name | string | 客户名称 |
number | string | 客户编号 |
category | string | 客户类型 |
default_amount | decimal | 期初应收款金额 |
balance | decimal | 应收款余额 |
seller_name | string | 销售员 |
assignee_name | string | 负责人 |
pre_collect_amount | decimal | 预收款 |
文档更新时间: 2025-03-17 14:52 作者:姜河