|
@@ -4,6 +4,7 @@ import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.fs.common.BeanCopyUtils;
|
|
|
import com.fs.common.core.domain.R;
|
|
@@ -214,28 +215,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
return fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(videoId);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public FsUserCourseVideoQVO selectFsUserCourseVideoByVideoIdVO(Long videoId,Long userId) {
|
|
|
- FsUserCourseVideoQVO fsUserCourseVideoQVO=new FsUserCourseVideoQVO();
|
|
|
- FsUserCourseVideo courseVideo = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoIdAndUserId(videoId,userId);
|
|
|
-
|
|
|
- BeanCopyUtils.copy(courseVideo,fsUserCourseVideoQVO);
|
|
|
- if (courseVideo.getRedPacketMoney()!=null){
|
|
|
- fsUserCourseVideoQVO.setRedPacketMoney(courseVideo.getRedPacketMoney().toString());
|
|
|
- }
|
|
|
- if (StringUtils.isNotEmpty(courseVideo.getQuestionBankId())){
|
|
|
- List<FsCourseQuestionBank> fsCourseQuestionBanks = courseQuestionBankMapper.selectFsCourseQuestionBankByIdVO(courseVideo.getQuestionBankId().split(","));
|
|
|
- fsUserCourseVideoQVO.setQuestionBankList(fsCourseQuestionBanks);
|
|
|
- }
|
|
|
- //返回课程关联的拍商品
|
|
|
- if(courseVideo.getIsProduct() != null && courseVideo.getIsProduct() == 1 && courseVideo.getProductId() != null){
|
|
|
- FsCourseProduct courseProduct = courseProductMapper.selectFsCourseProductById(courseVideo.getProductId());
|
|
|
- List<FsCourseProduct> courseProducts = Arrays.asList(courseProduct);
|
|
|
- fsUserCourseVideoQVO.setCourseProducts(courseProducts);
|
|
|
- }
|
|
|
- return fsUserCourseVideoQVO;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 查询课堂视频列表
|
|
|
*
|
|
@@ -902,14 +881,14 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
if (log.getRewardType() != null) {
|
|
|
FsCourseRedPacketLog packetLog = redPacketLogMapper.selectFsCourseRedPacketLogByTemporary(param.getVideoId(), param.getUserId());
|
|
|
if(packetLog != null && packetLog.getStatus() == 1) {
|
|
|
- return R.error("奖励已发放");
|
|
|
+ return R.error("已领取该课程奖励,不可重复领取!");
|
|
|
}
|
|
|
if(packetLog != null && packetLog.getStatus() == 0) {
|
|
|
if(StringUtils.isNotEmpty(packetLog.getResult())){
|
|
|
R r = JSON.parseObject(packetLog.getResult(), R.class);
|
|
|
return r;
|
|
|
} else {
|
|
|
- return R.error("奖励已发放");
|
|
|
+ return R.error("操作频繁,请稍后再试!");
|
|
|
}
|
|
|
}
|
|
|
if(packetLog != null && packetLog.getStatus() == 2) {
|
|
@@ -950,14 +929,14 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
if (log.getRewardType() != null) {
|
|
|
FsCourseRedPacketLog fsCourseRedPacketLog = redPacketLogMapper.selectUserFsCourseRedPacketLog(param.getVideoId(), param.getUserId(),param.getPeriodId());
|
|
|
if(fsCourseRedPacketLog != null && fsCourseRedPacketLog.getStatus() == 1) {
|
|
|
- return R.error("奖励已发放");
|
|
|
+ return R.error("已领取该课程奖励,不可重复领取!");
|
|
|
}
|
|
|
if(fsCourseRedPacketLog != null && fsCourseRedPacketLog.getStatus() == 0) {
|
|
|
if(StringUtils.isNotEmpty(fsCourseRedPacketLog.getResult())){
|
|
|
R r = JSON.parseObject(fsCourseRedPacketLog.getResult(), R.class);
|
|
|
return r;
|
|
|
} else {
|
|
|
- return R.error();
|
|
|
+ return R.error("操作频繁,请稍后再试!");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1185,6 +1164,9 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
|
|
|
System.out.println("红包金额"+amount);
|
|
|
System.out.println("红包商户号"+packetParam);
|
|
|
+ if (ObjectUtils.isNotEmpty(config.getIsNegative())&&config.getIsNegative() == 1) {
|
|
|
+ return processRedPacket(config, packetParam, param, amount, log);
|
|
|
+ }
|
|
|
//2025.6.19 红包金额为0的时候
|
|
|
if (amount.compareTo(BigDecimal.ZERO)>0){
|
|
|
|
|
@@ -1197,13 +1179,14 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
redPacketLog.setCompanyId(param.getCompanyId());
|
|
|
redPacketLog.setUserId(param.getUserId());
|
|
|
redPacketLog.setVideoId(param.getVideoId());
|
|
|
- redPacketLog.setStatus(2);
|
|
|
+ redPacketLog.setStatus(0);
|
|
|
redPacketLog.setQwUserId(param.getQwUserId() != null ? param.getQwUserId() : null);
|
|
|
redPacketLog.setCompanyUserId(param.getCompanyUserId());
|
|
|
redPacketLog.setCreateTime(new Date());
|
|
|
redPacketLog.setAmount(amount);
|
|
|
redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
|
|
|
redPacketLog.setPeriodId(param.getPeriodId());
|
|
|
+ redPacketLog.setAppId(param.getAppId());
|
|
|
redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
return R.error("销售公司余额不足");
|
|
|
}
|
|
@@ -1232,6 +1215,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
redPacketLog.setAmount(amount);
|
|
|
redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
|
|
|
redPacketLog.setPeriodId(param.getPeriodId());
|
|
|
+ redPacketLog.setAppId(param.getAppId());
|
|
|
redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
|
|
|
// 更新观看记录的奖励类型
|
|
@@ -1268,6 +1252,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
redPacketLog.setAmount(BigDecimal.ZERO);
|
|
|
redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
|
|
|
redPacketLog.setPeriodId(param.getPeriodId());
|
|
|
+ redPacketLog.setAppId(param.getAppId());
|
|
|
redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
|
|
|
// 更新观看记录的奖励类型
|
|
@@ -1280,6 +1265,64 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 直接发送奖励
|
|
|
+ *
|
|
|
+ * @param config
|
|
|
+ * @param packetParam
|
|
|
+ * @param param
|
|
|
+ * @param amount
|
|
|
+ * @param log
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private R processRedPacket(CourseConfig config, WxSendRedPacketParam packetParam, FsCourseSendRewardUParam param, BigDecimal amount, FsCourseWatchLog log) {
|
|
|
+ R sendRedPacket = paymentService.sendRedPacket(packetParam);
|
|
|
+
|
|
|
+ if (!sendRedPacket.get("code").equals(200)) {
|
|
|
+ return R.error("奖励发送失败,请联系客服");
|
|
|
+ }
|
|
|
+
|
|
|
+ createRedPacketLog(sendRedPacket, param, amount, log);
|
|
|
+ updateWatchLogRewardType(log, config);
|
|
|
+
|
|
|
+ return sendRedPacket;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void createRedPacketLog(R sendRedPacket, FsCourseSendRewardUParam param, BigDecimal amount, FsCourseWatchLog log) {
|
|
|
+ FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog();
|
|
|
+
|
|
|
+ // Set common fields
|
|
|
+ redPacketLog.setCourseId(param.getCourseId());
|
|
|
+ redPacketLog.setCompanyId(param.getCompanyId());
|
|
|
+ redPacketLog.setUserId(param.getUserId());
|
|
|
+ redPacketLog.setVideoId(param.getVideoId());
|
|
|
+ redPacketLog.setStatus(0);
|
|
|
+ redPacketLog.setQwUserId(param.getQwUserId());
|
|
|
+ redPacketLog.setCompanyUserId(param.getCompanyUserId());
|
|
|
+ redPacketLog.setCreateTime(new Date());
|
|
|
+ redPacketLog.setAmount(amount);
|
|
|
+ redPacketLog.setWatchLogId(log != null ? log.getLogId() : null);
|
|
|
+ redPacketLog.setPeriodId(param.getPeriodId());
|
|
|
+ redPacketLog.setAppId(param.getAppId());
|
|
|
+
|
|
|
+ // Set batch number based on isNew flag
|
|
|
+ if (sendRedPacket.get("isNew").equals(1)) {
|
|
|
+ TransferBillsResult transferBillsResult = (TransferBillsResult) sendRedPacket.get("data");
|
|
|
+ redPacketLog.setResult(JSON.toJSONString(sendRedPacket));
|
|
|
+ redPacketLog.setOutBatchNo(transferBillsResult.getOutBillNo());
|
|
|
+ } else {
|
|
|
+ redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateWatchLogRewardType(FsCourseWatchLog log, CourseConfig config) {
|
|
|
+ if (log != null) {
|
|
|
+ log.setRewardType(config.getRewardType());
|
|
|
+ courseWatchLogMapper.updateFsCourseWatchLog(log);
|
|
|
+ }
|
|
|
+ }
|
|
|
/**
|
|
|
* 获取用户openId
|
|
|
*
|