@RequestMapping(value = "/shop/{id}/products")
  public String productAll(@PathVariable("id") String shopId, Model model, HttpServletRequest req) {
    Shop shop = shopService.load(shopId);
    List<Product> products = productService.listProducts(shop.getId());
    model.addAttribute("shop", shop);
    model.addAttribute("products", products);

    ShopStyle shopStyle = shopService.loadShopStyle(shopId);
    List<String> bodyClasses = new ArrayList<String>();
    bodyClasses.add(shopStyle.getAvatarStyle());
    bodyClasses.add(shopStyle.getBackgroundColor());
    bodyClasses.add(shopStyle.getFontColor());
    bodyClasses.add(shopStyle.getFontFamily());
    bodyClasses.add(
        StringUtils.isEmpty(shopStyle.getListView()) ? "smallimg" : shopStyle.getListView());
    model.addAttribute("styles", StringUtils.join(bodyClasses, " "));
    model.addAttribute("waterfall", "waterfall".equalsIgnoreCase(shopStyle.getListView()));

    return "shop/shopAll";
  }
  /**
   * 只获取店铺信息,不获取商品列表
   *
   * @param shopId
   * @param model
   * @param req
   * @return
   */
  @RequestMapping(value = "/shop/{id}/withoutProduct")
  public String viewWithoutProduct(
      @PathVariable("id") String shopId, Model model, HttpServletRequest req) {
    Shop shop = shopService.load(shopId);
    if (shop == null) {
      throw new BizException(
          GlobalErrorCode.NOT_FOUND, new RequestContext(req).getMessage("shop.not.found"));
    }

    model.addAttribute("shop", shop);
    model.addAttribute("owner", userService.load(shop.getOwnerId()));

    ShopStyle shopStyle = shopService.loadShopStyle(shopId);
    List<String> bodyClasses = new ArrayList<String>();
    bodyClasses.add(shopStyle.getAvatarStyle());
    bodyClasses.add(shopStyle.getBackgroundColor());
    bodyClasses.add(shopStyle.getFontColor());
    bodyClasses.add(shopStyle.getFontFamily());
    bodyClasses.add(
        StringUtils.isEmpty(shopStyle.getListView()) ? "smallimg" : shopStyle.getListView());
    model.addAttribute("styles", StringUtils.join(bodyClasses, " "));
    model.addAttribute("waterfall", "waterfall".equalsIgnoreCase(shopStyle.getListView()));

    List<Category> categories = categoryService.listRootCategoriesByShop(shop.getId());
    List<CategoryVO> categoryVOs = new ArrayList<CategoryVO>();
    for (int i = 0; i < categories.size(); i++) {
      CategoryVO categoryVO = new CategoryVO();
      BeanUtils.copyProperties(categories.get(i), categoryVO);
      categoryVO.setProductCount(
          categoryService.countProductsUnderCategory((categories.get(i)).getId()));
      categoryVOs.add(categoryVO);
    }
    model.addAttribute("categories", categoryVOs);

    model.addAttribute("recommendCount", productService.countByRecommend(shopId));
    model.addAttribute("allCount", productService.countProductsBySales(shopId));

    return "shop/shopView";
  }
  @RequestMapping(value = "/shop/{id}")
  public String view(@PathVariable("id") String shopId, Model model, HttpServletRequest req) {
    Shop shop = shopService.load(shopId);
    if (shop == null || shop.getArchive() == Boolean.TRUE) {
      throw new BizException(
          GlobalErrorCode.NOT_FOUND, new RequestContext(req).getMessage("shop.not.found"));
    }

    model.addAttribute("shop", shop);
    model.addAttribute("owner", userService.load(shop.getOwnerId()));

    // 取推荐,和热卖商品
    List<Product> recommends =
        productService.listProductsByRecommend(shop.getId(), new PageRequest(0, 4));
    model.addAttribute("prodsRecommended", recommends);

    List<Product> prodsHot =
        productService.listProductsBySales(shop.getId(), new PageRequest(0, 12), Direction.DESC);
    model.addAttribute("prodsHot", prodsHot);

    boolean isShowAll = false;
    if (prodsHot.size() == 12) {
      Long count = productService.countProductsByStatus(shop.getId(), ProductStatus.ONSALE);
      isShowAll = (count.longValue() > 12);
    }
    model.addAttribute("isShowAll", isShowAll);

    ShopStyleVO shopStyle = shopService.loadShopStyle(shopId);
    List<String> bodyClasses = new ArrayList<String>();
    bodyClasses.add(shopStyle.getAvatarStyle());
    bodyClasses.add(shopStyle.getBackgroundColor());
    bodyClasses.add(shopStyle.getFontColor());
    bodyClasses.add(shopStyle.getFontFamily());
    bodyClasses.add(
        StringUtils.isEmpty(shopStyle.getListView()) ? "smallimg" : shopStyle.getListView());
    model.addAttribute("styles", StringUtils.join(bodyClasses, " "));
    model.addAttribute("waterfall", "waterfall".equalsIgnoreCase(shopStyle.getListView()));
    model.addAttribute("banner", shopStyle.getBannerImg());

    if (shop.getProvinceId() != null) {
      Zone province = zoneService.load(shop.getProvinceId().toString());
      model.addAttribute("province", province);
    }
    if (shop.getCityId() != null) {
      Zone city = zoneService.load(shop.getCityId().toString());
      model.addAttribute("city", city);
    }

    List<Category> categories = categoryService.listRootCategoriesByShop(shop.getId());
    List<CategoryVO> categoryVOs = new ArrayList<CategoryVO>();
    for (int i = 0; i < categories.size(); i++) {
      CategoryVO categoryVO = new CategoryVO();
      BeanUtils.copyProperties(categories.get(i), categoryVO);
      categoryVO.setProductCount(
          categoryService.countProductsUnderCategory((categories.get(i)).getId()));
      categoryVOs.add(categoryVO);
    }
    model.addAttribute("categories", categoryVOs);

    model.addAttribute("recommendCount", productService.countByRecommend(shopId));
    model.addAttribute("allCount", productService.countProductsBySales(shopId));

    return "shop/shopView";
  }
 @ResponseBody
 @RequestMapping(UrlHelper.SHOP_URL_PREFIX + "/{id}/styles")
 public ResponseObject<ShopStyleVO> shopStylesCss(@PathVariable String id) {
   ShopStyleVO ss = shopService.loadShopStyle(id);
   return new ResponseObject<ShopStyleVO>(ss);
 }