示例#1
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;
  }
示例#2
0
  @Override
  public List<DishBean> listDishItemByCondition(MenuSearchConditionBean condition) {

    List<Dish> dishList = this.listDishByCondition(condition);

    List<DishBean> jsonList = new ArrayList<DishBean>();
    for (int i = 0; i < dishList.size(); i++) {
      Dish dish = dishList.get(i);
      DishBean json = new DishBean();
      json.dishId = String.valueOf(dish.getmId());
      json.dishName = dish.getmName();
      json.dishPrice = String.valueOf(dish.getmPrice());
      json.dishImageUrl =
          getDishImageUrl(dish.getmImageName(), dish.getmDishCategory().getmRestaurant());
      json.type = ParameterConstant.MENU_ITEM_TYPE_DISH;

      jsonList.add(json);
    }

    return jsonList;
  }
示例#3
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;
  }
示例#4
0
  @Override
  public DishBean getDishBeanById(MenuSearchConditionBean condition, long id) {

    Dish dish = getBaseDAO().findById(Dish.class, id);
    Restaurant restaurant = dish.getmDishCategory().getmRestaurant();
    DishBean dishBean = new DishBean();
    String curTime = TimestampUtil.dateToStr(new Date(), DateFormatType.Time24);
    if (dish != null) {

      dishBean.dishId = String.valueOf(dish.getmId());
      dishBean.dishPrice = String.valueOf(dish.getmPrice());
      if (dish.getmName() != null) dishBean.dishName = dish.getmName();
      if (dish.getmDescription() != null) {
        dishBean.desc = dish.getmDescription();
      }
      if (dish.getmCustomization() != null) {
        dishBean.customization = JsonFormatUtils.getCustomization(dish.getmCustomization());
      }
      if (dish.getmDishCategory().getmRestaurant().getmFolderName() != null
          && dish.getmImageName() != null)
        dishBean.dishImageUrl =
            AwsS3Utils.getAwsS3RestaurantResUrl()
                + dish.getmDishCategory().getmRestaurant().getmFolderName()
                + "/"
                + dish.getmImageName();

      dishBean.restaurant.restaurantId =
          String.valueOf(dish.getmDishCategory().getmRestaurant().getmId());
      if (dish.getmDishCategory().getmRestaurant().getmName() != null)
        dishBean.restaurant.restaurantName = dish.getmDishCategory().getmRestaurant().getmName();
      dishBean.restaurant.freeDeliveryLimit =
          String.valueOf(dish.getmDishCategory().getmRestaurant().getmFreeDeliveryLimit());
      dishBean.restaurant.deliveryFee =
          String.valueOf(dish.getmDishCategory().getmRestaurant().getmDeliveryFee());
      if (dish.getmDishCategory().getmRestaurant().getmFolderName() != null
          && dish.getmDishCategory().getmRestaurant().getmLogo() != null)
        dishBean.restaurant.restaurantLogoUrl =
            AwsS3Utils.getAwsS3RestaurantResUrl()
                + dish.getmDishCategory().getmRestaurant().getmFolderName()
                + "/"
                + dish.getmDishCategory().getmRestaurant().getmLogo();

      // set different open time and delivery through different week
      int week = FormatUtils.getCurrentWeek();
      RestaurantDeliveryTimeBean restaurantDeliveryTimeBean = new RestaurantDeliveryTimeBean();
      switch (week) {
        case 0:
          if (restaurant.getmSunOpenStartTime() != null)
            dishBean.restaurant.openingStartTime = restaurant.getmSunOpenStartTime();
          if (restaurant.getmSunOpenEndTime() != null)
            dishBean.restaurant.openingEndTime = restaurant.getmSunOpenEndTime();
          if (restaurant.getmSunDeliveryStartTime() != null)
            restaurantDeliveryTimeBean.startTime = restaurant.getmSunDeliveryStartTime();
          if (restaurant.getmSunDeliveryEndTime() != null)
            restaurantDeliveryTimeBean.endTime = restaurant.getmSunDeliveryEndTime();
          break;

        case 1:
          if (restaurant.getmMonOpenStartTime() != null)
            dishBean.restaurant.openingStartTime = restaurant.getmMonOpenStartTime();
          if (restaurant.getmMonOpenEndTime() != null)
            dishBean.restaurant.openingEndTime = restaurant.getmMonOpenEndTime();
          if (restaurant.getmMonDeliveryStartTime() != null)
            restaurantDeliveryTimeBean.startTime = restaurant.getmMonDeliveryStartTime();
          if (restaurant.getmMonDeliveryEndTime() != null)
            restaurantDeliveryTimeBean.endTime = restaurant.getmMonDeliveryEndTime();
          break;

        case 2:
          if (restaurant.getmTueOpenStartTime() != null)
            dishBean.restaurant.openingStartTime = restaurant.getmTueOpenStartTime();
          if (restaurant.getmTueOpenEndTime() != null)
            dishBean.restaurant.openingEndTime = restaurant.getmTueOpenEndTime();
          if (restaurant.getmTueDeliveryStartTime() != null)
            restaurantDeliveryTimeBean.startTime = restaurant.getmTueDeliveryStartTime();
          if (restaurant.getmTueDeliveryEndTime() != null)
            restaurantDeliveryTimeBean.endTime = restaurant.getmTueDeliveryEndTime();
          break;

        case 3:
          if (restaurant.getmWedOpenStartTime() != null)
            dishBean.restaurant.openingStartTime = restaurant.getmWedOpenStartTime();
          if (restaurant.getmWedOpenEndTime() != null)
            dishBean.restaurant.openingEndTime = restaurant.getmWedOpenEndTime();
          if (restaurant.getmWedDeliveryStartTime() != null)
            restaurantDeliveryTimeBean.startTime = restaurant.getmWedDeliveryStartTime();
          if (restaurant.getmWedDeliveryEndTime() != null)
            restaurantDeliveryTimeBean.endTime = restaurant.getmWedDeliveryEndTime();
          break;

        case 4:
          if (restaurant.getmThuOpenStartTime() != null)
            dishBean.restaurant.openingStartTime = restaurant.getmThuOpenStartTime();
          if (restaurant.getmThuOpenEndTime() != null)
            dishBean.restaurant.openingEndTime = restaurant.getmThuOpenEndTime();
          if (restaurant.getmThuDeliveryStartTime() != null)
            restaurantDeliveryTimeBean.startTime = restaurant.getmThuDeliveryStartTime();
          if (restaurant.getmThuDeliveryEndTime() != null)
            restaurantDeliveryTimeBean.endTime = restaurant.getmThuDeliveryEndTime();
          break;

        case 5:
          if (restaurant.getmFriOpenStartTime() != null)
            dishBean.restaurant.openingStartTime = restaurant.getmFriOpenStartTime();
          if (restaurant.getmFriOpenEndTime() != null)
            dishBean.restaurant.openingEndTime = restaurant.getmFriOpenEndTime();
          if (restaurant.getmFriDeliveryStartTime() != null)
            restaurantDeliveryTimeBean.startTime = restaurant.getmFriDeliveryStartTime();
          if (restaurant.getmFriDeliveryEndTime() != null)
            restaurantDeliveryTimeBean.endTime = restaurant.getmFriDeliveryEndTime();
          break;

        case 6:
          if (restaurant.getmSatOpenStartTime() != null)
            dishBean.restaurant.openingStartTime = restaurant.getmSatOpenStartTime();
          if (restaurant.getmSatOpenEndTime() != null)
            dishBean.restaurant.openingEndTime = restaurant.getmSatOpenEndTime();
          if (restaurant.getmSatDeliveryStartTime() != null)
            restaurantDeliveryTimeBean.startTime = restaurant.getmSatDeliveryStartTime();
          if (restaurant.getmSatDeliveryEndTime() != null)
            restaurantDeliveryTimeBean.endTime = restaurant.getmSatDeliveryEndTime();
          break;

        default:
          break;
      }

      // 营业开始时间
      String beginHour = dishBean.restaurant.openingStartTime;
      // 营业结束时间
      String endHour = dishBean.restaurant.openingEndTime;
      // 如果超过则设置为非营业时间(默认是 营业时间)
      if (curTime.compareTo(beginHour) < 0 || curTime.compareTo(endHour) > 0)
        dishBean.restaurant.isOutOfBusinessHour = "1";

      // 送餐时间
      String beginTime = restaurantDeliveryTimeBean.startTime;
      String endTime = restaurantDeliveryTimeBean.endTime;
      if (curTime.compareTo(beginTime) < 0 || curTime.compareTo(endTime) > 0)
        dishBean.restaurant.isOutOfDeliveryTime = "1";

      dishBean.restaurant.deliveryTimeArray.add(restaurantDeliveryTimeBean);

      if (dish.getmStatus() != null) {
        dishBean.dishStatus = dish.getmStatus();
      }

      if (dish.getmDishCategory().getmRestaurant().getmStatus() != null) {
        dishBean.restaurant.restaurantStatus =
            String.valueOf(dish.getmDishCategory().getmRestaurant().getmStatus());
      }

      dishBean.restaurant.minDeliveryTotal = String.valueOf(restaurant.getmMinDeliveryTotal());
      dishBean.restaurant.deliveryDistance = String.valueOf(restaurant.getmDeliveryDistance());

      if (condition.latitude == null || condition.longitude == null) {
        dishBean.restaurant.distance = "999999";

      } else {
        dishBean.restaurant.distance =
            String.valueOf(
                MapUtils.getDistance(
                    condition.latitude,
                    condition.longitude,
                    dish.getmDishCategory().getmRestaurant().getmLatitude(),
                    dish.getmDishCategory().getmRestaurant().getmLongitude()));

        if (dishBean.restaurant.distance.compareTo(dishBean.restaurant.deliveryDistance) <= 0)
          dishBean.restaurant.isOutOfRange = "0";
      }
    }

    return dishBean;
  }