|
@@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import util.HttpClientHelper;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.Date;
|
|
|
+
|
|
|
/**
|
|
|
* TMS接口调用实例,以 "获取登陆凭证接口"、 "创建订单接口"、 "批量查询订单接口" 为例
|
|
|
* 其余接口调用方式相同;
|
|
@@ -18,6 +21,8 @@ public class TmsApiDemo {
|
|
|
|
|
|
private static final String PASSWORD = "123456";
|
|
|
|
|
|
+ private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
public static void main(String[] args) {
|
|
|
System.out.println("*********************获取登陆凭证接口*********************");
|
|
|
JSONObject tokenParams = new JSONObject();
|
|
@@ -33,6 +38,7 @@ public class TmsApiDemo {
|
|
|
System.out.println("ACCESS_TOKEN = " + accessToken);
|
|
|
System.out.println("REFRESH_TOKEN = " + refreshToken);
|
|
|
System.out.println();
|
|
|
+
|
|
|
System.out.println("*********************创建订单接口*********************");
|
|
|
JSONObject createOrderParams = new JSONObject();
|
|
|
JSONArray orders = new JSONArray();
|
|
@@ -67,6 +73,7 @@ public class TmsApiDemo {
|
|
|
JSONArray orderNumberList = createOrderResponse.getJSONArray("data");
|
|
|
System.out.println("TMS生成的单号:" + orderNumberList);
|
|
|
System.out.println();
|
|
|
+
|
|
|
System.out.println("*********************批量查询订单接口*********************");
|
|
|
JSONObject queryOrderParams = new JSONObject();
|
|
|
//页码,1开始
|
|
@@ -77,8 +84,8 @@ public class TmsApiDemo {
|
|
|
queryOrderParams.put("state", 1000);
|
|
|
//查询时间类型,created录入时间,deliveryed提货时间,appointArrived预约提货时间,signed签收时间
|
|
|
queryOrderParams.put("timeType", "created");
|
|
|
- queryOrderParams.put("startDate", "2019-12-15 00:00:00");
|
|
|
- queryOrderParams.put("endDate", "2019-12-18 16:00:00");
|
|
|
+ queryOrderParams.put("startDate", dateFormat.format(new Date(System.currentTimeMillis() - 24 * 3600 * 1000)));
|
|
|
+ queryOrderParams.put("endDate", dateFormat.format(new Date()));
|
|
|
result = HttpClientHelper.httpPost(URL + "/order/query_orders?access_token=" + accessToken, queryOrderParams);
|
|
|
JSONObject queryOrderResponse = JSONObject.parseObject(result);
|
|
|
JSONObject queryOrders = queryOrderResponse.getJSONObject("data");
|