刘立冬 hai 1 mes
pai
achega
01cfb01fc0

+ 9 - 3
risk-control-core/src/main/java/com/tzld/piaoquan/risk/control/service/impl/RiskRuleConfigService.java

@@ -14,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.time.Instant;
 import java.util.*;
 
@@ -57,7 +59,7 @@ public class RiskRuleConfigService {
 
 
     //防止误踢,只有满足存在五个正常群人数才会生效
-    public FixedRuleResult getFixedRulesForThisChat(String chatId, String roomId) {
+    public FixedRuleResult getFixedRulesForThisChat(String chatId, String roomId) throws ParseException {
         FixedRuleResult ruleResult = new FixedRuleResult();
         WorkWechatRoomInfoExample example = new WorkWechatRoomInfoExample();
         example.createCriteria().andRoomIdEqualTo(roomId);
@@ -67,8 +69,12 @@ public class RiskRuleConfigService {
             return ruleResult;
         }
         WorkWechatRoomInfo roomInfo = examples.get(0);
-        Instant instant = roomInfo.getUpdateTime().toInstant(); // 转为UTC时间
-        long roomUpdateTime = instant.getEpochSecond(); // 直接获取秒级时间戳
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        sdf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); // 设置为UTC+8
+        Date date = sdf.parse(roomInfo.getUpdateTime().toString());
+        long roomUpdateTime = date.getTime() / 1000; // 正确的UTC时间戳
+//        Instant instant = roomInfo.getUpdateTime().toInstant(); // 转为UTC时间
+//        long roomUpdateTime = instant.getEpochSecond(); // 直接获取秒级时间戳
 //        long roomUpdateTime = roomInfo.getUpdateTime().getTime()/1000;
         log.info("getFixedRulesForThisChat, roomId: {}, roomUpdateTime: {}", roomId, roomUpdateTime);
         List<UserListFromAdPlatformModel.ChatMember> memberList = getUserListFromAdPlatform(chatId);