From 87804eba1b006c1188e3324e96fa779b2681e887 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 2 Dec 2024 15:43:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E5=AE=A2=E4=B8=8B=E5=8D=95=20?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=E5=9B=9E=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ysk/cashier/pojo/product/TbProduct.java | 4 +++ .../productimpl/TbProductServiceImpl.java | 19 ++++++++----- .../cn/ysk/cashier/vo/TbProductNewVo.java | 27 +++++++++++-------- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java index 5fef345e..3620eb27 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/pojo/product/TbProduct.java @@ -72,6 +72,10 @@ public class TbProduct implements Serializable { @ApiModelProperty(value = "单位Id") private Integer unitId; + @Transient + @TableField(exist = false) + private String unitName; + @Column(name = "`cover_img`") @ApiModelProperty(value = "商品封面图") private String coverImg; 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 47fbed60..cc574cfc 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 @@ -321,7 +321,7 @@ public class TbProductServiceImpl implements TbProductService { BeanUtils.copyProperties(tbProduct, tbProductVo); //套餐 - if(tbProduct.getType().equals("package")){ + if (tbProduct.getType().equals("package")) { if (tbProduct.getGroupSnap() == null) { tbProductVo.setProGroupVo(null); } else { @@ -448,7 +448,7 @@ public class TbProductServiceImpl implements TbProductService { } } } - if("package".equals(resources.getType())){ + if ("package".equals(resources.getType())) { //套餐内容 if (!resources.getProGroupVo().isEmpty()) { product.setGroupSnap(ListUtil.listToJsonString(resources.getProGroupVo())); @@ -563,7 +563,7 @@ public class TbProductServiceImpl implements TbProductService { } else { product.setCategoryId(resources.getCategoryId().toString()); } - if("package".equals(resources.getType())){ + if ("package".equals(resources.getType())) { //套餐内容 if (CollectionUtil.isNotEmpty(resources.getProGroupVo())) { product.setGroupSnap(ListUtil.listToJsonString(resources.getProGroupVo())); @@ -771,7 +771,7 @@ public class TbProductServiceImpl implements TbProductService { com.baomidou.mybatisplus.extension.plugins.pagination.Page page1 = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page, size); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("is_del", 0) - .eq(false,"type", "coupon") + .eq(false, "type", "coupon") .eq("shop_id", shopId) .eq("status", 1) .eq("is_del", 0) @@ -790,12 +790,19 @@ public class TbProductServiceImpl implements TbProductService { if (productId != null) { queryWrapper.eq("id", productId); } - + Map unitMap = new HashMap<>(); com.baomidou.mybatisplus.extension.plugins.pagination.Page tbProductPage = productMapper.selectPage(page1, queryWrapper); tbProductPage.getRecords().forEach(item -> { - if("package".equals(item.getType())){ + if ("package".equals(item.getType())) { item.setProGroupVo(JSONUtil.parseJSONStrTList(item.getGroupSnap(), ProductGroupVo.class)); } + if (item.getUnitId() != null) { + if (!unitMap.containsKey(item.getUnitId())) { + TbShopUnit tbShopUnit = tbShopUnitRepository.searchUnit(item.getUnitId()); + unitMap.put(item.getId(), tbShopUnit.getName()); + } + item.setUnitName(unitMap.get(item.getUnitId())); + } TbProductSkuResult skuResult = productSkuResultRepository.findById(item.getId()).orElse(null); List tbProductSkus = producSkutMapper.selectList(new LambdaQueryWrapper().eq(TbProductSku::getIsDel, 0) .eq(TbProductSku::getIsPauseSale, 0) diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java index 34e15dcf..a83ae2fe 100644 --- a/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java +++ b/eladmin-system/src/main/java/cn/ysk/cashier/vo/TbProductNewVo.java @@ -28,6 +28,7 @@ public class TbProductNewVo { private String name; //售价 private String lowPrice; + private String type; //类型 单规格/多规格 private String typeEnum; //库存 @@ -53,26 +54,30 @@ public class TbProductNewVo { private Integer sort; public void setTypeEnum(String typeEnum) { - switch (typeEnum) { + switch (this.type) { case "normal": - this.typeEnum = "单规格"; - break; - case "sku": - this.typeEnum = "多规格"; - break; - case "weight": + this.typeEnum = "普通商品"; + case "weigh": this.typeEnum = "称重商品"; break; - case "currentPrice": - this.typeEnum = "时价商品"; + case "coupon": + this.typeEnum = "优惠券"; break; - case "group": - this.typeEnum = "套餐商品/团购卷"; + case "package": + this.typeEnum = "套餐商品"; break; default: this.typeEnum = typeEnum; break; } + switch (typeEnum) { + case "normal": + this.typeEnum = this.typeEnum + ":单规格"; + break; + case "sku": + this.typeEnum = this.typeEnum + "多规格"; + break; + } } @Data