Prechádzať zdrojové kódy

feat: 销售端首页

xdd 1 mesiac pred
rodič
commit
f9b53066bb

+ 45 - 23
fs-company/src/main/java/com/fs/company/controller/IndexStatisticsController.java

@@ -2,6 +2,9 @@ package com.fs.company.controller;
 
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
+import com.fs.common.utils.ServletUtils;
+import com.fs.core.security.LoginUser;
+import com.fs.core.web.service.TokenService;
 import com.fs.statis.StatisticsRedisConstant;
 import com.fs.statis.dto.*;
 import io.jsonwebtoken.lang.Assert;
@@ -22,6 +25,9 @@ import static com.fs.statis.StatisticsRedisConstant.*;
 public class IndexStatisticsController {
     @Autowired
     private RedisCache redisCache;
+
+    @Autowired
+    private TokenService tokenService;
     /**
      * 分析概览
      */
@@ -38,8 +44,8 @@ public class IndexStatisticsController {
         if(userType == null) {
             userType = 0;
         }
-        Asserts.notNull(param.getCompanyId(),"公司id不能为空!");
-
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        param.setCompanyId(loginUser.getCompany().getCompanyId());
         analysisPreviewDTO = redisCache.getCacheObject(String.format("%s:%d:%d:%d",DATA_OVERVIEW_DEALER_ANALYSISPREVIEW,type,userType,param.getCompanyId()));
 
         return R.ok().put("data",analysisPreviewDTO);
@@ -50,8 +56,9 @@ public class IndexStatisticsController {
      * 消费余额
      */
     @GetMapping("/rechargeComsumption")
-    public R rechargeComsumption(@RequestParam("companyId") Long companyId){
-        Assert.notNull(companyId,"公司id不能为空!");
+    public R rechargeComsumption(){
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getCompany().getCompanyId();
 
         ConsumptionBalanceDataDTO consumptionBalanceDataDTO = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.DATA_OVERVIEW_DEALER_BALANCE,companyId));
         return R.ok().put("data", consumptionBalanceDataDTO);
@@ -62,9 +69,9 @@ public class IndexStatisticsController {
      * @return
      */
     @GetMapping("/trafficLog")
-    public R getTrafficLog(@RequestParam("companyId") Long companyId){
-        Assert.notNull(companyId,"公司id不能为空!");
-
+    public R getTrafficLog(){
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getCompany().getCompanyId();
         TrafficLogDTO trafficLogDTO = redisCache.getCacheObject(String.format("%s:%d",DATA_OVERVIEW_TRAFFIC_LOG,companyId));
         return R.ok().put("data",trafficLogDTO);
     }
@@ -83,7 +90,9 @@ public class IndexStatisticsController {
         if(userType == null){
             userType = 0;
         }
-        Assert.notNull(param.getCompanyId(),"公司id不能为空!");
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getCompany().getCompanyId();
+        param.setCompanyId(companyId);
 
         String key = String.format("%s:%d:%d:%d", DATA_OVERVIEW_DEALER_CHARTS, type,userType,param.getCompanyId());
         List<DeaMemberTopTenDTO> deaMemberTopTenDTOS = redisCache.getCacheObject(key);
@@ -105,7 +114,9 @@ public class IndexStatisticsController {
         if(userType == null){
             userType = 0;
         }
-        Assert.notNull(param.getCompanyId(),"公司id不能为空!");
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getCompany().getCompanyId();
+        param.setCompanyId(companyId);
 
         List<DeaMemberTopTenDTO> deaMemberTopTenDTOS = redisCache.getCacheObject(String.format("%s:%d:%d:%d:%d", CHARTS_MEMBER_TOP_TEN_WATCH, type, statisticalType,userType,param.getCompanyId()));
         if(deaMemberTopTenDTOS == null){
@@ -122,7 +133,9 @@ public class IndexStatisticsController {
         Integer type = param.getType();
         Integer dataType = param.getDataType();
         Integer userType = param.getUserType();
-        Assert.notNull(param.getCompanyId(),"公司id不能为空!");
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getCompany().getCompanyId();
+        param.setCompanyId(companyId);
 
         List<RewardMoneyTopTenDTO> rewardMoneyTopTenDTOS = redisCache.getCacheObject( String.format("%s:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TOP_TEN, type,dataType,userType,param.getCompanyId()));
         return R.ok().put("data", rewardMoneyTopTenDTOS);
@@ -135,7 +148,9 @@ public class IndexStatisticsController {
     public R rewardMoneyTrend(@RequestBody AnalysisPreviewQueryDTO param){
         Integer type = param.getType();
         Integer userType = param.getUserType();
-        Assert.notNull(param.getCompanyId(),"公司id不能为空!");
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getCompany().getCompanyId();
+        param.setCompanyId(companyId);
 
         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);
@@ -150,7 +165,9 @@ public class IndexStatisticsController {
         String sort = param.getSort();
         Integer statisticalType = param.getStatisticalType();
         Integer userType = param.getUserType();
-        Assert.notNull(param.getCompanyId(),"公司id不能为空!");
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getCompany().getCompanyId();
+        param.setCompanyId(companyId);
 
         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);
@@ -160,8 +177,9 @@ public class IndexStatisticsController {
      * 数据概览
      */
     @GetMapping("/dealerAggregated")
-    public R dealerAggregated(@RequestParam("companyId") Long companyId){
-        Assert.notNull(companyId,"公司id不能为空!");
+    public R dealerAggregated(){
+        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));
 
@@ -172,8 +190,9 @@ public class IndexStatisticsController {
      * 短信余额
      */
     @GetMapping("/smsBalance")
-    public R smsBalance(@RequestParam("companyId") Long companyId){
-        Assert.notNull(companyId, "公司id不能为空!");
+    public R smsBalance(){
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getCompany().getCompanyId();
 
         Long smsBalance = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.DATA_OVERVIEW_DEALER_SMS_BALANCE,companyId));
 
@@ -185,8 +204,9 @@ public class IndexStatisticsController {
      * 授权信息
      */
     @GetMapping("/authorizationInfo")
-    public R authorizationInfo(@RequestParam("companyId") Long companyId){
-        Assert.notNull(companyId, "公司id不能为空!");
+    public R authorizationInfo(){
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getCompany().getCompanyId();
 
         AuthorizationInfoDTO authorizationInfoDTO = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AUTHORIZATION_INFO,companyId));
 
@@ -199,8 +219,9 @@ public class IndexStatisticsController {
      * @return
      */
     @GetMapping("/thisMonthOrderCount")
-    public R thisMonthOrderCount(@RequestParam("companyId") Long companyId){
-        Assert.notNull(companyId, "公司id不能为空!");
+    public R thisMonthOrderCount(){
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getCompany().getCompanyId();
 
         R result = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.THIS_MONTH_ORDER_COUNT,companyId));
         return result;
@@ -210,10 +231,11 @@ public class IndexStatisticsController {
      * 当月收益统计
      * @return
      */
-
     @GetMapping("/thisMonthRecvCount")
-    public R thisMonthRecvCount(@RequestParam("companyId") Long companyId){
-        Assert.notNull(companyId, "公司id不能为空!");
+    public R thisMonthRecvCount(){
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyId = loginUser.getCompany().getCompanyId();
+
         R result = redisCache.getCacheObject(String.format("%s:%d",StatisticsRedisConstant.THIS_MONTH_RECV_COUNT,companyId));
         return result;
     }

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

@@ -368,7 +368,7 @@
                                 <where>
                                     STATUS=1
                                     <if test="companyId != null">
-                                        company_id = #{companyId}
+                                        AND company_id = #{companyId}
                                     </if>
                                 </where>
                                 ) AS normal_num,
@@ -376,7 +376,7 @@
                                 <where>
                                     STATUS=0
                                     <if test="companyId != null">
-                                        company_id = #{companyId}
+                                        AND company_id = #{companyId}
                                     </if>
                                 </where>
                 ) AS black_num,