|
|
@@ -49,25 +49,31 @@ public class LotteryCountLogServiceImpl extends ServiceImpl<LotteryCountLogMappe
|
|
|
|
|
|
// 2. 构建查询条件 (用于查找未弹窗的记录)
|
|
|
LambdaQueryWrapper<LotteryCountLog> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.select(LotteryCountLog::getId)
|
|
|
- .eq(LotteryCountLog::getType, dto.getType())
|
|
|
- .eq(LotteryCountLog::getUserId, userId)
|
|
|
+ queryWrapper.eq(LotteryCountLog::getUserId, userId)
|
|
|
.eq(LotteryCountLog::getIsLottery, 0) // 只查未弹窗的
|
|
|
- .eq(LotteryCountLog::getIsDelete, 0);
|
|
|
+ .eq(LotteryCountLog::getIsDelete, 0)
|
|
|
+ .in(LotteryCountLog::getType, dto.getTypes());
|
|
|
|
|
|
- // 3.提取 ID 列表
|
|
|
- List<Long> logIds = this.baseMapper.selectList(queryWrapper).stream()
|
|
|
- .map(LotteryCountLog::getId)
|
|
|
- .collect(Collectors.toList());
|
|
|
+ // 3.提取列表
|
|
|
+ List<LotteryCountLog> lotteryCountLogs = this.baseMapper.selectList(queryWrapper);
|
|
|
|
|
|
// 4. 设置返回结果
|
|
|
- boolean hasChance = CollUtil.isNotEmpty(logIds);
|
|
|
- vo.setIsLottery(hasChance ? 1 : 0);
|
|
|
+ if (CollUtil.isEmpty(lotteryCountLogs)) {
|
|
|
+ vo.setIsLottery(0);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ LotteryCountLog lotteryCountLog = CollUtil.getFirst(lotteryCountLogs);
|
|
|
+
|
|
|
+ vo.setIsLottery(1);
|
|
|
+ vo.setActivityId(lotteryCountLog.getLocalActivityTableId());
|
|
|
|
|
|
// 5. 如果有记录,批量更新状态为“已弹窗”
|
|
|
- if (CollUtil.isNotEmpty(logIds)) {
|
|
|
+ if (CollUtil.isNotEmpty(lotteryCountLogs)) {
|
|
|
+
|
|
|
LambdaUpdateWrapper<LotteryCountLog> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.in(LotteryCountLog::getId, logIds)
|
|
|
+ updateWrapper.in(LotteryCountLog::getType, dto.getTypes())
|
|
|
+ .eq(LotteryCountLog::getUserId, userId)
|
|
|
.set(LotteryCountLog::getIsLottery, 1)
|
|
|
.set(LotteryCountLog::getUpdateTime, new Date());
|
|
|
|