!169 修复新增编辑商品无商品图片问题

Merge pull request !169 from OceansDeep/feature/pg
This commit is contained in:
OceansDeep 2022-05-30 02:42:56 +00:00 committed by Gitee
commit ceb5727337
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 35 additions and 8 deletions

View File

@ -632,6 +632,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
void renderGoodsSkuList(List<GoodsSku> goodsSkuList, GoodsOperationDTO goodsOperationDTO) { void renderGoodsSkuList(List<GoodsSku> goodsSkuList, GoodsOperationDTO goodsOperationDTO) {
// 商品销售模式渲染器 // 商品销售模式渲染器
salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderBatch(goodsSkuList, goodsOperationDTO)); salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderBatch(goodsSkuList, goodsOperationDTO));
for (GoodsSku goodsSku : goodsSkuList) {
this.renderImages(goodsSku);
}
} }
/** /**
@ -643,6 +646,21 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
void renderGoodsSku(GoodsSku goodsSku, GoodsOperationDTO goodsOperationDTO) { void renderGoodsSku(GoodsSku goodsSku, GoodsOperationDTO goodsOperationDTO) {
// 商品销售模式渲染器 // 商品销售模式渲染器
salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderSingle(goodsSku, goodsOperationDTO)); salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderSingle(goodsSku, goodsOperationDTO));
this.renderImages(goodsSku);
}
/**
* 渲染sku图片
*
* @param goodsSku
*/
void renderImages(GoodsSku goodsSku) {
JSONObject jsonObject = JSONUtil.parseObj(goodsSku.getSpecs());
List<Map<String, String>> images = jsonObject.get("images", List.class);
if (images != null && !images.isEmpty()) {
goodsSku.setThumbnail(goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getThumbnail());
goodsSku.setSmall(goodsGalleryService.getGoodsGallery(images.get(0).get("url")).getSmall());
}
} }
/** /**

View File

@ -41,6 +41,7 @@ public class WholesaleServiceImpl extends ServiceImpl<WholesaleMapper, Wholesale
public Boolean removeByGoodsId(String goodsId) { public Boolean removeByGoodsId(String goodsId) {
LambdaQueryWrapper<Wholesale> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<Wholesale> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Wholesale::getGoodsId, goodsId); queryWrapper.eq(Wholesale::getGoodsId, goodsId);
cache.remove("{wholesale}_" + goodsId);
return this.remove(queryWrapper); return this.remove(queryWrapper);
} }

View File

@ -71,18 +71,20 @@ public class GoodsSkuBuilder {
Map<String, Object> specMap = new HashMap<>(16); Map<String, Object> specMap = new HashMap<>(16);
// 原始规格项 // 原始规格项
String[] ignoreOriginKeys = {"id", "sn", "cost", "price", "quantity", "weight", IMAGES_KEY}; String[] ignoreOriginKeys = {"id", "sn", "cost", "price", "quantity", "weight"};
//获取规格信息 //获取规格信息
for (Map.Entry<String, Object> spec : skuInfo.entrySet()) { for (Map.Entry<String, Object> spec : skuInfo.entrySet()) {
//保存新增规格信息 //保存新增规格信息
if (!CollUtil.contains(Arrays.asList(ignoreOriginKeys), spec.getKey()) && spec.getValue() != null) { if (!CollUtil.contains(Arrays.asList(ignoreOriginKeys), spec.getKey()) && spec.getValue() != null) {
specMap.put(spec.getKey(), spec.getValue()); specMap.put(spec.getKey(), spec.getValue());
if (!spec.getKey().equals(IMAGES_KEY)) {
//设置商品名称 //设置商品名称
goodsName.append(" ").append(spec.getValue()); goodsName.append(" ").append(spec.getValue());
//规格简短信息 //规格简短信息
simpleSpecs.append(" ").append(spec.getValue()); simpleSpecs.append(" ").append(spec.getValue());
} }
} }
}
//设置规格信息 //设置规格信息
goodsSku.setGoodsName(goodsName.toString()); goodsSku.setGoodsName(goodsName.toString());

View File

@ -233,14 +233,20 @@ public class CheckDataRender implements CartRenderStep {
if (CollUtil.isNotEmpty(goodsGroup)) { if (CollUtil.isNotEmpty(goodsGroup)) {
goodsGroup.forEach((k, v) -> { goodsGroup.forEach((k, v) -> {
// 获取购买总数 // 获取购买总数
int sum = v.stream().mapToInt(CartSkuVO::getNum).sum(); int sum = v.stream().filter(i -> Boolean.TRUE.equals(i.getChecked())).mapToInt(CartSkuVO::getNum).sum();
int fSum = v.stream().filter(i -> Boolean.FALSE.equals(i.getChecked())).mapToInt(CartSkuVO::getNum).sum();
// 匹配符合的批发规则 // 匹配符合的批发规则
Wholesale match = wholesaleService.match(k, sum); Wholesale match = wholesaleService.match(k, sum);
if (match != null) { if (match != null) {
v.forEach(i -> { v.forEach(i -> {
// 将符合规则的商品设置批发价格 // 将符合规则的商品设置批发价格
if (Boolean.TRUE.equals(i.getChecked())) {
i.setPurchasePrice(match.getPrice()); i.setPurchasePrice(match.getPrice());
i.setSubTotal(CurrencyUtil.mul(i.getPurchasePrice(), i.getNum())); i.setSubTotal(CurrencyUtil.mul(i.getPurchasePrice(), i.getNum()));
} else {
i.setPurchasePrice(wholesaleService.match(k, fSum).getPrice());
i.setSubTotal(CurrencyUtil.mul(i.getPurchasePrice(), i.getNum()));
}
}); });
} }
}); });