Exemplo n.º 1
0
  @Override
  public List<NMenuItemBean> menuItemDishAndReviewsByCondition(MenuSearchConditionBean condition) {

    Map<String, String> results = mDishDAO.getDishAndReviewsMenuItemsByConditon(condition);
    List<NMenuItemBean> list = new ArrayList<NMenuItemBean>(results.size());
    for (String key : results.keySet()) {
      String type = key.substring(0, 1);
      String id = key.substring(1);
      NMenuItemBean bean = null;
      if (ParameterConstant.MENU_ITEM_TYPE_DISH.equals(type)) {
        NMenuItemDishBean _bean = mDishDAO.getDishMenuItemById(id);
        if (StringUtil.isEmpty(_bean.dishImageUrl)) continue;
        _bean.dishImageUrl = AwsS3Utils.getAwsS3RestaurantResUrl() + _bean.dishImageUrl;
        bean = _bean;
      } else {
        NMenuItemReviewBean _bean = mReviewDAO.getReviewMenuItemById(id);
        DetachedCriteria detachedCriteria = DetachedCriteria.forClass(ReviewItem.class);
        detachedCriteria.add(Restrictions.eq("mReview.mId", Long.parseLong(_bean.reviewId)));
        List<ReviewItem> reviewItems =
            mReviewDAO.findByCriteria(detachedCriteria, ReviewItem.class);
        List<NMenuItemReviewItemBean> urls =
            new ArrayList<NMenuItemReviewItemBean>(reviewItems.size());
        for (ReviewItem reviewItem : reviewItems) {

          Dish dish = mReviewDAO.findById(Dish.class, Long.valueOf(reviewItem.getmDishId()));
          NMenuItemReviewItemBean itemBean =
              new NMenuItemReviewItemBean(
                  AwsS3Utils.getAwsS3RootResUrl() + reviewItem.getmImageUrl());
          itemBean.comment = reviewItem.getmComment();
          itemBean.dishId = reviewItem.getmDishId();
          itemBean.dishName = dish.getmName();
          itemBean.dishPrice = String.valueOf(dish.getmPrice());
          urls.add(itemBean);
        }
        _bean.reviewItemArray = urls;
        NMenuItemReviewCustomerBean customer = new NMenuItemReviewCustomerBean();
        customer.setAvatarUrl(AwsS3Utils.getAwsS3CustomerResUrl() + _bean.avatarUrl);
        // customer.setCustomerCompany(_bean.customerCompany);
        // customer.setCustomerName(_bean.customerName);
        // customer.setCustomerProfession(_bean.customerProfession);

        //
        _bean.avatarUrl = null;
        _bean.customerCompany = null;
        _bean.customerName = null;
        _bean.customerProfession = null;
        // _bean.summary= null;

        _bean.customer = customer;

        bean = _bean;
      }
      list.add(bean);
    }
    return list;
  }
Exemplo n.º 2
0
  @Override
  public List<NMenuItemBean> menuItemDishsByCondition(MenuSearchConditionBean condition) {

    List<NMenuItemDishBean> list = mDishDAO.getDishMenuItemsByConditon(condition);

    List<NMenuItemBean> _list = new ArrayList<NMenuItemBean>(list.size());

    for (NMenuItemDishBean bean : list) {
      if (logger.isDebugEnabled()) logger.debug("NMenuItemDishBean:" + bean);
      bean.dishImageUrl = AwsS3Utils.getAwsS3RestaurantResUrl() + bean.dishImageUrl;
      _list.add(bean);
      if (logger.isDebugEnabled()) logger.debug("NMenuItemDishBean:" + bean);
    }

    return _list;
  }
Exemplo n.º 3
0
  @Override
  public List<DishBean> validateDish(DishValidationConditionBean condition, List<Long> dishIdList)
      throws ParseException {

    List<DishBean> dishBeanList = new ArrayList<DishBean>();

    List<Dish> dishList = mDishDAO.validateDish(condition, dishIdList);

    for (Dish dish : dishList) {

      DishBean dishBean = new DishBean();

      dishBean.dishId = String.valueOf(dish.getmId());
      dishBean.dishName = String.valueOf(dish.getmName());

      dishBeanList.add(dishBean);
    }

    return dishBeanList;
  }
Exemplo n.º 4
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;
  }