mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-13 06:20:07 +08:00
通过交易流水号查询订单信息
This commit is contained in:
@@ -30,6 +30,8 @@ public class CacheConstants {
|
|||||||
*/
|
*/
|
||||||
public static final String GET_ORDER_INFO_BY_ORDER_CODE = "get_order_info_by_order_code:";
|
public static final String GET_ORDER_INFO_BY_ORDER_CODE = "get_order_info_by_order_code:";
|
||||||
|
|
||||||
|
public static final String GET_ORDER_INFO_BY_TRANSACTION_CODE = "get_order_info_by_transaction_code:";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 充电枪口实时监控数据
|
* 充电枪口实时监控数据
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
public class TransactionRecordsData {
|
public class TransactionRecordsData {
|
||||||
|
// private String orderCode;
|
||||||
|
|
||||||
// 交易流水号
|
// 交易流水号
|
||||||
private String orderCode;
|
private String transactionCode;
|
||||||
|
|
||||||
// 桩编码
|
// 桩编码
|
||||||
private String pileSn;
|
private String pileSn;
|
||||||
@@ -121,7 +122,7 @@ public class TransactionRecordsData {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)
|
return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)
|
||||||
.append("orderCode", orderCode)
|
.append("transactionCode", transactionCode)
|
||||||
.append("pileSn", pileSn)
|
.append("pileSn", pileSn)
|
||||||
.append("connectorCode", connectorCode)
|
.append("connectorCode", connectorCode)
|
||||||
.append("startTime", startTime)
|
.append("startTime", startTime)
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ public class TransactionRecordsRequestHandler extends AbstractHandler {
|
|||||||
|
|
||||||
// 交易流水号
|
// 交易流水号
|
||||||
byte[] orderCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
byte[] orderCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||||||
String orderCode = BytesUtil.bcd2Str(orderCodeByteArr);
|
String transactionCode = BytesUtil.bcd2Str(orderCodeByteArr);
|
||||||
|
|
||||||
// 桩编码
|
// 桩编码
|
||||||
startIndex += length;
|
startIndex += length;
|
||||||
@@ -442,14 +442,15 @@ public class TransactionRecordsRequestHandler extends AbstractHandler {
|
|||||||
"峰单价:{}, 峰电量:{}, 计损峰电量:{}, 峰金额:{}, 平单价:{}, 平电量:{}, 计损平电量:{}, 平金额:{}, " +
|
"峰单价:{}, 峰电量:{}, 计损峰电量:{}, 峰金额:{}, 平单价:{}, 平电量:{}, 计损平电量:{}, 平金额:{}, " +
|
||||||
"谷单价:{}, 谷电量:{}, 计损谷电量:{}, 谷金额:{}, 电表总起值:{}, 电表总止值:{}, 总电量:{}, 计损总电量:{}, 消费金额:{}, " +
|
"谷单价:{}, 谷电量:{}, 计损谷电量:{}, 谷金额:{}, 电表总起值:{}, 电表总止值:{}, 总电量:{}, 计损总电量:{}, 消费金额:{}, " +
|
||||||
"电动汽车唯一标识:{}, 交易标识:{}, 交易日期、时间:{}, 停止原因码:{}, 停止原因描述:{}, 物理卡号:{}",
|
"电动汽车唯一标识:{}, 交易标识:{}, 交易日期、时间:{}, 停止原因码:{}, 停止原因描述:{}, 物理卡号:{}",
|
||||||
orderCode, pileSn, connectorCode, startTime, endTime, sharpPrice, sharpUsedElectricity, sharpPlanLossElectricity, sharpAmount,
|
transactionCode, pileSn, connectorCode, startTime, endTime, sharpPrice, sharpUsedElectricity, sharpPlanLossElectricity, sharpAmount,
|
||||||
peakPrice, peakUsedElectricity, peakPlanLossElectricity, peakAmount, flatPrice, flatUsedElectricity, flatPlanLossElectricity, flatAmount,
|
peakPrice, peakUsedElectricity, peakPlanLossElectricity, peakAmount, flatPrice, flatUsedElectricity, flatPlanLossElectricity, flatAmount,
|
||||||
valleyPrice, valleyUsedElectricity, valleyPlanLossElectricity, valleyAmount, ammeterTotalStart, ammeterTotalEnd, totalElectricity, planLossTotalElectricity,
|
valleyPrice, valleyUsedElectricity, valleyPlanLossElectricity, valleyAmount, ammeterTotalStart, ammeterTotalEnd, totalElectricity, planLossTotalElectricity,
|
||||||
consumptionAmount, vinCode, transactionIdentifier, transactionTime, stopReason, stopReasonMsg, logicCard);
|
consumptionAmount, vinCode, transactionIdentifier, transactionTime, stopReason, stopReasonMsg, logicCard);
|
||||||
|
|
||||||
// 交易记录封装到对象里
|
// 交易记录封装到对象里
|
||||||
TransactionRecordsData data = TransactionRecordsData.builder()
|
TransactionRecordsData data = TransactionRecordsData.builder()
|
||||||
.orderCode(orderCode)
|
// .orderCode(transactionCode)
|
||||||
|
.transactionCode(transactionCode)
|
||||||
.pileSn(pileSn)
|
.pileSn(pileSn)
|
||||||
.connectorCode(connectorCode)
|
.connectorCode(connectorCode)
|
||||||
.startTime(startTime)
|
.startTime(startTime)
|
||||||
@@ -487,7 +488,7 @@ public class TransactionRecordsRequestHandler extends AbstractHandler {
|
|||||||
pileMsgRecordService.save(pileSn, pileSn + connectorCode, type, jsonMsg, ykcDataProtocol.getHEXString());
|
pileMsgRecordService.save(pileSn, pileSn + connectorCode, type, jsonMsg, ykcDataProtocol.getHEXString());
|
||||||
|
|
||||||
// 处理订单加锁
|
// 处理订单加锁
|
||||||
String lockKey = "settle_order_" + orderCode;
|
String lockKey = "settle_order_" + transactionCode;
|
||||||
String uuid = IdUtils.fastUUID();
|
String uuid = IdUtils.fastUUID();
|
||||||
try {
|
try {
|
||||||
// redis锁
|
// redis锁
|
||||||
@@ -517,9 +518,12 @@ public class TransactionRecordsRequestHandler extends AbstractHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processOrder(TransactionRecordsData data) {
|
private void processOrder(TransactionRecordsData data) {
|
||||||
String orderCode = data.getOrderCode();
|
// String orderCode = data.getOrderCode();
|
||||||
|
String transactionCode = data.getTransactionCode();
|
||||||
// 根据订单号查询订单信息
|
// 根据订单号查询订单信息
|
||||||
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
// OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
|
||||||
|
// 根据交易流水号查询订单信息
|
||||||
|
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByTransactionCode(transactionCode);
|
||||||
if (orderBasicInfo != null) {
|
if (orderBasicInfo != null) {
|
||||||
// 平台存在订单
|
// 平台存在订单
|
||||||
orderBasicInfo.setReason(data.getStopReasonMsg());
|
orderBasicInfo.setReason(data.getStopReasonMsg());
|
||||||
|
|||||||
@@ -109,6 +109,8 @@ public interface OrderBasicInfoMapper {
|
|||||||
*/
|
*/
|
||||||
OrderBasicInfo getOrderInfoByOrderCode(String orderCode);
|
OrderBasicInfo getOrderInfoByOrderCode(String orderCode);
|
||||||
|
|
||||||
|
OrderBasicInfo getOrderInfoByTransactionCode(String transactionCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据桩编号和枪口号查询某状态订单
|
* 根据桩编号和枪口号查询某状态订单
|
||||||
*
|
*
|
||||||
@@ -182,4 +184,5 @@ public interface OrderBasicInfoMapper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<PersonPileConnectorSumInfoVO> getAccumulativeInfo(QueryPersonPileDTO dto);
|
List<PersonPileConnectorSumInfoVO> getAccumulativeInfo(QueryPersonPileDTO dto);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ public interface IOrderBasicInfoService {
|
|||||||
*/
|
*/
|
||||||
OrderBasicInfo getOrderInfoByOrderCode(String orderCode);
|
OrderBasicInfo getOrderInfoByOrderCode(String orderCode);
|
||||||
|
|
||||||
|
OrderBasicInfo getOrderInfoByTransactionCode(String transactionCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过桩号和枪口号查询充电中的状态
|
* 通过桩号和枪口号查询充电中的状态
|
||||||
* @param pileSn 桩编号
|
* @param pileSn 桩编号
|
||||||
@@ -198,4 +200,6 @@ public interface IOrderBasicInfoService {
|
|||||||
* @param pileSn
|
* @param pileSn
|
||||||
*/
|
*/
|
||||||
void updateOrderStatusAsAbnormal(String pileSn);
|
void updateOrderStatusAsAbnormal(String pileSn);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -389,6 +389,25 @@ public class OrderBasicInfoServiceImpl implements IOrderBasicInfoService {
|
|||||||
return orderBasicInfo;
|
return orderBasicInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderBasicInfo getOrderInfoByTransactionCode(String transactionCode) {
|
||||||
|
if (StringUtils.equals("00000000000000000000000000000000", transactionCode)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String redisKey = CacheConstants.GET_ORDER_INFO_BY_TRANSACTION_CODE + transactionCode;
|
||||||
|
OrderBasicInfo orderBasicInfo = redisCache.getCacheObject(redisKey);
|
||||||
|
if (orderBasicInfo == null) {
|
||||||
|
// 查数据库
|
||||||
|
orderBasicInfo = orderBasicInfoMapper.getOrderInfoByTransactionCode(transactionCode);
|
||||||
|
// 放缓存
|
||||||
|
if (orderBasicInfo != null) {
|
||||||
|
redisCache.setCacheObject(redisKey, orderBasicInfo, 5, TimeUnit.MINUTES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.info("通过交易流水号:{}, 查询订单信息:{}", transactionCode, JSON.toJSONString(orderBasicInfo));
|
||||||
|
return orderBasicInfo;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据充电桩编号和枪口号查询正在充电中的订单
|
* 根据充电桩编号和枪口号查询正在充电中的订单
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -655,6 +655,14 @@
|
|||||||
and del_flag = '0'
|
and del_flag = '0'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getOrderInfoByTransactionCode" resultMap="OrderBasicInfoResult">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
from order_basic_info
|
||||||
|
where del_flag = '0'
|
||||||
|
and transaction_code = #{transactionCode,jdbcType=VARCHAR}
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="queryOrderBasicInfo" resultMap="OrderBasicInfoResult">
|
<select id="queryOrderBasicInfo" resultMap="OrderBasicInfoResult">
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List"/>
|
<include refid="Base_Column_List"/>
|
||||||
@@ -830,4 +838,5 @@
|
|||||||
AND t1.order_status = '6'
|
AND t1.order_status = '6'
|
||||||
AND t1.del_flag = '0'
|
AND t1.del_flag = '0'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user