|
|
@@ -2,7 +2,6 @@ package com.zsElectric.boot.common.util.electric;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.google.gson.Gson;
|
|
|
-import com.google.gson.JsonElement;
|
|
|
import com.google.gson.JsonObject;
|
|
|
import com.zsElectric.boot.common.constant.ConnectivityConstants;
|
|
|
import com.zsElectric.boot.common.util.AESCryptoUtil;
|
|
|
@@ -13,7 +12,6 @@ import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.security.NoSuchAlgorithmException;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
@@ -70,14 +68,18 @@ public class ChargingUtil {
|
|
|
public JsonObject responseDecode(JsonObject response){
|
|
|
|
|
|
try {
|
|
|
+ if (Objects.isNull(response)) {
|
|
|
+ log.error("第三方接口响应数据为空");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
Gson gson = new Gson();
|
|
|
ResponseParmsEntity responseParms = gson.fromJson(response, ResponseParmsEntity.class);
|
|
|
- boolean verify = HmacMD5Util.verify(responseParms.getData(), ConnectivityConstants.PLATFORM_DATA_SECRET, responseParms.getSig());
|
|
|
+ String data = responseParms.getRet() + responseParms.getMsg() + responseParms.getData();
|
|
|
+ boolean verify = HmacMD5Util.verify(data, ConnectivityConstants.PLATFORM_DATA_SECRET, responseParms.getSig());
|
|
|
if (!verify) {
|
|
|
log.error("第三方接口响应数据签名验证失败");
|
|
|
return null;
|
|
|
}
|
|
|
-
|
|
|
if (responseParms.getRet() != 0){
|
|
|
switch (responseParms.getRet()) {
|
|
|
case -1:
|
|
|
@@ -100,7 +102,6 @@ public class ChargingUtil {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
String decodeData = AESCryptoUtil.decrypt(responseParms.getData(), ConnectivityConstants.PLATFORM_DATA_SECRET,
|
|
|
ConnectivityConstants.PLATFORM_DATA_SECRET_IV);
|
|
|
return gson.fromJson(decodeData, JsonObject.class);
|