拼多多开放平台:https://open.pinduoduo.com
拼多多提供了Java版本的SDK,所以调用起来特别容易。
1.pdd.logistics.address.get获取拼多多标准国家地址库
String clientId = "your clientId";
String clientSecret = "your clientSecret";
String accessToken = "your accessToken";
// PopBaseHttpRequest request = new PddLogisticsAddressGetRequest();
PddLogisticsAddressGetRequest request = new PddLogisticsAddressGetRequest();
PopClient client = new PopHttpClient(clientId, clientSecret);
String jsonStr = JsonUtil.transferToJson(client.syncInvoke(request, accessToken));
System.out.println(jsonStr);
2.pdd.logistics.companies.get快递公司查看接口
String clientId = "your clientId";
String clientSecret = "your clientSecret";
String accessToken = "your accessToken";
// PopBaseHttpRequest request = new PddLogisticsCompaniesGetRequest();
PddLogisticsCompaniesGetRequest request = new PddLogisticsCompaniesGetRequest();
PopClient client = new PopHttpClient(clientId, clientSecret);
String jsonStr = JsonUtil.transferToJson(client.syncInvoke(request, accessToken));
System.out.println(jsonStr);
3.pdd.order.list.get订单列表查询接口(根据成交时间)
String clientId = "your clientId";
String clientSecret = "your clientSecret";
String accessToken = "your accessToken";
// PopBaseHttpRequest request = new PddOrderListGetRequest();
PddOrderListGetRequest request = new PddOrderListGetRequest();
// 发货状态,1:待发货,2:已发货待签收,3:已签收 5:全部
request.setOrderStatus(5);
// 售后状态 1:无售后或售后关闭,2:售后处理中,3:退款中,4: 退款成功 5:全部
request.setRefundStatus(5);
// 成交时间的10位的时间戳,间隔不超过 24 小时
request.setStartConfirmAt(1599505839l);
request.setEndConfirmAt(1599535262l);
// 返回页码 默认 1,页码从 1 开始 PS:当前采用分页返回,数量和页数会一起传,如果不传,则采用 默认值
request.setPage(1);
// 返回数量,默认 100。最大 100
request.setPageSize(1);
// 订单类型 0-普通订单 ,1- 定金订单
// request.setTradeType(1);
// 是否启用has_next的分页方式,如果指定true,则返回的结果中不包含总记录数,但是会新增一个是否存在下一页的的字段,通过此种方式获取增量交易,效率在原有的基础上有80%的提升。
// request.setUseHasNext(false);
PopClient client = new PopHttpClient(clientId, clientSecret);
String jsonStr = JsonUtil.transferToJson(client.syncInvoke(request, accessToken));
System.out.println(jsonStr);
苏宁开放服务:http://open.suning.com
苏宁提供了Java版本的SDK,所以调用起来相对容易。举三个例子,已包含了常用功能的所有可能调用情况
1.API接口目录>平台业务>物流API>suning.custom.logisticcompany.query 获取物流公司代码(查询全部)
import com.suning.api.DefaultSuningClient;
import com.suning.api.SelectSuningRequest;
import com.suning.api.entity.transaction.LogisticcompanyQueryRequest;
import com.suning.api.exception.SuningApiException;
String appKey = "你的appKey";
String appSecret = "你的appSecret";
// SelectSuningRequest<?> request = new LogisticcompanyQueryRequest();
LogisticcompanyQueryRequest request = new LogisticcompanyQueryRequest();
// 页数从1开始,每页最大100
request.setPageNo(1);// 必填
request.setPageSize(100);// 必填
String serverUrl = "https://open.suning.com/api/http/sopRequest";
DefaultSuningClient client = new DefaultSuningClient(serverUrl, appKey, appSecret, "json");
String jsonStr = client.excute(request).getBody();
System.out.println(jsonStr);
2.API接口目录>平台业务>店铺API>suning.custom.shopinfo.get 获取店铺基本信息
import com.suning.api.DefaultSuningClient;
import com.suning.api.SuningRequest;
import com.suning.api.entity.shop.ShopInfoGetRequest;
import com.suning.api.exception.SuningApiException;
String appKey = "你的appKey";
String appSecret = "你的appSecret";
String accessToken = "你的accessToken";
// SuningRequest<?> request = new ShopInfoGetRequest();
ShopInfoGetRequest request = new ShopInfoGetRequest();
String serverUrl = "https://open.suning.com/api/http/sopRequest";
DefaultSuningClient client = new DefaultSuningClient(serverUrl, appKey, appSecret, accessToken, "json");
String jsonStr = client.excute(request).getBody();
System.out.println(jsonStr);
3.API接口目录>平台业务>交易API>suning.custom.order.query 批量获取订单(三个月内的订单)
import com.suning.api.DefaultSuningClient;
import com.suning.api.SelectSuningRequest;
import com.suning.api.entity.custom.orderQueryQueryRequest;
import com.suning.api.exception.SuningApiException;
String appKey = "你的appKey";
String appSecret = "你的appSecret";
String accessToken = "你的accessToken";
// SelectSuningRequest<?> request = new orderQueryQueryRequest();
orderQueryQueryRequest request = new orderQueryQueryRequest();
// yyyy-MM-dd HH:mm:ss间隔不超过31天
request.setStartTime("2020-08-15 10:00:00");
request.setEndTime("2020-08-15 23:00:00");
// 页数从1开始,每页最大100
request.setPageNo(1);
request.setPageSize(100);
// 订单头状态(10:买家已付款,20:卖家已发货,21:部分发货,30:交易成功,40:交易关闭)
// request.setOrderStatus("");
String serverUrl = "https://open.suning.com/api/http/sopRequest";
DefaultSuningClient client = new DefaultSuningClient(serverUrl, appKey, appSecret, accessToken, "json");
String jsonStr = client.excute(request).getBody();
System.out.println(jsonStr);
阿里巴巴开放平台:https://open.1688.com
阿里巴巴提供了Java版本的SDK
1.物流>物流公司列表-所有的物流公司 com.alibaba.logistics:alibaba.logistics.OpQueryLogisticCompanyList-1
String app_key = "";
String app_secret = "";
String access_token = "";
AlibabaLogisticsOpQueryLogisticCompanyListParam param = new AlibabaLogisticsOpQueryLogisticCompanyListParam();
SDKResult<?> results = new ApiExecutor(app_key, app_secret).execute(param, access_token);
Object obj = results.getResult();
AlibabaLogisticsOpQueryLogisticCompanyListResult result = (AlibabaLogisticsOpQueryLogisticCompanyListResult) obj;
HashMap<Object, Object> map = new HashMap<>();
if (result.getSuccess()) {
AlibabaLogisticsOpLogisticsCompanyModel[] res = result.getResult();
for (AlibabaLogisticsOpLogisticsCompanyModel mode : res) {
map.put(mode.getCompanyNo(), mode.getCompanyName());
}
}
String strJson = JSON.toJSONString(map);
System.out.println(strJson);
2.交易>订单列表查看(卖家视角) com.alibaba.trade:alibaba.trade.getSellerOrderList-1
String app_secret = "";
String access_token = "";
AlibabaTradeGetSellerOrderListParam param = new AlibabaTradeGetSellerOrderListParam();
param.setPage(1);
param.setPageSize(20);
param.setCreateStartTime(new Date());// 20180721172608000+0800
param.setCreateEndTime(new Date());// 20180721172608000+0800
SDKResult<?> results = new ApiExecutor(app_key, app_secret).execute(param, access_token);
Object obj = results.getResult();
AlibabaTradeGetSellerOrderListResult result = (AlibabaTradeGetSellerOrderListResult) obj;
if (result.getSuccess()) {
AlibabaOpenplatformTradeModelTradeInfo[] res = result.getResult();
for (AlibabaOpenplatformTradeModelTradeInfo mode : res) {
// 订单基础信息
AlibabaOpenplatformTradeModelOrderBaseInfo baseInfo = mode.getBaseInfo();
// 商品条目信息
AlibabaOpenplatformTradeModelProductItemInfo[] productItems = mode.getProductItems();
// 交易条款
AlibabaOpenplatformTradeModelTradeTermsInfo[] tradeTerms = mode.getTradeTerms();
// 订单评价信息
AlibabaTradeOrderRateInfo orderRateInfo = mode.getOrderRateInfo();
// 发票信息
AlibabaInvoiceOrderInvoiceModel orderInvoiceInfo = mode.getOrderInvoiceInfo();
}
}
3.交易>订单详情查看(卖家视角) com.alibaba.trade:alibaba.trade.get.sellerView-1
String app_key = "";
String app_secret = "";
String access_token = "";
AlibabaTradeGetSellerViewParam param = new AlibabaTradeGetSellerViewParam();
param.setOrderId(1111l);
SDKResult<?> results = new ApiExecutor(app_key, app_secret).execute(param, access_token);
Object obj = results.getResult();
AlibabaTradeGetSellerViewResult result = (AlibabaTradeGetSellerViewResult) obj;
if (result.getSuccess() != null) {
AlibabaOpenplatformTradeModelTradeInfo res = result.getResult();
// 订单基础信息
AlibabaOpenplatformTradeModelOrderBaseInfo baseInfo = res.getBaseInfo();
// 国内物流
AlibabaOpenplatformTradeModelNativeLogisticsInfo nativeLogistics = res.getNativeLogistics();
// 运单明细
AlibabaOpenplatformTradeModelNativeLogisticsItemsInfo[] logisticsItems = nativeLogistics.getLogisticsItems();
}