| | |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.enums.AuctionOrderTypeEnum; |
| | | import com.ruoyi.common.core.enums.ListingStatusEnum; |
| | | import com.ruoyi.common.core.enums.OrderFromEnum; |
| | | 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.IGoodsInfoTitleValueService; |
| | | import com.ruoyi.goods.service.IGoodsSkuService; |
| | | import com.ruoyi.goods.service.IMemberGoodsCollectionService; |
| | | import com.ruoyi.system.api.domain.AuctionGoods; |
| | | import com.ruoyi.system.api.domain.AuctionSalesroom; |
| | | import com.ruoyi.system.api.domain.AuctionSalesroomGoods; |
| | | import com.ruoyi.system.api.domain.GoodsBrand; |
| | | import com.ruoyi.system.api.domain.GoodsCategory; |
| | | import com.ruoyi.system.api.domain.GoodsFlavorType; |
| | |
| | | import com.ruoyi.system.api.domain.vo.HomeGoodsSkuInfoVO; |
| | | import com.ruoyi.system.api.domain.vo.HomeGoodsSkuListVO; |
| | | import com.ruoyi.system.api.domain.vo.getHomeGoodsSkuXxiVO; |
| | | import com.ruoyi.system.api.feignClient.AuctionClient; |
| | | import com.ruoyi.system.api.feignClient.GoodsSkuClient; |
| | | import com.ruoyi.system.api.feignClient.OrderClient; |
| | | import java.time.LocalDate; |
| | |
| | | private final GoodsSeckillMapper goodsSeckillMapper; |
| | | private final GoodsGroupPurchaseMapper goodsGroupPurchaseMapper; |
| | | private final RedissonClient redissonClient; |
| | | |
| | | private final AuctionClient auctionClient; |
| | | @Resource |
| | | private IGoodsBrowseRecordService iGoodsBrowseRecordService; |
| | | |
| | |
| | | .eq(GoodsSku::getId, dto.getId()) |
| | | .set(GoodsSku::getListingStatus, dto.getListingStatus()) |
| | | .update(); |
| | | //关联的秒杀商品和团购商品同步下架 |
| | | |
| | | if (dto.getListingStatus().equals(ListingStatusEnum.REMOVED_FROM_THE_SHELF)) { |
| | | // 校验是否有秒杀活动商品 |
| | | Long seckillCount = goodsSeckillMapper.selectCount( |
| | | new LambdaQueryWrapper<GoodsSeckill>().eq(GoodsSeckill::getGoodsSkuId, |
| | | dto.getId()) |
| | | .eq(GoodsSeckill::getStartStatus, StartStatusEnum.STARTED) |
| | | .eq(GoodsSeckill::getListingStatus, ListingStatusEnum.ON_SHELVES)); |
| | | if (seckillCount > 0) { |
| | | throw new ServiceException("该商品有秒杀活动商品正在进行中,不能下架"); |
| | | } |
| | | // 校验是否有团购活动商品 |
| | | Long groupCount = goodsGroupPurchaseMapper.selectCount( |
| | | new LambdaQueryWrapper<GoodsGroupPurchase>().eq( |
| | | GoodsGroupPurchase::getGoodsSkuId, |
| | | dto.getId()) |
| | | .eq(GoodsGroupPurchase::getStartStatus, StartStatusEnum.STARTED) |
| | | .eq(GoodsGroupPurchase::getListingStatus, |
| | | ListingStatusEnum.ON_SHELVES)); |
| | | if (groupCount > 0) { |
| | | throw new ServiceException("该商品有团购活动商品正在进行中,不能下架"); |
| | | } |
| | | // 校验是否有拍卖会商品 |
| | | List<AuctionSalesroom> auctionSalesrooms = auctionClient.getAuctionSalesroomBySkuId( |
| | | dto.getId(), SecurityConstants.INNER).getData(); |
| | | if (CollUtils.isNotEmpty(auctionSalesrooms)) { |
| | | throw new ServiceException("该商品有拍卖会商品正在进行中,不能下架"); |
| | | } |
| | | List<AuctionGoods> auctionGoodsList = auctionClient.getAuctionGoodsBySkuId(dto.getId(), |
| | | SecurityConstants.INNER).getData(); |
| | | if (CollUtils.isNotEmpty(auctionGoodsList)) { |
| | | throw new ServiceException("该商品有商品竞价商品正在进行中,不能下架"); |
| | | } |
| | | // 关联的秒杀商品和团购商品同步下架 |
| | | updateGoodsStatus(dto); |
| | | } |
| | | } |
| | |
| | | queryWrapper.eq(GoodsSeckill::getListingStatus, ListingStatusEnum.ON_SHELVES) |
| | | .eq(GoodsSeckill::getGoodsSkuId, dto.getId()); |
| | | List<GoodsSeckill> goodsSeckillList = goodsSeckillMapper.selectList(queryWrapper); |
| | | if (StringUtils.isNotNull(goodsSeckillList)) { |
| | | if (StringUtils.isNotEmpty(goodsSeckillList)) { |
| | | goodsSeckillList = goodsSeckillList.stream().peek(goodsSeckill -> { |
| | | goodsSeckill.setListingStatus(ListingStatusEnum.REMOVED_FROM_THE_SHELF); |
| | | }).collect(Collectors.toList()); |
| | |
| | | goodsSkuVO.setGoodsInfoTitleValueVOList(goodsInfoTitleValueVOList); |
| | | return goodsSkuVO; |
| | | } |
| | | |
| | | @Override |
| | | public void returnStockByOrder(Order order) { |
| | | Long goodsSkuId = null; |
| | | if (order.getOrderFrom().equals(OrderFromEnum.COMMODITY_ORDER)) { |
| | | goodsSkuId = order.getGoodsSkuId(); |
| | | } else if (order.getOrderFrom().equals(OrderFromEnum.SNAP_ORDERS)) { |
| | | GoodsSeckill goodsSeckill = goodsSeckillMapper.selectById(order.getGoodsSkuId()); |
| | | if (Objects.nonNull(goodsSeckill)) { |
| | | goodsSkuId = goodsSeckill.getGoodsSkuId(); |
| | | } |
| | | } else if (order.getOrderFrom().equals(OrderFromEnum.GROUP_PURCHASE_ORDERS)) { |
| | | GoodsGroupPurchase goodsGroupPurchase = goodsGroupPurchaseMapper.selectById( |
| | | order.getGoodsSkuId()); |
| | | if (Objects.nonNull(goodsGroupPurchase)) { |
| | | goodsSkuId = goodsGroupPurchase.getGoodsSkuId(); |
| | | } |
| | | } else if (order.getOrderFrom() |
| | | .equals(OrderFromEnum.AUCTION_ORDERS) && order.getAuctionOrderType() |
| | | .equals(AuctionOrderTypeEnum.REGULAR_ITEMS)) { |
| | | AuctionGoods auctionGoods = auctionClient.getAuctionGoodsId(order.getGoodsSkuId(), |
| | | SecurityConstants.INNER).getData(); |
| | | if (Objects.nonNull(auctionGoods)) { |
| | | goodsSkuId = auctionGoods.getGoodsSkuId(); |
| | | } |
| | | } else if (order.getOrderFrom() |
| | | .equals(OrderFromEnum.AUCTION_ORDERS) && order.getAuctionOrderType() |
| | | .equals(AuctionOrderTypeEnum.AUCTION_ITEMS)) { |
| | | AuctionSalesroomGoods auctionSalesroomGoods = auctionClient.getAuctionSalesroomGoodsById( |
| | | order.getGoodsSkuId(), |
| | | SecurityConstants.INNER).getData(); |
| | | if (Objects.nonNull(auctionSalesroomGoods)) { |
| | | goodsSkuId = auctionSalesroomGoods.getGoodsSkuId(); |
| | | } |
| | | } |
| | | if (Objects.nonNull(goodsSkuId)) { |
| | | updateGoodsStock(goodsSkuId, order.getGoodsQuantity()); |
| | | } |
| | | } |
| | | } |