Эх сурвалжийг харах

fix(product): 补注入 NutritionProductService 并修正 syncFromProduct 调用位置

Xiaogang Liao 1 өдөр өмнө
parent
commit
5f683f8679

+ 4 - 2
cfc-backend/src/main/java/com/etotem/cfc/service/ProductService.java

@@ -59,6 +59,9 @@ public class ProductService {
     @Resource
     private GrowthArchiveProductService growthArchiveProductService;
 
+    @Resource
+    private NutritionProductService nutritionProductService;
+
     @Resource
     private ProductDeliveryConfigService productDeliveryConfigService;
 
@@ -170,7 +173,6 @@ wrapper.in(Product::getId, productIds)
                 }
             });
         }
-        nutritionProductService.syncFromProduct(product);
         // 供应商可见过滤:仅对非供应商体系用户生效,供应商体系内用户可查看全部商品
         boolean isVendor = isVendorUser(userId, role);
         if (!isVendor && !isGuest(userId)) {
@@ -251,7 +253,6 @@ wrapper.in(Product::getId, productIds)
                 ProductDTO.BundleItemVO vo = new ProductDTO.BundleItemVO();
                 vo.setChildProductId(child.getId());
                 vo.setChildProductName(child.getName());
-        nutritionProductService.syncFromProduct(product);
                 vo.setCoverImage(child.getCoverImage());
                 vo.setChildSkuId(bi.getChildSkuId());
                 vo.setQuantity(bi.getQuantity());
@@ -293,6 +294,7 @@ wrapper.in(Product::getId, productIds)
         if (!deliveryConfig.isEmpty()) {
             dto.setDeliveryConfig(deliveryConfig);
         }
+        nutritionProductService.syncFromProduct(product);
         return Result.success(dto);
     }