|
@@ -391,18 +391,19 @@ public class FamilyMemberService {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 计算成员的实际角色(effective role)
|
|
* 计算成员的实际角色(effective role)
|
|
|
- * 基于 generation:>=0 → parent, <0 → child;无 generation 则按年龄 fallback
|
|
|
|
|
|
|
+ * 优先使用年龄判定(birthday → age < childThreshold → child),
|
|
|
|
|
+ * 无生日数据时回退到 generation 判定
|
|
|
*/
|
|
*/
|
|
|
private String computeEffectiveRole(FamilyMember member) {
|
|
private String computeEffectiveRole(FamilyMember member) {
|
|
|
- // 基于 generation 计算:generation >= 0 = parent, generation < 0 = child
|
|
|
|
|
- if (member.getGeneration() != null) {
|
|
|
|
|
- return member.getGeneration() >= 0 ? "parent" : "child";
|
|
|
|
|
- }
|
|
|
|
|
- // 兼容旧数据(无 generation):按年龄 fallback
|
|
|
|
|
|
|
+ // 优先按年龄判定(生日优先于 generation)
|
|
|
if (member.getBirthday() != null) {
|
|
if (member.getBirthday() != null) {
|
|
|
int age = calculateAge(member.getBirthday());
|
|
int age = calculateAge(member.getBirthday());
|
|
|
int childThreshold = systemConfigService.getChildAgeThreshold();
|
|
int childThreshold = systemConfigService.getChildAgeThreshold();
|
|
|
- if (age < childThreshold) return "child";
|
|
|
|
|
|
|
+ return age < childThreshold ? "child" : "parent";
|
|
|
|
|
+ }
|
|
|
|
|
+ // 无生日数据:按 generation 回退(generation >= 0 = parent, < 0 = child)
|
|
|
|
|
+ if (member.getGeneration() != null) {
|
|
|
|
|
+ return member.getGeneration() >= 0 ? "parent" : "child";
|
|
|
}
|
|
}
|
|
|
return "parent";
|
|
return "parent";
|
|
|
}
|
|
}
|