Ver Fonte

迁移批量红包问题,迁移流量统计问题

yfh há 3 semanas atrás
pai
commit
8239a58bb2

+ 8 - 0
fs-admin/src/main/java/com/fs/api/controller/IndexStatisticsController.java

@@ -4,6 +4,8 @@ import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.statis.StatisticsRedisConstant;
 import com.fs.statis.dto.*;
+import com.fs.system.domain.SysConfig;
+import com.fs.system.service.ISysConfigService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -20,6 +22,9 @@ import static com.fs.statis.StatisticsRedisConstant.*;
 public class IndexStatisticsController {
     @Autowired
     private RedisCache redisCache;
+
+    @Autowired
+    private ISysConfigService sysConfigService;
     /**
      * 分析概览
      */
@@ -59,6 +64,9 @@ public class IndexStatisticsController {
     @GetMapping("/trafficLog")
     public R getTrafficLog(){
         TrafficLogDTO trafficLogDTO = redisCache.getCacheObject(DATA_OVERVIEW_TRAFFIC_LOG);
+        SysConfig sysConfig = sysConfigService.selectConfigByConfigKey("redPacket.Traffic.config");
+        String configValue = sysConfig.getConfigValue();
+        trafficLogDTO.setTraffic(configValue);
         return R.ok().put("data",trafficLogDTO);
     }
 

+ 16 - 4
fs-admin/src/main/java/com/fs/course/controller/FsUserCoursePeriodController.java

@@ -10,10 +10,7 @@ import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.course.domain.FsUserCoursePeriod;
 import com.fs.course.domain.FsUserCoursePeriodDays;
 import com.fs.course.domain.FsUserCourseVideoRedPackage;
-import com.fs.course.param.CompanyRedPacketParam;
-import com.fs.course.param.FsBatchPeriodRedPackageParam;
-import com.fs.course.param.PeriodCountParam;
-import com.fs.course.param.PeriodStatisticCountParam;
+import com.fs.course.param.*;
 import com.fs.course.service.IFsUserCoursePeriodDaysService;
 import com.fs.course.service.IFsUserCoursePeriodService;
 import com.fs.course.service.IFsUserCourseVideoRedPackageService;
@@ -25,6 +22,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
@@ -273,4 +271,18 @@ public class FsUserCoursePeriodController extends BaseController {
         List<FsUserCoursePeriod> list = fsUserCoursePeriodService.selectFsPeriodlist(param);
         return R.ok().put("data", list);
     }
+
+    @PreAuthorize("@ss.hasPermi('course:period:setCompanyRedPacket')")
+    @ApiOperation("按公司批量保存设置红包金额")
+    @PostMapping("/batchRedPacket/byCompany")
+    public R batchRedPacketByCompany(@Validated @RequestBody BatchCompanyRedPackageParam param) {
+        try {
+            fsUserCourseVideoRedPackageService.batchRedPacketByCompany(param);
+        } catch (Exception e) {
+            logger.error("按恭送批量保存设置红包金额-失败!,入参:{}", param);
+            return R.error("保存失败!");
+        }
+        return R.ok();
+    }
+
 }

+ 0 - 7
fs-company/src/main/java/com/fs/company/controller/company/IndexStatisticsController.java

@@ -28,10 +28,6 @@ public class IndexStatisticsController {
 
     @Autowired
     private TokenService tokenService;
-
-
-    @Autowired
-    private ISysConfigService sysConfigService;
     /**
      * 分析概览
      */
@@ -77,9 +73,6 @@ public class IndexStatisticsController {
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         Long companyId = loginUser.getCompany().getCompanyId();
         TrafficLogDTO trafficLogDTO = redisCache.getCacheObject(String.format("%s:%d",DATA_OVERVIEW_TRAFFIC_LOG,companyId));
-        SysConfig sysConfig = sysConfigService.selectConfigByConfigKey("redPacket.Traffic.config");
-        String configValue = sysConfig.getConfigValue();
-        trafficLogDTO.setTraffic(configValue);
         return R.ok().put("data",trafficLogDTO);
     }
 

+ 14 - 8
fs-service/src/main/java/com/fs/course/service/IFsUserCourseVideoRedPackageService.java

@@ -2,19 +2,20 @@ package com.fs.course.service;
 
 import java.util.List;
 import com.fs.course.domain.FsUserCourseVideoRedPackage;
+import com.fs.course.param.BatchCompanyRedPackageParam;
 import com.fs.course.param.FsBatchPeriodRedPackageParam;
 
 /**
  * 课程公司红包Service接口
- * 
+ *
  * @author fs
  * @date 2024-10-25
  */
-public interface IFsUserCourseVideoRedPackageService 
+public interface IFsUserCourseVideoRedPackageService
 {
     /**
      * 查询课程公司红包
-     * 
+     *
      * @param id 课程公司红包主键
      * @return 课程公司红包
      */
@@ -22,7 +23,7 @@ public interface IFsUserCourseVideoRedPackageService
 
     /**
      * 查询课程公司红包列表
-     * 
+     *
      * @param fsUserCourseVideoRedPackage 课程公司红包
      * @return 课程公司红包集合
      */
@@ -30,7 +31,7 @@ public interface IFsUserCourseVideoRedPackageService
 
     /**
      * 新增课程公司红包
-     * 
+     *
      * @param fsUserCourseVideoRedPackage 课程公司红包
      * @return 结果
      */
@@ -38,7 +39,7 @@ public interface IFsUserCourseVideoRedPackageService
 
     /**
      * 修改课程公司红包
-     * 
+     *
      * @param fsUserCourseVideoRedPackage 课程公司红包
      * @return 结果
      */
@@ -46,7 +47,7 @@ public interface IFsUserCourseVideoRedPackageService
 
     /**
      * 批量删除课程公司红包
-     * 
+     *
      * @param ids 需要删除的课程公司红包主键集合
      * @return 结果
      */
@@ -54,7 +55,7 @@ public interface IFsUserCourseVideoRedPackageService
 
     /**
      * 删除课程公司红包信息
-     * 
+     *
      * @param id 课程公司红包主键
      * @return 结果
      */
@@ -78,4 +79,9 @@ public interface IFsUserCourseVideoRedPackageService
     List<FsUserCourseVideoRedPackage> selectByRuleIds(List<Long> ruleIds);
 
     void batchSaveFsUserCourseVideoRedPackage(List<FsUserCourseVideoRedPackage> redPackage);
+    /**
+     * 按照公司批量设置红包
+     * @param param 入参
+     */
+    void batchRedPacketByCompany(BatchCompanyRedPackageParam param);
 }

+ 50 - 8
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoRedPackageServiceImpl.java

@@ -4,10 +4,13 @@ import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
+import com.fs.common.exception.CustomException;
+import com.fs.common.utils.StringUtils;
 import com.fs.course.domain.FsUserCoursePeriod;
 import com.fs.course.domain.FsUserCoursePeriodDays;
 import com.fs.course.mapper.FsUserCoursePeriodDaysMapper;
 import com.fs.course.mapper.FsUserCoursePeriodMapper;
+import com.fs.course.param.BatchCompanyRedPackageParam;
 import com.fs.course.param.FsBatchPeriodRedPackageParam;
 import com.google.common.collect.Lists;
 import org.apache.ibatis.annotations.Param;
@@ -23,12 +26,12 @@ import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 课程公司红包Service业务层处理
- * 
+ *
  * @author fs
  * @date 2024-10-25
  */
 @Service
-public class FsUserCourseVideoRedPackageServiceImpl implements IFsUserCourseVideoRedPackageService 
+public class FsUserCourseVideoRedPackageServiceImpl implements IFsUserCourseVideoRedPackageService
 {
     @Autowired
     private FsUserCourseVideoRedPackageMapper fsUserCourseVideoRedPackageMapper;
@@ -44,7 +47,7 @@ public class FsUserCourseVideoRedPackageServiceImpl implements IFsUserCourseVide
 
     /**
      * 查询课程公司红包
-     * 
+     *
      * @param id 课程公司红包主键
      * @return 课程公司红包
      */
@@ -56,7 +59,7 @@ public class FsUserCourseVideoRedPackageServiceImpl implements IFsUserCourseVide
 
     /**
      * 查询课程公司红包列表
-     * 
+     *
      * @param fsUserCourseVideoRedPackage 课程公司红包
      * @return 课程公司红包
      */
@@ -68,7 +71,7 @@ public class FsUserCourseVideoRedPackageServiceImpl implements IFsUserCourseVide
 
     /**
      * 新增课程公司红包
-     * 
+     *
      * @param fsUserCourseVideoRedPackage 课程公司红包
      * @return 结果
      */
@@ -80,7 +83,7 @@ public class FsUserCourseVideoRedPackageServiceImpl implements IFsUserCourseVide
 
     /**
      * 修改课程公司红包
-     * 
+     *
      * @param fsUserCourseVideoRedPackage 课程公司红包
      * @return 结果
      */
@@ -92,7 +95,7 @@ public class FsUserCourseVideoRedPackageServiceImpl implements IFsUserCourseVide
 
     /**
      * 批量删除课程公司红包
-     * 
+     *
      * @param ids 需要删除的课程公司红包主键
      * @return 结果
      */
@@ -104,7 +107,7 @@ public class FsUserCourseVideoRedPackageServiceImpl implements IFsUserCourseVide
 
     /**
      * 删除课程公司红包信息
-     * 
+     *
      * @param id 课程公司红包主键
      * @return 结果
      */
@@ -239,5 +242,44 @@ public class FsUserCourseVideoRedPackageServiceImpl implements IFsUserCourseVide
     public void batchSaveFsUserCourseVideoRedPackage(List<FsUserCourseVideoRedPackage> redPackage) {
         fsUserCourseVideoRedPackageMapper.batchSaveFsUserCourseVideoRedPackage(redPackage);
     }
+    /**
+     * 按照公司批量设置红包
+     * @param param 入参
+     */
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void batchRedPacketByCompany(BatchCompanyRedPackageParam param) {
+        FsUserCoursePeriod period = userCoursePeriodMapper.selectFsUserCoursePeriodById(param.getPeriodId());
+        if (Objects.isNull(period)) {
+            throw new CustomException("营期不存在");
+        }
+
+        Set<Long> targetCompanyIds = new HashSet<>(param.getCompanyIds());
+        Set<Long> companyIds = Arrays.stream(period.getCompanyId().split(","))
+                .filter(StringUtils::isNotBlank)
+                .map(Long::valueOf)
+                .filter(targetCompanyIds::contains)
+                .collect(Collectors.toSet());
+
+        if (companyIds.isEmpty()) {
+            throw new CustomException("当前营期不包含所选公司");
+        }
+
+        List<FsUserCoursePeriodDays> periodVideos = userCoursePeriodDaysMapper.selectCourseVideoList(Collections.singleton(period.getPeriodId()));
+
+        List<FsUserCourseVideoRedPackage> fsRedPackageList = companyIds.stream()
+                .flatMap(companyId -> periodVideos.stream().map(video -> {
+                    FsUserCourseVideoRedPackage redPkg = new FsUserCourseVideoRedPackage();
+                    redPkg.setCompanyId(companyId);
+                    redPkg.setVideoId(video.getVideoId());
+                    redPkg.setRedPacketMoney(param.getRedPacketMoney());
+                    redPkg.setPeriodId(period.getPeriodId());
+                    redPkg.setDataType(2);
+                    return redPkg;
+                }))
+                .collect(Collectors.toList());
+
+        this.batchSaveCompanyRedPackage(fsRedPackageList);
+    }
 
 }