|
@@ -5,6 +5,7 @@ import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.fs.common.BeanCopyUtils;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
+import com.fs.common.core.domain.ResponseResult;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
@@ -18,7 +19,9 @@ import com.fs.course.service.IFsUserCourseVideoService;
|
|
|
import com.fs.course.vo.FsUserCourseVideoListUVO;
|
|
|
import com.fs.course.vo.FsUserCourseVideoQVO;
|
|
|
import com.fs.course.vo.FsUserCourseVideoVO;
|
|
|
+import com.fs.course.vo.newfs.FsUserCourseVideoDetailsVO;
|
|
|
import com.fs.course.vo.newfs.FsUserCourseVideoPageListVO;
|
|
|
+import com.fs.course.vo.newfs.FsUserVideoQuestionVO;
|
|
|
import com.fs.his.param.WxSendRedPacketParam;
|
|
|
import com.fs.store.domain.FsUser;
|
|
|
import com.fs.store.domain.FsUserIntegralLogs;
|
|
@@ -45,9 +48,11 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 课堂视频Service业务层处理
|
|
@@ -606,10 +611,10 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
return R.error("参数错误!");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 发放红包奖励
|
|
|
- *
|
|
|
+ *
|
|
|
* @param param 请求参数
|
|
|
* @param user 用户信息
|
|
|
* @param log 观看日志
|
|
@@ -621,13 +626,13 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
// 确定红包金额
|
|
|
BigDecimal amount = BigDecimal.ZERO;
|
|
|
FsUserCourseVideoRedPackage redPackage = fsUserCourseVideoRedPackageMapper.selectRedPacketByCompanyId(param.getVideoId(), param.getCompanyId());
|
|
|
-
|
|
|
+
|
|
|
if (redPackage != null) {
|
|
|
amount = redPackage.getRedPacketMoney();
|
|
|
} else if (video != null) {
|
|
|
amount = new BigDecimal(video.getRedPacketMoney());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 准备发送红包参数
|
|
|
WxSendRedPacketParam packetParam = new WxSendRedPacketParam();
|
|
|
packetParam.setOpenId(user.getMpOpenId());
|
|
@@ -637,7 +642,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
}
|
|
|
packetParam.setAmount(amount);
|
|
|
packetParam.setSource(param.getSource());
|
|
|
-
|
|
|
+
|
|
|
// 发送红包
|
|
|
R sendRedPacket = paymentService.sendRedPacket(packetParam);
|
|
|
if (sendRedPacket.get("code").equals(200)) {
|
|
@@ -655,7 +660,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
redPacketLog.setAmount(amount);
|
|
|
redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
|
|
|
redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
-
|
|
|
+
|
|
|
// 更新观看记录的奖励类型
|
|
|
if (param.getLinkType() == null || param.getLinkType() == 0) {
|
|
|
log.setRewardType(config.getRewardType());
|
|
@@ -666,10 +671,10 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
return R.error("奖励发送失败,请联系客服");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 发放积分奖励
|
|
|
- *
|
|
|
+ *
|
|
|
* @param user 用户信息
|
|
|
* @param log 观看日志
|
|
|
* @param config 配置信息
|
|
@@ -681,7 +686,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
userMap.setUserId(user.getUserId());
|
|
|
userMap.setIntegral(NumberUtil.add(user.getIntegral(), config.getAnswerIntegral()));
|
|
|
fsUserMapper.updateFsUser(userMap);
|
|
|
-
|
|
|
+
|
|
|
// 记录积分日志
|
|
|
FsUserIntegralLogs integralLogs = new FsUserIntegralLogs();
|
|
|
integralLogs.setIntegral(new BigDecimal(config.getAnswerIntegral()));
|
|
@@ -691,7 +696,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
integralLogs.setBusinessId(StringUtils.isNotEmpty(log.getLogId().toString()) ? log.getLogId().toString() : null);
|
|
|
integralLogs.setCreateTime(new Date());
|
|
|
fsUserIntegralLogsMapper.insertFsUserIntegralLogs(integralLogs);
|
|
|
-
|
|
|
+
|
|
|
return R.ok("奖励发放成功");
|
|
|
}
|
|
|
|
|
@@ -699,4 +704,27 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
public List<FsUserCourseVideoPageListVO> pageListCourseVideo(UserCourseVideoPageParam param) {
|
|
|
return fsUserCourseVideoMapper.selectFsUserCourseVideoPageList(param);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResponseResult<FsUserCourseVideoDetailsVO> getVideoDetails(Long videoId) {
|
|
|
+ FsUserCourseVideo fsUserCourseVideo = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(videoId);
|
|
|
+ FsUserCourseVideoDetailsVO fsUserCourseVideoDetailsVO = new FsUserCourseVideoDetailsVO();
|
|
|
+ BeanUtils.copyProperties(fsUserCourseVideo, fsUserCourseVideoDetailsVO);
|
|
|
+
|
|
|
+ // 获取课程相关的题库
|
|
|
+ String questionBankId = fsUserCourseVideo.getQuestionBankId();
|
|
|
+ List<FsUserVideoQuestionVO> questionList = Collections.emptyList();
|
|
|
+ if (StringUtils.isNotEmpty(questionBankId)) {
|
|
|
+ String[] questionBankIds = questionBankId.split(",");
|
|
|
+ List<FsCourseQuestionBank> fsCourseQuestionBanks = courseQuestionBankMapper.selectFsCourseQuestionBankByIdVO(questionBankIds);
|
|
|
+ questionList = fsCourseQuestionBanks.stream().map(v -> {
|
|
|
+ FsUserVideoQuestionVO fsUserVideoQuestionVO = new FsUserVideoQuestionVO();
|
|
|
+ BeanUtils.copyProperties(v, fsUserVideoQuestionVO);
|
|
|
+ return fsUserVideoQuestionVO;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ fsUserCourseVideoDetailsVO.setQuestionBankList(questionList);
|
|
|
+ return ResponseResult.ok(fsUserCourseVideoDetailsVO);
|
|
|
+ }
|
|
|
}
|