Pu Zhibing
2025-01-17 ec759e2c4e9340a1f447dec93ce4742c1c8c132a
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/SeckillActivityInfoServiceImpl.java
@@ -78,7 +78,7 @@
            LocalDateTime endTime = seckillActivityVO.getEndTime();
            if (endTime.isBefore(now)){
                seckillActivityVO.setStatus(3); //已结束
            }else if (startTime.isBefore(now)){
            }else if (startTime.isBefore(now) && endTime.isAfter(now)){
                seckillActivityVO.setStatus(2); // 已开始
            }else {
                seckillActivityVO.setStatus(1); // 未开始
@@ -202,8 +202,10 @@
    @Transactional(rollbackFor = Exception.class)
    public void saveSeckillActivityInfo(SeckillActivityInfo seckillActivityInfo) {
        Integer goodId = seckillActivityInfo.getGoodId();
        LocalDateTime startTime = seckillActivityInfo.getStartTime();
        LocalDateTime endTime = seckillActivityInfo.getEndTime();
        long count = this.count(new LambdaQueryWrapper<SeckillActivityInfo>().eq(SeckillActivityInfo::getGoodId, goodId).eq(SeckillActivityInfo::getDelFlag, 0)
                .eq(SeckillActivityInfo::getIsShelves, 1).last(" and now() between start_time and end_time"));
                .eq(SeckillActivityInfo::getIsShelves, 1).last(" and (" + startTime + " between start_time and end_time or " + endTime + " between start_time and end_time)"));
        if(0 < count){
            throw new RuntimeException("该秒杀商品已在其他秒杀活动中存在");
        }
@@ -221,9 +223,11 @@
    @Transactional(rollbackFor = Exception.class)
    public void updateSeckillActivityInfo(SeckillActivityInfo seckillActivityInfo) {
        Integer goodId = seckillActivityInfo.getGoodId();
        LocalDateTime startTime = seckillActivityInfo.getStartTime();
        LocalDateTime endTime = seckillActivityInfo.getEndTime();
        long count = this.count(new LambdaQueryWrapper<SeckillActivityInfo>().eq(SeckillActivityInfo::getGoodId, goodId).eq(SeckillActivityInfo::getDelFlag, 0)
                .eq(SeckillActivityInfo::getIsShelves, 1).last(" and now() between start_time and end_time"));
        if(1 < count){
                .eq(SeckillActivityInfo::getIsShelves, 1).last(" and (" + startTime + " between start_time and end_time or " + endTime + " between start_time and end_time)"));
        if(0 < count){
            throw new RuntimeException("该秒杀商品已在其他秒杀活动中存在");
        }
        this.baseMapper.updateById(seckillActivityInfo);