|
@@ -11,6 +11,7 @@ import com.fs.common.BeanCopyUtils;
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.ResponseResult;
|
|
import com.fs.common.core.domain.ResponseResult;
|
|
import com.fs.common.core.redis.RedisCache;
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
|
+import com.fs.common.enums.BizResponseEnum;
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
@@ -71,6 +72,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
|
+import java.time.Instant;
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.ZoneId;
|
|
import java.time.ZoneId;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -1077,64 +1079,102 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
return ResponseResult.fail(405,"当前销售不存在");
|
|
return ResponseResult.fail(405,"当前销售不存在");
|
|
}
|
|
}
|
|
|
|
|
|
- //判断:1、如果没有绑定销售,就提示;
|
|
|
|
|
|
+ //判断:1、如果没有绑定销售,就返回给客服的微信图片;
|
|
//2、如果只绑定了当前销售,需要添加看课记录(正常流程);
|
|
//2、如果只绑定了当前销售,需要添加看课记录(正常流程);
|
|
//3、以上都不是,则标识重粉,需要加入关系表,并打上重粉标签
|
|
//3、以上都不是,则标识重粉,需要加入关系表,并打上重粉标签
|
|
if(fsUser.getCompanyUserId() == null) {
|
|
if(fsUser.getCompanyUserId() == null) {
|
|
- return ResponseResult.fail(503, "暂时未绑定销售,请联系管理员");
|
|
|
|
- }
|
|
|
|
- if(companyUser.getUserId().equals(fsUser.getCompanyUserId())){
|
|
|
|
- //查询看课记录
|
|
|
|
- FsCourseWatchLog log = new FsCourseWatchLog();
|
|
|
|
- log.setUserId(param.getUserId());
|
|
|
|
- log.setCompanyUserId(param.getCompanyUserId());
|
|
|
|
- log.setVideoId(param.getVideoId());
|
|
|
|
- List<FsCourseWatchLog> fsCourseWatchLogs = courseWatchLogMapper.selectFsCourseWatchLogList(log);
|
|
|
|
-
|
|
|
|
- // 获取课程所属项目id
|
|
|
|
- FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(param.getCourseId());
|
|
|
|
- Long courseProject = null;
|
|
|
|
- if(fsUserCourse != null){
|
|
|
|
- courseProject = fsUserCourse.getProject();
|
|
|
|
- }
|
|
|
|
- //如果存在,则更新
|
|
|
|
- if (fsCourseWatchLogs != null && !fsCourseWatchLogs.isEmpty()){
|
|
|
|
- FsCourseWatchLog updateLog = new FsCourseWatchLog();
|
|
|
|
- updateLog.setPeriodId(param.getPeriodId());
|
|
|
|
- updateLog.setProject(courseProject);
|
|
|
|
- updateLog.setUpdateTime(new Date());
|
|
|
|
- courseWatchLogMapper.updateFsCourseWatchLog(updateLog);
|
|
|
|
- } else {
|
|
|
|
- //如果是会员,则需要添加看课记录
|
|
|
|
- FsCourseWatchLog fsCourseWatchLog = new FsCourseWatchLog();
|
|
|
|
- BeanUtils.copyProperties(param, fsCourseWatchLog);
|
|
|
|
- fsCourseWatchLog.setSendType(1);
|
|
|
|
- fsCourseWatchLog.setDuration(0L);
|
|
|
|
- fsCourseWatchLog.setCreateTime(new Date());
|
|
|
|
- fsCourseWatchLog.setLogType(1);
|
|
|
|
- fsCourseWatchLog.setProject(courseProject);
|
|
|
|
- courseWatchLogMapper.insertFsCourseWatchLog(fsCourseWatchLog);
|
|
|
|
|
|
+ return ResponseResult.fail(BizResponseEnum.DATA_NOT_EXIST, getCompanyUserQRCode(companyUser));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 逻辑调整:如果会员已经绑定了销售,直接提示,不添加重粉数据了-2025年6月16日14点53分
|
|
|
|
+ if (fsUser.getCompanyUserId() != null && !param.getCompanyUserId().equals(fsUser.getCompanyUserId())){
|
|
|
|
+ return ResponseResult.fail(406,"该用户已成为其他销售会员");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 如果开启了黑名单审核,需要提示
|
|
|
|
+ if(fsUser.getStatus() == 0) {
|
|
|
|
+// return ResponseResult.fail(505, "管理开启了会员审核,请等待审核");
|
|
|
|
+ return ResponseResult.fail(BizResponseEnum.WAIT_APPROVAL,getCompanyUserQRCode(companyUser));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //查询看课记录
|
|
|
|
+// FsCourseWatchLog watchCourseVideo = courseWatchLogMapper.getWatchCourseVideoByFsUser(param.getUserId(), param.getVideoId(), param.getCompanyUserId());
|
|
|
|
+ FsCourseWatchLog watchCourseVideo = courseWatchLogMapper.getCourseWatchLogByUser(param.getUserId(), param.getVideoId());
|
|
|
|
+ // 获取课程所属项目id
|
|
|
|
+ FsUserCourse fsUserCourse = fsUserCourseMapper.selectFsUserCourseByCourseId(param.getCourseId());
|
|
|
|
+ Long courseProject = null;
|
|
|
|
+ if(fsUserCourse != null){
|
|
|
|
+ courseProject = fsUserCourse.getProject();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //添加判断:该用户是否已经存在此课程的看课记录,并且看课记录的销售id不是传入的销售id
|
|
|
|
+ if(watchCourseVideo != null){
|
|
|
|
+ if(!watchCourseVideo.getCompanyUserId().equals(param.getCompanyUserId())) {
|
|
|
|
+ //提示
|
|
|
|
+ return ResponseResult.fail(504, "已看过其他销售分享的此课程,不能重复观看");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ FsCourseWatchLog updateLog = new FsCourseWatchLog();
|
|
|
|
+ updateLog.setPeriodId(param.getPeriodId());
|
|
|
|
+ updateLog.setProject(courseProject);
|
|
|
|
+ updateLog.setUpdateTime(new Date());
|
|
|
|
+ courseWatchLogMapper.updateFsCourseWatchLog(updateLog);
|
|
} else {
|
|
} else {
|
|
- FsUserCompanyUser fsUserCompanyUser = new FsUserCompanyUser();
|
|
|
|
|
|
+ FsCourseWatchLog fsCourseWatchLog = new FsCourseWatchLog();
|
|
|
|
+ BeanUtils.copyProperties(param, fsCourseWatchLog);
|
|
|
|
+ fsCourseWatchLog.setSendType(1);
|
|
|
|
+ fsCourseWatchLog.setDuration(0L);
|
|
|
|
+ fsCourseWatchLog.setCreateTime(new Date());
|
|
|
|
+ fsCourseWatchLog.setLogType(1);
|
|
|
|
+ fsCourseWatchLog.setProject(courseProject);
|
|
|
|
+ courseWatchLogMapper.insertFsCourseWatchLog(fsCourseWatchLog);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 添加会员销售关系表数据
|
|
|
|
+ // 逻辑调整:如果会员已经绑定了销售,直接提示,不添加重粉数据了-2025年6月16日14点58分
|
|
|
|
+ FsUserCompanyUser fsUserCompanyUser = getFsUserCompanyUser(param, fsUser);
|
|
|
|
+ QueryWrapper<FsUserCompanyUser> queryWrapper = new QueryWrapper<FsUserCompanyUser>().eq("user_id", param.getUserId()).eq("company_user_id", param.getCompanyUserId());
|
|
|
|
+ Integer i = fsUserCompanyUserMapper.selectCount(queryWrapper);
|
|
|
|
+ if(i == 0) {
|
|
|
|
+ fsUserCompanyUserMapper.insertFsUserCompanyUser(fsUserCompanyUser);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// // 如果重粉需要打上重粉标签
|
|
|
|
+// if(1 == fsUserCompanyUser.getIsRepeatFans()){
|
|
|
|
+// FsUserCourseBeMemberParam fsUserCourseBeMemberParam = new FsUserCourseBeMemberParam();
|
|
|
|
+// fsUserCourseBeMemberParam.setUserId(param.getUserId());
|
|
|
|
+// fsUserCourseBeMemberParam.setCompanyId(param.getCompanyId());
|
|
|
|
+// fsUserCourseBeMemberParam.setCompanyUserId(param.getCompanyUserId());
|
|
|
|
+// fsUserService.setRepeatFansTag(fsUserCourseBeMemberParam);
|
|
|
|
+// }
|
|
|
|
+ return ResponseResult.ok(Boolean.TRUE);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 添加关系表数据
|
|
|
|
+ public static FsUserCompanyUser getFsUserCompanyUser(FsUserCourseAddCompanyUserParam param, FsUser fsUser) {
|
|
|
|
+ FsUserCompanyUser fsUserCompanyUser = new FsUserCompanyUser();
|
|
|
|
+ // 判断是否绑定了销售,如果已绑定,则需要标识为重粉,且放黑名单
|
|
|
|
+ if (fsUser.getCompanyUserId() != null && !fsUser.getCompanyUserId().equals(param.getCompanyUserId())) {
|
|
fsUserCompanyUser.setIsRepeatFans(1);
|
|
fsUserCompanyUser.setIsRepeatFans(1);
|
|
- fsUserCompanyUser.setUserId(param.getUserId());
|
|
|
|
- fsUserCompanyUser.setCompanyId(param.getCompanyId());
|
|
|
|
- fsUserCompanyUser.setCompanyUserId(param.getCompanyUserId());
|
|
|
|
- QueryWrapper<FsUserCompanyUser> queryWrapper = new QueryWrapper<FsUserCompanyUser>().eq("user_id", param.getUserId()).eq("company_user_id", param.getCompanyUserId());
|
|
|
|
- Integer i = fsUserCompanyUserMapper.selectCount(queryWrapper);
|
|
|
|
- if(i == 0) {
|
|
|
|
- fsUserCompanyUserMapper.insertFsUserCompanyUser(fsUserCompanyUser);
|
|
|
|
- }
|
|
|
|
|
|
+ } else {
|
|
|
|
+ fsUserCompanyUser.setIsRepeatFans(0);
|
|
|
|
+ }
|
|
|
|
+ fsUserCompanyUser.setUserId(param.getUserId());
|
|
|
|
+ fsUserCompanyUser.setCompanyId(param.getCompanyId());
|
|
|
|
+ fsUserCompanyUser.setCompanyUserId(param.getCompanyUserId());
|
|
|
|
+ return fsUserCompanyUser;
|
|
|
|
+ }
|
|
|
|
|
|
- // 打上重粉标签
|
|
|
|
- FsUserCourseBeMemberParam fsUserCourseBeMemberParam = new FsUserCourseBeMemberParam();
|
|
|
|
- fsUserCourseBeMemberParam.setUserId(param.getUserId());
|
|
|
|
- fsUserCourseBeMemberParam.setCompanyId(param.getCompanyId());
|
|
|
|
- fsUserCourseBeMemberParam.setCompanyUserId(param.getCompanyUserId());
|
|
|
|
- fsUserService.setRepeatFansTag(fsUserCourseBeMemberParam);
|
|
|
|
|
|
+ private String getCompanyUserQRCode(CompanyUser companyUser) {
|
|
|
|
+ String companyUserQRCode;
|
|
|
|
+ if(StringUtils.isNotEmpty(companyUser.getQrCodeWeixin())){
|
|
|
|
+ companyUserQRCode = companyUser.getQrCodeWeixin();
|
|
|
|
+ } else {
|
|
|
|
+ String json = configService.selectConfigByKey("course.config");
|
|
|
|
+ CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
|
|
|
|
+ companyUserQRCode = config.getCompanyUserQRCode();
|
|
}
|
|
}
|
|
- return ResponseResult.ok(Boolean.TRUE);
|
|
|
|
|
|
+ return companyUserQRCode;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1158,8 +1198,17 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
ResponseResult<FsUserCourseVideoDetailsVO> videoDetails = this.getVideoDetails(param.getVideoId());
|
|
ResponseResult<FsUserCourseVideoDetailsVO> videoDetails = this.getVideoDetails(param.getVideoId());
|
|
FsUserCourseVideoDetailsVO courseVideoDetails = videoDetails.getData() != null ? videoDetails.getData() : null;
|
|
FsUserCourseVideoDetailsVO courseVideoDetails = videoDetails.getData() != null ? videoDetails.getData() : null;
|
|
|
|
|
|
- Long duration = 0L;
|
|
|
|
|
|
+ //课程logo
|
|
|
|
+ if (param.getPeriodId()!=null){
|
|
|
|
+ FsUserCoursePeriod fsUserCoursePeriod = fsUserCoursePeriodMapper.selectFsUserCoursePeriodById(param.getPeriodId());
|
|
|
|
+ if (fsUserCoursePeriod!=null){
|
|
|
|
+ config.setCourseLogo(fsUserCoursePeriod.getCourseLogo());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ long duration = 0L;
|
|
long tipsTime = 0L;
|
|
long tipsTime = 0L;
|
|
|
|
+ long tipsTime2 = 0L;
|
|
int isFinish = 0;
|
|
int isFinish = 0;
|
|
FsUserCourseVideoLinkDetailsVO vo = new FsUserCourseVideoLinkDetailsVO();
|
|
FsUserCourseVideoLinkDetailsVO vo = new FsUserCourseVideoLinkDetailsVO();
|
|
vo.setCourseVideoDetails(courseVideoDetails);
|
|
vo.setCourseVideoDetails(courseVideoDetails);
|
|
@@ -1183,9 +1232,12 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
duration = Objects.isNull(watchLog) ? 0 : watchLog.getDuration();
|
|
duration = Objects.isNull(watchLog) ? 0 : watchLog.getDuration();
|
|
}
|
|
}
|
|
//
|
|
//
|
|
-// if (course.getDuration()!=null){
|
|
|
|
-// tipsTime = course.getDuration()/2;
|
|
|
|
-// }
|
|
|
|
|
|
+ if (courseVideoDetails != null && courseVideoDetails.getDuration() != null){
|
|
|
|
+ tipsTime = courseVideoDetails.getDuration() / 3;
|
|
|
|
+ tipsTime2 = (courseVideoDetails.getDuration() * 2) / 3;
|
|
|
|
+ }
|
|
|
|
+ vo.setTipsTime(tipsTime);
|
|
|
|
+ vo.setTipsTime2(tipsTime2);
|
|
//判断是否完课
|
|
//判断是否完课
|
|
if (watchLog!=null && watchLog.getLogType() == 2) {
|
|
if (watchLog!=null && watchLog.getLogType() == 2) {
|
|
isFinish = 1;
|
|
isFinish = 1;
|
|
@@ -1202,9 +1254,43 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
//判断营期的课程状态是否是进行中
|
|
//判断营期的课程状态是否是进行中
|
|
if(param.getId() != null){
|
|
if(param.getId() != null){
|
|
FsUserCoursePeriodDays days = fsUserCoursePeriodDaysMapper.selectById(param.getId());
|
|
FsUserCoursePeriodDays days = fsUserCoursePeriodDaysMapper.selectById(param.getId());
|
|
- vo.setStartDateTime(days.getStartDateTime());
|
|
|
|
- vo.setEndDateTime(days.getEndDateTime());
|
|
|
|
- vo.setRang(DateUtil.isWithinRangeSafe(LocalDateTime.now(), days.getStartDateTime(), days.getEndDateTime()) && days.getStatus() == 1);
|
|
|
|
|
|
+
|
|
|
|
+ // 查询销售设置的看课时间
|
|
|
|
+ LocalDateTime companyUserStartDateTime = null;
|
|
|
|
+ LocalDateTime companyUserEndDateTime = null;
|
|
|
|
+
|
|
|
|
+ List<CompanyUserTimeQueryParam> queryList = new ArrayList<>();
|
|
|
|
+ CompanyUserTimeQueryParam query = new CompanyUserTimeQueryParam();
|
|
|
|
+ query.setPeriodId(param.getPeriodId());
|
|
|
|
+ query.setCourseId(param.getCourseId());
|
|
|
|
+ query.setVideoId(param.getVideoId());
|
|
|
|
+ query.setCompanyUserId(param.getCompanyUserId());
|
|
|
|
+ queryList.add(query);
|
|
|
|
+ List<FsUserCourseCompanyUserTime> fsUserCourseCompanyUserTimes = companyUserTimeMapper.batchSelectByParams(queryList);
|
|
|
|
+
|
|
|
|
+ if(CollectionUtils.isNotEmpty(fsUserCourseCompanyUserTimes)){
|
|
|
|
+ FsUserCourseCompanyUserTime fsUserCourseCompanyUserTime = fsUserCourseCompanyUserTimes.get(0);
|
|
|
|
+ Date cuStartDateTime = fsUserCourseCompanyUserTime.getStartDateTime();
|
|
|
|
+ Date cuEndDateTime = fsUserCourseCompanyUserTime.getEndDateTime();
|
|
|
|
+
|
|
|
|
+ if(cuStartDateTime != null){
|
|
|
|
+ Instant instant = cuStartDateTime.toInstant();
|
|
|
|
+ ZoneId zoneId = ZoneId.systemDefault();
|
|
|
|
+ companyUserStartDateTime = instant.atZone(zoneId).toLocalDateTime();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(cuEndDateTime != null){
|
|
|
|
+ Instant instant = cuEndDateTime.toInstant();
|
|
|
|
+ ZoneId zoneId = ZoneId.systemDefault();
|
|
|
|
+ companyUserEndDateTime = instant.atZone(zoneId).toLocalDateTime();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ vo.setStartDateTime(companyUserStartDateTime != null ? companyUserStartDateTime : days.getStartDateTime());
|
|
|
|
+ vo.setEndDateTime(companyUserEndDateTime != null ? companyUserEndDateTime : days.getEndDateTime());
|
|
|
|
+ vo.setRang(DateUtil.isWithinRangeSafe(LocalDateTime.now(),
|
|
|
|
+ companyUserStartDateTime != null ? companyUserStartDateTime : days.getStartDateTime(),
|
|
|
|
+ companyUserEndDateTime != null ? companyUserEndDateTime : days.getEndDateTime())
|
|
|
|
+ && days.getStatus() == 1);
|
|
}
|
|
}
|
|
return ResponseResult.ok(vo);
|
|
return ResponseResult.ok(vo);
|
|
}
|
|
}
|