Пример #1
0
  private String getDishImageUrl(String dishImageName, Restaurant restaurant) {

    if (restaurant == null) {
      return "";
    }

    if (dishImageName == null || dishImageName == "") {
      return "";
    }

    return AwsS3Utils.getAwsS3RestaurantResUrl()
        + restaurant.getmFolderName()
        + "/"
        + dishImageName;
  }
Пример #2
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;
  }