From 50f19eafbffe6d9ec9f5cd532eb29f9bbf3f4c59 Mon Sep 17 00:00:00 2001 From: Tankaikai Date: Mon, 17 Feb 2025 18:16:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E6=A8=A1=E5=9D=97=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ProductServiceImpl.java | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ProductServiceImpl.java b/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ProductServiceImpl.java index c4da214e7..2cae878f6 100644 --- a/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ProductServiceImpl.java +++ b/cash-service/product-service/src/main/java/com/czg/service/product/service/impl/ProductServiceImpl.java @@ -78,7 +78,7 @@ public class ProductServiceImpl extends ServiceImpl impl queryWrapper.select(PRODUCT.DEFAULT_COLUMNS) .select(SHOP_PROD_UNIT.NAME.as(ProductDTO::getUnitName)) .select(SHOP_PROD_CATEGORY.NAME.as(ProductDTO::getCategoryName)) - .select(SHOP_PROD_SPEC.NAME.as(ProductDTO::getSpecName),SHOP_PROD_SPEC.FULL_NAME.as(ProductDTO::getSpecFullName)) + .select(SHOP_PROD_SPEC.NAME.as(ProductDTO::getSpecName), SHOP_PROD_SPEC.FULL_NAME.as(ProductDTO::getSpecFullName)) .from(PRODUCT) .leftJoin(SHOP_PROD_UNIT).on(SHOP_PROD_UNIT.ID.eq(PRODUCT.UNIT_ID)) .leftJoin(SHOP_PROD_CATEGORY).on(SHOP_PROD_CATEGORY.ID.eq(PRODUCT.CATEGORY_ID)) @@ -116,13 +116,11 @@ public class ProductServiceImpl extends ServiceImpl impl entity.setGroupSnap(JSON.toJSONString(dto.getProGroupVo())); } } - - entity.setSpecInfo(JSON.toJSONString(dto.getSkuList())); entity.setIsDel(DeleteEnum.NORMAL.value()); entity.setShopId(shopId); super.save(entity); List skuList = dto.getSkuList(); - if(CollUtil.isNotEmpty(skuList)){ + if (CollUtil.isNotEmpty(skuList)) { List prodSkuList = new ArrayList<>(); for (ProdSkuDTO prodSkuDTO : skuList) { ProdSku prodSku = BeanUtil.copyProperties(prodSkuDTO, ProdSku.class); @@ -148,7 +146,32 @@ public class ProductServiceImpl extends ServiceImpl impl throw new CzgException("商品已存在"); } Product entity = BeanUtil.copyProperties(dto, Product.class); - return super.updateById(entity); + //套餐 + if (ProductTypeEnum.PACKAGE.value().equals(dto.getType())) { + //套餐内容 + if (CollUtil.isNotEmpty(dto.getProGroupVo())) { + entity.setGroupSnap(JSON.toJSONString(dto.getProGroupVo())); + } + } + entity.setIsDel(DeleteEnum.NORMAL.value()); + entity.setShopId(shopId); + super.save(entity); + List skuList = dto.getSkuList(); + if (CollUtil.isNotEmpty(skuList)) { + List prodSkuList = new ArrayList<>(); + for (ProdSkuDTO prodSkuDTO : skuList) { + ProdSku prodSku = BeanUtil.copyProperties(prodSkuDTO, ProdSku.class); + prodSku.setShopId(entity.getShopId()); + prodSku.setProductId(entity.getId()); + prodSku.setRealSalesNumber(BigDecimal.ZERO); + prodSku.setIsPauseSale(YesNoEnum.NO.value()); + prodSku.setIsGrounding(YesNoEnum.YES.value()); + prodSku.setIsDel(DeleteEnum.NORMAL.value()); + prodSkuList.add(prodSku); + } + prodSkuMapper.insertBatch(prodSkuList); + } + return true; } @Override