From 0121c546f4521e2eab7e55843d00d347f11804f1 Mon Sep 17 00:00:00 2001 From: paulGao Date: Thu, 24 Jun 2021 09:20:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E4=BF=AE=E6=94=B9=E7=B4=A2=E5=BC=95=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E5=90=8E=E6=B2=A1=E6=9C=89=E5=90=8C=E6=AD=A5=E5=88=B0?= =?UTF-8?q?=E5=95=86=E5=93=81=E5=8F=82=E6=95=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../goods/service/GoodsParamsService.java | 15 +++++++++++ .../serviceimpl/GoodsParamsServiceImpl.java | 27 ++++++++++++++++++- .../goods/ParameterManagerController.java | 10 ++++++- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/service/GoodsParamsService.java b/framework/src/main/java/cn/lili/modules/goods/service/GoodsParamsService.java index c0ea0bd1..bd8195fc 100644 --- a/framework/src/main/java/cn/lili/modules/goods/service/GoodsParamsService.java +++ b/framework/src/main/java/cn/lili/modules/goods/service/GoodsParamsService.java @@ -23,6 +23,21 @@ public interface GoodsParamsService extends IService { */ void addParams(List paramList, String goodsId); + /** + * 更新商品参数是否索引 + * + * @param paramId 参数id + * @param isIndex 是否索引 + */ + void updateParametersIsIndex(String paramId, Integer isIndex); + + /** + * 根据参数id删除已经设置的商品参数 + * + * @param paramId 参数id + */ + void deleteByParamId(String paramId); + /** * 获取商品关联参数 * diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java index 4fae7285..fc3d10ca 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java @@ -10,9 +10,10 @@ import cn.lili.modules.goods.service.CategoryParameterGroupService; import cn.lili.modules.goods.service.GoodsParamsService; import cn.lili.modules.goods.service.ParametersService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -60,6 +61,30 @@ public class GoodsParamsServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(GoodsParams::getParamId, paramId); + updateWrapper.set(GoodsParams::getIsIndex, isIndex); + this.update(updateWrapper); + } + + /** + * 根据参数id删除已经设置的商品参数 + * + * @param paramId 参数id + */ + @Override + public void deleteByParamId(String paramId) { + this.remove(new QueryWrapper().eq("param_id", paramId)); + } + @Override public List getGoodsParamsByGoodsId(String goodsId) { return this.list(new LambdaQueryWrapper().eq(GoodsParams::getGoodsId, goodsId)); diff --git a/manager-api/src/main/java/cn/lili/controller/goods/ParameterManagerController.java b/manager-api/src/main/java/cn/lili/controller/goods/ParameterManagerController.java index 2d746b23..8555e5c9 100644 --- a/manager-api/src/main/java/cn/lili/controller/goods/ParameterManagerController.java +++ b/manager-api/src/main/java/cn/lili/controller/goods/ParameterManagerController.java @@ -1,10 +1,11 @@ package cn.lili.controller.goods; import cn.lili.common.enums.ResultCode; -import cn.lili.common.exception.ServiceException; import cn.lili.common.enums.ResultUtil; +import cn.lili.common.exception.ServiceException; import cn.lili.common.vo.ResultMessage; import cn.lili.modules.goods.entity.dos.Parameters; +import cn.lili.modules.goods.service.GoodsParamsService; import cn.lili.modules.goods.service.ParametersService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -28,6 +29,9 @@ public class ParameterManagerController { @Autowired private ParametersService parametersService; + @Autowired + private GoodsParamsService goodsParamsService; + @ApiOperation(value = "添加参数") @PostMapping public ResultMessage save(@Valid Parameters parameters) { @@ -44,6 +48,9 @@ public class ParameterManagerController { public ResultMessage update(@Valid Parameters parameters) { if (parametersService.updateById(parameters)) { + if (parameters.getIsIndex() != null) { + goodsParamsService.updateParametersIsIndex(parameters.getId(), parameters.getIsIndex()); + } return ResultUtil.data(parameters); } throw new ServiceException(ResultCode.PARAMETER_UPDATE_ERROR); @@ -54,6 +61,7 @@ public class ParameterManagerController { @DeleteMapping(value = "/{id}") public ResultMessage delById(@PathVariable String id) { parametersService.removeById(id); + goodsParamsService.deleteByParamId(id); return ResultUtil.success(); } From c9b7ee2c81a983bb41ae635ad1632b058f404d8d Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 24 Jun 2021 10:57:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=20=E5=95=86=E5=93=81=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/goods/entity/dos/DraftGoods.java | 9 +- .../modules/goods/entity/vos/SpecValueVO.java | 18 +++- .../serviceimpl/GoodsParamsServiceImpl.java | 7 +- .../serviceimpl/GoodsSkuServiceImpl.java | 83 ++++++++++--------- .../PlatformViewDataServiceImpl.java | 3 - .../goods/SpecificationStoreController.java | 3 +- 6 files changed, 63 insertions(+), 60 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java index 23e0a4a3..df07486c 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/DraftGoods.java @@ -64,6 +64,10 @@ public class DraftGoods extends BaseEntity { @ApiModelProperty(value = "详情") private String intro; + + @ApiModelProperty(value = "商品移动端详情") + private String mobileIntro; + @Max(value = 99999999, message = "价格不能超过99999999") @ApiModelProperty(value = "商品价格") private Double price; @@ -114,11 +118,6 @@ public class DraftGoods extends BaseEntity { @ApiModelProperty(value = "是否自营") private Boolean selfOperated; - /** - * 商品移动端详情 - */ - @ApiModelProperty(value = "商品移动端详情") - private String mobileIntro; @ApiModelProperty(value = "商品视频") private String goodsVideo; diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/vos/SpecValueVO.java b/framework/src/main/java/cn/lili/modules/goods/entity/vos/SpecValueVO.java index 79ee16af..81bbc39b 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/vos/SpecValueVO.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/vos/SpecValueVO.java @@ -26,14 +26,24 @@ public class SpecValueVO implements Serializable { @ApiModelProperty(value = "规格值") private String specValue; - /** - * 规格类型,1图片 0 非图片 - */ @ApiModelProperty(value = "该规格是否有图片,1 有 0 没有") private Integer specType; /** * 规格图片 */ @ApiModelProperty(value = "规格的图片") - private List specImage; + private List specImage; + + @Data + public static class SpecImages implements Serializable { + + private static final long serialVersionUID = 1816357809660916086L; + + private String url; + + private String name; + + private String status; + + } } diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java index 4fae7285..93296051 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsParamsServiceImpl.java @@ -2,7 +2,6 @@ package cn.lili.modules.goods.serviceimpl; import cn.lili.modules.goods.entity.dos.CategoryParameterGroup; import cn.lili.modules.goods.entity.dos.GoodsParams; -import cn.lili.modules.goods.entity.dos.Parameters; import cn.lili.modules.goods.entity.vos.GoodsParamsGroupVO; import cn.lili.modules.goods.entity.vos.GoodsParamsVO; import cn.lili.modules.goods.mapper.GoodsParamsMapper; @@ -12,7 +11,6 @@ import cn.lili.modules.goods.service.ParametersService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -38,8 +36,6 @@ public class GoodsParamsServiceImpl extends ServiceImpl paramList, String goodsId) { @@ -48,12 +44,11 @@ public class GoodsParamsServiceImpl extends ServiceImpl i //商品相册 @Autowired private GoodsGalleryService goodsGalleryService; - //规格 - @Autowired - private SpecificationService specificationService; //缓存 @Autowired private StringRedisTemplate stringRedisTemplate; @@ -317,33 +316,30 @@ public class GoodsSkuServiceImpl extends ServiceImpl i @Override public GoodsSkuVO getGoodsSkuVO(GoodsSku goodsSku) { + //厨师还商品 GoodsSkuVO goodsSkuVO = new GoodsSkuVO(goodsSku); + //获取sku信息 JSONObject jsonObject = JSONUtil.parseObj(goodsSku.getSpecs()); + //用于接受sku信息 List specValueVOS = new ArrayList<>(); + //用于接受sku相册 List goodsGalleryList = new ArrayList<>(); -// for (Map.Entry entry : jsonObject.entrySet()) { -// SpecValueVO s = new SpecValueVO(); -// if (entry.getKey().equals("images")) { -// s.setSpecName(entry.getKey()); -// if (entry.getValue().toString().contains("url")) { -// List specImages = JSONUtil.toList(JSONUtil.parseArray(entry.getValue()), SpecValueVO.SpecImages.class); -// s.setSpecImage(specImages); -// goodsGalleryList = specImages.stream().map(SpecValueVO.SpecImages::getUrl).collect(Collectors.toList()); -// } -// } else { -// SpecificationVO specificationVO = new SpecificationVO(); -// specificationVO.setSpecName(entry.getKey()); -// specificationVO.setStoreId(goodsSku.getStoreId()); -// specificationVO.setCategoryPath(goodsSku.getCategoryPath()); -// Specification specification = specificationService.addSpecification(specificationVO); -// s.setSpecNameId(specification.getId()); -// SpecValues specValues = specValuesService.getSpecValues(entry.getValue().toString(), specification.getId()); -// s.setSpecValueId(specValues.getId()); -// s.setSpecName(entry.getKey()); -// s.setSpecValue(entry.getValue().toString()); -// } -// specValueVOS.add(s); -// } + //循环提交的sku表单 + for (Map.Entry entry : jsonObject.entrySet()) { + SpecValueVO specValueVO = new SpecValueVO(); + if (entry.getKey().equals("images")) { + specValueVO.setSpecName(entry.getKey()); + if (entry.getValue().toString().contains("url")) { + List specImages = JSONUtil.toList(JSONUtil.parseArray(entry.getValue()), SpecValueVO.SpecImages.class); + specValueVO.setSpecImage(specImages); + goodsGalleryList = specImages.stream().map(SpecValueVO.SpecImages::getUrl).collect(Collectors.toList()); + } + } else { + specValueVO.setSpecName(entry.getKey()); + specValueVO.setSpecValue(entry.getValue().toString()); + } + specValueVOS.add(specValueVO); + } goodsSkuVO.setGoodsGalleryList(goodsGalleryList); goodsSkuVO.setSpecList(specValueVOS); return goodsSkuVO; @@ -603,29 +599,34 @@ public class GoodsSkuServiceImpl extends ServiceImpl i List attributes = new ArrayList<>(); //获取规格信息 - for (Map.Entry m : map.entrySet()) { + for (Map.Entry spec : map.entrySet()) { //保存规格信息 - if (m.getKey().equals("id") || m.getKey().equals("sn") || m.getKey().equals("cost") || m.getKey().equals("price") || m.getKey().equals("quantity") || m.getKey().equals("weight")) { + if (spec.getKey().equals("id") || spec.getKey().equals("sn") || spec.getKey().equals("cost") + || spec.getKey().equals("price") || spec.getKey().equals("quantity") + || spec.getKey().equals("weight")) { continue; } else { - specMap.put(m.getKey(), m.getValue()); - if (m.getKey().equals("images")) { + specMap.put(spec.getKey(), spec.getValue()); + if (spec.getKey().equals("images")) { //设置规格商品缩略图 - List> images = (List>) m.getValue(); + List> images = (List>) spec.getValue(); if (images == null || images.isEmpty()) { - throw new ServiceException("sku图片至少为一个"); + continue; + } + //设置规格商品缩略图 + //如果规格没有图片,则用商品图片复盖。有则增加规格图片,放在商品图片集合之前 + if (spec.getValue() != null && StringUtils.isNotEmpty(spec.getValue().toString())) { + thumbnail = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getThumbnail(); + small = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getSmall(); + } else { + //设置商品名称 + goodsName.append(" ").append(spec.getValue()); + //规格简短信息 + simpleSpecs.append(" ").append(spec.getValue()); } - thumbnail = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getThumbnail(); - small = goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getSmall(); - } else { - //设置商品名称 - goodsName.append(" ").append(m.getValue()); - //规格简短信息 - simpleSpecs.append(" ").append(m.getValue()); } } } - //设置规格信息 sku.setGoodsName(goodsName.toString()); sku.setThumbnail(thumbnail); @@ -656,4 +657,4 @@ public class GoodsSkuServiceImpl extends ServiceImpl i public void setGoodsIndexService(EsGoodsIndexService goodsIndexService) { this.goodsIndexService = goodsIndexService; } -} \ No newline at end of file +} diff --git a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewDataServiceImpl.java b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewDataServiceImpl.java index 8d69e54f..2d358804 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewDataServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewDataServiceImpl.java @@ -4,7 +4,6 @@ import cn.lili.common.cache.Cache; import cn.lili.common.cache.CachePrefix; import cn.lili.common.security.enums.UserEnums; import cn.lili.common.utils.CurrencyUtil; -import cn.lili.common.utils.DateUtil; import cn.lili.config.properties.StatisticsProperties; import cn.lili.modules.base.entity.enums.ClientTypeEnum; import cn.lili.modules.member.entity.vo.MemberDistributionVO; @@ -221,8 +220,6 @@ public class PlatformViewDataServiceImpl extends ServiceImpl getSpecifications(String categoryId) { + public List getSpecifications(@PathVariable String categoryId) { return categorySpecificationService.getCategorySpecList(categoryId); } From 158234412c99c89da291c607460a2fda7990c71b Mon Sep 17 00:00:00 2001 From: Chopper Date: Thu, 24 Jun 2021 11:18:13 +0800 Subject: [PATCH 3/3] =?UTF-8?q?uv=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../statistics/serviceimpl/PlatformViewDataServiceImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewDataServiceImpl.java b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewDataServiceImpl.java index 2d358804..c39cf71e 100644 --- a/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewDataServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/statistics/serviceimpl/PlatformViewDataServiceImpl.java @@ -51,6 +51,9 @@ public class PlatformViewDataServiceImpl extends ServiceImpl