From 70d26b5c78d6544e0aa58d1b98ba4b536bc553fc Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 10 Oct 2024 16:20:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E5=93=81=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81=20=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../productimpl/TbProductServiceImpl.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java index fb715cd5..0895dd9a 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/service/impl/productimpl/TbProductServiceImpl.java @@ -253,9 +253,13 @@ public class TbProductServiceImpl implements TbProductService { productNewVo.setLowPrice(product.getLowPrice().toString()); productNewVo.setStockNumber(Double.valueOf(product.getStockNumber())); List tbProductSkus = tbProductSkuRepository.searchSku(product.getId().toString()); - if (tbProductSkus.size() > 1) { - BigDecimal maxPrice = tbProductSkus.stream().map(TbProductSku::getSalePrice).max(BigDecimal::compareTo).get(); - productNewVo.setLowPrice("¥" +productNewVo.getLowPrice() + "~¥" + maxPrice); + if ("sku".equals(product.getTypeEnum())){ + if(tbProductSkus.size() > 1){ + BigDecimal maxPrice = tbProductSkus.stream().map(TbProductSku::getSalePrice).max(BigDecimal::compareTo).get(); + productNewVo.setLowPrice("¥" +productNewVo.getLowPrice() + "~¥" + maxPrice); + }else { + productNewVo.setLowPrice("¥" +productNewVo.getLowPrice()); + } } ViewConSku viewConSku = new ViewConSku(); viewConSku.setShopId(Integer.valueOf(product.getShopId())); @@ -433,10 +437,8 @@ public class TbProductServiceImpl implements TbProductService { product.setStatus(1); product.setCreatedAt(Instant.now().toEpochMilli()); product.setUpdatedAt(Instant.now().toEpochMilli()); - if ("sku".equals(resources.getTypeEnum())) { - List collect = resources.getSkuList().stream().map(TbProductSku::getSalePrice).sorted().collect(Collectors.toList()); - product.setLowPrice(collect.get(0)); - } + List lowPrice = resources.getSkuList().stream().map(TbProductSku::getSalePrice).sorted().collect(Collectors.toList()); + product.setLowPrice(lowPrice.get(0)); if ("group".equals(resources.getTypeEnum())) { //套餐内容 if (!resources.getGroupSnap().isEmpty()) { @@ -505,13 +507,13 @@ public class TbProductServiceImpl implements TbProductService { StringBuilder description = new StringBuilder("商品" + source.getName()); //上架 库存开关 设为推荐 if (resources.getIsHot().equals(source.getIsHot())) { - description.append((resources.getIsHot() == 0 ? ",已取消" : ",已设为") + "推荐"); + description.append(resources.getIsHot() == 0 ? ",已取消" : ",已设为").append("推荐"); } if (resources.getIsGrounding().equals(source.getIsGrounding())) { - description.append((resources.getIsGrounding() == 0 ? ",已取消" : ",已设为") + "上架"); + description.append(resources.getIsGrounding() == 0 ? ",已取消" : ",已设为").append("上架"); } if (resources.getIsStock().equals(source.getIsStock())) { - description.append((resources.getIsStock() == 0 ? ",已关闭" : ",已打开") + "库存开关"); + description.append(resources.getIsStock() == 0 ? ",已关闭" : ",已打开").append("库存开关"); } TbProduct product = new TbProduct(); //组装 @@ -540,10 +542,8 @@ public class TbProductServiceImpl implements TbProductService { product.setUpdatedAt(Instant.now().toEpochMilli()); product.setImages(resources.getImages().toString()); product.setStockNumber(resources.getStockNumber().intValue()); - if ("sku".equals(resources.getTypeEnum())) { - List collect = resources.getSkuList().stream().map(TbProductSku::getSalePrice).sorted().collect(Collectors.toList()); - product.setLowPrice(collect.get(0)); - } + List lowPrices = resources.getSkuList().stream().map(TbProductSku::getSalePrice).sorted().collect(Collectors.toList()); + product.setLowPrice(lowPrices.get(0)); if ("group".equals(resources.getTypeEnum())) { //套餐内容 if (!resources.getGroupSnap().isEmpty()) {