接口说明
1、调用该接口获取访问令牌,其他请求均需要带此令牌;
2、每次请求该方法系统会生成新的token并且会覆盖之前的旧token;
3、token的默认到期时间为604800秒(即一周),在此时间内token有效,无需请求该接口生成新的token,当token失效时重新获取一次即可;
4、请不要频繁的调用该方法!
请求地址
环境 | 请求地址 | 支持方法 | 返回数据格式 |
---|---|---|---|
生产环境 | http://www.tofba.com:8887/api/accessToken | GET/POST | JSON |
测试环境 | http://tofba1.f3322.net:8887/api/accessToken | GET/POST | JSON |
请求参数说明
请求参数 | Required | 描述 |
---|---|---|
username | Yes | 用户名(九方ERP账户客户编码或者客户登录名) |
password | Yes | 密码 |
请求样例
xxxxxxxxxx
GET /api/accessToken?username=:username&password=:password
Host: www.tofba.com:8887/
Accept: application/json
Content-Type: application/json;charset=UTF-8
JSON响应结果
xxxxxxxxxx
### 响应成功:
{
"code": 200,
"timestamp": "2019-04-16 11:40:07",
"accessToken": "3bc517a2fa166dc5bda855d0a4739d60",
"expiresIn": 86400
}
### 响应失败:
{
"code": 400,
"errorType": "INVALID_LOGIN",
"errorMessage": "用户名或者密码错误或者系统无此客户信息",
"timestamp": "2019-04-16 12:32:57"
}
接口说明
xxxxxxxxxx
1、调用该接口可以获取所有九方生效的小包渠道信息;
2、调用该接口必须带参数token和customerCode(九方系统为每个客户生成的唯一客户编码);
3、返回结果中的productId(即渠道ID)用于创建订单接口中传参;
请求地址
环境 | 请求地址 | 支持方法 | 返回数据格式 |
---|---|---|---|
生产环境 | http://www.tofba.com:8887/api/getProductList | GET/POST | JSON |
测试环境 | http://tofba1.f3322.net:8887/api/getProductList | GET/POST | JSON |
请求参数说明
请求参数 | Required | 描述 |
---|---|---|
token | Yes | 请求令牌,获取令牌参考获取Token |
customerCode | Yes | 九方ERP系统为客户生成的唯一客户编码 |
请求样例
xxxxxxxxxx
GET /api/getProductList?token=:token&customerCode=:customerCode
Host: www.tofba.com:8887/
Accept: application/json
Content-Type: application/json;charset=UTF-8
JSON响应结果
xxxxxxxxxx
### 获取渠道信息失败响应结果示例
{
"code": 400,
"errorType": "INVALID_CUSTOMER_CODE",
"errorMessage": "客户编码错误或者token已经失效",
"timestamp": "2019-04-16 16:10:42"
}
### 获取渠道信息成功响应结果示例
{
"code": 200,
"timestamp": "2019-04-16 16:42:15",
"data": [
{
"productId": 0,
"productShortName": "通用产品",
"productType": "EXPRESS"
},
{
"productId": 2321,
"productShortName": "荷兰小包纯电挂号",
"productType": "EXPRESS"
},
{
"productId": 2361,
"productShortName": "澳洲小包快线",
"productType": "EXPRESS"
},
{
"productId": 2241,
"productShortName": "英国小包快线",
"productType": "EXPRESS"
},
{
"productId": 2281,
"productShortName": "荷兰小包挂号",
"productType": "EXPRESS"
},
{
"productId": 1881,
"productShortName": "深圳EUB",
"productType": "EXPRESS"
},
{
"productId": 2301,
"productShortName": "荷兰小包平邮",
"productType": "EXPRESS"
},
{
"productId": 2341,
"productShortName": "荷兰小包纯电平邮",
"productType": "EXPRESS"
},
{
"productId": 2381,
"productShortName": "美国小包快线",
"productType": "EXPRESS"
}
]
}
接口地址
xxxxxxxxxx
1、调用该接口可以通过API方式给九方小包系统下单;
2、该接口只支持POST请求,数据格式为JSON;
3、字段约束参考请求参数说明。
请求地址
环境 | 请求地址 | 支持方法 | 返回数据格式 |
---|---|---|---|
生产环境 | http://www.tofba.com:8887/api/createOrder | POST | JSON |
测试环境 | http://tofba1.f3322.net:8887/api/createOrder | POST | JSON |
请求参数说明
字段 | Required | 类型 | 描述 |
---|---|---|---|
token | Yes | String | 请求令牌,获取令牌参考获取Token |
customerCode | Yes | String | 九方ERP系统为客户生成的唯一客户编码 |
returnSign | Yes | String | 退回标志,N:表示不退回,Y:标表示退回,默认:N |
customerInvoiceCode | Yes | String | 原单号,客户自己系统中订单号 |
tradeType | false | String | 平台类型平台类型说明 |
countryCode | true | String | 收件国家二字码 |
productId | true | Long | 运输方式ID获取渠道接口查询得到 |
transactionUrl | false | String | 产品销售链接 |
currencyCode | false | String | 申报币种,币种代码。常见币种 |
consigneeName | true | String | 收件人姓名 |
consigneeAddress | true | String | 收件人地址 |
consigneeCity | true | String | 收件人城市 |
consigneePostCode | true | String | 收件人邮编 |
consigneeState | true | String | 收件人州/省 |
consigneeTelephone | true | String | 收件人电话 |
consigneeMobile | false | String | 收件人手机 |
consigneeEmail | false | String | 收件人邮箱 |
consigneeCompanyName | false | String | 收件人公司名 |
shipperName | false | String | 发件人姓名 |
shipperCompanyName | false | String | 发件人公司名 |
shipperAddress1 | false | String | 发件人地址1 |
shipperAddress2 | false | String | 发件人地址2 |
shipperAddress3 | false | String | 发件人地址3 |
shipperCity | false | String | 发件人城市 |
shipperState | false | String | 发件人省 |
shipperPostCode | false | String | 发件人邮编 |
shipperCountry | false | String | 发件人国家二字码 |
shipperTelephone | false | String | 发件人电话 |
orderPiece | true | Integer | 下单件数 |
weight | false | Double | 如果不填则默认为SKU重量之和 |
collectionAmount | false | Double | 代收金额 |
cargoAmount | false | Double | 订单实际金额 |
customerRemark | false | String | 订单备注 |
insuranceAmount | false | Double | 保险金额 |
orderInvoices | true | List | OrderInvoice |
orderVolumes | false | List | OrderVolume |
OrderInvoice
字段 | Required | 类型 | 描述 |
---|---|---|---|
invoiceAmount | true | Double | 总申报货值 |
invoicePcs | true | Integer | 数量 |
skuNameCn | true | String | 中文品名 |
skuNameEn | true | String | 英文品名 |
skuCode | true | String | SKU |
hsCode | true | String | 海关编码 |
invoicePurpose | false | String | 用途 |
invoiceWeight | false | Double | 单件重量 |
OrderVolume
字段 | Required | 类型 | 描述 |
---|---|---|---|
length | false | Double | 长 |
width | false | Double | 宽 |
height | false | Double | 高 |
weight | false | Double | 重 |
请求样例
xxxxxxxxxx
POST /api/createOrder
Host: www.tofba.com:8887/
Accept: application/json
Content-Type: application/json;charset=UTF-8
### POST请求体内容
{
"token": "4dfee9b82e8aec983ac0afb79aed1fee",
"customerCode": "J0698",
"returnSign": "N",
"customerInvoiceCode": "93778602",
"tradeType": "ZYXT",
"countryCode": "US",
"productId": 2381,
"transactionUrl": "https://www.amazon.com/gp/product/B07Q8RJSG7",
"currencyCode": "USD",
"consigneeName": "Lorenzo Martin Del Campo Alvarado",
"consigneeAddress": "1538 SEDALIA WAY.",
"consigneeCity": "AURORA",
"consigneePostCode": "80011-5013",
"consigneeState": "CO",
"consigneeTelephone": "7203817764",
"consigneeMobile": "13266829617",
"consigneeEmail": "zhc_hnust@outlook.com",
"consigneeCompanyName": "Lorenzo Martin Del Campo Alvarado",
"shipperName": "Mr Zhang",
"shipperCompanyName": "Haike Limited Comapany",
"shipperAddress1": "3/F,Second Phase,Qianlong Logistics Park,,China South City,Pinghu,Longgang",
"shipperCity": "SHEN ZHEN",
"shipperState": "GUANG DONG",
"shipperPostCode": "518111",
"shipperCountry": "CN",
"shipperTelephone": "17727165012",
"orderInvoices": [{
"invoiceAmount": 7.1,
"invoicePcs": 1,
"skuNameCn": "Galaxy watch active保护壳黑色40mm 1片装",
"skuNameEn": "watch cover",
"skuCode": "GWAEBHK2",
"hsCode": "",
"invoicePurpose": "手机保护装置"
}]
}
JSON响应结果
xxxxxxxxxx
### 创建订单失败响应结果示例
{
"code": 400,
"errorType": "PUSH_FAIL",
"errorMessage": "异常:客户参考号:93778603已存在!",
"timestamp": "2019-04-19 17:37:54"
}
### 创建订单成功响应结果示例
{
"code": 200,
"timestamp": "2019-04-19 17:46:44",
"data": {
"orderId": "302925",
"orderNo": "", ### 预留,后续返回物流商订单号
"referenceNumber": "93778604",
"trackingNumber": "74890983235158627602"
}
}
接口说明
xxxxxxxxxx
1、调用该接口可以将订单修改为预报订单。
请求地址
环境 | 请求地址 | 支持方法 | 返回数据格式 |
---|---|---|---|
生产环境 | http://www.tofba.com:8887/api/markShipment | GET/POST | JSON |
测试环境 | http://tofba1.f3322.net:8887/api/markShipment | GET/POST | JSON |
请求参数说明
请求参数 | Required | 描述 |
---|---|---|
token | Yes | 请求令牌,获取令牌参考获取Token |
customerCode | Yes | 九方ERP系统为客户生成的唯一客户编码 |
customerInvoiceCode | Yes | 九方ERP参考号,即客户所使用ERP系统中订单号 |
请求样例
x
GET /api/markShipment?token=:token&customerCode=:customerCode&customerInvoiceCode=:customerInvoiceCode
Host: www.tofba.com:8887/
Accept: application/json
Content-Type: application/json;charset=UTF-8
xxxxxxxxxx
POST /api/markShipment?token=:token&customerCode=:customerCode
Host: www.tofba.com:8887/
Accept: application/json
Content-Type: application/json;charset=UTF-8
{
"customerInvoiceCode": "123456"
}
JSON响应结果
xxxxxxxxxx
### 标记发货失败响应结果示例
{
"code": 400,
"errorType": "OPT_FAIL",
"errorMessage": "标记发货操作失败",
"timestamp": "2019-04-18 11:24:04"
}
### 标记发货成功响应结果示例
{
"code": 200,
"timestamp": "2019-04-18 11:24:04"
}
接口地址
xxxxxxxxxx
1、调用该接口可以更新已对接成功订单的预报重量。
请求地址
环境 | 请求地址 | 支持方法 | 返回数据格式 |
---|---|---|---|
生产环境 | http://www.tofba.com:8887/api/updateOrderWeight | GET/POST | JSON |
测试环境 | http://tofba1.f3322.net:8887/api/updateOrderWeight | GET/POST | JSON |
请求参数说明
请求参数 | Required | 描述 |
---|---|---|
token | Yes | 请求令牌,获取令牌参考获取Token |
customerCode | Yes | 九方ERP系统为客户生成的唯一客户编码 |
customerInvoiceCode | Yes | 九方ERP参考号,即客户所使用ERP系统中订单号 |
weight | Yes | 订单新重量,大于0的正实数 |
请求样例
xxxxxxxxxx
GET/POST /api/updateOrderWeight?token=:token&customerCode=:customerCode&customerInvoiceCode=:customerInvoiceCode&weight=:weight
Host: www.tofba.com:8887/
Accept: application/json
Content-Type: application/json;charset=UTF-8
JSON响应结果
xxxxxxxxxx
### 更新预报重量成功响应结果
{
"code": 200,
"timestamp": "2019-04-20 10:08:41"
}
### 更新预报重量失败响应结果
{
"code": 400,
"errorType": "OPT_FAIL",
"errorMessage": "更新预报重量失败",
"timestamp": "2019-04-20 10:17:40"
}
接口地址
xxxxxxxxxx
1、调用该接口可以获取已经推荐成功订单的追踪号。
请求地址
环境 | 请求地址 | 支持方法 | 返回数据格式 |
---|---|---|---|
生产环境 | http://www.tofba.com:8887/api/getOrderTrackNumber | GET/POST | JSON |
测试环境 | http://tofba1.f3322.net:8887/api/getOrderTrackNumber | GET/POST | JSON |
请求参数说明
请求参数 | Required | 描述 |
---|---|---|
token | Yes | 请求令牌,获取令牌参考获取Token |
customerCode | Yes | 九方ERP系统为客户生成的唯一客户编码 |
customerInvoiceCode | Yes | 参考号,即客户所使用ERP系统中订单号 |
请求样例
xxxxxxxxxx
GET/POST /api/getOrderTrackNumber?token=:token&customerCode=:customerCode&customerInvoiceCode=:customerInvoiceCode
Host: www.tofba.com:8887/
Accept: application/json
Content-Type: application/json;charset=UTF-8
JSON响应结果
xxxxxxxxxx
### 获取订单号成功响应结果
{
"code": 200,
"timestamp": "2019-04-20 10:08:41",
"data": {
"trackNumber": "74890983235158627237"
}
}
### 更新预报重量失败响应结果
{
"code": 400,
"errorType": "OPT_FAIL",
"errorMessage": "获取追踪号失败",
"timestamp": "2019-04-20 10:17:40"
}
接口地址
xxxxxxxxxx
1、调用该接口可以获取已经推荐成功订单的物流轨迹。
请求地址
环境 | 请求地址 | 支持方法 | 返回数据格式 |
---|---|---|---|
生产环境 | http://www.tofba.com:8887/api/getLogisticsTrack | GET/POST | JSON |
测试环境 | http://tofba1.f3322.net:8887/api/getLogisticsTrack | GET/POST | JSON |
请求参数说明
请求参数 | Required | 描述 |
---|---|---|
token | Yes | 请求令牌,获取令牌参考获取Token |
customerCode | Yes | 九方ERP系统为客户生成的唯一客户编码 |
documentCode | Yes | 追踪号,多个追踪号,分开,一次最多支持20个查询 |
请求样例
xxxxxxxxxx
GET/POST /api/getLogisticsTrack?token=:token&customerCode=:customerCode&documentCode=:documentCode
Host: www.tofba.com:8887/
Accept: application/json
Content-Type: application/json;charset=UTF-8
JSON响应结果
x{
"code": 200,
"timestamp": "2019-04-20 11:46:52",
"data": [
{
"trackDetails": [
{
"date": "2019-04-20 01:10:36",
"location": "深圳市",
"content": "【深圳处理中心】已出口直封",
"createDate": "2019-04-20 09:47:07"
},
{
"date": "2019-04-20 01:10:00",
"location": "",
"content": " Processed Through Facility SHENZHEN EMS, CHINA ",
"createDate": "2019-04-20 09:47:09"
},
{
"date": "2019-04-19 20:10:43",
"location": "深圳市",
"content": "【深圳】已出口开拆",
"createDate": "2019-04-20 09:47:07"
},
{
"date": "2019-04-19 20:10:00",
"location": "",
"content": " Processed Through Facility SHENZHEN, CHINA ",
"createDate": "2019-04-20 09:47:09"
},
{
"date": "2019-04-19 00:32:36",
"location": "深圳市",
"content": "已离开【中国香港中快收寄中心】",
"createDate": "2019-04-19 11:03:07"
},
{
"date": "2019-04-18 21:02:12",
"location": "深圳",
"content": "到达收货点",
"createDate": "2019-04-18 21:02:12"
},
{
"date": "2019-04-18 19:50:32",
"location": "深圳市",
"content": "【中国香港中快处理中心】已封发",
"createDate": "2019-04-19 11:03:07"
},
{
"date": "2019-04-18 19:42:29",
"location": "深圳市",
"content": "【中国香港中快收寄中心】已收寄",
"createDate": "2019-04-19 11:03:07"
},
{
"date": "2019-04-18 19:42:00",
"location": "",
"content": " Acceptance CHINA ",
"createDate": "2019-04-19 11:03:09"
}
],
"trackingNumber": "LT574081795CN"
},
{
"trackDetails": [
{
"date": "2019-04-20 01:15:06",
"location": "深圳市",
"content": "【深圳处理中心】已出口直封",
"createDate": "2019-04-20 09:47:06"
},
{
"date": "2019-04-20 01:15:00",
"location": "",
"content": " Processed Through Facility SHENZHEN EMS, CHINA ",
"createDate": "2019-04-20 09:47:08"
},
{
"date": "2019-04-19 20:10:43",
"location": "深圳市",
"content": "【深圳】已出口开拆",
"createDate": "2019-04-20 09:47:06"
},
{
"date": "2019-04-19 20:10:00",
"location": "",
"content": " Processed Through Facility SHENZHEN, CHINA ",
"createDate": "2019-04-20 09:47:08"
},
{
"date": "2019-04-19 00:32:36",
"location": "深圳市",
"content": "已离开【中国香港中快收寄中心】",
"createDate": "2019-04-19 11:03:40"
},
{
"date": "2019-04-18 21:02:12",
"location": "深圳",
"content": "到达收货点",
"createDate": "2019-04-18 21:02:12"
},
{
"date": "2019-04-18 19:50:32",
"location": "深圳市",
"content": "【中国香港中快处理中心】已封发",
"createDate": "2019-04-19 11:03:40"
},
{
"date": "2019-04-18 19:42:07",
"location": "深圳市",
"content": "【中国香港中快收寄中心】已收寄",
"createDate": "2019-04-19 11:03:40"
},
{
"date": "2019-04-18 19:42:00",
"location": "",
"content": " Acceptance CHINA ",
"createDate": "2019-04-19 11:04:42"
}
],
"trackingNumber": "LT574082310CN"
}
]
}
### 查询轨迹失败结果
{
"code": 200,
"timestamp": "2019-04-20 11:48:09",
"data": []
}
### 或者
{
"code": 400,
"errorType": "VALIDATION_ERROR",
"errorMessage": "输入的参数可能丢失或者无效",
"timestamp": "2019-04-20 11:50:27"
}
接口地址
xxxxxxxxxx
1、调用该接口可以获取已经推荐成功订单的九方系统状态。
请求地址
环境 | 请求地址 | 支持方法 | 返回数据格式 |
---|---|---|---|
生产环境 | http://www.tofba.com:8887/api/getOrderStatus | POST | JSON |
测试环境 | http://tofba1.f3322.net:8887/api/getOrderStatus | POST | JSON |
请求参数说明
请求参数 | Required | 描述 |
---|---|---|
token | Yes | 请求令牌,获取令牌参考获取Token |
customerCode | Yes | 九方ERP系统为客户生成的唯一客户编码 |
documentCode | Yes | 客户系统订单号,集合,一次最多允许传20个追踪号 |
请求样例
xxxxxxxxxx
POST /api/getOrderStatus?token=:token&customerCode=:customerCode
Host: www.tofba.com:8887/
Accept: application/json
Content-Type: application/json;charset=UTF-8
{
"documentCode": ["95958163", "95958035"]
}
响应结果
xxxxxxxxxx
### 成功
{
"code": 200,
"data": [
{
"orderNo": "95958163",
"status": 130
},
{
"orderNo": "95958035",
"status": 130
}
]
}
### 查询轨迹失败结果
{
"code": 200,
"timestamp": "2019-04-20 11:48:09",
"data": []
}
### 或者
{
"code": 400,
"errorType": "VALIDATION_ERROR",
"errorMessage": "输入的参数可能丢失或者无效",
"timestamp": "2019-04-20 11:50:27"
}
接口地址
xxxxxxxxxx
1、调用该接口可以获取已经推送成功并且返回追踪号的订单面单标签。
请求地址
环境 | 请求地址 | 支持方法 | 返回数据格式 |
---|---|---|---|
生产环境 | http://www.tofba.com:8887/api/getOrderLabel | POST | JSON |
测试环境 | http://tofba1.f3322.net:8887/api/getOrderLabel | POST | JSON |
请求参数说明
请求参数 | Required | 描述 |
---|---|---|
token | Yes | 请求令牌,获取令牌参考获取Token |
customerCode | Yes | 九方ERP系统为客户生成的唯一客户编码 |
documentCode | Yes | 追踪号,集合,一次最多允许传20个追踪号 |
请求样例
x
POST /api/getOrderLabel?token=:token&customerCode=:customerCode
Host: www.tofba.com:8887/
Accept: application/json
Content-Type: application/json;charset=UTF-8
{
"documentCode": [
"61290983235158571565", "74890983235158568943", "74890983235158560657"
]
}
响应结果
xxxxxxxxxx
### 响应成功
{
"code": 200,
"timestamp": "2019-04-22 16:17:12",
"data": [
{
"file": "面单Base64压缩码",
"trackerNumder": "61290983235158571565",
"url": "http://llfx.webok.net:9092/images/pdf/61290983235158571565.pdf"
},
{
"file": "",
"trackerNumder": "74890983235158568943",
"url": "http://llfx.webok.net:9092/images/pdf/74890983235158568943.pdf"
},
{
"file": "",
"trackerNumder": "74890983235158560657",
"url": "http://llfx.webok.net:9092/images/pdf/74890983235158560657.pdf"
}
]
}
### 失败结果
{
"code": 200,
"timestamp": "2019-04-20 11:48:09",
"data": []
}
### 或者
{
"code": 400,
"errorType": "VALIDATION_ERROR",
"errorMessage": "输入的参数可能丢失或者无效",
"timestamp": "2019-04-20 11:50:27"
}
响应结果data数据说明
字段 | 含义 |
---|---|
trackerNumder | 追踪号 |
url | 面单路径 |
file | 面单Base64压缩码 |
接口地址*
x
1、调用该接口可以取消已经推送至九方系统的订单。
请求地址
环境 | 请求地址 | 支持方法 | 返回数据格式 |
---|---|---|---|
生产环境 | http://www.tofba.com:8887/api/trashOrder | GET/POST | JSON |
测试环境 | http://tofba1.f3322.net:8887/api/trashOrder | GET/POST | JSON |
请求参数说明
请求参数 | Required | 描述 |
---|---|---|
token | Yes | 请求令牌,获取令牌参考获取Token |
customerCode | Yes | 九方ERP系统为客户生成的唯一客户编码 |
customerInvoiceCode | Yes | 九方ERP参考号,即客户所使用ERP系统中订单号 |
请求样例
x
GET/POST /api/trashOrder?token=:token&customerCode=:customerCode&customerInvoiceCode=:customerInvoiceCode
Host: www.tofba.com:8887/
Accept: application/json
Content-Type: application/json;charset=UTF-8
响应结果
xxxxxxxxxx
### 失败
{
"code": 400,
"errorType": "OPT_FAIL",
"errorMessage": "删除订单失败,订单系统不存在",
"timestamp": "2019-04-28 17:00:32"
}
### 成功
{
"code": 200,
"timestamp": "2019-04-28 16:59:37"
}
持续完善中.....
平台类型说明
序号 | 平台代码 | 平台描述 |
---|---|---|
1 | SUMAI | 速脉ERP |
2 | QQZS | 全球助手 |
3 | WDJL | 网店精灵 |
4 | IEBAY365 | IEBAY365 |
5 | STOMS | 赛兔OMS |
6 | TTERP | 通途ERP |
7 | MGDZ | 芒果店长 |
8 | LRERP | 懒人ERP |
9 | SUMOOL | 速猫ERP |
10 | GLBPAY | 上海九赢 |
11 | DXM | 店小秘 |
12 | ZYXT | 客户自用系统/其他不在列表中的均使用该代码 |
常用币种代码
货币名称 | 货币简称 | 货币名称 | 货币简称 |
---|---|---|---|
人民币 | RMB | 美元 | USD |
日元 | JPY | 欧元 | EUR |
英镑 | GBP | 德国马克 | DEM |
瑞士法郎 | CHF | 法国法郎 | FRF |
加拿大元 | CAD | 澳大利亚元 | AUD |
港币 | HKD | 奥地利先令 | ATS |
芬兰马克 | FIM | 比利时法郎 | BEF |
爱尔兰镑 | IEP | 意大利里拉 | ITL |
卢森堡法郎 | LUF | 荷兰盾 | NLG |
葡萄牙埃斯库多 | PTE | 西班牙比塞塔 | ESP |
印尼盾 | IDR | 马来西亚林吉特 | MYR |
新西兰元 | NZD | 菲律宾比索 | PHP |
俄罗斯卢布 | SUR | 新加坡元 | SGD |
韩国元 | KRW |
订单状态
状态码 | 状态描述 |
---|---|
10 | 待确认 |
20 | 待交寄 |
30 | 待入库 |
40 | 待出库 |
130 | 待派送 |
140 | 待签收 |
-20 | 已退货 |
参考代码
xxxxxxxxxx
/*订单实体*/
public class ExpressOrderApi implements Serializable {
private String token;// token
private String customerCode;// 客户编码
private Integer buyerId; // 选填
private String returnSign;// 退回标志默认N表示不退回Y标表示退回.中邮可以忽略该属性
private String customerInvoiceCode;// 原单号,必填
private String trackingNumber;// 追踪号
private String tradeType;// 平台类型
private String countryCode;// 收件国家二字码,必填
// ------------------------------------------------ 渠道信息
private Long productId;// 运输方式ID,必填
// ------------------------------------------------ 产品信息
private Integer orderPiece;// 下单件数
private Double weight;// 总重选填如果SKU上有单重可不填该项
private String transactionUrl;// 产品销售地址
// ------------------------------------------------ 代收货款业务
private Double collectionAmount;// 代收金额
private Double cargoAmount;// 订单实际金额用于报关申报
private Double insuranceAmount;// 保险金额
private String currencyCode;// 币种,标准三字代码
// ------------------------------------------------ 收件人信息
private String consigneeName;// 收件人,必填
private String consigneeAddress;// 收件人地址街道,必填
private String consigneeCity;// 收件人城市,必填
private String consigneePostCode;// 邮编有邮编,必填
private String consigneeState;// 收件人州/省,必填
private String consigneeTelephone;// 收件人电话,必填
private String consigneeMobile;// 手机号选填,选填
private String consigneeEmail;// 收件人邮箱,选填
private String consigneeCompanyName;// 收件公司名,选填
// ------------------------------------------------ 发件人信息
private String shipperName;// 发件人姓名,选填
private String shipperCompanyName;// 发件人公司名,选填
private String shipperAddress1;// 发件人地址1,选填
private String shipperAddress2;// 发件人地址2,选填
private String shipperAddress3;// 发件人地址3,选填
private String shipperCity;// 发件人城市,选填
private String shipperState;// 发件人州,选填
private String shipperPostCode;// 发件人邮编,选填
private String shipperCountry;// 发件人国家,选填
private String shipperTelephone;// 发件人电话,选填
private List<OrderInvoice> orderInvoices;
private List<OrderVolume> orderVolumes;
// 省略get和set方法
}
/*OrderInvoice*/
public class OrderInvoice implements Serializable {
private Double invoiceAmount;// 总申报货值,必填
private Integer invoicePcs;// 件数,必填
private String skuNameCn;// 中文品名,必填
private String skuNameEn;// 英文品名,必填
private String skuCode;// SKU,必填
private String hsCode;// 海关编码
private String invoicePurpose;// 用途
private Double invoiceWeight;// 单件重
// 省略get和set方法
}
/*OrderVolume*/
public class OrderVolume implements Serializable {
private Double length;
private Double width;
private Double height;
private Double weight;
// 省略get和set方法
}
/*Http请求方法*/
public class SendUrl {
public static String sendGet(String url) {
return sendGet(url, null);
}
public static String sendGet(String url, String param) {
String result = processSendGet(url, param, null);
return result;
}
public static String processSendGet(String url, String param, Map<String, String> paramMap) {
String result = "";
try {
String urlName = url;
if (null != param) {
urlName += "?" + param;
}
URL U = new URL(urlName);
URLConnection connection = U.openConnection();
if (null != paramMap) {
for (String key : paramMap.keySet()) {
connection.addRequestProperty(key, paramMap.get(key));
}
}
connection.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
in.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static InputStream sendGetReturnInputStream(String url, String param, Map<String, String> paramMap) {
InputStream inputStream = null;
try {
String urlName = url;
if (null != param) {
urlName += "?" + param;
}
URL U = new URL(urlName);
URLConnection connection = U.openConnection();
if (null != paramMap) {
for (String key : paramMap.keySet()) {
connection.addRequestProperty(key, paramMap.get(key));
}
}
connection.connect();
inputStream = connection.getInputStream();
} catch (Exception e) {
System.out.println(e);
}
return inputStream;
}
public static String sendPost(String url, Map<String, String> paramMap) {
String result = processSendPost(url, null, paramMap);
return result;
}
public static String sendPost(String url, String param) {
String result = processSendPost(url, param, null);
return result;
}
public static String processSendPost(String url, String param, Map<String, String> paramMap) {
String result = "";
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
}
}};
try {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (Exception e) {
e.printStackTrace();
}
BufferedReader reader = null;
try {
// Post请求的url,与get不同的是不需要带参数
URL postUrl = new URL(url);
// 打开连接
HttpURLConnection connection = (HttpURLConnection)postUrl.openConnection();
if (null != paramMap) {
for (String key : paramMap.keySet()) {
connection.addRequestProperty(key, paramMap.get(key));
}
}
connection.setConnectTimeout(40000);
connection.setReadTimeout(40000);
// Output to the connection. Default is
// false, set to true because post
// method must write something to the
// connection
// 设置是否向connection输出,因为这个是post请求,参数要放在
// http正文内,因此需要设为true
connection.setDoOutput(true);
// Read from the connection. Default is true.
connection.setDoInput(true);
// Set the post method. Default is GET
connection.setRequestMethod("POST");
// Post cannot use caches
// Post 请求不能使用缓存
connection.setUseCaches(false);
connection.setInstanceFollowRedirects(true);
// Set the content type to urlencoded,
// because we will write
// some URL-encoded content to the
// connection. Settings above must be set before connect!
// 配置本次连接的Content-type,配置为application/x-www-form-urlencoded的
// 意思是正文是urlencoded编码过的form参数,下面我们可以看到我们对正文内容使用URLEncoder.encode
// 进行编码
String contentType = "application/x-www-form-urlencoded";
if (null != paramMap) {
String _contentType = paramMap.get("Content-Type");
if (StringUtils.isNotEmpty(_contentType)) {
contentType = _contentType;
}
}
connection.setRequestProperty("Content-Type", contentType);
// 连接,从postUrl.openConnection()至此的配置必须要在connect之前完成,
// 要注意的是connection.getOutputStream会隐含的进行connect。
connection.connect();
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(connection.getOutputStream(), "UTF-8");
if (null != param) {
outputStreamWriter.write(param);
}
outputStreamWriter.flush();
outputStreamWriter.close();
String encoding = "utf-8";
if (null != paramMap && StringUtils.isNotEmpty(paramMap.get("encoding"))) {
encoding = paramMap.get("encoding");
}
reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), encoding));// 设置编码,否则中文乱码
String line = "";
while ((line = reader.readLine()) != null) {
result += line;
}
connection.disconnect();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != reader) {
reader.close();
}
} catch (Exception e) {
}
}
return result;
}
/**
* 模拟form表单请求
*
* @param requestUrl
* @param params
* @return
* @author Jeff(fba01)
* @version [版本号, 2018年3月30日]
* @see [类、类#方法、类#成员]
*/
public static String mockFormPost(String requestUrl, Map<String, String> params) {
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(requestUrl);
try {
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
if (params != null) {
for (Entry<String, String> entry : params.entrySet()) {
nvps.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
}
httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8"));
httpPost.setHeader("Content-type", "application/x-www-form-urlencoded");
HttpResponse httpResponse = httpClient.execute(httpPost);
int statusCode = httpResponse.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
System.out.println("Method is wrong " + httpResponse.getStatusLine());
return null;
}
return EntityUtils.toString(httpResponse.getEntity());
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
httpPost.releaseConnection();
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
/**
* 获取request中body的值
*
* @param request
* @return
* @author Jeff(fba01)
* @version [版本号, 2018年3月30日]
* @see [类、类#方法、类#成员]
*/
public static String gainRequestBodyConstent(HttpServletRequest request) {
String content = "";
if (null != request) {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
String str = "";
while ((str = reader.readLine()) != null) {
content += str;
}
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
return content;
}
/**
* 参数设置
* @return
* @author Henry(fba02)
*/
public static Map<String, String> getParamsMap() {
Map<String, String> map = new HashMap<String, String>();
map.put("Content-Type", "application/json");
map.put("Accept", "application/json");
return map;
}
}
/*创建订单*/
public static void main(String[] args) {
ExpressOrderApi expressOrderApi = new ExpressOrderApi();
expressOrderApi.setToken("4dfee9b82e8aec983ac0afb79aed1fee");
expressOrderApi.setCustomerCode("J0698");
expressOrderApi.setReturnSign("N");
expressOrderApi.setCustomerInvoiceCode("93778604");
expressOrderApi.setTradeType("ZYXT");
expressOrderApi.setCountryCode("US");
expressOrderApi.setProductId(Long.valueOf(2381));
expressOrderApi.setCurrencyCode("USD");
expressOrderApi.setTransactionUrl("https://www.amazon.com/gp/product/B07Q8RJSG7");
expressOrderApi.setOrderPiece(1);
expressOrderApi.setConsigneeName("Lorenzo Martin Del Campo Alvarado");
expressOrderApi.setConsigneeAddress("1538 SEDALIA WAY.");
expressOrderApi.setConsigneeCity("AURORA");
expressOrderApi.setConsigneePostCode("80011");
expressOrderApi.setConsigneeState("CO");
expressOrderApi.setConsigneeTelephone("7203817764");
expressOrderApi.setConsigneeMobile("13266829617");
expressOrderApi.setConsigneeEmail("zhc_hnust@outlook.com");
expressOrderApi.setConsigneeCompanyName("Lorenzo Martin Del Campo Alvarado");
expressOrderApi.setShipperName("Mr Zhang");
expressOrderApi.setShipperCompanyName("Haike Limited Comapany");
expressOrderApi.setShipperAddress1("3/F,Second Phase,Qianlong Logistics Park,,China South City,Pinghu,Longgang");
expressOrderApi.setShipperCity("SHEN ZHEN");
expressOrderApi.setShipperState("GUANG DONG");
expressOrderApi.setShipperPostCode("518111");
expressOrderApi.setShipperCountry("CN");
expressOrderApi.setShipperTelephone("17727165012");
List<OrderInvoice> orderInvoices = new ArrayList<OrderInvoice>();
OrderInvoice orderInvoice = new OrderInvoice();
orderInvoice.setSkuCode("GWAEBHK2");
orderInvoice.setInvoicePcs(1);
orderInvoice.setHsCode("6205300099");
orderInvoice.setSkuNameCn("Galaxy watch active保护壳黑色40mm 1片装");
orderInvoice.setSkuNameEn("watch cover");
orderInvoice.setInvoiceAmount(7.1);
orderInvoice.setInvoicePurpose("手机保护装置");
orderInvoices.add(orderInvoice);
expressOrderApi.setOrderInvoices(orderInvoices);
String json = new Gson().toJson(expressOrderApi);
SendUrl.processSendPost("http://192.168.180.22:8887/api/createOrder", json, SendUrl.getParamsMap());
}
关于作者
xxxxxxxxxx
联系人:曾先生
联系电话:13266829617(微信同号)
联系QQ:2851711830
Email:it01@tofba.com
由于时间仓促,错误在所难免,欢迎指正!