|
|
@@ -1,7 +1,6 @@
|
|
|
package com.zhentao.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.zhentao.entity.Matchmaker;
|
|
|
import com.zhentao.entity.MatchmakerCheckin;
|
|
|
import com.zhentao.mapper.MatchmakerCheckinMapper;
|
|
|
import com.zhentao.service.MatchmakerCheckinService;
|
|
|
@@ -94,52 +93,80 @@ public class MatchmakerCheckinServiceImpl extends ServiceImpl<MatchmakerCheckinM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean isCheckedIn(Long userId) {
|
|
|
- // 根据 userId 查询 matchmaker 信息
|
|
|
- MatchmakerVO matchmaker = matchmakerService.getMatchmakerByUserId(userId);
|
|
|
- if (matchmaker == null) {
|
|
|
- return false;
|
|
|
+ public boolean isCheckedIn(Long idParam) {
|
|
|
+ // idParam 可能是 userId 或 matchmakerId,需要兼容处理
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+
|
|
|
+ // 先尝试直接用 idParam 作为 matchmakerId 查询
|
|
|
+ MatchmakerCheckin checkin = matchmakerCheckinMapper.selectByMakerIdAndDate(idParam, today);
|
|
|
+ if (checkin != null) {
|
|
|
+ return true;
|
|
|
}
|
|
|
- Integer matchmakerId = matchmaker.getMatchmakerId();
|
|
|
|
|
|
- LocalDate today = LocalDate.now();
|
|
|
- MatchmakerCheckin checkin = matchmakerCheckinMapper.selectByMakerIdAndDate(matchmakerId.longValue(), today);
|
|
|
- return checkin != null;
|
|
|
+ // 如果没找到,尝试把 idParam 当作 userId 来查询 matchmaker
|
|
|
+ MatchmakerVO matchmaker = matchmakerService.getMatchmakerByUserId(idParam);
|
|
|
+ if (matchmaker != null && matchmaker.getMatchmakerId() != null) {
|
|
|
+ Long matchmakerId = matchmaker.getMatchmakerId().longValue();
|
|
|
+ checkin = matchmakerCheckinMapper.selectByMakerIdAndDate(matchmakerId, today);
|
|
|
+ return checkin != null;
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Integer getTotalDays(Long userId) {
|
|
|
- // 根据 userId 查询 matchmaker 信息
|
|
|
- MatchmakerVO matchmaker = matchmakerService.getMatchmakerByUserId(userId);
|
|
|
- if (matchmaker == null) {
|
|
|
- return 0;
|
|
|
+ public Integer getTotalDays(Long idParam) {
|
|
|
+ // idParam 可能是 userId 或 matchmakerId,需要兼容处理
|
|
|
+ Long matchmakerId = idParam;
|
|
|
+
|
|
|
+ // 先尝试直接用 idParam 作为 matchmakerId 查询
|
|
|
+ Integer totalDays = matchmakerCheckinMapper.selectTotalDaysByMakerId(idParam);
|
|
|
+ if (totalDays != null && totalDays > 0) {
|
|
|
+ return totalDays;
|
|
|
}
|
|
|
- Integer matchmakerId = matchmaker.getMatchmakerId();
|
|
|
|
|
|
- Integer totalDays = matchmakerCheckinMapper.selectTotalDaysByMakerId(matchmakerId.longValue());
|
|
|
- return totalDays != null ? totalDays : 0;
|
|
|
+ // 如果没找到,尝试把 idParam 当作 userId 来查询 matchmaker
|
|
|
+ MatchmakerVO matchmaker = matchmakerService.getMatchmakerByUserId(idParam);
|
|
|
+ if (matchmaker != null && matchmaker.getMatchmakerId() != null) {
|
|
|
+ matchmakerId = matchmaker.getMatchmakerId().longValue();
|
|
|
+ totalDays = matchmakerCheckinMapper.selectTotalDaysByMakerId(matchmakerId);
|
|
|
+ return totalDays != null ? totalDays : 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Integer getContinuousDays(Long userId) {
|
|
|
- // 根据 userId 查询 matchmaker 信息
|
|
|
- MatchmakerVO matchmaker = matchmakerService.getMatchmakerByUserId(userId);
|
|
|
- if (matchmaker == null) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
- Integer matchmakerId = matchmaker.getMatchmakerId();
|
|
|
+ public Integer getContinuousDays(Long idParam) {
|
|
|
+ // idParam 可能是 userId 或 matchmakerId,需要兼容处理
|
|
|
+ Long matchmakerId = idParam;
|
|
|
|
|
|
- MatchmakerCheckin lastCheckin = matchmakerCheckinMapper.selectLastByMakerId(matchmakerId.longValue());
|
|
|
+ // 先尝试直接用 idParam 作为 matchmakerId 查询
|
|
|
+ MatchmakerCheckin lastCheckin = matchmakerCheckinMapper.selectLastByMakerId(idParam);
|
|
|
if (lastCheckin != null) {
|
|
|
- // 检查是否是连续签到(今天或昨天)
|
|
|
LocalDate today = LocalDate.now();
|
|
|
LocalDate lastDate = lastCheckin.getCheckinDate();
|
|
|
long daysBetween = ChronoUnit.DAYS.between(lastDate, today);
|
|
|
-
|
|
|
if (daysBetween <= 1) {
|
|
|
return lastCheckin.getContinuousDays();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 如果没找到,尝试把 idParam 当作 userId 来查询 matchmaker
|
|
|
+ MatchmakerVO matchmaker = matchmakerService.getMatchmakerByUserId(idParam);
|
|
|
+ if (matchmaker != null && matchmaker.getMatchmakerId() != null) {
|
|
|
+ matchmakerId = matchmaker.getMatchmakerId().longValue();
|
|
|
+ lastCheckin = matchmakerCheckinMapper.selectLastByMakerId(matchmakerId);
|
|
|
+ if (lastCheckin != null) {
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ LocalDate lastDate = lastCheckin.getCheckinDate();
|
|
|
+ long daysBetween = ChronoUnit.DAYS.between(lastDate, today);
|
|
|
+ if (daysBetween <= 1) {
|
|
|
+ return lastCheckin.getContinuousDays();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return 0;
|
|
|
}
|
|
|
}
|