Merge remote-tracking branch 'origin/master'
commit
f29a9a4bbc
|
|
@ -80,6 +80,11 @@
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>33.0.0-jre</version>
|
<version>33.0.0-jre</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>2.0.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,98 @@ public class cityDelivery {
|
||||||
* 同城急送平台工具,post接口
|
* 同城急送平台工具,post接口
|
||||||
*/
|
*/
|
||||||
@Anonymous
|
@Anonymous
|
||||||
|
@GetMapping("/getOrder")
|
||||||
|
public void cityDelivery_signBody22(){
|
||||||
|
Long timeStamp = System.currentTimeMillis();
|
||||||
|
String nonce = UUID.randomUUID().toString().replace("-","");
|
||||||
|
System.out.println("nonce:"+nonce );
|
||||||
|
System.out.println("timeStamp:"+timeStamp );
|
||||||
|
//签名
|
||||||
|
Map<String,Object> sortedMap = new TreeMap<>();
|
||||||
|
//下单接口
|
||||||
|
String body = "{\n" +
|
||||||
|
" \"customerCode\": \"HFCP\",\n" +
|
||||||
|
" \"payTypeFirst\": \"03\",\n" +
|
||||||
|
" \"channelOrderNo\": \"Y202501021005-1\",\n" +
|
||||||
|
" \"platformOrderNo\": \"\",\n" +
|
||||||
|
" \"expressNbr\": \"\",\n" +
|
||||||
|
" \"coordinateTransformType\": \"02\",\n" +
|
||||||
|
" \"weight\": \"501\",\n" +
|
||||||
|
" \"expectedTime\": \"2025-01-22,18:12:00\",\n" +
|
||||||
|
" \"postageFee\": \"2000\",\n" +
|
||||||
|
// " \"convertFlag\": false,\n" +
|
||||||
|
" \"orderSource\": \"other\",\n" +
|
||||||
|
" \"orderSourcePlatform\": \"其他\",\n" +
|
||||||
|
" \"costFee\": \"0\",\n" +
|
||||||
|
" \"tipFee\": \"0\",\n" +
|
||||||
|
" \"insuredFee\": \"0\",\n" +
|
||||||
|
" \"otherFee1\": \"0\",\n" +
|
||||||
|
" \"otherFee2\": \"0\",\n" +
|
||||||
|
" \"packageDesc\": \"药品\",\n" +
|
||||||
|
" \"remark\": \"手机尾号1234\",\n" +
|
||||||
|
" \"addressFirst\": {\n" +
|
||||||
|
" \"senderProviceCode\": \"340000\",\n" +
|
||||||
|
" \"senderProviceName\": \"安徽省\",\n" +
|
||||||
|
" \"senderCityCode\": \"340100\",\n" +
|
||||||
|
" \"senderCityName\": \"合肥市\",\n" +
|
||||||
|
" \"senderCountyCode\": \"340102\",\n" +
|
||||||
|
" \"senderCountyName\": \"瑶海区\",\n" +
|
||||||
|
" \"senderContactName\": \"中山三院\",\n" +
|
||||||
|
" \"senderContactPhone\": \"17523029470\",\n" +
|
||||||
|
" \"senderLongitude\": \"117.307179\",\n" +
|
||||||
|
" \"senderLatitude\": \"31.856484\",\n" +
|
||||||
|
" \"senderStreetCode\": \"001\",\n" +
|
||||||
|
" \"senderStreetName\": \"明光路街道\",\n" +
|
||||||
|
" \"senderAddr\": \"明光路188号\",\n" +
|
||||||
|
" \"receiverProviceCode\": \"340000\",\n" +
|
||||||
|
" \"receiverProviceName\": \"安徽省\",\n" +
|
||||||
|
" \"receiverCityCode\": \"340100\",\n" +
|
||||||
|
" \"receiverCityName\": \"合肥市\",\n" +
|
||||||
|
" \"receiverCountyCode\": \"340103\",\n" +
|
||||||
|
" \"receiverCountyName\": \"庐阳区\",\n" +
|
||||||
|
" \"receiverContactName\": \"陈先生\",\n" +
|
||||||
|
" \"receiverContactPhone\": \"13711511111\",\n" +
|
||||||
|
" \"receiverAddr\": \"信源大厦20楼2007\",\n" +
|
||||||
|
" \"receiverLongitude\": \"117.285075\",\n" +
|
||||||
|
" \"receiverLatitude\": \"31.882703\",\n" +
|
||||||
|
" \"receiverStreetCode\": \"002\",\n" +
|
||||||
|
" \"receiverStreetName\": \"双岗街道\"\n" +
|
||||||
|
" },\n" +
|
||||||
|
" \"businessJson\": {\n" +
|
||||||
|
// " \"a\": \"a\",\n" +
|
||||||
|
// " \"b\": \"b\"\n" +
|
||||||
|
" }\n" +
|
||||||
|
"}";
|
||||||
|
//查询物流轨迹
|
||||||
|
// String body = "{\n" +
|
||||||
|
// " \"expressNbr\": \"1158114584567\",\n" +
|
||||||
|
// " \"channelOrderNo\": \"\"\n" +
|
||||||
|
// "}";
|
||||||
|
//get请求,组装成 k v类型
|
||||||
|
// sortedMap.put(paramName,request.getParameter(paramName));
|
||||||
|
/**
|
||||||
|
* post请求,需要放data
|
||||||
|
*/
|
||||||
|
String bodyjson = JSON.toJSONString(StrUtil.removeAll(body, specialChars));
|
||||||
|
System.out.println("bodyjson: " + bodyjson);
|
||||||
|
|
||||||
|
sortedMap.put("data", JSON.toJSONString(StrUtil.removeAll(body, specialChars)));
|
||||||
|
sortedMap.put("access_id",clientKey);
|
||||||
|
sortedMap.put("nonce", nonce);
|
||||||
|
sortedMap.put("timestamp",timeStamp);
|
||||||
|
//排序
|
||||||
|
Map<String,Object> sortedParams = new TreeMap<>(sortedMap);
|
||||||
|
Set<Map.Entry<String,Object>> entrySet = sortedParams.entrySet();
|
||||||
|
// 遍历排序后的字典,将所有参数按"key=value"格式拼接在一起
|
||||||
|
StringBuilder stringToSign = new StringBuilder();
|
||||||
|
for (Map.Entry<String,Object> param : entrySet) {
|
||||||
|
stringToSign.append(param.getKey()).append("=").append(param.getValue()).append(",");
|
||||||
|
}
|
||||||
|
stringToSign.append("accessSecret").append("=").append(clientSecret);
|
||||||
|
String genSign = cityDelivery_SM4Util.encryptCBC(stringToSign.toString(),clientSecret,sm4Key);
|
||||||
|
System.out.println("sign:" + genSign);
|
||||||
|
}
|
||||||
|
|
||||||
public void cityDelivery_signBody2(){
|
public void cityDelivery_signBody2(){
|
||||||
Long timeStamp = System.currentTimeMillis();
|
Long timeStamp = System.currentTimeMillis();
|
||||||
String nonce = UUID.randomUUID().toString().replace("-","");
|
String nonce = UUID.randomUUID().toString().replace("-","");
|
||||||
|
|
@ -50,11 +142,11 @@ public class cityDelivery {
|
||||||
Map<String,Object> sortedMap = new TreeMap<>();
|
Map<String,Object> sortedMap = new TreeMap<>();
|
||||||
//下单接口
|
//下单接口
|
||||||
String body = "{\n" +
|
String body = "{\n" +
|
||||||
" \"customerCode\": \"GZHX\",\n" +
|
" \"customerCode\": \"HFCP\",\n" +
|
||||||
" \"payTypeFirst\": \"03\",\n" +
|
" \"payTypeFirst\": \"03\",\n" +
|
||||||
" \"convertFlag\": false,\n" +
|
" \"convertFlag\": false,\n" +
|
||||||
" \"weight\": \"501\",\n" +
|
" \"weight\": \"501\",\n" +
|
||||||
" \"expectedTime\": \"2024-11-11 12:12:00\",\n" +
|
" \"expectedTime\": \"2025-01-22 18:12:00\",\n" +
|
||||||
" \"platformOrderNo\": \"\",\n" +
|
" \"platformOrderNo\": \"\",\n" +
|
||||||
" \"channelOrderNo\": \"\",\n" +
|
" \"channelOrderNo\": \"\",\n" +
|
||||||
" \"orderSource\": \"meituan\",\n" +
|
" \"orderSource\": \"meituan\",\n" +
|
||||||
|
|
@ -109,6 +201,8 @@ public class cityDelivery {
|
||||||
/**
|
/**
|
||||||
* post请求,需要放data
|
* post请求,需要放data
|
||||||
*/
|
*/
|
||||||
|
String bodyjson = JSON.toJSONString(StrUtil.removeAll(body, specialChars));
|
||||||
|
System.out.println("bodyjson :" + bodyjson);
|
||||||
sortedMap.put("data", JSON.toJSONString(StrUtil.removeAll(body, specialChars)));
|
sortedMap.put("data", JSON.toJSONString(StrUtil.removeAll(body, specialChars)));
|
||||||
sortedMap.put("access_id",clientKey);
|
sortedMap.put("access_id",clientKey);
|
||||||
sortedMap.put("nonce", nonce);
|
sortedMap.put("nonce", nonce);
|
||||||
|
|
@ -126,9 +220,66 @@ public class cityDelivery {
|
||||||
System.out.println("sign:" + genSign);
|
System.out.println("sign:" + genSign);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同城急送平台工具,获取token
|
||||||
|
*/
|
||||||
|
@Anonymous
|
||||||
|
@GetMapping("/getToken2")
|
||||||
|
public void getTokenPostMan(){
|
||||||
|
Long timeStamp = System.currentTimeMillis();
|
||||||
|
String nonce = UUID.randomUUID().toString().replace("-","");
|
||||||
|
System.out.println("timeStamp:" + timeStamp);
|
||||||
|
System.out.println("nonce:" + nonce);
|
||||||
|
//body
|
||||||
|
Map map = new HashMap();
|
||||||
|
map.put("clientKey",clientKey);
|
||||||
|
map.put("clientSecret",clientSecret);
|
||||||
|
map.put("appType",appType);
|
||||||
|
map.put("clientType",client_type);
|
||||||
|
map.put("version",version);
|
||||||
|
|
||||||
|
Map<String, Object> sortedParams1 = new TreeMap<>(map);
|
||||||
|
Set<Map.Entry<String, Object>> entrySet1 = sortedParams1.entrySet();
|
||||||
|
StringBuilder stringToSign = new StringBuilder();
|
||||||
|
for (Map.Entry<String, Object> param : entrySet1) {
|
||||||
|
stringToSign.append(param.getKey()).append("=").append(param.getValue()).append(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
String encryptBase64 = cityDelivery_SM4Util.encryptCBC(stringToSign.toString(),clientSecret,sm4Key);
|
||||||
|
System.out.println("body:" + encryptBase64);
|
||||||
|
//签名
|
||||||
|
Map<String,Object> sortedMap2 = new TreeMap<>();
|
||||||
|
|
||||||
|
//get请求,组装成 k v类型
|
||||||
|
// sortedMap2.put(paramName,request.getParameter(paramName));
|
||||||
|
/**
|
||||||
|
* post请求,需要放data
|
||||||
|
*/
|
||||||
|
Map bodyMap = new HashMap();
|
||||||
|
bodyMap.put("body",encryptBase64);
|
||||||
|
String bodyJson = JSON.toJSONString(bodyMap);
|
||||||
|
sortedMap2.put("data", JSON.toJSONString(bodyJson));
|
||||||
|
sortedMap2.put("access_id",clientKey);
|
||||||
|
sortedMap2.put("nonce", nonce);
|
||||||
|
sortedMap2.put("timestamp",timeStamp);
|
||||||
|
//排序
|
||||||
|
Map<String,Object> sortedParams2 = new TreeMap<>(sortedMap2);
|
||||||
|
Set<Map.Entry<String,Object>> entrySet2 = sortedParams2.entrySet();
|
||||||
|
// 遍历排序后的字典,将所有参数按"key=value"格式拼接在一起
|
||||||
|
StringBuilder stringToSign2 = new StringBuilder();
|
||||||
|
for (Map.Entry<String,Object> param : entrySet2) {
|
||||||
|
stringToSign2.append(param.getKey()).append("=").append(param.getValue()).append(",");
|
||||||
|
}
|
||||||
|
stringToSign2.append("accessSecret").append("=").append(clientSecret);
|
||||||
|
// String genSign = DigestUtils.md5Hex(stringToSign2.toString());
|
||||||
|
String genSign = cityDelivery_SM4Util.encryptCBC(stringToSign2.toString(),clientSecret,sm4Key);
|
||||||
|
System.out.println("------------");
|
||||||
|
System.out.println("sign:" + genSign);
|
||||||
|
}
|
||||||
|
|
||||||
//获取token
|
//获取token
|
||||||
@Anonymous
|
@Anonymous
|
||||||
@PostMapping("/getToken")
|
@GetMapping("/getToken")
|
||||||
public void getToken(){
|
public void getToken(){
|
||||||
System.out.println("获取token");
|
System.out.println("获取token");
|
||||||
String url = "https://wyjcs.gdwyj.cn/szelec/city-delivery-api/api/mini/app/login/token";
|
String url = "https://wyjcs.gdwyj.cn/szelec/city-delivery-api/api/mini/app/login/token";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue