|
|
@@ -36,8 +36,8 @@ import shop.alien.util.common.safe.TextModerationUtil;
|
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.time.Duration;
|
|
|
-import java.time.LocalDateTime;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.ZoneId;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -727,51 +727,51 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
int passedCount = passedAppealList.size();
|
|
|
// 列表已按 updated_time 降序,第一条即为最新通过记录
|
|
|
StoreCommentAppeal latestPassedAppeal = passedAppealList.isEmpty() ? null : passedAppealList.get(0);
|
|
|
- long countdownMillis = 0l;
|
|
|
+ String countdown = "0天";
|
|
|
+ long remainingDays = 0L;
|
|
|
if (passedCount > 3) {
|
|
|
- countdownMillis = calculateAppealPassCooldownCountdown(latestPassedAppeal);
|
|
|
+ remainingDays = resolveAppealPassCooldownRemainingDays(latestPassedAppeal);
|
|
|
+ countdown = calculateAppealPassCooldownCountdown(remainingDays);
|
|
|
}
|
|
|
|
|
|
- boolean canRate = passedCount <= 3 || countdownMillis <= 0;
|
|
|
+ boolean canRate = passedCount <= 3 || remainingDays <= 0;
|
|
|
resultMap.put("canRate", canRate);
|
|
|
resultMap.put("passedCount", passedCount);
|
|
|
resultMap.put("latestPassedAppeal", latestPassedAppeal);
|
|
|
- resultMap.put("countdown", formatCountdownToDayHour(countdownMillis));
|
|
|
+ resultMap.put("countdown", countdown);
|
|
|
|
|
|
log.info("StoreCommentAppealServiceImpl.canRate result, userId={}, canRate={}, passedCount={}, countdown={}",
|
|
|
- userId, canRate, passedCount, formatCountdownToDayHour(countdownMillis));
|
|
|
+ userId, canRate, passedCount, countdown);
|
|
|
return resultMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 将毫秒倒计时转换为「X天X小时」格式
|
|
|
+ * 计算申诉通过后的10天冷却倒计时(仅天数)
|
|
|
*/
|
|
|
- private String formatCountdownToDayHour(long countdownMillis) {
|
|
|
- if (countdownMillis <= 0) {
|
|
|
- return "0天0小时";
|
|
|
- }
|
|
|
- long totalHours = countdownMillis / (1000 * 60 * 60);
|
|
|
- long days = totalHours / 24;
|
|
|
- long hours = totalHours % 24;
|
|
|
- return days + "天" + hours + "小时";
|
|
|
+ private String calculateAppealPassCooldownCountdown(long remainingDays) {
|
|
|
+ String countdown = remainingDays + "天";
|
|
|
+ log.debug("calculateAppealPassCooldownCountdown, remainingDays={}, countdown={}", remainingDays, countdown);
|
|
|
+ return countdown;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 计算申诉通过后的10天冷却倒计时(毫秒)
|
|
|
- * 以申诉更新时间(通过时间)为起点,10天内返回剩余毫秒数,否则返回0
|
|
|
+ * 解析申诉通过后10天冷却剩余天数(按自然日计算,不含小时)
|
|
|
+ * 以申诉更新日期(通过日期)为起点,满10个自然日后冷却结束
|
|
|
*/
|
|
|
- private long calculateAppealPassCooldownCountdown(StoreCommentAppeal latestPassedAppeal) {
|
|
|
+ private long resolveAppealPassCooldownRemainingDays(StoreCommentAppeal latestPassedAppeal) {
|
|
|
if (latestPassedAppeal == null || latestPassedAppeal.getUpdatedTime() == null) {
|
|
|
return 0L;
|
|
|
}
|
|
|
- LocalDateTime passTime = latestPassedAppeal.getUpdatedTime().toInstant()
|
|
|
- .atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
- LocalDateTime cooldownEndTime = passTime.plusDays(10);
|
|
|
- LocalDateTime now = LocalDateTime.now();
|
|
|
- if (now.isBefore(cooldownEndTime)) {
|
|
|
- return Duration.between(now, cooldownEndTime).toMillis();
|
|
|
+ LocalDate passDate = latestPassedAppeal.getUpdatedTime().toInstant()
|
|
|
+ .atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
+ LocalDate cooldownEndDate = passDate.plusDays(10);
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ if (!today.isBefore(cooldownEndDate)) {
|
|
|
+ log.debug("resolveAppealPassCooldownRemainingDays: 冷却已结束, passDate={}, cooldownEndDate={}",
|
|
|
+ passDate, cooldownEndDate);
|
|
|
+ return 0L;
|
|
|
}
|
|
|
- return 0L;
|
|
|
+ return ChronoUnit.DAYS.between(today, cooldownEndDate);
|
|
|
}
|
|
|
|
|
|
/**
|