mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
【恢复】【BUG】修改秒杀根据时间段开判断是否开启活动
This commit is contained in:
parent
b092906a66
commit
7231042df4
@ -98,10 +98,9 @@ public interface SeckillActivityMapper extends BaseMapperX<SeckillActivityDO> {
|
|||||||
* @param dateTime 指定日期
|
* @param dateTime 指定日期
|
||||||
* @return 活动列表
|
* @return 活动列表
|
||||||
*/
|
*/
|
||||||
default List<SeckillActivityDO> selectListByIdsAndDateTimeLt(Collection<Long> ids, List<Long> confidIds, LocalDateTime dateTime) {
|
default List<SeckillActivityDO> selectListByIdsAndDateTimeLt(Collection<Long> ids, LocalDateTime dateTime) {
|
||||||
return selectList(new LambdaQueryWrapperX<SeckillActivityDO>()
|
return selectList(new LambdaQueryWrapperX<SeckillActivityDO>()
|
||||||
.in(SeckillActivityDO::getId, ids)
|
.in(SeckillActivityDO::getId, ids)
|
||||||
.in(SeckillActivityDO::getConfigIds,confidIds)
|
|
||||||
.lt(SeckillActivityDO::getStartTime, dateTime)
|
.lt(SeckillActivityDO::getStartTime, dateTime)
|
||||||
.gt(SeckillActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动
|
.gt(SeckillActivityDO::getEndTime, dateTime)// 开始时间 < 指定时间 < 结束时间,也就是说获取指定时间段的活动
|
||||||
.orderByDesc(SeckillActivityDO::getCreateTime));
|
.orderByDesc(SeckillActivityDO::getCreateTime));
|
||||||
|
@ -27,13 +27,4 @@ public interface SeckillConfigMapper extends BaseMapperX<SeckillConfigDO> {
|
|||||||
return selectList(SeckillConfigDO::getStatus, status);
|
return selectList(SeckillConfigDO::getStatus, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<SeckillConfigDO> selectListByIdsAndDateTimeLt(LocalDateTime dateTime){
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
|
||||||
String format = formatter.format(dateTime);
|
|
||||||
return selectList(new LambdaQueryWrapper<SeckillConfigDO>()
|
|
||||||
.eq(SeckillConfigDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
|
|
||||||
.lt(SeckillConfigDO::getStartTime, format)
|
|
||||||
.gt(SeckillConfigDO::getEndTime, format));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static cn.hutool.core.collection.CollUtil.isNotEmpty;
|
import static cn.hutool.core.collection.CollUtil.isNotEmpty;
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@ -335,12 +334,9 @@ public class SeckillActivityServiceImpl implements SeckillActivityService {
|
|||||||
if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) {
|
if (CollUtil.isEmpty(spuIdAndActivityIdMaps)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
// 2.查询当前时间属于哪个时间段
|
// 2.查询活动详情
|
||||||
List<SeckillConfigDO> seckillConfigList= seckillConfigMapper.selectListByIdsAndDateTimeLt(dateTime);
|
|
||||||
List<Long> confidIds = seckillConfigList.stream().map(SeckillConfigDO::getId).collect(Collectors.toList());
|
|
||||||
// 3.查询活动详情
|
|
||||||
return seckillActivityMapper.selectListByIdsAndDateTimeLt(
|
return seckillActivityMapper.selectListByIdsAndDateTimeLt(
|
||||||
convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId")), confidIds, dateTime);
|
convertSet(spuIdAndActivityIdMaps, map -> MapUtil.getLong(map, "activityId")), dateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user