mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-11 05:20:14 +08:00
update 对接lianlian平台
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
package com.jsowell.web.controller.thirdparty;
|
package com.jsowell.web.controller.thirdparty;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
@@ -10,15 +9,10 @@ import com.jsowell.common.exception.BusinessException;
|
|||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||||
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
||||||
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
|
||||||
import com.jsowell.thirdparty.platform.ThirdPartyPlatformService;
|
|
||||||
import com.jsowell.thirdparty.platform.util.Cryptos;
|
import com.jsowell.thirdparty.platform.util.Cryptos;
|
||||||
import com.jsowell.thirdparty.platform.util.GBSignUtils;
|
import com.jsowell.thirdparty.platform.util.GBSignUtils;
|
||||||
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
|
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@@ -33,9 +27,9 @@ import java.util.Map;
|
|||||||
@RestController
|
@RestController
|
||||||
public class ThirdPartyBaseController extends BaseController {
|
public class ThirdPartyBaseController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
// @Autowired
|
||||||
@Qualifier("zhongDianLianPlatformServiceImpl")
|
// @Qualifier("zhongDianLianPlatformServiceImpl")
|
||||||
private ThirdPartyPlatformService platformLogic;
|
// private ThirdPartyPlatformService platformLogic;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ThirdpartySecretInfoService thirdpartySecretInfoService;
|
private ThirdpartySecretInfoService thirdpartySecretInfoService;
|
||||||
@@ -44,18 +38,18 @@ public class ThirdPartyBaseController extends BaseController {
|
|||||||
* 获取token接口
|
* 获取token接口
|
||||||
* http://localhost:8080/query_token
|
* http://localhost:8080/query_token
|
||||||
*/
|
*/
|
||||||
@PostMapping("/query_token")
|
// @PostMapping("/query_token")
|
||||||
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
// public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
||||||
logger.info("平台请求令牌 params:{}", JSON.toJSONString(dto));
|
// logger.info("平台请求令牌 params:{}", JSON.toJSONString(dto));
|
||||||
try {
|
// try {
|
||||||
Map<String, String> map = platformLogic.queryToken(dto);
|
// Map<String, String> map = platformLogic.queryToken(dto);
|
||||||
logger.info("平台请求令牌 result:{}", JSON.toJSONString(map));
|
// logger.info("平台请求令牌 result:{}", JSON.toJSONString(map));
|
||||||
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
// return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
logger.error("平台请求令牌接口 异常", e);
|
// logger.error("平台请求令牌接口 异常", e);
|
||||||
return CommonResult.failed("获取token发生异常");
|
// return CommonResult.failed("获取token发生异常");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,7 +63,6 @@ public class ThirdPartyBaseController extends BaseController {
|
|||||||
// 解密
|
// 解密
|
||||||
String operatorId = StringUtils.isNotBlank(dto.getOperatorID()) ? dto.getOperatorID() : dto.getPlatformID();
|
String operatorId = StringUtils.isNotBlank(dto.getOperatorID()) ? dto.getOperatorID() : dto.getPlatformID();
|
||||||
// 通过operatorId 查出 operatorSecret
|
// 通过operatorId 查出 operatorSecret
|
||||||
// ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId);
|
|
||||||
ThirdPartySecretInfoVO secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId);
|
ThirdPartySecretInfoVO secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId);
|
||||||
if (secretInfoVO == null) {
|
if (secretInfoVO == null) {
|
||||||
throw new BusinessException("1", "无此对接平台");
|
throw new BusinessException("1", "无此对接平台");
|
||||||
|
|||||||
@@ -418,10 +418,10 @@ public class LianLianController extends ThirdPartyBaseController {
|
|||||||
try {
|
try {
|
||||||
// 校验令牌
|
// 校验令牌
|
||||||
String token = request.getHeader("Authorization");
|
String token = request.getHeader("Authorization");
|
||||||
// if (!JWTUtils.checkThirdPartyToken(token)) {
|
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||||
// // 校验失败
|
// 校验失败
|
||||||
// return CommonResult.failed("令牌校验错误");
|
return CommonResult.failed("令牌校验错误");
|
||||||
// }
|
}
|
||||||
|
|
||||||
// 校验签名
|
// 校验签名
|
||||||
// Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
// Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||||
@@ -434,24 +434,9 @@ public class LianLianController extends ThirdPartyBaseController {
|
|||||||
// String dataSecret = resultMap.get("DataSecret");
|
// String dataSecret = resultMap.get("DataSecret");
|
||||||
// String dataSecretIV = resultMap.get("DataSecretIV");
|
// String dataSecretIV = resultMap.get("DataSecretIV");
|
||||||
|
|
||||||
// 查询配置信息
|
|
||||||
// ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorID());
|
|
||||||
// String operatorSecret = platformConfig.getOperatorSecret();
|
|
||||||
// String dataString = dto.getData();
|
|
||||||
// String dataSecret = platformConfig.getDataSecret();
|
|
||||||
// String dataSecretIV = platformConfig.getDataSecretIv();
|
|
||||||
|
|
||||||
// 解密data
|
|
||||||
// byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
|
||||||
// String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
|
||||||
// 转换成相应对象
|
|
||||||
// QueryStartChargeDTO queryStartChargeDTO = JSONObject.parseObject(dataStr, QueryStartChargeDTO.class);
|
|
||||||
// queryStartChargeDTO.setOperatorId(dto.getOperatorID());
|
|
||||||
// Map<String, String> map = lianLianService.query_start_charge(queryStartChargeDTO);
|
|
||||||
|
|
||||||
QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto, QueryStartChargeDTO.class);
|
QueryStartChargeDTO queryStartChargeDTO = parseParamsDTO(dto, QueryStartChargeDTO.class);
|
||||||
|
|
||||||
queryStartChargeDTO.setOperatorId(dto.getOperatorID());
|
|
||||||
Map<String, String> map = lianLianService.queryStartCharge(queryStartChargeDTO);
|
Map<String, String> map = lianLianService.queryStartCharge(queryStartChargeDTO);
|
||||||
|
|
||||||
return CommonResult.success(0, "请求启动充电成功!", map.get("Data"), map.get("Sig"));
|
return CommonResult.success(0, "请求启动充电成功!", map.get("Data"), map.get("Sig"));
|
||||||
|
|||||||
Reference in New Issue
Block a user