update 联联接口

This commit is contained in:
Lemon
2023-06-02 11:37:30 +08:00
parent 4e6ee93eb0
commit 91847a9805
6 changed files with 83 additions and 15 deletions

View File

@@ -495,6 +495,46 @@ public class LianLianController extends BaseController {
}
}
/**
* 推送订单结算信息 (联联推给我们)
* @param request
* @param dto
* @return
*/
@PostMapping("/v1/notification_order_settlement_info")
public CommonResult<?> notification_order_settlement_info(HttpServletRequest request, @RequestBody CommonParamsDTO dto) {
logger.info("联联平台推送订单结算信息 params:{}", JSONObject.toJSONString(dto));
try {
// 校验令牌
String token = request.getHeader("Authorization");
if (!JWTUtils.checkThirdPartyToken(token)) {
// 校验失败
return CommonResult.failed("令牌校验错误");
}
// 校验签名
Map<String, String> resultMap = lianLianService.checkoutSign(dto);
if (resultMap == null) {
// 签名错误
return CommonResult.failed("签名校验错误");
}
String operatorSecret = resultMap.get("OperatorSecret");
String dataString = resultMap.get("Data");
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), operatorSecret.getBytes(), operatorSecret.getBytes());
String dataStr = new String(plainText, "UTF-8");
// 转换成相应对象
PushOrderSettlementDTO pushOrderSettlementDTO = JSONObject.parseObject(dataStr, PushOrderSettlementDTO.class);
pushOrderSettlementDTO.setOperatorId(dto.getOperatorID());
Map<String, String> map = lianLianService.pushOrderSettlementInfo(pushOrderSettlementDTO);
return CommonResult.success(0, "推送订单结算信息成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.info("联联平台推送订单结算信息 error:", e);
e.printStackTrace();
}
return CommonResult.failed("推送订单结算信息发生异常");
}
/**
* 联联平台查询充电站信息
* http://localhost:8080/LianLian/query_stations_info