|
@@ -4,8 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.etotem.cfc.common.Result;
|
|
import com.etotem.cfc.common.Result;
|
|
|
import com.etotem.cfc.entity.HealthMealRecord;
|
|
import com.etotem.cfc.entity.HealthMealRecord;
|
|
|
import com.etotem.cfc.entity.FoodRecommendIndex;
|
|
import com.etotem.cfc.entity.FoodRecommendIndex;
|
|
|
|
|
+import com.etotem.cfc.entity.Task;
|
|
|
|
|
+import com.etotem.cfc.entity.FamilyMember;
|
|
|
import com.etotem.cfc.mapper.HealthMealRecordMapper;
|
|
import com.etotem.cfc.mapper.HealthMealRecordMapper;
|
|
|
import com.etotem.cfc.mapper.FoodRecommendIndexMapper;
|
|
import com.etotem.cfc.mapper.FoodRecommendIndexMapper;
|
|
|
|
|
+import com.etotem.cfc.mapper.TaskMapper;
|
|
|
|
|
+import com.etotem.cfc.mapper.FamilyMemberMapper;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -17,7 +21,9 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
import com.etotem.cfc.service.PointsService;
|
|
import com.etotem.cfc.service.PointsService;
|
|
|
|
|
+import com.etotem.cfc.service.TaskService;
|
|
|
import com.etotem.cfc.util.ParamUtils;
|
|
import com.etotem.cfc.util.ParamUtils;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
@Tag(name = "饮食打卡")
|
|
@Tag(name = "饮食打卡")
|
|
|
@RestController
|
|
@RestController
|
|
@@ -230,6 +236,32 @@ public class HealthMealController {
|
|
|
record.setCreatedAt(new java.util.Date());
|
|
record.setCreatedAt(new java.util.Date());
|
|
|
healthMealRecordMapper.insert(record);
|
|
healthMealRecordMapper.insert(record);
|
|
|
|
|
|
|
|
|
|
+ // ===== 任务回写挂钩 =====
|
|
|
|
|
+ // 非补打打卡才回写任务(补打不参与任务完成逻辑)
|
|
|
|
|
+ if (!isBackfill) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (record.getTaskId() != null) {
|
|
|
|
|
+ Task linkedTask = taskMapper.selectById(record.getTaskId());
|
|
|
|
|
+ if (linkedTask != null) {
|
|
|
|
|
+ taskService.completeTask(
|
|
|
|
|
+ record.getTaskId(),
|
|
|
|
|
+ record.getMemberId(),
|
|
|
|
|
+ record.getPhotoUrls(),
|
|
|
|
|
+ record.getRemark(),
|
|
|
|
|
+ "text");
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 每日进度型任务:累计进度
|
|
|
|
|
+ com.etotem.cfc.entity.FamilyMember fm = familyMemberMapper.selectById(record.getMemberId());
|
|
|
|
|
+ if (fm != null && fm.getUserId() != null) {
|
|
|
|
|
+ taskService.updateProgress(fm.getUserId(), "DIET", 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.warn("饮食打卡任务回写失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 只有非补打才发积分
|
|
// 只有非补打才发积分
|
|
|
if (!isBackfill) {
|
|
if (!isBackfill) {
|
|
|
try {
|
|
try {
|