mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-08 20:10:16 +08:00
update 联联接口
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -19,9 +19,11 @@ import com.jsowell.common.util.id.IdUtils;
|
||||
import com.jsowell.netty.factory.YKCOperateFactory;
|
||||
import com.jsowell.pile.domain.OrderBasicInfo;
|
||||
import com.jsowell.pile.domain.PileAuthCard;
|
||||
import com.jsowell.pile.domain.ThirdPartySettingInfo;
|
||||
import com.jsowell.pile.service.IOrderBasicInfoService;
|
||||
import com.jsowell.pile.service.IPileAuthCardService;
|
||||
import com.jsowell.pile.service.IPileMsgRecordService;
|
||||
import com.jsowell.pile.service.IThirdPartySettingInfoService;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -63,6 +65,9 @@ public class TransactionRecordsRequestHandler extends AbstractHandler {
|
||||
@Autowired
|
||||
private IPileAuthCardService pileAuthCardService;
|
||||
|
||||
@Autowired
|
||||
private IThirdPartySettingInfoService thirdPartySettingInfoService;
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 获取消息体
|
||||
String msg = "000000000000000000000000000000008823000000030601a08c2e0d0404170000380d0404170000000000000000000000000000000000000000000000000000000000000000400d0300ee250000ee250000c84b000000000000000000000000000000000000e0bb040000cee1040000ee250000ee250000c84b00000000000000000000000000000000000000010000380d04041745a511101970000000";
|
||||
@@ -604,9 +609,14 @@ public class TransactionRecordsRequestHandler extends AbstractHandler {
|
||||
// 结算订单操作
|
||||
try {
|
||||
orderBasicInfoService.settleOrder(data, orderBasicInfo);
|
||||
// TODO 推送联联平台 订单信息推送接口
|
||||
|
||||
// 查询该站点是否推送联联平台
|
||||
|
||||
String stationId = orderBasicInfo.getStationId();
|
||||
ThirdPartySettingInfo infoByStationId = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(stationId));
|
||||
if (Objects.nonNull(infoByStationId)) {
|
||||
// TODO 推送联联平台 订单信息推送接口
|
||||
|
||||
}
|
||||
// 调用相关接口
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jsowell.pile.dto;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -48,4 +49,7 @@ public class PushOrderSettlementDTO {
|
||||
*/
|
||||
@JSONField(name = "SettlementMoney")
|
||||
private BigDecimal settlementMoney;
|
||||
|
||||
@JsonProperty(value = "OperatorID")
|
||||
private String OperatorId;
|
||||
}
|
||||
|
||||
@@ -127,11 +127,11 @@ public interface LianLianService {
|
||||
String pushChargeOrderInfo(String orderCode);
|
||||
|
||||
/**
|
||||
* 推送订单结算信息
|
||||
* 推送订单结算信息 (联联推给我们)
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
String pushOrderSettlementInfo(PushOrderSettlementDTO dto);
|
||||
Map<String, String> pushOrderSettlementInfo(PushOrderSettlementDTO dto);
|
||||
|
||||
/**
|
||||
* 查询订单结算信息
|
||||
|
||||
@@ -1163,17 +1163,17 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送订单结算信息
|
||||
* 推送订单结算信息 (联联推给我们)
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String pushOrderSettlementInfo(PushOrderSettlementDTO dto) {
|
||||
public Map<String, String> pushOrderSettlementInfo(PushOrderSettlementDTO dto) {
|
||||
String orderCode = dto.getStartChargeSeq();
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("StartChargeSeq", orderCode);
|
||||
json.put("ConnectorID", dto.getConnectorID());
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("StartChargeSeq", orderCode);
|
||||
map.put("ConnectorID", dto.getConnectorID());
|
||||
int confirmResult = Constants.one;
|
||||
// 根据订单号查询订单信息
|
||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||||
@@ -1181,17 +1181,32 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
if (orderInfo == null || orderDetail == null) {
|
||||
return null;
|
||||
}
|
||||
// 都不为空,根据传过来的数据进行修改数据库信息
|
||||
// 通过operatorID 查出 operatorSecret
|
||||
DockingPlatformConfig platformConfig = dockingPlatformConfigService.getInfoByOperatorId(dto.getOperatorId());
|
||||
if (platformConfig == null) {
|
||||
return null;
|
||||
}
|
||||
// orderInfo 和 orderDetail 都不为空,再根据传过来的数据进行修改数据库信息
|
||||
confirmResult = Constants.zero;
|
||||
orderDetail.setTotalUsedElectricity(dto.getTotalPower()); // 累计充电量
|
||||
orderDetail.setTotalOrderAmount(dto.getTotalMoney()); // 累计总金额
|
||||
|
||||
orderBasicInfoService.updateOrderDetail(orderDetail);
|
||||
|
||||
json.put("ConfirmResult", confirmResult);
|
||||
String jsonString = JSONObject.toJSONString(json);
|
||||
map.put("ConfirmResult", confirmResult);
|
||||
|
||||
return jsonString;
|
||||
Map<String, String> resultMap = Maps.newLinkedHashMap();
|
||||
// 加密数据
|
||||
byte[] encryptText = Cryptos.aesEncrypt(JSONObject.toJSONString(map).getBytes(),
|
||||
platformConfig.getOperatorSecret().getBytes(), platformConfig.getDataSecretIv().getBytes());
|
||||
String encryptData = Encodes.encodeBase64(encryptText);
|
||||
|
||||
resultMap.put("Data", encryptData);
|
||||
// 生成sig
|
||||
String resultSign = GBSignUtils.sign(resultMap, platformConfig.getOperatorSecret());
|
||||
resultMap.put("Sig", resultSign);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -112,8 +112,7 @@
|
||||
:src="require('@/assets/images/yue.png')"
|
||||
></el-image>
|
||||
</div>
|
||||
<div class="progress"></div></div
|
||||
>
|
||||
<div class="progress"></div></div>
|
||||
<!-- <div class="box">-->
|
||||
<!-- <div>总服务费金额</div>-->
|
||||
<!-- <div class="box-text">-->
|
||||
|
||||
Reference in New Issue
Block a user