| | |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.enums.ListingStatusEnum; |
| | | import com.ruoyi.common.core.enums.StartStatusEnum; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | |
| | | import com.ruoyi.goods.service.IGoodsSeckillService; |
| | | import com.ruoyi.goods.service.IGoodsSkuService; |
| | | import com.ruoyi.goods.service.async.AsyncMethodService; |
| | | import com.ruoyi.system.api.constants.DelayTaskEnum; |
| | | import com.ruoyi.system.api.constants.NotificationTypeConstant; |
| | | import com.ruoyi.system.api.domain.GoodsSeckill; |
| | | import com.ruoyi.system.api.domain.GoodsSku; |
| | |
| | | //查询秒杀商品 |
| | | GoodsSeckill goodsSeckill = this.getById(upd.getId()); |
| | | if (StringUtils.isNull(goodsSeckill)) { |
| | | throw new RuntimeException("秒杀商品不存在"); |
| | | throw new ServiceException("秒杀商品不存在"); |
| | | } |
| | | if (goodsSeckill.getStartStatus().equals(StartStatusEnum.STARTED)) { |
| | | throw new ServiceException("秒杀商品已开始秒杀,不能修改"); |
| | | } |
| | | GoodsSeckill goodsSeckillUpd = BeanUtils.copyBean(upd, GoodsSeckill.class); |
| | | this.updateById(goodsSeckillUpd); |
| | |
| | | */ |
| | | @Override |
| | | public void updStatus(ListStatusDTO dto) { |
| | | GoodsSeckill goodsSeckill = this.getById(dto.getId()); |
| | | if (StringUtils.isNull(goodsSeckill)) { |
| | | throw new ServiceException("秒杀商品不存在"); |
| | | } |
| | | this.lambdaUpdate() |
| | | .eq(GoodsSeckill::getId, dto.getId()) |
| | | .set(GoodsSeckill::getListingStatus, dto.getListingStatus()) |
| | | .update(); |
| | | if (dto.getListingStatus().equals(ListingStatusEnum.REMOVED_FROM_THE_SHELF)) { |
| | | //移除该秒杀商品的延时任务 |
| | | redisService.deleteObject( |
| | | DelayTaskEnum.SECKILL_START_TASK.getCode() + "-" + goodsSeckill.getId()); |
| | | redisService.deleteObject( |
| | | DelayTaskEnum.SECKILL_END_TASK.getCode() + "-" + goodsSeckill.getId()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | public GoodsSeckillVO getDetail(Long id) { |
| | | GoodsSeckill goodsSeckill = this.getById(id); |
| | | if (StringUtils.isNull(goodsSeckill)) { |
| | | throw new RuntimeException("秒杀商品不存在"); |
| | | throw new ServiceException("秒杀商品不存在"); |
| | | } |
| | | GoodsSeckillVO vo = BeanUtils.copyBean(goodsSeckill, GoodsSeckillVO.class); |
| | | GoodsSku goods = goodsSkuService.getById(goodsSeckill.getGoodsSkuId()); |