|
|
@@ -770,11 +770,9 @@ public List<Task> getTodayTasks(Long memberId, String dimensionCode) {
|
|
|
return buildIdempotentCompleteResult(task, memberId);
|
|
|
}
|
|
|
|
|
|
- // TC-C-02-E:超期任务提交必须被拒(deadline 守卫)——截止时间已过则不允许完成、不发奖。
|
|
|
- // 不修改任务、不写积分流水,直接抛异常由上游转错误提示(杜绝"迟到扣分"式静默完成)。
|
|
|
- if (task.getDeadline() != null && task.getDeadline().before(new Date())) {
|
|
|
- throw new IllegalArgumentException("任务已过截止时间,无法提交完成");
|
|
|
- }
|
|
|
+ // TC-C-02-E 修订(2026-11-16 产品拍板:过期任务可打卡但零奖励):
|
|
|
+ // 不再在此硬拦截——超期任务允许完成(状态置 completed、连续打卡照常),奖励是否发放由
|
|
|
+ // awardTaskCompletionRewards 按 isOverdue 统一裁剪(直接完成与审核通过两条路径一致)。
|
|
|
|
|
|
// TASK-SYS-248: 前置任务校验——前置未完成则拒绝
|
|
|
if (task.getPrerequisiteTaskId() != null) {
|
|
|
@@ -840,6 +838,7 @@ public List<Task> getTodayTasks(Long memberId, String dimensionCode) {
|
|
|
result.put("pointsEarned", pointsEarned);
|
|
|
result.put("newBalance", child != null ? child.getTotalPoints() : 0);
|
|
|
result.put("needReview", false);
|
|
|
+ result.put("overdue", isOverdue(task, now));
|
|
|
try {
|
|
|
com.etotem.cfc.entity.TaskReminderConfig cfg = taskReminderConfigService.loadAllConfigs().get(task.getExecutorId());
|
|
|
if (cfg != null && Integer.valueOf(1).equals(cfg.getCompletionPraiseEnabled())) {
|
|
|
@@ -1209,6 +1208,13 @@ public List<Task> getTodayTasks(Long memberId, String dimensionCode) {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+ // 2026-11-16 产品修订:任务超期(截止后超过宽限期)允许打卡完成,但零奖励——
|
|
|
+ // 不发积分/能量/CF/里程碑;仍置 completed 并更新连续打卡。直接完成与审核通过均经此路径。
|
|
|
+ if (isOverdue(task, completionTime)) {
|
|
|
+ completeTaskWithoutRewards(task, child, completionTime);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
String bonusRuleJson = task.getBonusRule();
|
|
|
if (bonusRuleJson != null && !bonusRuleJson.isEmpty()) {
|
|
|
pointsEarned = calculatePointsWithBonusRule(task, completionTime, isEarly, isLateGrace, child);
|
|
|
@@ -1225,20 +1231,7 @@ public List<Task> getTodayTasks(Long memberId, String dimensionCode) {
|
|
|
|
|
|
child.setTotalPoints(child.getTotalPoints() + pointsEarned);
|
|
|
|
|
|
- Date lastTaskDate = child.getLastTaskDate();
|
|
|
- Date today = new Date();
|
|
|
- Calendar cal = Calendar.getInstance();
|
|
|
- cal.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
- Date yesterday = cal.getTime();
|
|
|
-
|
|
|
- if (lastTaskDate == null || lastTaskDate.before(yesterday)) {
|
|
|
- child.setStreakDays(1);
|
|
|
- } else if (!isSameDay(lastTaskDate, today)) {
|
|
|
- child.setStreakDays(child.getStreakDays() + 1);
|
|
|
- }
|
|
|
- child.setLastTaskDate(today);
|
|
|
- child.setUpdatedAt(new Date());
|
|
|
- familyMemberMapper.updateById(child);
|
|
|
+ updateStreakAfterCompletion(child);
|
|
|
|
|
|
int milestoneReward = streakService.checkAndAwardMilestone(memberId, child.getStreakDays());
|
|
|
if (milestoneReward > 0) {
|
|
|
@@ -1307,6 +1300,42 @@ public List<Task> getTodayTasks(Long memberId, String dimensionCode) {
|
|
|
return pointsEarned;
|
|
|
}
|
|
|
|
|
|
+ /** 2026-11-16 产品修订:任务超期判定——截止时间已过且超过宽限期(LATE_GRACE_MINUTES)视为超期 */
|
|
|
+ private boolean isOverdue(Task task, Date completionTime) {
|
|
|
+ if (task.getDeadline() == null) return false;
|
|
|
+ if (completionTime.before(task.getDeadline())) return false;
|
|
|
+ long diffMinutes = (completionTime.getTime() - task.getDeadline().getTime()) / (1000 * 60);
|
|
|
+ return diffMinutes > LATE_GRACE_MINUTES;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 超期完成:允许打卡但零奖励——置 completed、更新连续打卡、解锁后置任务,不发任何奖励 */
|
|
|
+ private void completeTaskWithoutRewards(Task task, FamilyMember child, Date completionTime) {
|
|
|
+ task.setStatus("completed");
|
|
|
+ task.setCompletedAt(completionTime);
|
|
|
+ task.setUpdatedAt(new Date());
|
|
|
+ taskMapper.updateById(task);
|
|
|
+ updateStreakAfterCompletion(child);
|
|
|
+ unlockPrerequisiteTasks(task.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 打卡成功后更新连续打卡(发奖与超期零奖励共用) */
|
|
|
+ private void updateStreakAfterCompletion(FamilyMember child) {
|
|
|
+ Date lastTaskDate = child.getLastTaskDate();
|
|
|
+ Date today = new Date();
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+ cal.add(Calendar.DAY_OF_MONTH, -1);
|
|
|
+ Date yesterday = cal.getTime();
|
|
|
+
|
|
|
+ if (lastTaskDate == null || lastTaskDate.before(yesterday)) {
|
|
|
+ child.setStreakDays(1);
|
|
|
+ } else if (!isSameDay(lastTaskDate, today)) {
|
|
|
+ child.setStreakDays(child.getStreakDays() + 1);
|
|
|
+ }
|
|
|
+ child.setLastTaskDate(today);
|
|
|
+ child.setUpdatedAt(new Date());
|
|
|
+ familyMemberMapper.updateById(child);
|
|
|
+ }
|
|
|
+
|
|
|
private void recordTaskExecution(Task task, Long memberId, Date now, String content, String contentType) {
|
|
|
Long taskId = task.getId();
|
|
|
try {
|