/**
  * @param orderNumber
  * @return 得到购买的活动包含的商品
  */
 private List<OrderItem> getOrderItemByOrderNumber(String orderNumber) {
   List<OrderItem> items = orderManageMapper.getOrderItemByOrderNumber(orderNumber);
   Map<String, String> query = new HashMap<String, String>();
   query.put("orderNumber", orderNumber);
   for (OrderItem item : items) {
     String mid = item.getMid();
     // 商品编号第二位为活动编码
     if (StringUtils.indexOf(mid, CategoryId.ACTIVITY.getAbbreviation()) == 1) {
       String id = item.getId();
       query.put("aid", id);
       List<OrderItem> containItems = orderManageMapper.getOrderItemByActivityItemId(query);
       item.setContainItems(containItems);
     }
   }
   return items;
 }
  @Transactional(propagation = Propagation.REQUIRED)
  public void updateOrderItem(OrderItem orderItem) {
    // 取得要修改的数据
    String itemId = orderItem.getId();
    String orderNumber = orderItem.getOrderNumber();
    Double priceItem = orderItem.getSellingPrice();
    Integer quantityItem = orderItem.getQuantity();
    Double actualSellingPriceItem = orderItem.getActualSellingPrice();
    // 将item要修改的数据转换成精确类型,并重新赋值给item
    BigDecimal priceDecimal = new BigDecimal(priceItem + "");
    priceDecimal = priceDecimal.setScale(2, RoundingMode.HALF_UP); // 精确到小数点2位,四舍五入
    BigDecimal actualSellingPriceDecimal = new BigDecimal(actualSellingPriceItem + "");
    actualSellingPriceDecimal =
        actualSellingPriceDecimal.setScale(2, RoundingMode.HALF_UP); // 精确到小数点2位,四舍五入
    BigDecimal quantityDecimal = new BigDecimal(quantityItem + "");
    BigDecimal subtotalDecimal = priceDecimal.multiply(quantityDecimal);
    BigDecimal totalDecimal = actualSellingPriceDecimal.multiply(quantityDecimal);
    BigDecimal savingsDecimal = subtotalDecimal.subtract(totalDecimal);
    orderItem.setActualSellingPrice(actualSellingPriceDecimal.doubleValue()); // 将用户输入的金额四舍五入
    orderItem.setSavings(savingsDecimal.doubleValue());
    orderItem.setSubtotal(subtotalDecimal.doubleValue());
    orderItem.setTotal(totalDecimal.doubleValue());
    // 取得订单基本信息和商品信息
    Order order = orderManageMapper.getOrderByOrderNumber(orderNumber);
    List<OrderItem> items = orderManageMapper.getOrderItemByOrderNumber(orderNumber);
    // 初始化订单统计要用到的精确类型
    Integer quantity = 0;
    BigDecimal subtotal = new BigDecimal("0");
    BigDecimal savings = new BigDecimal("0");
    BigDecimal total = new BigDecimal("0");
    String savingsInfo = "";
    // 重新计算订单总价
    for (OrderItem item : items) {
      // 判断item是否是要修改的,如果是用前面转换的精确类型
      if (StringUtils.equals(item.getId(), itemId)) {
        quantity += quantityItem;
        subtotal = subtotal.add(subtotalDecimal);
        savings = savings.add(savingsDecimal);
        total = total.add(totalDecimal);
        // 将所有商品的优惠信息去重合并到一起,放到订单的优惠信息中
        if (StringUtils.isNotBlank(orderItem.getSavingInfo())
            && !StringUtils.contains(savingsInfo, orderItem.getSavingInfo())) {
          savingsInfo += orderItem.getSavingInfo() + "<br>";
        }
        continue;
      }
      quantity += item.getQuantity();
      BigDecimal itemSubtotal = new BigDecimal(item.getSubtotal() + "");
      BigDecimal itemSavings = new BigDecimal(item.getSavings() + "");
      BigDecimal itemTotal = new BigDecimal(item.getTotal() + "");
      subtotal = subtotal.add(itemSubtotal);
      savings = savings.add(itemSavings);
      total = total.add(itemTotal);

      String savingInfo = item.getSavingInfo();
      // 设置优惠计算信息
      if (StringUtils.isNotBlank(savingInfo) && !StringUtils.contains(savingsInfo, savingInfo)) {
        savingsInfo += savingInfo + "<br>";
      }
    }
    order.setSavingsInfo(savingsInfo);

    order.setQuantity(quantity);
    order.setSubtotal(subtotal.doubleValue());
    order.setSavings(savings.doubleValue());
    order.setTotal(total.doubleValue());
    order.setUpdatedById(orderItem.getUpdatedById());
    order.setUpdatedByName(orderItem.getUpdatedByName());
    order.setUpdatedTime(orderItem.getUpdatedTime());
    // 将重新计算的订单统计信息放入订单对像中
    // 更新数据库
    orderManageMapper.updateOrderItem(orderItem);
    orderManageMapper.updateOrderFee(order);
  }