抽奖weekKey问题修复,去除weekKey条件 并修复了数据
This commit is contained in:
parent
05f2a9990e
commit
7a00994663
@ -20,6 +20,7 @@ import com.red.circle.other.infra.database.rds.service.activity.LotteryTicketRec
|
||||
import com.red.circle.other.infra.database.rds.service.activity.LotteryTicketService;
|
||||
import com.red.circle.other.infra.database.rds.service.activity.LotteryUserCountService;
|
||||
import com.red.circle.other.infra.database.rds.service.activity.LotteryUserProgressService;
|
||||
import com.red.circle.other.infra.utils.ZonedDateTimeUtils;
|
||||
import com.red.circle.other.inner.asserts.lottery.LotteryErrorCode;
|
||||
import com.red.circle.tool.core.date.TimestampUtils;
|
||||
import java.math.BigDecimal;
|
||||
@ -31,6 +32,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@ -142,19 +144,19 @@ public class LotteryDrawExe {
|
||||
* 获取或创建用户进度.
|
||||
*/
|
||||
private LotteryUserProgress getOrCreateUserProgress(Long userId, Long activityId) {
|
||||
String weekKey = getWeekKey();
|
||||
// String weekKey = ZonedDateTimeUtils.getWeekKey();
|
||||
|
||||
LotteryUserProgress progress = lotteryUserProgressService.query()
|
||||
.eq(LotteryUserProgress::getUserId, userId)
|
||||
.eq(LotteryUserProgress::getActivityId, activityId)
|
||||
.eq(LotteryUserProgress::getWeekKey, weekKey)
|
||||
// .eq(LotteryUserProgress::getWeekKey, weekKey)
|
||||
.getOne();
|
||||
|
||||
if (progress == null) {
|
||||
progress = new LotteryUserProgress();
|
||||
progress.setUserId(userId);
|
||||
progress.setActivityId(activityId);
|
||||
progress.setWeekKey(weekKey);
|
||||
// progress.setWeekKey(weekKey);
|
||||
progress.setTotalAmount(BigDecimal.ZERO);
|
||||
progress.setTotalDrawCount(0);
|
||||
progress.setBigPrizeCount(0);
|
||||
@ -530,16 +532,6 @@ public class LotteryDrawExe {
|
||||
.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成周标识.
|
||||
*/
|
||||
private String getWeekKey() {
|
||||
LocalDate now = LocalDate.now();
|
||||
int year = now.getYear();
|
||||
int weekOfYear = now.get(WeekFields.of(Locale.getDefault()).weekOfYear());
|
||||
return String.format("%dW%02d", year, weekOfYear);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成记录编号.
|
||||
*/
|
||||
|
||||
@ -21,6 +21,7 @@ import com.red.circle.other.infra.database.rds.service.activity.LotteryTicketRec
|
||||
import com.red.circle.other.infra.database.rds.service.activity.LotteryTicketService;
|
||||
import com.red.circle.other.infra.database.rds.service.activity.LotteryUserCountService;
|
||||
import com.red.circle.other.infra.database.rds.service.activity.LotteryUserProgressService;
|
||||
import com.red.circle.other.infra.utils.ZonedDateTimeUtils;
|
||||
import com.red.circle.other.inner.asserts.lottery.LotteryErrorCode;
|
||||
import com.red.circle.tool.core.date.TimestampUtils;
|
||||
import java.math.BigDecimal;
|
||||
@ -181,17 +182,17 @@ public class LotteryMultiDrawExe {
|
||||
}
|
||||
|
||||
private LotteryUserProgress getOrCreateUserProgress(Long userId, Long activityId) {
|
||||
String weekKey = getWeekKey();
|
||||
// String weekKey = ZonedDateTimeUtils.getWeekKey();
|
||||
LotteryUserProgress progress = lotteryUserProgressService.query()
|
||||
.eq(LotteryUserProgress::getUserId, userId)
|
||||
.eq(LotteryUserProgress::getActivityId, activityId)
|
||||
.eq(LotteryUserProgress::getWeekKey, weekKey)
|
||||
// .eq(LotteryUserProgress::getWeekKey, weekKey)
|
||||
.getOne();
|
||||
if (progress == null) {
|
||||
progress = new LotteryUserProgress();
|
||||
progress.setUserId(userId);
|
||||
progress.setActivityId(activityId);
|
||||
progress.setWeekKey(weekKey);
|
||||
// progress.setWeekKey(weekKey);
|
||||
progress.setTotalAmount(BigDecimal.ZERO);
|
||||
progress.setTotalDrawCount(0);
|
||||
progress.setBigPrizeCount(0);
|
||||
@ -481,13 +482,6 @@ public class LotteryMultiDrawExe {
|
||||
.execute();
|
||||
}
|
||||
|
||||
private String getWeekKey() {
|
||||
LocalDate now = LocalDate.now();
|
||||
int year = now.getYear();
|
||||
int weekOfYear = now.get(WeekFields.of(Locale.getDefault()).weekOfYear());
|
||||
return String.format("%dW%02d", year, weekOfYear);
|
||||
}
|
||||
|
||||
private LotteryDrawResultCO convertToResultCO(LotteryRecord record, LotteryPrize prize) {
|
||||
LotteryDrawResultCO result = new LotteryDrawResultCO();
|
||||
result.setRecordNo(record.getRecordNo());
|
||||
|
||||
@ -30,11 +30,11 @@ public class LotteryWithdrawAmountQryExe {
|
||||
|
||||
public LotteryWithdrawAmountCO execute(Long userId, Long activityId) {
|
||||
// 1. 获取用户本周累计金额
|
||||
String weekKey = getCurrentWeekKey();
|
||||
// String weekKey = getCurrentWeekKey();
|
||||
LotteryUserProgress progress = lotteryUserProgressService.query()
|
||||
.eq(LotteryUserProgress::getUserId, userId)
|
||||
.eq(LotteryUserProgress::getActivityId, activityId)
|
||||
.eq(LotteryUserProgress::getWeekKey, weekKey)
|
||||
// .eq(LotteryUserProgress::getWeekKey, weekKey)
|
||||
.getOne();
|
||||
|
||||
BigDecimal totalAmount = progress != null && progress.getTotalAmount() != null
|
||||
|
||||
@ -6,6 +6,7 @@ import com.red.circle.other.infra.database.rds.entity.activity.LotteryUserProgre
|
||||
import com.red.circle.other.infra.database.rds.entity.activity.LotteryWithdraw;
|
||||
import com.red.circle.other.infra.database.rds.service.activity.LotteryUserProgressService;
|
||||
import com.red.circle.other.infra.database.rds.service.activity.LotteryWithdrawService;
|
||||
import com.red.circle.other.infra.utils.ZonedDateTimeUtils;
|
||||
import com.red.circle.other.inner.asserts.lottery.LotteryErrorCode;
|
||||
import com.red.circle.tool.core.date.TimestampUtils;
|
||||
import java.math.BigDecimal;
|
||||
@ -41,11 +42,11 @@ public class LotteryWithdrawApplyExe {
|
||||
amount.compareTo(BigDecimal.valueOf(10)) >= 0);
|
||||
|
||||
// 1. 获取用户本周累计金额
|
||||
String weekKey = getCurrentWeekKey();
|
||||
// String weekKey = ZonedDateTimeUtils.getWeekKey();
|
||||
LotteryUserProgress progress = lotteryUserProgressService.query()
|
||||
.eq(LotteryUserProgress::getUserId, userId)
|
||||
.eq(LotteryUserProgress::getActivityId, activityId)
|
||||
.eq(LotteryUserProgress::getWeekKey, weekKey)
|
||||
// .eq(LotteryUserProgress::getWeekKey, weekKey)
|
||||
.getOne();
|
||||
|
||||
ResponseAssert.notNull(LotteryErrorCode.NO_WITHDRAWAL_AMOUNT, progress);
|
||||
@ -109,16 +110,6 @@ public class LotteryWithdrawApplyExe {
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前周标识.
|
||||
*/
|
||||
private String getCurrentWeekKey() {
|
||||
LocalDate now = LocalDate.now();
|
||||
int year = now.getYear();
|
||||
int weekOfYear = now.get(WeekFields.of(Locale.getDefault()).weekOfYear());
|
||||
return String.format("%dW%02d", year, weekOfYear);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成提现单号.
|
||||
*/
|
||||
|
||||
@ -12,6 +12,7 @@ import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.time.temporal.WeekFields;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -472,6 +473,16 @@ public final class ZonedDateTimeUtils {
|
||||
return Timestamp.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成周标识(ISO 8601标准,周一为一周的开始).
|
||||
*/
|
||||
public static String getWeekKey() {
|
||||
LocalDate now = LocalDate.now();
|
||||
int year = now.get(WeekFields.ISO.weekBasedYear()); // 使用ISO周年
|
||||
int weekOfYear = now.get(WeekFields.ISO.weekOfWeekBasedYear()); // ISO周数
|
||||
return String.format("%dW%02d", year, weekOfYear);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换zoneId
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user