mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
update 对接内蒙古平台
This commit is contained in:
@@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
||||
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
||||
@@ -53,7 +54,7 @@ public class ThirdPartyBaseController extends BaseController {
|
||||
// 解析DTO
|
||||
protected <T> T parseDto(CommonParamsDTO dto, Class<T> targetClass) {
|
||||
// 解密
|
||||
String operatorId = dto.getOperatorID();
|
||||
String operatorId = StringUtils.isNotBlank(dto.getOperatorID()) ? dto.getOperatorID() : dto.getPlatformID();
|
||||
// 通过operatorId 查出 operatorSecret
|
||||
// ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId);
|
||||
ThirdPartySecretInfoVO secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId);
|
||||
@@ -61,8 +62,8 @@ public class ThirdPartyBaseController extends BaseController {
|
||||
throw new BusinessException("1", "无此对接平台");
|
||||
}
|
||||
|
||||
String dataSecret = secretInfoVO.getTheirDataSecret();
|
||||
String dataSecretIv = secretInfoVO.getTheirDataSecretIv();
|
||||
String dataSecret = secretInfoVO.getOurDataSecret();
|
||||
String dataSecretIv = secretInfoVO.getOurDataSecretIv();
|
||||
|
||||
// 解密data 获取参数中的OperatorSecret
|
||||
String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv);
|
||||
|
||||
@@ -37,7 +37,8 @@ public class CacheConstants {
|
||||
public static final int cache_expire_time_30d = cache_expire_time_1d * 30;
|
||||
|
||||
// 第三方平台密钥配置
|
||||
public static final String THIRD_PARTY_SECRET_INFO = "third_party_secret_info:";
|
||||
public static final String THIRD_PARTY_SECRET_INFO_BY_ID = "third_party_secret_info_by_id:";
|
||||
public static final String THIRD_PARTY_SECRET_INFO_BY_TYPE = "third_party_secret_info_by_type:";
|
||||
|
||||
// 保存order_monitor_data
|
||||
public static final String INSERT_ORDER_MONITOR_DATA = "insert_order_monitor_data:";
|
||||
|
||||
@@ -63,4 +63,6 @@ public interface ThirdpartySecretInfoMapper {
|
||||
int deleteThirdpartySecretInfoByIds(Long[] ids);
|
||||
|
||||
ThirdPartySecretInfoVO queryByOperatorId(String theirOperatorId);
|
||||
|
||||
ThirdPartySecretInfoVO queryByThirdPlatformType(String thirdPlatformType);
|
||||
}
|
||||
|
||||
@@ -61,4 +61,6 @@ public interface ThirdpartySecretInfoService {
|
||||
public int deleteThirdpartySecretInfoById(Long id);
|
||||
|
||||
ThirdPartySecretInfoVO queryByOperatorId(String theirOperatorId);
|
||||
|
||||
ThirdPartySecretInfoVO queryByThirdPlatformType(String thirdPlatformType);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class ThirdpartySecretInfoServiceImpl implements ThirdpartySecretInfoServ
|
||||
@Override
|
||||
public ThirdPartySecretInfoVO queryByOperatorId(String theirOperatorId) {
|
||||
// 加缓存
|
||||
String redisKey = CacheConstants.THIRD_PARTY_SECRET_INFO + theirOperatorId;
|
||||
String redisKey = CacheConstants.THIRD_PARTY_SECRET_INFO_BY_ID + theirOperatorId;
|
||||
ThirdPartySecretInfoVO result = redisCache.getCacheObject(redisKey);
|
||||
if (Objects.isNull(result)) {
|
||||
result = thirdpartySecretInfoMapper.queryByOperatorId(theirOperatorId);
|
||||
@@ -113,4 +113,18 @@ public class ThirdpartySecretInfoServiceImpl implements ThirdpartySecretInfoServ
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThirdPartySecretInfoVO queryByThirdPlatformType(String thirdPlatformType) {
|
||||
// 加缓存
|
||||
String redisKey = CacheConstants.THIRD_PARTY_SECRET_INFO_BY_TYPE + thirdPlatformType;
|
||||
ThirdPartySecretInfoVO result = redisCache.getCacheObject(redisKey);
|
||||
if (Objects.isNull(result)) {
|
||||
result = thirdpartySecretInfoMapper.queryByThirdPlatformType(thirdPlatformType);
|
||||
if (Objects.nonNull(result)) {
|
||||
redisCache.setCacheObject(redisKey, result, CacheConstants.cache_expire_time_1h);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,4 +152,21 @@
|
||||
where del_flag = '0'
|
||||
and their_operator_id = #{theirOperatorId,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<select id="queryByThirdPlatformType" resultType="com.jsowell.pile.vo.ThirdPartySecretInfoVO">
|
||||
select
|
||||
t1.their_operator_id as theirOperatorId,
|
||||
t1.their_operator_secret as theirOperatorSecret,
|
||||
t1.their_data_secret as theirDataSecret,
|
||||
t1.their_data_secret_iv as theirDataSecretIv,
|
||||
t1.their_sig_secret as theirSigSecret,
|
||||
t1.url_prefix as theirUrlPrefix,
|
||||
t1.our_operator_secret as ourOperatorSecret,
|
||||
t1.our_data_secret as ourDataSecret,
|
||||
t1.our_data_secret_iv as ourDataSecretIv,
|
||||
t1.our_sig_secret as ourSigSecret
|
||||
from thirdparty_secret_info t1
|
||||
where del_flag = '0'
|
||||
and platform_type = #{thirdPlatformType,jdbcType=VARCHAR}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -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:密钥错误; 3~99:自定义
|
||||
// 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:密钥错误; 3~99:自定义
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
10
jsowell-ui/src/views/thirdParty/secret/index.vue
vendored
10
jsowell-ui/src/views/thirdParty/secret/index.vue
vendored
@@ -131,7 +131,14 @@
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<!--<el-table-column label="主键" align="center" prop="id" />-->
|
||||
<el-table-column label="对接平台名称" align="center" prop="platformName" />
|
||||
<el-table-column label="对接平台类型" align="center" prop="platformType" />
|
||||
<el-table-column label="对接平台类型" align="center" prop="platformType" >
|
||||
<template slot-scope="scope">
|
||||
<dict-tag
|
||||
:options="dict.type.pile_status"
|
||||
:value="scope.row.status"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="接口地址前缀" align="center" prop="urlPrefix" />
|
||||
<el-table-column label="对接平台标识" align="center" prop="theirOperatorId" />
|
||||
<!--<el-table-column label="对接平台生成的唯一识别密钥" align="center" prop="theirOperatorSecret" />
|
||||
@@ -222,6 +229,7 @@ import {addSecret, getSecret, listSecret, updateSecret} from "@/api/thirdParty/s
|
||||
|
||||
export default {
|
||||
name: "Secret",
|
||||
dicts: ["connector_type"],
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
|
||||
Reference in New Issue
Block a user