mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
add 联联平台 推送订单信息接口
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.jsowell.thirdparty.domain;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -19,36 +20,43 @@ public class ChargeDetail {
|
||||
* 开始时间 Y
|
||||
* 格式“yyyy-MM-dd HH:mm:ss”
|
||||
*/
|
||||
private String chargingStartTime;
|
||||
@JSONField(name = "DetailStartTime")
|
||||
private String detailStartTime;
|
||||
|
||||
/**
|
||||
* 结束时间 Y
|
||||
* 格式“yyyy-MM-dd HH:mm:ss”
|
||||
*/
|
||||
private String chargingEndTime;
|
||||
@JSONField(name = "DetailEndTime")
|
||||
private String detailEndTime;
|
||||
|
||||
/**
|
||||
* 时段电价(小数点后4位) Y
|
||||
*/
|
||||
private BigDecimal electricityPrice;
|
||||
@JSONField(name = "ElecPrice")
|
||||
private BigDecimal elecPrice;
|
||||
|
||||
/**
|
||||
* 时段服务费价格(小数点后4位) Y
|
||||
*/
|
||||
private BigDecimal servicePrice;
|
||||
@JSONField(name = "SevicePrice")
|
||||
private BigDecimal sevicePrice;
|
||||
|
||||
/**
|
||||
* 时段充电量(单位:度,小数点后2位) Y
|
||||
*/
|
||||
private BigDecimal chargingDegree;
|
||||
@JSONField(name = "DetailPower")
|
||||
private BigDecimal detailPower;
|
||||
|
||||
/**
|
||||
* 时段电费(小数点后2位) Y
|
||||
*/
|
||||
private BigDecimal electricityAmount;
|
||||
@JSONField(name = "DetailElecMoney")
|
||||
private BigDecimal detailElecMoney;
|
||||
|
||||
/**
|
||||
* 时段服务费(小数点后2位) Y
|
||||
*/
|
||||
private BigDecimal serviceAmount;
|
||||
@JSONField(name = "DetailSeviceMoney")
|
||||
private BigDecimal detailSeviceMoney;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.jsowell.thirdparty.domain;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -20,37 +21,43 @@ public class OrderInfo {
|
||||
* 对接平台ID Y
|
||||
* 组织机构代码
|
||||
*/
|
||||
private String organizationCode;
|
||||
@JSONField(name = "OperatorID")
|
||||
private String operatorID;
|
||||
|
||||
/**
|
||||
* 设备所属运营商ID Y
|
||||
* 设备所属运营商组织机构代码
|
||||
*/
|
||||
private String merchantId;
|
||||
@JSONField(name = "EquipmentOwnerID")
|
||||
private String equipmentOwnerID;
|
||||
|
||||
/**
|
||||
* 充电站ID Y
|
||||
* 对接平台自定义的唯一编码
|
||||
*/
|
||||
private String stationId;
|
||||
@JSONField(name = "StationID")
|
||||
private String stationID;
|
||||
|
||||
/**
|
||||
* 设备编码 Y
|
||||
* 设备唯一编码,对同一对接平台,保证唯一
|
||||
*/
|
||||
private String pileSn;
|
||||
@JSONField(name = "EquipmentID")
|
||||
private String equipmentID;
|
||||
|
||||
/**
|
||||
* 充电设备接口编码 Y
|
||||
* 充电设备接口编码,同一对接平台内唯一
|
||||
*/
|
||||
private String pileConnectorCode;
|
||||
@JSONField(name = "ConnectorID")
|
||||
private String connectorID;
|
||||
|
||||
/**
|
||||
* 充电订单号 Y
|
||||
* 对接平台系统订单编号
|
||||
*/
|
||||
private String orderCode;
|
||||
@JSONField(name = "StartChargeSeq")
|
||||
private String startChargeSeq;
|
||||
|
||||
/**
|
||||
* 用户发起充电类型 Y
|
||||
@@ -59,55 +66,65 @@ public class OrderInfo {
|
||||
* 3:互联互通用户
|
||||
* 10:其他
|
||||
*/
|
||||
private Integer userType;
|
||||
@JSONField(name = "UserChargeType")
|
||||
private Integer userChargeType;
|
||||
|
||||
/**
|
||||
* 用户手机号 N
|
||||
* 若用户发起充电类型为 APP,用户手机号必填
|
||||
*/
|
||||
private String userPhoneNumber;
|
||||
@JSONField(name = "MobileNumber")
|
||||
private String mobileNumber;
|
||||
|
||||
/**
|
||||
* 本次充电消费总金额(单位:元,保留小数点后2位) Y
|
||||
*/
|
||||
private BigDecimal orderAmount;
|
||||
@JSONField(name = "Money")
|
||||
private BigDecimal money;
|
||||
|
||||
/**
|
||||
* 本次充电电费总金额(单位:元,保留小数点后2位) Y
|
||||
*/
|
||||
private BigDecimal electricityAmount;
|
||||
@JSONField(name = "ElectMoney")
|
||||
private BigDecimal electMoney;
|
||||
|
||||
/**
|
||||
* 本次充电服务费金额(单位:元,保留小数点后2位) Y
|
||||
*/
|
||||
private BigDecimal serviceAmount;
|
||||
@JSONField(name = "ServiceMoney")
|
||||
private BigDecimal serviceMoney;
|
||||
|
||||
/**
|
||||
* 本次充电电量 Y
|
||||
* 单位kWh,精度0.01,保留小数点后2位
|
||||
*/
|
||||
private BigDecimal usedElectricity;
|
||||
@JSONField(name = "Elect")
|
||||
private BigDecimal elect;
|
||||
|
||||
/**
|
||||
* 本次充电开始时间 Y
|
||||
* 格式“yyyy-MM-dd HH:mm:ss”
|
||||
*/
|
||||
private String chargingStartTime;
|
||||
@JSONField(name = "StartTime")
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* 本次充电结束时间 Y
|
||||
* 格式“yyyy-MM-dd HH:mm:ss”
|
||||
*/
|
||||
private String chargingEndTime;
|
||||
@JSONField(name = "EndTime")
|
||||
private String endTime;
|
||||
|
||||
/**
|
||||
* 支付金额 Y
|
||||
*/
|
||||
private BigDecimal payAmount;
|
||||
@JSONField(name = "PaymentAmount")
|
||||
private BigDecimal paymentAmount;
|
||||
|
||||
/**
|
||||
* 支付时间 N
|
||||
*/
|
||||
@JSONField(name = "PayTime")
|
||||
private String payTime;
|
||||
|
||||
/**
|
||||
@@ -119,13 +136,15 @@ public class OrderInfo {
|
||||
* 5:银联
|
||||
* 6:其他自定义
|
||||
*/
|
||||
private Integer payMode;
|
||||
@JSONField(name = "PayChannel")
|
||||
private Integer payChannel;
|
||||
|
||||
/**
|
||||
* 优惠信息描述 N
|
||||
* 描述支付的相关优惠信息,如优惠券,折扣等
|
||||
*/
|
||||
private String discountDescribe;
|
||||
@JSONField(name = "DiscountInfo")
|
||||
private String discountInfo;
|
||||
|
||||
/**
|
||||
* 充电结束原因 Y
|
||||
@@ -136,15 +155,18 @@ public class OrderInfo {
|
||||
* 4:连接器断开
|
||||
* 5-99自定义
|
||||
*/
|
||||
@JSONField(name = "StopReason")
|
||||
private Integer stopReason;
|
||||
|
||||
/**
|
||||
* 时段数N,范围:0~32 N
|
||||
*/
|
||||
private Integer timePeriod;
|
||||
@JSONField(name = "SumPeriod")
|
||||
private Integer sumPeriod;
|
||||
|
||||
/**
|
||||
* 充电明细信息 Y
|
||||
*/
|
||||
@JSONField(name = "ChargeDetails")
|
||||
private List<ChargeDetail> chargeDetails;
|
||||
}
|
||||
|
||||
@@ -74,10 +74,11 @@ public interface LianLianService {
|
||||
|
||||
/**
|
||||
* 联联平台获取令牌
|
||||
* @param dto
|
||||
* @param operatorId
|
||||
* @param operatorSecret
|
||||
* @return
|
||||
*/
|
||||
String getToken(LianLianGetTokenDTO dto);
|
||||
String getToken(String operatorId, String operatorSecret);
|
||||
|
||||
/**
|
||||
* 推送联联平台 设备状态变化推送
|
||||
@@ -86,4 +87,11 @@ public interface LianLianService {
|
||||
* @return
|
||||
*/
|
||||
String pushConnectorStatus(String pileConnectorCode, String status);
|
||||
|
||||
/**
|
||||
* 推送订单信息
|
||||
* @param orderCode
|
||||
* @return
|
||||
*/
|
||||
String pushOrderInfo(String orderCode);
|
||||
}
|
||||
|
||||
@@ -9,11 +9,10 @@ import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
|
||||
import com.jsowell.common.enums.LianLianPileStatusEnum;
|
||||
import com.jsowell.common.enums.StationPaymentEnum;
|
||||
import com.jsowell.common.enums.ykc.OrderStatusEnum;
|
||||
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
|
||||
import com.jsowell.common.enums.ykc.PileStatusEnum;
|
||||
import com.jsowell.common.enums.lianlian.LianLianPileStatusEnum;
|
||||
import com.jsowell.common.enums.lianlian.PayChannelEnum;
|
||||
import com.jsowell.common.enums.lianlian.StationPaymentEnum;
|
||||
import com.jsowell.common.enums.ykc.*;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.*;
|
||||
import com.jsowell.common.util.lianlian.*;
|
||||
@@ -22,27 +21,14 @@ import com.jsowell.netty.command.ykc.StopChargingCommand;
|
||||
import com.jsowell.netty.service.yunkuaichong.YKCPushCommandService;
|
||||
import com.jsowell.pile.domain.*;
|
||||
import com.jsowell.pile.dto.*;
|
||||
import com.jsowell.pile.service.IOrderBasicInfoService;
|
||||
import com.jsowell.pile.service.IPileBasicInfoService;
|
||||
import com.jsowell.pile.service.IPileConnectorInfoService;
|
||||
import com.jsowell.pile.service.IPileMerchantInfoService;
|
||||
import com.jsowell.pile.service.IPileModelInfoService;
|
||||
import com.jsowell.pile.service.IPileStationInfoService;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.base.MerchantInfoVO;
|
||||
import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
|
||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.web.PileModelInfoVO;
|
||||
import com.jsowell.thirdparty.domain.ConnectorChargeStatusInfo;
|
||||
import com.jsowell.thirdparty.domain.ConnectorInfo;
|
||||
import com.jsowell.thirdparty.domain.ConnectorStatsInfo;
|
||||
import com.jsowell.thirdparty.domain.ConnectorStatusInfo;
|
||||
import com.jsowell.thirdparty.domain.EquipmentInfo;
|
||||
import com.jsowell.thirdparty.domain.EquipmentStatsInfo;
|
||||
import com.jsowell.thirdparty.domain.OperatorInfo;
|
||||
import com.jsowell.thirdparty.domain.StationInfo;
|
||||
import com.jsowell.thirdparty.domain.StationStatsInfo;
|
||||
import com.jsowell.thirdparty.domain.StationStatusInfo;
|
||||
import com.jsowell.thirdparty.domain.*;
|
||||
import com.jsowell.thirdparty.service.LianLianService;
|
||||
import com.jsowell.thirdparty.vo.*;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -83,6 +69,9 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
@Autowired
|
||||
private YKCPushCommandService ykcPushCommandService;
|
||||
|
||||
@Autowired
|
||||
private IPileBillingTemplateService pileBillingTemplateService;
|
||||
|
||||
@Override
|
||||
public void pushMerchantInfo(Long merchantId) {
|
||||
// 通过id查询运营商信息
|
||||
@@ -574,9 +563,9 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getToken(LianLianGetTokenDTO dto) {
|
||||
String operatorId = dto.getOperatorId();
|
||||
String operatorSecret = dto.getOperatorSecret();
|
||||
public String getToken(String operatorId, String operatorSecret) {
|
||||
// String operatorId = dto.getOperatorId();
|
||||
// String operatorSecret = dto.getOperatorSecret();
|
||||
String token = "";
|
||||
try {
|
||||
//测试用请求地址
|
||||
@@ -633,10 +622,7 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
String url = TEST_URL + "notification_stationStatus";
|
||||
|
||||
// 获取令牌
|
||||
LianLianGetTokenDTO dto = new LianLianGetTokenDTO();
|
||||
dto.setOperatorId(OPERATOR_ID);
|
||||
dto.setOperatorSecret(OPERATOR_SECRET);
|
||||
String token = getToken(dto);
|
||||
String token = getToken(OPERATOR_ID, OPERATOR_SECRET);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return null;
|
||||
}
|
||||
@@ -654,6 +640,124 @@ public class LianLianServiceImpl implements LianLianService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String pushOrderInfo(String orderCode) {
|
||||
List<ChargeDetail> chargeDetails = new ArrayList<>();
|
||||
// 根据订单号查询出信息
|
||||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||||
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode);
|
||||
|
||||
String url = TEST_URL + "notification_orderInfo";
|
||||
|
||||
// 拼装成联联平台所需格式对象
|
||||
OrderInfo orderInfo = OrderInfo.builder()
|
||||
.operatorID(OPERATOR_ID)
|
||||
.equipmentOwnerID(Constants.OPERATORID_LIANLIAN)
|
||||
.stationID(orderBasicInfo.getStationId())
|
||||
.equipmentID(orderBasicInfo.getPileSn())
|
||||
.connectorID(orderBasicInfo.getPileConnectorCode())
|
||||
.startChargeSeq(orderCode)
|
||||
.userChargeType(Constants.one)
|
||||
.money(new BigDecimal(String.valueOf(orderBasicInfo.getOrderAmount())).setScale(2, BigDecimal.ROUND_HALF_UP))
|
||||
.electMoney(new BigDecimal(String.valueOf(orderDetail.getTotalElectricityAmount())).setScale(2, BigDecimal.ROUND_HALF_UP))
|
||||
.serviceMoney(new BigDecimal(String.valueOf(orderDetail.getTotalServiceAmount())).setScale(2, BigDecimal.ROUND_HALF_UP))
|
||||
.elect(new BigDecimal(String.valueOf(orderDetail.getTotalUsedElectricity())).setScale(2, BigDecimal.ROUND_HALF_UP))
|
||||
.startTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeStartTime()))
|
||||
.endTime(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderBasicInfo.getChargeEndTime()))
|
||||
.paymentAmount(orderBasicInfo.getPayAmount())
|
||||
// .payChannel()
|
||||
.stopReason(0)
|
||||
// .chargeDetails()
|
||||
.build();
|
||||
// 支付方式
|
||||
if (StringUtils.equals(orderBasicInfo.getPayMode(), OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())) {
|
||||
// 微信支付
|
||||
orderInfo.setPayChannel(Integer.valueOf(PayChannelEnum.WEXIN_PAY.getCode()));
|
||||
}else if (StringUtils.equals(orderBasicInfo.getPayMode(), OrderPayModeEnum.PAYMENT_OF_ALIPAY.getValue())) {
|
||||
// 支付宝支付
|
||||
orderInfo.setPayChannel(Integer.valueOf(PayChannelEnum.ALI_PAY.getCode()));
|
||||
}else {
|
||||
// 其他
|
||||
orderInfo.setPayChannel(Integer.valueOf(PayChannelEnum.OTHER.getCode()));
|
||||
}
|
||||
// 订单详情
|
||||
ChargeDetail detail;
|
||||
|
||||
List<BillingPriceVO> billingList = pileBillingTemplateService.queryBillingPrice(orderBasicInfo.getStationId());
|
||||
// 先将list按照 尖、峰、平、谷 时段排序
|
||||
// List<BillingPriceVO> collect = billingList.stream().sorted(Comparator.comparing(BillingPriceVO::getTimeType)).collect(Collectors.toList());
|
||||
// 再循环该list,拼装对应的充电价格、费率
|
||||
for (BillingPriceVO billingPriceVO : billingList) {
|
||||
detail = new ChargeDetail();
|
||||
if (StringUtils.equals(billingPriceVO.getTimeType(), "1")) {
|
||||
// 尖时段
|
||||
detail.setDetailStartTime(billingPriceVO.getStartTime());
|
||||
detail.setDetailEndTime(billingPriceVO.getEndTime());
|
||||
detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
|
||||
detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
|
||||
detail.setDetailPower(orderDetail.getSharpUsedElectricity());
|
||||
detail.setDetailElecMoney(orderDetail.getSharpElectricityPrice());
|
||||
detail.setDetailSeviceMoney(orderDetail.getSharpServicePrice());
|
||||
}else if (StringUtils.equals(billingPriceVO.getTimeType(), "2")) {
|
||||
// 峰时段
|
||||
detail.setDetailStartTime(billingPriceVO.getStartTime());
|
||||
detail.setDetailEndTime(billingPriceVO.getEndTime());
|
||||
detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
|
||||
detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
|
||||
detail.setDetailPower(orderDetail.getPeakUsedElectricity());
|
||||
detail.setDetailElecMoney(orderDetail.getPeakElectricityPrice());
|
||||
detail.setDetailSeviceMoney(orderDetail.getPeakServicePrice());
|
||||
}else if (StringUtils.equals(billingPriceVO.getTimeType(), "3")) {
|
||||
// 平时段
|
||||
detail.setDetailStartTime(billingPriceVO.getStartTime());
|
||||
detail.setDetailEndTime(billingPriceVO.getEndTime());
|
||||
detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
|
||||
detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
|
||||
detail.setDetailPower(orderDetail.getFlatUsedElectricity());
|
||||
detail.setDetailElecMoney(orderDetail.getFlatElectricityPrice());
|
||||
detail.setDetailSeviceMoney(orderDetail.getFlatServicePrice());
|
||||
}else if (StringUtils.equals(billingPriceVO.getTimeType(), "4")) {
|
||||
// 谷时段
|
||||
detail.setDetailStartTime(billingPriceVO.getStartTime());
|
||||
detail.setDetailEndTime(billingPriceVO.getEndTime());
|
||||
detail.setElecPrice(new BigDecimal(billingPriceVO.getElectricityPrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
|
||||
detail.setSevicePrice(new BigDecimal(billingPriceVO.getServicePrice()).setScale(4, BigDecimal.ROUND_HALF_UP));
|
||||
detail.setDetailPower(orderDetail.getValleyUsedElectricity());
|
||||
detail.setDetailElecMoney(orderDetail.getValleyElectricityPrice());
|
||||
detail.setDetailSeviceMoney(orderDetail.getValleyServicePrice());
|
||||
}
|
||||
chargeDetails.add(detail);
|
||||
}
|
||||
|
||||
orderInfo.setChargeDetails(chargeDetails);
|
||||
|
||||
// 获取令牌
|
||||
String token = getToken(OPERATOR_ID, OPERATOR_SECRET);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
return null;
|
||||
}
|
||||
// 调用联联平台接口
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("OrderInfo", orderInfo);
|
||||
String jsonString = JSONObject.toJSONString(json);
|
||||
|
||||
String result = HttpRequestUtil.sendPost(token, jsonString, url, DATA_SECRET, DATA_SECRETIV, OPERATOR_ID, SIG_SECRET);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// private ChargeDetail setChargeDetail(OrderBasicInfo orderBasicInfo, OrderDetail orderDetail) {
|
||||
// ChargeDetail detail = new ChargeDetail();
|
||||
//
|
||||
// detail.setDetailStartTime();
|
||||
// detail.setDetailEndTime();
|
||||
// detail.setElecPrice();
|
||||
// detail.setSevicePrice();
|
||||
// detail.setDetailPower();
|
||||
// detail.setDetailElecMoney();
|
||||
// detail.setDetailSeviceMoney();
|
||||
// }
|
||||
|
||||
// TODO 推送停止充电结果 notification_stop_charge_result
|
||||
|
||||
// TODO 推送充电订单信息 notification_charge_order_info
|
||||
|
||||
Reference in New Issue
Block a user