物流助手 /小程序使用 /getAllAccount

# logistics.getAllAccount

> 本接口应在服务器端调用,详细说明参见[服务端API](https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/backend-api.html)。

> 本接口支持[云调用](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html)。需开发者工具版本 >= `1.02.1904090`(最新[稳定版下载](https://developers.weixin.qq.com/miniprogram/dev/devtools/stable.html)),`wx-server-sdk` >= `0.4.0`

获取所有绑定的物流账号

调用方式:

- [HTTPS 调用](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-business/logistics.getAllAccount.html#method-http)
- [云调用](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/express/by-business/logistics.getAllAccount.html#method-cloud)



## HTTPS 调用

### 请求地址

```text
GET https://api.weixin.qq.com/cgi-bin/express/business/account/getall?access_token=ACCESS_TOKEN
```

### 请求参数

| 属性                                  | 类型   | 默认值 | 必填 | 说明                                                         |
| :------------------------------------ | :----- | :----- | :--- | :----------------------------------------------------------- |
| access_token / cloudbase_access_token | string |        | 是   | [接口调用凭证](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html) |

### 返回值

### Object

| 属性    | 类型           | 说明     |
| :------ | :------------- | :------- |
| errcode | number         | 错误码   |
| errmsg  | number         | 错误信息 |
| count   | number         | 账号数量 |
| list    | Array.<Object> | 账号列表 |

**errcode 的合法值**

| 值   | 说明     | 最低版本 |
| :--- | :------- | :------- |
| 0    | 成功     |          |
| -1   | 系统失败 |          |

**list 的结构**

| 属性              | 类型           | 说明                                      |
| :---------------- | :------------- | :---------------------------------------- |
| biz_id            | string         | 快递公司客户编码                          |
| delivery_id       | string         | 快递公司ID                                |
| create_time       | number         | 账号绑定时间                              |
| update_time       | number         | 账号更新时间                              |
| status_code       | number         | 绑定状态                                  |
| alias             | string         | 账号别名                                  |
| remark_wrong_msg  | string         | 账号绑定失败的错误信息(EMS审核结果)     |
| remark_content    | string         | 账号绑定时的备注内容(提交 EMS 审核需要) |
| quota_num         | number         | 电子面单余额                              |
| quota_update_time | number         | 电子面单余额更新时间                      |
| service_type      | Array.<Object> | 该绑定帐号支持的服务类型                  |

**list.status_code 的合法值**

| 值   | 说明     | 最低版本 |
| :--- | :------- | :------- |
| 0    | 绑定成功 |          |
| 1    | 审核中   |          |
| 2    | 绑定失败 |          |
| 3    | 已解绑   |          |

**list.service_type 的结构**

| 属性         | 类型   | 说明         |
| :----------- | :----- | :----------- |
| service_type | number | 服务类型ID   |
| service_name | string | 服务类型名称 |

### 返回数据示例

```json
{
       "count": 1,
       "list": [
           {
               "biz_id": "123456789",
               "delivery_id": "YUNDA",
               "create_time": 1555482786,
               "update_time": 1556594799,
               "status_code": 0,
               "alias": "",
               "remark_wrong_msg": "",
               "remark_content": "",
               "quota_num": 55,
               "quota_update_time": 1556594799
           }
       ]
   }
```



## 云调用

> [云调用](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html)是微信云开发提供的在云函数中调用微信开放接口的能力,需要在云函数中通过 `wx-server-sdk` 使用。

### 接口方法

```js
openapi.logistics.getAllAccount
```

> 需在 `config.json` 中配置 `logistics.getAllAccount` API 的权限,[详情](https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/openapi/openapi.html#usage-3)

### 返回值

### Object

| 属性    | 类型           | 说明     |
| :------ | :------------- | :------- |
| errCode | number         | 错误码   |
| errMsg  | number         | 错误信息 |
| count   | number         | 账号数量 |
| list    | Array.<Object> | 账号列表 |

**errCode 的合法值**

| 值   | 说明 | 最低版本 |
| :--- | :--- | :------- |
| 0    | 成功 |          |

**list 的结构**

| 属性            | 类型           | 说明                                      |
| :-------------- | :------------- | :---------------------------------------- |
| bizId           | string         | 快递公司客户编码                          |
| deliveryId      | string         | 快递公司ID                                |
| createTime      | number         | 账号绑定时间                              |
| updateTime      | number         | 账号更新时间                              |
| statusCode      | number         | 绑定状态                                  |
| alias           | string         | 账号别名                                  |
| remarkWrongMsg  | string         | 账号绑定失败的错误信息(EMS审核结果)     |
| remarkContent   | string         | 账号绑定时的备注内容(提交 EMS 审核需要) |
| quotaNum        | number         | 电子面单余额                              |
| quotaUpdateTime | number         | 电子面单余额更新时间                      |
| serviceType     | Array.<Object> | 该绑定帐号支持的服务类型                  |

**list.statusCode 的合法值**

| 值   | 说明     | 最低版本 |
| :--- | :------- | :------- |
| 0    | 绑定成功 |          |
| 1    | 审核中   |          |
| 2    | 绑定失败 |          |
| 3    | 已解绑   |          |

**list.serviceType 的结构**

| 属性        | 类型   | 说明         |
| :---------- | :----- | :----------- |
| serviceType | number | 服务类型ID   |
| serviceName | string | 服务类型名称 |

### 异常

### Object

抛出的异常

| 属性    | 类型   | 说明     |
| :------ | :----- | :------- |
| errCode | number | 错误码   |
| errMsg  | number | 错误信息 |

**errCode 的合法值**

| 值   | 说明     | 最低版本 |
| :--- | :------- | :------- |
| -1   | 系统失败 |          |

### 请求示例

```js
const cloud = require('wx-server-sdk')
cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV,
})
exports.main = async (event, context) => {
  try {
    const result = await cloud.openapi.logistics.getAllAccount({})
    return result
  } catch (err) {
    return err
  }
}
```

### 返回数据示例

```json
{
  "count": 1,
  "list": [
    {
      "alias": "",
      "bizId": "123456789",
      "deliveryId": "YUNDA",
      "createTime": 1555482786,
      "updateTime": 1556594799,
      "statusCode": 0,
      "remarkWrongMsg": "",
      "remarkContent": "",
      "quotaNum": 55,
      "quotaUpdateTime": 1556594799
    }
  ],
  "errMsg": "openapi.logistics.getAllAccount:ok"
}
```