订单搜索接口,获取全部待发货数据示例
订单搜索接口返回的数据默认只返回第一页的数据,每页数据默认返回 20 条,所以当您入参信息只传入订单状态时,只会返回 20 条数据。
如果想要返回全部数据,需要传入 page_no 和 page_size,通过遍历 page_no 来获取全部数据。注意:每页最大支持返回 100 条数据,最多支持 100 页。
示例:
YouzanTradesSoldGet youzanTradesSoldGet = new YouzanTradesSoldGet();
//创建参数对象,并设置参数
YouzanTradesSoldGetParams youzanTradesSoldGetParams = new YouzanTradesSoldGetParams();
youzanTradesSoldGetParams.setStatus("WAIT_SELLER_SEND_GOODS");
youzanTradesSoldGet.setAPIParams(youzanTradesSoldGetParams);
try {
YouzanTradesSoldGetResult result = yzClient.invoke(youzanTradesSoldGet, token, YouzanTradesSoldGetResult.class);
int pageNo = 0,pageSize = 100;
Long totalResults = result.getData().getTotalResults();
Long totalPageNo = totalResults / pageSize + 1;
for (int i = 0; i < totalPageNo; i++) {
pageNo = i+ 1;
youzanTradesSoldGetParams.setPageNo(pageNo);
youzanTradesSoldGetParams.setPageSize(pageSize);
youzanTradesSoldGetParams.setStatus("WAIT_SELLER_SEND_GOODS");
youzanTradesSoldGet.setAPIParams(youzanTradesSoldGetParams);
YouzanTradesSoldGetResult result1 = yzClient.invoke(youzanTradesSoldGet, token, YouzanTradesSoldGetResult.class);
System.out.println(JSONObject.toJSONString(result1));
}
} catch (SDKException e) {
e.printStackTrace();
}