|
|
@@ -326,9 +326,16 @@ public List<Task> getTodayTasks(Long memberId, String dimensionCode) {
|
|
|
|
|
|
LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<Task>()
|
|
|
.eq(Task::getFamilyMemberId, memberId)
|
|
|
- .ge(Task::getDeadline, startOfDay)
|
|
|
- .lt(Task::getDeadline, endOfDay)
|
|
|
.in(Task::getStatus, Arrays.asList("pending", "completed", "locked", "pending_review"))
|
|
|
+ .and(w -> w
|
|
|
+ // 普通任务:按 deadline 判断今日
|
|
|
+ .and(w2 -> w2.isNotNull(Task::getDeadline)
|
|
|
+ .ge(Task::getDeadline, startOfDay)
|
|
|
+ .lt(Task::getDeadline, endOfDay))
|
|
|
+ // 进度型任务:按 createdAt 判断今日(deadline 为 NULL)
|
|
|
+ .or(w3 -> w3.eq(Task::getIsDailyProgress, 1)
|
|
|
+ .ge(Task::getCreatedAt, startOfDay)
|
|
|
+ .lt(Task::getCreatedAt, endOfDay)))
|
|
|
.orderByAsc(Task::getDeadline);
|
|
|
|
|
|
if (dimensionCode != null && !dimensionCode.isEmpty()) {
|
|
|
@@ -340,6 +347,7 @@ public List<Task> getTodayTasks(Long memberId, String dimensionCode) {
|
|
|
|
|
|
SortUtil.applySort(wrapper);
|
|
|
List<Task> all = taskMapper.selectList(wrapper);
|
|
|
+ fillProgress(all, memberId);
|
|
|
return filterLockedChildren(all);
|
|
|
}
|
|
|
|
|
|
@@ -1527,6 +1535,32 @@ return 0; // 达到每日扣分上限
|
|
|
|
|
|
// ==================== 统一任务系统:成长任务迁移(原 GrowthTaskService) ====================
|
|
|
|
|
|
+ /**
|
|
|
+ * 回填进度型任务的当前进度(progress/todayDone,不入库)
|
|
|
+ */
|
|
|
+ private void fillProgress(List<Task> tasks, Long memberId) {
|
|
|
+ if (tasks == null || tasks.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (Task t : tasks) {
|
|
|
+ if (t.getIsDailyProgress() != null && t.getIsDailyProgress() == 1) {
|
|
|
+ TaskExecution exec = taskExecutionMapper.selectOne(new LambdaQueryWrapper<TaskExecution>()
|
|
|
+ .eq(TaskExecution::getTaskId, t.getId())
|
|
|
+ .eq(TaskExecution::getMemberId, memberId)
|
|
|
+ .last("LIMIT 1"));
|
|
|
+ int progress = 0;
|
|
|
+ if (exec != null && exec.getExtra() != null) {
|
|
|
+ try {
|
|
|
+ progress = JSON.parseObject(exec.getExtra()).getIntValue("progress");
|
|
|
+ } catch (Exception ignore) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ t.setProgress(progress);
|
|
|
+ t.setTodayDone("completed".equals(t.getStatus()) ? 1 : 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 统一任务系统:更新每日进度型任务的进度(原 growth_task updateProgress)
|
|
|
* 按 (userId→familyMemberId, taskKey) 找当日任务实例,累计进度,达标自动完成+发奖
|