mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-13 11:49:49 +08:00
update 对接第三方平台
This commit is contained in:
@@ -10,8 +10,7 @@ import com.jsowell.common.response.RestApiResponse;
|
|||||||
import com.jsowell.common.util.JWTUtils;
|
import com.jsowell.common.util.JWTUtils;
|
||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
|
||||||
import com.jsowell.pile.dto.PushInfoParamDTO;
|
import com.jsowell.pile.dto.*;
|
||||||
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
|
||||||
import com.jsowell.pile.service.ThirdPartyPlatformConfigService;
|
import com.jsowell.pile.service.ThirdPartyPlatformConfigService;
|
||||||
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||||
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
import com.jsowell.thirdparty.lianlian.common.CommonResult;
|
||||||
@@ -356,50 +355,50 @@ public class LianLianController extends BaseController {
|
|||||||
* @param dto
|
* @param dto
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// @PostMapping("/v1/query_equip_auth")
|
@PostMapping("/v1/query_equip_auth")
|
||||||
// public CommonResult<?> query_equip_auth(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
public CommonResult<?> query_equip_auth(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||||
// logger.info("联联平台请求设备认证 param:{}", JSON.toJSONString(dto));
|
logger.info("联联平台请求设备认证 param:{}", JSON.toJSONString(dto));
|
||||||
// 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);
|
||||||
// // if (resultMap == null) {
|
// if (resultMap == null) {
|
||||||
// // // 签名错误
|
// // 签名错误
|
||||||
// // return CommonResult.failed("签名校验错误");
|
// return CommonResult.failed("签名校验错误");
|
||||||
// // }
|
|
||||||
// // String operatorSecret = resultMap.get("OperatorSecret");
|
|
||||||
// // String dataString = resultMap.get("Data");
|
|
||||||
// // 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);
|
|
||||||
// // 转换成相应对象
|
|
||||||
// QueryEquipmentDTO queryEquipmentDTO = JSONObject.parseObject(dataStr, QueryEquipmentDTO.class);
|
|
||||||
// queryEquipmentDTO.setOperatorID(dto.getOperatorID());
|
|
||||||
// // Map<String, String> map = lianLianService.query_equip_auth(queryEquipmentDTO);
|
|
||||||
// Map<String, String> map = lianLianService.queryEquipAuth(queryEquipmentDTO);
|
|
||||||
//
|
|
||||||
// return CommonResult.success(0, "请求设备认证成功!", map.get("Data"), map.get("Sig"));
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// logger.info("联联平台请求设备认证 error:", e);
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// return CommonResult.failed("请求设备认证发生异常");
|
|
||||||
// }
|
// }
|
||||||
|
// String operatorSecret = resultMap.get("OperatorSecret");
|
||||||
|
// String dataString = resultMap.get("Data");
|
||||||
|
// 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);
|
||||||
|
// 转换成相应对象
|
||||||
|
QueryEquipmentDTO queryEquipmentDTO = JSONObject.parseObject(dataStr, QueryEquipmentDTO.class);
|
||||||
|
queryEquipmentDTO.setOperatorID(dto.getOperatorID());
|
||||||
|
// Map<String, String> map = lianLianService.query_equip_auth(queryEquipmentDTO);
|
||||||
|
Map<String, String> map = lianLianService.queryEquipAuth(queryEquipmentDTO);
|
||||||
|
|
||||||
|
return CommonResult.success(0, "请求设备认证成功!", map.get("Data"), map.get("Sig"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.info("联联平台请求设备认证 error:", e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return CommonResult.failed("请求设备认证发生异常");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求启动充电
|
* 请求启动充电
|
||||||
@@ -407,49 +406,49 @@ public class LianLianController extends BaseController {
|
|||||||
* @param dto
|
* @param dto
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// @PostMapping("/v1/query_start_charge")
|
@PostMapping("/v1/query_start_charge")
|
||||||
// public CommonResult<?> query_start_charge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
public CommonResult<?> query_start_charge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||||
// logger.info("联联平台请求启动充电 params :{}", JSON.toJSONString(dto));
|
logger.info("联联平台请求启动充电 params :{}", JSON.toJSONString(dto));
|
||||||
// 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);
|
||||||
// // if (resultMap == null) {
|
// if (resultMap == null) {
|
||||||
// // // 签名错误
|
// // 签名错误
|
||||||
// // return CommonResult.failed("签名校验错误");
|
// return CommonResult.failed("签名校验错误");
|
||||||
// // }
|
|
||||||
// // String operatorSecret = resultMap.get("OperatorSecret");
|
|
||||||
// // String dataString = resultMap.get("Data");
|
|
||||||
// // 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);
|
|
||||||
// Map<String, String> map = lianLianService.queryStartCharge(queryStartChargeDTO);
|
|
||||||
//
|
|
||||||
// return CommonResult.success(0, "请求启动充电成功!", map.get("Data"), map.get("Sig"));
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// logger.error("联联平台请求启动充电 error", e);
|
|
||||||
// }
|
|
||||||
// return CommonResult.failed("请求启动充电发生异常");
|
|
||||||
// }
|
// }
|
||||||
|
// String operatorSecret = resultMap.get("OperatorSecret");
|
||||||
|
// String dataString = resultMap.get("Data");
|
||||||
|
// 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);
|
||||||
|
Map<String, String> map = lianLianService.queryStartCharge(queryStartChargeDTO);
|
||||||
|
|
||||||
|
return CommonResult.success(0, "请求启动充电成功!", map.get("Data"), map.get("Sig"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("联联平台请求启动充电 error", e);
|
||||||
|
}
|
||||||
|
return CommonResult.failed("请求启动充电发生异常");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询充电状态
|
* 查询充电状态
|
||||||
@@ -457,49 +456,49 @@ public class LianLianController extends BaseController {
|
|||||||
* @param dto
|
* @param dto
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// @PostMapping("/v1/query_equip_charge_status")
|
@PostMapping("/v1/query_equip_charge_status")
|
||||||
// public CommonResult<?> query_equip_charge_status(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
public CommonResult<?> query_equip_charge_status(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||||
// logger.info("联联平台查询充电状态 params :{}", JSON.toJSONString(dto));
|
logger.info("联联平台查询充电状态 params :{}", JSON.toJSONString(dto));
|
||||||
// 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);
|
||||||
// // if (resultMap == null) {
|
// if (resultMap == null) {
|
||||||
// // // 签名错误
|
// // 签名错误
|
||||||
// // return CommonResult.failed("签名校验错误");
|
// return CommonResult.failed("签名校验错误");
|
||||||
// // }
|
|
||||||
// // String operatorSecret = resultMap.get("OperatorSecret");
|
|
||||||
// // String dataString = resultMap.get("Data");
|
|
||||||
// // 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);
|
|
||||||
// // 转换成相应对象
|
|
||||||
// QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = JSONObject.parseObject(dataStr, QueryEquipChargeStatusDTO.class);
|
|
||||||
// queryEquipChargeStatusDTO.setOperatorID(dto.getOperatorID());
|
|
||||||
// // Map<String, String> map = lianLianService.query_equip_charge_status(queryEquipChargeStatusDTO);
|
|
||||||
// Map<String, String> map = lianLianService.queryEquipChargeStatus(queryEquipChargeStatusDTO);
|
|
||||||
//
|
|
||||||
// return CommonResult.success(0, "查询充电状态成功!", map.get("Data"), map.get("Sig"));
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// logger.error("联联平台查询充电状态 error", e);
|
|
||||||
// }
|
|
||||||
// return CommonResult.failed("联联平台查询充电状态发生异常");
|
|
||||||
// }
|
// }
|
||||||
|
// String operatorSecret = resultMap.get("OperatorSecret");
|
||||||
|
// String dataString = resultMap.get("Data");
|
||||||
|
// 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);
|
||||||
|
// 转换成相应对象
|
||||||
|
QueryEquipChargeStatusDTO queryEquipChargeStatusDTO = JSONObject.parseObject(dataStr, QueryEquipChargeStatusDTO.class);
|
||||||
|
queryEquipChargeStatusDTO.setOperatorID(dto.getOperatorID());
|
||||||
|
// Map<String, String> map = lianLianService.query_equip_charge_status(queryEquipChargeStatusDTO);
|
||||||
|
Map<String, String> map = lianLianService.queryEquipChargeStatus(queryEquipChargeStatusDTO);
|
||||||
|
|
||||||
|
return CommonResult.success(0, "查询充电状态成功!", map.get("Data"), map.get("Sig"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("联联平台查询充电状态 error", e);
|
||||||
|
}
|
||||||
|
return CommonResult.failed("联联平台查询充电状态发生异常");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求停止充电
|
* 请求停止充电
|
||||||
@@ -507,49 +506,49 @@ public class LianLianController extends BaseController {
|
|||||||
* @param dto
|
* @param dto
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// @PostMapping("/v1/query_stop_charge")
|
@PostMapping("/v1/query_stop_charge")
|
||||||
// public CommonResult<?> query_stop_charge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
public CommonResult<?> query_stop_charge(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||||
// logger.info("联联平台请求停止充电 params :{}", JSON.toJSONString(dto));
|
logger.info("联联平台请求停止充电 params :{}", JSON.toJSONString(dto));
|
||||||
// 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);
|
||||||
// // if (resultMap == null) {
|
// if (resultMap == null) {
|
||||||
// // // 签名错误
|
// // 签名错误
|
||||||
// // return CommonResult.failed("签名校验错误");
|
// return CommonResult.failed("签名校验错误");
|
||||||
// // }
|
|
||||||
// // String operatorSecret = resultMap.get("OperatorSecret");
|
|
||||||
// // String dataString = resultMap.get("Data");
|
|
||||||
// // 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_stop_charge(queryStartChargeDTO);
|
|
||||||
// Map<String, String> map = lianLianService.queryStopCharge(queryStartChargeDTO);
|
|
||||||
//
|
|
||||||
// return CommonResult.success(0, "请求停止充电成功!", map.get("Data"), map.get("Sig"));
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// logger.error("联联平台请求停止充电 error", e);
|
|
||||||
// }
|
|
||||||
// return CommonResult.failed("联联平台请求停止充电发生异常");
|
|
||||||
// }
|
// }
|
||||||
|
// String operatorSecret = resultMap.get("OperatorSecret");
|
||||||
|
// String dataString = resultMap.get("Data");
|
||||||
|
// 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_stop_charge(queryStartChargeDTO);
|
||||||
|
Map<String, String> map = lianLianService.queryStopCharge(queryStartChargeDTO);
|
||||||
|
|
||||||
|
return CommonResult.success(0, "请求停止充电成功!", map.get("Data"), map.get("Sig"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("联联平台请求停止充电 error", e);
|
||||||
|
}
|
||||||
|
return CommonResult.failed("联联平台请求停止充电发生异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -559,62 +558,61 @@ public class LianLianController extends BaseController {
|
|||||||
* @param dto
|
* @param dto
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
// @PostMapping("/v1/notification_order_settlement_info")
|
@PostMapping("/v1/notification_order_settlement_info")
|
||||||
// public CommonResult<?> notification_order_settlement_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
public CommonResult<?> notification_order_settlement_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
|
||||||
// logger.info("联联平台推送订单结算信息 params:{}", JSON.toJSONString(dto));
|
logger.info("联联平台推送订单结算信息 params:{}", JSON.toJSONString(dto));
|
||||||
// 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);
|
||||||
// // if (resultMap == null) {
|
// if (resultMap == null) {
|
||||||
// // // 签名错误
|
// // 签名错误
|
||||||
// // return CommonResult.failed("签名校验错误");
|
// return CommonResult.failed("签名校验错误");
|
||||||
// // }
|
|
||||||
// // String operatorSecret = resultMap.get("OperatorSecret");
|
|
||||||
// // String dataString = resultMap.get("Data");
|
|
||||||
// // 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);
|
|
||||||
// // 转换成相应对象
|
|
||||||
// PushOrderSettlementDTO pushOrderSettlementDTO = JSONObject.parseObject(dataStr, PushOrderSettlementDTO.class);
|
|
||||||
// pushOrderSettlementDTO.setOperatorId(dto.getOperatorID());
|
|
||||||
// Map<String, String> map = lianLianService.pushOrderSettlementInfo(pushOrderSettlementDTO);
|
|
||||||
// // Map<String, String> map = lianLianService.notificationOrderInfo(pushOrderSettlementDTO);
|
|
||||||
//
|
|
||||||
// return CommonResult.success(0, "推送订单结算信息成功!", map.get("Data"), map.get("Sig"));
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// logger.info("联联平台推送订单结算信息 error:", e);
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// return CommonResult.failed("推送订单结算信息发生异常");
|
|
||||||
// }
|
// }
|
||||||
|
// String operatorSecret = resultMap.get("OperatorSecret");
|
||||||
|
// String dataString = resultMap.get("Data");
|
||||||
|
// String dataSecret = resultMap.get("DataSecret");
|
||||||
|
// String dataSecretIV = resultMap.get("DataSecretIV");
|
||||||
|
|
||||||
// @GetMapping("/pushStationFee/{stationId}")
|
// 查询配置信息
|
||||||
// public RestApiResponse<?> pushStationFee(@PathVariable("stationId") String stationId) {
|
ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorID());
|
||||||
// RestApiResponse<?> response = null;
|
String operatorSecret = platformConfig.getOperatorSecret();
|
||||||
// try {
|
String dataString = dto.getData();
|
||||||
// // String result = lianLianService.pushStationFee(stationId);
|
String dataSecret = platformConfig.getDataSecret();
|
||||||
// String result = lianLianService.notificationStationFee(stationId);
|
String dataSecretIV = platformConfig.getDataSecretIv();
|
||||||
// response = new RestApiResponse<>(result);
|
|
||||||
// } catch (Exception e) {
|
// 解密data
|
||||||
// e.printStackTrace();
|
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||||
// }
|
String dataStr = new String(plainText, StandardCharsets.UTF_8);
|
||||||
// return response;
|
// 转换成相应对象
|
||||||
// }
|
PushOrderSettlementDTO pushOrderSettlementDTO = JSONObject.parseObject(dataStr, PushOrderSettlementDTO.class);
|
||||||
|
pushOrderSettlementDTO.setOperatorId(dto.getOperatorID());
|
||||||
|
Map<String, String> map = lianLianService.notificationOrderSettlementInfo(pushOrderSettlementDTO);
|
||||||
|
|
||||||
|
return CommonResult.success(0, "推送订单结算信息成功!", map.get("Data"), map.get("Sig"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.info("联联平台推送订单结算信息 error:", e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return CommonResult.failed("推送订单结算信息发生异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/pushStationFee/{stationId}")
|
||||||
|
public RestApiResponse<?> pushStationFee(@PathVariable("stationId") String stationId) {
|
||||||
|
RestApiResponse<?> response = null;
|
||||||
|
try {
|
||||||
|
// String result = lianLianService.pushStationFee(stationId);
|
||||||
|
String result = lianLianService.notificationStationFee(stationId);
|
||||||
|
response = new RestApiResponse<>(result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -334,6 +334,13 @@ public interface ThirdPartyPlatformService {
|
|||||||
throw new UnsupportedOperationException("This method is not yet implemented");
|
throw new UnsupportedOperationException("This method is not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 推送订单结算信息 notification_order_settlement_info
|
||||||
|
*/
|
||||||
|
default Map<String, String> notificationOrderSettlementInfo(PushOrderSettlementDTO order) {
|
||||||
|
throw new UnsupportedOperationException("This method is not yet implemented");
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------- 以下是公用方法 --------------------------------------- //
|
// -------------------------------------- 以下是公用方法 --------------------------------------- //
|
||||||
/**
|
/**
|
||||||
* 从联联平台获取令牌
|
* 从联联平台获取令牌
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.jsowell.common.util.JWTUtils;
|
|||||||
import com.jsowell.common.util.PageUtils;
|
import com.jsowell.common.util.PageUtils;
|
||||||
import com.jsowell.common.util.StringUtils;
|
import com.jsowell.common.util.StringUtils;
|
||||||
import com.jsowell.pile.domain.*;
|
import com.jsowell.pile.domain.*;
|
||||||
|
import com.jsowell.pile.dto.PushOrderSettlementDTO;
|
||||||
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
import com.jsowell.pile.dto.QueryStationInfoDTO;
|
||||||
import com.jsowell.pile.service.*;
|
import com.jsowell.pile.service.*;
|
||||||
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||||
@@ -857,5 +858,42 @@ public class LianLianPlatformServiceImpl implements ThirdPartyPlatformService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Map<String, String> notificationOrderSettlementInfo(PushOrderSettlementDTO dto) {
|
||||||
|
String orderCode = dto.getStartChargeSeq();
|
||||||
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
|
map.put("StartChargeSeq", orderCode);
|
||||||
|
map.put("ConnectorID", dto.getConnectorID());
|
||||||
|
int confirmResult = Constants.one;
|
||||||
|
// 根据订单号查询订单信息
|
||||||
|
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||||||
|
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode);
|
||||||
|
if (orderInfo == null || orderDetail == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// 通过operatorID 查出 operatorSecret
|
||||||
|
ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
|
||||||
|
if (platformConfig == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// orderInfo 和 orderDetail 都不为空,再根据传过来的数据进行修改数据库信息
|
||||||
|
confirmResult = Constants.zero;
|
||||||
|
orderDetail.setTotalUsedElectricity(dto.getTotalPower()); // 累计充电量
|
||||||
|
orderDetail.setTotalOrderAmount(dto.getTotalMoney()); // 累计总金额
|
||||||
|
orderBasicInfoService.updateOrderDetail(orderDetail);
|
||||||
|
map.put("ConfirmResult", confirmResult);
|
||||||
|
|
||||||
|
Map<String, String> resultMap = Maps.newLinkedHashMap();
|
||||||
|
// 加密数据
|
||||||
|
String encrypt = Cryptos.encrypt(JSON.toJSONString(map), platformConfig.getDataSecret(), platformConfig.getDataSecretIv());
|
||||||
|
resultMap.put("Data", encrypt);
|
||||||
|
// 生成sig
|
||||||
|
String resultSign = GBSignUtils.sign(resultMap, platformConfig.getSignSecret());
|
||||||
|
resultMap.put("Sig", resultSign);
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user