diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java index ffaf4434d..a3b3b5b5a 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/platform/service/impl/LianLianPlatformServiceImpl.java @@ -116,16 +116,14 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { // 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义 int failReason = 0; - String operatorId = dto.getOperatorID(); - // token缓存key值 - String redisKey = operatorId + "_token:"; + String operatorId = StringUtils.isNotBlank(dto.getOperatorID()) ? dto.getOperatorID() : dto.getPlatformID(); // 通过operatorId 查出 operatorSecret ThirdPartySecretInfoVO thirdPartySecretInfoVO = getLianLianPlatformSecretInfo(); if (thirdPartySecretInfoVO == null) { failReason = 1; succStat = 1; } else { - String ourOperatorSecret = thirdPartySecretInfoVO.getOurOperatorSecret(); + String theirOperatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String dataSecret = thirdPartySecretInfoVO.getOurDataSecret(); String dataSecretIv = thirdPartySecretInfoVO.getOurDataSecretIv(); // 解密data 获取参数中的OperatorSecret @@ -135,31 +133,23 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { inputOperatorSecret = JSON.parseObject(decrypt).getString("OperatorSecret"); } // 对比密钥 - if (!StringUtils.equals(ourOperatorSecret, inputOperatorSecret)) { + List operatorSecretList = Lists.newArrayList(theirOperatorSecret, thirdPartySecretInfoVO.getOurOperatorSecret()); + if (!operatorSecretList.contains(inputOperatorSecret)) { failReason = 1; succStat = 1; } else { - // 先查缓存中是否有已生成的token - String token = redisCache.getCacheObject(redisKey); - int expiredTime = (int) redisCache.getExpire(redisKey); - if (StringUtils.isBlank(token)) { - // 生成token - token = JWTUtils.createToken(operatorId, ourOperatorSecret, JWTUtils.ttlMillis); - expiredTime = (int) (JWTUtils.ttlMillis / 1000); - } + // 生成token + String token = JWTUtils.createToken(operatorId, theirOperatorSecret, JWTUtils.ttlMillis); vo.setAccessToken(token); - vo.setTokenAvailableTime(expiredTime); - // 设置缓存 - redisCache.setCacheObject(redisKey, token, expiredTime, TimeUnit.SECONDS); + vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000)); } } // 组装返回参数 - vo.setOperatorID(operatorId); + vo.setPlatformId(operatorId); vo.setFailReason(failReason); vo.setSuccStat(succStat); - Map resultMap = ThirdPartyPlatformUtils.generateResultMapV2(vo, thirdPartySecretInfoVO.getOurDataSecret(), - thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getTheirSigSecret()); + Map resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO); return resultMap; } @@ -761,7 +751,7 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService { // 查询相关配置信息 ThirdPartySecretInfoVO thirdPartySecretInfoVO = getLianLianPlatformSecretInfo(); - String operatorId = Constants.OPERATORID_JIANG_SU; + String operatorId = thirdPartySecretInfoVO.getOurOperatorId(); String operatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret(); String signSecret = thirdPartySecretInfoVO.getTheirSigSecret(); String dataSecret = thirdPartySecretInfoVO.getTheirDataSecret();