fix: 修复商品模版/商品草稿,保存批发规则无效问题
This commit is contained in:
parent
4ea6660402
commit
b9d7e0787c
@ -5,15 +5,13 @@ import cn.hutool.core.collection.CollUtil;
|
|||||||
import cn.hutool.json.JSONArray;
|
import cn.hutool.json.JSONArray;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import cn.lili.modules.goods.entity.dos.*;
|
import cn.lili.modules.goods.entity.dos.*;
|
||||||
import cn.lili.modules.goods.entity.dto.DraftGoodsDTO;
|
import cn.lili.modules.goods.entity.dto.*;
|
||||||
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.vos.DraftGoodsVO;
|
import cn.lili.modules.goods.entity.vos.DraftGoodsVO;
|
||||||
import cn.lili.modules.goods.mapper.DraftGoodsMapper;
|
import cn.lili.modules.goods.mapper.DraftGoodsMapper;
|
||||||
import cn.lili.modules.goods.service.*;
|
import cn.lili.modules.goods.service.*;
|
||||||
import cn.lili.modules.goods.sku.GoodsSkuBuilder;
|
import cn.lili.modules.goods.sku.GoodsSkuBuilder;
|
||||||
import cn.lili.mybatis.util.PageUtil;
|
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.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -75,13 +73,23 @@ public class DraftGoodsServiceImpl extends ServiceImpl<DraftGoodsMapper, DraftGo
|
|||||||
draftGoods.setSmall(goodsGallery.getSmall());
|
draftGoods.setSmall(goodsGallery.getSmall());
|
||||||
draftGoods.setThumbnail(goodsGallery.getThumbnail());
|
draftGoods.setThumbnail(goodsGallery.getThumbnail());
|
||||||
}
|
}
|
||||||
|
// 商品图片
|
||||||
draftGoods.setGoodsGalleryListJson(JSONUtil.toJsonStr(draftGoods.getGoodsGalleryList()));
|
draftGoods.setGoodsGalleryListJson(JSONUtil.toJsonStr(draftGoods.getGoodsGalleryList()));
|
||||||
// 检查是否需要生成索引
|
// 商品参数
|
||||||
List<GoodsSku> 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()));
|
draftGoods.setGoodsParamsListJson(JSONUtil.toJsonStr(draftGoods.getGoodsParamsDTOList()));
|
||||||
this.saveOrUpdate(draftGoods);
|
boolean result = this.saveOrUpdate(draftGoods);
|
||||||
|
if (result) {
|
||||||
|
// 商品sku
|
||||||
|
List<GoodsSku> 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<DraftGoods> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
updateWrapper.eq(DraftGoods::getId, draftGoods.getId());
|
||||||
|
updateWrapper.set(DraftGoods::getSkuListJson, JSONUtil.toJsonStr(goodsSkus));
|
||||||
|
this.update(updateWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -55,7 +55,9 @@ public class WholesaleSaleModelRenderImpl implements SalesModelRender {
|
|||||||
skus.setPrice(collect.get(0).getPrice());
|
skus.setPrice(collect.get(0).getPrice());
|
||||||
skus.setCost(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.removeByGoodsId(goodsSkus.get(0).getGoodsId());
|
||||||
}
|
}
|
||||||
wholesaleService.saveOrUpdateBatch(collect);
|
wholesaleService.saveOrUpdateBatch(collect);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user