一、获取淘宝卖家店铺订单背景
订单是卖家的核心数据,卖家的很多日常工作都是围绕着订单展开,应用的基本功能就是要保证订单实时、完整的展示在卖家面前。由于API请求依赖于网络,存在 着网络不稳定和同步时间长的问题,所以应用必须把淘宝的订单数据同步到本地。如何才能快速、完整的把订单同步到本地是本方案将要讨论的问题。
二、名词解释
在线订单:卖家三个月内已卖出的订单。
增量订单:相对已经同步到本地的订单,凡是在淘宝上发生了变更的订单就是增量订单。
消息服务:一种通过HTTP长连接实时向客户端(应用)推送数据(交易)变更的渠道。
三、API介绍
taobao.trades.sold.get - 获取三个月内已卖出的在线订单,适用于用户初始化的时候使用,ISV不应该用此接口来获取增量订单。不建议使用或尽量少用此接口。
taobao.trades.sold.increment.get – 获取增量订单,适用于用户初始化后,增量同步发生变更的订单,ISV不应该用此接口来获取三个月内的订单。
taobao.trade.fullinfo.get - 获取单笔订单详情。
四、实施方案
订单同步主要分为初始化和增量获取两个步骤:
1、初始化是把3个月内的在线订单全部同步回来,这个需要较长的时间;
2、增量获取则是把淘宝发生了变更的订单同步回来,这个一般需要较短的时间。
五、代码展示
{"page": "1","real_total_results": "4959370","total_results": "4959370","page_size": "10","pagecount": "200","item": [{"title": "优衣库 【Theory联名款】女装 连帽外套 448450 UNIQLO","pic_url": "http://g./img/bao/uploaded/i4/i3/196993935/O1CN01PsEfDn1ewHIdMTmjI_!!0-item_pic.jpg_60x60.jpg","promotion_price": "199.00","price": "199.00","sales": "186","num_iid": "668508094727","seller_nick": "优衣库官方旗舰店","area": "上海","seller_id": "196993935","detail_url": "http://a./i668508094727.htm?&ttid=%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"},{"title": "优衣库防晒衣女装AIRism防紫外线拉链连帽开衫(春秋透气)433703","pic_url": "http://g./img/bao/uploaded/i4/i1/196993935/O1CN01THQ4jc1ewHIXivjCU_!!0-item_pic.jpg_60x60.jpg","promotion_price": "99.00","price": "99.00","sales": "4252","num_iid": "634981011414","seller_nick": "优衣库官方旗舰店","area": "上海","seller_id": "196993935","detail_url": "http://a./i634981011414.htm?&ttid=%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"},{"title": "优衣库 女装印花V领收腰连衣裙(春季 七分袖 法式风情)448065","pic_url": "http://g./img/bao/uploaded/i4/i2/196993935/O1CN01VSra8T1ewHHpq4zgu_!!0-item_pic.jpg_60x60.jpg","promotion_price": "149.00","price": "149.00","sales": "356","num_iid": "663771779061","seller_nick": "优衣库官方旗舰店","area": "上海","seller_id": "196993935","detail_url": "http://a./i663771779061.htm?&ttid=%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"},{"title": "优衣库女装半拉链卫衣(长袖运动衫 套头情侣卫衣) 442794/451155","pic_url": "http://g./img/bao/uploaded/i4/i3/196993935/O1CN012txBAe1ewHIbmP0us_!!0-item_pic.jpg_60x60.jpg","promotion_price": "79.00","price": "79.00","sales": "2734","num_iid": "658345840527","seller_nick": "优衣库官方旗舰店","area": "上海","seller_id": "196993935","detail_url": "http://a./i658345840527.htm?&ttid=%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"},{"title": "黑色西装裤女夏薄款九分西裤高腰裤子大码女裤秋冬垂感职业烟管裤","pic_url": "http://g./img/bao/uploaded/i4/i1/872268169/O1CN01D6P1Fb2ADS2sMR6RX_!!0-item_pic.jpg_60x60.jpg","promotion_price": "129.00","price": "129.00","sales": "2287","num_iid": "552967842105","seller_nick": "潞依韩旗舰店","area": "浙江 杭州","seller_id": "872268169","detail_url": "http://a./i552967842105.htm?&ttid=%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"},{"title": "优衣库 UNIQLO U女装 圆领T恤(白色短袖正肩上衣)435193","pic_url": "http://g./img/bao/uploaded/i4/i2/196993935/O1CN01XD3Hjc1ewHHgaXi2q_!!196993935.jpg_60x60.jpg","promotion_price": "79.00","price": "79.00","sales": "98","num_iid": "66979491","seller_nick": "优衣库官方旗舰店","area": "上海","seller_id": "196993935","detail_url": "http://a./i66979491.htm?&ttid=%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"},{"title": "妈妈秋装外套洋气高贵新款中年女士秋季风衣中老年人春秋上衣","pic_url": "http://g./img/bao/uploaded/i4/i3/2216096858/O1CN01RZHkJr20X0uuDSuiu_!!0-item_pic.jpg_60x60.jpg","promotion_price": "366.00","price": "366.00","sales": "1417","num_iid": "600291055211","seller_nick": "乔芙丽旗舰店","area": "湖北 武汉","seller_id": "2216096858","detail_url": "http://a./i600291055211.htm?&ttid=%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"},{"title": "太平鸟短款牛仔外套女春秋装新款炸街韩版宽松牛仔衣ins潮","pic_url": "http://g./img/bao/uploaded/i4/i2/112394247/O1CN01mbt8Jd1hFAs8ZGzTd_!!0-item_pic.jpg_60x60.jpg","promotion_price": "569.00","price": "569.00","sales": "551","num_iid": "620482928256","seller_nick": "太平鸟官方旗舰店","area": "浙江 宁波","seller_id": "112394247","detail_url": "http://a./i620482928256.htm?&ttid=%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"},{"title": "优衣库【UNIQLO U】女装AIRism棉混纺喇叭型长连衣裙(短袖)448069","pic_url": "http://g./img/bao/uploaded/i4/i3/196993935/O1CN01ulWkNQ1ewHHpVeAg4_!!0-item_pic.jpg_60x60.jpg","promotion_price": "149.00","price": "149.00","sales": "782","num_iid": "666989006518","seller_nick": "优衣库官方旗舰店","area": "上海","seller_id": "196993935","detail_url": "http://a./i666989006518.htm?&ttid=%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"},{"title": "美背内衣吊带背心女夏季内搭外穿文胸一体打底网红爆款带胸垫上衣","pic_url": "http://g./img/bao/uploaded/i4/i1/3481090180/O1CN01wD2a0A1DCTt5bmtYh_!!3481090180-0-lubanu-s.jpg_60x60.jpg","promotion_price": "69.00","price": "69.00","sales": "8478","num_iid": "615965749443","seller_nick": "法澳娜旗舰店","area": "浙江 温州","seller_id": "3481090180","detail_url": "http://a./i615965749443.htm?&ttid=%40taobao_h5_9.9.9&v=1.0&sid=25d90641cf102b2b17dfba392308cc3c"}],"_ddf": "cdy","error": "","reason": "","error_code": "0000","cache": 0,"api_info": "today:3 max:10100 all[22=3+2+17];expires:2030-12-31","execution_time": "2.609","server_time": "Beijing/-09-27 09:31:50","client_ip": "106.6.34.243","call_args": [],"api_type": "taobao","translate_language": "zh-CN","translate_engine": "baidu_api","server_memory": "5.93MB","request_id": "gw-3.6332528457059","last_id": "1246151746"}
如果觉得《【淘宝API开发系列】获取商品详情 商品评论 卖家订单接口》对你有帮助,请点赞、收藏,并留下你的观点哦!