Explorar o código

Merge remote-tracking branch 'origin/会员关联项目' into 会员关联项目

yfh hai 1 semana
pai
achega
7140550b0a
Modificáronse 43 ficheiros con 1077 adicións e 160 borrados
  1. 34 0
      fs-admin/src/main/java/com/fs/api/controller/CommonApiController.java
  2. 1 0
      fs-admin/src/main/java/com/fs/core/config/SecurityConfig.java
  3. 6 6
      fs-admin/src/main/java/com/fs/store/controller/FsIndexController.java
  4. 13 0
      fs-common/src/main/java/com/fs/common/config/FSSysConfig.java
  5. 1 1
      fs-company-app/src/main/java/com/fs/app/controller/FsUserController.java
  6. 4 4
      fs-company/src/main/java/com/fs/common/controller/IndexController.java
  7. 47 9
      fs-company/src/main/java/com/fs/company/controller/IndexStatisticsController.java
  8. 3 3
      fs-company/src/main/resources/application.yml
  9. 2 0
      fs-service-system/src/main/java/com/fs/company/mapper/CompanyUserMapper.java
  10. 2 0
      fs-service-system/src/main/java/com/fs/company/service/ICompanyUserService.java
  11. 5 0
      fs-service-system/src/main/java/com/fs/company/service/impl/CompanyUserServiceImpl.java
  12. 19 0
      fs-service-system/src/main/java/com/fs/core/utils/OrderCodeUtils.java
  13. 3 3
      fs-service-system/src/main/java/com/fs/course/mapper/FsCourseTrafficLogMapper.java
  14. 1 1
      fs-service-system/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java
  15. 1 1
      fs-service-system/src/main/java/com/fs/course/service/impl/FsUserWatchCourseStatisticsServiceImpl.java
  16. 4 1
      fs-service-system/src/main/java/com/fs/qw/service/impl/CustomerTransferApprovalServiceImpl.java
  17. 4 1
      fs-service-system/src/main/java/com/fs/statis/dto/AnalysisPreviewQueryDTO.java
  18. 1 1
      fs-service-system/src/main/java/com/fs/statis/mapper/ConsumptionBalanceMapper.java
  19. 17 0
      fs-service-system/src/main/java/com/fs/statis/service/IStatisticsCompanyService.java
  20. 723 10
      fs-service-system/src/main/java/com/fs/statis/service/impl/StatisticsCompanyServiceImpl.java
  21. 5 5
      fs-service-system/src/main/java/com/fs/statis/service/impl/StatisticsServiceImpl.java
  22. 2 11
      fs-service-system/src/main/java/com/fs/store/mapper/FsStoreOrderMapper.java
  23. 2 11
      fs-service-system/src/main/java/com/fs/store/mapper/FsStorePaymentMapper.java
  24. 1 10
      fs-service-system/src/main/java/com/fs/store/mapper/FsStoreProductMapper.java
  25. 2 13
      fs-service-system/src/main/java/com/fs/store/mapper/FsUserMapper.java
  26. 1 1
      fs-service-system/src/main/java/com/fs/store/service/IFsStoreOrderService.java
  27. 1 1
      fs-service-system/src/main/java/com/fs/store/service/IFsStorePaymentService.java
  28. 1 1
      fs-service-system/src/main/java/com/fs/store/service/IFsUserService.java
  29. 2 2
      fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java
  30. 14 4
      fs-service-system/src/main/java/com/fs/store/service/impl/FsStorePaymentServiceImpl.java
  31. 1 1
      fs-service-system/src/main/java/com/fs/store/service/impl/FsUserCourseCountServiceImpl.java
  32. 16 31
      fs-service-system/src/main/java/com/fs/store/service/impl/FsUserServiceImpl.java
  33. 1 0
      fs-service-system/src/main/resources/application-config-zkzh.yml
  34. 9 0
      fs-service-system/src/main/resources/mapper/course/FsCourseTrafficLogMapper.xml
  35. 1 1
      fs-service-system/src/main/resources/mapper/course/FsUserCourseVideoMapper.xml
  36. 44 3
      fs-service-system/src/main/resources/mapper/statis/ConsumptionBalanceMapper.xml
  37. 13 0
      fs-service-system/src/main/resources/mapper/store/FsStoreOrderMapper.xml
  38. 13 0
      fs-service-system/src/main/resources/mapper/store/FsStorePaymentMapper.xml
  39. 14 0
      fs-service-system/src/main/resources/mapper/store/FsStoreProductMapper.xml
  40. 4 4
      fs-service-system/src/main/resources/mapper/store/FsUserCourseCountMapper.xml
  41. 23 6
      fs-service-system/src/main/resources/mapper/store/FsUserMapper.xml
  42. 2 0
      fs-user-app/src/main/java/com/fs/app/controller/CourseWxH5Controller.java
  43. 14 14
      fs-user-app/src/main/java/com/fs/app/controller/WxCompanyUserController.java

+ 34 - 0
fs-admin/src/main/java/com/fs/api/controller/CommonApiController.java

@@ -0,0 +1,34 @@
+package com.fs.api.controller;
+
+
+import com.fs.common.core.domain.R;
+import com.fs.core.utils.OrderCodeUtils;
+import io.swagger.annotations.Api;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+@Api("公共接口")
+@RestController
+@RequestMapping(value="/app/common")
+public class CommonApiController {
+
+
+    @GetMapping("/genOrderCode")
+    public R genOrderCode() {
+
+        String orderCode= OrderCodeUtils.genOrderSn();
+        if(StringUtils.isNotEmpty(orderCode)){
+            return R.ok().put("orderCode",orderCode);
+        }
+        else{
+            return R.error("订单号生成失败");
+        }
+
+    }
+
+
+
+}

+ 1 - 0
fs-admin/src/main/java/com/fs/core/config/SecurityConfig.java

@@ -126,6 +126,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .antMatchers("/*/api-docs").anonymous()
                 .antMatchers("/druid/**").anonymous()
                 .antMatchers("/expense/**").anonymous()
+                .antMatchers("/app/common/genOrderCode").anonymous()
                 // 除上面外的所有请求全部需要鉴权认证
                 .anyRequest().authenticated()
                 .and()

+ 6 - 6
fs-admin/src/main/java/com/fs/store/controller/FsIndexController.java

@@ -38,16 +38,16 @@ public class FsIndexController
     public R getIndexData()
     {
         Map<String,Object> data=new HashMap<>();
-        Long userCount=userService.selectFsUserCount(0,null);
-        Long dayUserCount=userService.selectFsUserCount(1,null);
+        Long userCount=userService.selectFsUserCount(0,null,null);
+        Long dayUserCount=userService.selectFsUserCount(1,null,null);
         data.put("userCount",userCount);
         data.put("dayUserCount",dayUserCount);
-        Long storeOrderCount=storeOrderService.selectFsStoreOrderTotalCount(0,null);
-        Long dayStoreOrderCount=storeOrderService.selectFsStoreOrderTotalCount(1,null);
+        Long storeOrderCount=storeOrderService.selectFsStoreOrderTotalCount(0,null,null);
+        Long dayStoreOrderCount=storeOrderService.selectFsStoreOrderTotalCount(1,null,null);
         data.put("storeOrderCount",storeOrderCount);
         data.put("dayStoreOrderCount",dayStoreOrderCount);
-        Long paymentCount=paymentService.selectFsStorePaymentCount(0,null);
-        Long dayPaymentCount=paymentService.selectFsStorePaymentCount(1,null);
+        Long paymentCount=paymentService.selectFsStorePaymentCount(0,null,null);
+        Long dayPaymentCount=paymentService.selectFsStorePaymentCount(1,null,null);
         data.put("paymentCount",paymentCount);
         data.put("dayPaymentCount",dayPaymentCount);
         Long productCount=productService.selectFsStoreProductCount(0);

+ 13 - 0
fs-common/src/main/java/com/fs/common/config/FSSysConfig.java

@@ -49,6 +49,10 @@ public class FSSysConfig
 //    private String cwarehouseCode;
 //    private String cwarehouseName;
 
+
+
+    String commonApi;
+
     public String getKdnId() {
         return kdnId;
     }
@@ -288,4 +292,13 @@ public class FSSysConfig
 //    public void setCwarehouseName(String cwarehouseName) {
 //        this.cwarehouseName = cwarehouseName;
 //    }
+
+    public String getCommonApi() {
+        return commonApi;
+    }
+
+    public void setCommonApi(String commonApi) {
+        this.commonApi = commonApi;
+    }
+
 }

+ 1 - 1
fs-company-app/src/main/java/com/fs/app/controller/FsUserController.java

@@ -332,7 +332,7 @@ public class FsUserController extends AppBaseController {
         return fsUserService.becomeMember(param);
     }
 
-    @Login
+    //    @Login
     @PostMapping("/userImage")
     @ApiOperation("生成分享会员海报")
     public R createCourseImage(@RequestBody FsUserCourseBeMemberImageParam param) {

+ 4 - 4
fs-company/src/main/java/com/fs/common/controller/IndexController.java

@@ -50,12 +50,12 @@ public class IndexController
         Long dayCustomerCount=crmCustomerService.selectCrmCustomerCount(1,loginUser.getCompany().getCompanyId());
         data.put("customerCount",customerCount);
         data.put("dayCustomerCount",dayCustomerCount);
-        Long storeOrderCount=storeOrderService.selectFsStoreOrderTotalCount(0,loginUser.getCompany().getCompanyId());
-        Long dayStoreOrderCount=storeOrderService.selectFsStoreOrderTotalCount(1,loginUser.getCompany().getCompanyId());
+        Long storeOrderCount=storeOrderService.selectFsStoreOrderTotalCount(0,loginUser.getCompany().getCompanyId(),null);
+        Long dayStoreOrderCount=storeOrderService.selectFsStoreOrderTotalCount(1,loginUser.getCompany().getCompanyId(),null);
         data.put("storeOrderCount",storeOrderCount);
         data.put("dayStoreOrderCount",dayStoreOrderCount);
-        Long paymentCount=paymentService.selectFsStorePaymentCount(0,loginUser.getCompany().getCompanyId());
-        Long dayPaymentCount=paymentService.selectFsStorePaymentCount(1,loginUser.getCompany().getCompanyId());
+        Long paymentCount=paymentService.selectFsStorePaymentCount(0,loginUser.getCompany().getCompanyId(),null);
+        Long dayPaymentCount=paymentService.selectFsStorePaymentCount(1,loginUser.getCompany().getCompanyId(),null);
         data.put("paymentCount",paymentCount);
         data.put("dayPaymentCount",dayPaymentCount);
 

+ 47 - 9
fs-company/src/main/java/com/fs/company/controller/IndexStatisticsController.java

@@ -45,8 +45,14 @@ public class IndexStatisticsController {
             userType = 0;
         }
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyUserId = loginUser.getUser().getUserId();
+
         param.setCompanyId(loginUser.getCompany().getCompanyId());
-        analysisPreviewDTO = redisCache.getCacheObject(String.format("%s:%d:%d:%d",DATA_OVERVIEW_DEALER_ANALYSISPREVIEW,type,userType,param.getCompanyId()));
+        if(loginUser.getUser().isAdmin()) {
+            analysisPreviewDTO = redisCache.getCacheObject(String.format("%s:%d:%d:%d",DATA_OVERVIEW_DEALER_ANALYSISPREVIEW,type,userType,param.getCompanyId()));
+        } else {
+            analysisPreviewDTO = redisCache.getCacheObject(String.format("%s:%d:%d:%d:%d",DATA_OVERVIEW_DEALER_ANALYSISPREVIEW,type,userType,param.getCompanyId(),companyUserId));
+        }
 
         return R.ok().put("data",analysisPreviewDTO);
     }
@@ -71,8 +77,14 @@ public class IndexStatisticsController {
     @GetMapping("/trafficLog")
     public R getTrafficLog(){
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyUserId = loginUser.getUser().getUserId();
         Long companyId = loginUser.getCompany().getCompanyId();
-        TrafficLogDTO trafficLogDTO = redisCache.getCacheObject(String.format("%s:%d",DATA_OVERVIEW_TRAFFIC_LOG,companyId));
+        TrafficLogDTO trafficLogDTO;
+        if(loginUser.getUser().isAdmin()) {
+            trafficLogDTO = redisCache.getCacheObject(String.format("%s:%d",DATA_OVERVIEW_TRAFFIC_LOG,companyId));
+        } else {
+            trafficLogDTO = redisCache.getCacheObject(String.format("%s:%d:%d",DATA_OVERVIEW_TRAFFIC_LOG,companyId,companyUserId));
+        }
         return R.ok().put("data",trafficLogDTO);
     }
 
@@ -91,11 +103,20 @@ public class IndexStatisticsController {
             userType = 0;
         }
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        Long companyUserId = loginUser.getUser().getUserId();
         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);
+        List<DeaMemberTopTenDTO> deaMemberTopTenDTOS;
+        if(loginUser.getUser().isAdmin()) {
+            String key = String.format("%s:%d:%d:%d", DATA_OVERVIEW_DEALER_CHARTS, type,userType,companyId);
+            deaMemberTopTenDTOS = redisCache.getCacheObject(key);
+        } else {
+            String key = String.format("%s:%d:%d:%d:%d", DATA_OVERVIEW_DEALER_CHARTS, type,userType,companyId,companyUserId);
+            deaMemberTopTenDTOS = redisCache.getCacheObject(key);
+        }
+
         return R.ok().put("data", deaMemberTopTenDTOS);
     }
 
@@ -117,11 +138,21 @@ public class IndexStatisticsController {
         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){
-            deaMemberTopTenDTOS = new ArrayList<>();
+        Long companyUserId = loginUser.getUser().getUserId();
+
+        List<DeaMemberTopTenDTO> deaMemberTopTenDTOS;
+        if(loginUser.getUser().isAdmin()) {
+            deaMemberTopTenDTOS = redisCache.getCacheObject(String.format("%s:%d:%d:%d:%d", CHARTS_MEMBER_TOP_TEN_WATCH, type, statisticalType,userType,param.getCompanyId()));
+            if(deaMemberTopTenDTOS == null){
+                deaMemberTopTenDTOS = new ArrayList<>();
+            }
+        } else {
+            deaMemberTopTenDTOS = redisCache.getCacheObject(String.format("%s:%d:%d:%d:%d:%d", CHARTS_MEMBER_TOP_TEN_WATCH, type, statisticalType,userType,param.getCompanyId(),companyUserId));
+            if(deaMemberTopTenDTOS == null){
+                deaMemberTopTenDTOS = new ArrayList<>();
+            }
         }
+
         return R.ok().put("data", deaMemberTopTenDTOS);
     }
 
@@ -135,9 +166,16 @@ public class IndexStatisticsController {
         Integer userType = param.getUserType();
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         Long companyId = loginUser.getCompany().getCompanyId();
+        Long companyUserId = loginUser.getUser().getUserId();
+
         param.setCompanyId(companyId);
+        List<RewardMoneyTopTenDTO> rewardMoneyTopTenDTOS;
+        if(loginUser.getUser().isAdmin()) {
+            rewardMoneyTopTenDTOS = redisCache.getCacheObject( String.format("%s:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TOP_TEN, type,dataType,userType,param.getCompanyId()));
+        } else {
+            rewardMoneyTopTenDTOS = redisCache.getCacheObject( String.format("%s:%d:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TOP_TEN, type,dataType,userType,param.getCompanyId(),companyUserId));
+        }
 
-        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);
     }
 

+ 3 - 3
fs-company/src/main/resources/application.yml

@@ -4,7 +4,7 @@ server:
 
 spring:
   profiles:
-    active: dev
+#    active: dev
 #    include: common,config-dev
-#    active: druid-fby
-#    include: common,config-fby
+    active: druid-fby
+    include: common,config-fby

+ 2 - 0
fs-service-system/src/main/java/com/fs/company/mapper/CompanyUserMapper.java

@@ -298,4 +298,6 @@ public interface CompanyUserMapper
 
     int updateAllowedAllRegister(@Param("status") boolean status, @Param("userIds")List<Long> userIds);
 
+    @Select("select user_id,company_id from company_user")
+    List<CompanyUser> selectAllCompanyUser();
 }

+ 2 - 0
fs-service-system/src/main/java/com/fs/company/service/ICompanyUserService.java

@@ -215,4 +215,6 @@ public interface ICompanyUserService {
      */
     Boolean isAllowedAllRegister(boolean status,  List<Long> userIds);
 
+    List<CompanyUser> getAllCompanyUser();
+
 }

+ 5 - 0
fs-service-system/src/main/java/com/fs/company/service/impl/CompanyUserServiceImpl.java

@@ -545,6 +545,11 @@ public class CompanyUserServiceImpl implements ICompanyUserService
         return true;
     }
 
+    @Override
+    public List<CompanyUser> getAllCompanyUser() {
+        return companyUserMapper.selectAllCompanyUserList();
+    }
+
     /**
      * 批量审核用户
      * @param userIds 用户ID集合

+ 19 - 0
fs-service-system/src/main/java/com/fs/core/utils/OrderCodeUtils.java

@@ -4,14 +4,20 @@ import cn.hutool.core.util.IdUtil;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.json.JSONUtil;
 import com.fs.common.config.FSConfig;
+import com.fs.common.config.FSSysConfig;
 import com.fs.common.utils.spring.SpringUtils;
 import com.fs.core.vo.OrderCodeVO;
+import lombok.extern.slf4j.Slf4j;
 import org.redisson.api.RLock;
 import org.redisson.api.RedissonClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
 import java.util.concurrent.TimeUnit;
 
+@Slf4j
 public class OrderCodeUtils {
+    static FSSysConfig fsSysConfig = SpringUtils.getBean(FSSysConfig.class);
 
     public static String genOrderSn(){
 
@@ -38,6 +44,19 @@ public class OrderCodeUtils {
 
     }
 
+    public static String getOrderSn(){
+        String url= fsSysConfig.getCommonApi()+ "/app/common/genOrderCode";
+        String json = HttpRequest.get(url)
+                .execute().body();
+        OrderCodeVO vo= JSONUtil.toBean(json, OrderCodeVO.class);
+        if(vo.getCode()==200){
+            return vo.getOrderCode();
+        }
+        else return null;
+        //return genOrderSn();
+
+    }
+
 
 //    public static String genOrderSn() {
 //

+ 3 - 3
fs-service-system/src/main/java/com/fs/course/mapper/FsCourseTrafficLogMapper.java

@@ -80,20 +80,20 @@ public interface FsCourseTrafficLogMapper
      * @return Long
      */
     Long getTodayTrafficLog();
-    Long getTodayTrafficLogCompanyId(@Param("companyId") Long companyId);
+    Long getTodayTrafficLogCompanyId(@Param("companyId") Long companyId,@Param("companyUserId") Long companyUserId);
 
     /**
      * 获取当月统计流量
      * @return Long
      */
     Long getMonthTrafficLog();
-    Long getMonthTrafficLogCompanyId(@Param("companyId") Long companyId);
+    Long getMonthTrafficLogCompanyId(@Param("companyId") Long companyId,@Param("companyUserId") Long companyUserId);
 
     /**
      * 昨天
      * @return Long
      */
     Long getYesterdayTrafficLog();
-    Long getYesterdayTrafficLogCompanyId(@Param("companyId") Long companyId);
+    Long getYesterdayTrafficLogCompanyId(@Param("companyId") Long companyId,@Param("companyUserId") Long companyUserId);
 
 }

+ 1 - 1
fs-service-system/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -1007,7 +1007,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
     @Override
     @Transactional
     public ResponseResult<Boolean> isAddCompanyUser(FsUserCourseAddCompanyUserParam param) {
-        logger.info("=======================进入个微-判断是否添加客服===========================,入参:{}",param);
+        logger.info("\n 【进入个微-判断是否添加客服】,入参:{}",param);
         //查询用户
         FsUser fsUser = fsUserMapper.selectFsUserById(param.getUserId());
         if (fsUser == null){

+ 1 - 1
fs-service-system/src/main/java/com/fs/course/service/impl/FsUserWatchCourseStatisticsServiceImpl.java

@@ -209,7 +209,7 @@ public class FsUserWatchCourseStatisticsServiceImpl extends ServiceImpl<FsUserWa
             BigDecimal watchNum = new BigDecimal(vo.getWatchNum());
             BigDecimal userNum = new BigDecimal(vo.getUserNum());
             if(!userNum.equals(BigDecimal.ZERO)){
-                BigDecimal onlineRate = watchNum.divide(userNum, 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
+                BigDecimal onlineRate = watchNum.divide(userNum, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
                 vo.setOnlineRate(onlineRate);
             } else{
                 vo.setOnlineRate(BigDecimal.ZERO);

+ 4 - 1
fs-service-system/src/main/java/com/fs/qw/service/impl/CustomerTransferApprovalServiceImpl.java

@@ -150,13 +150,16 @@ public class CustomerTransferApprovalServiceImpl implements ICustomerTransferApp
                     CompanyUser companyUser = companyUserCacheService.selectCompanyUserById(userCompanyUser.getCompanyUserId());
                     String companyUserName = String.format("%s_%d", companyUser.getUserName(), companyUser.getUserId());
 
+                    CompanyUser afterCompanyUser = companyUserCacheService.selectCompanyUserById(item.getTargetUserId());
+                    String afterCompanyUserName = String.format("%s_%d", afterCompanyUser.getUserName(), companyUser.getUserId());
+
                     customerList.add(TransferCustomDTO.builder()
                             .userName(String.format("%s_%d", fsUser.getNickname(), fsUser.getUserId()))
                             .userId(fsUser.getUserId())
                             .projectId(customerId.getProjectId())
                             .beforeCompanyUserName(companyUserName)
                             .beforeCompanyUserId(companyUser.getUserId())
-                            .afterCompanyUserName(item.getTargetUserName())
+                            .afterCompanyUserName(afterCompanyUserName)
                             .afterCompanyUserId(item.getTargetUserId())
                             .build());
                 }

+ 4 - 1
fs-service-system/src/main/java/com/fs/statis/dto/AnalysisPreviewQueryDTO.java

@@ -6,7 +6,6 @@ import lombok.Setter;
 import java.io.Serializable;
 
 @Data
-@Setter
 public class AnalysisPreviewQueryDTO implements Serializable {
 
     /**
@@ -47,4 +46,8 @@ public class AnalysisPreviewQueryDTO implements Serializable {
      */
     private Long companyId;
 
+    /**
+     * 销售id
+     */
+    private Long companyUserId;
 }

+ 1 - 1
fs-service-system/src/main/java/com/fs/statis/mapper/ConsumptionBalanceMapper.java

@@ -18,7 +18,7 @@ public interface ConsumptionBalanceMapper {
     ConsumptionBalanceDataDTO rechargeConsumption();
 
     DealerAggregatedDTO dealerAggregated();
-    DealerAggregatedDTO dealerAggregatedCompanyId(@Param("companyId") Long companyId);
+    DealerAggregatedDTO dealerAggregatedCompanyId(@Param("companyId") Long companyId,@Param("companyUserId") Long companyUserId);
 
     /**
      * 观看人数

+ 17 - 0
fs-service-system/src/main/java/com/fs/statis/service/IStatisticsCompanyService.java

@@ -13,38 +13,54 @@ public interface IStatisticsCompanyService {
      * 数据概览定时任务
      */
     void dataOverviewTask();
+    void dataOverviewTaskCompanyUser();
 
     /**
      * 分析概览定时任务
      */
     void analysisPreviewTask(Integer type,Integer userType,Long companyId);
+    /**
+     * 分析概览定时任务-销售
+     */
+    void analysisPreviewTask(Integer type,Integer userType,Long companyId,Long companyUserId);
 
 
     /**
      * 会员观看、完播人数趋势图
      */
     void watchEndPlayTrendTask(Integer type,Integer userType,Long companyId);
+    /**
+     * 会员观看、完播人数趋势图-销售
+     */
+    void watchEndPlayTrendTask(Integer type,Integer userType,Long companyId,Long companyUserId);
 
 
     /**
      * 经销商会员观看TOP10
      */
     void companyWatchCourseTopTenTask(Integer type,Integer statisticalType,Integer userType,Long companyId);
+    void companyWatchCourseTopTenTask(Integer type,Integer statisticalType,Integer userType,Long companyId,Long companyUserId);
 
     /**
      * 课程观看TOP10
      */
     void watchCourseTopTenTask(Integer type,Integer statisticalType,Integer userType,String sort,Long companyId);
+    void watchCourseTopTenTask(Integer type,Integer statisticalType,Integer userType,String sort,Long companyId,Long companyUserId);
 
     /**
      * 答题红包金额TOP10
      */
     void rewardMoneyTopTenTask(Integer type,Integer dataType,Integer userType,Long companyId);
+    void rewardMoneyTopTenTask(Integer type,Integer dataType,Integer userType,Long companyId,Long companyUserId);
+
+
     void rewardMoneyTradeTask(Integer type,Integer userType,Long companyId);
+    void rewardMoneyTradeTask(Integer type,Integer userType,Long companyId,Long companyUserId);
 
 
 
     DealerAggregatedDTO dealerAggregated(Long companyId);
+    DealerAggregatedDTO dealerAggregated(Long companyId,Long companyUserId);
 
     /**
      * 消费余额
@@ -95,6 +111,7 @@ public interface IStatisticsCompanyService {
      * @return TrafficLogDTO
      */
     TrafficLogDTO getTrafficLog(Long companyId);
+    TrafficLogDTO getTrafficLog(Long companyId,Long companyUserId);
 
     /**
      * 本月订单数

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

@@ -5,7 +5,12 @@ import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.utils.TimeUtils;
 import com.fs.company.cache.ICompanyCacheService;
+import com.fs.company.domain.Company;
+import com.fs.company.domain.CompanyUser;
+import com.fs.company.mapper.CompanyUserMapper;
 import com.fs.company.service.ICompanyService;
+import com.fs.company.service.ICompanyUserService;
+import com.fs.company.service.impl.CompanyUserServiceImpl;
 import com.fs.course.mapper.FsCourseTrafficLogMapper;
 import com.fs.his.vo.OptionsVO;
 import com.fs.statis.StatisticsRedisConstant;
@@ -75,6 +80,10 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
 
     @Autowired
     private ICompanyService companyService;
+
+    @Autowired
+    private CompanyUserMapper companyUserMapper;
+
     @Override
     public void dataOverviewTask() {
         List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
@@ -87,6 +96,14 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
         }
     }
 
+    @Override
+    public void dataOverviewTaskCompanyUser() {
+        List<CompanyUser> companyUsers = companyUserMapper.selectAllCompanyUser();
+        for (CompanyUser companyUser : companyUsers) {
+            dataOverviewTaskCompany(companyUser.getCompanyId(),companyUser.getUserId());
+        }
+    }
+
     private void dataOverviewTaskCompany(Long companyId){
         DealerAggregatedDTO dealerAggregatedDTO = this.dealerAggregated(companyId);
         ConsumptionBalanceDataDTO consumptionBalanceDataDTO = this.rechargeConsumption(companyId);
@@ -100,6 +117,21 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
         redisCache.setCacheObject(String.format(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_SMS_BALANCE+":%d",companyId), smsBalance);
         redisCache.setCacheObject(String.format(StatisticsRedisConstant.DATA_OVERVIEW_TRAFFIC_LOG+":%d",companyId),trafficLog);
     }
+
+    private void dataOverviewTaskCompany(Long companyId,Long companyUserId){
+        DealerAggregatedDTO dealerAggregatedDTO = this.dealerAggregated(companyId,companyUserId);
+        ConsumptionBalanceDataDTO consumptionBalanceDataDTO = this.rechargeConsumption(companyId);
+        AuthorizationInfoDTO authorizationInfoDTO = authorizationInfo();
+        Long smsBalance = this.smsBalance(companyId);
+        TrafficLogDTO trafficLog = this.getTrafficLog(companyId,companyUserId);
+
+        redisCache.setCacheObject(String.format(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AGGREGATED+":%d:%d",companyId,companyUserId), dealerAggregatedDTO);
+        redisCache.setCacheObject(String.format(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_BALANCE+":%d:%d",companyId,companyUserId), consumptionBalanceDataDTO);
+        redisCache.setCacheObject(String.format(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_AUTHORIZATION_INFO+":%d:%d",companyId,companyUserId), authorizationInfoDTO);
+        redisCache.setCacheObject(String.format(StatisticsRedisConstant.DATA_OVERVIEW_DEALER_SMS_BALANCE+":%d:%d",companyId,companyUserId), smsBalance);
+        redisCache.setCacheObject(String.format(StatisticsRedisConstant.DATA_OVERVIEW_TRAFFIC_LOG+":%d:%d",companyId,companyUserId),trafficLog);
+    }
+
     public void analysisPreviewTask0(){
         List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
         for (OptionsVO optionsVO : optionsVOS) {
@@ -134,6 +166,41 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
             analysisPreviewTask(4,2,companyId);
         }
     }
+    public void analysisPreviewTask0CompanyUser(){
+        List<CompanyUser> companyUsers = companyUserMapper.selectAllCompanyUser();
+        for (CompanyUser companyUser : companyUsers) {
+            Long companyId = companyUser.getCompanyId();
+            if (companyId == null) {
+                continue;
+            }
+            analysisPreviewTask(0,1,companyId,companyUser.getUserId());
+            analysisPreviewTask(0,2,companyId,companyUser.getUserId());
+        }
+    }
+
+    public void analysisPreviewTask1CompanyUser(){
+        List<CompanyUser> companyUsers = companyUserMapper.selectAllCompanyUser();
+        for (CompanyUser companyUser : companyUsers) {
+            Long companyId = companyUser.getCompanyId();
+            if (companyId == null) {
+                continue;
+            }
+            analysisPreviewTask(0,1,companyId,companyUser.getUserId());
+            analysisPreviewTask(1,1,companyId,companyUser.getUserId());
+            analysisPreviewTask(2,1,companyId,companyUser.getUserId());
+            analysisPreviewTask(3,1,companyId,companyUser.getUserId());
+            analysisPreviewTask(4,1,companyId,companyUser.getUserId());
+
+            analysisPreviewTask(0,2,companyId,companyUser.getUserId());
+            analysisPreviewTask(1,2,companyId,companyUser.getUserId());
+            analysisPreviewTask(2,2,companyId,companyUser.getUserId());
+            analysisPreviewTask(3,2,companyId,companyUser.getUserId());
+            analysisPreviewTask(4,2,companyId,companyUser.getUserId());
+        }
+    }
+
+
+
     @Override
     public void analysisPreviewTask(Integer type, Integer userType,Long companyId) {
         // 根据type计算出时间范围
@@ -192,6 +259,64 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
         redisCache.setCacheObject(String.format("%s:%d:%d:%d",DATA_OVERVIEW_DEALER_ANALYSISPREVIEW,type,userType,companyId), analysisPreviewDTO);
     }
 
+    @Override
+    public void analysisPreviewTask(Integer type, Integer userType, Long companyId, Long companyUserId) {
+        // 根据type计算出时间范围
+        String startDate = "";
+        String endDate = "";
+
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
+
+        if(0 == type){
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
+        } else if(1 == type){
+            LocalDateTime yesterday = now.minusDays(1);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
+        } else if(2 == type) {
+            LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(3 == type) {
+            LocalDateTime startOfMonth = now.withDayOfMonth(1);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(4 == type) {
+            LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
+            LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
+        }
+
+        AnalysisPreviewQueryDTO param = new AnalysisPreviewQueryDTO();
+        param.setStartTime(startDate);
+        param.setEndTime(endDate);
+        param.setType(type);
+        param.setUserType(userType);
+        param.setCompanyId(companyId);
+
+        AnalysisPreviewDTO analysisPreviewDTO = this.analysisPreview(param);
+
+        redisCache.setCacheObject(String.format("%s:%d:%d:%d:%d",DATA_OVERVIEW_DEALER_ANALYSISPREVIEW,type,userType,companyId,companyUserId), analysisPreviewDTO);
+    }
+
 
     public void watchEndPlayTrendTask0(){
         List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
@@ -204,6 +329,18 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
             this.watchEndPlayTrendTask(0,2,companyId);
         }
 
+    }
+    public void watchEndPlayTrendTask0CompanyUser(){
+        List<CompanyUser> companyUsers = companyUserMapper.selectAllCompanyUser();
+        for (CompanyUser companyUser : companyUsers) {
+            Long companyId = companyUser.getCompanyId();
+            if(companyId == null){
+                continue;
+            }
+            this.watchEndPlayTrendTask(0,1,companyId,companyUser.getUserId());
+            this.watchEndPlayTrendTask(0,2,companyId,companyUser.getUserId());
+        }
+
     }
 
     public void watchEndPlayTrendTask1(){
@@ -224,6 +361,27 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
             this.watchEndPlayTrendTask(4,2,companyId);
         }
 
+    }
+
+    public void watchEndPlayTrendTask1CompanyUser(){
+        List<CompanyUser> companyUsers = companyUserMapper.selectAllCompanyUser();
+
+        for (CompanyUser companyUser : companyUsers) {
+            Long companyId = companyUser.getCompanyId();
+            if(companyId == null){
+                continue;
+            }
+            this.watchEndPlayTrendTask(1,1,companyId,companyUser.getUserId());
+            this.watchEndPlayTrendTask(2,1,companyId,companyUser.getUserId());
+            this.watchEndPlayTrendTask(3,1,companyId,companyUser.getUserId());
+            this.watchEndPlayTrendTask(4,1,companyId,companyUser.getUserId());
+
+            this.watchEndPlayTrendTask(1,2,companyId,companyUser.getUserId());
+            this.watchEndPlayTrendTask(2,2,companyId,companyUser.getUserId());
+            this.watchEndPlayTrendTask(3,2,companyId,companyUser.getUserId());
+            this.watchEndPlayTrendTask(4,2,companyId,companyUser.getUserId());
+        }
+
     }
     @Override
     public void watchEndPlayTrendTask(Integer type, Integer userType,Long companyId) {
@@ -283,6 +441,65 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
         redisCache.setCacheObject(String.format("%s:%d:%d",DATA_OVERVIEW_DEALER_CHARTS,type,userType),watchEndPlayTrendDTOS);
     }
 
+    @Override
+    public void watchEndPlayTrendTask(Integer type, Integer userType, Long companyId, Long companyUserId) {
+        // 根据type计算出时间范围
+        String startDate = "";
+        String endDate = "";
+
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
+
+        if(0 == type){
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
+        } else if(1 == type){
+            LocalDateTime yesterday = now.minusDays(1);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
+        } else if(2 == type) {
+            LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(3 == type) {
+            LocalDateTime startOfMonth = now.withDayOfMonth(1);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(4 == type) {
+            LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
+            LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
+        }
+
+        AnalysisPreviewQueryDTO param = new AnalysisPreviewQueryDTO();
+        param.setStartTime(startDate);
+        param.setEndTime(endDate);
+        param.setType(type);
+        param.setCompanyId(companyId);
+
+        param.setUserType(userType);
+        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);
+    }
+
     @Override
     public void companyWatchCourseTopTenTask(Integer type, Integer statisticalType, Integer userType,Long companyId) {
 
@@ -342,6 +559,65 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
         redisCache.setCacheObject(String.format("%s:%d:%d:%d:%d", CHARTS_MEMBER_TOP_TEN_WATCH, type,statisticalType,userType,companyId), deaMemberTopTenDTOS);
     }
 
+    @Override
+    public void companyWatchCourseTopTenTask(Integer type, Integer statisticalType, Integer userType, Long companyId, Long companyUserId) {
+        AnalysisPreviewQueryDTO dto = new AnalysisPreviewQueryDTO();
+        dto.setType(type);
+        dto.setStatisticalType(statisticalType);
+
+        String startDate = "";
+        String endDate = "";
+
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
+
+        if(0 == type){
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
+        } else if(1 == type){
+            LocalDateTime yesterday = now.minusDays(1);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
+        } else if(2 == type) {
+            LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(3 == type) {
+            LocalDateTime startOfMonth = now.withDayOfMonth(1);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(4 == type) {
+            LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
+            LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
+        }
+
+        dto.setStartTime(startDate);
+        dto.setEndTime(endDate);
+        dto.setUserType(userType);
+        dto.setCompanyId(companyId);
+        dto.setCompanyUserId(companyUserId);
+
+        List<DeaMemberTopTenDTO> deaMemberTopTenDTOS = deaMemberTopTen(dto);
+        redisCache.setCacheObject(String.format("%s:%d:%d:%d:%d:%d", CHARTS_MEMBER_TOP_TEN_WATCH, type,statisticalType,userType,companyId,companyUserId), deaMemberTopTenDTOS);
+    }
+
     public void companyWatchCourseTopTenTask0(){
         List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
         for (OptionsVO optionsVO : optionsVOS) {
@@ -387,6 +663,56 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
 
 
 
+    }
+
+
+    public void companyWatchCourseTopTenTask0CompanyUser(){
+        List<CompanyUser> companyUsers = companyUserMapper.selectAllCompanyUser();
+        for (CompanyUser companyUser : companyUsers) {
+            Long companyId = companyUser.getCompanyId();
+            if (companyId == null) {
+                continue;
+            }
+            companyWatchCourseTopTenTask(0,0,1,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(0,1,1,companyId,companyUser.getUserId());
+
+
+            companyWatchCourseTopTenTask(0,0,2,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(0,1,2,companyId,companyUser.getUserId());
+        }
+
+
+    }
+
+    public void companyWatchCourseTopTenTask1CompanyUser(){
+        List<CompanyUser> companyUsers = companyUserMapper.selectAllCompanyUser();
+        for (CompanyUser companyUser : companyUsers) {
+            Long companyId = companyUser.getCompanyId();
+            if (companyId == null) {
+                continue;
+            }
+            companyWatchCourseTopTenTask(1,0,1,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(1,1,1,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(2,0,1,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(2,1,1,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(3,0,1,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(3,1,1,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(4,0,1,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(4,1,1,companyId,companyUser.getUserId());
+
+            companyWatchCourseTopTenTask(1,0,2,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(1,1,2,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(2,0,2,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(2,1,2,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(3,0,2,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(3,1,2,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(4,0,2,companyId,companyUser.getUserId());
+            companyWatchCourseTopTenTask(4,1,2,companyId,companyUser.getUserId());
+
+        }
+
+
+
     }
 
     @Override
@@ -448,6 +774,66 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
 
     }
 
+    @Override
+    public void watchCourseTopTenTask(Integer type, Integer statisticalType, Integer userType, String sort, Long companyId, Long companyUserId) {
+        AnalysisPreviewQueryDTO dto = new AnalysisPreviewQueryDTO();
+        dto.setType(type);
+        dto.setStatisticalType(statisticalType);
+        dto.setSort(sort);
+
+        String startDate = "";
+        String endDate = "";
+
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
+
+        if(0 == type){
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
+        } else if(1 == type){
+            LocalDateTime yesterday = now.minusDays(1);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
+        } else if(2 == type) {
+            LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(3 == type) {
+            LocalDateTime startOfMonth = now.withDayOfMonth(1);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(4 == type) {
+            LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
+            LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
+        }
+        dto.setStartTime(startDate);
+        dto.setEndTime(endDate);
+        dto.setUserType(userType);
+        dto.setCompanyId(companyId);
+        dto.setCompanyUserId(companyUserId);
+        List<CourseStatsDTO> courseStatsDTOS = watchCourseTopTen(dto);
+
+        redisCache.setCacheObject( String.format("%s:%d:%d:%d:%s:%d:%d", CHARTS_WATCH_TOP_TEN, type,statisticalType,userType,sort,companyId,companyUserId), courseStatsDTOS);
+
+    }
+
 
     public void watchCourseTopTenTask0(){
         List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
@@ -585,6 +971,117 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
 
     }
 
+    public void watchCourseTopTenTask0CompanyUser(){
+        List<CompanyUser> companyUsers = companyUserMapper.selectAllCompanyUser();
+        for (CompanyUser companyUser : companyUsers) {
+            Long companyId = companyUser.getCompanyId();
+            Long userId = companyUser.getUserId();
+
+            if (companyId == null) {
+                continue;
+            }
+
+            watchCourseTopTenTask(0,0,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(0,0,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(0,1,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(0,1,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(0,2,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(0,2,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(0,3,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(0,3,1,"ASC",companyId,userId);
+
+            watchCourseTopTenTask(0,0,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(0,0,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(0,1,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(0,1,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(0,2,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(0,2,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(0,3,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(0,3,1,"ASC",companyId,userId);
+        }
+
+    }
+
+    public void watchCourseTopTenTask1CompanyUser(){
+        List<CompanyUser> companyUsers = companyUserMapper.selectAllCompanyUser();
+
+        for (CompanyUser companyUser : companyUsers) {
+            Long companyId = companyUser.getCompanyId();
+            Long userId = companyUser.getUserId();
+            if (companyId == null) {
+                continue;
+            }
+
+            watchCourseTopTenTask(1,0,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(1,0,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(1,0,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(1,0,2,"ASC",companyId,userId);
+
+            watchCourseTopTenTask(1,1,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(1,1,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(1,1,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(1,1,2,"ASC",companyId,userId);
+            watchCourseTopTenTask(1,2,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(1,2,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(1,2,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(1,2,2,"ASC",companyId,userId);
+
+            watchCourseTopTenTask(1,3,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(1,3,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(1,3,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(1,3,2,"ASC",companyId,userId);
+            watchCourseTopTenTask(2,0,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(2,0,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(2,0,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(2,0,2,"ASC",companyId,userId);
+            watchCourseTopTenTask(2,1,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(2,1,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(2,1,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(2,1,2,"ASC",companyId,userId);
+            watchCourseTopTenTask(2,2,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(2,2,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(2,2,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(2,2,2,"ASC",companyId,userId);
+
+            watchCourseTopTenTask(2,3,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(2,3,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(2,3,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(2,3,2,"ASC",companyId,userId);
+            watchCourseTopTenTask(3,0,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(3,0,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(3,0,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(3,0,2,"ASC",companyId,userId);
+            watchCourseTopTenTask(3,1,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(3,1,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(3,1,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(3,1,2,"ASC",companyId,userId);
+            watchCourseTopTenTask(3,2,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(3,2,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(3,2,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(3,2,2,"ASC",companyId,userId);
+            watchCourseTopTenTask(3,3,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(3,3,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(3,3,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(3,3,2,"ASC",companyId,userId);
+            watchCourseTopTenTask(4,0,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(4,0,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(4,0,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(4,0,2,"ASC",companyId,userId);
+            watchCourseTopTenTask(4,1,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(4,1,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(4,2,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(4,2,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(4,3,1,"DESC",companyId,userId);
+            watchCourseTopTenTask(4,3,1,"ASC",companyId,userId);
+            watchCourseTopTenTask(4,1,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(4,1,2,"ASC",companyId,userId);
+            watchCourseTopTenTask(4,2,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(4,2,2,"ASC",companyId,userId);
+            watchCourseTopTenTask(4,3,2,"DESC",companyId,userId);
+            watchCourseTopTenTask(4,3,2,"ASC",companyId,userId);
+        }
+
+    }
 
     @Override
     public void rewardMoneyTopTenTask(Integer type, Integer dataType, Integer userType,Long companyId) {
@@ -646,6 +1143,66 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
 
     }
 
+    @Override
+    public void rewardMoneyTopTenTask(Integer type, Integer dataType, Integer userType, Long companyId, Long companyUserId) {
+        AnalysisPreviewQueryDTO dto = new AnalysisPreviewQueryDTO();
+        dto.setType(type);
+        dto.setDataType(dataType);
+
+        String startDate = "";
+        String endDate = "";
+
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
+
+        if(0 == type){
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
+        } else if(1 == type){
+            LocalDateTime yesterday = now.minusDays(1);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
+        } else if(2 == type) {
+            LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(3 == type) {
+            LocalDateTime startOfMonth = now.withDayOfMonth(1);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(4 == type) {
+            LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
+            LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
+        }
+
+        dto.setStartTime(startDate);
+        dto.setEndTime(endDate);
+        dto.setUserType(userType);
+        dto.setCompanyId(companyId);
+        dto.setCompanyUserId(companyUserId);
+        List<RewardMoneyTopTenDTO> rewardMoneyTopTenDTOS = rewardMoneyTopTen(dto);
+
+        redisCache.setCacheObject( String.format("%s:%d:%d:%d:%d:%d", CHARTS_REWARD_MONEY_TOP_TEN, type,dataType,userType,companyId,companyUserId), rewardMoneyTopTenDTOS);
+
+    }
+
     @Override
     public void rewardMoneyTradeTask(Integer type, Integer userType,Long companyId) {
         AnalysisPreviewQueryDTO dto = new AnalysisPreviewQueryDTO();
@@ -699,7 +1256,64 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
         dto.setUserType(userType);
         dto.setCompanyId(companyId);
         List<RewardMoneyTrendDTO> rewardMoneyTrendDTOS = rewardMoneyTrendDTO(dto);
-        redisCache.setCacheObject( String.format("%s:%d:%d", CHARTS_REWARD_MONEY_TREND, type,userType), rewardMoneyTrendDTOS);
+        redisCache.setCacheObject( String.format("%s:%d:%d:%d", CHARTS_REWARD_MONEY_TREND, type,userType,companyId), rewardMoneyTrendDTOS);
+
+    }
+
+    @Override
+    public void rewardMoneyTradeTask(Integer type, Integer userType, Long companyId, Long companyUserId) {
+        AnalysisPreviewQueryDTO dto = new AnalysisPreviewQueryDTO();
+        dto.setType(type);
+
+        String startDate = "";
+        String endDate = "";
+
+        LocalDateTime now = LocalDateTime.now();
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+
+        LocalTime startOfDayTime = LocalTime.MIN;
+        LocalTime endOfDayTime = LocalTime.of(23, 59, 59);
+
+        if(0 == type){
+            LocalDateTime startOfDay = now.with(startOfDayTime);
+            LocalDateTime endOfDay = now.with(endOfDayTime);
+            startDate = startOfDay.format(formatter);
+            endDate = endOfDay.format(formatter);
+        } else if(1 == type){
+            LocalDateTime yesterday = now.minusDays(1);
+            LocalDateTime startOfYesterday = yesterday.with(startOfDayTime);
+            LocalDateTime endOfYesterday = yesterday.with(endOfDayTime);
+            startDate = startOfYesterday.format(formatter);
+            endDate = endOfYesterday.format(formatter);
+        } else if(2 == type) {
+            LocalDateTime startOfWeek = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+            LocalDateTime startOfStartOfWeek = startOfWeek.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfWeek.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(3 == type) {
+            LocalDateTime startOfMonth = now.withDayOfMonth(1);
+            LocalDateTime startOfStartOfMonth = startOfMonth.with(startOfDayTime);
+            LocalDateTime endOfToday = now.with(endOfDayTime);
+            startDate = startOfStartOfMonth.format(formatter);
+            endDate = endOfToday.format(formatter);
+        } else if(4 == type) {
+            LocalDateTime firstDayOfPreviousMonth = now.minusMonths(1).withDayOfMonth(1);
+            LocalDateTime lastDayOfPreviousMonth = now.withDayOfMonth(1).minusDays(1);
+
+            LocalDateTime startOfPrevMonthStart = firstDayOfPreviousMonth.with(startOfDayTime);
+            LocalDateTime endOfPrevMonthEnd = lastDayOfPreviousMonth.with(endOfDayTime);
+
+            startDate = startOfPrevMonthStart.format(formatter);
+            endDate = endOfPrevMonthEnd.format(formatter);
+        }
+
+        dto.setStartTime(startDate);
+        dto.setEndTime(endDate);
+        dto.setUserType(userType);
+        dto.setCompanyId(companyId);
+        List<RewardMoneyTrendDTO> rewardMoneyTrendDTOS = rewardMoneyTrendDTO(dto);
+        redisCache.setCacheObject( String.format("%s:%d:%d:%d", CHARTS_REWARD_MONEY_TREND, type,userType,companyId), rewardMoneyTrendDTOS);
 
     }
 
@@ -724,7 +1338,74 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
 
     }
 
+    public void rewardMoneyTask15MinutesCompanyUser(){
+        List<CompanyUser> companyUsers = companyUserMapper.selectAllCompanyUser();
+        for (CompanyUser companyUser : companyUsers) {
+            Long companyId = companyUser.getCompanyId();
+            Long companyUserId = companyUser.getUserId();
+
+            if (companyId == null) {
+                continue;
+            }
+            rewardMoneyTopTenTask(0,0,1,companyId,companyUserId);
+            rewardMoneyTopTenTask(0,1,1,companyId,companyUserId);
+
+            rewardMoneyTradeTask(0,1,companyId,companyUserId);
+
+            rewardMoneyTopTenTask(0,0,2,companyId,companyUserId);
+            rewardMoneyTopTenTask(0,1,2,companyId,companyUserId);
+
+            rewardMoneyTradeTask(0,2,companyId,companyUserId);
+        }
+
+    }
+    public void rewardMoneyTaskEverydayCompanyUser(){
+        List<CompanyUser> companyUsers = companyUserMapper.selectAllCompanyUser();
+
+        for (CompanyUser companyUser : companyUsers) {
+            Long companyId = companyUser.getCompanyId();
+            Long companyUserId = companyUser.getUserId();
+
+            if (companyId == null) {
+                continue;
+            }
+
+            rewardMoneyTopTenTask(1,0,1,companyId,companyUserId);
+            rewardMoneyTopTenTask(1,1,1,companyId,companyUserId);
+
+
+            rewardMoneyTopTenTask(2,0,1,companyId,companyUserId);
+            rewardMoneyTopTenTask(2,1,1,companyId,companyUserId);
+
+            rewardMoneyTopTenTask(3,0,1,companyId,companyUserId);
+            rewardMoneyTopTenTask(3,1,1,companyId,companyUserId);
 
+            rewardMoneyTopTenTask(4,0,1,companyId,companyUserId);
+            rewardMoneyTopTenTask(4,1,1,companyId,companyUserId);
+
+
+            rewardMoneyTradeTask(1,1,companyId,companyUserId);
+            rewardMoneyTradeTask(2,1,companyId,companyUserId);
+            rewardMoneyTradeTask(3,1,companyId,companyUserId);
+            rewardMoneyTradeTask(4,1,companyId,companyUserId);
+
+
+            rewardMoneyTopTenTask(1,0,2,companyId,companyUserId);
+            rewardMoneyTopTenTask(1,1,2,companyId,companyUserId);
+            rewardMoneyTopTenTask(2,0,2,companyId,companyUserId);
+            rewardMoneyTopTenTask(2,1,2,companyId,companyUserId);
+            rewardMoneyTopTenTask(3,0,2,companyId,companyUserId);
+            rewardMoneyTopTenTask(3,1,2,companyId,companyUserId);
+            rewardMoneyTopTenTask(4,0,2,companyId,companyUserId);
+            rewardMoneyTopTenTask(4,1,2,companyId,companyUserId);
+
+            rewardMoneyTradeTask(1,2,companyId,companyUserId);
+            rewardMoneyTradeTask(2,2,companyId,companyUserId);
+            rewardMoneyTradeTask(3,2,companyId,companyUserId);
+            rewardMoneyTradeTask(4,2,companyId,companyUserId);
+        }
+
+    }
     public void rewardMoneyTaskEveryday(){
         List<OptionsVO> optionsVOS = companyService.selectAllCompanyList();
         for (OptionsVO optionsVO : optionsVOS) {
@@ -772,14 +1453,34 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
 
     @Override
     public DealerAggregatedDTO dealerAggregated(Long companyId) {
-        Long dayUserCount=userService.selectFsUserCount(1,companyId);
-        Long storeOrderCount=storeOrderService.selectFsStoreOrderTotalCount(0,companyId);
-        Long dayStoreOrderCount=storeOrderService.selectFsStoreOrderTotalCount(1,companyId);
-        Long paymentCount=paymentService.selectFsStorePaymentCount(0,companyId);
-        Long dayPaymentCount=paymentService.selectFsStorePaymentCount(1,companyId);
+        Long dayUserCount=userService.selectFsUserCount(1,companyId,null);
+        Long storeOrderCount=storeOrderService.selectFsStoreOrderTotalCount(0,companyId,null);
+        Long dayStoreOrderCount=storeOrderService.selectFsStoreOrderTotalCount(1,companyId,null);
+        Long paymentCount=paymentService.selectFsStorePaymentCount(0,companyId,null);
+        Long dayPaymentCount=paymentService.selectFsStorePaymentCount(1,companyId,null);
         Long productCount=productService.selectFsStoreProductCount(0,companyId);
         Long dayProductCount=productService.selectFsStoreProductCount(1,companyId);
-        DealerAggregatedDTO dealerAggregatedDTO = consumptionBalanceMapper.dealerAggregatedCompanyId(companyId);
+        DealerAggregatedDTO dealerAggregatedDTO = consumptionBalanceMapper.dealerAggregatedCompanyId(companyId,null);
+        dealerAggregatedDTO.setTodayIncreaseUserNum(dayUserCount);
+        dealerAggregatedDTO.setOrderTotalNum(storeOrderCount);
+        dealerAggregatedDTO.setTodayOrderNum(dayStoreOrderCount);
+        dealerAggregatedDTO.setRecvTodayNum(paymentCount);
+        dealerAggregatedDTO.setRecvTodayNum(dayPaymentCount);
+        dealerAggregatedDTO.setGoodsTotalNum(productCount);
+        dealerAggregatedDTO.setTodayGoodsNum(dayProductCount);
+        return dealerAggregatedDTO;
+    }
+
+    @Override
+    public DealerAggregatedDTO dealerAggregated(Long companyId, Long companyUserId) {
+        Long dayUserCount=userService.selectFsUserCount(1,companyId,companyUserId);
+        Long storeOrderCount=storeOrderService.selectFsStoreOrderTotalCount(0,companyId,companyUserId);
+        Long dayStoreOrderCount=storeOrderService.selectFsStoreOrderTotalCount(1,companyId,companyUserId);
+        Long paymentCount=paymentService.selectFsStorePaymentCount(0,companyId,companyUserId);
+        Long dayPaymentCount=paymentService.selectFsStorePaymentCount(1,companyId,companyUserId);
+        Long productCount=productService.selectFsStoreProductCount(0,companyId);
+        Long dayProductCount=productService.selectFsStoreProductCount(1,companyId);
+        DealerAggregatedDTO dealerAggregatedDTO = consumptionBalanceMapper.dealerAggregatedCompanyId(companyId,companyUserId);
         dealerAggregatedDTO.setTodayIncreaseUserNum(dayUserCount);
         dealerAggregatedDTO.setOrderTotalNum(storeOrderCount);
         dealerAggregatedDTO.setTodayOrderNum(dayStoreOrderCount);
@@ -1017,9 +1718,21 @@ public class StatisticsCompanyServiceImpl implements IStatisticsCompanyService {
     @Override
     public TrafficLogDTO getTrafficLog(Long companyId) {
         TrafficLogDTO trafficLogDTO = new TrafficLogDTO();
-        Long todayTrafficLog = fsCourseTrafficLogMapper.getTodayTrafficLogCompanyId(companyId);
-        Long yesterdayTrafficLog = fsCourseTrafficLogMapper.getYesterdayTrafficLogCompanyId(companyId);
-        Long monthTrafficLog = fsCourseTrafficLogMapper.getMonthTrafficLogCompanyId(companyId);
+        Long todayTrafficLog = fsCourseTrafficLogMapper.getTodayTrafficLogCompanyId(companyId,null);
+        Long yesterdayTrafficLog = fsCourseTrafficLogMapper.getYesterdayTrafficLogCompanyId(companyId,null);
+        Long monthTrafficLog = fsCourseTrafficLogMapper.getMonthTrafficLogCompanyId(companyId,null);
+        trafficLogDTO.setToday(todayTrafficLog);
+        trafficLogDTO.setThisMonth(monthTrafficLog);
+        trafficLogDTO.setYesterday(yesterdayTrafficLog);
+        return trafficLogDTO;
+    }
+
+    @Override
+    public TrafficLogDTO getTrafficLog(Long companyId, Long companyUserId) {
+        TrafficLogDTO trafficLogDTO = new TrafficLogDTO();
+        Long todayTrafficLog = fsCourseTrafficLogMapper.getTodayTrafficLogCompanyId(companyId,companyUserId);
+        Long yesterdayTrafficLog = fsCourseTrafficLogMapper.getYesterdayTrafficLogCompanyId(companyId,companyUserId);
+        Long monthTrafficLog = fsCourseTrafficLogMapper.getMonthTrafficLogCompanyId(companyId,companyUserId);
         trafficLogDTO.setToday(todayTrafficLog);
         trafficLogDTO.setThisMonth(monthTrafficLog);
         trafficLogDTO.setYesterday(yesterdayTrafficLog);

+ 5 - 5
fs-service-system/src/main/java/com/fs/statis/service/impl/StatisticsServiceImpl.java

@@ -675,11 +675,11 @@ public class StatisticsServiceImpl implements IStatisticsService {
 
     @Override
     public DealerAggregatedDTO dealerAggregated() {
-        Long dayUserCount=userService.selectFsUserCount(1,null);
-        Long storeOrderCount=storeOrderService.selectFsStoreOrderTotalCount(0,null);
-        Long dayStoreOrderCount=storeOrderService.selectFsStoreOrderTotalCount(1,null);
-        Long paymentCount=paymentService.selectFsStorePaymentCount(0,null);
-        Long dayPaymentCount=paymentService.selectFsStorePaymentCount(1,null);
+        Long dayUserCount=userService.selectFsUserCount(1,null,null);
+        Long storeOrderCount=storeOrderService.selectFsStoreOrderTotalCount(0,null,null);
+        Long dayStoreOrderCount=storeOrderService.selectFsStoreOrderTotalCount(1,null,null);
+        Long paymentCount=paymentService.selectFsStorePaymentCount(0,null,null);
+        Long dayPaymentCount=paymentService.selectFsStorePaymentCount(1,null,null);
         Long productCount=productService.selectFsStoreProductCount(0);
         Long dayProductCount=productService.selectFsStoreProductCount(1);
         DealerAggregatedDTO dealerAggregatedDTO = consumptionBalanceMapper.dealerAggregated();

+ 2 - 11
fs-service-system/src/main/java/com/fs/store/mapper/FsStoreOrderMapper.java

@@ -538,17 +538,8 @@ public interface FsStoreOrderMapper
             "</if>" +
             "</script>"})
     FsStoreOrderVO selectFsStoreOrderVOByOrderCode(@Param("orderCode") String orderCode);
-    @Select({"<script> " +
-            "select count(1) from fs_store_order  " +
-            "where 1=1 " +
-            "<if test = 'type != null and  type ==1  '> " +
-            "and  DATE_FORMAT(create_time, '%Y-%m-%d')  = DATE_FORMAT(NOW(), '%Y-%m-%d') " +
-            "</if>" +
-            "<if test = 'companyId != null  '> " +
-            "and  company_id=#{companyId} " +
-            "</if>" +
-            "</script>"})
-    Long selectFsStoreOrderTotalCount(@Param("type")int type,@Param("companyId")Long companyId);
+
+    Long selectFsStoreOrderTotalCount(@Param("type")int type,@Param("companyId")Long companyId,@Param("companyUserId")Long companyUserId);
     @Select({"<script> " +
             "select o.id as orderid ,o.order_code as order_code,o.create_time as orderdate,o.total_price as amount,o.real_name as customername,o.user_phone as tel,o.user_address as address,o.delivery_name as express,o.delivery_id as packageno   from fs_store_order o  " +
             "where o.is_del=0 and o.is_sys_del=0 " +

+ 2 - 11
fs-service-system/src/main/java/com/fs/store/mapper/FsStorePaymentMapper.java

@@ -275,17 +275,8 @@ public interface FsStorePaymentMapper
     @Select("select * from fs_store_payment where business_type=2 and order_id=#{orderId} and status=1   ")
     List<FsStorePayment> selectFsStorePaymentByOrderId(Long orderId);
 
-    @Select({"<script> " +
-            "select count(1) from fs_store_payment  " +
-            "where business_type=1 and status=1 " +
-            "<if test = 'type != null and  type ==1  '> " +
-            "and  DATE_FORMAT(create_time, '%Y-%m-%d')  = DATE_FORMAT(NOW(), '%Y-%m-%d') " +
-            "</if>" +
-            "<if test = 'companyId != null  '> " +
-            "and  company_id=#{companyId} " +
-            "</if>" +
-            "</script>"})
-    Long selectFsStorePaymentCount(@Param("type") int type,@Param("companyId") Long companyId);
+
+    Long selectFsStorePaymentCount(@Param("type") int type,@Param("companyId") Long companyId,@Param("companyUserId") Long companyUserId);
 
     List<JSONObject> selectFsStorePaymentCounts(Map<String, Object> toMap);
 

+ 1 - 10
fs-service-system/src/main/java/com/fs/store/mapper/FsStoreProductMapper.java

@@ -182,16 +182,7 @@ public interface FsStoreProductMapper
             "</if>" +
             "</script>"})
     Long selectFsStoreProductCount(@Param("type") int type );
-    @Select({"<script> " +
-            "select count(1) from fs_store_product  " +
-            "where 1=1 " +
-            "<if test = 'type != null and  type ==1  '> " +
-            "and  DATE_FORMAT(create_time, '%Y-%m-%d')  = DATE_FORMAT(NOW(), '%Y-%m-%d') " +
-            "</if>" +
-            "<if test = 'companyIds != null and companyIds != \"\" '> " +
-            "and find_in_set(#{companyIds}, company_ids) " +
-            "</if>" +
-            "</script>"})
+
     Long selectFsStoreProductCompanyCount(@Param("type") int type,@Param("companyIds") Long companyIds);
 
     @Select({"<script> " +

+ 2 - 13
fs-service-system/src/main/java/com/fs/store/mapper/FsUserMapper.java

@@ -162,17 +162,8 @@ public interface FsUserMapper
             "order by tui_money desc " +
             "</script>"})
     List<FsUserTuiVO> selectFsUserTuiList(String userId);
-    @Select({"<script> " +
-            "select count(distinct u.user_id) from fs_user u left join fs_user_company_user ucu on ucu.user_id = u.user_id left join company_user cu on cu.user_id = ucu.company_user_id  " +
-            "where 1=1 " +
-            "<if test = 'type != null and  type ==1  '> " +
-            "and  DATE_FORMAT(u.create_time, '%Y-%m-%d')  = DATE_FORMAT(NOW(), '%Y-%m-%d') " +
-            "</if>" +
-            "<if test = 'companyId != null  '> " +
-            "and  cu.company_id=#{companyId} " +
-            "</if>" +
-            "</script>"})
-    Long selectFsUserCount(@Param("type") int type,@Param("companyId") Long companyId);
+
+    Long selectFsUserCount(@Param("type") int type,@Param("companyId") Long companyId,@Param("companyUserId") Long companyUserId);
 
     @Select("select * from fs_user where ma_open_id=#{openid}")
     FsUser selectFsUserByMaOpenId(String openid);
@@ -186,8 +177,6 @@ public interface FsUserMapper
     @Select("select * from fs_user where course_ma_open_id=#{openId}")
     FsUser selectFsUserByCourseMaOpenId(String openId);
 
-    Long selectCrmCustomerCount(int type, Long companyId);
-
     @Select("select * from fs_user where user_code=#{userCode}")
     FsUser selectFsUserByUserCode(String userCode);
     @Select("select * from fs_user where user_id=#{userId} for update")

+ 1 - 1
fs-service-system/src/main/java/com/fs/store/service/IFsStoreOrderService.java

@@ -144,7 +144,7 @@ public interface IFsStoreOrderService
 
     FsStoreOrderVO selectFsStoreOrderVOByOrderCode(String orderCode);
 
-    Long selectFsStoreOrderTotalCount(int type,Long companyId);
+    Long selectFsStoreOrderTotalCount(int type,Long companyId,Long companyUserId);
 
     R editTuiMoney(FsStoreOrderEditTuiMoneyParam param);
 

+ 1 - 1
fs-service-system/src/main/java/com/fs/store/service/IFsStorePaymentService.java

@@ -87,7 +87,7 @@ public interface IFsStorePaymentService
 
     List<FsStorePayment> selectFsStorePaymentByOrderId(Long orderId);
 
-    Long selectFsStorePaymentCount(int type,Long companyId);
+    Long selectFsStorePaymentCount(int type,Long companyId,Long companyUserId);
 
     String payConfirm(String payCode,String tradeNo,String bankTransactionId,String bankSerialNo);
 

+ 1 - 1
fs-service-system/src/main/java/com/fs/store/service/IFsUserService.java

@@ -110,7 +110,7 @@ public interface IFsUserService
 
     List<FsUserTuiVO> selectFsUserTuiList(String userId);
 
-    Long selectFsUserCount(int type,Long companyId);
+    Long selectFsUserCount(int type,Long companyI,Long companyUserId);
 
     void addTuiMoney(FsStoreOrder order, List<FsStoreOrderItem> items);
 

+ 2 - 2
fs-service-system/src/main/java/com/fs/store/service/impl/FsStoreOrderServiceImpl.java

@@ -1654,8 +1654,8 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
     }
 
     @Override
-    public Long selectFsStoreOrderTotalCount(int type,Long companyId) {
-        return fsStoreOrderMapper.selectFsStoreOrderTotalCount(type,companyId);
+    public Long selectFsStoreOrderTotalCount(int type,Long companyId,Long companyUserId) {
+        return fsStoreOrderMapper.selectFsStoreOrderTotalCount(type,companyId,companyUserId);
     }
 
     @Override

+ 14 - 4
fs-service-system/src/main/java/com/fs/store/service/impl/FsStorePaymentServiceImpl.java

@@ -15,11 +15,13 @@ import com.fs.common.core.domain.R;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.IPUtils;
 import com.fs.common.utils.ServletUtils;
+import com.fs.common.utils.StringUtils;
 import com.fs.company.domain.CompanyConfig;
 import com.fs.company.domain.CompanyUser;
 import com.fs.company.mapper.CompanyConfigMapper;
 import com.fs.company.service.ICompanyService;
 import com.fs.company.service.ICompanyUserService;
+import com.fs.core.utils.OrderCodeUtils;
 import com.fs.course.config.RedPacketConfig;
 import com.fs.course.service.IFsCourseRedPacketLogService;
 import com.fs.pay.pay.config.PayConfig;
@@ -298,8 +300,8 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
     }
 
     @Override
-    public Long selectFsStorePaymentCount(int type,Long companyId) {
-        return fsStorePaymentMapper.selectFsStorePaymentCount(type,companyId);
+    public Long selectFsStorePaymentCount(int type,Long companyId,Long companyUserId) {
+        return fsStorePaymentMapper.selectFsStorePaymentCount(type,companyId,companyUserId);
     }
 
     @Override
@@ -406,7 +408,11 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
         System.out.println("appid:"+config.getAppId());
         request.setOpenid(param.getOpenId());
 
-        String code = String.valueOf(IdUtil.getSnowflake(0, 0).nextId());
+//        String code = String.valueOf(IdUtil.getSnowflake(0, 0).nextId());
+        String code =  OrderCodeUtils.getOrderSn();
+        if(StringUtils.isEmpty(code)){
+            return R.error("红包单号生成失败,请重试");
+        }
         request.setOutBillNo("fsCourse" + code);
 
         Integer amount = WxPayUnifiedOrderRequest.yuanToFen(param.getAmount() != null ? param.getAmount().toString() : "0.1");
@@ -450,7 +456,11 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
 
         TransferBatchesRequest request = new TransferBatchesRequest();
         request.setAppid(config.getAppId());
-        String code = IdUtil.getSnowflake(0, 0).nextIdStr();
+//        String code = IdUtil.getSnowflake(0, 0).nextIdStr();
+        String code =  OrderCodeUtils.getOrderSn();
+        if(StringUtils.isEmpty(code)){
+            return R.error("红包单号生成失败,请重试");
+        }
         request.setOutBatchNo("fsCourse" + code);
         request.setBatchRemark("课堂答题奖励");
         request.setBatchName("课堂答题奖励");

+ 1 - 1
fs-service-system/src/main/java/com/fs/store/service/impl/FsUserCourseCountServiceImpl.java

@@ -129,7 +129,7 @@ public class FsUserCourseCountServiceImpl implements IFsUserCourseCountService
             if(fsUserCourseCount != null){
                 data.setLastWatchDate(fsUserCourseCount.getLastWatchDate());
                 data.setStatus(fsUserCourseCount.getStatus());
-                data.setStopWatchDays(fsUserCourseCount.getStopWatchDays());
+//                data.setStopWatchDays(fsUserCourseCount.getStopWatchDays());
             }
         }
 

+ 16 - 31
fs-service-system/src/main/java/com/fs/store/service/impl/FsUserServiceImpl.java

@@ -278,8 +278,8 @@ public class FsUserServiceImpl implements IFsUserService
     }
 
     @Override
-    public Long selectFsUserCount(int type,Long companyId) {
-        return fsUserMapper.selectFsUserCount(type,companyId);
+    public Long selectFsUserCount(int type,Long companyId,Long companyUserId) {
+        return fsUserMapper.selectFsUserCount(type,companyId,companyUserId);
     }
 
     @Override
@@ -498,36 +498,21 @@ public class FsUserServiceImpl implements IFsUserService
         }
         List<FsUserPageListVO> fsUserPageListVOS = fsUserMapper.selectFsUserPageList(param);
 
-        // 项目
+
         List<SysDictData> courseProject = dictDataMapper.selectDictDataByType("sys_course_project");
-        fsUserPageListVOS.forEach(vo -> courseProject.stream()
-                .filter(c -> c.getDictValue().equals(vo.getProjectId().toString()))
-                .findFirst()
-                .ifPresent(c -> vo.setProjectName(c.getDictLabel())));
-
-        // 获取当前销售所有重粉会员
-        List<FsUserCompanyUser> fsUserCompanyUsers = userCompanyUserService.selectRepeatUser(param.getUserId());
-
-        if(!fsUserCompanyUsers.isEmpty()){
-            List<Long> userIds = fsUserCompanyUsers.stream().map(FsUserCompanyUser::getUserId).collect(Collectors.toList());
-            // 获取会员所属的重粉销售
-            List<FsUserCompanyUser> repeatCompanyUserNames = userCompanyUserService.selectRepeatCompanyUserName(userIds);
-            Map<Long, String> map = repeatCompanyUserNames.stream().collect(Collectors.toMap(FsUserCompanyUser::getUserId, FsUserCompanyUser::getRepeatCompanyUserName));
-
-            for (FsUserPageListVO fsUserPageListVO : fsUserPageListVOS) {
-                fsUserPageListVO.setRepeatCompanyUserName(map.get(fsUserPageListVO.getUserId()));
-                if ("微信用户".equals(fsUserPageListVO.getNickname()) && StringUtils.isNotEmpty(fsUserPageListVO.getPhone())) {
-                    fsUserPageListVO.setNickname(fsUserPageListVO.getPhone());
-                }
-                if(StringUtils.isNotEmpty(fsUserPageListVO.getTag()) && fsUserPageListVO.getIsRepeatFans() == 0){
-                    StringBuilder newTag = removeRepeatFansTag(fsUserPageListVO);
-                    fsUserPageListVO.setTag(newTag.toString());
-                }
+        for (FsUserPageListVO fsUserPageListVO : fsUserPageListVOS) {
+            // 项目
+            courseProject.stream()
+                    .filter(c -> c.getDictValue().equals(fsUserPageListVO.getProjectId().toString()))
+                    .findFirst()
+                    .ifPresent(c -> fsUserPageListVO.setProjectName(c.getDictLabel()));
+            if (StringUtils.isEmpty(fsUserPageListVO.getNickname())){
+                fsUserPageListVO.setNickname("用户暂未授权昵称");
             }
-            return new PageInfo<>(fsUserPageListVOS);
-        } else {
-            return new PageInfo<>(fsUserPageListVOS);
         }
+
+        return new PageInfo<>(fsUserPageListVOS);
+
     }
 
     private static StringBuilder removeRepeatFansTag(FsUserPageListVO fsUserPageListVO) {
@@ -562,8 +547,8 @@ public class FsUserServiceImpl implements IFsUserService
         Map<Long, CompanyTag> tagMap = companyTagCacheService.queryAllTagMap();
         //获取会员的最新的看课状态和最后看课时间
         Set<Long> userIds = fsUserPageListVOS.stream().map(FsUserPageListVO::getUserId).collect(Collectors.toSet());
-        List<FsUserLastCount> fsUserCourseCounts = new ArrayList<>();
-        if (userIds.size() > 0) {
+        List<FsUserLastCount> fsUserCourseCounts = Collections.emptyList();
+        if(!userIds.isEmpty()){
             fsUserCourseCounts = fsUserCourseCountMapper.selectUserLastCount(userIds);
         }
         Map<Long, FsUserLastCount> countMap = fsUserCourseCounts.stream().collect(Collectors.toMap(FsUserLastCount::getUserId, Function.identity()));

+ 1 - 0
fs-service-system/src/main/resources/application-config-zkzh.yml

@@ -50,6 +50,7 @@ fsConfig:
   appId: 1661496555
   manuId: 0212af1e742b41b09089afeec98f8276
   callbackUrl: https://api.yjf.runtzh.com/app/prescribe/presribeNotify
+  commonApi: http://172.21.76.167:7011 #admin后台
 logging:
   level:
     org.springframework.web: INFO

+ 9 - 0
fs-service-system/src/main/resources/mapper/course/FsCourseTrafficLogMapper.xml

@@ -111,6 +111,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyId != null">
                 AND company_id = ${companyId}
             </if>
+            <if test="companyUserId != null">
+                AND company_user_id = #{companyUserId}
+            </if>
         </where>
 
     </select>
@@ -125,6 +128,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyId != null">
                 AND company_id = ${companyId}
             </if>
+            <if test="companyUserId != null">
+                AND company_user_id = #{companyUserId}
+            </if>
         </where>
     </select>
     <select id="getYesterdayTrafficLogCompanyId" resultType="java.lang.Long">
@@ -137,6 +143,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyId != null">
                 AND company_id = ${companyId}
             </if>
+            <if test="companyUserId != null">
+                AND company_user_id = #{companyUserId}
+            </if>
         </where>
 
     </select>

+ 1 - 1
fs-service-system/src/main/resources/mapper/course/FsUserCourseVideoMapper.xml

@@ -261,7 +261,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND ccut.course_id = fcpd.course_id
             AND ccut.video_id = fcpd.video_id
             AND ccut.company_user_id = #{companyUserId}
-        where course.is_del = 0
+        where course.is_del = 0 and fcp.del_flag = 0 and fcpd.del_flag = 0
         AND FIND_IN_SET(#{companyId}, fcp.company_id)
         <if test="periodId != null and periodId !='' ">
             AND fcpd.period_id = #{periodId}

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

@@ -50,6 +50,9 @@
             <if test="companyId != null">
                 and company_id = #{companyId}
             </if>
+            <if test="companyUserId != null">
+                and company_user_id = #{companyUserId}
+            </if>
         </where>
     </select>
     <select id="queryCompletedUserCount" resultType="java.lang.Long">
@@ -65,6 +68,9 @@
             <if test="companyId != null">
                 and company_id = #{companyId}
             </if>
+            <if test="companyUserId != null">
+                and company_user_id = #{companyUserId}
+            </if>
         </where>
     </select>
     <select id="queryWatchUserCount" resultType="java.lang.Long">
@@ -79,7 +85,9 @@
             <if test="companyId != null">
                 and company_id = #{companyId}
             </if>
-
+            <if test="companyUserId != null">
+                and company_user_id = #{companyUserId}
+            </if>
         </where>
     </select>
     <select id="queryCompletedCount" resultType="java.lang.Long">
@@ -95,6 +103,9 @@
              <if test="companyId != null">
                  and company_id = #{companyId}
              </if>
+             <if test="companyUserId != null">
+                 and company_user_id = #{companyUserId}
+             </if>
          </where>
     </select>
     <select id="queryAnswerMemberCount" resultType="java.lang.Long">
@@ -106,6 +117,9 @@
            <if test="companyId != null">
                and company_id = #{companyId}
            </if>
+           <if test="companyUserId != null">
+               and company_user_id = #{companyUserId}
+           </if>
        </where>
     </select>
     <select id="queryCorrectUserCount" resultType="java.lang.Long">
@@ -118,6 +132,9 @@
             <if test="companyId != null">
                 and company_id = #{companyId}
             </if>
+            <if test="companyUserId != null">
+                and company_user_id = #{companyUserId}
+            </if>
         </where>
     </select>
     <select id="queryRewardCount" resultType="java.lang.Long">
@@ -134,6 +151,9 @@
             <if test="companyId != null">
                 and log.company_id = #{companyId}
             </if>
+            <if test="companyUserId != null">
+                and log.company_user_id = #{companyUserId}
+            </if>
         </where>
     </select>
     <select id="queryRewardMoney" resultType="java.math.BigDecimal">
@@ -150,6 +170,9 @@
             <if test="companyId != null">
                 and log.company_id = #{companyId}
             </if>
+            <if test="companyUserId != null">
+                and log.company_user_id = #{companyUserId}
+            </if>
         </where>
     </select>
     <select id="smsBalance" resultType="java.lang.Long">
@@ -243,11 +266,14 @@
                 AND w.create_time <![CDATA[<]]> #{endTime}
             </if>
             <if test="userType != null">
-                AND send_type = ${userType}
+                AND w.send_type = ${userType}
             </if>
             <if test="companyId != null">
                 AND w.company_id = ${companyId}
             </if>
+            <if test="companyUserId != null">
+                AND w.company_user_id= #{companyUserId}
+            </if>
         </where>
         GROUP BY
         w.course_id
@@ -349,12 +375,18 @@
                                      <if test="companyId != null">
                                          company_id = #{companyId}
                                      </if>
+                                     <if test="companyUserId != null">
+                                         AND user_id = #{companyUserId}
+                                     </if>
                                  </where>
                                  ) AS group_mgr_count,
                 (SELECT COUNT(*) FROM FS_USER
                                 <where>
                                     <if test="companyId != null">
-                                        company_id = #{companyId}
+                                        AND company_id = #{companyId}
+                                    </if>
+                                    <if test="companyUserId != null">
+                                        AND company_user_id = #{companyUserId}
                                     </if>
                                 </where>
                                 ) AS member_count,
@@ -364,6 +396,9 @@
                                     <if test="companyId != null">
                                         AND company_id = #{companyId}
                                     </if>
+                                    <if test="companyUserId != null">
+                                        AND company_user_id = #{companyUserId}
+                                    </if>
                                 </where>
                                 ) AS normal_num,
                 (SELECT COUNT(*) FROM FS_USER
@@ -372,6 +407,9 @@
                                     <if test="companyId != null">
                                         AND company_id = #{companyId}
                                     </if>
+                                    <if test="companyUserId != null">
+                                        AND company_user_id = #{companyUserId}
+                                    </if>
                                 </where>
                 ) AS black_num,
                 (select COUNT(*) FROM qw_user
@@ -379,6 +417,9 @@
                     <if test="companyId != null">
                        AND company_id = ${companyId}
                     </if>
+                    <if test="companyUserId != null">
+                        AND company_user_id = #{companyUserId}
+                    </if>
                 </where>
         ) AS qw_member_num
     </select>

+ 13 - 0
fs-service-system/src/main/resources/mapper/store/FsStoreOrderMapper.xml

@@ -530,4 +530,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
 
     </select>
+    <select id="selectFsStoreOrderTotalCount" resultType="java.lang.Long">
+        select count(1) from fs_store_order
+        where 1=1
+        <if test = "type != null and  type ==1  ">
+            and  DATE_FORMAT(create_time, '%Y-%m-%d')  = DATE_FORMAT(NOW(), '%Y-%m-%d')
+        </if>
+        <if test = "companyId != null">
+            and  company_id = #{companyId}
+        </if>
+        <if test="companyUserId != null">
+            and company_user_id = #{companyUserId}
+        </if>
+    </select>
 </mapper>

+ 13 - 0
fs-service-system/src/main/resources/mapper/store/FsStorePaymentMapper.xml

@@ -178,6 +178,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ) t
         GROUP BY t.type
     </select>
+    <select id="selectFsStorePaymentCount" resultType="java.lang.Long">
+        select count(1) from fs_store_payment
+        where business_type=1 and status=1
+        <if test = "type != null and  type ==1">
+            and DATE_FORMAT(create_time, '%Y-%m-%d')  = DATE_FORMAT(NOW(), '%Y-%m-%d')
+        </if>
+        <if test = "companyId != null">
+            and company_id = #{companyId}
+        </if>
+        <if test="companyUserId != null">
+            and company_user_id = #{companyUserId}
+        </if>
+    </select>
 
 
 </mapper>

+ 14 - 0
fs-service-system/src/main/resources/mapper/store/FsStoreProductMapper.xml

@@ -105,6 +105,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectFsStoreProductVo"/>
         where product_id = #{productId}
     </select>
+    <select id="selectFsStoreProductCompanyCount" resultType="java.lang.Long">
+        select count(1) from fs_store_product
+        <where>
+            <if test = 'type != null and  type ==1  '>
+                and  DATE_FORMAT(create_time, '%Y-%m-%d')  = DATE_FORMAT(NOW(), '%Y-%m-%d')
+            </if>
+            <if test = 'companyIds != null and companyIds != "" '>
+                and find_in_set(#{companyIds}, company_ids)
+            </if>
+            <if test="companyUserId != null">
+                and
+            </if>
+        </where>
+    </select>
 
     <insert id="insertFsStoreProduct" parameterType="FsStoreProduct" useGeneratedKeys="true" keyProperty="productId">
         insert into fs_store_product

+ 4 - 4
fs-service-system/src/main/resources/mapper/store/FsUserCourseCountMapper.xml

@@ -189,10 +189,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                     2
                 WHEN fs_course_watch_log.log_type = 3 THEN
                     3
-                END AS STATUS,
-            DATEDIFF(
-                    DATE_FORMAT( NOW(), '%Y-%m-%d' ),
-                    DATE_FORMAT( fs_course_watch_log.last_heartbeat_time, '%Y-%m-%d' )) AS stop_watch_days
+                END AS STATUS
+--             DATEDIFF(
+--                     DATE_FORMAT( NOW(), '%Y-%m-%d' ),
+--                     DATE_FORMAT( fs_course_watch_log.last_heartbeat_time, '%Y-%m-%d' )) AS stop_watch_days
         FROM
             fs_course_watch_log
                 left join fs_user_company_user ucu on ucu.user_id = fs_course_watch_log.user_id

+ 23 - 6
fs-service-system/src/main/resources/mapper/store/FsUserMapper.xml

@@ -245,7 +245,7 @@
         SELECT
         b.total_amount,b.last_buy_time,p.pay_money as number,p.payment_id,p.pay_time,
         u.*,
-        fcc.watch_course_count, fcc.part_course_count, company_user.nick_name AS companyUserNickName, fcc.last_watch_date
+        fs_course_watch_log.watch_course_count, fs_course_watch_log.part_course_count, company_user.nick_name AS companyUserNickName, fs_course_watch_log.last_watch_date
         ,company.company_name
         FROM
         fs_user u
@@ -265,15 +265,19 @@
         AND b.payment_id = p.payment_id
         LEFT JOIN (
         SELECT
-        fs_user_course_count.user_id,Max( fs_user_course_count.last_watch_date ) AS last_watch_date,fs_user_course_count.watch_course_count,
-        fs_user_course_count.part_course_count
+        fs_course_watch_log.user_id,
+        Max( fs_course_watch_log.last_heartbeat_time ) AS last_watch_date,
+        count( DISTINCT fs_course_watch_log.video_id ) watch_course_count,
+        count( DISTINCT fs_course_watch_log.period_id ) part_course_count
         FROM
-        fs_user_course_count
-        GROUP BY fs_user_course_count.user_id
-        ) fcc ON fcc.user_id = u.user_id
+        fs_course_watch_log
+        GROUP BY
+        fs_course_watch_log.user_id
+        ) fs_course_watch_log ON fs_course_watch_log.user_id = u.user_id
         LEFT JOIN company_user ON company_user.user_id = u.company_user_id
         LEFT JOIN company on company.company_id = company_user.company_id
         <where>
+        1 = 1
         <if test = "maps.userId != null" >
             AND u.user_id = #{maps.userId}
         </if >
@@ -1848,6 +1852,19 @@
         </where>
         order by user_id desc
     </select>
+    <select id="selectFsUserCount" resultType="java.lang.Long">
+        select count(distinct u.user_id) from fs_user u left join fs_user_company_user ucu on ucu.user_id = u.user_id left join company_user cu on cu.user_id = ucu.company_user_id
+        where 1=1
+        <if test = "type != null and  type ==1">
+            and DATE_FORMAT(u.create_time, '%Y-%m-%d')  = DATE_FORMAT(NOW(), '%Y-%m-%d')
+        </if>
+        <if test = "companyId != null">
+            and cu.company_id=#{companyId}
+        </if>
+        <if test="companyUserId != null">
+            and cu.company_user_id = #{companyUserId}
+        </if>
+    </select>
     <select id="countUserCourse2" resultType="java.util.Map">
         SELECT
         (

+ 2 - 0
fs-user-app/src/main/java/com/fs/app/controller/CourseWxH5Controller.java

@@ -51,6 +51,8 @@ public class CourseWxH5Controller extends AppBaseController {
     @Autowired
     private IFsUserService fsUserService;
 
+
+//    @RepeatSubmit
     @Login
     @ApiOperation("判断是否添加客服(是否关联销售)")
     @PostMapping("/isAddKf")

+ 14 - 14
fs-user-app/src/main/java/com/fs/app/controller/WxCompanyUserController.java

@@ -36,6 +36,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.validation.Valid;
 import java.util.Date;
 import java.util.Objects;
 
@@ -103,15 +104,15 @@ public class WxCompanyUserController extends AppBaseController {
             }
 
             // 特殊(需求设计:需要根据公司是否开启黑名单来设置会员初始化的状态)
-            Company company = null;
-            if(param.getCompanyId() != null){
-                company = companyService.selectCompanyById(param.getCompanyId());
+            Company company = companyService.selectCompanyById(param.getCompanyId());
+            if (company==null || company.getStatus()==0){
+                return R.error("注册失败团队已停用,或不存在!");
             }
 
             // 根据销售后台设置的  是否需要单独注册会员 来判断是否需要设置销售的值
-            CompanyUser companyUser = null;
-            if(param.getCompanyUserId() != null){
-                companyUser = companyUserService.selectCompanyUserById(param.getCompanyUserId());
+            CompanyUser companyUser = companyUserService.selectCompanyUserById(param.getCompanyUserId());;
+            if(companyUser == null || companyUser.getStatus().equals("1")){
+                return R.error("注册失败客服已停用,或不存在!");
             }
 
             String ip = IpUtil.getRequestIp();
@@ -127,7 +128,6 @@ public class WxCompanyUserController extends AppBaseController {
                     //修改
                     FsUser userMap = new FsUser();
                     userMap.setUserId(user.getUserId());
-//                userMap.setMpOpenId(session.getOpenid());
                     userMap.setMaOpenId(session.getOpenid());
                     userMap.setUnionId(session.getUnionid());
                     userMap.setUpdateTime(new DateTime());
@@ -139,13 +139,13 @@ public class WxCompanyUserController extends AppBaseController {
                     if (Objects.nonNull(userCompanyUser) && !param.getCompanyUserId().equals(userCompanyUser.getCompanyUserId())){
                         return R.error(406, "该用户已成为其他销售会员");
                     }
-                    if(companyUser != null &&
-                            (companyUser.getIsAllowedAllRegister() == null || companyUser.getIsAllowedAllRegister() == 1)
-                            && companyUser.getIsNeedRegisterMember() != null && companyUser.getIsNeedRegisterMember() != 1){
-                        if (Objects.isNull(userCompanyUser)) {
-                            userCompanyUserService.bindRelationship(user.getUserId(), param.getProjectId(), companyUser.getCompanyId(), companyUser.getUserId(), defaultStatus);
-                        }
-                    }
+//                    if(companyUser != null &&
+//                            (companyUser.getIsAllowedAllRegister() == null || companyUser.getIsAllowedAllRegister() == 1)
+//                            && companyUser.getIsNeedRegisterMember() != null && companyUser.getIsNeedRegisterMember() != 1){
+//                        if (Objects.isNull(userCompanyUser)) {
+//                            userCompanyUserService.bindRelationship(user.getUserId(), param.getProjectId(), companyUser.getCompanyId(), companyUser.getUserId(), defaultStatus);
+//                        }
+//                    }
                     userService.updateFsUser(userMap);
                 } else {
                     //新增