update 华为Service

This commit is contained in:
Lemon
2024-03-21 09:27:57 +08:00
parent d53f830298
commit f97a745361
4 changed files with 31 additions and 8 deletions

View File

@@ -27,7 +27,7 @@ import java.util.List;
import java.util.Map;
/**
* TODO
* 华为 Controller V2
*
* @author Lemon
* @Date 2024/2/2 14:34:56

View File

@@ -232,6 +232,21 @@ public class CacheConstants {
*/
public static final String JIANGSU_PUSH_PILE_STATUS = "JIANGSU_PUSH_PILE_STATUS:";
/**
* 华为获取令牌
*/
public static final String HUAWEI_GET_TOKEN = "HUAWEI_GET_TOKEN:";
/**
* 华为保存实时设备充电状态信息
*/
public static final String HUA_WEI_REAL_TIME_INFO_BY_ORDER_CODE = "HUA_WEI_REAL_TIME_INFO_BY_ORDER_CODE:";
/**
* 华为订单信息
*/
public static final String HUA_WEI_ORDER_INFO_BY_ORDER_CODE = "HUA_WEI_ORDER_INFO_BY_ORDER_CODE:";
/**
* 桩硬件故障
*/

View File

@@ -436,6 +436,11 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
// 订单退款
refundOrder(orderBasicInfo);
// 如果是vin启动将启动锁定状态改为正常
if (StringUtils.equals(data.getTransactionIdentifier(), "05")) {
vinStatusUnlocked(data.getVinCode());
}
// 发送停止充电订阅消息
sendMsg(orderBasicInfo);

View File

@@ -6,6 +6,7 @@ import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.google.common.collect.Maps;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
@@ -102,9 +103,6 @@ public class HuaweiServiceV2 {
@Autowired
private IThirdpartySnRelationService thirdpartySnRelationService;
@Resource
private TransactionService transactionService;
@Autowired
private RedisCache redisCache;
@@ -114,7 +112,7 @@ public class HuaweiServiceV2 {
*/
public String getHuaWeiToken() {
String operatorId = Constants.OPERATORID_JIANG_SU;
String redisKey = "huawei_get_token:" + operatorId;
String redisKey = CacheConstants.HUAWEI_GET_TOKEN + operatorId;
// 先查缓存
String cacheToken = redisCache.getCacheObject(redisKey);
if (StringUtils.isNotBlank(cacheToken)) {
@@ -624,7 +622,7 @@ public class HuaweiServiceV2 {
return null;
}
// 将源数据存储至缓存
String redisKey = "HUA_WEI_REAL_TIME_INFO_BY_ORDER_CODE:" + startChargeSeq;
String redisKey = CacheConstants.HUA_WEI_REAL_TIME_INFO_BY_ORDER_CODE + startChargeSeq;
String jsonMsg = JSON.toJSONString(dto);
// 在同一分钟内,只保留最后一条实时数据
redisCache.hset(redisKey, DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:00", new Date()), jsonMsg);
@@ -732,7 +730,7 @@ public class HuaweiServiceV2 {
String pileConnectorCode = dto.getConnectorID();
// 将源数据存缓存
String redisKey = "HUA_WEI_ORDER_INFO_BY_ORDER_CODE:" + startChargeSeq;
String redisKey = CacheConstants.HUA_WEI_ORDER_INFO_BY_ORDER_CODE + startChargeSeq;
redisCache.setCacheObject(redisKey, dto);
// // 截取桩号
@@ -751,7 +749,7 @@ public class HuaweiServiceV2 {
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(startChargeSeq);
// OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(startChargeSeq);
// TODO 结算订单
// 结算订单
TransactionRecordsData data = TransactionRecordsData.builder()
.consumptionAmount(String.valueOf(dto.getTotalMoney())) // 订单总金额
.stopReasonMsg(String.valueOf(dto.getStopReason())) // 停止原因
@@ -759,6 +757,11 @@ public class HuaweiServiceV2 {
.totalElectricityAmount(String.valueOf(dto.getTotalElecMoney())) // 总电费
.totalServiceAmount(String.valueOf(dto.getTotalSeviceMoney())) // 总服务费
.build();
if (StringUtils.equals(StartModeEnum.VIN_CODE.getValue(), orderBasicInfo.getStartMode())) {
// 将交易记录中的交易标识 05 传入实时数据对象,用于结算订单后解锁 vin 状态
data.setTransactionIdentifier("05");
}
String mode = pileMerchantInfoService.getDelayModeByMerchantId(orderBasicInfo.getMerchantId());
AbstractProgramLogic orderLogic = ProgramLogicFactory.getProgramLogic(mode);
orderLogic.settleOrderForThirdParty(data, orderBasicInfo);