|
|
@@ -9,6 +9,7 @@ import com.fs.course.mapper.FsUserCourseMapper;
|
|
|
import com.fs.course.mapper.FsUserCourseVideoMapper;
|
|
|
import com.fs.course.param.FsUserCourseVideoAddKfUParam;
|
|
|
import com.fs.course.service.ICourseRepeatByProjectService;
|
|
|
+import com.fs.course.support.CourseProjectEquivalence;
|
|
|
import com.fs.course.service.IFsUserCompanyBindService;
|
|
|
import com.fs.course.service.IFsUserCompanyUserService;
|
|
|
import com.fs.his.domain.FsUser;
|
|
|
@@ -57,12 +58,13 @@ public class CourseRepeatByProjectServiceImpl implements ICourseRepeatByProjectS
|
|
|
log.debug("看课重粉判断跳过:课程未关联项目,userId={}", param.getUserId());
|
|
|
return;
|
|
|
}
|
|
|
- boolean projectRepeat = isRepeatWatchByProject(param, projectId);
|
|
|
+ List<Long> equivalentProjectIds = CourseProjectEquivalence.equivalentProjectIds(projectId);
|
|
|
+ boolean projectRepeat = isRepeatWatchByProject(param, equivalentProjectIds);
|
|
|
boolean userAlreadyRepeat = fsUser.getIsRepeat() != null && fsUser.getIsRepeat() == 1;
|
|
|
- log.info("看课重粉判断(按项目):userId={}, projectId={}, projectRepeat={}, userAlreadyRepeat={}",
|
|
|
- param.getUserId(), projectId, projectRepeat, userAlreadyRepeat);
|
|
|
+ log.info("看课重粉判断(按项目):userId={}, projectId={}, equivalentProjectIds={}, projectRepeat={}, userAlreadyRepeat={}",
|
|
|
+ param.getUserId(), projectId, equivalentProjectIds, projectRepeat, userAlreadyRepeat);
|
|
|
if (projectRepeat || userAlreadyRepeat) {
|
|
|
- markRepeatFansByProject(fsUser, param, projectId);
|
|
|
+ markRepeatFansByProject(fsUser, param, equivalentProjectIds);
|
|
|
return;
|
|
|
}
|
|
|
if (param.getQwExternalId() != null) {
|
|
|
@@ -89,32 +91,39 @@ public class CourseRepeatByProjectServiceImpl implements ICourseRepeatByProjectS
|
|
|
return 0L;
|
|
|
}
|
|
|
|
|
|
- private boolean isRepeatWatchByProject(FsUserCourseVideoAddKfUParam param, Long projectId) {
|
|
|
+ private boolean isRepeatWatchByProject(FsUserCourseVideoAddKfUParam param, List<Long> equivalentProjectIds) {
|
|
|
+ if (CollectionUtils.isEmpty(equivalentProjectIds)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
Long userId = param.getUserId();
|
|
|
Long currentCompanyUserId = param.getCompanyUserId();
|
|
|
Long currentQwUserId = parseQwUserId(param.getQwUserId());
|
|
|
|
|
|
- FsUserCompanyQw existBind = fsUserCompanyQwMapper.selectByUserAndProject(userId, projectId);
|
|
|
- if (existBind != null) {
|
|
|
- if (currentCompanyUserId != null && existBind.getCompanyUserId() != null
|
|
|
- && !existBind.getCompanyUserId().equals(currentCompanyUserId)) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- if (currentQwUserId != null && existBind.getQwUserId() != null
|
|
|
- && !existBind.getQwUserId().equals(currentQwUserId)) {
|
|
|
- return true;
|
|
|
+ for (Long projectId : equivalentProjectIds) {
|
|
|
+ FsUserCompanyQw existBind = fsUserCompanyQwMapper.selectByUserAndProject(userId, projectId);
|
|
|
+ if (existBind != null) {
|
|
|
+ if (currentCompanyUserId != null && existBind.getCompanyUserId() != null
|
|
|
+ && !existBind.getCompanyUserId().equals(currentCompanyUserId)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (currentQwUserId != null && existBind.getQwUserId() != null
|
|
|
+ && !existBind.getQwUserId().equals(currentQwUserId)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(userId, projectId);
|
|
|
- if (userCompanyUser != null && currentCompanyUserId != null
|
|
|
- && userCompanyUser.getCompanyUserId() != null
|
|
|
- && !userCompanyUser.getCompanyUserId().equals(currentCompanyUserId)) {
|
|
|
- return true;
|
|
|
+ for (Long projectId : equivalentProjectIds) {
|
|
|
+ FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(userId, projectId);
|
|
|
+ if (userCompanyUser != null && currentCompanyUserId != null
|
|
|
+ && userCompanyUser.getCompanyUserId() != null
|
|
|
+ && !userCompanyUser.getCompanyUserId().equals(currentCompanyUserId)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
List<FsUserCompanyBind> binds = fsUserCompanyBindService.list(
|
|
|
- new QueryWrapper<FsUserCompanyBind>().eq("fs_user_id", userId).eq("project_id", projectId));
|
|
|
+ new QueryWrapper<FsUserCompanyBind>().eq("fs_user_id", userId).in("project_id", equivalentProjectIds));
|
|
|
if (CollectionUtils.isNotEmpty(binds)) {
|
|
|
if (currentQwUserId != null && binds.stream().map(FsUserCompanyBind::getQwUserId).filter(Objects::nonNull)
|
|
|
.anyMatch(qwId -> !qwId.equals(currentQwUserId))) {
|
|
|
@@ -127,7 +136,7 @@ public class CourseRepeatByProjectServiceImpl implements ICourseRepeatByProjectS
|
|
|
}
|
|
|
|
|
|
QueryWrapper<FsCourseWatchLog> watchWrapper = new QueryWrapper<FsCourseWatchLog>()
|
|
|
- .eq("project", projectId)
|
|
|
+ .in("project", equivalentProjectIds)
|
|
|
.isNotNull("company_user_id");
|
|
|
watchWrapper.and(w -> {
|
|
|
w.eq("user_id", userId);
|
|
|
@@ -155,7 +164,7 @@ public class CourseRepeatByProjectServiceImpl implements ICourseRepeatByProjectS
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void markRepeatFansByProject(FsUser fsUser, FsUserCourseVideoAddKfUParam param, Long projectId) {
|
|
|
+ private void markRepeatFansByProject(FsUser fsUser, FsUserCourseVideoAddKfUParam param, List<Long> equivalentProjectIds) {
|
|
|
List<QwExternalContact> toUpdate = new ArrayList<>();
|
|
|
if (param.getQwExternalId() != null) {
|
|
|
QwExternalContact current = qwExternalContactMapper.selectById(param.getQwExternalId());
|
|
|
@@ -165,7 +174,7 @@ public class CourseRepeatByProjectServiceImpl implements ICourseRepeatByProjectS
|
|
|
}
|
|
|
}
|
|
|
List<FsUserCompanyBind> binds = fsUserCompanyBindService.list(
|
|
|
- new QueryWrapper<FsUserCompanyBind>().eq("fs_user_id", param.getUserId()).eq("project_id", projectId));
|
|
|
+ new QueryWrapper<FsUserCompanyBind>().eq("fs_user_id", param.getUserId()).in("project_id", equivalentProjectIds));
|
|
|
if (CollectionUtils.isNotEmpty(binds)) {
|
|
|
Set<Long> contactIds = binds.stream().map(FsUserCompanyBind::getQwExternalContactId)
|
|
|
.filter(Objects::nonNull).collect(Collectors.toSet());
|
|
|
@@ -193,10 +202,12 @@ public class CourseRepeatByProjectServiceImpl implements ICourseRepeatByProjectS
|
|
|
fsUser.setIsRepeat(1);
|
|
|
fsUserMapper.updateFsUser(fsUser);
|
|
|
}
|
|
|
- FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(param.getUserId(), projectId);
|
|
|
- if (userCompanyUser != null && (userCompanyUser.getIsRepeatFans() == null || userCompanyUser.getIsRepeatFans() != 1)) {
|
|
|
- userCompanyUser.setIsRepeatFans(1);
|
|
|
- userCompanyUserService.updateById(userCompanyUser);
|
|
|
+ for (Long projectId : equivalentProjectIds) {
|
|
|
+ FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(param.getUserId(), projectId);
|
|
|
+ if (userCompanyUser != null && (userCompanyUser.getIsRepeatFans() == null || userCompanyUser.getIsRepeatFans() != 1)) {
|
|
|
+ userCompanyUser.setIsRepeatFans(1);
|
|
|
+ userCompanyUserService.updateById(userCompanyUser);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|