mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 19:45:09 +08:00
update 对接内蒙古平台
This commit is contained in:
@@ -3,6 +3,7 @@ package com.jsowell.thirdparty.platform.util;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
||||
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -12,6 +13,16 @@ import java.util.regex.Pattern;
|
||||
@Component
|
||||
public class ThirdPartyPlatformUtils {
|
||||
|
||||
/**
|
||||
* 生成结果集
|
||||
* @param obj 需要返回的数据
|
||||
* @param secretInfo 密钥配置信息对象
|
||||
* @return 结果集
|
||||
*/
|
||||
public static Map<String, String> generateResultMap(Object obj, ThirdPartySecretInfoVO secretInfo) {
|
||||
return generateResultMap(obj, secretInfo.getTheirOperatorSecret(), secretInfo.getTheirDataSecretIv(), secretInfo.getTheirSigSecret());
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成结果集
|
||||
* @param obj 需要返回的数据
|
||||
|
||||
@@ -3,13 +3,14 @@ package com.jsowell.thirdparty.platform.zhongdianlian.service;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.jsowell.common.util.JWTUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
||||
import com.jsowell.pile.service.ThirdPartyPlatformConfigService;
|
||||
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
||||
import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO;
|
||||
import com.jsowell.thirdparty.platform.ThirdPartyPlatformService;
|
||||
import com.jsowell.thirdparty.platform.util.Cryptos;
|
||||
import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils;
|
||||
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -21,6 +22,9 @@ public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformServi
|
||||
@Autowired
|
||||
private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService;
|
||||
|
||||
@Autowired
|
||||
private ThirdpartySecretInfoService thirdpartySecretInfoService;
|
||||
|
||||
/**
|
||||
* query_token 获取token,提供给第三方平台使用
|
||||
*
|
||||
@@ -37,14 +41,15 @@ public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformServi
|
||||
|
||||
String operatorId = StringUtils.isNotBlank(dto.getOperatorID()) ? dto.getOperatorID() : dto.getPlatformID();
|
||||
// 通过operatorId 查出 operatorSecret
|
||||
ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId);
|
||||
if (platformConfig == null) {
|
||||
// ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId);
|
||||
ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId);
|
||||
if (thirdPartySecretInfoVO == null) {
|
||||
failReason = 1;
|
||||
succStat = 1;
|
||||
} else {
|
||||
String operatorSecret = platformConfig.getOperatorSecret();
|
||||
String dataSecret = platformConfig.getDataSecret();
|
||||
String dataSecretIv = platformConfig.getDataSecretIv();
|
||||
String theirOperatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
|
||||
String dataSecret = thirdPartySecretInfoVO.getOurDataSecret();
|
||||
String dataSecretIv = thirdPartySecretInfoVO.getOurDataSecretIv();
|
||||
// 解密data 获取参数中的OperatorSecret
|
||||
String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv);
|
||||
String inputOperatorSecret = null;
|
||||
@@ -52,12 +57,12 @@ public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformServi
|
||||
inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret");
|
||||
}
|
||||
// 对比密钥
|
||||
if (!StringUtils.equals(operatorSecret, inputOperatorSecret)) {
|
||||
if (!StringUtils.equals(theirOperatorSecret, inputOperatorSecret)) {
|
||||
failReason = 1;
|
||||
succStat = 1;
|
||||
} else {
|
||||
// 生成token
|
||||
String token = JWTUtils.createToken(operatorId, operatorSecret, JWTUtils.ttlMillis);
|
||||
String token = JWTUtils.createToken(operatorId, theirOperatorSecret, JWTUtils.ttlMillis);
|
||||
vo.setAccessToken(token);
|
||||
vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000));
|
||||
}
|
||||
@@ -67,7 +72,7 @@ public class ZhongDianLianPlatformServiceImpl implements ThirdPartyPlatformServi
|
||||
vo.setFailReason(failReason);
|
||||
vo.setSuccStat(succStat);
|
||||
|
||||
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, platformConfig);
|
||||
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO);
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user