Explorar el Código

Merge remote-tracking branch 'origin/master'

ct hace 6 días
padre
commit
38c2ad2ee1

+ 1 - 1
fs-admin/src/main/java/com/fs/course/controller/FsCourseTrafficLogController.java

@@ -154,7 +154,7 @@ public class FsCourseTrafficLogController extends BaseController
     public R rechargeTraffic(@RequestBody InternetTrafficParam internetTrafficParam) {
 
         fsCourseTrafficLogService.updateTrafficStatus(internetTrafficParam);
-        return R.ok().put("data", null);  // 返回计算结果
+        return R.ok();  // 返回计算结果
     }
 
 }

+ 22 - 0
fs-admin/src/main/java/com/fs/task/trafficlog/TrafficlogTask.java

@@ -0,0 +1,22 @@
+package com.fs.task.trafficlog;
+
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.fs.course.service.IFsCourseTrafficLogService;
+import com.fs.crm.service.ICrmCustomerService;
+import com.fs.system.domain.SysConfig;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service("trafficlogTask")
+@Slf4j
+public class TrafficlogTask {
+    @Autowired
+    private IFsCourseTrafficLogService fsCourseTrafficLogService;
+    /**
+     * 红包流量统计
+     */
+    public void sumTrafficlog(){
+        fsCourseTrafficLogService.sumTrafficlog();
+    }
+}

+ 4 - 3
fs-admin/src/test/java/com/fs/course/controller/AdHtmlClickLogServiceImplTest.java

@@ -21,8 +21,9 @@ public class AdHtmlClickLogServiceImplTest {
 
     @Test
     public void test(){
-        InternetTrafficParam internetTrafficParam = new InternetTrafficParam();
-        internetTrafficParam.setAccount("1");
-        fsCourseTrafficLogService.updateTrafficStatus(internetTrafficParam);
+//        InternetTrafficParam internetTrafficParam = new InternetTrafficParam();
+//        internetTrafficParam.setAccount("1");
+//        fsCourseTrafficLogService.updateTrafficStatus(internetTrafficParam);
+        fsCourseTrafficLogService.sumTrafficlog();
     }
 }

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

@@ -1,5 +1,6 @@
 package com.fs.course.mapper;
 
+import java.util.Date;
 import java.util.List;
 import com.fs.course.domain.FsCourseTrafficLog;
 import com.fs.course.param.FsCourseTrafficLogParam;
@@ -103,19 +104,19 @@ public interface FsCourseTrafficLogMapper
     // 按创建时间查询未使用的流量记录(用于分批更新)
     @Select("<script>" +
             "SELECT COALESCE(sum(internet_traffic), 0) FROM fs_course_traffic_log " +
-            "WHERE status = 0" +
+            "WHERE status &lt;&gt;1" +
             "<if test='companyId != null'>AND company_id = #{companyId}</if> " +
             "</script>")
     Long findRecordsNum(@Param("companyId") Long companyId);
 
     // 批量更新状态
     @Update("<script>" +
-            "UPDATE fs_course_traffic_log SET status = 1 WHERE log_id IN " +
+            "UPDATE fs_course_traffic_log SET status = #{status} WHERE log_id IN " +
             "<foreach item='id' collection='ids' open='(' separator=',' close=')'>" +
             "#{id}" +
             "</foreach>" +
             "</script>")
-    int updateStatusByIds(@Param("ids") List<Long> ids);
+    int updateStatusByIds(@Param("ids") List<Long> ids,@Param("status")Integer status);
 
     @Select("<script>" +
             "SELECT internet_traffic FROM fs_course_traffic_log WHERE log_id IN " +
@@ -128,7 +129,7 @@ public interface FsCourseTrafficLogMapper
     // 新增带流量字段的记录查询(按公司ID)
     @Select("<script>" +
             "SELECT log_id, internet_traffic FROM fs_course_traffic_log " +
-            "WHERE status = 0" +
+            "WHERE status &lt;&gt;1" +
             "<if test='companyId != null'>AND company_id = #{companyId}</if> " +
             "ORDER BY create_time ASC " +
             "LIMIT #{offset}, #{pageSize}" +
@@ -137,6 +138,17 @@ public interface FsCourseTrafficLogMapper
             @Param("companyId") Long companyId,
             @Param("offset") int offset,
             @Param("pageSize") int pageSize);
+    @Select("<script>" +
+            "SELECT COALESCE(sum(internet_traffic), 0) FROM fs_course_traffic_log " +
+            "WHERE status =0" +
+            "<if test='createTime != null'>AND create_time &lt;= #{createTime}</if> " +
+            "</script>")
+    Long findRecordsNumBYD( @Param("createTime") Date createTime);
 
-
+    @Select("<script>" +
+            "SELECT log_id FROM fs_course_traffic_log " +
+            "WHERE status =0" +
+            "<if test='createTime != null'>AND create_time &lt;= #{createTime}</if> " +
+            "</script>")
+    List<Long> findRecordsNumByIds( @Param("createTime") Date createTime);
 }

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

@@ -67,4 +67,9 @@ public interface IFsCourseTrafficLogService
     List<FsCourseTrafficLogListVO> selectTrafficNew(FsCourseTrafficLogParam param);
 
     void updateTrafficStatus(InternetTrafficParam internetTrafficParam);
+
+    /**
+     * 定时统计流量总数
+     */
+    void sumTrafficlog();
 }

+ 96 - 60
fs-service-system/src/main/java/com/fs/course/service/impl/FsCourseTrafficLogServiceImpl.java

@@ -2,6 +2,7 @@ package com.fs.course.service.impl;
 
 import java.util.*;
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
@@ -15,6 +16,7 @@ import com.fs.store.service.cache.IFsUserCourseCacheService;
 import com.fs.system.domain.SysConfig;
 import com.fs.system.service.ISysConfigService;
 import com.hc.openapi.tool.util.StringUtils;
+import org.apache.http.util.Asserts;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.fs.course.mapper.FsCourseTrafficLogMapper;
@@ -98,17 +100,7 @@ public class FsCourseTrafficLogServiceImpl implements IFsCourseTrafficLogService
     public int insertFsCourseTrafficLog(FsCourseTrafficLog fsCourseTrafficLog)
     {
         fsCourseTrafficLog.setCreateTime(DateUtils.getNowDate());
-        SysConfig sysConfig = iSysConfigService.selectConfigByConfigKey("redPacket.Traffic.config");
-        if (ObjectUtils.isEmpty(sysConfig)){
-            sysConfig = new SysConfig();
-            sysConfig.setConfigKey("redPacket.Traffic.config");
-            sysConfig.setConfigName("红包流量配置");
-            sysConfig.setConfigValue("-"+fsCourseTrafficLog.getInternetTraffic());
-            iSysConfigService.insertConfig(sysConfig);
-        }else {
-            sysConfig.setConfigValue(String.valueOf((Long.parseLong(sysConfig.getConfigValue())-fsCourseTrafficLog.getInternetTraffic())));
-            iSysConfigService.updateConfig(sysConfig);
-        }
+
         return fsCourseTrafficLogMapper.insertFsCourseTrafficLog(fsCourseTrafficLog);
     }
 
@@ -190,30 +182,36 @@ public class FsCourseTrafficLogServiceImpl implements IFsCourseTrafficLogService
 
         // 计算充值对应的流量
         double account = Double.parseDouble(internetTrafficParam.getAccount());
-        double pricePerGB = 0.05;
-        double trafficGB = account / pricePerGB;
+
+        SysConfig config = iSysConfigService.selectConfigByConfigKey("statis.config");
+        JSONObject jsonObject = JSONObject.parseObject(config.getConfigValue());
+        float trafficPrice = jsonObject.getFloatValue("trafficPrice");
+
+        double trafficGB = account / trafficPrice;
         long trafficKB = (long) (trafficGB * 1024 * 1024);
 
         System.out.println("充值金额:" + account + " 元,对应可用流量:" + trafficKB + " KB");
 
         long updatedTrafficKB = 0L;
-        int pageSize = 3;  // 每次查询1000条
-        int pageNum = 0;  // 分页页码
-        int loopCount = 0; // 查询次数
-        int maxLoop = 20;  // 最大循环次数
+        int pageSize = 1000;  // 每次查询1000条
+        int pageNum = 0;      // 分页页码
+        int loopCount = 0;    // 查询次数
+        int maxLoop = 20;     // 最大循环次数
 
-        List<Long> idsToUpdate = new ArrayList<>();
-        Set<Long> processedIds = new HashSet<>();  // 用于去重
-        long remainingTrafficKB = trafficKB;  // 还需补充的流量
-        long totalInternetTrafficRemaining = 0L;  // 记录未处理的流量总和
+        List<Long> idsToUpdate = new ArrayList<>();       // 用于更新状态为1的ID
+        Set<Long> processedIds = new HashSet<>();         // 用于去重
+        long remainingTrafficKB = trafficKB;              // 还需补充的流量
+        long totalInternetTrafficRemaining = 0L;          // 记录未处理的流量总和
 
+        // 第一阶段:处理需要用于充值的记录
         while (updatedTrafficKB < trafficKB && loopCount < maxLoop) {
             loopCount++;
-            int offset = pageNum * pageSize; // 计算当前查询的偏移量
+            int offset = pageNum * pageSize;
 
             // 查询当前分页的数据
             List<TrafficRecord> trafficRecords =
-                    fsCourseTrafficLogMapper.findUnusedRecordsWithTraffic(internetTrafficParam.getCompanyId(), offset, pageSize);
+                    fsCourseTrafficLogMapper.findUnusedRecordsWithTraffic(
+                            internetTrafficParam.getCompanyId(), offset, pageSize);
 
             if (trafficRecords.isEmpty()) {
                 break;
@@ -221,26 +219,22 @@ public class FsCourseTrafficLogServiceImpl implements IFsCourseTrafficLogService
 
             // 处理当前批次的数据
             for (TrafficRecord record : trafficRecords) {
-                if (updatedTrafficKB >= trafficKB) break;  // 达到目标流量则退出
-
                 Long logId = record.getLogId();
+
                 if (processedIds.contains(logId)) {
-                    continue; // 如果记录已处理过,则跳过
+                    continue;
                 }
 
-                updatedTrafficKB += record.getInternetTraffic();  // 累加已使用的流量
-                idsToUpdate.add(logId);  // 记录需要更新的ID
-                processedIds.add(logId);  // 标记为已处理
-
-                remainingTrafficKB = Math.max(0, trafficKB - updatedTrafficKB);  // 更新剩余流量
-                totalInternetTrafficRemaining += record.getInternetTraffic();  // 累计未处理的流量
-                // 如果剩余流量不足,则停止处理
-                if (remainingTrafficKB == 0) {
-                    break;
+                if (updatedTrafficKB < trafficKB) {
+                    updatedTrafficKB += record.getInternetTraffic();
+                    idsToUpdate.add(logId);
+                    remainingTrafficKB = Math.max(0, trafficKB - updatedTrafficKB);
                 }
+
+                processedIds.add(logId);
+                totalInternetTrafficRemaining += record.getInternetTraffic();
             }
 
-            // 模拟数据库压力,休眠一段时间
             try {
                 Thread.sleep(100);
             } catch (InterruptedException e) {
@@ -248,55 +242,97 @@ public class FsCourseTrafficLogServiceImpl implements IFsCourseTrafficLogService
                 break;
             }
 
-            pageNum++;  // 翻到下一页
+            pageNum++;
+        }
+
+        // 第二阶段:将所有未处理的记录状态改为3
+        List<Long> allUnprocessedIds = new ArrayList<>();
+        pageNum = 0;  // 重置分页
+        boolean hasMore = true;
+
+        while (hasMore && loopCount < maxLoop * 2) {  // 扩大循环次数限制
+            loopCount++;
+            int offset = pageNum * pageSize;
+
+            List<TrafficRecord> allRecords =
+                    fsCourseTrafficLogMapper.findUnusedRecordsWithTraffic(
+                            internetTrafficParam.getCompanyId(), offset, pageSize);
+
+            if (allRecords.isEmpty()) {
+                hasMore = false;
+                continue;
+            }
+
+            for (TrafficRecord record : allRecords) {
+                Long logId = record.getLogId();
+                if (!idsToUpdate.contains(logId)) {  // 不是已处理的记录
+                    allUnprocessedIds.add(logId);
+                }
+            }
+
+            pageNum++;
         }
+
         // 更新数据库状态
         if (!idsToUpdate.isEmpty()) {
-            fsCourseTrafficLogMapper.updateStatusByIds(idsToUpdate);
-            System.out.println("共更新状态记录数:" + idsToUpdate.size());
-        } else {
-            System.out.println("没有记录被更新。");
+            fsCourseTrafficLogMapper.updateStatusByIds(idsToUpdate, 1);
+            System.out.println("共更新状态为1的记录数:" + idsToUpdate.size());
         }
 
-        // 计算超出充值流量的部分
+        if (!allUnprocessedIds.isEmpty()) {
+            fsCourseTrafficLogMapper.updateStatusByIds(allUnprocessedIds, 3);
+            System.out.println("共更新状态为3的记录数:" + allUnprocessedIds.size());
+        }
+
+        // 剩余的计算和输出逻辑保持不变...
         Long count = fsCourseTrafficLogMapper.findRecordsNum(internetTrafficParam.getCompanyId());
-        long overflowTrafficKB = Math.max(0, updatedTrafficKB - trafficKB)+count;
+        long overflowTrafficKB = Math.max(0, updatedTrafficKB - trafficKB) + count;
         if (overflowTrafficKB > 0) {
             System.out.println("已使用流量超过充值流量,超出部分:" + overflowTrafficKB + " KB");
         }
 
-        // 输出未处理的流量信息
-        long remainingUnprocessedTrafficKB = totalInternetTrafficRemaining - overflowTrafficKB;
-        if (updatedTrafficKB < trafficKB) {
-            System.out.println("处理完毕,未使用完的剩余流量:" + remainingUnprocessedTrafficKB + " KB");
-        }
-
-        // 输出最终统计结果
         System.out.println("充值总流量:" + trafficKB + " KB");
         System.out.println("已使用流量:" + updatedTrafficKB + " KB");
         long finalRemainingTrafficKB = Math.max(0, trafficKB - updatedTrafficKB);
         System.out.println("最终剩余流量:" + finalRemainingTrafficKB + " KB");
+
+        // 系统配置更新逻辑保持不变...
         SysConfig sysConfig = iSysConfigService.selectConfigByConfigKey("redPacket.Traffic.config");
-        String trafficCount = null;
-        if (finalRemainingTrafficKB==0){
-            trafficCount = "-"+overflowTrafficKB;
-        }else {
-            trafficCount = String.valueOf(finalRemainingTrafficKB);
+        String trafficCount = finalRemainingTrafficKB == 0 ?
+                "-" + overflowTrafficKB : String.valueOf(finalRemainingTrafficKB);
+
+        if (ObjectUtils.isEmpty(sysConfig)) {
+            sysConfig = new SysConfig();
+            sysConfig.setConfigKey("redPacket.Traffic.config");
+            sysConfig.setConfigName("红包流量配置");
+            sysConfig.setConfigValue(trafficCount);
+            iSysConfigService.insertConfig(sysConfig);
+        } else {
+            sysConfig.setConfigValue(trafficCount);
+            iSysConfigService.updateConfig(sysConfig);
+        }
+    }
+    @Override
+    public void sumTrafficlog() {
+        SysConfig sysConfig = iSysConfigService.selectConfigByConfigKey("redPacket.Traffic.config");
+        Date date = new Date();
+        Long count = fsCourseTrafficLogMapper.findRecordsNumBYD(date);
+        List<Long> ids = fsCourseTrafficLogMapper.findRecordsNumByIds(date);
+        if (count<=0){
+            return;
         }
         if (ObjectUtils.isEmpty(sysConfig)){
             sysConfig = new SysConfig();
             sysConfig.setConfigKey("redPacket.Traffic.config");
             sysConfig.setConfigName("红包流量配置");
-            sysConfig.setConfigValue(trafficCount);
+            sysConfig.setConfigValue("-"+count);
             iSysConfigService.insertConfig(sysConfig);
         }else {
-            sysConfig.setConfigValue(trafficCount);
+            sysConfig.setConfigValue(String.valueOf((Long.parseLong(sysConfig.getConfigValue())-count)));
             iSysConfigService.updateConfig(sysConfig);
         }
+        fsCourseTrafficLogMapper.updateStatusByIds(ids,2);
     }
 
 
-
-
-
 }

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

@@ -188,6 +188,9 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 
     @Autowired
     private IFsUserWxService fsUserWxService;
+
+    @Autowired
+    private FsCourseAnswerLogsMapper courseAnswerLogsMapper;
     /**
      * 查询课堂视频
      *
@@ -742,6 +745,13 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
         if (log == null) {
             return R.error("无记录");
         }
+
+        FsCourseAnswerLogs rightLog = courseAnswerLogsMapper.selectRightLogByCourseVideo(param.getVideoId(), param.getUserId(), param.getQwUserId());
+
+        if (rightLog == null) {
+            logger.error("未答题:{}",param.getUserId());
+            return R.error("未答题");
+        }
         if (log.getRewardType() != null) {
             FsCourseRedPacketLog fsCourseRedPacketLog = redPacketLogMapper.selectUserFsCourseRedPacketLog(param.getVideoId(), param.getUserId(),param.getPeriodId());
             if(fsCourseRedPacketLog != null && fsCourseRedPacketLog.getStatus() == 1) {
@@ -824,7 +834,13 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             FsUserWx fsUserWx = fsUserWxService.selectByAppIdAndUserId(param.getAppId(),user.getUserId(),1);
             if (fsUserWx ==null){
                 packetParam.setOpenId(user.getMaOpenId());
-                handleFsUserWx(user,param.getAppId());
+                try {
+                    handleFsUserWx(user,param.getAppId());
+                } catch (Exception e){
+                    e.printStackTrace();
+                    logger.error(e.getMessage(),e);
+                }
+
             }else {
                 //查出openid并赋值
                 packetParam.setOpenId(fsUserWx.getOpenId());

+ 2 - 0
fs-service-system/src/main/java/com/fs/his/service/impl/FsUserWxServiceImpl.java

@@ -28,6 +28,8 @@ public class FsUserWxServiceImpl extends ServiceImpl<FsUserWxMapper, FsUserWx> i
                         .eq("app_id", appId)
                         .eq("fs_user_id", userId)
                         .eq("type", type)
+                        .orderByDesc("id")
+                        .last("LIMIT 1")
         );
     }
 }

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

@@ -520,41 +520,41 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
 
     private void handleFsUserWx(FsUser user,String appId,WxMaJscode2SessionResult session) {
         // 尝试更新
-        FsUserWx userWx = fsUserWxService.selectByAppIdAndUserId(appId,user.getUserId(),1);
-        if (userWx!=null && !userWx.getOpenId().equals(session.getOpenid())){
-            userWx.setOpenId(session.getOpenid());
-            fsUserWxService.updateById(userWx);
-        }else {
-            userWx = new FsUserWx();
-            userWx.setType(1);
-            userWx.setFsUserId(user.getUserId());
-            userWx.setAppId(appId);
-            userWx.setOpenId(session.getOpenid());
-            userWx.setUnionId(session.getUnionid() == null ? "" : session.getUnionid());
-            userWx.setCreateTime(new Date());
-            userWx.setUpdateTime(new Date());
-            fsUserWxService.save(userWx);
-        }
-//        boolean updated = fsUserWxService.lambdaUpdate()
-//                .eq(FsUserWx::getFsUserId, user.getUserId())
-//                .eq(FsUserWx::getAppId,appId )
-//                .eq(FsUserWx::getOpenId, session.getOpenid())
-//                .set(FsUserWx::getUnionId, session.getUnionid() == null ? "" : session.getUnionid())
-//                .set(FsUserWx::getUpdateTime, new Date())
-//                .update();
-//
-//        // 如果更新失败(记录不存在),则插入
-//        if (!updated) {
-//            FsUserWx fsUserWx = new FsUserWx();
-//            fsUserWx.setType(1);
-//            fsUserWx.setFsUserId(user.getUserId());
-//            fsUserWx.setAppId(appId);
-//            fsUserWx.setOpenId(session.getOpenid());
-//            fsUserWx.setUnionId(session.getUnionid() == null ? "" : session.getUnionid());
-//            fsUserWx.setCreateTime(new Date());
-//            fsUserWx.setUpdateTime(new Date());
-//            fsUserWxService.save(fsUserWx);
+//        FsUserWx userWx = fsUserWxService.selectByAppIdAndUserId(appId,user.getUserId(),1);
+//        if (userWx!=null && !userWx.getOpenId().equals(session.getOpenid())){
+//            userWx.setOpenId(session.getOpenid());
+//            fsUserWxService.updateById(userWx);
+//        }else {
+//            userWx = new FsUserWx();
+//            userWx.setType(1);
+//            userWx.setFsUserId(user.getUserId());
+//            userWx.setAppId(appId);
+//            userWx.setOpenId(session.getOpenid());
+//            userWx.setUnionId(session.getUnionid() == null ? "" : session.getUnionid());
+//            userWx.setCreateTime(new Date());
+//            userWx.setUpdateTime(new Date());
+//            fsUserWxService.save(userWx);
 //        }
+        boolean updated = fsUserWxService.lambdaUpdate()
+                .eq(FsUserWx::getFsUserId, user.getUserId())
+                .eq(FsUserWx::getAppId,appId )
+                .eq(FsUserWx::getOpenId, session.getOpenid())
+                .set(FsUserWx::getUnionId, session.getUnionid() == null ? "" : session.getUnionid())
+                .set(FsUserWx::getUpdateTime, new Date())
+                .update();
+
+        // 如果更新失败(记录不存在),则插入
+        if (!updated) {
+            FsUserWx fsUserWx = new FsUserWx();
+            fsUserWx.setType(1);
+            fsUserWx.setFsUserId(user.getUserId());
+            fsUserWx.setAppId(appId);
+            fsUserWx.setOpenId(session.getOpenid());
+            fsUserWx.setUnionId(session.getUnionid() == null ? "" : session.getUnionid());
+            fsUserWx.setCreateTime(new Date());
+            fsUserWx.setUpdateTime(new Date());
+            fsUserWxService.save(fsUserWx);
+        }
     }
 
 

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

@@ -81,13 +81,13 @@ wx:
         token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
         aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
         msgDataFormat: JSON
-      - appid: wx328c85d0437b5a66   #中康未来智慧服务
-        secret: fa00dce55bc4b6cdc1c692c0496ee2af
+      - appid: wxdbaca81abc336277   #虹恺百货店
+        secret: 31b39464bad4549b6c59f79e4e2c3f94
         token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
         aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
         msgDataFormat: JSON
-      - appid: wxdbaca81abc336277   #虹恺百货店
-        secret: 31b39464bad4549b6c59f79e4e2c3f94
+      - appid: wx77346c2440b70ecd   #中康智慧店R
+        secret: 25c900efbbc4aa70b070e3f77d3597ba
         token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
         aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
         msgDataFormat: JSON

+ 5 - 7
fs-service-system/src/main/resources/mapper/store/FsUserMapper.xml

@@ -962,13 +962,12 @@
     <select id="countTag" resultType="FsUserSummaryCountTagVO">
         SELECT
             company_tag.tag AS tagName,
-            count( fs_user.user_id ) AS number
+            count( ucu.user_id ) AS number
         FROM
-            company_tag_user
-                LEFT JOIN fs_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 ucu on ucu.user_id = fs_user.user_id
-                LEFT JOIN company_user ON ucu.company_user_id = company_user.user_id
+        fs_user_project_tag upt
+        inner join fs_user_company_user ucu on ucu.id = upt.user_company_user_id
+        inner join company_tag ON upt.tag_id = company_tag.tag_id
+        left join company_user on company_user.user_id = ucu.company_user_id
         <where>
         <if test="userId != null and userId != 0 ">
             and (ucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
@@ -976,7 +975,6 @@
         <if test="companyId != null ">
             and ucu.company_id = #{companyId}
         </if>
-           and company_tag.tag_id is not null
         </where>
         GROUP BY
             company_tag.tag_id