Пример #1
0
  public OrderFormBean(OrderForm orderForm) {

    this.orderFormId = String.valueOf(orderForm.getmId());

    if (orderForm.getmTrade() != null) {
      if (orderForm.getmTrade().getmGetType() != null)
        this.getType = String.valueOf(orderForm.getmTrade().getmGetType());
      if (orderForm.getmTrade().getmCustomerName() != null)
        this.customerName = orderForm.getmTrade().getmCustomerName();
      if (orderForm.getmTrade().getmCustomerAddress() != null)
        this.customerAddress = orderForm.getmTrade().getmCustomerAddress();
      if (orderForm.getmTrade().getmCustomerPhone() != null)
        this.customerPhone = orderForm.getmTrade().getmCustomerPhone();
    }
    if (orderForm.getmCode() != null) this.orderFormCode = orderForm.getmCode();
    if (orderForm.getmTaxFee() != null)
      this.taxFee = FormatUtils.formatPrice(orderForm.getmTaxFee());
    if (orderForm.getmTipsFee() != null)
      this.tipsFee = FormatUtils.formatPrice(orderForm.getmTipsFee());
    if (orderForm.getmDeliveryFee() != null)
      this.deliveryFee = FormatUtils.formatPrice(orderForm.getmDeliveryFee());
    if (orderForm.getmDiscountFee() != null)
      this.discountFee = FormatUtils.formatPrice(orderForm.getmDiscountFee());
    if (orderForm.getmPrice() != null)
      this.orderFormPrice = FormatUtils.formatPrice(orderForm.getmPrice());

    if (orderForm.getmStatus() != null) this.status = orderForm.getmStatus();

    if (orderForm.getmRestConfirmedTimestamp() != null)
      this.orderFormRestConfirmedDateTime =
          TimestampUtil.formatTimestamp(orderForm.getmRestConfirmedTimestamp());
    if (orderForm.getmCancelTimestamp() != null)
      this.orderFormCancelDateTime = TimestampUtil.formatTimestamp(orderForm.getmCancelTimestamp());
    if (orderForm.getmCallDeliveryTimestamp() != null)
      this.orderFormCallDeliveryDateTime =
          TimestampUtil.formatTimestamp(orderForm.getmCallDeliveryTimestamp());
    if (orderForm.getmDriverConfirmedTimestamp() != null)
      this.orderFormDriverConfirmedDateTime =
          TimestampUtil.formatTimestamp(orderForm.getmDriverConfirmedTimestamp());
    if (orderForm.getmArrivedTimestamp() != null)
      this.orderFormArrivedDateTime =
          TimestampUtil.formatTimestamp(orderForm.getmArrivedTimestamp());
    if (orderForm.getmCreateTimestamp() != null)
      this.orderFormCreateDateTime = TimestampUtil.formatTimestamp(orderForm.getmCreateTimestamp());

    if (orderForm.getmRestConfirmedTimestamp() != null)
      this.orderFormRestConfirmedTimestamp = orderForm.getmRestConfirmedTimestamp();
    if (orderForm.getmCancelTimestamp() != null)
      this.orderFormCancelTimestamp = orderForm.getmCancelTimestamp();
    if (orderForm.getmCallDeliveryTimestamp() != null)
      this.orderFormCallDeliveryTimestamp = orderForm.getmCallDeliveryTimestamp();
    if (orderForm.getmDriverConfirmedTimestamp() != null)
      this.orderFormDriverConfirmedTimestamp = orderForm.getmDriverConfirmedTimestamp();
    if (orderForm.getmArrivedTimestamp() != null)
      this.orderFormArrivedTimestamp = orderForm.getmArrivedTimestamp();
    if (orderForm.getmCreateTimestamp() != null)
      this.orderFormCreateTimestamp = orderForm.getmCreateTimestamp();

    List<OrderItemBean> orderItemBeanList = new ArrayList<OrderItemBean>();
    for (OrderItem orderItem : orderForm.getmOrderItemSet()) {

      OrderItemBean orderItemBean = new OrderItemBean();

      orderItemBean.setDishId(String.valueOf(orderItem.getmId()));
      ;
      if (orderItem.getmDishName() != null) orderItemBean.setDishName(orderItem.getmDishName());
      ;
      if (orderItem.getmDishImageUrl() != null)
        orderItemBean.setDishImageUrl(orderItem.getmDishImageUrl());
      ;
      if (orderItem.getmDishAmount() != null)
        orderItemBean.setDishAmount(orderItem.getmDishAmount());
      ;
      if (orderItem.getmDishPrice() != null) orderItemBean.setDishPrice(orderItem.getmDishPrice());
      ;
      if (orderItem.getmPrice() != null)
        orderItemBean.setOrderItemPrice(FormatUtils.formatPrice(orderItem.getmPrice()));
      ;

      List<DishOptionItemBean> dishOptionItemBeanList = new ArrayList<DishOptionItemBean>();
      for (OrderItemIngredient ingredient : orderItem.getmOrderItemIngredientSet()) {

        DishOptionItemBean ingredientBean = new DishOptionItemBean();

        if (ingredient.getmName() != null) ingredientBean.setName(ingredient.getmName());
        if (ingredient.getmPrice() != null)
          ingredientBean.setPrice(FormatUtils.formatPrice(ingredient.getmPrice()));

        dishOptionItemBeanList.add(ingredientBean);
      }
      orderItemBean.setOrderItemOptionItemArray(dishOptionItemBeanList);

      orderItemBeanList.add(orderItemBean);
    }

    this.orderItemArray = orderItemBeanList;

    this.curTimestamp = TimestampUtil.getCurrentTimestamp();
  }