|
@@ -71,6 +71,7 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.BeansException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -97,6 +98,9 @@ import static com.fs.course.utils.LinkUtil.generateRandomStringWithLock;
|
|
|
@Service
|
|
|
public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
{
|
|
|
+ @Value("${cloud_host.company_name}")
|
|
|
+ private String signProjectName;
|
|
|
+
|
|
|
private static final Logger logger = LoggerFactory.getLogger(FsUserCourseVideoServiceImpl.class);
|
|
|
|
|
|
|
|
@@ -1020,31 +1024,32 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
packetParam.setSource(param.getSource());
|
|
|
packetParam.setRedPacketMode(config.getRedPacketMode());
|
|
|
packetParam.setCompanyId(param.getCompanyId());
|
|
|
+ packetParam.setAppId(param.getAppId());
|
|
|
|
|
|
System.out.println("红包金额"+amount);
|
|
|
System.out.println("红包商户号"+packetParam);
|
|
|
//2025.6.19 红包金额为0的时候
|
|
|
if (amount.compareTo(BigDecimal.ZERO)>0){
|
|
|
|
|
|
- Company company = companyMapper.selectCompanyByIdForUpdate(param.getCompanyId());
|
|
|
- BigDecimal money = company.getMoney();
|
|
|
- BigDecimal subtract = money.subtract(amount);
|
|
|
- if (subtract.compareTo(BigDecimal.ZERO)<0){
|
|
|
- FsCourseRedPacketLog 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());
|
|
|
- redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
- return R.error("销售公司余额不足");
|
|
|
- }
|
|
|
+// Company company = companyMapper.selectCompanyByIdForUpdate(param.getCompanyId());
|
|
|
+ // BigDecimal money = company.getMoney();
|
|
|
+ // BigDecimal subtract = money.subtract(amount);
|
|
|
+// if (subtract.compareTo(BigDecimal.ZERO)<0){
|
|
|
+// FsCourseRedPacketLog 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());
|
|
|
+// redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
+// return R.error("余额不足请稍等");
|
|
|
+// }
|
|
|
// 发送红包
|
|
|
R sendRedPacket = paymentService.sendRedPacket(packetParam);
|
|
|
if (sendRedPacket.get("code").equals(200)) {
|
|
@@ -1075,17 +1080,18 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
// 更新观看记录的奖励类型
|
|
|
log.setRewardType(config.getRewardType());
|
|
|
courseWatchLogMapper.updateFsCourseWatchLog(log);
|
|
|
- company.setMoney(subtract);
|
|
|
- companyMapper.updateCompany(company);
|
|
|
-
|
|
|
- CompanyMoneyLogs logs=new CompanyMoneyLogs();
|
|
|
- logs.setCompanyId(company.getCompanyId());
|
|
|
- logs.setRemark("扣除红包金额");
|
|
|
- logs.setMoney(amount.multiply(new BigDecimal(-1)));
|
|
|
- logs.setLogsType(15);
|
|
|
- logs.setBalance(company.getMoney());
|
|
|
- logs.setCreateTime(new Date());
|
|
|
- moneyLogsMapper.insertCompanyMoneyLogs(logs);
|
|
|
+//
|
|
|
+// company.setMoney(subtract);
|
|
|
+// companyMapper.updateCompany(company);
|
|
|
+//
|
|
|
+// CompanyMoneyLogs logs=new CompanyMoneyLogs();
|
|
|
+// logs.setCompanyId(company.getCompanyId());
|
|
|
+// logs.setRemark("扣除红包金额");
|
|
|
+// logs.setMoney(amount.multiply(new BigDecimal(-1)));
|
|
|
+// logs.setLogsType(15);
|
|
|
+// logs.setBalance(company.getMoney());
|
|
|
+// logs.setCreateTime(new Date());
|
|
|
+// moneyLogsMapper.insertCompanyMoneyLogs(logs);
|
|
|
|
|
|
return sendRedPacket;
|
|
|
} else {
|
|
@@ -1209,26 +1215,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
//2025.6.19 红包金额为0的时候
|
|
|
if (amount.compareTo(BigDecimal.ZERO)>0){
|
|
|
|
|
|
- Company company = companyMapper.selectCompanyByIdForUpdate(param.getCompanyId());
|
|
|
- BigDecimal money = company.getMoney();
|
|
|
- BigDecimal subtract = money.subtract(amount);
|
|
|
- if (subtract.compareTo(BigDecimal.ZERO)<0){
|
|
|
- FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog();
|
|
|
- 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);
|
|
|
- return R.error("销售公司余额不足");
|
|
|
- }
|
|
|
// 发送红包
|
|
|
R sendRedPacket = paymentService.sendRedPacket(packetParam);
|
|
|
if (sendRedPacket.get("code").equals(200)) {
|
|
@@ -1260,17 +1246,6 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
// 更新观看记录的奖励类型
|
|
|
log.setRewardType(config.getRewardType());
|
|
|
courseWatchLogMapper.updateFsCourseWatchLog(log);
|
|
|
- company.setMoney(subtract);
|
|
|
- companyMapper.updateCompany(company);
|
|
|
-
|
|
|
- CompanyMoneyLogs logs=new CompanyMoneyLogs();
|
|
|
- logs.setCompanyId(company.getCompanyId());
|
|
|
- logs.setRemark("扣除红包金额");
|
|
|
- logs.setMoney(amount.multiply(new BigDecimal(-1)));
|
|
|
- logs.setLogsType(15);
|
|
|
- logs.setBalance(company.getMoney());
|
|
|
- logs.setCreateTime(new Date());
|
|
|
- moneyLogsMapper.insertCompanyMoneyLogs(logs);
|
|
|
|
|
|
return sendRedPacket;
|
|
|
} else {
|
|
@@ -1284,7 +1259,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
redPacketLog.setCompanyId(param.getCompanyId());
|
|
|
redPacketLog.setUserId(param.getUserId());
|
|
|
redPacketLog.setVideoId(param.getVideoId());
|
|
|
- redPacketLog.setStatus(0);
|
|
|
+ redPacketLog.setStatus(1);
|
|
|
redPacketLog.setQwUserId(param.getQwUserId() != null ? param.getQwUserId() : null);
|
|
|
redPacketLog.setCompanyUserId(param.getCompanyUserId());
|
|
|
redPacketLog.setCreateTime(new Date());
|
|
@@ -1294,11 +1269,9 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
redPacketLog.setAppId(param.getAppId());
|
|
|
redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
|
|
|
|
|
|
- // 更新观看记录的奖励类型
|
|
|
-// if (param.getLinkType() == null || param.getLinkType() == 0) {
|
|
|
+ // 更新观看记录的奖励类
|
|
|
log.setRewardType(config.getRewardType());
|
|
|
courseWatchLogMapper.updateFsCourseWatchLog(log);
|
|
|
-// }
|
|
|
return R.ok("红包发送成功");
|
|
|
}
|
|
|
|
|
@@ -1586,7 +1559,11 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
}
|
|
|
|
|
|
if (userCompanyUser.getStatus() == 2) {
|
|
|
- return ResponseResult.fail(504, "已被拉黑,请联系管理员");
|
|
|
+ if("福本源".equals(signProjectName)){
|
|
|
+ return ResponseResult.fail(504, "服务暂时不可用,请联系管理员");
|
|
|
+ } else {
|
|
|
+ return ResponseResult.fail(504, "已被拉黑,请联系管理员");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//查询看课记录
|
|
@@ -2337,7 +2314,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
Long duration = redisCache.getCacheObject(redisKey);
|
|
|
|
|
|
if (duration == null) {
|
|
|
- FsUserCourseVideoQVO videoInfo = selectFsUserCourseVideoByVideoIdVO(videoId);
|
|
|
+ FsUserCourseVideoQVO videoInfo = selectFsUserCourseVideoByVideoIdVO(videoId,null);
|
|
|
if (videoInfo == null || videoInfo.getDuration() == null) {
|
|
|
throw new IllegalArgumentException("视频时长信息不存在");
|
|
|
}
|
|
@@ -2468,9 +2445,9 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public FsUserCourseVideoQVO selectFsUserCourseVideoByVideoIdVO(Long videoId) {
|
|
|
+ public FsUserCourseVideoQVO selectFsUserCourseVideoByVideoIdVO(Long videoId,Long userId) {
|
|
|
FsUserCourseVideoQVO fsUserCourseVideoQVO = new FsUserCourseVideoQVO();
|
|
|
- FsUserCourseVideo courseVideo = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoId(videoId);
|
|
|
+ FsUserCourseVideo courseVideo = fsUserCourseVideoMapper.selectFsUserCourseVideoByVideoIdAndUserId(videoId,userId);
|
|
|
|
|
|
BeanCopyUtils.copy(courseVideo,fsUserCourseVideoQVO);
|
|
|
|