From 23e3602b4f3ebde8665c3ab3a56ef81b8d671e0d Mon Sep 17 00:00:00 2001
From: zepengdev <lzpsmith@outlook.com>
Date: Wed, 17 Sep 2025 19:17:21 +0800
Subject: [PATCH] feat: 增加商品库存设置功能

---
 oying-system/src/main/java/com/oying/modules/pc/product/service/impl/ProductMerchantServiceImpl.java |   19 +++----------------
 1 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/oying-system/src/main/java/com/oying/modules/pc/product/service/impl/ProductMerchantServiceImpl.java b/oying-system/src/main/java/com/oying/modules/pc/product/service/impl/ProductMerchantServiceImpl.java
index 24ed038..e4eef20 100644
--- a/oying-system/src/main/java/com/oying/modules/pc/product/service/impl/ProductMerchantServiceImpl.java
+++ b/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) {

--
Gitblit v1.9.3