|
|
@@ -10,9 +10,13 @@ import com.etotem.cfc.dto.ProductListQueryDTO;
|
|
|
import com.etotem.cfc.entity.AssessmentProduct;
|
|
|
import com.etotem.cfc.entity.GrowthArchiveProduct;
|
|
|
import com.etotem.cfc.entity.Product;
|
|
|
+import com.etotem.cfc.entity.ProductBundleItem;
|
|
|
import com.etotem.cfc.entity.ProductGiftRule;
|
|
|
+import com.etotem.cfc.entity.ProductSku;
|
|
|
import com.etotem.cfc.entity.User;
|
|
|
+import com.etotem.cfc.mapper.ProductBundleItemMapper;
|
|
|
import com.etotem.cfc.mapper.ProductMapper;
|
|
|
+import com.etotem.cfc.mapper.ProductSkuMapper;
|
|
|
import com.etotem.cfc.mapper.UserMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -50,6 +54,12 @@ public class ProductService {
|
|
|
@Resource
|
|
|
private ProductDeliveryConfigService productDeliveryConfigService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ProductBundleItemMapper bundleItemMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ProductSkuMapper productSkuMapper;
|
|
|
+
|
|
|
public Product getById(Long id) {
|
|
|
return productMapper.selectById(id);
|
|
|
}
|
|
|
@@ -127,6 +137,29 @@ wrapper.in(Product::getId, productIds)
|
|
|
return Result.error("商品未上架");
|
|
|
}
|
|
|
ProductDTO dto = ProductDTO.from(product);
|
|
|
+ // 套餐商品:填充套餐组成(子商品名称/封面/SKU规格/数量)
|
|
|
+ if ("bundle".equals(product.getProductType())) {
|
|
|
+ List<ProductBundleItem> items = bundleItemMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<ProductBundleItem>()
|
|
|
+ .eq(ProductBundleItem::getBundleProductId, id));
|
|
|
+ List<ProductDTO.BundleItemVO> bundleItems = new ArrayList<>();
|
|
|
+ for (ProductBundleItem bi : items) {
|
|
|
+ Product child = productMapper.selectById(bi.getChildProductId());
|
|
|
+ if (child == null) continue; // 子商品已删除则跳过
|
|
|
+ ProductDTO.BundleItemVO vo = new ProductDTO.BundleItemVO();
|
|
|
+ vo.setChildProductId(child.getId());
|
|
|
+ vo.setChildProductName(child.getName());
|
|
|
+ vo.setCoverImage(child.getCoverImage());
|
|
|
+ vo.setChildSkuId(bi.getChildSkuId());
|
|
|
+ vo.setQuantity(bi.getQuantity());
|
|
|
+ if (bi.getChildSkuId() != null) {
|
|
|
+ ProductSku sku = productSkuMapper.selectById(bi.getChildSkuId());
|
|
|
+ if (sku != null) vo.setSpecs(sku.getSpecs());
|
|
|
+ }
|
|
|
+ bundleItems.add(vo);
|
|
|
+ }
|
|
|
+ dto.setBundleItems(bundleItems);
|
|
|
+ }
|
|
|
ProductGiftRule giftRule = productGiftRuleService.getActiveByProductId(id);
|
|
|
if (giftRule != null) {
|
|
|
dto.setGiftLevelCode(giftRule.getLevelCode());
|