mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
update 对接lianlian平台
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package com.jsowell.web.controller.thirdparty;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
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.pile.thirdparty.CommonParamsDTO;
|
||||
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.GBSignUtils;
|
||||
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
|
||||
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 java.lang.reflect.Field;
|
||||
@@ -33,9 +27,9 @@ import java.util.Map;
|
||||
@RestController
|
||||
public class ThirdPartyBaseController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("zhongDianLianPlatformServiceImpl")
|
||||
private ThirdPartyPlatformService platformLogic;
|
||||
// @Autowired
|
||||
// @Qualifier("zhongDianLianPlatformServiceImpl")
|
||||
// private ThirdPartyPlatformService platformLogic;
|
||||
|
||||
@Autowired
|
||||
private ThirdpartySecretInfoService thirdpartySecretInfoService;
|
||||
@@ -44,18 +38,18 @@ public class ThirdPartyBaseController extends BaseController {
|
||||
* 获取token接口
|
||||
* http://localhost:8080/query_token
|
||||
*/
|
||||
@PostMapping("/query_token")
|
||||
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
||||
logger.info("平台请求令牌 params:{}", JSON.toJSONString(dto));
|
||||
try {
|
||||
Map<String, String> map = platformLogic.queryToken(dto);
|
||||
logger.info("平台请求令牌 result:{}", JSON.toJSONString(map));
|
||||
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
||||
} catch (Exception e) {
|
||||
logger.error("平台请求令牌接口 异常", e);
|
||||
return CommonResult.failed("获取token发生异常");
|
||||
}
|
||||
}
|
||||
// @PostMapping("/query_token")
|
||||
// public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
|
||||
// logger.info("平台请求令牌 params:{}", JSON.toJSONString(dto));
|
||||
// try {
|
||||
// Map<String, String> map = platformLogic.queryToken(dto);
|
||||
// logger.info("平台请求令牌 result:{}", JSON.toJSONString(map));
|
||||
// return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
|
||||
// } catch (Exception e) {
|
||||
// logger.error("平台请求令牌接口 异常", e);
|
||||
// return CommonResult.failed("获取token发生异常");
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
@@ -69,7 +63,6 @@ public class ThirdPartyBaseController extends BaseController {
|
||||
// 解密
|
||||
String operatorId = StringUtils.isNotBlank(dto.getOperatorID()) ? dto.getOperatorID() : dto.getPlatformID();
|
||||
// 通过operatorId 查出 operatorSecret
|
||||
// ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId);
|
||||
ThirdPartySecretInfoVO secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId);
|
||||
if (secretInfoVO == null) {
|
||||
throw new BusinessException("1", "无此对接平台");
|
||||
|
||||
@@ -418,10 +418,10 @@ public class LianLianController extends ThirdPartyBaseController {
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
// if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// // 校验失败
|
||||
// return CommonResult.failed("令牌校验错误");
|
||||
// }
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
}
|
||||
|
||||
// 校验签名
|
||||
// Map<String, String> resultMap = lianLianService.checkoutSign(dto);
|
||||
@@ -434,24 +434,9 @@ public class LianLianController extends ThirdPartyBaseController {
|
||||
// String dataSecret = resultMap.get("DataSecret");
|
||||
// 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.setOperatorId(dto.getOperatorID());
|
||||
Map<String, String> map = lianLianService.queryStartCharge(queryStartChargeDTO);
|
||||
|
||||
return CommonResult.success(0, "请求启动充电成功!", map.get("Data"), map.get("Sig"));
|
||||
|
||||
Reference in New Issue
Block a user