| | |
| | | } |
| | | List<ProductInfo> products = new ArrayList<>(); |
| | | BigDecimal amount = BigDecimal.ZERO; |
| | | int count = 0; |
| | | for (ProductOrder productOrder : criteria.getProducts()) { |
| | | Product product = productService.getById(productOrder.getProductId()); |
| | | if (product == null) { |
| | |
| | | info.setCount(productOrder.getCount()); |
| | | products.add(info); |
| | | amount = BigDecimalUtils.add(amount, BigDecimalUtils.multiply(product.getPrice(), productOrder.getCount())); |
| | | count += productOrder.getCount(); |
| | | } |
| | | if (!(amount.compareTo(store.getDeliveryMinimum()) >= 0)) { |
| | | throw new BadRequestException("起送金额:" + store.getDeliveryMinimum()); |
| | |
| | | info.setAmount(amount); |
| | | info.setPayAmount(amount); |
| | | info.setPromotionAmount(BigDecimal.ZERO); |
| | | info.setDeliveryPrice(store.getDeliveryFee()); |
| | | info.setPackagingPrice(BigDecimalUtils.multiply(store.getPackagingFee(), count)); |
| | | info.setUserAddresses(userAddressService.queryUserAddress(store.getLongitude(), store.getLatitude())); |
| | | return info; |
| | | } |