bugfix 修复获取甬城泊车平台获取令牌错误

This commit is contained in:
Lemon
2023-11-23 11:46:11 +08:00
parent 2d3459c67b
commit 1cf38cd8e4
2 changed files with 27 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ package com.jsowell.thirdparty.yongchengboche.service.impl;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
@@ -116,19 +117,21 @@ public class YCBCServiceImpl implements YCBCService {
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64((String) result.getData()),
dataSecret.getBytes(), dataSecretIv.getBytes());
String dataStr = new String(plainText, "UTF-8");
Map<String, String> resultMap = (Map<String, String>) JSON.parse(dataStr);
int succStat = Integer.parseInt(resultMap.get("SuccStat"));
JSONObject resultJson = (JSONObject) JSON.parse(dataStr);
logger.info("获取甬城泊车平台令牌 resultJson:{}", resultJson);
int succStat = resultJson.getInteger("SuccStat");
if (succStat != 0) {
logger.error("获取甬城泊车平台令牌 error:{}", result.getMsg());
return token;
}
token = resultMap.get("AccessToken");
token = resultJson.getString("AccessToken");
logger.info("甬城泊车 token: {}", token);
// 存入缓存
int tokenAvailableTime = Integer.parseInt(resultMap.get("TokenAvailableTime"));
redisCache.setCacheObject(redisKey, token, tokenAvailableTime, TimeUnit.SECONDS);
long tokenAvailableTime = resultJson.getLong("TokenAvailableTime");
redisCache.setCacheObject(redisKey, token, (int) tokenAvailableTime, TimeUnit.SECONDS);
}
} catch (Exception e) {
logger.error("获取甬城泊车平台令牌 error:", e);
return token;
}
return token;