Prechádzať zdrojové kódy

Merge branch 'master_cart' of xiongzhu/raex_back into master

wangqifan 3 rokov pred
rodič
commit
c746fe4b88

+ 10 - 10
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -196,18 +196,18 @@ public class OrderService {
             throw new BusinessException("签名已过期");
         }
 
-//        if (redisTemplate.opsForValue().get(RedisKeys.BLACK_LIST + userId) != null) {
-//            throw new BusinessException("频繁操作,请稍后再试");
-//        }
+        if (redisTemplate.opsForValue().get(RedisKeys.BLACK_LIST + userId) != null) {
+            throw new BusinessException("频繁操作,请稍后再试");
+        }
         BoundValueOperations<String, Object> ops = redisTemplate.boundValueOps(RedisKeys.LIMIT_USER + userId);
         ops.setIfAbsent(0, Duration.ofSeconds(10));
-//        long val = Optional.ofNullable(ops.increment()).orElse(0L);
-//        if (val > 5) {
-//            if (val > 10) {
-//                redisTemplate.opsForValue().set(RedisKeys.BLACK_LIST + userId, 1, Duration.ofSeconds(60 * 10));
-//            }
-//            throw new BusinessException("频繁操作,请稍后再试");
-//        }
+        long val = Optional.ofNullable(ops.increment()).orElse(0L);
+        if (val > 5) {
+            if (val > 10) {
+                redisTemplate.opsForValue().set(RedisKeys.BLACK_LIST + userId, 1, Duration.ofSeconds(60 * 10));
+            }
+            throw new BusinessException("频繁操作,请稍后再试");
+        }
 
         limitReq(collectionId);