| | |
| | | package com.oying.modules.pc.product.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.ObjUtil; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.oying.exception.BadRequestException; |
| | | import com.oying.exception.EntityNotFoundException; |
| | | import com.oying.modules.pc.common.core.constrant.AuditStatusEnum; |
| | | import com.oying.modules.pc.product.converter.ProductImageAssembler; |
| | | import com.oying.modules.pc.product.converter.ProductLabelAssembler; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(ProductMerchantUpdateRequest request) { |
| | | Product existingProduct = this.findOrThrow(request.getProductId()); |
| | | Product existingProduct = productService.getProduct(request.getProductId()); |
| | | this.validateApprovedStatus(existingProduct.getShelfStatus()); |
| | | this.processImagesUpdate(request); |
| | | this.processLabelsUpdate(request); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateImages(ProductMerchantUpdateRequest request) { |
| | | Product existingProduct = this.findOrThrow(request.getProductId()); |
| | | Product existingProduct = productService.getProduct(request.getProductId()); |
| | | this.validateApprovedStatus(existingProduct.getShelfStatus()); |
| | | this.findOrThrow(request.getProductId()); |
| | | this.processImagesUpdate(request); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateLabels(ProductMerchantUpdateRequest request) { |
| | | Product existingProduct = this.findOrThrow(request.getProductId()); |
| | | Product existingProduct = productService.getProduct(request.getProductId()); |
| | | this.validateApprovedStatus(existingProduct.getShelfStatus()); |
| | | this.findOrThrow(request.getProductId()); |
| | | this.processImagesUpdate(request); |
| | | } |
| | | |
| | |
| | | } catch (Exception e) { |
| | | log.error("处理商品审核结果异常", e); |
| | | } |
| | | } |
| | | |
| | | private Product findOrThrow(Long productId) { |
| | | Product existingProduct = productService.getById(productId); |
| | | if (ObjUtil.isEmpty(existingProduct)) { |
| | | throw new EntityNotFoundException(Product.class, "id", Optional.ofNullable(productId).map(Object::toString).orElse("null")); |
| | | } |
| | | return existingProduct; |
| | | } |
| | | |
| | | private void processImagesUpdate(ProductMerchantUpdateRequest request) { |