Browse Source

refactor(backend): 首页能量沙盘解锁改判任一维度能量值>0

hasFamilySelfCheck 从仅五维自检记录放宽为 family 内任一 five_dimension_score 维度>0,使做过测评/上传报告/完成任务即可解锁沙盘

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
liaoxg 1 month ago
parent
commit
a06074cdcf

+ 10 - 8
cfc-backend/src/main/java/com/etotem/cfc/service/UnlockGateService.java

@@ -36,6 +36,9 @@ public class UnlockGateService {
     @Resource
     private FiveDimensionSelfCheckMapper selfCheckMapper;
 
+    @Resource
+    private FiveDimensionScoreMapper fiveDimensionScoreMapper;
+
     @Resource
     private MicroActionRecordMapper microActionRecordMapper;
 
@@ -142,17 +145,16 @@ public class UnlockGateService {
     }
 
     /**
-     * 家庭级判据:family 内任一成员做过五维自检(首页能量沙盘解锁条件,书稿"测量先行")
-     * 不依赖 unlock_gates 种子配置,直接查 five_dimension_self_checks
+     * 家庭级判据:family 内任一维度能量值有值(>0)即解锁首页能量沙盘。
+     * 放宽自改进前的"须做完五维自检":做过任一测评/上传报告/完成任务,只要任一经落库为
+     * five_dimension_score 的能量维度 >0,即可展示沙盘。
      */
     public boolean hasFamilySelfCheck(Long familyId) {
         if (familyId == null) return false;
-        List<User> familyUsers = userMapper.selectList(
-                new LambdaQueryWrapper<User>().eq(User::getFamilyId, familyId));
-        if (familyUsers.isEmpty()) return false;
-        List<Long> userIds = familyUsers.stream().map(User::getId).collect(Collectors.toList());
-        long count = selfCheckMapper.selectCount(
-                new LambdaQueryWrapper<FiveDimensionSelfCheck>().in(FiveDimensionSelfCheck::getUserId, userIds));
+        long count = fiveDimensionScoreMapper.selectCount(
+                new LambdaQueryWrapper<FiveDimensionScore>()
+                        .eq(FiveDimensionScore::getFamilyId, familyId)
+                        .gt(FiveDimensionScore::getScore, 0));
         return count >= 1;
     }