新增 青海平台推送充电订单接口

This commit is contained in:
Lemon
2024-04-18 10:43:59 +08:00
parent d34961e46d
commit c76cbf3c07
7 changed files with 350 additions and 0 deletions

View File

@@ -0,0 +1,191 @@
package com.jsowell.thirdparty.platform.common;
import com.alibaba.fastjson2.annotation.JSONField;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* 充电订单明细
*
* @author Lemon
* @Date 2024/4/18 8:44:07
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ChargeOrderInfo {
/**
* 运营平台ID
*/
@JSONField(name = "OperatorID")
private String operatorId;
/**
* 设备产权所属单位ID
*/
@JSONField(name = "EquipmentOwnerID")
private String equipmentOwnerId;
/**
* 充电站ID
*/
@JSONField(name = "StationID")
private String stationId;
/**
* 设备编码
*/
@JSONField(name = "EquipmentID")
private String equipmentId;
/**
* 充电设备接口编码
*/
@JSONField(name = "ConnectorID")
private String connectorId;
/**
* 充电订单号
*/
@JSONField(name = "StartChargeSeq")
private String startChargeSeq;
/**
* 换电订单编号
*/
@JSONField(name = "SwapOrderID")
private Integer swapOrderId;
/**
* 设备分类
* 1车辆充电设备
* 2换电站内的电池箱充电设备
*/
@JSONField(name = "EquipmentClassification")
private String equipmentClassification;
/**
* 充电开始SOC
*/
@JSONField(name = "StartSoc")
private BigDecimal startSoc;
/**
* 充电结束SOC
*/
@JSONField(name = "EndSoc")
private BigDecimal endSoc;
/**
* 电池箱编码
*/
@JSONField(name = "BatteryPackID")
private String batteryPackId;
/**
* 是否有调仓
*/
@JSONField(name = "BatteryCabinChange")
private Integer batteryCabinChange;
/**
* 本次充电消费总金额
* 保留小数点后 2 位
*
*/
@JSONField(name = "TotalMoney")
private BigDecimal totalMoney;
/**
* 本次充电电费总金额
* 保留小数点后 2 位
*/
@JSONField(name = "TotalElecMoney")
private BigDecimal totalElecMoney;
/**
* 本次充电服务费金额
* 保留小数点后 2 位
*/
@JSONField(name = "TotalSeviceMoney")
private BigDecimal totalSeviceMoney;
/**
* 本次充电电量
* 保留小数点后 2 位
*/
@JSONField(name = "TotalPower")
private BigDecimal totalPower;
/**
* 本次充电开始时间
* 格式“yyyy-MM-dd HH:mm:ss”
*/
@JSONField(name = "StartTime")
private String startTime;
/**
* 本次充电结束时间
* 格式“yyyy-MM-dd HH:mm:ss”
*/
@JSONField(name = "EndTime")
private String endTime;
/**
* 支付金额
* 保留小数点后 2 位
*/
@JSONField(name = "PaymentAmount")
private BigDecimal paymentAmount;
/**
* 支付时间
* 格式“yyyy-MM-dd HH:mm:ss”
*/
@JSONField(name = "PayTime")
private String payTime;
/**
* 支付方式
* 1支付宝
* 2微信支付
* 3交通卡
* 4预充卡
* 5银联
* 6其他自定义
*/
@JSONField(name = "PayWay")
private Integer payWay;
/**
* 充电结束原因
* 0:用户手动停止充电
* 1:客户归属地运营商平台停止充电
* 2:BMS 停止充电
* 3:充电机设备故障
* 4:连接器断开
* 5-99自定义
*/
@JSONField(name = "StopReason")
private Integer stopReason;
/**
* 电表总起值
* 小数点后 3 位
*/
@JSONField(name = "StartMeterNum")
private BigDecimal startMeterNum;
/**
* 电表总止值
* 小数点后 3 位
*/
@JSONField(name = "EndMeterNum")
private BigDecimal endMeterNum;
}

View File

@@ -11,6 +11,7 @@ import com.jsowell.common.enums.thirdparty.BusinessInformationExchangeEnum;
import com.jsowell.common.enums.thirdparty.ThirdPartyOperatorIdEnum;
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.enums.ykc.OrderStatusEnum;
import com.jsowell.common.enums.ykc.PayModeEnum;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.DateUtils;
@@ -27,6 +28,7 @@ import com.jsowell.pile.thirdparty.ZDLStationInfo;
import com.jsowell.pile.vo.base.ThirdPartyStationInfoVO;
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
import com.jsowell.pile.vo.uniapp.OrderVO;
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
import com.jsowell.pile.vo.web.PileMerchantInfoVO;
import com.jsowell.pile.vo.web.PileStationVO;
@@ -34,6 +36,7 @@ import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO;
import com.jsowell.thirdparty.lianlian.domain.ConnectorStatusInfo;
import com.jsowell.thirdparty.lianlian.vo.QueryChargingStatusVO;
import com.jsowell.thirdparty.platform.ThirdPartyPlatformService;
import com.jsowell.thirdparty.platform.common.ChargeOrderInfo;
import com.jsowell.thirdparty.platform.common.ConnectorChargeStatusInfo;
import com.jsowell.thirdparty.platform.common.SupStationPowerInfo;
import com.jsowell.thirdparty.platform.hainan.domain.HNStationInfo;
@@ -475,6 +478,86 @@ public class QingHaiPlatformServiceImpl implements ThirdPartyPlatformService {
return resultMap;
}
/**
* 推送充电订单信息 notification_charge_order_info
* @param orderCode 订单编号
* @return
*/
@Override
public String notificationChargeOrderInfo(String orderCode) {
// 通过订单号查询订单信息
OrderVO orderVO = orderBasicInfoService.getChargeOrderInfoByOrderCode(orderCode);
BigDecimal startSoc = orderVO.getStartSoc() == null ? BigDecimal.ZERO : new BigDecimal(orderVO.getStartSoc());
BigDecimal endSoc = orderVO.getEndSoc() == null ? BigDecimal.ZERO : new BigDecimal(orderVO.getEndSoc());
ChargeOrderInfo chargeOrderInfo = ChargeOrderInfo.builder()
.operatorId(Constants.OPERATORID_JIANG_SU)
// .equipmentId()
.stationId(orderVO.getStationId())
.equipmentId(orderVO.getPileSn())
.connectorId(orderVO.getPileConnectorCode())
.startChargeSeq(orderVO.getOrderCode())
.startSoc(startSoc)
.endSoc(endSoc)
.totalMoney(orderVO.getOrderAmount())
.totalElecMoney(orderVO.getTotalElectricityAmount())
.totalSeviceMoney(orderVO.getTotalServiceAmount())
.totalPower(new BigDecimal(orderVO.getTotalPower()))
.startTime(orderVO.getStartTime())
.endTime(orderVO.getEndTime())
.paymentAmount(orderVO.getPayAmount())
.payTime(orderVO.getPayTime())
// .payWay(orderVO.getPayMode())
.stopReason(Constants.two) // 2-BMS 停止充电
.startMeterNum(BigDecimal.ZERO) // 电表起止值(暂时给0)
.endMeterNum(BigDecimal.ZERO)
.build();
// 设备产权所属单位ID
String organizationCode = orderVO.getOrganizationCode();
if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) {
String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1);
chargeOrderInfo.setEquipmentOwnerId(equipmentOwnerId);
} else {
chargeOrderInfo.setEquipmentOwnerId(Constants.OPERATORID_JIANG_SU);
}
// 支付方式
String payMode = orderVO.getPayMode();
if (StringUtils.equals("4", payMode)) {
// 微信支付
chargeOrderInfo.setPayWay(2);
}else {
chargeOrderInfo.setPayWay(6);
}
// 获取推送配置密钥信息
ThirdPartyStationRelationVO settingInfo = getQingHaiSettingInfo();
if (settingInfo == null) {
return null;
}
String operatorId = settingInfo.getOperatorId();
String operatorSecret = settingInfo.getOperatorSecret();
String signSecret = settingInfo.getSignSecret();
String dataSecret = settingInfo.getDataSecret();
String dataSecretIv = settingInfo.getDataSecretIv();
String urlAddress = settingInfo.getUrlAddress();
String url = urlAddress + "notification_charge_order_info";
// 获取令牌
String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret);
if (StringUtils.isBlank(token)) {
return null;
}
// 封装参数
JSONObject jsonObject = new JSONObject();
jsonObject.put("ChargeOrderInfo", chargeOrderInfo);
String jsonString = JSON.toJSONString(jsonObject);
// 发送请求
String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret);
return result;
}
// 获取青海平台配置密钥信息
private ThirdPartyStationRelationVO getQingHaiSettingInfo() {