release- 多次连续签到额外积分异步处理方式

release-2024-04-25
huangyw 4 days ago
parent 7406b7a97f
commit e2011afa8a

@ -220,11 +220,32 @@ public class UserPointLogService {
if (userPointLogDao.findTodayByUserIdAndTaskPointId(userPointLog.getUserId(),
userPointLog.getTaskPointId()) != null) {
return;
} else if (Objects.equals(taskPointId, TaskPointIdConstants.DAILY_SIGN)) {
// 连续3天签到
List<UserPointLog> daysByUserIdAndTaskPointId3 = userPointLogDao.findDaysByUserIdAndTaskPointId(
userPointLog.getUserId(), TaskPointIdConstants.DAILY_SIGN, 3 - 1);
if (daysByUserIdAndTaskPointId3.size() == 3 - 1) {
addByTaskDailyAndUserId(TaskPointIdConstants.DAILY_SIGN_3, userPointLog.getUserId());
}
// 连续7天签到
List<UserPointLog> daysByUserIdAndTaskPointId7 = userPointLogDao.findDaysByUserIdAndTaskPointId(
userPointLog.getUserId(), TaskPointIdConstants.DAILY_SIGN, 7 - 1);
if (daysByUserIdAndTaskPointId7.size() == 7 - 1) {
addByTaskDailyAndUserId(TaskPointIdConstants.DAILY_SIGN_7, userPointLog.getUserId());
}
// 连续30天签到
List<UserPointLog> daysByUserIdAndTaskPointId30 = userPointLogDao.findDaysByUserIdAndTaskPointId(
userPointLog.getUserId(), TaskPointIdConstants.DAILY_SIGN, 30 - 1);
if (daysByUserIdAndTaskPointId30.size() == 30 - 1) {
addByTaskDailyAndUserId(TaskPointIdConstants.DAILY_SIGN_30, userPointLog.getUserId());
}
}
} else {
List<UserPointLog> list = userPointLogDao.findUserPointLogsByUserIdAndTaskPointId(
userPointLog.getUserId(), TaskPointIdConstants.NEW_USER_INVITE);
if (list.size() >= 3) {
if (list.size() >= 3 - 1) {
// 邀请人数 >= 3人并且没有获得对应的积分
List<UserPointLog> userPointLogsByUserIdAndTaskPointId3 = userPointLogDao.findUserPointLogsByUserIdAndTaskPointId(
TaskPointIdConstants.INVITE_USER_3, userPointLog.getUserId());
@ -233,7 +254,7 @@ public class UserPointLogService {
TaskPointIdConstants.INVITE_USER_3, userPointLog.getUserId());
}
}
if (list.size() >= 6) {
if (list.size() >= 6 - 1) {
// 邀请人数 >= 6人并且没有获得对应的积分
List<UserPointLog> userPointLogsByUserIdAndTaskPointId6 = userPointLogDao.findUserPointLogsByUserIdAndTaskPointId(
TaskPointIdConstants.INVITE_USER_6, userPointLog.getUserId());
@ -242,7 +263,7 @@ public class UserPointLogService {
TaskPointIdConstants.INVITE_USER_6, userPointLog.getUserId());
}
}
if (list.size() >= 10) {
if (list.size() >= 10 - 1) {
// 邀请人数 >= 10人并且没有获得对应的积分
List<UserPointLog> userPointLogsByUserIdAndTaskPointId10 = userPointLogDao.findUserPointLogsByUserIdAndTaskPointId(
TaskPointIdConstants.INVITE_USER_10, userPointLog.getUserId());
@ -251,7 +272,7 @@ public class UserPointLogService {
TaskPointIdConstants.INVITE_USER_10, userPointLog.getUserId());
}
}
if (list.size() >= 20) {
if (list.size() >= 20 - 1) {
// 邀请人数 >= 20人并且没有获得对应的积分
List<UserPointLog> userPointLogsByUserIdAndTaskPointId20 = userPointLogDao.findUserPointLogsByUserIdAndTaskPointId(
TaskPointIdConstants.INVITE_USER_20, userPointLog.getUserId());
@ -339,27 +360,6 @@ public class UserPointLogService {
if (todayByUserIdAndTaskPointId == null) {
// 今天还没签到
addByTaskDaily(TaskPointIdConstants.DAILY_SIGN, token);
// 连续3天
List<UserPointLog> daysByUserIdAndTaskPointId3 = userPointLogDao.findDaysByUserIdAndTaskPointId(
userLoginDto.getUserId(), TaskPointIdConstants.DAILY_SIGN, 3 - 1);
if (daysByUserIdAndTaskPointId3.size() == 3) {
addByTaskDaily(TaskPointIdConstants.DAILY_SIGN_3, token);
}
// 连续7天
List<UserPointLog> daysByUserIdAndTaskPointId7 = userPointLogDao.findDaysByUserIdAndTaskPointId(
userLoginDto.getUserId(), TaskPointIdConstants.DAILY_SIGN, 7 - 1);
if (daysByUserIdAndTaskPointId7.size() == 7) {
addByTaskDaily(TaskPointIdConstants.DAILY_SIGN_7, token);
}
// 连续30天
List<UserPointLog> daysByUserIdAndTaskPointId30 = userPointLogDao.findDaysByUserIdAndTaskPointId(
userLoginDto.getUserId(), TaskPointIdConstants.DAILY_SIGN, 30 - 1);
if (daysByUserIdAndTaskPointId30.size() == 30) {
addByTaskDaily(TaskPointIdConstants.DAILY_SIGN_30, token);
}
} else {
throw new BizException(ErrorConstants.DAILY_SIGN_ALREADY);
}

Loading…
Cancel
Save