diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java b/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java index fdf4749..386e34e 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java @@ -21,14 +21,6 @@ import constants.ErrorConstants; import constants.TaskPointIdConstants; import dto.UserLoginDto; import enums.PointEnums; - -import java.io.IOException; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - import exception.BizException; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; @@ -41,6 +33,13 @@ import org.springframework.transaction.annotation.Transactional; import util.IdWorker; import util.JwtUtil; +import java.io.IOException; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + /** * @program: luoo_parent * @description: 积分明细 @@ -208,6 +207,14 @@ public class UserPointLogService { } } + // 对于日常任务,每天只允许完成一次,如果用户已经完成过,则直接返回,不重复添加积分 + if (Objects.equals(type, PointEnums.TASK_TYPE_DAILY.getCode())) { + // 日常任务,每天只触发一次 + if (userPointLogDao.findTodayByUserIdAndTaskPointId(userPointLog.getUserId(), userPointLog.getTaskPointId()) != null) { + return; + } + } + userPointLog.setScore(score); userPointLog.setDescription(description);