| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.common.collect.Lists; |
| | | import com.ruoyi.common.core.constant.CacheConstants; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.enums.ListingStatusEnum; |
| | |
| | | .set(GoodsSku::getStock, goodsSku.getStock() - seckillStock) |
| | | .ge(GoodsSku::getStock, seckillStock) |
| | | .eq(GoodsSku::getId, goodsSku.getId()); |
| | | asyncMethodService.seckillScheduleTask(goodsSeckill); |
| | | asyncMethodService.seckillScheduleTask(Lists.newArrayList(goodsSeckill)); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | GoodsSeckill goodsSeckillUpd = BeanUtils.copyBean(upd, GoodsSeckill.class); |
| | | this.updateById(goodsSeckillUpd); |
| | | asyncMethodService.seckillScheduleTask(goodsSeckill); |
| | | asyncMethodService.seckillScheduleTask(Lists.newArrayList(goodsSeckill)); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void startSeckill(Long seckillId) throws JsonProcessingException { |
| | | log.info(">>>>>>>>>>>>>>>>>>>>{}秒杀开始<<<<<<<<<<<<<<<<<<<<", seckillId); |
| | | GoodsSeckill goodsSeckill = this.getById(seckillId); |
| | | //秒杀商品不能为空且状态为未开始 |
| | | // 秒杀商品不能为空且上架状态为上架中 状态为未开始 |
| | | if (StringUtils.isNotNull(goodsSeckill) |
| | | && goodsSeckill.getStartStatus().equals(StartStatusEnum.NOT_STARTED)) { |
| | | && goodsSeckill.getStartStatus().equals(StartStatusEnum.NOT_STARTED) && |
| | | goodsSeckill.getListingStatus() |
| | | .equals(ListingStatusEnum.ON_SHELVES)) { |
| | | //开始秒杀 |
| | | this.lambdaUpdate().set(GoodsSeckill::getStartStatus, StartStatusEnum.STARTED) |
| | | .eq(GoodsSeckill::getId, seckillId).update(); |
| | |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.SECKILL); |
| | | map.put("notification_time", LocalDateTime.now()); |
| | | map.put("target_id", seckillId); |
| | | map.put("message_type", "start"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | WebSocketUsers.sendMessageToUsersByText(msg); |
| | |
| | | Map<String, Object> map = new ConcurrentHashMap<>(); |
| | | map.put("notification_type", NotificationTypeConstant.SECKILL); |
| | | map.put("notification_time", LocalDateTime.now()); |
| | | map.put("target_id", seckillId); |
| | | map.put("message_type", "end"); |
| | | String msg = objectMapper.writeValueAsString(map); |
| | | WebSocketUsers.sendMessageToUsersByText(msg); |