From b9d7e0787c3e2f0634ef7eb59d903b41e05a844a Mon Sep 17 00:00:00 2001 From: paulGao Date: Fri, 14 Oct 2022 10:31:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81?= =?UTF-8?q?=E6=A8=A1=E7=89=88/=E5=95=86=E5=93=81=E8=8D=89=E7=A8=BF?= =?UTF-8?q?=EF=BC=8C=E4=BF=9D=E5=AD=98=E6=89=B9=E5=8F=91=E8=A7=84=E5=88=99?= =?UTF-8?q?=E6=97=A0=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/DraftGoodsServiceImpl.java | 26 ++++++++++++------- .../impl/WholesaleSaleModelRenderImpl.java | 4 ++- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java index 02072469..14860643 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/DraftGoodsServiceImpl.java @@ -5,15 +5,13 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONUtil; import cn.lili.modules.goods.entity.dos.*; -import cn.lili.modules.goods.entity.dto.DraftGoodsDTO; -import cn.lili.modules.goods.entity.dto.DraftGoodsSearchParams; -import cn.lili.modules.goods.entity.dto.GoodsOperationDTO; -import cn.lili.modules.goods.entity.dto.GoodsParamsDTO; +import cn.lili.modules.goods.entity.dto.*; import cn.lili.modules.goods.entity.vos.DraftGoodsVO; import cn.lili.modules.goods.mapper.DraftGoodsMapper; import cn.lili.modules.goods.service.*; import cn.lili.modules.goods.sku.GoodsSkuBuilder; import cn.lili.mybatis.util.PageUtil; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; @@ -75,13 +73,23 @@ public class DraftGoodsServiceImpl extends ServiceImpl goodsSkus = GoodsSkuBuilder.buildBatch(new Goods(draftGoods), draftGoods.getSkuList()); - goodsSkuService.renderGoodsSkuList(goodsSkus, GoodsOperationDTO.builder().goodsTemplateFlag(true).wholesaleList(draftGoods.getWholesaleList()).salesModel(draftGoods.getSalesModel()).build()); - draftGoods.setSkuListJson(JSONUtil.toJsonStr(goodsSkus)); + // 商品参数 draftGoods.setGoodsParamsListJson(JSONUtil.toJsonStr(draftGoods.getGoodsParamsDTOList())); - this.saveOrUpdate(draftGoods); + boolean result = this.saveOrUpdate(draftGoods); + if (result) { + // 商品sku + List goodsSkus = GoodsSkuBuilder.buildBatch(new Goods(draftGoods), draftGoods.getSkuList()); + for (WholesaleDTO wholesaleDTO : draftGoods.getWholesaleList()) { + wholesaleDTO.setTemplateId(draftGoods.getId()); + } + goodsSkuService.renderGoodsSkuList(goodsSkus, GoodsOperationDTO.builder().goodsTemplateFlag(true).wholesaleList(draftGoods.getWholesaleList()).salesModel(draftGoods.getSalesModel()).build()); + LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); + updateWrapper.eq(DraftGoods::getId, draftGoods.getId()); + updateWrapper.set(DraftGoods::getSkuListJson, JSONUtil.toJsonStr(goodsSkus)); + this.update(updateWrapper); + } } @Override diff --git a/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java b/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java index 55a95bb2..d34a4ac2 100644 --- a/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/sku/render/impl/WholesaleSaleModelRenderImpl.java @@ -55,7 +55,9 @@ public class WholesaleSaleModelRenderImpl implements SalesModelRender { skus.setPrice(collect.get(0).getPrice()); skus.setCost(collect.get(0).getPrice()); } - if (Boolean.FALSE.equals(goodsOperationDTO.getGoodsTemplateFlag())) { + if (Boolean.TRUE.equals(goodsOperationDTO.getGoodsTemplateFlag())) { + wholesaleService.removeByTemplateId(goodsSkus.get(0).getGoodsId()); + } else { wholesaleService.removeByGoodsId(goodsSkus.get(0).getGoodsId()); } wholesaleService.saveOrUpdateBatch(collect);