|
|
@@ -31,6 +31,7 @@ import com.fs.company.mapper.*;
|
|
|
import com.fs.company.service.ICompanyService;
|
|
|
import com.fs.company.util.CompanyRedPacketBalanceUtil;
|
|
|
import com.fs.config.cloud.CloudHostProper;
|
|
|
+import com.fs.core.utils.OrderCodeUtils;
|
|
|
import com.fs.course.config.CourseConfig;
|
|
|
import com.fs.course.domain.*;
|
|
|
import com.fs.course.dto.CoursePackageDTO;
|
|
|
@@ -1201,10 +1202,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService {
|
|
|
return R.error("操作频繁,请稍后再试!");
|
|
|
}
|
|
|
}
|
|
|
- if (packetLog != null && packetLog.getStatus() == 2) {
|
|
|
- return R.error("请联系客服补发");
|
|
|
- }
|
|
|
- return R.error("奖励已发放");
|
|
|
}
|
|
|
// 获取视频信息
|
|
|
FsUserCourseVideo video = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(param.getVideoId());
|
|
|
@@ -1482,6 +1479,34 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ FsCourseRedPacketLog redPacketLog = redPacketLogMapper.selectFsCourseRedPacketLogByTemporary(param.getVideoId(), param.getUserId());
|
|
|
+ if (redPacketLog != null && redPacketLog.getStatus() != 2) {
|
|
|
+ return R.error("操作频繁,请稍后再试!");
|
|
|
+ } else {
|
|
|
+ // 添加红包记录
|
|
|
+ redPacketLog = new FsCourseRedPacketLog();
|
|
|
+ redPacketLog.setCourseId(param.getCourseId());
|
|
|
+ redPacketLog.setCompanyId(param.getCompanyId());
|
|
|
+ redPacketLog.setUserId(param.getUserId());
|
|
|
+ redPacketLog.setVideoId(param.getVideoId());
|
|
|
+ redPacketLog.setStatus(2);
|
|
|
+ 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());
|
|
|
+
|
|
|
+ String code = OrderCodeUtils.getOrderSn();
|
|
|
+ if (StringUtils.isEmpty(code)) {
|
|
|
+ return R.error("红包单号生成失败,请重试");
|
|
|
+ }
|
|
|
+ redPacketLog.setOutBatchNo("fsCourse"+cloudHostProper.getProjectCode() + code);
|
|
|
+
|
|
|
+ redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
+ }
|
|
|
+
|
|
|
+ packetParam.setOutBatchNo(redPacketLog.getOutBatchNo());
|
|
|
// 发送红包
|
|
|
R sendRedPacket;
|
|
|
try {
|
|
|
@@ -1492,29 +1517,20 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService {
|
|
|
}
|
|
|
|
|
|
if (sendRedPacket.get("code").equals(200)) {
|
|
|
- FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog();
|
|
|
TransferBillsResult transferBillsResult;
|
|
|
+ OffsetDateTime offsetDateTime;
|
|
|
if (sendRedPacket.get("isNew").equals(1)) {
|
|
|
transferBillsResult = (TransferBillsResult) sendRedPacket.get("data");
|
|
|
redPacketLog.setResult(JSON.toJSONString(sendRedPacket));
|
|
|
redPacketLog.setOutBatchNo(transferBillsResult.getOutBillNo());
|
|
|
+ offsetDateTime = OffsetDateTime.parse(transferBillsResult.getCreateTime());
|
|
|
} else {
|
|
|
redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
|
|
|
+ offsetDateTime = OffsetDateTime.parse(sendRedPacket.get("createTime").toString());
|
|
|
}
|
|
|
- // 添加红包记录
|
|
|
- redPacketLog.setCourseId(param.getCourseId());
|
|
|
- redPacketLog.setCompanyId(param.getCompanyId());
|
|
|
- redPacketLog.setUserId(param.getUserId());
|
|
|
- redPacketLog.setVideoId(param.getVideoId());
|
|
|
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());
|
|
|
-
|
|
|
- redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
+ redPacketLog.setCreateTime(Date.from(offsetDateTime.toInstant()));
|
|
|
+ redPacketLogMapper.updateFsCourseRedPacketLog(redPacketLog);
|
|
|
// 更新观看记录的奖励类型
|
|
|
log.setRewardType(config.getRewardType());
|
|
|
courseWatchLogMapper.updateFsCourseWatchLog(log);
|
|
|
@@ -1624,6 +1640,36 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ FsCourseRedPacketLog redPacketLog = redPacketLogMapper.selectUserFsCourseRedPacketLog(param.getVideoId(), param.getUserId(), param.getPeriodId());
|
|
|
+ if (redPacketLog != null && redPacketLog.getStatus() != 2) {
|
|
|
+ return R.error("操作频繁,请稍后再试!");
|
|
|
+ } else {
|
|
|
+ // 添加红包记录
|
|
|
+ redPacketLog = new FsCourseRedPacketLog();
|
|
|
+ redPacketLog.setCourseId(param.getCourseId());
|
|
|
+ redPacketLog.setCompanyId(param.getCompanyId());
|
|
|
+ redPacketLog.setUserId(param.getUserId());
|
|
|
+ redPacketLog.setVideoId(param.getVideoId());
|
|
|
+ redPacketLog.setStatus(2);
|
|
|
+ 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());
|
|
|
+
|
|
|
+ String code = OrderCodeUtils.getOrderSn();
|
|
|
+ if (StringUtils.isEmpty(code)) {
|
|
|
+ return R.error("红包单号生成失败,请重试");
|
|
|
+ }
|
|
|
+ redPacketLog.setOutBatchNo("fsCourse"+cloudHostProper.getProjectCode() + code);
|
|
|
+
|
|
|
+ redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
+ }
|
|
|
+
|
|
|
+ packetParam.setOutBatchNo(redPacketLog.getOutBatchNo());
|
|
|
+
|
|
|
// 发送红包
|
|
|
R sendRedPacket;
|
|
|
try {
|
|
|
@@ -1635,32 +1681,22 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService {
|
|
|
|
|
|
// 红包发送成功处理
|
|
|
if (sendRedPacket.get("code").equals(200)) {
|
|
|
- FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog();
|
|
|
TransferBillsResult transferBillsResult;
|
|
|
+ OffsetDateTime offsetDateTime;
|
|
|
if (sendRedPacket.get("isNew").equals(1)){
|
|
|
transferBillsResult = (TransferBillsResult)sendRedPacket.get("data");
|
|
|
redPacketLog.setResult(JSON.toJSONString(sendRedPacket));
|
|
|
redPacketLog.setOutBatchNo(transferBillsResult.getOutBillNo());
|
|
|
redPacketLog.setBatchId(transferBillsResult.getTransferBillNo());
|
|
|
+ offsetDateTime = OffsetDateTime.parse(transferBillsResult.getCreateTime());
|
|
|
}else {
|
|
|
redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
|
|
|
redPacketLog.setBatchId(sendRedPacket.get("batchId").toString());
|
|
|
+ offsetDateTime = OffsetDateTime.parse(sendRedPacket.get("createTime").toString());
|
|
|
}
|
|
|
- // 添加红包记录
|
|
|
- redPacketLog.setCourseId(param.getCourseId());
|
|
|
- redPacketLog.setCompanyId(param.getCompanyId());
|
|
|
- redPacketLog.setUserId(param.getUserId());
|
|
|
- redPacketLog.setVideoId(param.getVideoId());
|
|
|
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);
|
|
|
+ redPacketLog.setCreateTime(Date.from(offsetDateTime.toInstant()));
|
|
|
+ redPacketLogMapper.updateFsCourseRedPacketLog(redPacketLog);
|
|
|
|
|
|
// 更新观看记录的奖励类型
|
|
|
log.setRewardType(config.getRewardType());
|