Bläddra i källkod

Merge remote-tracking branch 'origin/ScrmStores' into ScrmStores

zhangqin 2 veckor sedan
förälder
incheckning
eafc3c012d

+ 5 - 0
fs-common/src/main/java/com/fs/common/utils/date/DateUtil.java

@@ -142,6 +142,11 @@ public final class DateUtil {
 		return formatter.format(localDateTime);
 	}
 
+	public static String formatLocalTime(LocalTime localDateTime, String pattern){
+		DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
+		return formatter.format(localDateTime);
+	}
+
 	/**
 	 * StringToDate
 	 * @author MengDaNai

+ 7 - 7
fs-qw-task/src/main/java/com/fs/app/task/qwTask.java

@@ -372,20 +372,20 @@ public class qwTask {
             companyTrafficRecordService.refreshTraffic();
         }
     }
-    @Scheduled(cron = "0 3 * * * ?")
+    @Scheduled(cron = "0 */10 * * * ?")
     public void refreshCompanyMoney(){
         SysConfig config = configService.selectConfigByConfigKey("medicalMall.func.switch");
         MedicalMallConfig medicalMallConfig = JSON.parseObject(config.getConfigValue(), MedicalMallConfig.class);
         log.info("是否更新红包:{}", medicalMallConfig.isStatics());
         if(medicalMallConfig.isStatics()) {
             LocalDateTime now = LocalDateTime.now();
-            // 获取上一个小时的开始时间
-            LocalDateTime startTime = now.minusHours(1)
-                    .withMinute(0)
-                    .withSecond(0);
-            // 获取上一个小时的结束时间
+            // 获取上一个10分钟时间段的开始时间
+            LocalDateTime startTime = now.minusMinutes(10)
+                    .withSecond(0)
+                    .withNano(0);
+            // 获取上一个10分钟时间段的结束时间
             LocalDateTime endTime = startTime
-                    .withMinute(59)
+                    .plusMinutes(9)
                     .withSecond(59);
             List<RedPacketMoneyVO> redPacketMoneyVOS = fsCourseRedPacketLogMapper.selectFsCourseRedPacketLogHourseByCompany(startTime, endTime);
             for (RedPacketMoneyVO redPacketMoneyVO : redPacketMoneyVOS) {

+ 3 - 2
fs-service/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java

@@ -12,6 +12,7 @@ import com.fs.common.exception.base.BaseException;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.SecurityUtils;
 import com.fs.common.utils.StringUtils;
+import com.fs.common.utils.date.DateUtil;
 import com.fs.company.domain.*;
 import com.fs.company.mapper.*;
 import com.fs.company.param.CompanyParam;
@@ -548,12 +549,12 @@ public class CompanyServiceImpl implements ICompanyService
         if(companyId!=null&&companyId>0){
             Company company=companyMapper.selectCompanyByIdForUpdate(companyId);
             if(company!=null){
-                logger.info("每个小时扣除红包金额:{}", money);
+                logger.info("每十分钟扣除红包金额:{}", money);
                 company.setMoney(company.getMoney().subtract(money));
                 companyMapper.updateCompany(company);
                 CompanyMoneyLogs log=new CompanyMoneyLogs();
                 log.setCompanyId(company.getCompanyId());
-                log.setRemark("扣除"+start.getHour()+"点红包金额");
+                log.setRemark("扣除" + DateUtil.formatLocalTime(start, "HH:mm") + "到" + DateUtil.formatLocalTime(end, "HH:mm") +"红包金额");
                 log.setMoney(money.multiply(new BigDecimal(-1)));
                 log.setLogsType(15);
                 log.setBalance(company.getMoney());

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

@@ -1157,10 +1157,10 @@ 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){
+            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());
@@ -1174,8 +1174,8 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 //                redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
 //                redPacketLog.setPeriodId(param.getPeriodId());
 //                redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
-//                return R.error("余额不足请稍等");
-//            }
+                return R.error("红包领取失败,请联系对应管理员");
+            }
             // 发送红包
             R sendRedPacket = paymentService.sendRedPacket(packetParam);
             if (sendRedPacket.get("code").equals(200)) {
@@ -1936,14 +1936,14 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             duration = Objects.isNull(watchLog) ? 0 : watchLog.getDuration();
         }
 //
-        if (courseVideoDetails != null && courseVideoDetails.getDuration() != null){
-            // 查询视频是否设置了红包,没有就不提示
-            Integer fsUserCourseVideoRedPackage = fsUserCourseVideoRedPackageMapper.selectRedPacketByCompanyCount(param.getVideoId(), null, param.getPeriodId());
-            if(fsUserCourseVideoRedPackage>0){
-                tipsTime = courseVideoDetails.getDuration() / 3;
-                tipsTime2 = (courseVideoDetails.getDuration() * 2) / 3;
-            }
-        }
+//        if (courseVideoDetails != null && courseVideoDetails.getDuration() != null){
+//            // 查询视频是否设置了红包,没有就不提示
+//            Integer fsUserCourseVideoRedPackage = fsUserCourseVideoRedPackageMapper.selectRedPacketByCompanyCount(param.getVideoId(), null, param.getPeriodId());
+//            if(fsUserCourseVideoRedPackage>0){
+//                tipsTime = courseVideoDetails.getDuration() / 3;
+//                tipsTime2 = (courseVideoDetails.getDuration() * 2) / 3;
+//            }
+//        }
         vo.setTipsTime(tipsTime);
         vo.setTipsTime2(tipsTime2);
         //判断是否完课