Пример #1
0
  /**
   * 获取店铺详情
   *
   * @param shop
   * @return
   */
  public ShopDetail getShopDetail(Shop shop) {

    ShopDetail detail = new ShopDetail();

    detail.setCode(shop.getId());
    detail.setTitle(shop.getName());
    detail.setHeaderImageurl(shop.getLogo());
    detail.setScore(shop.getAvgScore());
    detail.setCollectFlag(
        shopFavoriteService.isUserCollectShop(memberService.getAppCurrent(), shop) ? 1 : 0);
    detail.setAllProduct(productService.findShopProductCount(shop));
    detail.setSaleProduct(promotionService.findShopPromotionCount(shop));
    detail.setSaleStatus(shop.getStatus());
    detail.setDesc(shop.getDescription());
    detail.setType(shop.getShopType());
    detail.setAddress(shop.getAddress());
    detail.setNotice(shop.getNotice());
    detail.setLatitude(shop.getLatitude() == null ? 0 : shop.getLatitude().doubleValue());
    detail.setLongitude(shop.getLongitude() == null ? 0 : shop.getLongitude().doubleValue());
    detail.setTelephone(shop.getTelephone());
    detail.setBusinessTime(shop.getBusinessTime());

    List<ShopImage> shopImages = shop.getShopImages();
    List<String> imageList = new ArrayList<String>();

    if (shopImages != null && shopImages.size() > 0) {
      for (ShopImage image : shopImages) {
        imageList.add(image.getSource());
      }
    }

    detail.setShopImages(imageList);

    ShopReview shopReview = shopReviewService.findLatestReview(shop);
    detail.setEvaluate(shopReview == null ? "" : shopReview.getContent());

    List<ShopActivity> shopActivities = shop.getShopActivities();
    List<cn.bmwm.modules.shop.controller.app.vo.ShopActivity> activityList =
        new ArrayList<cn.bmwm.modules.shop.controller.app.vo.ShopActivity>();

    if (shopActivities != null && shopActivities.size() > 0) {
      for (ShopActivity shopActivity : shopActivities) {
        cn.bmwm.modules.shop.controller.app.vo.ShopActivity activity =
            new cn.bmwm.modules.shop.controller.app.vo.ShopActivity();
        activity.setImageurl(shopActivity.getImageurl());
        activity.setLinkurl(shopActivity.getLinkurl());
        activityList.add(activity);
      }
    }

    detail.setActivityList(activityList);

    // 店铺热销商品
    List<Product> hostList = productService.findShopHotList(shop);

    detail.setRecommend(this.getShopProductItemCategory(shop, hostList));

    return detail;
  }
Пример #2
0
  /**
   * 店铺内商品列表
   *
   * @param shopId:店铺ID
   * @param globalCatId:全站分类Id
   * @param catId:店铺分类Id
   * @param page:页码
   * @param size:每页显示商品数量
   * @param order:排序方式,1:促销,2:新品,3:销量,4:价格
   * @param x:经度
   * @param y:纬度
   * @return
   */
  @RequestMapping(value = "/productlist", method = RequestMethod.GET)
  @ResponseBody
  public Result productList(
      Long shopId, Long globalCatId, Long catId, Integer page, Integer size, Integer order) {

    log.warn(
        "shopId = "
            + shopId
            + " , catId = "
            + catId
            + " , globalCatId = "
            + globalCatId
            + " , order = "
            + order);

    if (shopId == null) {
      throw new BusinessException(" parameter 'shopId' can not be null !");
    }

    if (page == null) page = 1;
    if (size == null) size = 10;
    if (order == null) order = 1;

    Shop shop = shopService.find(shopId);

    if (shop == null) {
      throw new BusinessException(" Invalid parameter 'shopId' ! ");
    }

    ShopCategory shopCategory = null;

    if (catId != null) {
      shopCategory = shopCategoryService.find(catId);
    }

    ProductCategory productCategory = null;

    if (globalCatId != null) {
      productCategory = productCategoryService.find(globalCatId);
    }

    ItemPage<Product> itemPage =
        productService.findShopProductList(shop, productCategory, shopCategory, page, size, order);

    return new Result(Code.SUCCESS, 1, "", getProductItems(itemPage.getList()));
  }