| | |
| | | if(totalAmount.doubleValue() <= 0){//假如总价小于等于0,则支付0.01元 |
| | | totalAmount = new BigDecimal(0.01); |
| | | } |
| | | order.setTotalAmount(totalAmount.add(p.getPacking()).add(transportFee)); |
| | | order.setTotalAmount(totalAmount); |
| | | |
| | | order.setCustomer(address.getName()); |
| | | order.setCustomerTel(address.getTel()); |
| | |
| | | BigDecimal couponAmount = calculateCoupon(memberCouponAmount, t.getTotal() |
| | | , flowerAmount, t.getNum(), t.getPrice(), isLastOne, usedCouponAmount); |
| | | t.setCouponAmount(couponAmount);//每扎平摊的优惠券面值 |
| | | t.setRealPrice(t.getPrice().subtract(couponAmount));//退款时使用的真实成交价 |
| | | t.setRealPrice(t.getPrice().subtract(couponAmount));//退款时使用的真实成交单价 |
| | | |
| | | usedCouponAmount = usedCouponAmount.add(couponAmount.multiply(BigDecimal.valueOf(t.getNum()))); |
| | | t.setCouponAmountTotal(couponAmount.multiply(BigDecimal.valueOf(t.getNum()))); |
| | | if(isLastOne){ |
| | | t.setCouponAmountTotal(memberCouponAmount.subtract(usedCouponAmount)); |
| | | } else { |
| | | usedCouponAmount = usedCouponAmount.add(t.getCouponAmountTotal()); |
| | | } |
| | | t.setRealTotal(t.getTotal().subtract(t.getCouponAmountTotal())); |
| | | |
| | | t.create(userId); |
| | | orderItemMapper.insert(t); |
| | |
| | | BigDecimal subCoupon = couponAmount.subtract(usedCouponAmount);//占有的优惠券面值 |
| | | return subCoupon.divide(BigDecimal.valueOf(num), 2, RoundingMode.HALF_UP); |
| | | } |
| | | BigDecimal radio = itemTotalAmount.divide(totalAmount, 2, RoundingMode.HALF_UP);//计算该商品总价在订单中的占比 |
| | | |
| | | /*BigDecimal radio = itemTotalAmount.divide(totalAmount, 2, RoundingMode.HALF_UP);//计算该商品总价在订单中的占比 |
| | | BigDecimal subCoupon = couponAmount.multiply(radio);//占有的优惠券面值 |
| | | return subCoupon.divide(BigDecimal.valueOf(num), 2, RoundingMode.HALF_UP); |
| | | return subCoupon.divide(BigDecimal.valueOf(num), 2, RoundingMode.HALF_UP);*/ |
| | | |
| | | //不能分步计算,分步计算会有精度问题 |
| | | return couponAmount.multiply(itemTotalAmount).divide(totalAmount.multiply(BigDecimal.valueOf(num)), 2, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | private CouponRecordDO useCouponRecord(String orderId, BigDecimal amount, String couponRecordId){ |
| | |
| | | orderIds.add(o.getId()); |
| | | } |
| | | |
| | | List<OrderItem> itemList = orderItemMapper.selectList( |
| | | new QueryWrapper<OrderItem>().in("order_id", orderIds)); |
| | | List<OrderItemListDTO> itemList = orderItemMapper.getOrderItems(orderIds); |
| | | Map<String, List<OrderItemListDTO>> map = new HashMap<>(); |
| | | for (OrderItem oi : itemList) { |
| | | for (OrderItemListDTO oi : itemList) { |
| | | String orderId = oi.getOrderId(); |
| | | List<OrderItemListDTO> ll = map.computeIfAbsent(orderId, k -> new ArrayList<>()); |
| | | OrderItemListDTO d = new OrderItemListDTO(); |
| | |
| | | if(llc == null){ |
| | | llc = new OrderCheckLocationListDTO(); |
| | | BeanUtils.copyProperties(c, llc); |
| | | rMap.put(locationId, llc); |
| | | llc.setTotalAmount(new BigDecimal(0)); |
| | | |
| | | rMap.put(locationId, llc); |
| | | result.add(llc); |
| | | } |
| | | |