Api-批量导入订单 ¶
- 请输入原订单订单号,地址,SKU,库存,仓库,等等信息进行订单创建:供销商在自己平台产生的订单,可以通过该api,把订单导入到Quarkscm中。
- 在Quarkscm.com 后台通过余额付款:通过该接口把订单成功导入分销系统后,您需要前往http://www.quarkscm.com 登录账户,登录成功后点击 批量下单,为每一个订单选择货运方式,然后点击 合并支付 按钮,进行站内余额付款,
- 如果您站内余额不足,那么您需要先访问 钱包 进行充值。
- 如果付款成功的订单会进入 我的订单 页面,如果付款没有成功订单会保留在 批量下单 页面。
准备工作 ¶
您需要先获取access-toekn,获取access-toekn参看接口: Api-获取access-token
Api-批量导入订单 ¶
URL: https://dpapi.quarkscm.com/v1/myorder/import
格式:json
方式:post
注意:所有参数必须是utf-8字符集
Request Header ¶
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
access-token | 必须 | String | 身份验证,获取access-toekn参看接口: Api-获取access-token |
Body Form-Data: ¶
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
orderInfos | 必须 | Array | 订单数组 |
orderInfos
是一个数组,数组中的每一个子项的格式如下:
子参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
orginal_order_no | 必须 | String | 订单在分销商的订单号 |
customer_firstname | 必须 | String | 订单客户的firstname |
customer_lastname | 必须 | String | 订单客户的lastname |
customer_telephone | 必须 | String | 订单客户的电话 |
customer_email | 必须 | String | 订单客户的下单邮箱 |
customer_address_country | 必须 | String | 订单客户的收货地址:国家 |
customer_address_state | 必须 | String | 订单客户的收货地址:省/州 |
customer_address_city | 必须 | String | 订单客户的收货地址:城市 |
customer_address_street1 | 必须 | String | 订单客户的收货地址:详细地址1 |
customer_address_street2 | 选填 | String | 订单客户的收货地址:详细地址2 |
remark | 选填 | String | 备注:(买家留言.不能超过1000个字符) |
customer_address_zip | 必须 | String | 订单客户的收货地址:邮编 |
shipping_method | 必须 | String | 货运方式 |
origin_order_platforms | 必须 | String | 订单所属平台 ,ebay,amazon,aliexpress,wish,lazada,other |
origin_amount | 选填 | Number | 订单金额(美元) |
products | 必须 | String | 订单产品 |
products
是一个数组,数字中的每一个子项的格式如下:
子参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
sku | 必须 | String | Sku |
warehouse | 必须 | String | 仓库CODE |
qty | 必须 | Number | 订单产品数 |
请求参数示例如下:
{
"orderInfos": [
{
"orginal_order_no":"1000001",
"customer_firstname":"terry",
"customer_lastname":"water",
"customer_telephone":"1933434343",
"customer_email":"232324@qq.com",
"customer_address_country":"US",
"customer_address_state":"STSDF",
"customer_address_city":"FDFD",
"customer_address_zip":"231334",
"customer_address_street1":"XXXXX",
"customer_address_street2":"TTTTT",
"remark":"what is next",
"origin_order_platforms":"amazon",
"shipping_method" : "P",
"origin_amount":44,
"products":[
{
"sku":"xxxx",
"warehouse":"SZ1",
"qty":2
},
{
"sku":"yyyy",
"warehouse":"UK",
"qty":1
}
]
},
{
"orginal_order_no":"1000002",
"customer_firstname":"terry",
"customer_lastname":"water",
"customer_telephone":"1933434343",
"customer_email":"232324@qq.com",
"customer_address_country":"US",
"customer_address_state":"STSDF",
"customer_address_city":"FDFD",
"customer_address_zip":"231334",
"customer_address_street1":"XXXXX",
"customer_address_street2":"TTTTT",
"remark":"what is next",
"origin_order_platforms":"amazon",
"shipping_method" : "D",
"origin_amount":44,
"products":[
{
"sku":"xxxx",
"warehouse":"SZ1",
"qty":2
},
{
"sku":"yyyy",
"warehouse":"UK",
"qty":1
}
]
}
]
}
返回参数 ¶
格式:json
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
code | 必须 | Number | 200 代表完成 |
details | 必须 | Array | 订单批量导入各个订单的详细情况 |
注意:code 值为200,并不代表所有的订单导入成功,需要到details里面查看详细
details数组的子参数
子参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
status | 必须 | String | success 代表导入成功,fail代表导入失败 |
orderNo | 必须 | String | 订单所在平台的订单号 |
info | 必须 | String | 如果status为fail,这里为失败的详情原因 |
返回参数的示例如下:
{
"code":200,
"details":[
{
"status":"success",
"orderNo":"100000001",
"info":""
},
{
"status":"fail",
"orderNo":"100000002",
"info":"stock is out"
},
{
"status":"fail",
"orderNo":"100000003",
"info":"you must fill request param [必须填的请求参数]"
}
]
}
php 代码示例: ¶
<?php
function getCurlData($url,$type="get",$data=array(),$timeout = 10) {
//对空格进行转义
$url = str_replace(' ','+',$url);
if ($type == "get") {
if (!empty($data) && is_array($data)) {
$arr = [];
foreach ($data as $k=>$v) {
$arr[] = $k."=".$v;
}
$str = implode("&",$arr);
if (strstr($url,"?")) {
$url .= "&".$str;
} else {
$url .= "?".$str;
}
}
}
$access_token = '';
if(isset($data['access-token'])){
$access_token = $data['access-token'];
unset($data['access-token']);
}
$data = json_encode($data);
$ch = curl_init();
//设置选项,包括URL
curl_setopt($ch, CURLOPT_URL, "$url");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_TIMEOUT,$timeout); //定义超时3秒钟
if($type == "post"){
// POST数据
curl_setopt($ch, CURLOPT_POST, 1);
$http_header = [
'Accept: application/json',
'Content-Type: application/json',
'Content-Length: ' . strlen($data),
];
if($access_token){
$http_header[] = 'access-token: ' . $access_token;
}
curl_setopt($ch, CURLOPT_HTTPHEADER,$http_header);
// 把post的变量加上
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
//执行并获取url地址的内容
$output = curl_exec($ch);
//echo $output ;
//释放curl句柄
curl_close($ch);
//var_dump($output);exit;
return $output;
}
$post_data = [
'access-token' => '6-BXC_GVOQuLEpQ9VXVpTknU2z52LLxl',
'orderInfos' => [
[
'orginal_order_no' => '1000001', // 原始订单号
'customer_firstname' => 'terry', // 客户的first name
'customer_lastname' => 'water', // 客户的last name
'customer_telephone' => '1933434343', // 客户的电话
'customer_email' => '232324@qq.com', // 客户的email
'customer_address_country' => 'US', // 客户的国家简码,譬如CN,US,
'customer_address_state' => 'STSDF', // 客户收货地址的省/州
'customer_address_city' => 'FDFD', // 客户收货地址的城市
'customer_address_zip' => '231334', // 客户收货地址的邮政编码
'customer_address_street1' => 'XXXXX', // 客户收货地址的详细地址1
'customer_address_street2' => 'TTTTT', // 客户收货地址的详细地址2
'remark' => 'what is next' //备注
'origin_order_platforms' => 'ebay', // 原始订单所在的平台 ,ebay,amazon,aliexpress,wish,lazada,other
'origin_amount' => 33, // 原始订单的金额(美元)
'shipping_method' => 'P', //货运方式
'products' => [
[
'sku' =>'P1341W-EU',
'warehouse' =>'CN',
'qty' => 1
],
[
'sku' => 'P1380S-EU',
'warehouse' => 'CN',
'qty' => 1
],
]
],
//[...] , other order
]
];
$api_url = 'https://dpapi.quarkscm.com/v1/myorder/import';
$return_data = getCurlData($api_url,'post',$post_data,10);
var_dump($return_data);
返回结果:
{"code":200,"details":[{"status":"fail","orderNo":"1000001","info":"sku: is stock out"}]}