jean 1 mesiac pred
rodič
commit
e4b0c51260

+ 3 - 2
doge/contract-swap-api/src/main/java/com/bizzan/bitrade/controller/WalletNewController.java

@@ -9,7 +9,7 @@ import java.util.*;
 
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.kafka.core.KafkaTemplate;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -116,8 +116,9 @@ public class WalletNewController {
 	private MemberWalletService memberWalletService;
 	@Autowired
 	private MemberTransactionService memberTransactionService;
+	/** 使用 StringRedisTemplate 读取交易所写入的纯字符串行情数据,避免 JDK 序列化反序列化失败 */
 	@Autowired
-	private RedisTemplate<String, String> redisTemplate;
+	private StringRedisTemplate redisTemplate;
 	@Autowired
 	private FundAssetService fundAssetService;
 	@Autowired

+ 8 - 1
doge/core/src/main/java/com/bizzan/bitrade/util/RedisManager.java

@@ -13,6 +13,7 @@ import org.springframework.data.redis.connection.RedisConnection;
 import org.springframework.data.redis.core.RedisCallback;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.SetOperations;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.data.redis.core.ValueOperations;
 import org.springframework.stereotype.Component;
 
@@ -32,6 +33,10 @@ public class RedisManager {
 	@Autowired
     private RedisTemplate<Object,Object> redisTemplate;
 
+    /** 用于读取交易所写入的纯字符串行情数据(如 ExchangeNew2:latestPrice) */
+    @Autowired
+    private StringRedisTemplate stringRedisTemplate;
+
     @Resource(name = "redisTemplate")
     private ValueOperations<Object,Object> valOps;
 
@@ -634,8 +639,10 @@ public class RedisManager {
         }
         try {
             // field 格式:ibitusdt(全小写,直接拼接 usdt)
+            // 使用 StringRedisTemplate 读取,因为交易所写入的是纯字符串,
+            // 用 redisTemplate(JDK/Jackson 序列化)读取会导致反序列化失败
             String field = coinUnit.trim().toLowerCase() + "usdt";
-            Object val = redisTemplate.opsForHash().get(SPOT_LATEST_PRICE_KEY, field);
+            Object val = stringRedisTemplate.opsForHash().get(SPOT_LATEST_PRICE_KEY, field);
             if (val != null) {
                 java.math.BigDecimal price = new java.math.BigDecimal(val.toString());
                 if (price.compareTo(java.math.BigDecimal.ZERO) > 0) {