diff --git a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardCarServiceImpl.java b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardCarServiceImpl.java index 94c6e3754..35fc6f96d 100644 --- a/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardCarServiceImpl.java +++ b/pjcloud-hardware/pjcloud-hardware-biz/src/main/java/com/bsd/pjcloud/hard/service/impl/order/HardCarServiceImpl.java @@ -171,24 +171,46 @@ public class HardCarServiceImpl extends ServiceImpl { - // 查询超市商品 AtomicInteger supermarketTotalPrice = new AtomicInteger(); - List supList = supermarketUnitSkuService.getSupermarketUnits(productIds).getData(); - for (HardCreateCarDto v : list) { - supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> { - Integer price = getSupermarket(spu); - if (ObjectUtil.isNotEmpty(v.getProductCount()) && !ObjectUtil.equals(v.getProductCount(), 0)) { - // 按数量 - int itemTotalPrice = v.getProductCount() * price; - supermarketTotalPrice.addAndGet(itemTotalPrice); - } else if (ObjectUtil.isNotEmpty(v.getProductWeight()) && v.getProductWeight().compareTo(BigDecimal.valueOf(0)) != 0) { - // 按重量 - // 向上取整 - int itemTotalPrice = v.getProductWeight().multiply(BigDecimal.valueOf(price)).setScale(0, RoundingMode.CEILING).intValue(); - supermarketTotalPrice.addAndGet(itemTotalPrice); - } - }); + // 线上 + if (ObjectUtil.equals(HardOrderTypeEnum.RESERVE, orderType)) { + List skuList = remoteShopSkuService.getSelectListAll(productIds).getData(); + for (HardCreateCarDto v : list) { + skuList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(sku -> { + Integer price = getSupermarket(sku); + if (ObjectUtil.isNotEmpty(v.getProductCount()) && !ObjectUtil.equals(v.getProductCount(), 0)) { + // 按数量 + int itemTotalPrice = v.getProductCount() * price; + supermarketTotalPrice.addAndGet(itemTotalPrice); + } else if (ObjectUtil.isNotEmpty(v.getProductWeight()) && v.getProductWeight().compareTo(BigDecimal.valueOf(0)) != 0) { + // 按重量 + // 向上取整 + int itemTotalPrice = v.getProductWeight().multiply(BigDecimal.valueOf(price)).setScale(0, RoundingMode.CEILING).intValue(); + supermarketTotalPrice.addAndGet(itemTotalPrice); + } + }); + } + } + // 线下 + else { + List supList = supermarketUnitSkuService.getSupermarketUnits(productIds).getData(); + for (HardCreateCarDto v : list) { + supList.stream().filter(i -> ObjectUtil.equals(i.getId(), v.getProductId())).findFirst().ifPresent(spu -> { + Integer price = getSupermarket(spu); + if (ObjectUtil.isNotEmpty(v.getProductCount()) && !ObjectUtil.equals(v.getProductCount(), 0)) { + // 按数量 + int itemTotalPrice = v.getProductCount() * price; + supermarketTotalPrice.addAndGet(itemTotalPrice); + } else if (ObjectUtil.isNotEmpty(v.getProductWeight()) && v.getProductWeight().compareTo(BigDecimal.valueOf(0)) != 0) { + // 按重量 + // 向上取整 + int itemTotalPrice = v.getProductWeight().multiply(BigDecimal.valueOf(price)).setScale(0, RoundingMode.CEILING).intValue(); + supermarketTotalPrice.addAndGet(itemTotalPrice); + } + }); + } } yield supermarketTotalPrice.get(); }