Răsfoiți Sursa

元域名大小写

wangqifan 2 ani în urmă
părinte
comite
ddc2e81065

+ 1 - 1
src/main/java/com/izouma/nineth/repo/OrderRepo.java

@@ -70,7 +70,7 @@ public interface OrderRepo extends JpaRepository<Order, Long>, JpaSpecificationE
     List<Order> findByCreatedAtBetweenAndSourceAndStatusIn(LocalDateTime start, LocalDateTime end, CollectionSource source, Collection<OrderStatus> statuses);
 
     @Query(nativeQuery = true, value = "select o.user_id  from order_info o " +
-            " WHERE o.created_at < ?1 and o.created_at > ?2 and o.status = 'NOT_PAID' " +
+            " WHERE o.created_at < ?1 and o.created_at > ?2 and ( o.status = 'NOT_PAID' OR o.status = 'CANCELLED')" +
             "GROUP BY o.user_id " +
             "HAVING count(*) > 2")
     List<Long> checkBlackList(LocalDateTime start, LocalDateTime end);

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

@@ -1002,9 +1002,11 @@ public class OrderService {
     @Scheduled(cron = "0 0/3 * * * ?")
     public void setBlackList() {
         List<Long> userIds = orderRepo
-                .checkBlackList(LocalDateTime.now(), LocalDateTime.now().minusHours(1));
+                .checkBlackList(LocalDateTime.now(), LocalDateTime.now().minusMinutes(30));
         userIds.forEach(userId -> {
-            redisTemplate.opsForValue().set(RedisKeys.BLACK_LIST + userId, 10, Duration.ofSeconds(60 * 180));
+            if (redisTemplate.opsForValue().get(RedisKeys.BLACK_LIST + userId) == null) {
+                redisTemplate.opsForValue().set(RedisKeys.BLACK_LIST + userId, 1, Duration.ofSeconds(60 * 180));
+            }
         });
     }