Browse Source

聊天室开启自动定时任务 直播自动任务 弹幕脚本 流量统计

yuhongqi 1 week ago
parent
commit
69dc948fd2
40 changed files with 1205 additions and 50 deletions
  1. 101 0
      fs-admin/src/main/java/com/fs/live/controller/LiveAutoTaskController.java
  2. 2 0
      fs-admin/src/main/java/com/fs/live/controller/LiveController.java
  3. 7 0
      fs-admin/src/main/java/com/fs/live/controller/LiveLotteryConfController.java
  4. 8 0
      fs-admin/src/main/java/com/fs/live/controller/LiveRedConfController.java
  5. 122 0
      fs-admin/src/main/java/com/fs/live/controller/LiveTrafficLogController.java
  6. 10 0
      fs-common/src/main/java/com/fs/common/core/redis/RedisUtil.java
  7. 123 6
      fs-company/src/main/java/com/fs/company/controller/live/LiveAutoTaskController.java
  8. 8 0
      fs-company/src/main/java/com/fs/company/controller/live/LiveLotteryConfController.java
  9. 8 0
      fs-company/src/main/java/com/fs/company/controller/live/LiveRedConfController.java
  10. 1 0
      fs-live-socket/src/main/java/com/fs/live/controller/LiveController.java
  11. 24 8
      fs-live-socket/src/main/java/com/fs/live/websocket/service/WebSocketServer.java
  12. 23 0
      fs-service-system/src/main/java/com/fs/crm/param/LiveAutoTaskExportParam.java
  13. 23 0
      fs-service-system/src/main/java/com/fs/crm/param/LiveAutoTaskImportParam.java
  14. 1 0
      fs-service-system/src/main/java/com/fs/live/domain/Live.java
  15. 2 1
      fs-service-system/src/main/java/com/fs/live/domain/LiveAutoTask.java
  16. 59 0
      fs-service-system/src/main/java/com/fs/live/domain/LiveTrafficLog.java
  17. 3 0
      fs-service-system/src/main/java/com/fs/live/domain/LiveVideo.java
  18. 6 0
      fs-service-system/src/main/java/com/fs/live/mapper/LiveAutoTaskMapper.java
  19. 3 0
      fs-service-system/src/main/java/com/fs/live/mapper/LiveLotteryConfMapper.java
  20. 2 0
      fs-service-system/src/main/java/com/fs/live/mapper/LiveLotteryProductConfMapper.java
  21. 3 0
      fs-service-system/src/main/java/com/fs/live/mapper/LiveRedConfMapper.java
  22. 83 0
      fs-service-system/src/main/java/com/fs/live/mapper/LiveTrafficLogMapper.java
  23. 24 0
      fs-service-system/src/main/java/com/fs/live/param/LiveFinishUParam.java
  24. 16 0
      fs-service-system/src/main/java/com/fs/live/param/LiveTrafficLogParam.java
  25. 4 0
      fs-service-system/src/main/java/com/fs/live/service/ILiveAutoTaskService.java
  26. 2 0
      fs-service-system/src/main/java/com/fs/live/service/ILiveLotteryConfService.java
  27. 2 0
      fs-service-system/src/main/java/com/fs/live/service/ILiveRedConfService.java
  28. 70 0
      fs-service-system/src/main/java/com/fs/live/service/ILiveTrafficLogService.java
  29. 53 7
      fs-service-system/src/main/java/com/fs/live/service/impl/LiveAutoTaskServiceImpl.java
  30. 6 4
      fs-service-system/src/main/java/com/fs/live/service/impl/LiveLotteryConfServiceImpl.java
  31. 5 0
      fs-service-system/src/main/java/com/fs/live/service/impl/LiveRedConfServiceImpl.java
  32. 73 21
      fs-service-system/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java
  33. 155 0
      fs-service-system/src/main/java/com/fs/live/service/impl/LiveTrafficLogServiceImpl.java
  34. 6 0
      fs-service-system/src/main/java/com/fs/live/service/impl/LiveWatchUserServiceImpl.java
  35. 22 0
      fs-service-system/src/main/java/com/fs/live/vo/LiveTrafficLogListVO.java
  36. 8 0
      fs-service-system/src/main/resources/mapper/live/LiveLotteryProductConfMapper.xml
  37. 2 2
      fs-service-system/src/main/resources/mapper/live/LiveMapper.xml
  38. 101 0
      fs-service-system/src/main/resources/mapper/live/LiveTrafficLogMapper.xml
  39. 5 1
      fs-service-system/src/main/resources/mapper/live/LiveVideoMapper.xml
  40. 29 0
      fs-user-app/src/main/java/com/fs/app/controller/LiveTrafficLogController.java

+ 101 - 0
fs-admin/src/main/java/com/fs/live/controller/LiveAutoTaskController.java

@@ -6,13 +6,26 @@ import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.DateUtils;
+import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.crm.param.LiveAutoTaskExportParam;
+import com.fs.crm.param.LiveAutoTaskImportParam;
+import com.fs.live.domain.Live;
 import com.fs.live.domain.LiveAutoTask;
+import com.fs.live.mapper.LiveMapper;
 import com.fs.live.service.ILiveAutoTaskService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -27,6 +40,8 @@ public class LiveAutoTaskController extends BaseController
 {
     @Autowired
     private ILiveAutoTaskService liveAutoTaskService;
+    @Autowired
+    private LiveMapper liveMapper;
 
     /**
      * 查询直播间自动化任务配置列表
@@ -95,4 +110,90 @@ public class LiveAutoTaskController extends BaseController
     {
         return toAjax(liveAutoTaskService.deleteLiveAutoTaskByIds(ids));
     }
+
+    /**
+     * 导出直播间自动化任务配置列表
+     */
+    @PreAuthorize("@ss.hasPermi('live:task:export')")
+    @Log(title = "直播间自动化任务配置", businessType = BusinessType.EXPORT)
+    @GetMapping("/exportData")
+    public AjaxResult exportData(LiveAutoTask liveAutoTask)
+    {
+        List<LiveAutoTask> list = liveAutoTaskService.selectLiveAutoTaskBarrageList(liveAutoTask);
+        ExcelUtil<LiveAutoTaskExportParam> util = new ExcelUtil<LiveAutoTaskExportParam>(LiveAutoTaskExportParam.class);
+        ArrayList<LiveAutoTaskExportParam> barrageList = new ArrayList<>();
+        for (LiveAutoTask autoTask : list) {
+            LiveAutoTaskExportParam liveAutoTaskImportParam = new LiveAutoTaskExportParam();
+            liveAutoTaskImportParam.setTaskName(autoTask.getTaskName());
+            liveAutoTaskImportParam.setContent(autoTask.getContent());
+            liveAutoTaskImportParam.setRegisterDate(autoTask.getTriggerValue());
+            barrageList.add(liveAutoTaskImportParam);
+        }
+
+        return util.exportExcel(barrageList, "直播间弹幕脚本数据");
+    }
+
+    @PreAuthorize("@ss.hasPermi('live:task:export')")
+    @PostMapping("/importData")
+    public AjaxResult importLineData(@RequestParam("liveId") String liveId, MultipartFile file) throws Exception
+    {
+        ExcelUtil<LiveAutoTaskImportParam> util = new ExcelUtil<LiveAutoTaskImportParam>(LiveAutoTaskImportParam.class);
+        List<LiveAutoTaskImportParam> list = util.importExcel(file.getInputStream());
+        if(list.size()>12000){
+            return new AjaxResult(500,"导入数据超出范围,最大12000条");
+        }
+        LiveAutoTask liveAutoTask;
+        Date nowDate = DateUtils.getNowDate();
+        Live live = liveMapper.selectLiveByLiveId(Long.parseLong(liveId));
+        for (LiveAutoTaskImportParam liveAutoTaskImportParam : list) {
+            if(StringUtils.isEmpty(liveAutoTaskImportParam.getTaskName()) || StringUtils.isEmpty(liveAutoTaskImportParam.getRegisterDate()) || StringUtils.isEmpty(liveAutoTaskImportParam.getContent())) continue;
+            liveAutoTask = new LiveAutoTask();
+            liveAutoTask.setLiveId(Long.parseLong(liveId));
+            liveAutoTask.setTaskName(liveAutoTaskImportParam.getTaskName());
+            liveAutoTask.setTaskType(3L);
+            liveAutoTask.setTriggerType(2L);
+            liveAutoTask.setTriggerValue(formatTime(liveAutoTaskImportParam.getRegisterDate()));
+            liveAutoTask.setContent(liveAutoTaskImportParam.getContent());
+            liveAutoTask.setAbsValue(getTriggerValue(liveAutoTask.getTriggerValue(),live.getStartTime()));
+            liveAutoTask.setCreateTime(nowDate);
+            liveAutoTask.setUpdateTime(nowDate);
+            liveAutoTask.setStatus(1L);
+            liveAutoTask.setFinishStatus(0L);
+            liveAutoTaskService.directInsertLiveAutoTask(liveAutoTask);
+        }
+        return AjaxResult.success();
+    }
+
+    public static Date formatTime(String duration) {
+        String[] parts = duration.split(":");
+        if (parts.length != 3) {
+            throw new IllegalArgumentException("时间格式不正确,应为 hh:mm:ss");
+        }
+        int hours = Integer.parseInt(parts[0]);
+        int minutes = Integer.parseInt(parts[1]);
+        int seconds = Integer.parseInt(parts[2]);
+
+        // 获取当前日期的Calendar实例
+        Calendar calendar = Calendar.getInstance();
+        // 设置时分秒
+        calendar.set(Calendar.HOUR_OF_DAY, hours); // 24小时制
+        calendar.set(Calendar.MINUTE, minutes);
+        calendar.set(Calendar.SECOND, seconds);
+        calendar.set(Calendar.MILLISECOND, 0); // 毫秒设为0
+
+        return calendar.getTime();
+    }
+
+    private Date getTriggerValue(Date triggerValue, LocalDateTime liveStartTime) {
+        LocalDateTime triggerDateTime = LocalDateTime.ofInstant(
+                triggerValue.toInstant(),
+                ZoneId.systemDefault()
+        );
+        LocalTime triggerTime = triggerDateTime.toLocalTime();
+        LocalDateTime combinedTime = liveStartTime
+                .plusHours(triggerTime.getHour())
+                .plusMinutes(triggerTime.getMinute())
+                .plusSeconds(triggerTime.getSecond());
+        return Date.from(combinedTime.atZone(ZoneId.systemDefault()).toInstant());
+    }
 }

+ 2 - 0
fs-admin/src/main/java/com/fs/live/controller/LiveController.java

@@ -109,6 +109,8 @@ public class LiveController extends BaseController {
         return liveService.updateLive(live);
     }
 
+
+
     /**
      * 批量上下架视频
      */

+ 7 - 0
fs-admin/src/main/java/com/fs/live/controller/LiveLotteryConfController.java

@@ -42,6 +42,13 @@ public class LiveLotteryConfController extends BaseController
         return getDataTable(list);
     }
 
+    @GetMapping("/listOn")
+    public TableDataInfo listOn(LiveLotteryConf liveLotteryConf)
+    {
+        startPage();
+        List<LiveLotteryConf> list = liveLotteryConfService.selectLiveLotteryConfListOn(liveLotteryConf);
+        return getDataTable(list);
+    }
     /**
      * 导出直播抽奖配置列表
      */

+ 8 - 0
fs-admin/src/main/java/com/fs/live/controller/LiveRedConfController.java

@@ -41,6 +41,14 @@ public class LiveRedConfController extends BaseController
         return getDataTable(list);
     }
 
+    @GetMapping("/listOn")
+    public TableDataInfo listOn(LiveRedConf liveRedConf)
+    {
+        startPage();
+        List<LiveRedConf> list = liveRedConfService.selectLiveRedConfListOn(liveRedConf);
+        return getDataTable(list);
+    }
+
     /**
      * 导出直播红包记录配置列表
      */

+ 122 - 0
fs-admin/src/main/java/com/fs/live/controller/LiveTrafficLogController.java

@@ -0,0 +1,122 @@
+package com.fs.live.controller;
+
+import java.text.SimpleDateFormat;
+import java.util.List;
+
+import com.fs.live.param.LiveTrafficLogParam;
+import com.fs.live.vo.LiveTrafficLogListVO;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.fs.common.annotation.Log;
+import com.fs.common.core.controller.BaseController;
+import com.fs.common.core.domain.AjaxResult;
+import com.fs.common.enums.BusinessType;
+import com.fs.live.domain.LiveTrafficLog;
+import com.fs.live.service.ILiveTrafficLogService;
+import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.common.core.page.TableDataInfo;
+
+/**
+ * 直播流量记录Controller
+ *
+ * @author fs
+ * @date 2025-10-13
+ */
+@RestController
+@RequestMapping("/live/trafficLog")
+public class LiveTrafficLogController extends BaseController
+{
+    @Autowired
+    private ILiveTrafficLogService liveTrafficLogService;
+
+    /**
+     * 查询直播流量记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('live:trafficLog:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(LiveTrafficLogParam param)
+    {
+        startPage();
+        if (param.getTime() != null) {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+            String formattedDate = sdf.format(param.getTime());
+            String[] parts = formattedDate.split("-");
+            param.setYear(Integer.parseInt(parts[0]));
+            param.setMonth(Integer.parseInt(parts[1]));
+        }
+        List<LiveTrafficLogListVO> list = liveTrafficLogService.selectTrafficByCompany(param);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出直播流量记录列表
+     */
+    @PreAuthorize("@ss.hasPermi('live:trafficLog:export')")
+    @Log(title = "直播流量记录", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(LiveTrafficLogParam param)
+    {
+        if (param.getTime() != null) {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+            String formattedDate = sdf.format(param.getTime());
+            String[] parts = formattedDate.split("-");
+            param.setYear(Integer.parseInt(parts[0]));
+            param.setMonth(Integer.parseInt(parts[1]));
+        }
+
+        List<LiveTrafficLogListVO> list = liveTrafficLogService.selectTrafficByCompany(param);
+        ExcelUtil<LiveTrafficLogListVO> util = new ExcelUtil<LiveTrafficLogListVO>(LiveTrafficLogListVO.class);
+        return util.exportExcel(list, "直播流量记录数据");
+    }
+
+    /**
+     * 获取直播流量记录详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('live:trafficLog:query')")
+    @GetMapping(value = "/{logId}")
+    public AjaxResult getInfo(@PathVariable("logId") Long logId)
+    {
+        return AjaxResult.success(liveTrafficLogService.selectLiveTrafficLogById(logId));
+    }
+
+    /**
+     * 新增直播流量记录
+     */
+    @PreAuthorize("@ss.hasPermi('live:trafficLog:add')")
+    @Log(title = "直播流量记录", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody LiveTrafficLog liveTrafficLog)
+    {
+        return toAjax(liveTrafficLogService.insertLiveTrafficLog(liveTrafficLog));
+    }
+
+    /**
+     * 修改直播流量记录
+     */
+    @PreAuthorize("@ss.hasPermi('live:trafficLog:edit')")
+    @Log(title = "直播流量记录", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody LiveTrafficLog liveTrafficLog)
+    {
+        return toAjax(liveTrafficLogService.updateLiveTrafficLog(liveTrafficLog));
+    }
+
+    /**
+     * 删除直播流量记录
+     */
+    @PreAuthorize("@ss.hasPermi('live:trafficLog:remove')")
+    @Log(title = "直播流量记录", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{logIds}")
+    public AjaxResult remove(@PathVariable Long[] logIds)
+    {
+        return toAjax(liveTrafficLogService.deleteLiveTrafficLogByIds(logIds));
+    }
+}

+ 10 - 0
fs-common/src/main/java/com/fs/common/core/redis/RedisUtil.java

@@ -193,6 +193,16 @@ public class RedisUtil {
         redisTemplate.opsForHash().put(key, hashKey, value);
     }
 
+    /**
+     * 向哈希表中添加键值对
+     *
+     * @param key     哈希表键
+     * @param hashKey 哈希键
+     */
+    public void hashDelete(String key, String hashKey) {
+        redisTemplate.opsForHash().delete(key, hashKey);
+    }
+
     /**
      * 向哈希表中添加键值对批量
      *

+ 123 - 6
fs-company/src/main/java/com/fs/company/controller/live/LiveAutoTaskController.java

@@ -6,13 +6,31 @@ import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
+import com.fs.common.utils.DateUtils;
+import com.fs.common.utils.ServletUtils;
+import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.core.security.LoginUser;
+import com.fs.crm.param.CrmCompanyLineCustomerImportParam;
+import com.fs.crm.param.LiveAutoTaskExportParam;
+import com.fs.crm.param.LiveAutoTaskImportParam;
+import com.fs.live.domain.Live;
 import com.fs.live.domain.LiveAutoTask;
+import com.fs.live.mapper.LiveMapper;
 import com.fs.live.service.ILiveAutoTaskService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -27,11 +45,13 @@ public class LiveAutoTaskController extends BaseController
 {
     @Autowired
     private ILiveAutoTaskService liveAutoTaskService;
+    @Autowired
+    private LiveMapper liveMapper;
 
     /**
      * 查询直播间自动化任务配置列表
      */
-    @PreAuthorize("@ss.hasPermi('shop:task:list')")
+    @PreAuthorize("@ss.hasPermi('live:task:list')")
     @GetMapping("/list")
     public TableDataInfo list(LiveAutoTask liveAutoTask)
     {
@@ -39,11 +59,22 @@ public class LiveAutoTaskController extends BaseController
         List<LiveAutoTask> list = liveAutoTaskService.selectLiveAutoTaskList(liveAutoTask);
         return getDataTable(list);
     }
+    /**
+     * 查询直播间自动化任务配置列表
+     */
+    @PreAuthorize("@ss.hasPermi('live:task:list')")
+    @GetMapping("/listBarrage")
+    public TableDataInfo listBarrage(LiveAutoTask liveAutoTask)
+    {
+        startPage();
+        List<LiveAutoTask> list = liveAutoTaskService.selectLiveAutoTaskBarrageList(liveAutoTask);
+        return getDataTable(list);
+    }
 
     /**
      * 导出直播间自动化任务配置列表
      */
-    @PreAuthorize("@ss.hasPermi('shop:task:export')")
+    @PreAuthorize("@ss.hasPermi('live:task:export')")
     @Log(title = "直播间自动化任务配置", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
     public AjaxResult export(LiveAutoTask liveAutoTask)
@@ -56,7 +87,7 @@ public class LiveAutoTaskController extends BaseController
     /**
      * 获取直播间自动化任务配置详细信息
      */
-    @PreAuthorize("@ss.hasPermi('shop:task:query')")
+    @PreAuthorize("@ss.hasPermi('live:task:query')")
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id)
     {
@@ -66,7 +97,7 @@ public class LiveAutoTaskController extends BaseController
     /**
      * 新增直播间自动化任务配置
      */
-    @PreAuthorize("@ss.hasPermi('shop:task:add')")
+    @PreAuthorize("@ss.hasPermi('live:task:add')")
     @Log(title = "直播间自动化任务配置", businessType = BusinessType.INSERT)
     @PostMapping
     public R add(@RequestBody LiveAutoTask liveAutoTask)
@@ -77,7 +108,7 @@ public class LiveAutoTaskController extends BaseController
     /**
      * 修改直播间自动化任务配置
      */
-    @PreAuthorize("@ss.hasPermi('shop:task:edit')")
+    @PreAuthorize("@ss.hasPermi('live:task:edit')")
     @Log(title = "直播间自动化任务配置", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody LiveAutoTask liveAutoTask)
@@ -88,11 +119,97 @@ public class LiveAutoTaskController extends BaseController
     /**
      * 删除直播间自动化任务配置
      */
-    @PreAuthorize("@ss.hasPermi('shop:task:remove')")
+    @PreAuthorize("@ss.hasPermi('live:task:remove')")
     @Log(title = "直播间自动化任务配置", businessType = BusinessType.DELETE)
 	@DeleteMapping("/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids)
     {
         return toAjax(liveAutoTaskService.deleteLiveAutoTaskByIds(ids));
     }
+
+    /**
+     * 导出直播间自动化任务配置列表
+     */
+    @PreAuthorize("@ss.hasPermi('live:task:export')")
+    @Log(title = "直播间自动化任务配置", businessType = BusinessType.EXPORT)
+    @GetMapping("/exportData")
+    public AjaxResult exportData(LiveAutoTask liveAutoTask)
+    {
+        List<LiveAutoTask> list = liveAutoTaskService.selectLiveAutoTaskBarrageList(liveAutoTask);
+        ExcelUtil<LiveAutoTaskExportParam> util = new ExcelUtil<LiveAutoTaskExportParam>(LiveAutoTaskExportParam.class);
+        ArrayList<LiveAutoTaskExportParam> barrageList = new ArrayList<>();
+        for (LiveAutoTask autoTask : list) {
+            LiveAutoTaskExportParam liveAutoTaskImportParam = new LiveAutoTaskExportParam();
+            liveAutoTaskImportParam.setTaskName(autoTask.getTaskName());
+            liveAutoTaskImportParam.setContent(autoTask.getContent());
+            liveAutoTaskImportParam.setRegisterDate(autoTask.getTriggerValue());
+            barrageList.add(liveAutoTaskImportParam);
+        }
+
+        return util.exportExcel(barrageList, "直播间弹幕脚本数据");
+    }
+
+    @PreAuthorize("@ss.hasPermi('live:task:export')")
+    @PostMapping("/importData")
+    public AjaxResult importLineData(@RequestParam("liveId") String liveId,MultipartFile file) throws Exception
+    {
+        ExcelUtil<LiveAutoTaskImportParam> util = new ExcelUtil<LiveAutoTaskImportParam>(LiveAutoTaskImportParam.class);
+        List<LiveAutoTaskImportParam> list = util.importExcel(file.getInputStream());
+        if(list.size()>12000){
+            return new AjaxResult(500,"导入数据超出范围,最大12000条");
+        }
+        LiveAutoTask liveAutoTask;
+        Date nowDate = DateUtils.getNowDate();
+        Live live = liveMapper.selectLiveByLiveId(Long.parseLong(liveId));
+        for (LiveAutoTaskImportParam liveAutoTaskImportParam : list) {
+            if(StringUtils.isEmpty(liveAutoTaskImportParam.getTaskName()) || StringUtils.isEmpty(liveAutoTaskImportParam.getRegisterDate()) || StringUtils.isEmpty(liveAutoTaskImportParam.getContent())) continue;
+            liveAutoTask = new LiveAutoTask();
+            liveAutoTask.setLiveId(Long.parseLong(liveId));
+            liveAutoTask.setTaskName(liveAutoTaskImportParam.getTaskName());
+            liveAutoTask.setTaskType(3L);
+            liveAutoTask.setTriggerType(2L);
+            liveAutoTask.setTriggerValue(formatTime(liveAutoTaskImportParam.getRegisterDate()));
+            liveAutoTask.setContent(liveAutoTaskImportParam.getContent());
+            liveAutoTask.setAbsValue(getTriggerValue(liveAutoTask.getTriggerValue(),live.getStartTime()));
+            liveAutoTask.setCreateTime(nowDate);
+            liveAutoTask.setUpdateTime(nowDate);
+            liveAutoTask.setStatus(1L);
+            liveAutoTask.setFinishStatus(0L);
+            liveAutoTaskService.directInsertLiveAutoTask(liveAutoTask);
+        }
+        return AjaxResult.success();
+    }
+
+    public static Date formatTime(String duration) {
+        String[] parts = duration.split(":");
+        if (parts.length != 3) {
+            throw new IllegalArgumentException("时间格式不正确,应为 hh:mm:ss");
+        }
+        int hours = Integer.parseInt(parts[0]);
+        int minutes = Integer.parseInt(parts[1]);
+        int seconds = Integer.parseInt(parts[2]);
+
+        // 获取当前日期的Calendar实例
+        Calendar calendar = Calendar.getInstance();
+        // 设置时分秒
+        calendar.set(Calendar.HOUR_OF_DAY, hours); // 24小时制
+        calendar.set(Calendar.MINUTE, minutes);
+        calendar.set(Calendar.SECOND, seconds);
+        calendar.set(Calendar.MILLISECOND, 0); // 毫秒设为0
+
+        return calendar.getTime();
+    }
+
+    private Date getTriggerValue(Date triggerValue, LocalDateTime liveStartTime) {
+        LocalDateTime triggerDateTime = LocalDateTime.ofInstant(
+                triggerValue.toInstant(),
+                ZoneId.systemDefault()
+        );
+        LocalTime triggerTime = triggerDateTime.toLocalTime();
+        LocalDateTime combinedTime = liveStartTime
+                .plusHours(triggerTime.getHour())
+                .plusMinutes(triggerTime.getMinute())
+                .plusSeconds(triggerTime.getSecond());
+        return Date.from(combinedTime.atZone(ZoneId.systemDefault()).toInstant());
+    }
 }

+ 8 - 0
fs-company/src/main/java/com/fs/company/controller/live/LiveLotteryConfController.java

@@ -42,6 +42,14 @@ public class LiveLotteryConfController extends BaseController
         return getDataTable(list);
     }
 
+    @GetMapping("/listOn")
+    public TableDataInfo listOn(LiveLotteryConf liveLotteryConf)
+    {
+        startPage();
+        List<LiveLotteryConf> list = liveLotteryConfService.selectLiveLotteryConfListOn(liveLotteryConf);
+        return getDataTable(list);
+    }
+
     /**
      * 导出直播抽奖配置列表
      */

+ 8 - 0
fs-company/src/main/java/com/fs/company/controller/live/LiveRedConfController.java

@@ -41,6 +41,14 @@ public class LiveRedConfController extends BaseController
         return getDataTable(list);
     }
 
+    @GetMapping("/listOn")
+    public TableDataInfo listOn(LiveRedConf liveRedConf)
+    {
+        startPage();
+        List<LiveRedConf> list = liveRedConfService.selectLiveRedConfListOn(liveRedConf);
+        return getDataTable(list);
+    }
+
     /**
      * 导出直播红包记录配置列表
      */

+ 1 - 0
fs-live-socket/src/main/java/com/fs/live/controller/LiveController.java

@@ -105,6 +105,7 @@ public class LiveController {
 		liveVideo.setDuration(Long.valueOf(params.get("duration")));
 		liveVideo.setCreateTime(nowDate);
 		liveVideo.setUpdateTime(nowDate);
+		liveVideo.setFileSize(Long.valueOf(params.get("file_size")));
 		videoService.saveOrUpdate(liveVideo);
 		return R.ok();
 //		{app=200149.push.tlivecloud.com, appid=1319721001, appname=live,

+ 24 - 8
fs-live-socket/src/main/java/com/fs/live/websocket/service/WebSocketServer.java

@@ -492,20 +492,36 @@ public class WebSocketServer {
 
 
     public void handleAutoTask(LiveAutoTask task) {
-        if (task.getTaskType() == 1L) {
-            SendMsgVo msg = new SendMsgVo();
-            msg.setLiveId(task.getLiveId());
-            msg.setData(task.getContent());
-            msg.setCmd("goods");
-            try {
+        SendMsgVo msg = new SendMsgVo();
+        msg.setLiveId(task.getLiveId());
+        msg.setData(task.getContent());
+        try {
+            if (task.getTaskType() == 1L) {
+                msg.setCmd("goods");
                 LiveGoodsVo liveGoodsVo = JSON.parseObject(task.getContent(), LiveGoodsVo.class);
                 liveGoodsService.updateLiveIsShow(liveGoodsVo.getGoodsId(), task.getLiveId());
-            } catch (Exception e) {
-                log.error("定时任务执行异常:{}", e.getMessage());
+            }else if (task.getTaskType() == 2L) {
+                msg.setCmd("red");
+                LiveRedConf liveRedConf = JSON.parseObject(task.getContent(), LiveRedConf.class);
+                liveRedConf.setRedStatus(1L);
+                liveRedConfService.updateLiveRedConf(liveRedConf);
+            }else if (task.getTaskType() == 4L) {
+                msg.setCmd("lottery");
+                LiveLotteryConf liveLotteryConf = JSON.parseObject(task.getContent(), LiveLotteryConf.class);
+                liveLotteryConf.setLotteryStatus("1");
+                liveLotteryConfService.updateLiveLotteryConf(liveLotteryConf);
+            }else if (task.getTaskType() == 3L) {
+                msg.setCmd("sendMsg");
+                msg.setMsg(task.getContent());
+                msg.setUserType(1L);
+                msg.setNickName(task.getTaskName());
             }
             msg.setStatus(1);
             broadcastMessage(task.getLiveId(), JSONObject.toJSONString(R.ok().put("data", msg)));
+        } catch (Exception e) {
+            log.error("定时任务执行异常:{}", e.getMessage());
         }
+
     }
     private void delAutoTask(long liveId, Long data) {
         String key = "live:auto_task:";

+ 23 - 0
fs-service-system/src/main/java/com/fs/crm/param/LiveAutoTaskExportParam.java

@@ -0,0 +1,23 @@
+package com.fs.crm.param;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+@Data
+public class LiveAutoTaskExportParam implements Serializable {
+
+    @JsonFormat(pattern = "HH:mm:ss")
+    @Excel(name = "时间", width = 20, dateFormat = "HH:mm:ss")
+    private Date registerDate;
+
+    @Excel(name = "昵称")
+    private String taskName;
+
+    @Excel(name = "台词" )
+    private String content;
+
+}

+ 23 - 0
fs-service-system/src/main/java/com/fs/crm/param/LiveAutoTaskImportParam.java

@@ -0,0 +1,23 @@
+package com.fs.crm.param;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class LiveAutoTaskImportParam implements Serializable {
+
+    @JsonFormat(pattern = "HH:mm:ss")
+    @Excel(name = "时间", width = 20, dateFormat = "HH:mm:ss")
+    private String registerDate;
+
+    @Excel(name = "昵称")
+    private String taskName;
+
+    @Excel(name = "台词" )
+    private String content;
+
+}

+ 1 - 0
fs-service-system/src/main/java/com/fs/live/domain/Live.java

@@ -117,4 +117,5 @@ public class   Live extends BaseEntity {
     /** 创建时间 */
     private Date createTime;
     private String companyName;
+    private Long fileSize;
 }

+ 2 - 1
fs-service-system/src/main/java/com/fs/live/domain/LiveAutoTask.java

@@ -30,7 +30,7 @@ public class LiveAutoTask extends BaseEntity{
     private String taskName;
 
     /** 任务类型:1-定时推送卡片商品 2-定时发送红包 3-定时开启互动 */
-    @Excel(name = "任务类型:1-定时推送卡片商品 2-定时发送红包 3-定时开启互动")
+    @Excel(name = "任务类型:1-定时推送卡片商品 2-定时发送红包 3-定时开启互动 4-抽奖")
     private Long taskType;
 
     /** 触发类型:1-绝对时间 2-相对直播开始时间 */
@@ -53,6 +53,7 @@ public class LiveAutoTask extends BaseEntity{
     @Excel(name = "状态:0-禁用 1-启用")
     private Long status;
 
+    /** 结束状态:0-未结束 1-已结束 */
     private Long finishStatus;
 
 

+ 59 - 0
fs-service-system/src/main/java/com/fs/live/domain/LiveTrafficLog.java

@@ -0,0 +1,59 @@
+package com.fs.live.domain;
+
+import com.fs.common.annotation.Excel;
+import com.fs.common.core.domain.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 直播流量记录对象 live_traffic_log
+ *
+ * @author fs
+ * @date 2025-10-13
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class LiveTrafficLog extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 日志Id */
+    private Long logId;
+
+    /** 用户id */
+    @Excel(name = "用户id")
+    private Long userId;
+
+    /** 直播间id */
+    @Excel(name = "直播间id")
+    private Long liveId;
+
+    /** 企微外部联系人id */
+    @Excel(name = "企微外部联系人id")
+    private Long qwExternalContactId;
+
+    /** 使用流量 */
+    @Excel(name = "使用流量")
+    private Long internetTraffic;
+
+    /** 分享人企微userId */
+    @Excel(name = "分享人企微userId")
+    private String qwUserId;
+
+    /** 销售id */
+    @Excel(name = "销售id")
+    private Long companyUserId;
+
+    /** 公司id */
+    @Excel(name = "公司id")
+    private Long companyId;
+
+    /** 课程id */
+    @Excel(name = "课程id")
+    private Long courseId;
+
+    /** 唯一id */
+    @Excel(name = "唯一id")
+    private String uuId;
+
+}

+ 3 - 0
fs-service-system/src/main/java/com/fs/live/domain/LiveVideo.java

@@ -35,6 +35,9 @@ public class LiveVideo extends BaseEntity {
     @Excel(name = "视屏时长")
     private Long duration;
 
+    @Excel(name = "文件大小")
+    private Long fileSize;
+
     /** 排序号 */
     @Excel(name = "排序号")
     private Long sort;

+ 6 - 0
fs-service-system/src/main/java/com/fs/live/mapper/LiveAutoTaskMapper.java

@@ -69,6 +69,9 @@ public interface LiveAutoTaskMapper {
     @Select("select * from live_auto_task where live_id= #{liveId}")
     List<LiveAutoTask> selectLiveAutoTaskByLiveId(@Param("liveId") Long liveId);
 
+    @Select("select * from live_auto_task where live_id= #{liveId} and task_type = 1")
+    List<LiveAutoTask> recalcLiveAutoTaskQuery(@Param("liveId") Long liveId);
+
     @Select("select * from live_auto_task where live_id= #{liveId} and status=1 and finish_status = 0 and abs_value>#{now} order by abs_value")
     List<LiveAutoTask> selectNoActivedByLiveId(@Param("liveId") Long existLiveId,@Param("now") Date now);
 
@@ -76,4 +79,7 @@ public interface LiveAutoTaskMapper {
 
     @Update("update live_auto_task set finish_status = 1 where id = #{id}")
     void finishLiveAutoTask(LiveAutoTask task);
+
+    @Select("select * from live_auto_task where live_id= #{liveId} and task_type = 3")
+    List<LiveAutoTask> selectLiveAutoTaskBarrageList(LiveAutoTask liveAutoTask);
 }

+ 3 - 0
fs-service-system/src/main/java/com/fs/live/mapper/LiveLotteryConfMapper.java

@@ -97,4 +97,7 @@ public interface LiveLotteryConfMapper {
     LiveLotteryConfVo selectLiveLotteryConfVoByLotteryId(@Param("lotteryId") Long lotteryId);
 
     void finishStatusByLotteryIds(@Param("ids")  List<Long> ids);
+
+    @Select("SELECT * FROM live_lottery_conf WHERE live_id = #{liveId} AND lottery_status = 0 ")
+    List<LiveLotteryConf> selectLiveLotteryConfListOn(LiveLotteryConf liveLotteryConf);
 }

+ 2 - 0
fs-service-system/src/main/java/com/fs/live/mapper/LiveLotteryProductConfMapper.java

@@ -77,4 +77,6 @@ public interface LiveLotteryProductConfMapper {
     void deleteLiveLotteryProductConfByLotteryId(Long lotteryId);
 
     List<LiveLotteryProductListVo> selectLiveLotteryProductConfByLotteryIds(@Param("lotteryIds") List<Long> lotteryIds);
+
+    List<LiveLotteryProductConf> selectEntityByIds(@Param("lotteryIds") List<Long> lotteryIds);
 }

+ 3 - 0
fs-service-system/src/main/java/com/fs/live/mapper/LiveRedConfMapper.java

@@ -93,4 +93,7 @@ public interface LiveRedConfMapper {
     List<LiveRedConf> selectActivedRed(@Param("liveId") Long liveId);
 
     void finishRedStatusBySetIds(@Param("ids") Set<String> ids);
+
+    @Select("SELECT * FROM live_red_conf WHERE red_status = 0 and live_id=#{liveId}")
+    List<LiveRedConf> selectLiveRedConfListOn(LiveRedConf liveRedConf);
 }

+ 83 - 0
fs-service-system/src/main/java/com/fs/live/mapper/LiveTrafficLogMapper.java

@@ -0,0 +1,83 @@
+package com.fs.live.mapper;
+
+import java.util.List;
+import com.fs.live.domain.LiveTrafficLog;
+import com.fs.live.param.LiveTrafficLogParam;
+import com.fs.live.vo.LiveTrafficLogListVO;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+/**
+ * 直播流量记录Mapper接口
+ *
+ * @author fs
+ * @date 2025-10-13
+ */
+public interface LiveTrafficLogMapper
+{
+    /**
+     * 查询直播流量记录
+     *
+     * @param logId 直播流量记录ID
+     * @return 直播流量记录
+     */
+    public LiveTrafficLog selectLiveTrafficLogById(Long logId);
+
+    /**
+     * 查询直播流量记录列表
+     *
+     * @param liveTrafficLog 直播流量记录
+     * @return 直播流量记录集合
+     */
+    public List<LiveTrafficLog> selectLiveTrafficLogList(LiveTrafficLog liveTrafficLog);
+
+    /**
+     * 新增直播流量记录
+     *
+     * @param liveTrafficLog 直播流量记录
+     * @return 结果
+     */
+    public int insertLiveTrafficLog(LiveTrafficLog liveTrafficLog);
+
+    /**
+     * 修改直播流量记录
+     *
+     * @param liveTrafficLog 直播流量记录
+     * @return 结果
+     */
+    public int updateLiveTrafficLog(LiveTrafficLog liveTrafficLog);
+
+    /**
+     * 删除直播流量记录
+     *
+     * @param logId 直播流量记录ID
+     * @return 结果
+     */
+    public int deleteLiveTrafficLogById(Long logId);
+
+    /**
+     * 批量删除直播流量记录
+     *
+     * @param logIds 需要删除的数据ID
+     * @return 结果
+     */
+    public int deleteLiveTrafficLogByIds(Long[] logIds);
+
+    @Select({"<script> " +
+            "select c.company_name, SUM(l.internet_traffic) AS total_internet_traffic" +
+            ",DATE_FORMAT(l.create_time, '%Y-%m') AS `month`  from live_traffic_log l " +
+            "left join company c on c.company_id = l.company_id " +
+            "where 1 = 1 " +
+            "<if test= 'maps.year != null '>" +
+            "and YEAR(l.create_time) = #{maps.year} " +
+            "</if>" +
+            "<if test= 'maps.month != null '>"+
+            "and MONTH(l.create_time) = #{maps.month} " +
+            "</if>" +
+            "<if test = ' maps.companyId !=null '> " +
+            "and l.company_id = #{maps.companyId} " +
+            "</if>" +
+            "group by l.company_id,`month` "+
+            "</script>"})
+    List<LiveTrafficLogListVO> selectTrafficByCompany(@Param("maps") LiveTrafficLogParam param);
+}

+ 24 - 0
fs-service-system/src/main/java/com/fs/live/param/LiveFinishUParam.java

@@ -0,0 +1,24 @@
+package com.fs.live.param;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class LiveFinishUParam implements Serializable {
+    private Long duration; //时长
+    private Long liveId;
+    private Long userId;
+    private String qwUserId;
+    private String corpId;
+    private Long companyUserId;
+    private Long companyId;
+    private Long courseId;
+    private BigDecimal bufferRate; //缓冲百分比
+    private String uuId;
+    private Long qwExternalId;
+    private Integer linkType;
+    private String chatId;
+    private Integer videoType;
+}

+ 16 - 0
fs-service-system/src/main/java/com/fs/live/param/LiveTrafficLogParam.java

@@ -0,0 +1,16 @@
+package com.fs.live.param;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class LiveTrafficLogParam {
+
+    @JsonFormat(pattern = "yyyy-MM")
+    private Date time;
+    private Long companyId;
+    private Integer year;
+    private Integer month;
+}

+ 4 - 0
fs-service-system/src/main/java/com/fs/live/service/ILiveAutoTaskService.java

@@ -78,4 +78,8 @@ public interface ILiveAutoTaskService {
     void recalcLiveAutoTask(Long liveId);
 
     void finishLiveAutoTask(LiveAutoTask task);
+
+    List<LiveAutoTask> selectLiveAutoTaskBarrageList(LiveAutoTask liveAutoTask);
+
+    void directInsertLiveAutoTask(LiveAutoTask liveAutoTask);
 }

+ 2 - 0
fs-service-system/src/main/java/com/fs/live/service/ILiveLotteryConfService.java

@@ -95,4 +95,6 @@ public interface ILiveLotteryConfService {
     R detail(LotteryPO lottery);
 
     void finishStatusByLotteryIds(List<Long> ids);
+
+    List<LiveLotteryConf> selectLiveLotteryConfListOn(LiveLotteryConf liveLotteryConf);
 }

+ 2 - 0
fs-service-system/src/main/java/com/fs/live/service/ILiveRedConfService.java

@@ -88,4 +88,6 @@ public interface ILiveRedConfService {
     void redStatusUpdate(Set<Long> redIds);
 
     void updateRedQuantityNum();
+
+    List<LiveRedConf> selectLiveRedConfListOn(LiveRedConf liveRedConf);
 }

+ 70 - 0
fs-service-system/src/main/java/com/fs/live/service/ILiveTrafficLogService.java

@@ -0,0 +1,70 @@
+package com.fs.live.service;
+
+import java.util.List;
+
+import com.fs.common.core.domain.R;
+import com.fs.live.domain.LiveTrafficLog;
+import com.fs.live.param.LiveFinishUParam;
+import com.fs.live.param.LiveTrafficLogParam;
+import com.fs.live.vo.LiveTrafficLogListVO;
+
+/**
+ * 直播流量记录Service接口
+ *
+ * @author fs
+ * @date 2025-10-13
+ */
+public interface ILiveTrafficLogService
+{
+    /**
+     * 查询直播流量记录
+     *
+     * @param logId 直播流量记录ID
+     * @return 直播流量记录
+     */
+    public LiveTrafficLog selectLiveTrafficLogById(Long logId);
+
+    /**
+     * 查询直播流量记录列表
+     *
+     * @param liveTrafficLog 直播流量记录
+     * @return 直播流量记录集合
+     */
+    public List<LiveTrafficLog> selectLiveTrafficLogList(LiveTrafficLog liveTrafficLog);
+
+    /**
+     * 新增直播流量记录
+     *
+     * @param liveTrafficLog 直播流量记录
+     * @return 结果
+     */
+    public int insertLiveTrafficLog(LiveTrafficLog liveTrafficLog);
+
+    /**
+     * 修改直播流量记录
+     *
+     * @param liveTrafficLog 直播流量记录
+     * @return 结果
+     */
+    public int updateLiveTrafficLog(LiveTrafficLog liveTrafficLog);
+
+    /**
+     * 批量删除直播流量记录
+     *
+     * @param logIds 需要删除的直播流量记录ID
+     * @return 结果
+     */
+    public int deleteLiveTrafficLogByIds(Long[] logIds);
+
+    /**
+     * 删除直播流量记录信息
+     *
+     * @param logId 直播流量记录ID
+     * @return 结果
+     */
+    public int deleteLiveTrafficLogById(Long logId);
+
+    List<LiveTrafficLogListVO> selectTrafficByCompany(LiveTrafficLogParam param);
+
+    R getInternetTraffic(LiveFinishUParam param);
+}

+ 53 - 7
fs-service-system/src/main/java/com/fs/live/service/impl/LiveAutoTaskServiceImpl.java

@@ -3,6 +3,7 @@ package com.fs.live.service.impl;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.ZoneId;
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
@@ -12,11 +13,14 @@ import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.live.domain.Live;
 import com.fs.live.domain.LiveAutoTask;
-import com.fs.live.mapper.LiveAutoTaskMapper;
-import com.fs.live.mapper.LiveMapper;
+import com.fs.live.domain.LiveLotteryConf;
+import com.fs.live.domain.LiveRedConf;
+import com.fs.live.mapper.*;
+import com.fs.live.param.LiveLotteryProduct;
 import com.fs.live.service.ILiveAutoTaskService;
 import com.fs.live.service.ILiveGoodsService;
 import com.fs.live.vo.LiveGoodsVo;
+import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -38,6 +42,13 @@ public class LiveAutoTaskServiceImpl implements ILiveAutoTaskService {
     @Autowired
     private LiveAutoTaskMapper baseMapper;
 
+    @Autowired
+    private LiveRedConfMapper liveRedConfMapper;
+    @Autowired
+    private LiveLotteryConfMapper liveLotteryConfMapper;
+    @Autowired
+    private LiveLotteryProductConfMapper lotteryProductConfMapper;
+
     /**
      * 查询直播间自动化任务配置
      *
@@ -96,10 +107,34 @@ public class LiveAutoTaskServiceImpl implements ILiveAutoTaskService {
         liveAutoTask.setTriggerType(2L);
         liveAutoTask.setFinishStatus(0L);
         if(liveAutoTask.getStatus() == null) liveAutoTask.setStatus(1L);
-        LiveGoodsVo liveGoodsVo = goodsService.selectLiveGoodsVoByGoodsId(Long.valueOf(liveAutoTask.getContent()));
-        if(liveGoodsVo == null) return R.error("商品不存在");
-        liveAutoTask.setContent(JSON.toJSONString(liveGoodsVo));
-        baseMapper.insertLiveAutoTask(liveAutoTask);
+        if (liveAutoTask.getTaskType() == 1L) {
+            // 商品
+            LiveGoodsVo liveGoodsVo = goodsService.selectLiveGoodsVoByGoodsId(Long.valueOf(liveAutoTask.getContent()));
+            if(liveGoodsVo == null) return R.error("商品不存在");
+            liveAutoTask.setContent(JSON.toJSONString(liveGoodsVo));
+            baseMapper.insertLiveAutoTask(liveAutoTask);
+        }else if (liveAutoTask.getTaskType() == 2L) {
+            // 红包
+            LiveRedConf liveRedConf = liveRedConfMapper.selectLiveRedConfByRedId(Long.valueOf(liveAutoTask.getContent()));
+            if(liveRedConf == null) return R.error("红包配置不存在");
+            if(liveRedConf.getRedStatus() != 0L) return R.error("红包状态应该为:未发放");
+            liveAutoTask.setContent(JSON.toJSONString(liveRedConf));
+            baseMapper.insertLiveAutoTask(liveAutoTask);
+        }else if (liveAutoTask.getTaskType() == 4L) {
+            // 开启抽奖
+            LiveLotteryConf liveLotteryConf = liveLotteryConfMapper.selectLiveLotteryConfByLotteryId(Long.valueOf(liveAutoTask.getContent()));
+            if(liveLotteryConf == null) return R.error("抽奖配置不存在");
+            if(!"0".equals(liveLotteryConf.getLotteryStatus())) return R.error("抽奖状态应该为:未开始");
+            List<LiveLotteryProduct> prizes = lotteryProductConfMapper.selectLiveLotteryProductConfByLotteryId(liveLotteryConf.getLotteryId());
+            if (prizes == null || prizes.isEmpty()) {
+                return R.error("抽奖配置请先添加奖品");
+            }
+            liveAutoTask.setContent(JSON.toJSONString(liveLotteryConf));
+            baseMapper.insertLiveAutoTask(liveAutoTask);
+        } else {
+            return R.error("任务类型错误");
+        }
+
 
         if (live.getStatus() == 2 && liveAutoTask.getStatus() == 1L) {
             liveAutoTask.setUpdateTime(null);
@@ -224,7 +259,8 @@ public class LiveAutoTaskServiceImpl implements ILiveAutoTaskService {
     public void recalcLiveAutoTask(Long liveId) {
         Live live = liveMapper.selectLiveByLiveId(liveId);
         if(live == null) return;
-        List<LiveAutoTask> liveAutoTasks = baseMapper.selectLiveAutoTaskByLiveId(liveId);
+        // 目前只重算 推送商品
+        List<LiveAutoTask> liveAutoTasks = baseMapper.recalcLiveAutoTaskQuery(liveId);
         Date now = new Date();
         for (LiveAutoTask liveAutoTask : liveAutoTasks) {
             liveAutoTask.setAbsValue(getTriggerValue(liveAutoTask.getTriggerValue(), live.getStartTime()));
@@ -238,4 +274,14 @@ public class LiveAutoTaskServiceImpl implements ILiveAutoTaskService {
     public void finishLiveAutoTask(LiveAutoTask task) {
         baseMapper.finishLiveAutoTask(task);
     }
+
+    @Override
+    public List<LiveAutoTask> selectLiveAutoTaskBarrageList(LiveAutoTask liveAutoTask) {
+        return baseMapper.selectLiveAutoTaskBarrageList(liveAutoTask);
+    }
+
+    @Override
+    public void directInsertLiveAutoTask(LiveAutoTask liveAutoTask) {
+        baseMapper.insertLiveAutoTask(liveAutoTask);
+    }
 }

+ 6 - 4
fs-service-system/src/main/java/com/fs/live/service/impl/LiveLotteryConfServiceImpl.java

@@ -21,10 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -269,5 +266,10 @@ public class LiveLotteryConfServiceImpl implements ILiveLotteryConfService {
         baseMapper.finishStatusByLotteryIds(ids);
     }
 
+    @Override
+    public List<LiveLotteryConf> selectLiveLotteryConfListOn(LiveLotteryConf liveLotteryConf) {
+        return baseMapper.selectLiveLotteryConfListOn(liveLotteryConf);
+    }
+
 
 }

+ 5 - 0
fs-service-system/src/main/java/com/fs/live/service/impl/LiveRedConfServiceImpl.java

@@ -334,6 +334,11 @@ public class LiveRedConfServiceImpl implements ILiveRedConfService {
         }
     }
 
+    @Override
+    public List<LiveRedConf> selectLiveRedConfListOn(LiveRedConf liveRedConf) {
+        return baseMapper.selectLiveRedConfListOn(liveRedConf);
+    }
+
     private void updateDbByRed(LiveRedConf red) {
         // 更新数据库
         Date now = new Date();

+ 73 - 21
fs-service-system/src/main/java/com/fs/live/service/impl/LiveServiceImpl.java

@@ -16,6 +16,7 @@ import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.bean.BeanUtils;
 import com.fs.live.domain.*;
 import com.fs.live.mapper.*;
+import com.fs.live.param.LiveLotteryProduct;
 import com.fs.live.param.LiveReplayParam;
 import com.fs.live.service.*;
 import com.fs.live.utils.ProcessManager;
@@ -233,11 +234,11 @@ public class LiveServiceImpl implements ILiveService
             dataValue.setValue(mapData.get(k));
             data.put(k, dataValue);
         });
-        notifyTask.setData(JSON.toJSONString(data));
-        return R.ok("success");
-//        fsMiniprogramSubNotifyTaskMapper.insert(notifyTask);
-
+//        notifyTask.setData(JSON.toJSONString(data));
 //        return R.ok("success");
+        fsMiniprogramSubNotifyTaskMapper.insert(notifyTask);
+
+        return R.ok("success");
     }
 
     /**
@@ -309,6 +310,7 @@ public class LiveServiceImpl implements ILiveService
         liveVideo.setVideoUrl(live.getVideoUrl());
         liveVideo.setVideoType(1);
         liveVideo.setDuration(live.getDuration());
+        liveVideo.setFileSize(live.getFileSize());
         liveVideoService.insertLiveVideo(liveVideo);
 
         //新增直播数据表
@@ -341,6 +343,7 @@ public class LiveServiceImpl implements ILiveService
             liveVideo.setVideoUrl(live.getVideoUrl());
             liveVideo.setUpdateTime(DateUtils.getNowDate());
             liveVideo.setDuration(live.getDuration());
+            liveVideo.setFileSize(live.getFileSize());
             liveVideoService.updateLiveVideo(liveVideo);
         }
         if (StringUtils.isNotEmpty(live.getLiveConfig())) {
@@ -686,6 +689,34 @@ public class LiveServiceImpl implements ILiveService
                 liveVideoService.insertLiveVideo(videoEntity);
             }
         }
+
+        // 运营自动化
+        List<LiveAutoTask> liveAutoTasksList = liveAutoTaskService.selectLiveAutoTaskByLiveId(existLiveId);
+        List<LiveAutoTask> goodsTask = liveAutoTasksList.stream().filter(liveAutoTask -> liveAutoTask.getTaskType() == 1L).collect(Collectors.toList());
+        Map<Long, LiveAutoTask> redMap = liveAutoTasksList.stream()
+                .filter(liveAutoTask -> liveAutoTask.getTaskType() == 2L)
+                .collect(Collectors.toMap(liveAutoTask -> {
+                    return parseIdFromContent(liveAutoTask.getContent(),"redId");
+                        }, liveAutoTask -> liveAutoTask, (existing, replacement) -> replacement
+                ));
+        Map<Long, LiveAutoTask> lotteryMap = liveAutoTasksList.stream()
+                .filter(liveAutoTask -> liveAutoTask.getTaskType() == 4L)
+                .collect(Collectors.toMap(liveAutoTask -> {
+                    return parseIdFromContent(liveAutoTask.getContent(),"lotteryId");
+                        }, liveAutoTask -> liveAutoTask, (existing, replacement) -> replacement
+                ));
+        if (!goodsTask.isEmpty()) {
+            LiveAutoTask liveAutoTaskEntity = new LiveAutoTask();
+            for (LiveAutoTask liveAutoTask : goodsTask) {
+                BeanUtils.copyBeanProp(liveAutoTaskEntity, liveAutoTask);
+                liveAutoTaskEntity.setId(null);
+                liveAutoTaskEntity.setLiveId(newLiveId);
+                liveAutoTaskEntity.setCreateTime(now);
+                liveAutoTaskEntity.setUpdateTime(now);
+                liveAutoTaskEntity.setFinishStatus(0L);
+                liveAutoTaskService.copyInsertLiveAutoTask(liveAutoTaskEntity);
+            }
+        }
         //直播间红包配置
         List<LiveRedConf> liveRedConfs = liveRedConfService.selectByLiveId(existLiveId);
         if (!liveRedConfs.isEmpty()) {
@@ -698,12 +729,26 @@ public class LiveServiceImpl implements ILiveService
                 liveRedConfEntity.setCreateTime(now);
                 liveRedConfEntity.setTotalSend(0L);
                 liveRedConfService.insertLiveRedConf(liveRedConfEntity);
+                if (redMap.containsKey(liveRedConf.getRedId())) {
+                    LiveAutoTask liveAutoTaskEntity = new LiveAutoTask();
+                    LiveAutoTask liveAutoTask = redMap.get(liveRedConf.getRedId());
+                    BeanUtils.copyBeanProp(liveAutoTaskEntity, liveAutoTask);
+                    liveAutoTaskEntity.setId(null);
+                    liveAutoTaskEntity.setLiveId(newLiveId);
+                    liveAutoTaskEntity.setCreateTime(now);
+                    liveAutoTaskEntity.setUpdateTime(now);
+                    liveAutoTaskEntity.setFinishStatus(0L);
+                    liveAutoTaskEntity.setContent(JSON.toJSONString(liveRedConfEntity));
+                    liveAutoTaskService.copyInsertLiveAutoTask(liveAutoTaskEntity);
+                }
             }
         }
         // 直播间礼物配置
         List<LiveLotteryConf> liveLotteryConfs = liveLotteryConfService.selectByLiveId(existLiveId);
         if (!liveLotteryConfs.isEmpty()) {
             LiveLotteryConf liveLotteryConfEntity = new LiveLotteryConf();
+            List<Long> lotteryIds = liveLotteryConfs.stream().map(LiveLotteryConf::getLotteryId).collect(Collectors.toList());
+            List<LiveLotteryProductConf> products = liveLotteryProductConfMapper.selectEntityByIds(lotteryIds);
             for (LiveLotteryConf liveLotteryConf : liveLotteryConfs) {
                 BeanUtils.copyBeanProp(liveLotteryConfEntity, liveLotteryConf);
                 liveLotteryConfEntity.setLotteryId(null);
@@ -711,6 +756,24 @@ public class LiveServiceImpl implements ILiveService
                 liveLotteryConfEntity.setLotteryStatus(String.valueOf(0));
                 liveLotteryConfEntity.setCreateTime(now);
                 liveLotteryConfService.insertLiveLotteryConf(liveLotteryConfEntity);
+                products.stream().filter(product -> product.getLotteryId().equals(liveLotteryConf.getLotteryId()))
+                        .forEach(product -> {
+                            product.setId(null);
+                            product.setLotteryId(liveLotteryConfEntity.getLotteryId());
+                            liveLotteryProductConfMapper.insertLiveLotteryProductConf(product);
+                        });
+                if (lotteryMap.containsKey(liveLotteryConf.getLotteryId())) {
+                    LiveAutoTask liveAutoTaskEntity = new LiveAutoTask();
+                    LiveAutoTask liveAutoTask = lotteryMap.get(liveLotteryConf.getLotteryId());
+                    BeanUtils.copyBeanProp(liveAutoTaskEntity, liveAutoTask);
+                    liveAutoTaskEntity.setId(null);
+                    liveAutoTaskEntity.setLiveId(newLiveId);
+                    liveAutoTaskEntity.setCreateTime(now);
+                    liveAutoTaskEntity.setUpdateTime(now);
+                    liveAutoTaskEntity.setFinishStatus(0L);
+                    liveAutoTaskEntity.setContent(JSON.toJSONString(liveLotteryConfEntity));
+                    liveAutoTaskService.copyInsertLiveAutoTask(liveAutoTaskEntity);
+                }
             }
         }
         // 直播间商品
@@ -727,27 +790,16 @@ public class LiveServiceImpl implements ILiveService
                 liveGoodsService.insertLiveGoods(liveGoodsEntity);
             }
         }
-        // 运营自动化
-        List<LiveAutoTask> liveAutoTasksList = liveAutoTaskService.selectLiveAutoTaskByLiveId(existLiveId);
-        if (!liveAutoTasksList.isEmpty()) {
-            LiveAutoTask liveAutoTaskEntity = new LiveAutoTask();
-            for (LiveAutoTask liveAutoTask : liveAutoTasksList) {
-                BeanUtils.copyBeanProp(liveAutoTaskEntity, liveAutoTask);
-                liveAutoTaskEntity.setId(null);
-                liveAutoTaskEntity.setLiveId(newLiveId);
-                liveAutoTaskEntity.setCreateTime(now);
-                liveAutoTaskEntity.setUpdateTime(now);
-                liveAutoTaskEntity.setFinishStatus(0L);
-                liveAutoTaskService.copyInsertLiveAutoTask(liveAutoTaskEntity);
-            }
-        }
-
-
-
 
         return R.ok("复制成功");
     }
 
+    private Long parseIdFromContent(String content, String key) {
+        // 假设content是JSON字符串,使用FastJSON解析
+        JSONObject jsonObject = JSON.parseObject(content);
+        return jsonObject.getLong(key);
+    }
+
 
 
     /**

+ 155 - 0
fs-service-system/src/main/java/com/fs/live/service/impl/LiveTrafficLogServiceImpl.java

@@ -0,0 +1,155 @@
+package com.fs.live.service.impl;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+import com.fs.common.core.domain.R;
+import com.fs.common.utils.DateUtils;
+import com.fs.common.utils.StringUtils;
+import com.fs.live.domain.LiveVideo;
+import com.fs.live.mapper.LiveVideoMapper;
+import com.fs.live.param.LiveFinishUParam;
+import com.fs.live.param.LiveTrafficLogParam;
+import com.fs.live.vo.LiveTrafficLogListVO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.fs.live.mapper.LiveTrafficLogMapper;
+import com.fs.live.domain.LiveTrafficLog;
+import com.fs.live.service.ILiveTrafficLogService;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * 直播流量记录Service业务层处理
+ *
+ * @author fs
+ * @date 2025-10-13
+ */
+@Service
+@Slf4j
+public class LiveTrafficLogServiceImpl implements ILiveTrafficLogService
+{
+    @Autowired
+    private LiveTrafficLogMapper liveTrafficLogMapper;
+    @Autowired
+    private LiveVideoMapper liveVideoMapper;
+
+    /**
+     * 查询直播流量记录
+     *
+     * @param logId 直播流量记录ID
+     * @return 直播流量记录
+     */
+    @Override
+    public LiveTrafficLog selectLiveTrafficLogById(Long logId)
+    {
+        return liveTrafficLogMapper.selectLiveTrafficLogById(logId);
+    }
+
+    /**
+     * 查询直播流量记录列表
+     *
+     * @param liveTrafficLog 直播流量记录
+     * @return 直播流量记录
+     */
+    @Override
+    public List<LiveTrafficLog> selectLiveTrafficLogList(LiveTrafficLog liveTrafficLog)
+    {
+        return liveTrafficLogMapper.selectLiveTrafficLogList(liveTrafficLog);
+    }
+
+    /**
+     * 新增直播流量记录
+     *
+     * @param liveTrafficLog 直播流量记录
+     * @return 结果
+     */
+    @Override
+    public int insertLiveTrafficLog(LiveTrafficLog liveTrafficLog)
+    {
+        liveTrafficLog.setCreateTime(DateUtils.getNowDate());
+        return liveTrafficLogMapper.insertLiveTrafficLog(liveTrafficLog);
+    }
+
+    /**
+     * 修改直播流量记录
+     *
+     * @param liveTrafficLog 直播流量记录
+     * @return 结果
+     */
+    @Override
+    public int updateLiveTrafficLog(LiveTrafficLog liveTrafficLog)
+    {
+        return liveTrafficLogMapper.updateLiveTrafficLog(liveTrafficLog);
+    }
+
+    /**
+     * 批量删除直播流量记录
+     *
+     * @param logIds 需要删除的直播流量记录ID
+     * @return 结果
+     */
+    @Override
+    public int deleteLiveTrafficLogByIds(Long[] logIds)
+    {
+        return liveTrafficLogMapper.deleteLiveTrafficLogByIds(logIds);
+    }
+
+    /**
+     * 删除直播流量记录信息
+     *
+     * @param logId 直播流量记录ID
+     * @return 结果
+     */
+    @Override
+    public int deleteLiveTrafficLogById(Long logId)
+    {
+        return liveTrafficLogMapper.deleteLiveTrafficLogById(logId);
+    }
+
+    @Override
+    public List<LiveTrafficLogListVO> selectTrafficByCompany(LiveTrafficLogParam param) {
+        return liveTrafficLogMapper.selectTrafficByCompany(param);
+    }
+
+    @Override
+    @Transactional
+    public R getInternetTraffic(LiveFinishUParam param) {
+        try {
+            LiveTrafficLog trafficLog = new LiveTrafficLog();
+            trafficLog.setQwExternalContactId(param.getQwExternalId());
+            trafficLog.setCreateTime(new Date());
+            BeanUtils.copyProperties(param, trafficLog);
+
+            List<LiveVideo> liveVideos = liveVideoMapper.selectByLiveIdAndType(param.getLiveId(),param.getVideoType());
+
+            LiveVideo video = liveVideos.get(0);
+            if (video == null) {
+                return R.error("视频不存在");
+            }
+
+            // 计算流量
+            BigDecimal result = param.getBufferRate().divide(new BigDecimal("100"), 4, RoundingMode.HALF_UP);
+            BigDecimal longAsBigDecimal = BigDecimal.valueOf(video.getFileSize());
+            long roundedResult = result.multiply(longAsBigDecimal).setScale(0, RoundingMode.HALF_UP).longValue();
+            trafficLog.setInternetTraffic(roundedResult);
+
+            // 处理 UUID 为空的情况
+            if (StringUtils.isNotEmpty(trafficLog.getUuId())) {
+                // 直接插入或更新
+//                logger.error("zyp \n【插入或更新流量】:{}",trafficLog);
+                liveTrafficLogMapper.insertLiveTrafficLog(trafficLog);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            // 打印参数param和异常信息
+            log.error("zyp \n【插入或更新流量失败】参数: {}, 错误信息:{}", param, e.getMessage(), e);
+            return R.error();
+        }
+        return R.ok();
+    }
+}

+ 6 - 0
fs-service-system/src/main/java/com/fs/live/service/impl/LiveWatchUserServiceImpl.java

@@ -156,6 +156,10 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
             liveWatchUser.setUpdateTime(DateUtils.getNowDate());
             baseMapper.insertLiveWatchUser(liveWatchUser);
         }
+        liveWatchUser.setAvatar(fsUserVO.getAvatar());
+        liveWatchUser.setNickName(fsUserVO.getNickname());
+        String hashKey  = String.format(LiveKeysConstant.LIVE_WATCH_USERS, liveId);
+        redisUtil.hashPut(hashKey, String.valueOf(userId), JSON.toJSONString(liveWatchUser));
         return liveWatchUser;
     }
     @Override
@@ -164,6 +168,8 @@ public class LiveWatchUserServiceImpl implements ILiveWatchUserService {
         liveWatchUser.setUpdateTime(DateUtils.getNowDate());
         liveWatchUser.setOnline(1);
         baseMapper.updateLiveWatchUser(liveWatchUser);
+        String hashKey  = String.format(LiveKeysConstant.LIVE_WATCH_USERS, liveId);
+        redisUtil.hashDelete(hashKey, String.valueOf(userId));
         return liveWatchUser;
     }
 

+ 22 - 0
fs-service-system/src/main/java/com/fs/live/vo/LiveTrafficLogListVO.java

@@ -0,0 +1,22 @@
+package com.fs.live.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 短链课程流量记录对象 fs_course_traffic_log
+ *
+ * @author fs
+ * @date 2024-10-31
+ */
+@Data
+public class LiveTrafficLogListVO implements Serializable
+{
+    private String companyName;
+
+    private Long totalInternetTraffic;
+
+    private String month;
+
+}

+ 8 - 0
fs-service-system/src/main/resources/mapper/live/LiveLotteryProductConfMapper.xml

@@ -139,4 +139,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 #{id}
             </foreach>
     </select>
+    <select id="selectEntityByIds"  resultType="com.fs.live.domain.LiveLotteryProductConf">
+        select llpc.*
+               from live_lottery_product_conf llpc
+            where llpc.lottery_id in
+            <foreach item="id" collection="lotteryIds" separator="," open="(" close=")">
+                #{id}
+            </foreach>
+    </select>
 </mapper>

+ 2 - 2
fs-service-system/src/main/resources/mapper/live/LiveMapper.xml

@@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="liveList" parameterType="Live" resultMap="LiveResult">
         select a.live_id, a.company_id, a.company_user_id,talent_id, a.live_name, a.is_audit, a.live_desc, a.show_type, a.status, a.anchor_id,
         a.live_type, a.start_time, a.finish_time, a.live_img_url, a.live_config, a.id_card_url, a.is_show, a.is_del, a.qw_qr_code, a.rtmp_url,
-        a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url,c.company_name
+        a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url,c.company_name,b.file_size
         from live
         a
         left join live_video b on a.live_id = b.live_id
@@ -57,7 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select a.live_id, a.company_id, a.company_user_id,talent_id, a.live_name, a.is_audit, a.live_desc, a.show_type, a.status, a.anchor_id,
                a.live_type, a.start_time, a.finish_time, a.live_img_url, a.live_config, a.id_card_url, a.is_show, a.is_del, a.qw_qr_code, a.rtmp_url,
                a.flv_hls_url, a.create_time, a.create_by, a.update_by, a.update_time, a.remark,config_json, b.video_url
-                ,c.live_code_url,d.company_name
+                ,c.live_code_url,d.company_name,b.file_size
 
         from live a
         left join live_video b on a.live_id = b.live_id

+ 101 - 0
fs-service-system/src/main/resources/mapper/live/LiveTrafficLogMapper.xml

@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fs.live.mapper.LiveTrafficLogMapper">
+    
+    <resultMap type="LiveTrafficLog" id="LiveTrafficLogResult">
+        <result property="logId"    column="log_id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="liveId"    column="live_id"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="qwExternalContactId"    column="qw_external_contact_id"    />
+        <result property="internetTraffic"    column="internet_traffic"    />
+        <result property="qwUserId"    column="qw_user_id"    />
+        <result property="companyUserId"    column="company_user_id"    />
+        <result property="companyId"    column="company_id"    />
+        <result property="courseId"    column="course_id"    />
+        <result property="uuId"    column="uu_id"    />
+    </resultMap>
+
+    <sql id="selectLiveTrafficLogVo">
+        select log_id, user_id, live_id, create_time, qw_external_contact_id, internet_traffic, qw_user_id, company_user_id, company_id, course_id, uu_id from live_traffic_log
+    </sql>
+
+    <select id="selectLiveTrafficLogList" parameterType="LiveTrafficLog" resultMap="LiveTrafficLogResult">
+        <include refid="selectLiveTrafficLogVo"/>
+        <where>  
+            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="liveId != null "> and live_id = #{liveId}</if>
+            <if test="qwExternalContactId != null "> and qw_external_contact_id = #{qwExternalContactId}</if>
+            <if test="internetTraffic != null "> and internet_traffic = #{internetTraffic}</if>
+            <if test="qwUserId != null  and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
+            <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
+            <if test="companyId != null "> and company_id = #{companyId}</if>
+            <if test="courseId != null "> and course_id = #{courseId}</if>
+            <if test="uuId != null  and uuId != ''"> and uu_id = #{uuId}</if>
+        </where>
+    </select>
+    
+    <select id="selectLiveTrafficLogById" parameterType="Long" resultMap="LiveTrafficLogResult">
+        <include refid="selectLiveTrafficLogVo"/>
+        where log_id = #{logId}
+    </select>
+        
+    <insert id="insertLiveTrafficLog" parameterType="LiveTrafficLog" useGeneratedKeys="true" keyProperty="logId">
+        insert into live_traffic_log
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="userId != null">user_id,</if>
+            <if test="liveId != null">live_id,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="qwExternalContactId != null">qw_external_contact_id,</if>
+            <if test="internetTraffic != null">internet_traffic,</if>
+            <if test="qwUserId != null">qw_user_id,</if>
+            <if test="companyUserId != null">company_user_id,</if>
+            <if test="companyId != null">company_id,</if>
+            <if test="courseId != null">course_id,</if>
+            <if test="uuId != null">uu_id,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="userId != null">#{userId},</if>
+            <if test="liveId != null">#{liveId},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="qwExternalContactId != null">#{qwExternalContactId},</if>
+            <if test="internetTraffic != null">#{internetTraffic},</if>
+            <if test="qwUserId != null">#{qwUserId},</if>
+            <if test="companyUserId != null">#{companyUserId},</if>
+            <if test="companyId != null">#{companyId},</if>
+            <if test="courseId != null">#{courseId},</if>
+            <if test="uuId != null">#{uuId},</if>
+         </trim>
+    </insert>
+
+    <update id="updateLiveTrafficLog" parameterType="LiveTrafficLog">
+        update live_traffic_log
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="liveId != null">live_id = #{liveId},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="qwExternalContactId != null">qw_external_contact_id = #{qwExternalContactId},</if>
+            <if test="internetTraffic != null">internet_traffic = #{internetTraffic},</if>
+            <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
+            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
+            <if test="companyId != null">company_id = #{companyId},</if>
+            <if test="courseId != null">course_id = #{courseId},</if>
+            <if test="uuId != null">uu_id = #{uuId},</if>
+        </trim>
+        where log_id = #{logId}
+    </update>
+
+    <delete id="deleteLiveTrafficLogById" parameterType="Long">
+        delete from live_traffic_log where log_id = #{logId}
+    </delete>
+
+    <delete id="deleteLiveTrafficLogByIds" parameterType="String">
+        delete from live_traffic_log where log_id in 
+        <foreach item="logId" collection="array" open="(" separator="," close=")">
+            #{logId}
+        </foreach>
+    </delete>
+    
+</mapper>

+ 5 - 1
fs-service-system/src/main/resources/mapper/live/LiveVideoMapper.xml

@@ -16,10 +16,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateTime"    column="update_time"    />
         <result property="duration"    column="duration"    />
         <result property="remark"    column="remark"    />
+        <result property="fileSize"    column="file_size"    />
     </resultMap>
 
     <sql id="selectLiveVideoVo">
-        select video_id, live_id, video_url, video_type, sort, create_time, create_by, update_by, update_time, remark,duration from live_video
+        select video_id, live_id, video_url, video_type, sort, create_time, create_by, update_by, update_time, remark,duration,file_size from live_video
     </sql>
 
     <select id="selectLiveVideoList" parameterType="LiveVideo" resultMap="LiveVideoResult">
@@ -55,6 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">update_time,</if>
             <if test="remark != null">remark,</if>
             <if test="duration != null">duration,</if>
+            <if test="fileSize != null">file_size,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="liveId != null">#{liveId},</if>
@@ -67,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateTime != null">#{updateTime},</if>
             <if test="remark != null">#{remark},</if>
             <if test="duration != null">#{duration},</if>
+            <if test="fileSize != null">#{fileSize},</if>
          </trim>
     </insert>
 
@@ -83,6 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="remark != null">remark = #{remark},</if>
+            <if test="fileSize != null">file_size = #{fileSize},</if>
         </trim>
         where video_id = #{videoId}
     </update>

+ 29 - 0
fs-user-app/src/main/java/com/fs/app/controller/LiveTrafficLogController.java

@@ -0,0 +1,29 @@
+package com.fs.app.controller;
+
+import com.fs.app.annotation.Login;
+import com.fs.common.core.domain.R;
+import com.fs.live.param.LiveFinishUParam;
+import com.fs.live.service.ILiveTrafficLogService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/app/live/liveTrafficLog")
+public class LiveTrafficLogController extends AppBaseController {
+    @Autowired
+    private ILiveTrafficLogService liveTrafficLogService;
+
+    @Login
+    @ApiOperation("获取缓冲流量 ps:前端定时调")
+    @PostMapping("/getInternetTraffic")
+    public R getInternetTraffic(@RequestBody LiveFinishUParam param) {
+        Long userId = Long.parseLong(getUserId());
+        param.setUserId(userId);
+        return liveTrafficLogService.getInternetTraffic(param);
+    }
+
+}