1.1. 验签及传参
1.1.1. 传参
所有参数都使用form-data传参,http method 全部使用POST
接口版本号
v1
说明:所有接口path都有一个版本参数,如:https://www.qianyierp.com/api/{version}/asn,其中{version}字段若没有特别说明,那么这个参数固定为v1
编码方式
UTF-8
1.1.2. 公共请求参数
参数 | 是否必须 | 类型 | 示例 | 备注 |
---|---|---|---|---|
appId | Y | String | “abc” | 千易应用ID,联系千易官方获取 |
serviceType | Y | String | “QUERY_SALES_ORDER_LIST” | 请求接口名 |
sign | Y | String | 签名字符串 | |
bizParam | Y | String | “JSON” | 接口参数,只支持json格式的字符串 |
timestamp | Y | Number | 时间戳,单位毫秒 |
sign生成
将除了sign之外的全部参数,按照参数名的ASCII码递增排序(字母顺序升序排序)后拼接起来,然后再拼接上token,如:a=参数值ab=参数值b{openApi_TOKEN},最后使用md5生成sign字符串
1.1.3. 公共返回参数 JSON
参数 | 是否必须 | 类型 | 示例 | 备注 |
---|---|---|---|---|
errorCode | Y | String | 0 | 错误码 |
errorMsg | Y | String | 错误信息 | |
state | Y | String | success | 请求结果 |
bizContent | Y | String | {"id":"1", ...} | 业务返回参数,只支持json格式 |
1.1.4. 签名示例
appId:openApi_TEST
serviceType:CREATE_ASN_ORDER
bizParam:{"asnSkuVOList":[{"expectQuantity":"100","sku":"SKU1230","purchasePrice":"10","transferPrice":"100","firstLegPrice":"100"}],"warehouseName":"best warehouse(测试用)","customNumber":"xx1224325212","trackNumber":"xx1223122","remark":"xx122312","purchasePriceCurrency":"CNY","firstLegPriceCurrency":"CNY","transferPriceCurrency":"CNY"}
timestamp:1662448537275
sign:b3dfeed438e36f1f89534ce415cf4113
排序后的参数字符串:
appId=openApi_TESTbizParam={"asnSkuVOList":[{"expectQuantity":"100","sku":"SKU1230","purchasePrice":"10","transferPrice":"100","firstLegPrice":"100"}],"warehouseName":"best warehouse(测试用)","customNumber":"xx1224325212","trackNumber":"xx1223122","remark":"xx122312","purchasePriceCurrency":"CNY","firstLegPriceCurrency":"CNY","transferPriceCurrency":"CNY"}serviceType=CREATE_ASN_ORDERtimestamp=1662448537275openApi_TOKEN
appId: openApi_TEST
appSecrest: openApi_TOKEN
package com.example.yahoo.test;
import org.springframework.util.DigestUtils;
import java.nio.charset.Charset;
public class SignUtils {
public static final String EQUAL_SIGN = "=";
public static final String APP_ID = "appId";
public static final String SERVICE_TYPE = "serviceType";
public static final String BIZ_PARAM = "bizParam";
public static final String TIMESTAMP = "timestamp";
public static String calcSign(final String appId, final String bizParam, final String serviceType, final Long timestamp,
final String secret) {
byte[] bytes = buildSignStr(appId, bizParam, serviceType, timestamp, secret)
.getBytes(Charset.forName("UTF-8"));
return new String(DigestUtils.md5DigestAsHex(bytes).getBytes(Charset.forName("UTF-8")));
}
private static String buildSignStr(final String appId, final String bizParam, final String serviceType, final Long timestamp,
final String secret) {
StringBuilder checkStr = new StringBuilder();
checkStr.append(APP_ID).append(EQUAL_SIGN).append(appId)
.append(BIZ_PARAM).append(EQUAL_SIGN).append(bizParam)
.append(SERVICE_TYPE).append(EQUAL_SIGN).append(serviceType)
.append(TIMESTAMP).append(EQUAL_SIGN).append(timestamp)
.append(secret);
return checkStr.toString();
}
}

1.1.5. 请求地址
环境 | 地址 |
---|---|
国内生产环境 | www.qianyierp.com |
海外生产环境 | asia.qianyierp.com |
测试环境 | gerp-test1.800best.com |