|
@@ -0,0 +1,71 @@
|
|
|
+package demo;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import org.apache.http.HttpResponse;
|
|
|
+import org.apache.http.client.HttpClient;
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
+import org.apache.http.entity.ContentType;
|
|
|
+import org.apache.http.entity.StringEntity;
|
|
|
+import org.apache.http.impl.client.HttpClientBuilder;
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by lxji on 2017/9/5.
|
|
|
+ */
|
|
|
+public class TestCreatePack {
|
|
|
+ private static final String BASEURL = "http://api.test.56ctms.com";
|
|
|
+ private static final String token = "e75fe624-eab6-4238-85f8-1cdb82d71568";
|
|
|
+
|
|
|
+ public static void main(String[] args) throws IOException {
|
|
|
+ HttpPost httpPost = new HttpPost(BASEURL + "/order/create_order_pack" + "?access_token=" + token);
|
|
|
+
|
|
|
+ JSONObject order = new JSONObject();
|
|
|
+ order.put("orderNumber", "wmssn1231231111122211");
|
|
|
+ order.put("batchNumber", "batchNumber1231232222233322");
|
|
|
+ order.put("customerOrderNumber", "customerOrderNumber12312344433");
|
|
|
+ order.put("deliveryTime", 1502880855);
|
|
|
+ order.put("appointArriveTime", (int)(System.currentTimeMillis() / 1000));
|
|
|
+ order.put("startAddress", "郑州");
|
|
|
+ order.put("endAddress", "武汉");
|
|
|
+ order.put("consignerCity", "郑州");
|
|
|
+ order.put("consignerDistrict", "郑州利泉局"); // 发货方
|
|
|
+ order.put("consignerPhone", "123");
|
|
|
+ order.put("consignerName", "卜桂芳"); // 发货人
|
|
|
+ order.put("consignerAddress", "郑州市惠济区天河路格力广场3号库负一层");
|
|
|
+ order.put("consigneeCity", "郑州");
|
|
|
+ order.put("consigneeName", "黄洁丽");
|
|
|
+ order.put("consigneePhone", "123");
|
|
|
+ order.put("consigneeAddress", "河南郑州市二七区瓯海中路");
|
|
|
+ JSONArray cargoes = new JSONArray();
|
|
|
+ JSONObject cargo = new JSONObject();
|
|
|
+ cargo.put("name", "xxx");
|
|
|
+ cargo.put("weight", 1);
|
|
|
+ cargo.put("volume", 1);
|
|
|
+ cargo.put("quantity", 1);
|
|
|
+ cargo.put("productModel", "zzz");
|
|
|
+ cargoes.add(cargo);
|
|
|
+ order.put("cargoList", cargoes);
|
|
|
+
|
|
|
+ JSONArray orders = new JSONArray();
|
|
|
+ orders.add(order);
|
|
|
+
|
|
|
+ JSONObject request = new JSONObject();
|
|
|
+ request.put("orderList", orders);
|
|
|
+ request.put("driverPhone", "15267153010");
|
|
|
+
|
|
|
+
|
|
|
+ StringEntity stringEntity = new StringEntity(request.toJSONString(), ContentType.APPLICATION_JSON);
|
|
|
+ httpPost.setEntity(stringEntity);
|
|
|
+ httpPost.setHeader("Content-Type", "application/json; charset=utf-8");
|
|
|
+
|
|
|
+ HttpClient httpClient = HttpClientBuilder.create().build();
|
|
|
+ HttpResponse response = httpClient.execute(httpPost);
|
|
|
+ String body = EntityUtils.toString(response.getEntity());
|
|
|
+ JSONObject result = JSON.parseObject(body);
|
|
|
+ System.out.println(result);
|
|
|
+ }
|
|
|
+}
|