吴树波 3 viikkoa sitten
vanhempi
commit
8e855d6eb0
1 muutettua tiedostoa jossa 31 lisäystä ja 31 poistoa
  1. 31 31
      fs-qw-task/src/main/java/com/fs/app/task/qwTask.java

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

@@ -2,7 +2,10 @@ package com.fs.app.task;
 
 import com.alibaba.fastjson.JSON;
 import com.fs.app.taskService.*;
+import com.fs.company.service.ICompanyService;
 import com.fs.company.service.ICompanyTrafficRecordService;
+import com.fs.company.vo.RedPacketMoneyVO;
+import com.fs.course.mapper.FsCourseRedPacketLogMapper;
 import com.fs.hisStore.config.MedicalMallConfig;
 import com.fs.qw.service.IQwExternalErrRetryService;
 import com.fs.qw.service.IQwGroupMsgService;
@@ -16,6 +19,7 @@ import com.fs.sop.service.impl.QwSopServiceImpl;
 import com.fs.sop.vo.QwSopLogsDoSendListTVO;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.service.ISysConfigService;
+import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
@@ -36,55 +40,27 @@ import java.util.List;
  */
 @Component
 @Slf4j
+@AllArgsConstructor
 public class qwTask {
 
-    @Autowired
     private QwSopServiceImpl qwSopService;
-
-    @Autowired
     private IQwSopLogsService iQwSopLogsService;
-
-    @Autowired
     private QwSopLogsServiceImpl qwSopLogsService;
-
-    @Autowired
     private IQwGroupMsgService qwGroupMsgService;
-
-    @Autowired
     private ISopUserLogsService sopUserLogsService;
-
-    @Autowired
     private SopLogsTaskService sopLogsTaskService;
-
-    @Autowired
     private SopWxLogsService sopWxLogsService;
-
-    @Autowired
+    private FsCourseRedPacketLogMapper fsCourseRedPacketLogMapper;
+    private ICompanyService companyService;
     private SopLogsChatTaskService sopLogsTaskChatService;
-
-    @Autowired
     private IQwExternalErrRetryService errRetryService;
-
-    @Autowired
     private QwExternalContactRatingService qwExternalContactRatingService;
-
-    @Autowired
     private IQwWorkUserService qwWorkUserService;
-
-    @Autowired
     private QwSopLogsMapper qwSopLogsMapper;
-
-    @Autowired
     private IQwSopTagService qwSopTagService;
-
-    @Autowired
     private SopUserLogsInfoByIsDaysNotStudy logsInfoByIsDaysNotStudy;
-
-    @Autowired
     private QwExternalContactRatingMoreSevenDaysService qwExternalContactRatingMoreSevenDaysService;
-    @Autowired
     private ICompanyTrafficRecordService companyTrafficRecordService;
-    @Autowired
     private ISysConfigService configService;
 
     /**
@@ -396,4 +372,28 @@ public class qwTask {
             companyTrafficRecordService.refreshTraffic();
         }
     }
+    /**
+     * 每天扣除流量余额
+     * */
+    @Scheduled(cron = "0 3 * * * ?")
+    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);
+            // 获取上一个小时的结束时间
+            LocalDateTime endTime = startTime
+                    .withMinute(59)
+                    .withSecond(59);
+            List<RedPacketMoneyVO> redPacketMoneyVOS = fsCourseRedPacketLogMapper.selectFsCourseRedPacketLogHourseByCompany(startTime, endTime);
+            for (RedPacketMoneyVO redPacketMoneyVO : redPacketMoneyVOS) {
+                companyService.subtractCompanyMoneyHourse(redPacketMoneyVO.getMoney(),redPacketMoneyVO.getCompanyId(), startTime.toLocalTime(), endTime.toLocalTime());
+            }
+        }
+    }
 }