zepengdev
2025-09-17 3c9e545c80af5515264f28dd60c46b1147281581
oying-system/src/main/java/com/oying/modules/pc/product/service/impl/ProductMerchantServiceImpl.java
@@ -1,11 +1,9 @@
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;
@@ -30,7 +28,6 @@
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
@@ -77,7 +74,7 @@
    @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);
@@ -88,18 +85,16 @@
    @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);
    }
@@ -160,14 +155,6 @@
        } 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) {