Browse Source

店铺打卡效验24小时

qinxuyang 1 month ago
parent
commit
72843e2ece

+ 9 - 6
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -6096,12 +6096,15 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         }
 
         // 今天在该店铺是否打过卡
-        int today = (int) clockStoreList.stream().filter(item -> item.getCreatedTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().equals(LocalDate.now())).count();
-        if (today > 0) {
-            result.setClockInStoreToday(1);
-        } else {
-            result.setClockInStoreToday(0);
-        }
+//        int today = (int) clockStoreList.stream().filter(item -> item.getCreatedTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().equals(LocalDate.now())).count();
+        int today = clockStoreList.stream()
+                .filter(item -> item.getCreatedTime() != null)
+                .max(Comparator.comparing(StoreClockIn::getCreatedTime))
+                .map(item -> Duration.between(item.getCreatedTime().toInstant(), Instant.now())
+                        .compareTo(Duration.ofHours(24)) > 0 ? 1 : 0)
+                .orElse(0);
+
+        result.setClockInStoreToday(today);
 
         Integer totalCount = 0;
         Object ratingObj =  commonRatingService.getRatingCount(storeInfo.getId(), 1);