Quellcode durchsuchen

Merge remote-tracking branch 'origin/master'

yfh vor 1 Woche
Ursprung
Commit
94ec43a1d4

+ 2 - 0
fs-admin/src/main/java/com/fs/course/controller/FsUserCoursePeriodController.java

@@ -189,6 +189,7 @@ public class FsUserCoursePeriodController extends BaseController {
         return R.ok().put("data", periodRedPacketList);
     }
 
+    @Log(title = "按课程批量保存设置红包金额", businessType = BusinessType.UPDATE)
     @PreAuthorize("@ss.hasPermi('course:period:setCourseRedPacket')")
     @ApiOperation("按课程批量保存设置红包金额")
     @PostMapping("/batchRedPacket")
@@ -202,6 +203,7 @@ public class FsUserCoursePeriodController extends BaseController {
         return R.ok();
     }
 
+    @Log(title = "按营期批量保存设置红包金额", businessType = BusinessType.UPDATE)
     @PreAuthorize("@ss.hasPermi('course:period:setRedPacket')")
     @ApiOperation("按营期批量保存设置红包金额")
     @PostMapping("/batchRedPacket/byPeriod")

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

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

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

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

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

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

+ 3 - 0
fs-service-system/src/main/java/com/fs/course/param/PeriodCountParam.java

@@ -30,5 +30,8 @@ public class PeriodCountParam implements Serializable {
 
     private LocalDate maxDate;
 
+    @ApiModelProperty(value = "公司ID")
+    private Long companyId;
+
 }
 

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

@@ -35,7 +35,10 @@ import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -238,6 +241,7 @@ public class FsUserCoursePeriodDaysServiceImpl extends ServiceImpl<FsUserCourseP
         CourseAnalysisParam courseAnalysisParam = new CourseAnalysisParam();
         courseAnalysisParam.setPeriodId(param.getPeriodId());
         courseAnalysisParam.setVideoIdList(param.getVideoIdList());
+        courseAnalysisParam.setCompanyId(param.getCompanyId());
         List<FsCourseAnalysisCountVO> courseCountList = fsUserMapper.courseAnalysisWatchLog(courseAnalysisParam);
         List<FsCourseAnalysisCountVO> redPacketCountList = fsUserMapper.courseAnalysisRedPacketCount(courseAnalysisParam);
         List<FsCourseAnalysisCountVO> answerCountList = fsUserMapper.courseAnalysisAnswerCount(courseAnalysisParam);

+ 3 - 1
fs-service-system/src/main/java/com/fs/his/param/WxSendRedPacketParam.java

@@ -16,7 +16,9 @@ public class WxSendRedPacketParam implements Serializable {
 
     private Integer source=1;//来源 1:h5  2:看课小程序
 
-    private Integer redPacketMode; //红包模式
+    private Integer redPacketMode;//红包模式
+
+    private String appId;
 
 
 }

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

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

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

@@ -76,6 +76,11 @@ wx:
         token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
         aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
         msgDataFormat: JSON
+      - appid: wx414427b10866c04e   #凯逸轩服装店C
+        secret: 4a56cc02f53859e1e9582c15d840c4af
+        token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
+        aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
+        msgDataFormat: JSON
 
   pay:
     appId: wx11a2ce7c2bbc4521 #微信公众号或者小程序等的appid

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

@@ -119,6 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             fwl.company_id
         FROM
             fs_course_watch_log fwl
+
         WHERE
             fwl.send_type = 1
         GROUP BY

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

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

+ 48 - 26
fs-service-system/src/main/resources/mapper/store/FsUserMapper.xml

@@ -525,10 +525,12 @@
         fs_user.*,
         fs_user_course_count.id,
         fs_user_course_count.watch_course_count,
+--         fs_course_watch_log.watch_course_count,
         fs_user_course_count.miss_course_count,
         fs_user_course_count.miss_course_status,
         fs_user_course_count.course_ids,
         fs_user_course_count.part_course_count,
+--         fs_course_watch_log.part_course_count,
         fs_user_course_count.last_watch_date,
         fs_user_course_count.STATUS AS courseCountStatus,
         fs_user_course_count.stop_watch_days,
@@ -543,6 +545,17 @@
         LEFT JOIN company_tag_user ON fs_user.user_id = company_tag_user.user_id
         LEFT JOIN company_tag ON FIND_IN_SET(company_tag.tag_id, company_tag_user.tag_ids) > 0
         LEFT JOIN fs_user_company_user ON fs_user_company_user.user_id = fs_user.user_id
+        LEFT JOIN company_user ON company_user.user_id = fs_user_company_user.company_user_id
+--         LEFT JOIN (
+--         SELECT
+--         fs_course_watch_log.user_id,
+--         count( DISTINCT fs_course_watch_log.video_id ) watch_course_count,
+--         count( DISTINCT fs_course_watch_log.period_id ) part_course_count
+--         FROM
+--         fs_course_watch_log
+--         GROUP BY
+--         fs_course_watch_log.user_id
+--         ) fs_course_watch_log ON fs_course_watch_log.user_id = fs_user.user_id
         LEFT JOIN company_user ON company_user.user_id = fs_user.company_user_id
         where fs_user.is_del = 0
         <if test="userId != null and userId!= 0 ">
@@ -1418,6 +1431,9 @@
                     #{videoId}
                 </foreach>
             </if>
+            <if test="companyId != null">
+                AND flog.company_id = #{companyId}
+            </if>
         </where>
         GROUP BY
         flog.video_id
@@ -1462,7 +1478,9 @@
                     #{videoId}
                 </foreach>
             </if>
-
+            <if test="companyId != null">
+                AND fs_course_answer_logs.company_id = #{companyId}
+            </if>
         </where>
         GROUP BY
         fs_course_answer_logs.video_id
@@ -1582,6 +1600,9 @@
                     #{videoId}
                 </foreach>
             </if>
+            <if test="companyId != null">
+                AND fwl.company_id = #{companyId}
+            </if>
         </where>
         GROUP BY
         fwl.video_id
@@ -1667,6 +1688,7 @@
             fwl.period_id, fwl.video_id, fwl.company_user_id, fwl.company_id
         FROM
             fs_course_watch_log fwl
+
         WHERE
             fwl.send_type = 1
         GROUP BY
@@ -1765,6 +1787,7 @@
             and company_user_id = #{companyUserId}
         </if>
     </select>
+
     <select id="countUserCourse2" resultType="java.util.Map">
         SELECT
         (
@@ -1775,29 +1798,29 @@
         LEFT JOIN fs_user on fs_user.user_id = l.user_id
         LEFT JOIN company_user ON l.company_user_id = company_user.user_id
         where
-            l.log_type != 3 and send_type = 1 AND fs_user.is_del = 0 AND fs_user.`status` = 1
-            <if test="userId != null and userId != 0 ">
-                and (l.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
-            </if>
-            <if test="userId != null and userId == 0 ">
-                and l.company_id = #{companyId}
-            </if>
-            <if test="periodId != null and periodId != ''">
-                AND l.period_id = #{periodId}
-            </if>
-            <if test="videoId != null and videoId != ''">
-                AND l.video_id = #{videoId}
-            </if>
-            <if test="startTime != null and startTime !='' ">
-                and l.create_time &gt;= #{startTime}
-            </if>
-            <if test="endTime != null and endTime != ''">
-                and l.create_time &lt;= #{endTime}
-            </if>
-            -- 单独通过销售id查询
-            <if test="companyUserId != null and companyUserId != ''">
-                AND l.company_user_id = #{companyUserId}
-            </if>
+        l.log_type != 3 and send_type = 1
+        <if test="userId != null and userId != 0 ">
+            and (l.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
+        </if>
+        <if test="userId != null and userId == 0 ">
+            and l.company_id = #{companyId}
+        </if>
+        <if test="periodId != null and periodId != ''">
+            AND l.period_id = #{periodId}
+        </if>
+        <if test="videoId != null and videoId != ''">
+            AND l.video_id = #{videoId}
+        </if>
+        <if test="startTime != null and startTime !='' ">
+            and l.create_time &gt;= #{startTime}
+        </if>
+        <if test="endTime != null and endTime != ''">
+            and l.create_time &lt;= #{endTime}
+        </if>
+        -- 单独通过销售id查询
+        <if test="companyUserId != null and companyUserId != ''">
+            AND l.company_user_id = #{companyUserId}
+        </if>
         ) as courseWatchNum,
         (
         SELECT
@@ -1807,7 +1830,7 @@
         LEFT JOIN fs_user on fs_user.user_id = l.user_id
         LEFT JOIN company_user ON l.company_user_id = company_user.user_id
         where
-        l.log_type = 2 and send_type = 1 AND fs_user.is_del = 0 AND fs_user.`status` = 1
+        l.log_type = 2 and send_type = 1
         <if test="userId != null and userId != 0 ">
             and (l.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
         </if>
@@ -1845,7 +1868,6 @@
         WHERE
         l.log_type != 3
         AND send_type = 1
-        AND fs_user.is_del = 0 AND fs_user.`status` = 1
         <if test="userId != null and userId != 0 ">
             AND l.company_user_id = #{userId}
         </if>

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

@@ -76,7 +76,7 @@ public class WxCompanyUserController extends AppBaseController {
 //            return R.error("昵称不符合标准!");
 //        }
         //获取第二个小程序配置,序号从0开始
-        final WxMaService wxService = WxMaConfiguration.getMaService(maProperties.getConfigs().get(1).getAppid());
+        final WxMaService wxService = WxMaConfiguration.getMaService(param.getAppId());
         try {
             WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
             this.logger.info(session.getSessionKey());

+ 1 - 2
fs-user-app/src/main/java/com/fs/app/controller/WxPayController.java

@@ -112,8 +112,7 @@ public class WxPayController {
     }
 
     @PostMapping( "/test")
-    public R test() throws Exception {
-        WxSendRedPacketParam param  = new WxSendRedPacketParam();
+    public R test(@RequestBody WxSendRedPacketParam param) throws Exception {
         storePaymentService.sendRedPacketTest(param);
         return R.ok();
     }

+ 2 - 0
fs-user-app/src/main/java/com/fs/app/param/LoginMaWxParam.java

@@ -55,4 +55,6 @@ public class LoginMaWxParam implements Serializable {
     @ApiModelProperty(value = "小程序授权类型")
     private Integer authType;
 
+    private String appId;
+
 }