增加商品批发销售模式的处理。优化生成商品sku的结构。
This commit is contained in:
		
							parent
							
								
									8fbcad8856
								
							
						
					
					
						commit
						17c7552f7f
					
				| @ -632,6 +632,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i | ||||
|     void renderGoodsSkuList(List<GoodsSku> goodsSkuList, GoodsOperationDTO 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) { | ||||
|         // 商品销售模式渲染器 | ||||
|         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()); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | ||||
| @ -41,6 +41,7 @@ public class WholesaleServiceImpl extends ServiceImpl<WholesaleMapper, Wholesale | ||||
|     public Boolean removeByGoodsId(String goodsId) { | ||||
|         LambdaQueryWrapper<Wholesale> queryWrapper = new LambdaQueryWrapper<>(); | ||||
|         queryWrapper.eq(Wholesale::getGoodsId, goodsId); | ||||
|         cache.remove("{wholesale}_" + goodsId); | ||||
|         return this.remove(queryWrapper); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -71,18 +71,20 @@ public class GoodsSkuBuilder { | ||||
|         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()) { | ||||
|             //保存新增规格信息 | ||||
|             if (!CollUtil.contains(Arrays.asList(ignoreOriginKeys), spec.getKey()) && spec.getValue() != null) { | ||||
|                 specMap.put(spec.getKey(), spec.getValue()); | ||||
|                 if (!spec.getKey().equals(IMAGES_KEY)) { | ||||
|                     //设置商品名称 | ||||
|                     goodsName.append(" ").append(spec.getValue()); | ||||
|                     //规格简短信息 | ||||
|                     simpleSpecs.append(" ").append(spec.getValue()); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         //设置规格信息 | ||||
|         goodsSku.setGoodsName(goodsName.toString()); | ||||
| 
 | ||||
|  | ||||
| @ -233,14 +233,20 @@ public class CheckDataRender implements CartRenderStep { | ||||
|         if (CollUtil.isNotEmpty(goodsGroup)) { | ||||
|             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); | ||||
|                 if (match != null) { | ||||
|                     v.forEach(i -> { | ||||
|                         // 将符合规则的商品设置批发价格 | ||||
|                         if (Boolean.TRUE.equals(i.getChecked())) { | ||||
|                             i.setPurchasePrice(match.getPrice()); | ||||
|                             i.setSubTotal(CurrencyUtil.mul(i.getPurchasePrice(), i.getNum())); | ||||
|                         } else { | ||||
|                             i.setPurchasePrice(wholesaleService.match(k, fSum).getPrice()); | ||||
|                             i.setSubTotal(CurrencyUtil.mul(i.getPurchasePrice(), i.getNum())); | ||||
|                         } | ||||
|                     }); | ||||
|                 } | ||||
|             }); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 paulGao
						paulGao