对接邮政城配系统
parent
f29a9a4bbc
commit
95c5a342fc
|
|
@ -1,347 +0,0 @@
|
||||||
package com.cpxt.web.controller.biz.orderutil;
|
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.http.HttpRequest;
|
|
||||||
import cn.hutool.http.HttpResponse;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.cpxt.common.annotation.Anonymous;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.security.Security;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author Ly
|
|
||||||
* @Create 2024/12/4 18:57
|
|
||||||
* @Desc
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/test")
|
|
||||||
@Slf4j
|
|
||||||
public class cityDelivery {
|
|
||||||
private static final char[] specialChars = {'\n', '\r', '\t', '\f','\b',' '};
|
|
||||||
|
|
||||||
// test
|
|
||||||
String clientKey ="7480617400984563";//accessKey
|
|
||||||
String clientSecret = "91wCEvn82CeyMg3k";
|
|
||||||
String sm4Key = "MJy05dcI4mPbGB61";
|
|
||||||
String appType = "wxmp";
|
|
||||||
String client_type = "other";
|
|
||||||
String version = "1.0.0";
|
|
||||||
|
|
||||||
/*static{
|
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 同城急送平台工具,post接口
|
|
||||||
*/
|
|
||||||
@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(){
|
|
||||||
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" +
|
|
||||||
" \"convertFlag\": false,\n" +
|
|
||||||
" \"weight\": \"501\",\n" +
|
|
||||||
" \"expectedTime\": \"2025-01-22 18:12:00\",\n" +
|
|
||||||
" \"platformOrderNo\": \"\",\n" +
|
|
||||||
" \"channelOrderNo\": \"\",\n" +
|
|
||||||
" \"orderSource\": \"meituan\",\n" +
|
|
||||||
" \"orderSourcePlatform\": \"01\",\n" +
|
|
||||||
" \"costFee\": \"100\",\n" +
|
|
||||||
" \"packageDesc\": \"药品\",\n" +
|
|
||||||
" \"remark\": \"手机尾号1234\",\n" +
|
|
||||||
" \"expressNbr\": \"\",\n" +
|
|
||||||
" \"insuredFee\": \"1\",\n" +
|
|
||||||
" \"otherFee1\": \"2\",\n" +
|
|
||||||
" \"otherFee2\": \"3\",\n" +
|
|
||||||
" \"addressFirst\": {\n" +
|
|
||||||
" \"senderProviceCode\": \"440000\",\n" +
|
|
||||||
" \"senderProviceName\": \"广东省\",\n" +
|
|
||||||
" \"senderCityCode\": \"440100\",\n" +
|
|
||||||
" \"senderCityName\": \"广州市\",\n" +
|
|
||||||
" \"senderCountyCode\": \"440106\",\n" +
|
|
||||||
" \"senderCountyName\": \"天河区\",\n" +
|
|
||||||
" \"senderContactName\": \"中山三院\",\n" +
|
|
||||||
" \"senderContactPhone\": \"17523029470\",\n" +
|
|
||||||
" \"senderLongitude\": \"113.264000\",\n" +
|
|
||||||
" \"senderLatitude\": \"23.129101\",\n" +
|
|
||||||
" \"senderStreetCode\": \"001\",\n" +
|
|
||||||
" \"senderStreetName\": \"林和街道1\",\n" +
|
|
||||||
" \"senderAddr\": \"天河北路188号\",\n" +
|
|
||||||
" \"receiverProviceCode\": \"440000\",\n" +
|
|
||||||
" \"receiverProviceName\": \"广东省\",\n" +
|
|
||||||
" \"receiverCityCode\": \"440100\",\n" +
|
|
||||||
" \"receiverCityName\": \"广州市\",\n" +
|
|
||||||
" \"receiverCountyCode\": \"440106\",\n" +
|
|
||||||
" \"receiverCountyName\": \"天河区\",\n" +
|
|
||||||
" \"receiverContactName\": \"陈先生\",\n" +
|
|
||||||
" \"receiverContactPhone\": \"13711511111\",\n" +
|
|
||||||
" \"receiverAddr\": \"信源大厦20楼2007\",\n" +
|
|
||||||
" \"receiverLongitude\": \"113.265000\",\n" +
|
|
||||||
" \"receiverLatitude\": \"23.129101\",\n" +
|
|
||||||
" \"receiverStreetCode\": \"002\",\n" +
|
|
||||||
" \"receiverStreetName\": \"林和街道2\"\n" +
|
|
||||||
" },\n" +
|
|
||||||
" \"businessJson\": {\n" +
|
|
||||||
" \"a\": \"asd\",\n" +
|
|
||||||
" \"b\": \"asd\"\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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 同城急送平台工具,获取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
|
|
||||||
@Anonymous
|
|
||||||
@GetMapping("/getToken")
|
|
||||||
public void getToken(){
|
|
||||||
System.out.println("获取token");
|
|
||||||
String url = "https://wyjcs.gdwyj.cn/szelec/city-delivery-api/api/mini/app/login/token";
|
|
||||||
String nonce = UUID.randomUUID().toString().replace("-", "");
|
|
||||||
Long timestamp = System.currentTimeMillis();
|
|
||||||
//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);
|
|
||||||
|
|
||||||
|
|
||||||
HttpResponse response = HttpRequest.post(url)
|
|
||||||
.body(JSON.toJSONString(bodyMap))
|
|
||||||
.header("Content-Type", "application/json")
|
|
||||||
.header("client_type", client_type)
|
|
||||||
.header("app_type", appType)
|
|
||||||
.header("access_id", clientKey)
|
|
||||||
.header("nonce", nonce)
|
|
||||||
.header("timestamp", timestamp.toString())
|
|
||||||
.header("sign", genSign)
|
|
||||||
.execute();
|
|
||||||
System.out.println(response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -137,11 +137,12 @@
|
||||||
<version>5.5.7</version>
|
<version>5.5.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!--<dependency>
|
||||||
<groupId>com.alibaba</groupId>
|
<groupId>com.alibaba</groupId>
|
||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>1.2.83</version>
|
<version>1.2.83</version>
|
||||||
</dependency>
|
<scope>compile</scope>
|
||||||
|
</dependency>-->
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on -->
|
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk15on -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package com.cpxt.biz.domain;
|
package com.cpxt.biz.domain;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
@ -66,4 +68,49 @@ public class BizOrderSub
|
||||||
@Excel(name = "备注")
|
@Excel(name = "备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
/** 平台订单号 */
|
||||||
|
@Excel(name = "平台订单号")
|
||||||
|
private String platformOrderNo;
|
||||||
|
|
||||||
|
/** 邮件号(运单号) */
|
||||||
|
@Excel(name = "邮件号(运单号)")
|
||||||
|
private String expressNbr;
|
||||||
|
|
||||||
|
/** 预计送达时间 */
|
||||||
|
@Excel(name = "预计送达时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date expectTime;
|
||||||
|
|
||||||
|
/** 配送距离(米) */
|
||||||
|
@Excel(name = "配送距离(米)")
|
||||||
|
private String distance;
|
||||||
|
|
||||||
|
/** 配送费 */
|
||||||
|
@Excel(name = "配送费")
|
||||||
|
private String postageFee;
|
||||||
|
|
||||||
|
/** 工本费 */
|
||||||
|
@Excel(name = "工本费")
|
||||||
|
private String costFee;
|
||||||
|
|
||||||
|
/** 骑手小费 */
|
||||||
|
@Excel(name = "骑手小费")
|
||||||
|
private String tipFee;
|
||||||
|
|
||||||
|
/** 保价费 */
|
||||||
|
@Excel(name = "保价费")
|
||||||
|
private String insuredFee;
|
||||||
|
|
||||||
|
/** 其它费用1 */
|
||||||
|
@Excel(name = "其它费用1")
|
||||||
|
private String otherFee1;
|
||||||
|
|
||||||
|
/** 其它费用2 */
|
||||||
|
@Excel(name = "其它费用2")
|
||||||
|
private String otherFee2;
|
||||||
|
|
||||||
|
/** 总费用 */
|
||||||
|
@Excel(name = "总费用")
|
||||||
|
private String totalFee;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,548 @@
|
||||||
|
package com.cpxt.biz.orderutil;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.cpxt.biz.domain.BizOrder;
|
||||||
|
import com.cpxt.biz.domain.BizOrderSub;
|
||||||
|
import com.cpxt.biz.domain.SysArea;
|
||||||
|
import com.cpxt.biz.mapper.SysAreaMapper;
|
||||||
|
import com.cpxt.common.annotation.Anonymous;
|
||||||
|
import com.cpxt.system.mapper.SysDictDataMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author Ly
|
||||||
|
* @Create 2024/12/4 18:57
|
||||||
|
* @Desc
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class CityDelivery {
|
||||||
|
|
||||||
|
private static final char[] specialChars = {'\n', '\r', '\t', '\f', '\b', ' '};
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysDictDataMapper sysDictDataMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysAreaMapper sysAreaMapper;
|
||||||
|
|
||||||
|
// test
|
||||||
|
String clientKey = "7480617400984563";//accessKey
|
||||||
|
String clientSecret = "91wCEvn82CeyMg3k";
|
||||||
|
String sm4Key = "MJy05dcI4mPbGB61";
|
||||||
|
String appType = "wxmp";
|
||||||
|
String client_type = "other";
|
||||||
|
String version = "1.0.0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同城急送平台工具,post接口
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同城急送平台工具,post接口
|
||||||
|
*/
|
||||||
|
public void addOrder(BizOrder bizOrder,BizOrderSub bizOrderSub) {
|
||||||
|
String url = "https://wyjcs.gdwyj.cn/szelec/city-delivery-api/api/base/order/add";
|
||||||
|
String goodsType = bizOrderSub.getGoodsType();
|
||||||
|
String goodsTypeLabel = sysDictDataMapper.selectDictLabel("sys_goods_type", goodsType);
|
||||||
|
|
||||||
|
String payType = bizOrder.getPayType();
|
||||||
|
if (payType == null) payType = "";
|
||||||
|
String subOrderSn = bizOrderSub.getSubOrderSn();
|
||||||
|
if (subOrderSn == null) subOrderSn = "";
|
||||||
|
BigDecimal weight = bizOrderSub.getWeight();
|
||||||
|
String remark = bizOrderSub.getRemark();
|
||||||
|
if (remark == null) remark = "";
|
||||||
|
|
||||||
|
// 寄件人信息
|
||||||
|
String senderArea = bizOrder.getSenderArea(); // 寄件人街道代码
|
||||||
|
if (senderArea == null) senderArea = "";
|
||||||
|
String senderProviceCode = "";
|
||||||
|
if (ObjectUtil.isNotEmpty(senderArea)){
|
||||||
|
senderProviceCode = senderArea.substring(0,2) + "0000"; // 寄件人省份代码(6位国标码)
|
||||||
|
}
|
||||||
|
String senderProviceName = "";
|
||||||
|
SysArea sysArea1 = sysAreaMapper.selectById(senderProviceCode + "000000");
|
||||||
|
if (ObjectUtil.isNotEmpty(sysArea1)){
|
||||||
|
senderProviceName = sysArea1.getName(); // 寄件人省份名称
|
||||||
|
}
|
||||||
|
String senderCityCode = "";
|
||||||
|
if (ObjectUtil.isNotEmpty(senderArea)){
|
||||||
|
senderCityCode = senderArea.substring(0,4) + "00"; // 寄件人城市代码(6位国标码)
|
||||||
|
}
|
||||||
|
String senderCityName = "";
|
||||||
|
SysArea sysArea2 = sysAreaMapper.selectById(senderCityCode + "000000");
|
||||||
|
if (ObjectUtil.isNotEmpty(sysArea2)){
|
||||||
|
senderCityName = sysArea2.getName(); // 寄件人城市名称
|
||||||
|
}
|
||||||
|
String senderCountyCode = "";
|
||||||
|
if (ObjectUtil.isNotEmpty(senderArea)){
|
||||||
|
senderCountyCode = senderArea.substring(0,6); // 寄件人区县代码(6位国标码)
|
||||||
|
}
|
||||||
|
String senderCountyName = "";
|
||||||
|
SysArea sysArea3 = sysAreaMapper.selectById(senderCountyCode + "000000");
|
||||||
|
if (ObjectUtil.isNotEmpty(sysArea3)){
|
||||||
|
senderCountyName = sysArea3.getName(); // 寄件人区县名称
|
||||||
|
}
|
||||||
|
String senderStreetName = "";
|
||||||
|
SysArea sysArea4 = sysAreaMapper.selectById(senderArea);
|
||||||
|
if (ObjectUtil.isNotEmpty(sysArea4)){
|
||||||
|
senderStreetName = sysArea4.getName(); // 寄件人街道名称
|
||||||
|
}
|
||||||
|
String senderAddress = bizOrder.getSenderAddress(); // 寄件人详细地址
|
||||||
|
if (senderAddress == null) senderAddress = "";
|
||||||
|
String senderName = bizOrder.getSenderName(); // 寄件人姓名
|
||||||
|
if (senderName == null) senderName = "";
|
||||||
|
String senderPhone = bizOrder.getSenderPhone(); // 寄件人手机号
|
||||||
|
if (senderPhone == null) senderPhone = "";
|
||||||
|
|
||||||
|
String senderLng = ""; // 寄件人经度
|
||||||
|
if (bizOrder.getSenderLng() != null){
|
||||||
|
senderLng = bizOrder.getSenderLng().toString();
|
||||||
|
}
|
||||||
|
String senderLat = ""; // 寄件人纬度
|
||||||
|
if (bizOrder.getSenderLat() != null){
|
||||||
|
senderLat = bizOrder.getSenderLat().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 收件人信息
|
||||||
|
String receiverArea = bizOrder.getReceiverArea(); // 收件人街道代码
|
||||||
|
if (receiverArea == null) receiverArea = "";
|
||||||
|
String receiverProviceCode = "";
|
||||||
|
if (ObjectUtil.isNotEmpty(receiverArea)){
|
||||||
|
receiverProviceCode = receiverArea.substring(0,2) + "0000"; // 收件人省份代码(6位国标码)
|
||||||
|
}
|
||||||
|
String receiverProviceName = "";
|
||||||
|
SysArea sysArea5 = sysAreaMapper.selectById(receiverProviceCode + "000000");
|
||||||
|
if (ObjectUtil.isNotEmpty(sysArea5)){
|
||||||
|
receiverProviceName = sysArea5.getName(); // 收件人省份名称
|
||||||
|
}
|
||||||
|
String receiverCityCode = "";
|
||||||
|
if (ObjectUtil.isNotEmpty(receiverArea)){
|
||||||
|
receiverCityCode = receiverArea.substring(0,4) + "00"; // 收件人城市代码(6位国标码)
|
||||||
|
}
|
||||||
|
String receiverCityName = "";
|
||||||
|
SysArea sysArea6 = sysAreaMapper.selectById(receiverCityCode + "000000");
|
||||||
|
if (ObjectUtil.isNotEmpty(sysArea6)){
|
||||||
|
receiverCityName = sysArea6.getName(); // 收件人城市名称
|
||||||
|
}
|
||||||
|
String receiverCountyCode = "";
|
||||||
|
if (ObjectUtil.isNotEmpty(receiverArea)){
|
||||||
|
receiverCountyCode = receiverArea.substring(0,6); // 收件人区县代码(6位国标码)
|
||||||
|
}
|
||||||
|
String receiverCountyName = "";
|
||||||
|
SysArea sysArea7 = sysAreaMapper.selectById(receiverCountyCode + "000000");
|
||||||
|
if (ObjectUtil.isNotEmpty(sysArea7)){
|
||||||
|
receiverCountyName = sysArea7.getName(); // 收件人区县名称
|
||||||
|
}
|
||||||
|
String receiverStreetName = "";
|
||||||
|
SysArea sysArea8 = sysAreaMapper.selectById(receiverArea);
|
||||||
|
if (ObjectUtil.isNotEmpty(sysArea8)){
|
||||||
|
receiverStreetName = sysArea8.getName(); // 收件人街道名称
|
||||||
|
}
|
||||||
|
String receiverAddress = bizOrder.getReceiverAddress(); // 收件人详细地址
|
||||||
|
String receiverName = bizOrder.getReceiverName(); // 收件人姓名
|
||||||
|
String receiverPhone = bizOrder.getReceiverPhone(); // 收件人手机号
|
||||||
|
String receiverLng = ""; // 收件人经度
|
||||||
|
if (bizOrder.getReceiverLng() != null){
|
||||||
|
receiverLng = bizOrder.getReceiverLng().toString();
|
||||||
|
}
|
||||||
|
String receiverLat = ""; // 收件人纬度
|
||||||
|
if (bizOrder.getReceiverLat() != null){
|
||||||
|
receiverLat = bizOrder.getReceiverLat().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
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\": \"" + payType + "\",\n" +
|
||||||
|
" \"channelOrderNo\": \"" + subOrderSn + "\",\n" +
|
||||||
|
" \"platformOrderNo\": \"\",\n" +
|
||||||
|
" \"expressNbr\": \"\",\n" +
|
||||||
|
" \"coordinateTransformType\": \"02\",\n" +
|
||||||
|
" \"weight\": \"" + weight + "\",\n" +
|
||||||
|
" \"expectedTime\": \"\",\n" +
|
||||||
|
" \"postageFee\": \"\",\n" +
|
||||||
|
// " \"convertFlag\": false,\n" +
|
||||||
|
" \"orderSource\": \"other\",\n" +
|
||||||
|
" \"orderSourcePlatform\": \"其他\",\n" +
|
||||||
|
" \"costFee\": \"\",\n" +
|
||||||
|
" \"tipFee\": \"\",\n" +
|
||||||
|
" \"insuredFee\": \"\",\n" +
|
||||||
|
" \"otherFee1\": \"\",\n" +
|
||||||
|
" \"otherFee2\": \"\",\n" +
|
||||||
|
" \"packageDesc\": \"" + goodsTypeLabel + "\",\n" +
|
||||||
|
" \"remark\": \"" + remark + "\",\n" +
|
||||||
|
" \"addressFirst\": {\n" +
|
||||||
|
" \"senderProviceCode\": \"" + senderProviceCode + "\",\n" +
|
||||||
|
" \"senderProviceName\": \"" + senderProviceName + "\",\n" +
|
||||||
|
" \"senderCityCode\": \"" + senderCityCode + "\",\n" +
|
||||||
|
" \"senderCityName\": \"" + senderCityName + "\",\n" +
|
||||||
|
" \"senderCountyCode\": \"" + senderCountyCode + "\",\n" +
|
||||||
|
" \"senderCountyName\": \"" + senderCountyName + "\",\n" +
|
||||||
|
" \"senderContactName\": \"" + senderName + "\",\n" +
|
||||||
|
" \"senderContactPhone\": \"" + senderPhone + "\",\n" +
|
||||||
|
" \"senderLongitude\": \"" + senderLng + "\",\n" +
|
||||||
|
" \"senderLatitude\": \"" + senderLat + "\",\n" +
|
||||||
|
" \"senderStreetCode\": \"" + senderArea + "\",\n" +
|
||||||
|
" \"senderStreetName\": \"" + senderStreetName + "\",\n" +
|
||||||
|
" \"senderAddr\": \"" + senderAddress + "\",\n" +
|
||||||
|
" \"receiverProviceCode\": \"" + receiverProviceCode + "\",\n" +
|
||||||
|
" \"receiverProviceName\": \"" + receiverProviceName + "\",\n" +
|
||||||
|
" \"receiverCityCode\": \"" + receiverCityCode + "\",\n" +
|
||||||
|
" \"receiverCityName\": \"" + receiverCityName + "\",\n" +
|
||||||
|
" \"receiverCountyCode\": \"" + receiverCountyCode + "\",\n" +
|
||||||
|
" \"receiverCountyName\": \"" + receiverCountyName + "\",\n" +
|
||||||
|
" \"receiverContactName\": \"" + receiverName + "\",\n" +
|
||||||
|
" \"receiverContactPhone\": \"" + receiverPhone + "\",\n" +
|
||||||
|
" \"receiverAddr\": \"" + receiverAddress + "\",\n" +
|
||||||
|
" \"receiverLongitude\": \"" + receiverLng + "\",\n" +
|
||||||
|
" \"receiverLatitude\": \"" + receiverLat + "\",\n" +
|
||||||
|
" \"receiverStreetCode\": \"" + receiverArea + "\",\n" +
|
||||||
|
" \"receiverStreetName\": \"" + 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));
|
||||||
|
String token = refreshToken();
|
||||||
|
log.info("========================================准备请求========================================");
|
||||||
|
log.info("body:" + body);
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
log.info("client_type:" + client_type);
|
||||||
|
System.out.println("client_type:" + client_type);
|
||||||
|
log.info("app_type:" + appType);
|
||||||
|
System.out.println("app_type:" + appType);
|
||||||
|
log.info("access_id:" + clientKey);
|
||||||
|
System.out.println("access_id:" + clientKey);
|
||||||
|
log.info("nonce:" + nonce);
|
||||||
|
System.out.println("nonce:" + nonce);
|
||||||
|
log.info("timestamp:" + timeStamp);
|
||||||
|
System.out.println("timestamp:" + timeStamp);
|
||||||
|
log.info("sign:" + genSign);
|
||||||
|
System.out.println("sign:" + genSign);
|
||||||
|
log.info("Authorization:" + token);
|
||||||
|
System.out.println("Authorization:" + token);
|
||||||
|
log.info("========================================开始请求========================================");
|
||||||
|
HttpResponse response = HttpRequest.post(url)
|
||||||
|
.body(JSONObject.toJSONString(body))
|
||||||
|
.header("Content-Type", "application/json")
|
||||||
|
.header("client_type", client_type)
|
||||||
|
.header("app_type", appType)
|
||||||
|
.header("access_id", clientKey)
|
||||||
|
.header("nonce", nonce)
|
||||||
|
.header("timestamp", timeStamp.toString())
|
||||||
|
.header("sign", genSign)
|
||||||
|
.header("Authorization", token)
|
||||||
|
.execute();
|
||||||
|
log.info("========================================请求结果========================================");
|
||||||
|
System.out.println("response:" + response);
|
||||||
|
log.info("response:" + response);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同城急送平台工具,获取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
|
||||||
|
// @Anonymous
|
||||||
|
// @GetMapping("/getToken")
|
||||||
|
public void getToken() {
|
||||||
|
System.out.println("获取token");
|
||||||
|
String url = "https://wyjcs.gdwyj.cn/szelec/city-delivery-api/api/mini/app/login/token";
|
||||||
|
String nonce = UUID.randomUUID().toString().replace("-", "");
|
||||||
|
Long timestamp = System.currentTimeMillis();
|
||||||
|
//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);
|
||||||
|
|
||||||
|
HttpResponse response = HttpRequest.post(url)
|
||||||
|
.body(JSON.toJSONString(bodyMap))
|
||||||
|
.header("Content-Type", "application/json")
|
||||||
|
.header("client_type", client_type)
|
||||||
|
.header("app_type", appType)
|
||||||
|
.header("access_id", clientKey)
|
||||||
|
.header("nonce", nonce)
|
||||||
|
.header("timestamp", timestamp.toString())
|
||||||
|
.header("sign", genSign)
|
||||||
|
.execute();
|
||||||
|
log.info("response:" + response);
|
||||||
|
System.out.println("response:" + response);
|
||||||
|
log.info("responseBody:" + response.body());
|
||||||
|
System.out.println("responseBody:" + response.body());
|
||||||
|
|
||||||
|
JSONObject jsonObject = JSON.parseObject(response.body());
|
||||||
|
Map<String, Object> result = (Map<String, Object>) jsonObject.get("result");
|
||||||
|
String token = (String) result.get("token");
|
||||||
|
Long expirationTimestamp = (Long) result.get("expirationTimestamp");
|
||||||
|
redisTemplate.opsForValue().set("city_delivery_token", token);
|
||||||
|
redisTemplate.opsForValue().set("city_delivery_token_expirationTimestamp", expirationTimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@GetMapping("/111")
|
||||||
|
@Anonymous
|
||||||
|
public void test(){
|
||||||
|
String body = "{\"success\":true,\"message\":\"\",\"code\":200,\"result\":{\"expirationTimestamp\":1737624154641,\"token\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOiIxMDAwMiIsInJuU3RyIjoiRDA5VGtjUTZ4Y3dobjdMNDFISXdWTjM1bGdScWt1cVkiLCJjbGllbnRUeXBlIjoib3RoZXIiLCJ1c2VySWQiOiIxMDAwMiJ9.yA3zq8e4uDZCLBlMpL0dfyIfkP3zoegcNt9iHSjB-jM\"},\"timestamp\":1737620554641}\n";
|
||||||
|
JSONObject jsonObject = JSON.parseObject(body);
|
||||||
|
System.out.println("jsonObject = " + jsonObject);
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新token
|
||||||
|
*
|
||||||
|
* @return token
|
||||||
|
*/
|
||||||
|
public String refreshToken() {
|
||||||
|
String cacheToken = (String) redisTemplate.opsForValue().get("city_delivery_token");
|
||||||
|
if (ObjectUtil.isNotEmpty(cacheToken)) {
|
||||||
|
long expirationTimestamp = (long)redisTemplate.opsForValue().get("city_delivery_token_expirationTimestamp");
|
||||||
|
long currentTimeMillis = System.currentTimeMillis();
|
||||||
|
if (expirationTimestamp > currentTimeMillis) { // 没过期
|
||||||
|
return cacheToken;
|
||||||
|
} else { // 过期,重新获取
|
||||||
|
getToken();
|
||||||
|
return (String) redisTemplate.opsForValue().get("city_delivery_token");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
getToken();
|
||||||
|
return (String) redisTemplate.opsForValue().get("city_delivery_token");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.cpxt.web.controller.biz.orderutil;
|
package com.cpxt.biz.orderutil;
|
||||||
|
|
||||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
import cn.hutool.core.exceptions.ExceptionUtil;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
|
|
@ -20,7 +20,7 @@ import java.util.Base64;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class cityDelivery_SM4Util {
|
public class CityDelivery_SM4Util {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -5,7 +5,6 @@ import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
|
@ -15,6 +14,7 @@ import com.cpxt.biz.domain.*;
|
||||||
import com.cpxt.biz.domain.vo.BizOrderVo;
|
import com.cpxt.biz.domain.vo.BizOrderVo;
|
||||||
import com.cpxt.biz.domain.vo.BizOrderVoCustomer;
|
import com.cpxt.biz.domain.vo.BizOrderVoCustomer;
|
||||||
import com.cpxt.biz.mapper.*;
|
import com.cpxt.biz.mapper.*;
|
||||||
|
import com.cpxt.biz.orderutil.CityDelivery;
|
||||||
import com.cpxt.common.core.domain.entity.SysUser;
|
import com.cpxt.common.core.domain.entity.SysUser;
|
||||||
import com.cpxt.common.exception.ServiceException;
|
import com.cpxt.common.exception.ServiceException;
|
||||||
import com.cpxt.common.utils.Helper;
|
import com.cpxt.common.utils.Helper;
|
||||||
|
|
@ -73,6 +73,9 @@ public class BizOrderServiceImpl implements IBizOrderService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysUserMapper sysUserMapper;
|
private SysUserMapper sysUserMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CityDelivery cityDelivery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询订单
|
* 查询订单
|
||||||
*
|
*
|
||||||
|
|
@ -330,9 +333,14 @@ public class BizOrderServiceImpl implements IBizOrderService {
|
||||||
|
|
||||||
bizOrder.setCustomerName(bizCustomerMapper.selectById(customerId).getName());
|
bizOrder.setCustomerName(bizCustomerMapper.selectById(customerId).getName());
|
||||||
if (ObjectUtil.isNotEmpty(routeId)) bizOrder.setRouteName(bizCustomerRouteMapper.selectById(routeId).getName());
|
if (ObjectUtil.isNotEmpty(routeId)) bizOrder.setRouteName(bizCustomerRouteMapper.selectById(routeId).getName());
|
||||||
if (ObjectUtil.isNotEmpty(warehouseId))
|
if (ObjectUtil.isNotEmpty(warehouseId)){
|
||||||
bizOrder.setWarehouseName(bizCustomerWarehouseMapper.selectById(warehouseId).getName());
|
bizOrder.setWarehouseName(bizCustomerWarehouseMapper.selectById(warehouseId).getName());
|
||||||
if (ObjectUtil.isNotEmpty(shopId)) bizOrder.setShopName(bizCustomerShopMapper.selectById(shopId).getName());
|
bizOrder.setSenderArea(bizCustomerWarehouseMapper.selectById(warehouseId).getArea());
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(shopId)){
|
||||||
|
bizOrder.setShopName(bizCustomerShopMapper.selectById(shopId).getName());
|
||||||
|
bizOrder.setReceiverArea(bizCustomerShopMapper.selectById(shopId).getArea());
|
||||||
|
}
|
||||||
if (ObjectUtil.isNotEmpty(carId)) bizOrder.setCarNo(bizCarMapper.selectById(carId).getCarNo());
|
if (ObjectUtil.isNotEmpty(carId)) bizOrder.setCarNo(bizCarMapper.selectById(carId).getCarNo());
|
||||||
if (ObjectUtil.isNotEmpty(driverId)) bizOrder.setDriverName(bizDriverMapper.selectById(driverId).getName());
|
if (ObjectUtil.isNotEmpty(driverId)) bizOrder.setDriverName(bizDriverMapper.selectById(driverId).getName());
|
||||||
if (ObjectUtil.isNotEmpty(copilotId)) bizOrder.setCopilotName(bizDriverMapper.selectById(copilotId).getName());
|
if (ObjectUtil.isNotEmpty(copilotId)) bizOrder.setCopilotName(bizDriverMapper.selectById(copilotId).getName());
|
||||||
|
|
@ -377,6 +385,8 @@ public class BizOrderServiceImpl implements IBizOrderService {
|
||||||
BizOrder bizOrder = bizOrderMapper.selectByOrderSn(orderSn);
|
BizOrder bizOrder = bizOrderMapper.selectByOrderSn(orderSn);
|
||||||
bizOrder.setSubStatus(1);
|
bizOrder.setSubStatus(1);
|
||||||
bizOrderMapper.updateById(bizOrder);
|
bizOrderMapper.updateById(bizOrder);
|
||||||
|
// 同步调用同城急送平台
|
||||||
|
cityDelivery.addOrder(bizOrder,bizOrderSub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue