api文档
下单接口 :https://qiao.sf-express.com/Api/ApiDetails?level3=393&interName=%E4%B8%8B%E8%AE%A2%E5%8D%95%E6%8E%A5%E5%8F%A3-EXP_RECE_CREATE_ORDER
取消订单接口: https://qiao.sf-express.com/Api/ApiDetails?level3=339&interName=%E8%AE%A2%E5%8D%95%E7%A1%AE%E8%AE%A4%2F%E5%8F%96%E6%B6%88%E6%8E%A5%E5%8F%A3-EXP_RECE_UPDATE_ORDER
- 每个接口需要测试成功三次才可上线
- 下单接口上线需要上传电子面单,下线订单量不大时可以走免面单申请,不需要提交电子面单也可以上线接口
单元测试类
package com.cqdh.group.applet;
import cn.hutool.core.lang.UUID;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import org.apache.commons.codec.binary.Base64;
import org.junit.Test;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.MessageDigest;
public class SFApiTest {
private static final String partnerID = "ZYHNYK*****";
private static final String url = "https://sfapi-sbox.sf-express.com/std/service";
private static final String checkWord = "pUVFxVbrao35vtzY***********";
@Test
public void createLogisticsOrder() throws UnsupportedEncodingException {
String serviceCode = "EXP_RECE_CREATE_ORDER";
String requestID = UUID.randomUUID().toString();
String timespase = System.currentTimeMillis() + "";
String msgData = "{\"expressTypeId\":1,\"orderId\":\"SC1714182733078591144\",\"payMethod\":1,\"totalWeight\":1,\"monthlyCard\":\"7551234567\",\"signBackRemark\":\"test--签\",\"contactInfoList\":[{\"country\":\"CN\",\"contactType\":1,\"tel\":\"13866666666\",\"address\":\"重庆市渝北区两港大道与婵衣路交叉路口往东约140米\",\"contact\":\"小红\"},{\"country\":\"CN\",\"contactType\":2,\"tel\":\"13866666666\",\"address\":\"遵义市汇川区红河路莲花山公园西南侧约150米\",\"contact\":\"张三\"}],\"isDocall\":1}";
String msgDigest = getMsgDigest(msgData, timespase, checkWord);
HttpRequest request = HttpRequest.post(url);
request.header("Content-Type", "application/x-www-form-urlencoded");
String formData = String.format("serviceCode=%s&partnerID=%s&requestID=%s×tamp=%s&msgDigest=%s&msgData=%s",
serviceCode, partnerID, requestID, timespase, msgDigest, msgData);
HttpResponse response = request.body(formData).execute();
String result = response.body();
System.out.println("响应内容:" + result);
}
@Test
public void cannelLogisticsOrder() throws UnsupportedEncodingException {
String serviceCode = "EXP_RECE_UPDATE_ORDER";
String requestID = UUID.randomUUID().toString();
String timespase = System.currentTimeMillis() + "";
String msgData = "{\"dealType\":2,\"language\":\"zh-CN\",\"orderId\":\"SC1714182733078597644\",\"totalWeight\":1,\"waybillNoInfoList\":[]}";
String msgDigest = getMsgDigest(msgData, timespase, checkWord);
HttpRequest request = HttpRequest.post(url);
request.header("Content-Type", "application/x-www-form-urlencoded");
String formData = String.format("serviceCode=%s&partnerID=%s&requestID=%s×tamp=%s&msgDigest=%s&msgData=%s",
serviceCode, partnerID, requestID, timespase, msgDigest, msgData);
HttpResponse response = request.body(formData).execute();
String result = response.body();
System.out.println("响应内容:" + result);
}
public static String getMsgDigest(String msgData, String timeStamp, String md5Key) throws UnsupportedEncodingException {
return (new Base64()).encodeAsString(md5Encrypt(URLEncoder.encode(msgData + timeStamp + md5Key, "UTF-8")));
}
private static byte[] md5Encrypt(String encryptStr) {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(encryptStr.getBytes("utf8"));
return md5.digest();
} catch (Exception var2) {
throw new RuntimeException(var2);
}
}
}
下单响应报文
{
"apiErrorMsg":"",
"apiResponseID":"00018BB37AD8993FDF02951B4A6F363F",
"apiResultCode":"A1000",
"apiResultData":"{\"success\":true,\"errorCode\":\"S0000\",\"errorMsg\":null,\"msgData\":{\"orderId\":\"SC1714182733078591144\",\"originCode\":\"023\",\"destCode\":\"052\",\"filterResult\":2,\"remark\":\"\",\"url\":null,\"paymentLink\":null,\"isUpstairs\":null,\"isSpecialWarehouseService\":null,\"mappingMark\":null,\"agentMailno\":null,\"returnExtraInfoList\":null,\"waybillNoInfoList\":[{\"waybillType\":1,\"waybillNo\":\"SF7444473317974\",\"boxNo\":null,\"length\":null,\"width\":null,\"height\":null,\"weight\":null,\"volume\":null}],\"routeLabelInfo\":[{\"code\":\"1000\",\"routeLabelData\":{\"waybillNo\":\"SF7444473317974\",\"sourceTransferCode\":\"023W\",\"sourceCityCode\":\"023\",\"sourceDeptCode\":\"023\",\"sourceTeamCode\":\"\",\"destCityCode\":\"052\",\"destDeptCode\":\"052GC\",\"destDeptCodeMapping\":\"\",\"destTeamCode\":\"004\",\"destTeamCodeMapping\":\"\",\"destTransferCode\":\"052\",\"destRouteLabel\":\"052GC-004\",\"proName\":\"\",\"cargoTypeCode\":\"C201\",\"limitTypeCode\":\"T4\",\"expressTypeCode\":\"B1\",\"codingMapping\":\"C15\",\"codingMappingOut\":\"\",\"xbFlag\":\"0\",\"printFlag\":\"000000000\",\"twoDimensionCode\":\"MMM={'k1':'052','k2':'052GC','k3':'004','k4':'T4','k5':'SF7444473317974','k6':'','k7':'1d8ee46c'}\",\"proCode\":\"特快\",\"printIcon\":\"00000000\",\"abFlag\":\"\",\"destPortCode\":\"\",\"destCountry\":\"\",\"destPostCode\":\"\",\"goodsValueTotal\":\"\",\"currencySymbol\":\"\",\"cusBatch\":\"\",\"goodsNumber\":\"\",\"errMsg\":\"\",\"checkCode\":\"1d8ee46c\",\"proIcon\":\"\",\"fileIcon\":\"\",\"fbaIcon\":\"\",\"icsmIcon\":\"\",\"destGisDeptCode\":\"052GC\",\"newIcon\":null,\"sendAreaCode\":null,\"destinationStationCode\":null,\"sxLabelDestCode\":null,\"sxDestTransferCode\":null,\"sxCompany\":null,\"newAbFlag\":null,\"destAddrKeyWord\":\"\",\"rongType\":null,\"waybillIconList\":null},\"message\":\"SF7444473317974:\"}],\"contactInfoList\":null,\"sendStartTm\":null,\"customerRights\":null,\"expressTypeId\":null}}"
}
取消订单响应报文
{
"apiErrorMsg":"",
"apiResponseID":"00018BB37FFC733FEB93CB6399A4D03F",
"apiResultCode":"A1000",
"apiResultData":"{\"success\":true,\"errorCode\":\"S0000\",\"errorMsg\":null,\"msgData\":{\"orderId\":\"SC1714182733078591144\",\"waybillNoInfoList\":[{\"waybillType\":1,\"waybillNo\":\"SF7444473317974\"}],\"resStatus\":2,\"extraInfoList\":null}}"
}