|
|
@@ -1,24 +1,19 @@
|
|
|
package com.kym.service.platform.impl;
|
|
|
|
|
|
-import cn.hutool.core.date.DatePattern;
|
|
|
-import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
-import cn.hutool.crypto.digest.HMac;
|
|
|
-import cn.hutool.crypto.digest.HmacAlgorithm;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.kym.common.annotation.ConnectorID;
|
|
|
import com.kym.common.annotation.DynamicCache;
|
|
|
import com.kym.common.annotation.PlatformConvert;
|
|
|
import com.kym.common.annotation.PlatformName;
|
|
|
+import com.kym.common.cache.PlatformCache;
|
|
|
import com.kym.common.constant.ResponseEnum;
|
|
|
import com.kym.common.exception.BusinessException;
|
|
|
-import com.kym.common.exception.PlatformPushException;
|
|
|
import com.kym.common.utils.CommUtil;
|
|
|
import com.kym.common.utils.PlatformAesUtil;
|
|
|
import com.kym.common.utils.PlatformConvertUtil;
|
|
|
import com.kym.entity.common.RedisKeys;
|
|
|
import com.kym.entity.platform.PlatformRespQueryToken;
|
|
|
import com.kym.entity.platform.response.PlatformResponse;
|
|
|
-import com.kym.common.cache.PlatformCache;
|
|
|
import com.kym.service.platform.PlatformApi;
|
|
|
import com.kym.service.platform.PlatformApiService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -27,7 +22,6 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
-import java.time.LocalDateTime;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import static com.kym.common.utils.PlatformAesUtil.buildPlatformParams;
|
|
|
@@ -88,10 +82,10 @@ public class PlatformApiServiceImpl implements PlatformApiService {
|
|
|
log.error(":url:{}, params:{},token:{},返回信息:{}", url, params, token, response);
|
|
|
if (4002 == response.getRet()) {
|
|
|
// 如果返回Ret=4002,token错误的情况下,删除redis中的token,如果是预约订单则将此订单设置为延迟启动
|
|
|
- redisTemplate.delete(RedisKeys.EN_PLUS_TOKEN + platformName);
|
|
|
- throw new BusinessException(ResponseEnum.PLATFORM_TOKEN_EXCEPTION);
|
|
|
+ redisTemplate.delete(RedisKeys.PLATFORM_QUERY_TOKEN + platformName);
|
|
|
+ throw new BusinessException(ResponseEnum.PLATFORM_QUERY_TOKEN_EXCEPTION);
|
|
|
}
|
|
|
- throw new BusinessException(ResponseEnum.PLATFORM__API_EXCEPTION);
|
|
|
+ throw new BusinessException(ResponseEnum.PLATFORM_API_EXCEPTION);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -117,10 +111,10 @@ public class PlatformApiServiceImpl implements PlatformApiService {
|
|
|
@Override
|
|
|
public String queryPlatformToken(String platformName) {
|
|
|
log.info("查询互联互通平台{}token", platformName);
|
|
|
- var token = redisTemplate.opsForValue().get(RedisKeys.EN_PLUS_TOKEN + platformName);
|
|
|
+ var token = redisTemplate.opsForValue().get(RedisKeys.PLATFORM_QUERY_TOKEN + platformName);
|
|
|
if (CommUtil.isNotEmptyAndNull(token)) {
|
|
|
// 不同平台不同key
|
|
|
- log.debug("从缓存中查询到token:{},ttl:{}", token, redisTemplate.getExpire(RedisKeys.EN_PLUS_TOKEN + platformName));
|
|
|
+ log.debug("从缓存中查询到token:{},ttl:{}", token, redisTemplate.getExpire(RedisKeys.PLATFORM_QUERY_TOKEN + platformName));
|
|
|
return token;
|
|
|
}
|
|
|
var platform = PlatformCache.INSTANCE.getPlatformByName(platformName);
|
|
|
@@ -141,7 +135,7 @@ public class PlatformApiServiceImpl implements PlatformApiService {
|
|
|
var platformRespQueryToken = parse(jsonObject.toJSONString(), PlatformRespQueryToken.class);
|
|
|
log.debug("{}接口AccessToken:{}", platformName, platformRespQueryToken.toString());
|
|
|
// 缓存token不同平台不同key,有效期7天(我们这里每次请求en+获取token的有效期并不是从7天开始,有效期是在en+的剩余有效时间)
|
|
|
- redisTemplate.opsForValue().set(RedisKeys.EN_PLUS_TOKEN + platformName,
|
|
|
+ redisTemplate.opsForValue().set(RedisKeys.PLATFORM_QUERY_TOKEN + platformName,
|
|
|
platformRespQueryToken.getAccessToken(), platformRespQueryToken.getTokenAvailableTime(), TimeUnit.SECONDS);
|
|
|
return platformRespQueryToken.getAccessToken();
|
|
|
} else {
|
|
|
@@ -164,7 +158,7 @@ public class PlatformApiServiceImpl implements PlatformApiService {
|
|
|
return response;
|
|
|
} else {
|
|
|
log.error("互联互通接口数据异常:url:{}, params:{},返回信息:{}", url, params, response);
|
|
|
- throw new BusinessException(ResponseEnum.PLATFORM__API_EXCEPTION);
|
|
|
+ throw new BusinessException(ResponseEnum.PLATFORM_API_EXCEPTION);
|
|
|
}
|
|
|
}
|
|
|
|