mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
update
This commit is contained in:
@@ -9,6 +9,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.lianlian.StationPaymentEnum;
|
||||
import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum;
|
||||
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
||||
@@ -57,6 +58,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -84,6 +86,8 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
private OrderBasicInfoService orderBasicInfoService;
|
||||
@Autowired
|
||||
private PileBillingTemplateService pileBillingTemplateService;
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
@@ -91,7 +95,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
}
|
||||
|
||||
/**
|
||||
* query_token 获取token,提供给第三方平台使用
|
||||
* 请求令牌 query_token
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
@@ -104,41 +108,50 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
// 0:无;1:无此对接平台;2:密钥错误; 3~99:自定义
|
||||
int failReason = 0;
|
||||
|
||||
String operatorId = dto.getPlatformID();
|
||||
String operatorId = dto.getOperatorID();
|
||||
// token缓存key值
|
||||
String redisKey = operatorId + "_token:";
|
||||
// 通过operatorId 查出 operatorSecret
|
||||
ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId);
|
||||
ThirdPartySecretInfoVO thirdPartySecretInfoVO = getGuiZhouPlatformSecretInfo();
|
||||
if (thirdPartySecretInfoVO == null) {
|
||||
failReason = 1;
|
||||
succStat = 1;
|
||||
} else {
|
||||
String theirOperatorSecret = thirdPartySecretInfoVO.getTheirOperatorSecret();
|
||||
String ourOperatorSecret = thirdPartySecretInfoVO.getOurOperatorSecret();
|
||||
String dataSecret = thirdPartySecretInfoVO.getOurDataSecret();
|
||||
String dataSecretIv = thirdPartySecretInfoVO.getOurDataSecretIv();
|
||||
// 解密data 获取参数中的OperatorSecret
|
||||
String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv);
|
||||
if (StringUtils.isBlank(decrypt)) {
|
||||
failReason = 2;
|
||||
String inputOperatorSecret = null;
|
||||
if (StringUtils.isNotBlank(decrypt)) {
|
||||
inputOperatorSecret = JSON.parseObject(decrypt).getString("OperatorSecret");
|
||||
}
|
||||
// 对比密钥
|
||||
if (!StringUtils.equals(ourOperatorSecret, inputOperatorSecret)) {
|
||||
failReason = 1;
|
||||
succStat = 1;
|
||||
} else {
|
||||
String inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret");
|
||||
// 对比密钥
|
||||
if (!StringUtils.equals(theirOperatorSecret, inputOperatorSecret)) {
|
||||
failReason = 2;
|
||||
succStat = 1;
|
||||
} else {
|
||||
// 先查缓存中是否有已生成的token
|
||||
String token = redisCache.getCacheObject(redisKey);
|
||||
int expiredTime = (int) redisCache.getExpire(redisKey);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
// 生成token
|
||||
String token = JWTUtils.createToken(operatorId, theirOperatorSecret, JWTUtils.ttlMillis);
|
||||
vo.setAccessToken(token);
|
||||
vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000));
|
||||
token = JWTUtils.createToken(operatorId, ourOperatorSecret, JWTUtils.ttlMillis);
|
||||
expiredTime = (int) (JWTUtils.ttlMillis / 1000);
|
||||
}
|
||||
vo.setAccessToken(token);
|
||||
vo.setTokenAvailableTime(expiredTime);
|
||||
// 设置缓存
|
||||
redisCache.setCacheObject(redisKey, token, expiredTime, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
// 组装返回参数
|
||||
vo.setPlatformId(operatorId);
|
||||
vo.setOperatorID(operatorId);
|
||||
vo.setFailReason(failReason);
|
||||
vo.setSuccStat(succStat);
|
||||
|
||||
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, thirdPartySecretInfoVO);
|
||||
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMapV2(vo, thirdPartySecretInfoVO.getOurDataSecret()
|
||||
, thirdPartySecretInfoVO.getOurDataSecretIv(), thirdPartySecretInfoVO.getOurSigSecret());
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@@ -787,6 +800,7 @@ public class GuiZhouPlatformServiceImpl implements ThirdPartyPlatformService {
|
||||
* @return
|
||||
*/
|
||||
private ThirdPartySecretInfoVO getGuiZhouPlatformSecretInfo() {
|
||||
String thirdPartyType = ThirdPlatformTypeEnum.GUI_ZHOU_PLATFORM.getTypeCode();
|
||||
// 通过第三方平台类型查询相关配置信息
|
||||
ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(ThirdPlatformTypeEnum.GUI_ZHOU_PLATFORM.getTypeCode());
|
||||
if (thirdPartySecretInfoVO == null) {
|
||||
|
||||
Reference in New Issue
Block a user