!20 改造交易记录领域模型

* 改造交易记录领域模型
This commit is contained in:
三丙
2025-08-11 10:53:06 +00:00
parent 199711026c
commit ca536a55f2
4 changed files with 69 additions and 31 deletions

View File

@@ -32,7 +32,7 @@ public enum YunKuaiChongDownlinkCmdEnum {
REMOTE_STOP_CHARGING(0x36),
TRANSACTION_RECORD(0x40),
TRANSACTION_RECORD_ACK(0x40),
REMOTE_PARALLEL_START_CHARGING(0xA4),

View File

@@ -20,7 +20,7 @@ import sanbing.jcpp.protocol.yunkuaichong.annotation.YunKuaiChongCmd;
import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongDwonlinkMessage.FAILURE_BYTE;
import static sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongDwonlinkMessage.SUCCESS_BYTE;
import static sanbing.jcpp.protocol.yunkuaichong.enums.YunKuaiChongDownlinkCmdEnum.TRANSACTION_RECORD;
import static sanbing.jcpp.protocol.yunkuaichong.enums.YunKuaiChongDownlinkCmdEnum.TRANSACTION_RECORD_ACK;
/**
* 云快充1.5.0 交易记录确认
@@ -46,7 +46,7 @@ public class YunKuaiChongV150TransactionRecordAckDLCmd extends YunKuaiChongDownl
msgBody.writeBytes(encodeTradeNo(transactionRecordAck.getTradeNo()));
msgBody.writeByte(transactionRecordAck.getSuccess() ? SUCCESS_BYTE : FAILURE_BYTE);
encodeAndWriteFlush(TRANSACTION_RECORD,
encodeAndWriteFlush(TRANSACTION_RECORD_ACK,
requestData.getSequenceNumber(),
requestData.getEncryptionFlag(),
msgBody,

View File

@@ -13,8 +13,7 @@ import lombok.extern.slf4j.Slf4j;
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
import sanbing.jcpp.infrastructure.util.codec.CP56Time2aUtil;
import sanbing.jcpp.infrastructure.util.jackson.JacksonUtil;
import sanbing.jcpp.proto.gen.ProtocolProto.TransactionRecord;
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
import sanbing.jcpp.proto.gen.ProtocolProto.*;
import sanbing.jcpp.protocol.ProtocolContext;
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongUplinkCmdExe;
@@ -154,12 +153,8 @@ public class YunKuaiChongV150TransactionRecordULCmd extends YunKuaiChongUplinkCm
String cardNo = BCDUtil.toString(cardNoBytes);
additionalInfo.put("物理卡号", cardNo);
TransactionRecord transactionRecord = TransactionRecord.newBuilder()
.setPileCode(pileCode)
.setGunCode(gunCode)
.setTradeNo(tradeNo)
.setStartTs(startTime.toEpochMilli())
.setEndTs(endTime.toEpochMilli())
// 构建峰谷电量明细
PeakValleyDetail peakValleyDetail = PeakValleyDetail.newBuilder()
.setTopEnergyKWh(topEnergy.toPlainString())
.setTopAmountYuan(topAmount.toPlainString())
.setPeakEnergyKWh(peakEnergy.toPlainString())
@@ -168,10 +163,26 @@ public class YunKuaiChongV150TransactionRecordULCmd extends YunKuaiChongUplinkCm
.setFlatAmountYuan(flatAmount.toPlainString())
.setValleyEnergyKWh(valleyEnergy.toPlainString())
.setValleyAmountYuan(valleyAmount.toPlainString())
.build();
// 构建交易明细
TransactionDetail transactionDetail = TransactionDetail.newBuilder()
.setType(DetailType.PEAK_VALLEY)
.setPeakValley(peakValleyDetail)
.build();
// 构建交易记录
TransactionRecord transactionRecord = TransactionRecord.newBuilder()
.setPileCode(pileCode)
.setGunCode(gunCode)
.setTradeNo(tradeNo)
.setStartTs(startTime.toEpochMilli())
.setEndTs(endTime.toEpochMilli())
.setTotalEnergyKWh(totalEnergy.toPlainString())
.setTotalAmountYuan(totalAmount.toPlainString())
.setTradeTs(tradeTime.toEpochMilli())
.setStopReason(stopReason)
.setDetail(transactionDetail)
.setAdditionalInfo(additionalInfo.toString())
.build();