mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-22 12:05:05 +08:00
update 电单车协议
This commit is contained in:
@@ -64,7 +64,7 @@ public class ChargingOperationResponse extends AbsEBikeMessage2 {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String s = "444e591d00198bca07f106820013273881052409191439471814850828040000ad06";
|
||||
String s = "444e591d00198bca0727268200132738810524091914394718148508280400000306";
|
||||
byte[] messageBytes = BytesUtil.hexStringToByteArray(s);
|
||||
ChargingOperationResponse response = new ChargingOperationResponse(messageBytes);
|
||||
System.out.println(response);
|
||||
|
||||
@@ -7,19 +7,21 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class EBikeMessageCmd03 extends AbsEBikeMessage2 {
|
||||
private int chargingTime; // 充电时长, 单位:"秒"
|
||||
private int maxPower; // 最大功率, 单位:"0.1W"
|
||||
private int consumedEnergy; // 耗电量, 单位:"0.01度"
|
||||
private BigDecimal maxPower; // 最大功率, 桩给的数据单位:"0.1W", 代码已经转为瓦
|
||||
private BigDecimal consumedEnergy; // 耗电量, 桩给的数据单位:"0.01度", 代码已经转为度
|
||||
private String connectorCode; // 端口号
|
||||
private int startMode; // 在线/离线启动/验证码
|
||||
private int cardNumberOrVerificationCode; // 卡号/验证码
|
||||
private int stopReason; // 停止原因
|
||||
private String orderNumber; // 订单编号
|
||||
private int secondMaxPower; // 第二最大功率
|
||||
private BigDecimal secondMaxPower; // 第二最大功率
|
||||
// private String timestamp; // 时间戳 上发指令当时的时间,有时候不准确,该字段属于调试使用,服务器无需关心此字段
|
||||
// private String placeholderDuration; // 占位时长 充电柜专用,其他设备忽略此字段 表示充满后占用设备的时长,单位为分钟
|
||||
|
||||
@@ -32,11 +34,12 @@ public class EBikeMessageCmd03 extends AbsEBikeMessage2 {
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.maxPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
this.maxPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length))).multiply(new BigDecimal("0.1"));
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.consumedEnergy = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
this.consumedEnergy = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length)))
|
||||
.multiply(new BigDecimal("0.01"));
|
||||
|
||||
startIndex += length;
|
||||
length = 1;
|
||||
@@ -60,7 +63,7 @@ public class EBikeMessageCmd03 extends AbsEBikeMessage2 {
|
||||
|
||||
startIndex += length;
|
||||
length = 2;
|
||||
this.secondMaxPower = BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length));
|
||||
this.secondMaxPower = new BigDecimal(BytesUtil.bytesToIntLittle(BytesUtil.copyBytes(messageBytes, startIndex, length))).multiply(new BigDecimal("0.1"));
|
||||
|
||||
// this.timestamp = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(messageBytes, 31, 35)) + "";
|
||||
// this.placeholderDuration = BytesUtil.bytesToIntLittle(Arrays.copyOfRange(messageBytes, 35, 37)) + "";
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.ebike.EBikeChargeCommandResponse;
|
||||
import com.jsowell.common.enums.ebike.EBikeChargeResponseEnum;
|
||||
import com.jsowell.common.enums.ykc.ChargingFailedReasonEnum;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
@@ -141,7 +141,7 @@ public class PileRemoteService {
|
||||
// 启动成功
|
||||
orderBasicInfoService.chargingPileStartedSuccessfully(transactionCode);
|
||||
} else {
|
||||
String failedReasonMsg = EBikeChargeCommandResponse.getDescriptionByCode(result);
|
||||
String failedReasonMsg = EBikeChargeResponseEnum.getDescriptionByCode(result);
|
||||
// 启动失败 682204000001000000000041
|
||||
orderBasicInfoService.chargingPileFailedToStart(transactionCode, failedReasonMsg);
|
||||
}
|
||||
|
||||
@@ -3103,8 +3103,8 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
|
||||
*/
|
||||
@Override
|
||||
public void payOrderSuccessCallback(PayOrderSuccessCallbackDTO dto) {
|
||||
logger.info("订单:{}支付成功 支付回调", dto.getOrderCode());
|
||||
OrderBasicInfo orderInfo = this.getOrderInfoByOrderCode(dto.getOrderCode());
|
||||
logger.info("订单:{}支付成功支付回调, OrderBasicInfo:{}", dto.getOrderCode(), JSON.toJSONString(orderInfo));
|
||||
BigDecimal payAmount = dto.getPayAmount();
|
||||
|
||||
// 是否发送启动指令
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.jsowell.common.enums.DelFlagEnum;
|
||||
import com.jsowell.common.enums.MemberWalletEnum;
|
||||
import com.jsowell.common.enums.adapay.AdapayStatusEnum;
|
||||
import com.jsowell.common.enums.adapay.MerchantDelayModeEnum;
|
||||
import com.jsowell.common.enums.ebike.EBikeStopReasonEnum;
|
||||
import com.jsowell.common.enums.ykc.*;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.AdapayUtil;
|
||||
@@ -473,7 +474,35 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
|
||||
|
||||
@Override
|
||||
public void settleOrderForEBike(EBikeMessageCmd03 message, OrderBasicInfo orderBasicInfo) {
|
||||
// 判断订单状态
|
||||
if (StringUtils.equals(orderBasicInfo.getOrderStatus(), OrderStatusEnum.ORDER_COMPLETE.getValue())) {
|
||||
logger.info("结算订单:{}, 是订单完成状态", orderBasicInfo.getOrderCode());
|
||||
return;
|
||||
}
|
||||
|
||||
// 订单状态
|
||||
orderBasicInfo.setOrderStatus(OrderStatusEnum.ORDER_COMPLETE.getValue());
|
||||
// 停止原因
|
||||
orderBasicInfo.setReason(EBikeStopReasonEnum.getDescriptionByCode(message.getStopReason()));
|
||||
|
||||
// 更新订单详情
|
||||
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderBasicInfo.getOrderCode());
|
||||
if (orderDetail != null) {
|
||||
orderDetail.setTotalUsedElectricity(message.getConsumedEnergy());
|
||||
orderDetail.setFlatUsedElectricity(message.getConsumedEnergy());
|
||||
}
|
||||
|
||||
// 更新数据库
|
||||
OrderTransactionDTO dto = new OrderTransactionDTO();
|
||||
dto.setOrderBasicInfo(orderBasicInfo);
|
||||
dto.setOrderDetail(orderDetail);
|
||||
transactionService.doUpdateOrder(dto);
|
||||
|
||||
// 充电时间大于30秒不退费
|
||||
int chargingTime = message.getChargingTime();
|
||||
if (chargingTime < 30) {
|
||||
// 退款
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user