| | |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | c.valid_start as validStart, |
| | | c.valid_end as validEnd, |
| | | c.issue_time as issueTime, |
| | | c.family_card_limit as familyCardLimit, |
| | | c.card_level as cardLevel, |
| | | (select count(*) from dependent_card_apply approved |
| | | where approved.deleted = 0 |
| | | and approved.talent_card_id = a.talent_card_id |
| | |
| | | where a.id = ? and a.deleted = 0 |
| | | limit 1 |
| | | """, apply.getId()); |
| | | return rows.isEmpty() ? Map.of() : rows.get(0); |
| | | if (rows.isEmpty()) { |
| | | return Map.of(); |
| | | } |
| | | Map<String, Object> extra = new LinkedHashMap<>(rows.get(0)); |
| | | // 名额按真正生效的规则算:审核/申请侧也是这个口径。之前直接读 talent_card.family_card_limit, |
| | | // 那一列在库里基本是 0(按卡配置那条路没启用),页面就成了「1/0」。 |
| | | extra.put("familyCardLimit", familyCardLimit(string(extra.get("cardLevel")))); |
| | | return extra; |
| | | } |
| | | |
| | | /** |
| | | * 家属附属卡名额:卓越人才卡 2 个({@link #MAX_FAMILY_CARD_COUNT}),其它等级没有名额。 |
| | | * 展示与限流都用这一个口径,避免「页面显示 0、实际能绑 2 个」。 |
| | | */ |
| | | private int familyCardLimit(String cardLevel) { |
| | | return cardLevel != null && ELITE_CARD_LEVEL.equals(cardLevel.trim()) ? MAX_FAMILY_CARD_COUNT : 0; |
| | | } |
| | | |
| | | private String string(Object value) { |
| | | return value == null ? "" : String.valueOf(value).trim(); |
| | | } |
| | | |
| | | private void ensureApprovalSlot(DependentCardApply apply) { |
| | |
| | | // if (configuredLimit == null || configuredLimit <= 0) { |
| | | // throw new BusinessException(ErrorCode.CONFLICT, "该主卡未配置家属附属卡名额"); |
| | | // } |
| | | int familyCardLimit = Math.min(2, MAX_FAMILY_CARD_COUNT); |
| | | int familyCardLimit = familyCardLimit(ownerCard.getCardLevel()); |
| | | long approvedCount = mapper.selectCount( |
| | | Wrappers.<DependentCardApply>lambdaQuery() |
| | | .eq(DependentCardApply::getTalentCardId, apply.getTalentCardId()) |