日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

顺丰快递下单接口

發布時間:2023/12/20 编程问答 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 顺丰快递下单接口 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/*下單測試接口*/ @PostMapping(value = "/test") @ApiOperation(value = "順風--下單") public R test() throws IOException {//收貨人信息Map<String,Object> receive=new HashMap<>();receive.put("user_name", URLEncoder.encode("小明"));receive.put("user_phone","13855552125");receive.put("user_address",URLEncoder.encode("七里河區125號"));receive.put("user_lng","116.382342");receive.put("user_lat","39.923099");//將收貨人信息轉成json對象JSONObject json = new JSONObject(receive);//快遞要發的商品詳情List<JSONObject> product_detai=new ArrayList<>();Map<String,Object> pd=new HashMap<>();pd.put("product_name",URLEncoder.encode("食品"));pd.put("product_num",1);JSONObject pdjons=new JSONObject(pd);product_detai.add(pdjons);//訂單詳情(必須傳)Map<String,Object> order_detail=new HashMap<>();order_detail.put("total_price",100);order_detail.put("product_type",1);order_detail.put("weight_gram",10);order_detail.put("product_num",1);order_detail.put("product_type_num",1);// order_detail.put("product_detail",product_detai);//順風接口需要的其他參數Date date = new Date();long push_time=date.getTime()/1000;Map<String,Object> map=new HashMap<>();map.put("dev_id",APP_ID);map.put("shop_id",shop_id);map.put("shop_order_id", OrderNumUtil.getOrderIdByTime());map.put("order_source","1");map.put("pay_type",0);map.put("order_time",push_time);map.put("is_appoint",0);map.put("is_insured",0);map.put("push_time",push_time);map.put("version",17);map.put("receive",json);//收貨人信息jsonmap.put("order_detail",order_detail);///訂單信息jsonJSONObject jsonObj=new JSONObject(map);String jsonParam=jsonObj.toString();//順風下單接口String url="https://commit-openic.sf-express.com/open/api/external/createorder?sign="+sign(jsonParam);CloseableHttpClient closeableHttpClient = HttpClients.createDefault();CloseableHttpResponse closeableHttpResponse;//發送post請求HttpPost httpPost = new HttpPost(url);httpPost.addHeader("Content-Type", "application/json;charset=UTF-8");StringEntity entity = new StringEntity(jsonParam, ContentType.create("text/json", "UTF-8"));httpPost.setEntity(entity);RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(2000).setConnectTimeout(2000).build();httpPost.setConfig(requestConfig);closeableHttpResponse = closeableHttpClient.execute(httpPost);int statusCode = closeableHttpResponse.getStatusLine().getStatusCode();if (statusCode == HttpStatus.SC_OK) {//下單成功,處理自己的代碼}//接口返回結果HttpEntity httpEntity = closeableHttpResponse.getEntity();String asset_synchronization = EntityUtils.toString(httpEntity, "UTF-8");JSONObject data =JSON.parseObject(asset_synchronization);return R.ok(data); }

總結

以上是生活随笔為你收集整理的顺丰快递下单接口的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。