/**
   * TODO 暂没有用上
   *
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ModelAndView productJSONData(HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    Integer productId = RequestUtil.getInteger(request, "productId");
    Product product = productManager.getById(productId);
    Integer storeId = ConfigUtil.getInstance().getStore().getStoreId();
    ProductStat productStat = productStatManager.getProductStat(storeId, product.getId());
    // TODO 是否只检查已激活的Sku信息
    List<ProductSku> productSkuList = productSkuManager.findActiveProductSkusByProductId(productId);

    JSONObject jsonProduct = new JSONObject();
    jsonProduct.put("productId", product.getProductId());
    jsonProduct.put("productName", product.getProductName());
    jsonProduct.put("productCode", product.getProductCode());
    jsonProduct.put("availabilityRule", product.getAvailabilityRule());
    Map<String, Object> jsonProductStat = new HashMap<String, Object>();
    jsonProductStat.put("buyCount", productStat.getBuyCount());
    jsonProductStat.put("averageRate", productStat.getAverageRate());
    jsonProductStat.put("reviewCount", productStat.getReviewCount());
    jsonProduct.put("productStat", jsonProductStat);
    List<Map<String, Object>> jsonProductSkus = new ArrayList<Map<String, Object>>();
    for (ProductSku productSku : productSkuList) {
      Map<String, Object> jsonProductSku = new HashMap<String, Object>();
      jsonProductSku.put("productSkuId", productSku.getProductSkuId());
      jsonProductSku.put("productSkuCode", productSku.getProductSkuCode());
      // 相应的价格等
      Inventory inventory = inventoryService.getInventoryBySku(productSku.getId());
      Map<String, Object> jsonInventory = new HashMap<String, Object>();
      jsonInventory.put("productSkuId", inventory.getProductSkuId());
      jsonInventory.put("quantityOnHand", inventory.getQuantityOnHand());
      jsonInventory.put("allocatedQuantity", inventory.getAllocatedQuantity());
      jsonInventory.put("availableQuantity", inventory.getAvailableQuantity());
      jsonProductSku.put("inventory", jsonInventory);
      jsonProductSkus.add(jsonProductSku);
      if (productSku.getId().intValue() == product.getDefaultProductSkuId().intValue()) {
        jsonProduct.put("defaultProductSku", jsonProductSku);
      }
    }
    jsonProduct.put("productSkus", jsonProductSkus);
    PrintWriter out = response.getWriter();
    out.println(jsonProduct.toString());
    return null;
  }
 private JSONObject productJSONData(Product product, List<ProductSku> productSkuList) {
   Integer storeId = ConfigUtil.getInstance().getStore().getStoreId();
   ProductStat productStat = productStatManager.getProductStat(storeId, product.getId());
   // TODO 是否只检查已激活的Sku信息
   JSONObject jsonProduct = new JSONObject();
   jsonProduct.put("productId", product.getProductId());
   jsonProduct.put("productName", product.getProductName());
   jsonProduct.put("productCode", product.getProductCode());
   jsonProduct.put("availabilityRule", product.getAvailabilityRule());
   jsonProduct.put(
       "expectedReleaseDate",
       product.getExpectedReleaseDate() == null
           ? ""
           : DateUtil.convertDateToString(product.getExpectedReleaseDate()));
   jsonProduct.put("preOrBackOrderLimit", product.getPreOrBackOrderLimit());
   Map<String, Object> jsonProductStat = new HashMap<String, Object>();
   jsonProductStat.put("buyCount", productStat.getBuyCount());
   jsonProductStat.put("averageRate", productStat.getAverageRate());
   jsonProductStat.put("reviewCount", productStat.getReviewCount());
   jsonProduct.put("productStat", jsonProductStat);
   if (product.getProductKind().intValue() == CatalogConstants.PRODUCT_KIND_VARIATION.intValue()) {
     List<Map<String, Object>> jsonProductSkus = new ArrayList<Map<String, Object>>();
     for (ProductSku productSku : productSkuList) {
       // 获取sku的选项及值,SkuOption及SkuOptionValue
       Map<SkuOption, SkuOptionValue> skuOptionAndValues =
           productMainManager.findSkuOptionAndValuesByProductSku(productSku.getId());
       JSONObject jsonProductSku = skuToJson(productSku, skuOptionAndValues);
       jsonProductSkus.add(jsonProductSku);
       if (productSku.getId().intValue() == product.getDefaultProductSkuId().intValue()) {
         jsonProduct.put("defaultProductSku", jsonProductSku);
       }
     }
     jsonProduct.put("productSkus", jsonProductSkus);
   }
   return jsonProduct;
 }