| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.ruoyi.common.core.enums.ListingStatusEnum; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.utils.page.BeanUtils; |
| | |
| | | import com.ruoyi.goods.controller.management.DTO.GoodsSkuDTO; |
| | | import com.ruoyi.goods.controller.management.DTO.GoodsSkuQuery; |
| | | import com.ruoyi.goods.controller.management.VO.GoodsSkuVO; |
| | | import com.ruoyi.goods.domain.GoodsGroupPurchase; |
| | | import com.ruoyi.goods.domain.GoodsInfoTitleValue; |
| | | import com.ruoyi.goods.domain.GoodsSeckill; |
| | | import com.ruoyi.goods.domain.GoodsSku; |
| | | import com.ruoyi.goods.mapper.GoodsSkuMapper; |
| | | import com.ruoyi.goods.service.IGoodsGroupPurchaseService; |
| | | import com.ruoyi.goods.service.IGoodsInfoTitleValueService; |
| | | import com.ruoyi.goods.service.IGoodsSeckillService; |
| | | import com.ruoyi.goods.service.IGoodsSkuService; |
| | | import com.ruoyi.system.api.domain.dto.ListStatusDTO; |
| | | import java.util.List; |
| | |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | /** |
| | |
| | | public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> implements IGoodsSkuService { |
| | | |
| | | private final IGoodsInfoTitleValueService goodsInfoTitleValueService; |
| | | private final IGoodsSeckillService goodsSeckillService; |
| | | private final IGoodsGroupPurchaseService goodsGroupPurchaseService; |
| | | private static final ObjectMapper objectMapper = new ObjectMapper(); |
| | | |
| | | /** |
| | |
| | | query.getSkuName()) |
| | | .eq(StringUtils.isNotNull(query.getListingStatus() |
| | | ), GoodsSku::getListingStatus, query.getListingStatus()) |
| | | .page(new Page<GoodsSku>(query.getPageCurr(), query.getPageSize())); |
| | | |
| | | .eq(query.getQueryType().equals(1), GoodsSku::getListingStatus, |
| | | ListingStatusEnum.ON_SHELVES) |
| | | .page(new Page<>(query.getPageCurr(), query.getPageSize())); |
| | | return PageDTO.of(page, GoodsSkuVO.class); |
| | | } |
| | | |
| | |
| | | * 更新商品SKU的状态。 |
| | | * |
| | | * @param dto 数据传输对象,包含需要更新的SKU的ID和新的上架状态。 其中,ID用于指定要更新的具体SKU,listingStatus用于指定新的上架状态。 |
| | | * @return 无返回值。 |
| | | */ |
| | | @Override |
| | | public void updStatus(ListStatusDTO dto) { |
| | | @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) |
| | | public void updStatus(ListStatusDTO dto) throws Exception { |
| | | this.lambdaUpdate() |
| | | .eq(GoodsSku::getId, dto.getId()) |
| | | .set(GoodsSku::getListingStatus, dto.getListingStatus()) |
| | | .update(); |
| | | //关联的秒杀商品和团购商品同步下架 |
| | | if (dto.getListingStatus().equals(ListingStatusEnum.REMOVED_FROM_THE_SHELF)) { |
| | | updateGoodsStatus(dto); |
| | | } |
| | | } |
| | | |
| | | private void updateGoodsStatus(ListStatusDTO dto) { |
| | | goodsSeckillService.lambdaUpdate() |
| | | .set(GoodsSeckill::getListingStatus, |
| | | ListingStatusEnum.REMOVED_FROM_THE_SHELF) |
| | | .eq(GoodsSeckill::getListingStatus, ListingStatusEnum.ON_SHELVES) |
| | | .eq(GoodsSeckill::getGoodsSkuId, dto.getId()).update(); |
| | | goodsGroupPurchaseService.lambdaUpdate() |
| | | .set(GoodsGroupPurchase::getListingStatus, |
| | | ListingStatusEnum.REMOVED_FROM_THE_SHELF) |
| | | .eq(GoodsGroupPurchase::getListingStatus, |
| | | ListingStatusEnum.ON_SHELVES) |
| | | .eq(GoodsGroupPurchase::getGoodsSkuId, dto.getId()).update(); |
| | | } |
| | | } |