Browse Source

Merge branch 'master-fby' of http://1.14.104.71:10880/root/ylrz_scrm_java into master-fby

caoliqin 1 week ago
parent
commit
6182b00a28

+ 9 - 0
fs-admin/src/test/java/com/fs/course/controller/FsCourseDomainNameControllerTest.java

@@ -4,6 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.json.JSONUtil;
 import com.fs.FSAdminApplication;
 import com.fs.course.config.RedPacketConfig;
+import com.fs.statis.service.IStatisticsCompanyService;
+import com.fs.statis.service.impl.StatisticsCompanyServiceImpl;
 import com.fs.system.service.ISysConfigService;
 import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
 import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
@@ -32,11 +34,18 @@ import static org.junit.jupiter.api.Assertions.*;
 @Slf4j
 class FsCourseDomainNameControllerTest {
 
+    @Autowired
+    private StatisticsCompanyServiceImpl statisticsCompanyService;
     @Autowired
     private WxPayService wxPayService;
 
     @Autowired
     private ISysConfigService configService;
+
+    @Test
+    public void test(){
+        statisticsCompanyService.rewardMoneyTaskEverydayCompanyUser();
+    }
     @Test
     public void nativePay() throws WxPayException {
 

+ 36 - 5
fs-company/src/main/java/com/fs/company/controller/IndexStatisticsController.java

@@ -8,6 +8,7 @@ import com.fs.core.web.service.TokenService;
 import com.fs.statis.StatisticsRedisConstant;
 import com.fs.statis.dto.*;
 import io.jsonwebtoken.lang.Assert;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.http.util.Asserts;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -20,6 +21,7 @@ import static com.fs.statis.StatisticsRedisConstant.*;
 /**
  * 首页-统计
  */
+@Slf4j
 @RestController
 @RequestMapping("/index/statistics")
 public class IndexStatisticsController {
@@ -161,20 +163,32 @@ public class IndexStatisticsController {
      */
     @PostMapping("/rewardMoneyTopTen")
     public R rewardMoneyTopTen(@RequestBody AnalysisPreviewQueryDTO param){
+        log.info("开始处理奖励金额top10请求");
+
         Integer type = param.getType();
         Integer dataType = param.getDataType();
         Integer userType = param.getUserType();
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         Long companyId = loginUser.getCompany().getCompanyId();
         Long companyUserId = loginUser.getUser().getUserId();
+        log.info("请求参数: type={}, dataType={}, userType={}, companyId={}, companyUserId={}",
+                type, dataType, userType, companyId, companyUserId);
 
         param.setCompanyId(companyId);
         List<RewardMoneyTopTenDTO> rewardMoneyTopTenDTOS;
+        String cacheKey;
+
         if(loginUser.getUser().isAdmin()) {
-            rewardMoneyTopTenDTOS = redisCache.getCacheObject( String.format("%s:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TOP_TEN, type,dataType,userType,param.getCompanyId()));
+            cacheKey = String.format("%s:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TOP_TEN, type,dataType,userType,param.getCompanyId());
+            log.info("管理员用户,使用缓存key: {}", cacheKey);
+
         } else {
-            rewardMoneyTopTenDTOS = redisCache.getCacheObject( String.format("%s:%d:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TOP_TEN, type,dataType,userType,param.getCompanyId(),companyUserId));
+            cacheKey = String.format("%s:%d:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TOP_TEN, type,dataType,userType,param.getCompanyId(),companyUserId);
+            log.info("普通用户,使用缓存key: {}", cacheKey);
+
         }
+        rewardMoneyTopTenDTOS = redisCache.getCacheObject(cacheKey);
+        log.info("从Redis缓存中获取到的数据大小: {}", rewardMoneyTopTenDTOS != null ? rewardMoneyTopTenDTOS.size() : 0);
 
         return R.ok().put("data", rewardMoneyTopTenDTOS);
     }
@@ -189,8 +203,13 @@ public class IndexStatisticsController {
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         Long companyId = loginUser.getCompany().getCompanyId();
         param.setCompanyId(companyId);
+        List<RewardMoneyTrendDTO> rewardMoneyTrendDTOS;
+        if(loginUser.getUser().isAdmin()) {
+            rewardMoneyTrendDTOS = redisCache.getCacheObject( String.format("%s:%d:%d:%d", CHARTS_REWARD_MONEY_TREND, type,userType,param.getCompanyId()));
+        } else {
+            rewardMoneyTrendDTOS = redisCache.getCacheObject( String.format("%s:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TREND, type,userType,param.getCompanyId(),loginUser.getUser().getUserId()));
+        }
 
-        List<RewardMoneyTrendDTO> rewardMoneyTrendDTOS = redisCache.getCacheObject( String.format("%s:%d:%d:%d", CHARTS_REWARD_MONEY_TREND, type,userType,param.getCompanyId()));
         return R.ok().put("data", rewardMoneyTrendDTOS);
     }
 
@@ -206,8 +225,13 @@ public class IndexStatisticsController {
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         Long companyId = loginUser.getCompany().getCompanyId();
         param.setCompanyId(companyId);
+        List<CourseStatsDTO> courseStatsDTOS;
+        if(loginUser.getUser().isAdmin()) {
+            courseStatsDTOS = redisCache.getCacheObject(String.format("%s:%d:%d:%d:%s:%d", CHARTS_WATCH_TOP_TEN, type,statisticalType,userType,sort,param.getCompanyId()));
+        } else {
+            courseStatsDTOS = redisCache.getCacheObject(String.format("%s:%d:%d:%d:%s:%d:%d", CHARTS_WATCH_TOP_TEN, type,statisticalType,userType,sort,param.getCompanyId(),loginUser.getUser().getUserId()));
+        }
 
-        List<CourseStatsDTO> courseStatsDTOS = redisCache.getCacheObject(String.format("%s:%d:%d:%d:%s:%d", CHARTS_WATCH_TOP_TEN, type,statisticalType,userType,sort,param.getCompanyId()));
         return R.ok().put("data", courseStatsDTOS);
     }
 
@@ -219,7 +243,14 @@ public class IndexStatisticsController {
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         Long companyId = loginUser.getCompany().getCompanyId();
 
-        DealerAggregatedDTO dealerAggregatedDTO = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AGGREGATED,companyId));
+        DealerAggregatedDTO dealerAggregatedDTO;
+
+        if(loginUser.getUser().isAdmin()) {
+            dealerAggregatedDTO = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AGGREGATED,companyId));
+        } else {
+            dealerAggregatedDTO = redisCache.getCacheObject(String.format("%s:%d:%d",StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AGGREGATED,companyId,loginUser.getUser().getUserId()));
+        }
+
 
         return R.ok().put("data",dealerAggregatedDTO);
     }

+ 2 - 2
fs-service-system/src/main/java/com/fs/statis/service/impl/StatisticsCompanyServiceImpl.java

@@ -438,7 +438,7 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
         param.setUserType(userType);
         List<WatchEndPlayTrendDTO> watchEndPlayTrendDTOS = this.watchEndPlayTrend(param);
 
-        redisCache.setCacheObject(String.format("%s:%d:%d",DATA_OVERVIEW_DEALER_CHARTS,type,userType),watchEndPlayTrendDTOS);
+        redisCache.setCacheObject(String.format("%s:%d:%d:%d",DATA_OVERVIEW_DEALER_CHARTS,type,userType,companyId),watchEndPlayTrendDTOS);
     }
 
     @Override
@@ -497,7 +497,7 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
         param.setCompanyUserId(companyUserId);
         List<WatchEndPlayTrendDTO> watchEndPlayTrendDTOS = this.watchEndPlayTrend(param);
 
-        redisCache.setCacheObject(String.format("%s:%d:%d:%d",DATA_OVERVIEW_DEALER_CHARTS,type,userType,companyUserId),watchEndPlayTrendDTOS);
+        redisCache.setCacheObject(String.format("%s:%d:%d:%d:%d",DATA_OVERVIEW_DEALER_CHARTS,type,userType,companyId,companyUserId),watchEndPlayTrendDTOS);
     }
 
     @Override

+ 12 - 0
fs-service-system/src/main/resources/mapper/statis/ConsumptionBalanceMapper.xml

@@ -213,6 +213,12 @@
             <if test="userType != null">
                 AND send_type = ${userType}
             </if>
+            <if test="companyId != null">
+                AND company_id = #{companyId}
+            </if>
+            <if test="companyUserId != null">
+                AND company_user_id = #{companyUserId}
+            </if>
         </where>
         GROUP BY
         start_date
@@ -322,6 +328,9 @@
             <if test="companyId != null">
                 and log.company_id = ${companyId}
             </if>
+            <if test="companyUserId != null">
+                and log.company_user_id = #{companyUserId}
+            </if>
         </where>
         GROUP BY
             <if test="dataType == 0">
@@ -361,6 +370,9 @@
             <if test="companyId != null">
                 and log.company_id = ${companyId}
             </if>
+            <if test="companyUserId != null">
+                and log.company_user_id = #{companyUserId}
+            </if>
         </where>
         group by start_date
     </select>