Esempio n. 1
0
  @Override
  public List<DishBean> listDishMenuItemByCondition(MenuSearchConditionBean condition) {

    List<Dish> dishList = mDishDAO.getDishMenuItemListByConditon(condition);

    List<DishBean> dishBeanlList = new ArrayList<DishBean>();
    for (Dish dish : dishList) {
      DishBean dishBean = new DishBean();

      dishBean.dishId = String.valueOf(dish.getmId());
      if (dish.getmName() != null) dishBean.dishName = dish.getmName();
      if (dish.getmPrice() != null) dishBean.dishPrice = FormatUtils.formatPrice(dish.getmPrice());
      if (dish.getmImageName() != null && dish.getmDishCategory().getmRestaurant() != null)
        dishBean.dishImageUrl =
            getDishImageUrl(dish.getmImageName(), dish.getmDishCategory().getmRestaurant());

      int pageView = 0;
      int purchaseVolume = 0;
      DishRank dishRank = dish.getmDishRank();
      if (dishRank != null) {
        pageView = (int) dishRank.getmPageView();
        purchaseVolume = (int) dishRank.getmPurchaseVolume();
      }

      dishBean.rank = (double) (pageView + purchaseVolume);

      dishBeanlList.add(dishBean);
    }

    // Collections.sort(dishBeanlList, new Comparator<DishBean>() {
    //
    // public int compare(DishBean arg0, DishBean arg1) {
    // return arg0.rank.compareTo(arg1.rank);
    // }
    // });

    return dishBeanlList;
  }
Esempio n. 2
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();
  }