|
|
@@ -17,6 +17,8 @@ import com.fs.company.service.ICompanyUserService;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
|
import com.fs.course.domain.FsCourseWatchLog;
|
|
|
import com.fs.course.service.IFsCourseWatchLogService;
|
|
|
+import com.fs.his.domain.FsUser;
|
|
|
+import com.fs.his.mapper.FsUserMapper;
|
|
|
import com.fs.fastGpt.service.IFastGptChatSessionService;
|
|
|
import com.fs.qw.domain.QwApiSopLogToken;
|
|
|
import com.fs.qw.domain.QwExternalContact;
|
|
|
@@ -76,6 +78,7 @@ public class QwSopLogsServiceImpl extends ServiceImpl<QwSopLogsMapper, QwSopLogs
|
|
|
{
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(QwSopLogsServiceImpl.class);
|
|
|
+ public static final String FS_USER_BLACKLIST_REMARK = "该客户已经被管理员拉黑";
|
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
|
@Autowired
|
|
|
@@ -126,6 +129,9 @@ public class QwSopLogsServiceImpl extends ServiceImpl<QwSopLogsMapper, QwSopLogs
|
|
|
@Autowired
|
|
|
private ICompanyUserService companyUserService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FsUserMapper fsUserMapper;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 查询企业微信SOP 定时任务
|
|
|
@@ -1075,6 +1081,10 @@ public class QwSopLogsServiceImpl extends ServiceImpl<QwSopLogsMapper, QwSopLogs
|
|
|
for (QwSopLogsDoSendListTVO log : result) {
|
|
|
|
|
|
try {
|
|
|
+ if (log.getFsUserId() != null && isFsUserBlacklisted(log.getFsUserId())) {
|
|
|
+ qwSopLogsService.updateQwSopLogsByWatchLogType(log.getId(), FS_USER_BLACKLIST_REMARK);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
if (log.getSendType()==8){
|
|
|
//(AI消息不做任何判断 直接入)切 只取了一条
|
|
|
sendJsApiList.add(log);
|
|
|
@@ -1595,9 +1605,65 @@ public class QwSopLogsServiceImpl extends ServiceImpl<QwSopLogsMapper, QwSopLogs
|
|
|
|
|
|
public void batchInsertQwSopLogs(List<QwSopLogs> logsToInsert) {
|
|
|
if(logsToInsert == null || logsToInsert.isEmpty()) return;
|
|
|
+ applyBlacklistCheck(logsToInsert);
|
|
|
qwSopLogsMapper.batchInsertQwSopLogs(logsToInsert);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void applyBlacklistCheck(QwSopLogs sopLogs) {
|
|
|
+ if (sopLogs == null || sopLogs.getFsUserId() == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (isFsUserBlacklisted(sopLogs.getFsUserId())) {
|
|
|
+ markSopLogAsBlacklisted(sopLogs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void applyBlacklistCheck(List<QwSopLogs> sopLogs) {
|
|
|
+ if (sopLogs == null || sopLogs.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Set<Long> fsUserIds = sopLogs.stream()
|
|
|
+ .map(QwSopLogs::getFsUserId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ if (fsUserIds.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Set<Long> blacklistedUserIds = new HashSet<>(fsUserMapper.selectBlacklistedUserIds(fsUserIds));
|
|
|
+ if (blacklistedUserIds.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (QwSopLogs sopLog : sopLogs) {
|
|
|
+ if (sopLog.getFsUserId() != null && blacklistedUserIds.contains(sopLog.getFsUserId())) {
|
|
|
+ markSopLogAsBlacklisted(sopLog);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void cancelPendingSopLogsByBlacklistedFsUserId(Long fsUserId) {
|
|
|
+ if (fsUserId == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ qwSopLogsMapper.updateQwSopLogsByBlacklistedFsUserId(fsUserId, FS_USER_BLACKLIST_REMARK);
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean isFsUserBlacklisted(Long fsUserId) {
|
|
|
+ if (fsUserId == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ FsUser fsUser = fsUserMapper.selectFsUserByUserId(fsUserId);
|
|
|
+ return fsUser != null && fsUser.getManageStatus() != null && fsUser.getManageStatus() == 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void markSopLogAsBlacklisted(QwSopLogs sopLogs) {
|
|
|
+ sopLogs.setSendStatus(5L);
|
|
|
+ sopLogs.setReceivingStatus(4L);
|
|
|
+ sopLogs.setRemark(FS_USER_BLACKLIST_REMARK);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<QwSopLogsDoSendListTVO> expiredMessagesByQwSopLogs() {
|
|
|
return qwSopLogsMapper.getExpiredMessagesByQwSopLogs();
|