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

@@ -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);