Przeglądaj źródła

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

caoliqin 1 miesiąc temu
rodzic
commit
4e1a2da44a

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

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

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

@@ -890,7 +890,7 @@ public class FsCourseWatchLogServiceImpl extends ServiceImpl<FsCourseWatchLogMap
                 //判断是否完课
                 long percentage = (duration * 100 / videoDuration);
                 if (percentage >= config.getAnswerRate()) {
-                    watchLog.setLogType(2); // 设置状态为“已完成”
+                    watchLog.setLogType(2); // 设置状态为“已完成”checkFsUserWatchStatus
                     watchLog.setFinishTime(new Date());
                     String heartbeatKey ="h5wxuser:watch:heartbeat:" + userId+ ":" + videoId + ":" + companyUserId;
                     // 完课删除心跳记录

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

@@ -46,6 +46,7 @@ import com.fs.store.service.IFsUserService;
 import com.fs.store.service.cache.IFsUserCourseCacheService;
 import com.fs.system.service.ISysConfigService;
 import com.github.binarywang.wxpay.bean.transfer.TransferBillsResult;
+import lombok.extern.slf4j.Slf4j;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
@@ -67,6 +68,7 @@ import java.util.stream.Collectors;
  * @author fs
  * @date 2024-05-17
  */
+@Slf4j
 @Service
 public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 {
@@ -304,6 +306,7 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 
         // 从Redis中获取观看时长
         String redisKey = "h5user:watch:duration:" + param.getQwUserId()+ ":" + param.getQwExternalId() + ":" + param.getVideoId();
+        log.info("看课redis-key:{}", redisKey);
         try {
             String durationStr = redisCache.getCacheObject(redisKey);
             Long duration = durationStr != null ? Long.parseLong(durationStr) : 0L;
@@ -1017,8 +1020,10 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 
         // 从Redis中获取观看时长
         String redisKey = "h5wxuser:watch:duration:" + param.getUserId() + ":" + param.getVideoId() + ":" + param.getCompanyUserId();
+        log.info("看课redis缓存key:{}", redisKey);
         try {
             String durationStr = redisCache.getCacheObject(redisKey);
+            log.info("看课记录:{}", durationStr);
             long duration = durationStr != null ? Long.parseLong(durationStr) : 0L;
 
             // 更新Redis中的观看时长

+ 39 - 48
fs-service-system/src/main/java/com/fs/sop/service/impl/QwSopTempServiceImpl.java

@@ -210,55 +210,46 @@ public class QwSopTempServiceImpl implements IQwSopTempService
             day.setName("第" + day.getDayNum() + "天");
             day.setSorts(day.getDayNum());
             day.setList(new ArrayList<>());
-            QwSopTempRules rules = new QwSopTempRules();
-            rules.setTempId(temp.getId());
-            rules.setName(day.getName());
-            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
-            rules.setTime(e.getViewStartTime().format(formatter));
-            rules.setContentType(2);
-            rules.setType(2);
-            rules.setCourseType(0);
-            rules.setCourseId(e.getCourseId());
-            rules.setVideoId(e.getVideoId());
-            rules.setSorts(0);
-            day.getList().add(rules);
-            QwSopTempContent content = new QwSopTempContent();
-            content.setTempId(temp.getId());
-            content.setContentType(3);
-            QwSopTempSetting2.Content.Setting setting = new QwSopTempSetting2.Content.Setting();
-            setting.setLinkTitle(fsUserCourse.getCourseName());
-            setting.setIsBindUrl(1);
-            setting.setLinkDescribe(e.getTitle());
-            setting.setLinkImageUrl(fsUserCourse.getImgUrl());
-            setting.setContentType("3");
-            content.setContent(JSON.toJSONString(setting));
-            content.setIsBindUrl(1);
-            rules.setList(Collections.singletonList(content));
-
-
-
-            if(temp.getTimeList() != null &&  !temp.getTimeList().isEmpty()){
-                AtomicInteger sorts = new AtomicInteger(1);
-                List<QwSopTempRules> rulesList = temp.getTimeList().stream().map(time -> {
-                    QwSopTempRules rulesSub = new QwSopTempRules();
-                    rulesSub.setTempId(temp.getId());
-                    rulesSub.setName(day.getName());
-                    rulesSub.setTime(time);
-                    rulesSub.setContentType(1);
-                    rulesSub.setType(1);
-                    rulesSub.setSorts(sorts.getAndIncrement());
-                    QwSopTempContent contentSbu = new QwSopTempContent();
-                    contentSbu.setTempId(temp.getId());
-                    contentSbu.setContentType(1);
-                    QwSopTempSetting2.Content.Setting settingSub = new QwSopTempSetting2.Content.Setting();
-                    settingSub.setContentType("1");
-                    settingSub.setValue("");
-                    contentSbu.setContent(JSON.toJSONString(settingSub));
-                    rulesSub.setList(Collections.singletonList(contentSbu));
-                    return rulesSub;
-                }).collect(Collectors.toList());
-                day.getList().addAll(rulesList);
+            if(temp.getTimeList() == null){
+                temp.setTimeList(new ArrayList<>());
             }
+            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
+            temp.getTimeList().add(0, e.getViewStartTime().format(formatter));
+            AtomicInteger sorts = new AtomicInteger(0);
+            List<QwSopTempRules> rulesList = temp.getTimeList().stream().map(time -> {
+                QwSopTempRules rules = new QwSopTempRules();
+                rules.setTempId(temp.getId());
+                rules.setName(day.getName());
+                rules.setTime(time);
+                rules.setContentType(2);
+                rules.setType(2);
+                rules.setCourseType(0);
+                rules.setCourseId(e.getCourseId());
+                rules.setVideoId(e.getVideoId());
+                rules.setSorts(sorts.getAndIncrement());
+                // 设置消息类型
+                if(rules.getSorts() == 0){
+                    rules.setCourseType(0);
+                }else if(rules.getSorts() == 1){
+                    rules.setCourseType(1);
+                }else{
+                    rules.setCourseType(4);
+                }
+                QwSopTempContent content = new QwSopTempContent();
+                content.setTempId(temp.getId());
+                content.setContentType(3);
+                QwSopTempSetting2.Content.Setting setting = new QwSopTempSetting2.Content.Setting();
+                setting.setLinkTitle(fsUserCourse.getCourseName());
+                setting.setIsBindUrl(1);
+                setting.setLinkDescribe(e.getTitle());
+                setting.setLinkImageUrl(fsUserCourse.getImgUrl());
+                setting.setContentType("3");
+                content.setContent(JSON.toJSONString(setting));
+                content.setIsBindUrl(1);
+                rules.setList(Collections.singletonList(content));
+                return rules;
+            }).collect(Collectors.toList());
+            day.getList().addAll(rulesList);
             return day;
         }).collect(Collectors.toList());
         qwSopTempDayService.addOrUpdateBatch(collect);

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

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

+ 5 - 0
fs-user-app/src/main/java/com/fs/app/controller/CourseH5Controller.java

@@ -64,6 +64,7 @@ public class CourseH5Controller extends  AppBaseController{
     @GetMapping("/getH5CourseVideoDetails")
     public R getCourseVideoDetails(FsUserCourseVideoFinishUParam param)
     {
+        param.setUserId(Long.parseLong(getUserId()));
         String json = configService.selectConfigByKey("course.config");
         CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
         FsUserCourseVideoH5DVO course = courseService.selectFsUserCourseVideoH5DVOByVideoId(param.getVideoId());
@@ -128,6 +129,7 @@ public class CourseH5Controller extends  AppBaseController{
     @PostMapping("/updateWatchDuration")
     public R updateWatchDuration(@RequestBody FsUserCourseVideoFinishUParam param)
     {
+        param.setUserId(Long.parseLong(getUserId()));
         return courseVideoService.updateWatchDuration(param);
     }
 
@@ -135,6 +137,7 @@ public class CourseH5Controller extends  AppBaseController{
     @ApiOperation("获取缓冲流量")
     @PostMapping("/getInternetTraffic")
     public R getInternetTraffic(@RequestBody FsUserCourseVideoFinishUParam param) {
+        param.setUserId(Long.parseLong(getUserId()));
         return courseVideoService.getInternetTraffic(param);
     }
 
@@ -142,6 +145,7 @@ public class CourseH5Controller extends  AppBaseController{
     @PostMapping("/courseAnswer")
     public R courseAnswer(@RequestBody FsCourseQuestionAnswerUParam param)
     {
+        param.setUserId(Long.parseLong(getUserId()));
         logger.info("zyp \n【答题】:{}",param.getQuestions());
         if (param.getDuration()==null){
             logger.info("zyp \n【未识别到时长】:{}",param.getUserId());
@@ -154,6 +158,7 @@ public class CourseH5Controller extends  AppBaseController{
     @RepeatSubmit
     public R sendReward(@RequestBody FsCourseSendRewardUParam param)
     {
+        param.setUserId(Long.parseLong(getUserId()));
         logger.info("zyp \n【发放奖励】:{}",param);
         return courseVideoService.sendReward(param);
     }

+ 1 - 1
fs-user-app/src/main/resources/application.yml

@@ -50,7 +50,7 @@ server:
 # 日志配置
 logging:
   level:
-    com.fs: info
+    com.fs: debug
     org.springframework: warn
 
 # Spring配置