Finance财务相关接口
更新时间:2019-06-14
财务相关错误码
code | message |
---|---|
OperateUserBalanceError | Operate user balance failed, the bill type is null. |
OperateUserBalanceError | Operate user balance failed, the amount is null. |
BillRequestError | Add bill failed, the type is null. |
BillRequestError | Query bill failed, the id is null. |
BillSummaryRequestError | Add bill summary failed, the type is null. |
BillSummaryRequestError | Query bill summary failed, the id is null. |
BillSummaryRequestError | Query bill summary failed, the id list is null. |
OperateUserBalanceError | Operate user balance failed, the request serial number is already in database. |
获取账户余额接口
请求
方法 | URI | 说明 |
---|---|---|
GET | /finance/v1/cluster/<cluster_id>/user/<user_id>/balance | 获取账户余额 |
请求参数
无
响应
名称 | 类型 | 描述 |
---|---|---|
balance | Int | 当前库中记录的广告主账户余额,单位:分*1000 |
示例
请求示例
GET /finance/v1/cluster/dsp_cluster_1/user/2288/balance HTTP/1.1
Host: rtb-finance.bj.baidubce.com
Date: Fri, 24 Mar 2017 13:22:45 GMT
Authorization: AuthorizationString
Content-Length: 0
响应示例
HTTP/1.1 200 OK
x-bce-request-id: 9ab42373-60cd-1f8a-b49b-3049ca707409
Date: Fri, 24 Mar 2017 13:22:45 GMT
Content-Length: 23
Connection: close
Server: BaiduBce
{
"balance": 2900000
}
账户余额操作接口
请求
方法 | URI | 说明 |
---|---|---|
PUT | /finance/v1/cluster/<cluster_id>/user/<user_id>/balance | 操作账户余额 |
请求参数
名称 | 类型 | 描述 | 是否必须 |
---|---|---|---|
RequestSerialNumber | String | 请求操作流水号 | 是 |
Operation | Int | 账户操作类型 1 charge - 消费 2 recharge - 充值 3 withdraw - 提现 |
是 |
Amount | Int | 充值金额,单位:分*1000 | 是 |
响应
名称 | 类型 | 描述 |
---|---|---|
ResponseSerialNum | String | 响应流水号(还是请求流水号) |
示例
请求示例
PUT /v1/cluster/dsp_cluster_1/user/2288/balance HTTP/1.1
Host: clouddsp.bj.baidubce.com
Date: Fri, 24 Mar 2017 13:22:45 GMT
Authorization: AuthorizationString
Content-Length: 59
{
"requestSerialNumber": "recharge_serial_number",
"type": 2,
"amount": 100000,
}
响应示例
HTTP/1.1 200 OK
x-bce-request-id: 9ab42373-60cd-1f8a-b49b-3049ca707409
Date: Fri, 24 Mar 2017 13:22:45 GMT
Content-Length: 23
Connection: close
Server: BaiduBce
{
"data": "responseSerialNum"
}
获取单条账单记录
请求
方法 | URI | 说明 |
---|---|---|
GET | /finance/v1/cluster/<cluster_id>/bill/<bill_id> | 获取单条账单 | |
请求参数
名称 | 类型 | 描述 | 是否必须 |
---|---|---|---|
bill_id | int | 账单ID | 是 |
响应
名称 | 类型 | 描述 |
---|---|---|
billId | Int | 账单ID |
operatorId | Int | 操作人ID |
targetId | Int | 广告主账户ID |
createTime | Timestamp | 生成时间 |
processTime | Timestamp | 处理时间 |
billType | Int | 账户操作类型 2 recharge - 充值 3 withdraw - 提现 1 charge - 消费 |
amount | Int | 操作金额,单位:分*1000 |
balance | Int | 操作完成后账户余额,单位:分*1000 |
reqSerialNum | String | 请求流水号 |
resSerialNum | String | 响应流水号 |
示例
请求示例
GET /finance/v1/cluster/1/bill/1 HTTP/1.1
Host: clouddsp.bj.baidubce.com
Date: Fri, 24 Mar 2017 13:22:45 GMT
Authorization: AuthorizationString
Content-Length: 122
响应示例
HTTP/1.1 200 OK
x-bce-request-id: 9ab42373-60cd-1f8a-b49b-3049ca707409
Date: Fri, 24 Mar 2017 13:22:45 GMT
Content-Length: <ContentLength>
Connection: close
Server: BaiduBce
{
"data": {
"billId": 1,
"operatorId": 0,
"targetId": 1,
"billType": "CHARGE",
"amount": -10000,
"balance": 100000,
"reqSerialNum": "req_serial_num",
"resSerialNum": "res_serial_num",
"createTime": "2016-06-23T20:40:16.000",
"processTime": "2016-06-23T20:40:16.000"
}
}
获取全部账单记录
请求
方法 | URI | 说明 |
---|---|---|
POST | /finance/v1/cluster/<cluster_id>/bill | 获取集群账户全部账单 |
请求参数
名称 | 类型 | 描述 | 是否必须 |
---|---|---|---|
UserIdList | List<Int> |
广告主账户ID | 否 |
BillTypeList | List<String> |
账户操作类型 RECHARGE - 充值 WITHDRAW - 提现 CHARGE - 消费 |
否 |
StartDate | Timestamp | 账户操作记录开始时间 | 否 |
EndDate | TimeStamp | 账户操作记录结束时间 | 否 |
ReqSerialNum | String | 请求流水号 | 否 |
ResSerialNum | String | 响应流水号 | 否 |
OrderBy | String | 操作记录排序方式 bill_id - 按账单id排序 update_time - 按时间排序 |
否 |
Order | String | 倒序输出或正序输出 DESC - 倒序 ASC - 升序 |
否 |
PageSize | int | 页面大小 | 否 |
PageNo | int | 页面序号 | 否 |
响应
名称 | 类型 | 描述 |
---|---|---|
billId | Int | 账单ID |
operatorId | Int | 操作人ID |
targetId | Int | 广告主账户ID |
createTime | Timestamp | 生成时间 |
processTime | Timestamp | 处理时间 |
billType | Int | 账户操作类型 2 recharge - 充值 3 withdraw - 提现 1 charge - 消费 |
amount | Int | 操作金额,单位:分*1000 |
balance | Int | 操作完成后账户余额,单位:分*1000 |
reqSerialNum | String | 请求流水号 |
resSerialNum | String | 响应流水号 |
示例
请求示例
POST /finance/v1/cluster/1/bill HTTP/1.1
Host: clouddsp.bj.baidubce.com
Date: Fri, 24 Mar 2017 13:22:45 GMT
Authorization: AuthorizationString
Content-Length: 122
{
"userIds":[1],
"billTypes":["CHARGE","RECHARGE","WITHDRAW"],
"reqSerialNum": "req_serial_num",
"startDate": "2016-06-22",
"endDate": "2017-06-25"
}
响应示例
HTTP/1.1 200 OK
x-bce-request-id: 9ab42373-60cd-1f8a-b49b-3049ca707409
Date: Fri, 24 Mar 2017 13:22:45 GMT
Content-Length: <ContentLength>
Connection: close
Server: BaiduBce
{
"totalCount": 1,
"pageNo": 1,
"pageSize": 20,
"orderBy": "bill_id",
"order": "desc",
"result": [
{
"billId": 1,
"operatorId": 0,
"targetId": 1,
"billType": "CHARGE",
"amount": -10000,
"balance": 100000,
"reqSerialNum": "req_serial_num",
"resSerialNum": "res_serial_num",
"createTime": "2016-06-23T20:40:16.000",
"processTime": "2016-06-23T20:40:16.000"
}
]
}
获取账户财务统计总览
请求
方法 | URI | 说明 |
---|---|---|
POST | /finance/v1/cluster/<cluster_id>/summary/overview | 获取总览 | |
请求参数
名称 | 类型 | 描述 | 是否必需 |
---|---|---|---|
UserIdList | List<Int> |
广告主账户ID | 必 |
BillTypeList | List<String> |
账户操作类型 RECHARGE - 充值 WITHDRAW - 提现 CHARGE - 消费 |
否 |
StartTime | Timestamp | 账户操作记录开始时间 | 否 |
EndTime | TimeStamp | 账户操作记录结束时间 | 否 |
OrderBy | String | 排序方式 bill_id - 按账单id排序 update_time - 按时间排序 |
否 |
Order | String | 倒序输出或正序输出 DESC - 倒序 ASC - 升序 |
否 |
PageSize | int | 页面大小 | 否 |
PageNo | int | 页面序号 | 否 |
响应
名称 | 类型 | 描述 |
---|---|---|
id | Int | 账单ID |
targetId | Int | 广告主账户ID |
billType | Int | 账户操作类型 2 recharge - 充值 3 withdraw - 提现 1 charge - 消费 |
amount | Int | 操作金额,单位:分*1000 |
示例
请求示例
POST /finance/v1/cluster/dsp_cluster_1/bill/overview HTTP/1.1
Host: clouddsp.bj.baidubce.com
Date: Fri, 24 Mar 2017 13:22:45 GMT
Authorization: AuthorizationString
Content-Length: 20
{
"userIds":[1],
"billTypes":["CHARGE","RECHARGE","WITHDRAW"],
"startTime": "2016-06-22",
"endTime": "2017-06-25"
}
响应示例
HTTP/1.1 200 OK
x-bce-request-id: 9ab42373-60cd-1f8a-b49b-3049ca707409
Date: Fri, 24 Mar 2017 13:22:45 GMT
Content-Length: 230
Connection: close
Server: BaiduBce
{
"totalCount": 2,
"pageNo": 1,
"pageSize": 20,
"orderBy": "id",
"order": "desc",
"result": [
{
"id": 0,
"targetId": 0,
"billType": "CHARGE",
"amount": -10000
},
{
"id": 0,
"targetId": 0,
"billType": "WITHDRAW",
"amount": 30000
}
]
}
添加账户财务统计
请求
方法 | URI | 说明 |
---|---|---|
POST | /finance/v1/cluster/<cluster_id>/summary | 添加集群账户财务统计| |
请求参数
名称 | 类型 | 描述 | 是否必需 |
---|---|---|---|
TargetId | Int | 广告主账户ID | 否 |
BillType | String | 账户操作类型 RECHARGE - 充值 WITHDRAW - 提现 CHARGE - 消费 |
否 |
SummaryTime | Timestamp | 统计时间 | 否 |
Amount | Int | 金额 | 否 |
响应
无
示例
请求示例
POST /finance/v1/cluster/dsp_cluster_1/summary HTTP/1.1
Host: clouddsp.bj.baidubce.com
Date: Fri, 24 Mar 2017 13:22:45 GMT
Authorization: AuthorizationString
Content-Length: 20
{
"targetId":1,
"billType":"CHARGE",
"summaryTime": "2016-06-22",
"amount": 10000
}
响应示例
HTTP/1.1 200 OK
x-bce-request-id: 9ab42373-60cd-1f8a-b49b-3049ca707409
Date: Fri, 24 Mar 2017 13:22:45 GMT
Content-Length: 230
Connection: close
Server: BaiduBce
更新账户财务统计
请求
方法 | URI | 说明 |
---|---|---|
PUT | /finance/v1/cluster/<cluster_id>/summary | 更新集群账户财务统计 |
请求参数
名称 | 类型 | 描述 | 是否必需 |
---|---|---|---|
ID | Int | 统计记录ID | 否 |
TargetId | Int | 广告主账户ID | 否 |
BillType | String | 账户操作类型 RECHARGE - 充值 WITHDRAW - 提现 CHARGE - 消费 |
否 |
SummaryTime | Timestamp | 统计时间 | 否 |
Amount | Int | 金额 | 否 |
响应
无
示例
请求示例
PUT /finance/v1/cluster/dsp_cluster_1/summary HTTP/1.1
Host: clouddsp.bj.baidubce.com
Date: Fri, 24 Mar 2017 13:22:45 GMT
Authorization: AuthorizationString
Content-Length: 20
{
"id": 10,
"targetId":1,
"billType":"CHARGE",
"summaryTime": "2016-06-22",
"amount": 10000
}
响应示例
HTTP/1.1 200 OK
x-bce-request-id: 9ab42373-60cd-1f8a-b49b-3049ca707409
Date: Fri, 24 Mar 2017 13:22:45 GMT
Content-Length: 230
Connection: close
Server: BaiduBce
按日获取账户财务统计
请求
方法 | URI | 说明 |
---|---|---|
POST | /finance/v1/cluster/<cluster_id>/summary/day | 查询账户财务统计 |
请求参数
名称 | 类型 | 描述 | 是否必需 |
---|---|---|---|
UserIdList | List<Int> |
广告主账户ID | 否 |
BillTypeList | List<String> |
账户操作类型 RECHARGE - 充值 WITHDRAW - 提现 CHARGE - 消费 |
否 |
StartTime | Timestamp | 账户操作记录开始时间 | 否 |
EndTime | TimeStamp | 账户操作记录结束时间 | 否 |
OrderBy | String | 排序方式 bill_id - 按账单id排序 update_time - 按时间排序 |
否 |
Order | String | 倒序输出或正序输出 DESC - 倒序 ASC - 升序 |
否 |
PageSize | int | 页面大小 | 否 |
PageNo | int | 页面序号 | 否 |
响应
名称 | 类型 | 描述 |
---|---|---|
id | Int | 账单ID |
targetId | Int | 广告主账户ID |
billType | Int | 账户操作类型 2 recharge - 充值 3 withdraw - 提现 1 charge - 消费 |
amount | Int | 操作金额,单位:分*1000 |
summaryTime | TimeStamp | 统计日期 |
示例
请求示例
POST /finance/v1/cluster/dsp_cluster_1/bill/overview HTTP/1.1
Host: clouddsp.bj.baidubce.com
Date: Fri, 24 Mar 2017 13:22:45 GMT
Authorization: AuthorizationString
Content-Length: 20
{
"userIds":[1],
"billTypes":["CHARGE","RECHARGE","WITHDRAW"],
"startTime": "2016-06-22",
"endTime": "2017-06-25"
}
响应示例
HTTP/1.1 200 OK
x-bce-request-id: 9ab42373-60cd-1f8a-b49b-3049ca707409
Date: Fri, 24 Mar 2017 13:22:45 GMT
Content-Length: 230
Connection: close
Server: BaiduBce
{
"totalCount": 2,
"pageNo": 1,
"pageSize": 20,
"orderBy": "id",
"order": "desc",
"result": [
{
"id": 0,
"targetId": 0,
"billType": "CHARGE",
"amount": -10000,
"summaryTime": "2016-06-23T00:00:00.000"
},
{
"id": 0,
"targetId": 0,
"billType": "WITHDRAW",
"amount": 30000,
"summaryTime": "2016-06-23T00:00:00.000"
}
]
}