公司由于购买了一套ERP,主要用于抓取各大平台订单进行仓库作业,有个客户由于是阿里巴巴店铺,由于阿里巴巴店铺后台没有单独设置的商品属性,因此抓取下里的SKU条码是整个页面的ID,就调查了一番并找到解决原因。
客户拍的订单的产品 http://detail.1688.com/offer/520715808273.html 地址
网店后台设置
看见抓取下来的SKUID不是在后台设置的因此就去阿里巴巴的API那去看接口定义了
http://gw.open.1688.com/dev/tools/api_test_aop.html?ns=cn.alibaba.open&n=trade.order.detail.get&v=1 地址
在下面填入相应的appkey app签名密匙 获取用户授权就可以进行获取所需信息了。
1:获取订单详情
{
"InvokeStartTime": "20151013132257352+0800",
"InvokeCostTime": 48,
"Status": {
"Code": 200,
"Message": "OK"
},
"Responses": [
{
"Status": {
"Code": 200,
"Message": "OK"
},
"Result": {
"message": null,
"result": {
"total": 1,
"toReturn": [
{
"sellerEmail": null,
"gmtModified": "20151008151716000+0800",
"tradeType": "6",
"buyerUserId": 832393331,
"orderEntries": [
{
"id": 1320343702663133,
"price": 4800,
"refundId": null,
"offerSnapshotImageUrl": "http://cbu01.alicdn.com/img/order/trading/331/366/2073430231/2312501537_1951861158.310x310.jpg",
"entryStatus": "waitbuyerreceive",
"productPic": "http://cbu01.alicdn.com/img/order/trading/331/366/2073430231/2312501537_1951861158.310x310.jpg",
"entryCodStatus": 0,
"specId": "9957d84126a023eac7e818cc8e19bb17",
"logisticsOrderId": 530939288,
"quantity": 1,
"productName": "厂家直销网布TPU底新款男士耐磨透气足球鞋防滑足球舒适",
"entryDiscount": 0,
"sourceId": 520715808273
}
],
"sumProductPayment": 4800,
"sellerRateStatus": 5,
"sumPayment": 5400,
"id": 1320343702663133,
"buyerFeedback": null,
"gmtPayment": "20151006171414000+0800",
"gmtCompleted": null,
"logistics": [
{
"logisticsBillNo": "100465708443",
"status": "alreadysend",
"fromContact": "罗志新",
"fromProvince": "2847",
"toPost": "315806",
"fromPost": null,
"toPhone": null,
"logisticsOrderNo": "ZX00000530939288",
"gmtSend": "20151008151716000+0800",
"toArea": "浙江省 宁波市 北仑区 大矸民乐村1095号B幢,吉兴制衣有限公司",
"fromMobile": null,
"logisticsId": 530939288,
"logisticsCompanyName": "圆通",
"toProvince": "-1",
"fromPhone": "86-0532-1dd53207839",
"toMobile": "1873244410150",
"fromAddress": "宁安路",
"toCity": "-1",
"toContact": "柯小涛",
"fromArea": "4156",
"fromCity": "2854",
"logisticsCompanyNo": "YTO",
"toAddress": null
}
],
"sellerUserId": 2561331698,
"sellerAlipayId": "2088022009133660",
"alipayTradeId": "2015100621001001580004295288",
"gmtCreate": "20151006171230000+0800",
"buyerRateStatus": 5,
"status": "waitbuyerreceive",
"carriage": 600,
"sellerCompanyName": "青岛霍尼特贸易有限公司",
"buyerEmail": null,
"sellerPhone": "86-0532-4543334343",
"buyerAlipayId": "2088702690180582",
"buyerMemberId": "b2b-832393331",
"discount": 0,
"buyerMobile": null,
"gmtGoodsSend": "20151008151716000+0800",
"buyerPhone": "",
"sellerMemberId": "b2b-2561331698nkpim",
"refundPayment": 0,
"closeReason": null,
"sellerMobile": null
}
],
"success": true
},
"code": null
}
}
]
}
2:解析订单详情的JSON数据得到 "sourceId":520715808273 和"specId":"9957d84126a023eac7e818cc8e19bb17" 然后根据sourceId 获取详细下面的的所有颜色尺码
的信息 sourceId 就是订单的产品 http://detail.1688.com/offer/520715808273.html 的地址 也就是顶部的主ID
{
"result": {
"total": 1,
"toReturn": [
{
"skuArray": [
{
"fid": 3216,
"value": "红色",
"children": [
{
"fid": 450,
"retailPrice": "",
"price": "",
"canBookCount": 5000,
"cargoNumber": "15A560340",
"specId": "174d6754d131c1404834e0c8f0e0d8b7",
"value": "40",
"saleCount": 0
},
{
"fid": 450,
"retailPrice": "",
"price": "",
"canBookCount": 5000,
"cargoNumber": "15A560341",
"specId": "bdf68773fe0896aac520b33337365b88",
"value": "41",
"saleCount": 0
},
{
"fid": 450,
"retailPrice": "",
"price": "",
"canBookCount": 5000,
"cargoNumber": "15A560342",
"specId": "43b7b1f10fca2df514204ba5462f2fe6",
"value": "42",
"saleCount": 0
},
{
"fid": 450,
"retailPrice": "",
"price": "",
"canBookCount": 5000,
"cargoNumber": "15A560343",
"specId": "b5cac471ae2ef667df339044c9e97099",
"value": "43",
"saleCount": 0
},
{
"fid": 450,
"retailPrice": "",
"price": "",
"canBookCount": 5000,
"cargoNumber": "15A560344",
"specId": "39e860c1d517dc2216bce26106b1ab10",
"value": "44",
"saleCount": 0
}
]
},
{
"fid": 3216,
"value": "蓝色",
"children": [
{
"fid": 450,
"retailPrice": "",
"price": "",
"canBookCount": 5000,
"cargoNumber": "15A561940",
"specId": "39d077517ebaae7b5cb00a1e621cfb02",
"value": "40",
"saleCount": 1
},
{
"fid": 450,
"retailPrice": "",
"price": "",
"canBookCount": 5000,
"cargoNumber": "15A561941",
"specId": "fd2173f6cc74d724a99f7d6f2a75b977",
"value": "41",
"saleCount": 1
},
{
"fid": 450,
"retailPrice": "",
"price": "",
"canBookCount": 5000,
"cargoNumber": "15A561942",
"specId": "20133821574d7db283cc8c82a4154ec9",
"value": "42",
"saleCount": 1
},
{
"fid": 450,
"retailPrice": "",
"price": "",
"canBookCount": 4999,
"cargoNumber": "15A561943",
"specId": "9957d84126a023eac7e818cc8e19bb17",
"value": "43",
"saleCount": 2
},
{
"fid": 450,
"retailPrice": "",
"price": "",
"canBookCount": 5000,
"cargoNumber": "15A561944",
"specId": "3b9ce2ca98c6724edace309a77af4f27",
"value": "44",
"saleCount": 1
}
]
},
{
"fid": 3216,
"value": "黑色",
"children": [
{
"fid": 450,
"retailPrice": "",
"price": "",
"canBookCount": 5000,
"cargoNumber": "15A560140",
"specId": "f279f76ad1b737009211a09179cb4d19",
"value": "40",
"saleCount": 1
},
{
"fid": 450,
"retailPrice": "",
"price": "",
"canBookCount": 5000,
"cargoNumber": "15A560141",
"specId": "f13a9daaf289f5b716d04a2b3b8fc2b0",
"value": "41",
"saleCount": 1
},
{
"fid": 450,
"retailPrice": "",
"price": "",
"canBookCount": 5000,
"cargoNumber": "15A560142",
"specId": "b825000ae9a12f71815406c77db3c440",
"value": "42",
"saleCount": 2
},
{
"fid": 450,
"retailPrice": "",
"price": "",
"canBookCount": 5000,
"cargoNumber": "15A560143",
"specId": "eea47f53753ea744a2915efa56dd1263",
"value": "43",
"saleCount": 5
},
{
"fid": 450,
"retailPrice": "",
"price": "",
"canBookCount": 5000,
"cargoNumber": "15A560144",
"specId": "1ef04a8c3262c38535070c23ddc0e091",
"value": "44",
"saleCount": 0
}
]
}
]
}
],
"success": true
}
}
取得SKU规格属性信息{fid:value}当有多个值时用"#"联接,然后进行 JSON解析,然后用第一步取得的specid与第一步解析后的specid比较 取出"cargoNumber":"15A561943"
这样就能得到单品货号了。