|
@@ -2,11 +2,14 @@ package com.tzld.piaoquan.risk.control.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.tzld.piaoquan.risk.control.config.QywxConfig;
|
|
|
+import com.tzld.piaoquan.risk.control.dao.mapper.UserBaseMapper;
|
|
|
import com.tzld.piaoquan.risk.control.dao.mapper.WorkWechatRoomInfoMapper;
|
|
|
import com.tzld.piaoquan.risk.control.model.po.UserBase;
|
|
|
+import com.tzld.piaoquan.risk.control.model.po.UserBaseExample;
|
|
|
import com.tzld.piaoquan.risk.control.model.po.WorkWechatRoomInfo;
|
|
|
import com.tzld.piaoquan.risk.control.model.po.WorkWechatRoomInfoExample;
|
|
|
import com.tzld.piaoquan.risk.control.model.qywx.*;
|
|
|
+import com.tzld.piaoquan.risk.control.service.CorpBlacklistService;
|
|
|
import com.tzld.piaoquan.risk.control.util.HttpClientUtil;
|
|
|
import com.tzld.piaoquan.risk.control.util.HttpPoolClient;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -26,6 +29,13 @@ public class RiskUserOperateService {
|
|
|
private QywxConfig qywxConfig; // 注入配置类
|
|
|
@Autowired
|
|
|
private WorkWechatRoomInfoMapper workWechatRoomInfoMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CorpBlacklistService corpBlacklistService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserBaseMapper userBaseMapper;
|
|
|
+
|
|
|
@Value("${qywx.corpid}")
|
|
|
private long corpid;
|
|
|
private static final HttpPoolClient httpPoolClientDefault = HttpClientUtil.create(10000, 10000, 2000, 5000, 5, 10000);
|
|
@@ -104,11 +114,32 @@ public class RiskUserOperateService {
|
|
|
if(message.getMemberList().isEmpty()) {
|
|
|
return false;
|
|
|
}
|
|
|
+ boolean inBlacklist = false;
|
|
|
+
|
|
|
long vid = message.getMemberList().get(0);
|
|
|
- if(!BLACKLIST_VID.contains(vid)) {
|
|
|
- LOGGER.info("quickKick, vid: {} is in blacklist, skip kick", vid);
|
|
|
+ // 根据 vid 判断是否在全局黑名单中
|
|
|
+ if(BLACKLIST_VID.contains(vid)) {
|
|
|
+ LOGGER.info("quickKick, vid: {} is in blacklist", vid);
|
|
|
+ inBlacklist = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据 vid 判断是否在企业黑名单中
|
|
|
+ if ( !inBlacklist ) {
|
|
|
+ // 根据 uuid 查询 corp_id
|
|
|
+ Long corpId = getCorpIdByUuid(uuid);
|
|
|
+ // 根据 corp_id 和 vid判断是否在企业黑名单中
|
|
|
+ if( corpBlacklistService.isInCorpBlacklist(vid, corpId)) {
|
|
|
+ LOGGER.info("quickKick, vid: {} is in corp blacklist", vid);
|
|
|
+ inBlacklist = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果不在黑名单中,直接返回
|
|
|
+ if( !inBlacklist ) {
|
|
|
+ LOGGER.info("quickKick, vid: {} is not in any blacklist, skip kick", vid);
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
// 如果是群聊,直接踢出
|
|
|
LOGGER.info("quickKick, message: {}, uuid: {},timestamp {}", message, uuid,System.currentTimeMillis());
|
|
|
requestBody.put("blacklist_vid",Arrays.asList(message.getMemberList().get(0)));
|
|
@@ -130,6 +161,41 @@ public class RiskUserOperateService {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据uuid查询corp_id
|
|
|
+ * @param uuid
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Long getCorpIdByUuid(String uuid) {
|
|
|
+ // 从qywx_user_base表根据uuid查询corp_id
|
|
|
+ if (uuid == null || uuid.trim().isEmpty()) {
|
|
|
+ LOGGER.warn("getCorpIdByUuid called with null or empty uuid");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ UserBaseExample example = new UserBaseExample();
|
|
|
+ example.createCriteria().andUuidEqualTo(uuid);
|
|
|
+
|
|
|
+ List<UserBase> users = userBaseMapper.selectByExample(example);
|
|
|
+
|
|
|
+ if (users.isEmpty()) {
|
|
|
+ LOGGER.warn("No user found for uuid: {}", uuid);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ UserBase user = users.get(0);
|
|
|
+ Long corpId = user.getCorpId();
|
|
|
+
|
|
|
+ LOGGER.debug("Found corpId: {} for uuid: {}", corpId, uuid);
|
|
|
+ return corpId;
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ LOGGER.error("Failed to get corpId for uuid: {}", uuid, e);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public boolean checkAndKickExternalUser(UserBase staff,RiskUserInfo riskUserInfo,long vid,long roomId) {
|
|
|
LOGGER.info("checkAndKickExternalUser, staff: {}, riskUserInfo: {}, vid: {}, roomId: {}", staff, riskUserInfo, vid, roomId);
|
|
|
boolean inRoom = isInRoom(staff, roomId, vid);
|