update 对接内蒙古平台

This commit is contained in:
2024-04-19 14:06:01 +08:00
parent 646e88b057
commit 7e41f69f5a
9 changed files with 105 additions and 52 deletions

View File

@@ -5,7 +5,6 @@ import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.github.pagehelper.PageInfo;
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.enums.thirdparty.BusinessInformationExchangeEnum;
@@ -14,6 +13,7 @@ import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.enums.ykc.BillingTimeTypeEnum;
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.JWTUtils;
import com.jsowell.common.util.PageUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.OrderBasicInfo;
@@ -24,8 +24,10 @@ import com.jsowell.pile.dto.QueryEquipChargeStatusDTO;
import com.jsowell.pile.dto.QueryOperatorInfoDTO;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.service.*;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
import com.jsowell.pile.thirdparty.EquipmentInfo;
import com.jsowell.pile.util.MerchantUtils;
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
import com.jsowell.pile.vo.base.ConnectorInfoVO;
import com.jsowell.pile.vo.base.MerchantInfoVO;
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
@@ -35,6 +37,7 @@ import com.jsowell.pile.vo.web.PileStationVO;
import com.jsowell.thirdparty.lianlian.domain.ConnectorChargeStatusInfo;
import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo;
import com.jsowell.thirdparty.lianlian.domain.StationStatusInfo;
import com.jsowell.thirdparty.lianlian.vo.AccessTokenVO;
import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO;
import com.jsowell.thirdparty.platform.ThirdPartyPlatformService;
import com.jsowell.thirdparty.platform.neimenggu.domain.ChargeOrderInfo;
@@ -45,6 +48,7 @@ import com.jsowell.thirdparty.platform.util.Cryptos;
import com.jsowell.thirdparty.platform.util.Encodes;
import com.jsowell.thirdparty.platform.util.HttpRequestUtil;
import com.jsowell.thirdparty.platform.util.ThirdPartyPlatformUtils;
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -71,6 +75,9 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
@Autowired
private ThirdPartyStationRelationService thirdPartyStationRelationService;
@Autowired
private ThirdpartySecretInfoService thirdpartySecretInfoService;
@Autowired
private PileBasicInfoService pileBasicInfoService;
@@ -95,49 +102,49 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
* @param dto
* @return
*/
// @Override
// public Map<String, String> queryToken(CommonParamsDTO dto) {
// AccessTokenVO vo = new AccessTokenVO();
// // 0:成功1:失败
// int succStat = 0;
// // 0:无1:无此对接平台2:密钥错误; 399:自定义
// int failReason = 0;
//
// String operatorId = dto.getPlatformID();
// // 通过operatorId 查出 operatorSecret
// ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId);
// if (platformConfig == null) {
// failReason = 1;
// succStat = 1;
// } else {
// String operatorSecret = platformConfig.getOperatorSecret();
// String dataSecret = platformConfig.getDataSecret();
// String dataSecretIv = platformConfig.getDataSecretIv();
// // 解密data 获取参数中的OperatorSecret
// String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv);
// String inputOperatorSecret = null;
// if (StringUtils.isNotBlank(decrypt)) {
// inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret");
// }
// // 对比密钥
// if (!StringUtils.equals(operatorSecret, inputOperatorSecret)) {
// failReason = 1;
// succStat = 1;
// } else {
// // 生成token
// String token = JWTUtils.createToken(operatorId, operatorSecret, JWTUtils.ttlMillis);
// vo.setAccessToken(token);
// vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000));
// }
// }
// // 组装返回参数
// vo.setPlatformId(operatorId);
// vo.setFailReason(failReason);
// vo.setSuccStat(succStat);
//
// Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, platformConfig);
// return resultMap;
// }
@Override
public Map<String, String> queryToken(CommonParamsDTO dto) {
AccessTokenVO vo = new AccessTokenVO();
// 0:成功1:失败
int succStat = 0;
// 0:无1:无此对接平台2:密钥错误; 399:自定义
int failReason = 0;
String operatorId = dto.getPlatformID();
// 通过operatorId 查出 operatorSecret
ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId);
if (platformConfig == null) {
failReason = 1;
succStat = 1;
} else {
String operatorSecret = platformConfig.getOperatorSecret();
String dataSecret = platformConfig.getDataSecret();
String dataSecretIv = platformConfig.getDataSecretIv();
// 解密data 获取参数中的OperatorSecret
String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv);
String inputOperatorSecret = null;
if (StringUtils.isNotBlank(decrypt)) {
inputOperatorSecret = JSON.parseObject(decrypt).getString("PlatformSecret");
}
// 对比密钥
if (!StringUtils.equals(operatorSecret, inputOperatorSecret)) {
failReason = 1;
succStat = 1;
} else {
// 生成token
String token = JWTUtils.createToken(operatorId, operatorSecret, JWTUtils.ttlMillis);
vo.setAccessToken(token);
vo.setTokenAvailableTime((int) (JWTUtils.ttlMillis / 1000));
}
}
// 组装返回参数
vo.setPlatformId(operatorId);
vo.setFailReason(failReason);
vo.setSuccStat(succStat);
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(vo, platformConfig);
return resultMap;
}
/**
* 查询运营商信息 query_operator_info
@@ -148,7 +155,6 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
*/
@Override
public Map<String, String> queryOperatorInfo(QueryOperatorInfoDTO dto) {
Map<String, String> resultMap = Maps.newHashMap();
List<MerchantInfoVO> merchantList = thirdPartyStationRelationService.selectMerchantList(thirdPlatformType);
if (CollectionUtils.isNotEmpty(merchantList)) {
List<SupOperatorInfo> operatorInfos = Lists.newArrayList();
@@ -163,6 +169,8 @@ public class NeiMengGuPlatformServiceImpl implements ThirdPartyPlatformService {
operatorInfos.add(supOperatorInfo);
}
}
ThirdPartySecretInfoVO thirdPartySecretInfoVO = thirdpartySecretInfoService.queryByThirdPlatformType(thirdPlatformType);
Map<String, String> resultMap = ThirdPartyPlatformUtils.generateResultMap(merchantList, thirdPartySecretInfoVO);
return resultMap;
}

View File

@@ -20,7 +20,7 @@ public class ThirdPartyPlatformUtils {
* @return 结果集
*/
public static Map<String, String> generateResultMap(Object obj, ThirdPartySecretInfoVO secretInfo) {
return generateResultMap(obj, secretInfo.getTheirOperatorSecret(), secretInfo.getTheirDataSecretIv(), secretInfo.getTheirSigSecret());
return generateResultMap(obj, secretInfo.getOurDataSecret(), secretInfo.getOurDataSecretIv(), secretInfo.getTheirSigSecret());
}
/**