Преглед на файлове

Merge remote-tracking branch 'origin/master'

yfh преди 3 седмици
родител
ревизия
fa0aa39a3b
променени са 1 файла, в които са добавени 42 реда и са изтрити 66 реда
  1. 42 66
      fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

+ 42 - 66
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -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);
 
 
@@ -1026,25 +1030,25 @@ 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(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 +1079,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 +1214,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 +1245,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 +1258,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 +1268,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 +1558,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, "已被拉黑,请联系管理员");
+            }
         }
 
         //查询看课记录