Example #1
0
 /**
  * 发送email,报告错误
  *
  * @param context
  * @param jobEx
  */
 private void reportEmail(JobExecutionContext context, JobExecutionException jobEx) {
   ConfigUtil configUtil = ConfigUtil.getInstance();
   MailEngine mailEngine = (MailEngine) ContextUtil.getSpringBeanById("mailEngine");
   if (mailEngine == null) {
     return;
   }
   String error =
       new StringBuilder("Trigger[")
           .append(context.getTrigger().getName())
           .append("]<br/> Time[")
           .append(new Date())
           .append("]<br/><br/>StoreURL:")
           .append(ConfigUtil.getInstance().getStore().getSiteUrl())
           .append("<br/><br/>")
           .append(jobEx.toString())
           .toString();
   Map model = new HashMap();
   model.put("errorMsg", error);
   try {
     mailEngine.sendSimpleTemplateMail(
         EMAIL_TEMPLATE, model, null, null, configUtil.getBugReportEmail());
   } catch (Exception e) {
     logger.error(e);
   }
 }
 public Date getDefaultRecommendedProductExpireTime() {
   int conf = ConfigUtil.getInstance().getRecommendedProductExpireYears();
   Calendar cal = Calendar.getInstance();
   cal.setTime(new Date());
   cal.add(Calendar.YEAR, new Integer(conf).intValue());
   return cal.getTime();
 }
Example #3
0
 public void onConfigChanged() {
   logger.info(
       "Updating server side page cache time settings from: "
           + getTime()
           + " to: "
           + ConfigUtil.getInstance().getServerSidePageCacheSeconds());
   setTime(ConfigUtil.getInstance().getServerSidePageCacheSeconds());
   logger.info("Enable server side page caching? " + (getTime() > 0));
   logger.info(
       "Updating browser side page cache time settings from: "
           + getCacheControlMaxAge()
           + " to: "
           + ConfigUtil.getInstance().getBrowserSidePageCacheSeconds());
   setCacheControlMaxAge(ConfigUtil.getInstance().getBrowserSidePageCacheSeconds());
   // logger.warn("Updating cachable urls: " + ConfigUtil.getInstance().getCachableUrls());
   String[] cachableUris =
       StringUtil.toArrayByDel(ConfigUtil.getInstance().getCachableUrls(), ",");
   Collection<String> stores = ConfigUtil.getInstance().getAllStoreCodes();
   for (String code : stores) {
     ArrayList<Pattern> patterns = matchPatterns.get(code);
     if (patterns == null) {
       patterns = new ArrayList<Pattern>();
       matchPatterns.put(code, patterns);
     }
     if (cachableUris != null) {
       for (String uri : cachableUris) {
         uri = "^" + uri.replace("*", ".*");
         Pattern p = Pattern.compile(uri);
         patterns.add(p);
         logger.info("URI cache match pattern :" + uri);
       }
     }
   }
 }
 /**
  * save Synonym
  *
  * @param req
  * @param resp
  * @return
  */
 public ModelAndView saveSynonym(HttpServletRequest req, HttpServletResponse resp) {
   String synonym = req.getParameter("synonym");
   String searchServerPath = ConfigUtil.getInstance().getStoreSearchPath();
   try {
     FileUtil.writeStringToFile(searchServerPath + "/product/conf/synonyms.txt", synonym);
     saveMessage(Message.info("searchServer.save.synonym.succeeded"));
   } catch (IOException e) {
     // TODO Auto-generated catch block
     logger.error(e);
   }
   ModelAndView mv = new ModelAndView(new RedirectView("/system/searchServer.html", true));
   return mv;
 }
 public ModelAndView review(HttpServletRequest request, HttpServletResponse response) {
   String uri = request.getRequestURI();
   if (RequestContext.isAnonymousUser() && !ConfigUtil.getInstance().getIsAllowAnonymousReview()) {
     SessionUtil.setAttribute(request.getSession(), "HAS_ERRORS", Boolean.TRUE);
     saveMessage(Message.error("common.loginConfirm"));
     return new ModelAndView(new RedirectView(uri + "#review"));
   }
   Integer pIdcId[] = CatalogHelper.getInstance().getProductIdByUri(uri);
   Integer productId = pIdcId[0];
   String message = request.getParameter("message");
   String customerName = request.getParameter("customerName");
   String subject = request.getParameter("subject");
   Integer productRate = Integer.parseInt(request.getParameter("productRate").split("_")[1]);
   ;
   String attrRates[] = request.getParameterValues("rateItems");
   if (productId.intValue() != 0 && productId.intValue() != 0) {
     ProductReview productReview = new ProductReview();
     productReview.setProductId(productId);
     productReview.setSubject(subject);
     productReview.setMessage(message);
     if (RequestContext.isAnonymousUser()) {
       // TODO 设置匿名用户对象,系统必须存在Id为-2的匿名用户
       productReview.setReviewUserId(Constants.USERID_ANONYMOUS);
     } else {
       productReview.setReviewUserId(RequestContext.getCurrentUserId());
     }
     productReview.setCustomerName(customerName);
     productReview.setRate(productRate);
     productReview.setRemoteIp(request.getRemoteAddr());
     productReview.setStore(ConfigUtil.getInstance().getStore());
     if (attrRates == null) attrRates = new String[] {};
     productMainManager.saveProductReviewAction(productReview, attrRates);
     saveMessage(Message.info("product.addReview.success"));
   }
   return new ModelAndView(new RedirectView(uri + "#review"));
 }
  public ModelAndView defaultAction(HttpServletRequest req, HttpServletResponse resp) {
    removeNavFromSearchCriteria(req);
    // 获得admin的solrServer
    SolrServer coreadmin = solr.getSolrServer(SearchConstants.CORE_NAME_ADMIN);

    ModelAndView mv = new ModelAndView("system/searchServer");
    try {
      // 获得product的status
      CoreAdminResponse mcr =
          CoreAdminRequest.getStatus(SearchConstants.CORE_NAME_PRODUCT, coreadmin);
      NamedList rs = mcr.getCoreStatus().get(SearchConstants.CORE_NAME_PRODUCT);
      NamedList indexInfo = (NamedList) rs.get("index");
      mv.addObject("productCore", rs);
      mv.addObject("productIndexInfo", indexInfo);
      // 获得salesorder的status
      CoreAdminResponse so_mcr =
          CoreAdminRequest.getStatus(SearchConstants.CORE_NAME_SALESORDER, coreadmin);
      NamedList so_rs = so_mcr.getCoreStatus().get(SearchConstants.CORE_NAME_SALESORDER);
      NamedList so_indexInfo = (NamedList) so_rs.get("index");
      mv.addObject("salesOrderCore", so_rs);
      mv.addObject("salesOrderIndexInfo", so_indexInfo);
      // 获得salesorder的status
      CoreAdminResponse cn_mcr =
          CoreAdminRequest.getStatus(SearchConstants.CORE_NAME_CONTENT, coreadmin);
      NamedList cn_rs = cn_mcr.getCoreStatus().get(SearchConstants.CORE_NAME_CONTENT);
      NamedList cn_indexInfo = (NamedList) cn_rs.get("index");
      mv.addObject("contentCore", cn_rs);
      mv.addObject("contentIndexInfo", cn_indexInfo);

      String searchServerPath = ConfigUtil.getInstance().getStoreSearchPath();
      if (logger.isDebugEnabled()) logger.debug("searchServerPath=" + searchServerPath);
      if (searchServerPath != null) {
        String synonyms =
            FileUtil.readFileToString(searchServerPath + "/product/conf/synonyms.txt");
        String protwords =
            FileUtil.readFileToString(searchServerPath + "/product/conf/protwords.txt");
        mv.addObject("synonyms", synonyms);
        mv.addObject("protwords", protwords);
      }

    } catch (Exception e) {
      logger.error(e);
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return mv;
  }
  public void doFilterInternal(
      HttpServletRequest request, HttpServletResponse response, FilterChain chain)
      throws IOException, ServletException {

    if (ConfigUtil.getInstance().getIsGzipEnabled() && isGZIPSupported(request)) {
      if (log.isDebugEnabled()) {
        log.debug("GZIP supported, compressing response");
      }

      GZIPResponseWrapper wrappedResponse = new GZIPResponseWrapper(response);

      chain.doFilter(request, wrappedResponse);
      wrappedResponse.finishResponse();

      return;
    }

    chain.doFilter(request, response);
  }
  /**
   * 获取订单,用于智能审核
   *
   * @param sc
   * @return
   */
  public List<OrderShipment> getOrderShipment4RobotReview(SearchCriteria sc) {
    // N分钟前
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.MINUTE, -ConfigUtil.getInstance().getOrderRobotReviewDelayMinutes());
    Date dt1 = cal.getTime();

    String hql =
        "select os from SalesOrder so, OrderShipment os where so.salesOrderId=os.salesOrder.salesOrderId and so.paymentStatus=? and so.isOnHold=0 and so.isLocked=0 and os.status=? and so.createTime<?";
    // select so from SalesOrder so, OrderShipment os where
    // so.salesOrderId=os.salesOrder.salesOrderId and so.paymentStatus=30 and os.status=20 and
    // so.isOnHold = 0 order by so.salesOrderId desc
    return this.find(
        hql,
        sc.getStartIdx(),
        sc.getFetchSize(),
        OrderConstants.PAYMENT_STATUS_PAID,
        OrderConstants.SHIPMENT_STATUS_INVENTORY_ASSIGNED,
        dt1);
  }
  /**
   * 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;
 }
Example #11
0
 protected String getMediaStorePath() {
   return ConfigUtil.getInstance().getMediaStorePath();
 }
  private JSONObject skuToJson(
      ProductSku productSku, Map<SkuOption, SkuOptionValue> skuOptionAndValues) {
    ConfigUtil configUtil = ConfigUtil.getInstance();
    JSONObject jsonProductSku = new JSONObject();
    jsonProductSku.put("productSkuId", productSku.getProductSkuId());
    jsonProductSku.put("productSkuCode", productSku.getProductSkuCode());
    jsonProductSku.put("image", productSku.getImage());
    jsonProductSku.put(
        "weight",
        productSku.getWeight() == null
            ? null
            : productSku.getWeight().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
    // 相应的价格等
    jsonProductSku.put("priceViewType", productSku.getPriceViewType());
    jsonProductSku.put(
        "price", productSku.getPrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
    jsonProductSku.put(
        "salePrice",
        productSku.getSalePrice() == null
            ? null
            : productSku.getSalePrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
    jsonProductSku.put(
        "discountPrice",
        productSku.getDiscountPrice() == null
            ? null
            : productSku.getDiscountPrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
    jsonProductSku.put(
        "listPrice",
        productSku.getListPrice() == null
            ? null
            : productSku.getListPrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
    jsonProductSku.put("discountPercent", productSku.getDiscountPercent());

    // 获取批发价
    Set<WholesalePrice> wholesalePrices = productSku.getWholesalePrices();
    List<JSONArray> jsonWholesalePrices = new ArrayList<JSONArray>();
    for (WholesalePrice wholesalePrice : wholesalePrices) {
      JSONArray jsonWholesalePrice = new JSONArray();
      jsonWholesalePrice.add(wholesalePrice.getMinQuantity());
      jsonWholesalePrice.add(
          wholesalePrice.getPrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
      jsonWholesalePrices.add(jsonWholesalePrice);
    }
    jsonProductSku.put("wholesalePrices", jsonWholesalePrices);

    // 获取产品媒体productMedia
    Set<ProductMedia> productMedias = productSku.getProductMedias();
    JSONArray jsonProductMedias = new JSONArray();
    for (ProductMedia media : productMedias) {
      jsonProductMedias.add(media.getMediaUrlLarge());
    }
    jsonProductSku.put("productMedias", jsonProductMedias);

    // 获取库存信息
    if (productSku.getProduct().getAvailabilityRule().intValue()
            != CatalogConstants.PRODUCT_AVAILABILITY_ALWAYS_SELL.intValue()
        && productSku.getProduct().getAvailabilityRule().intValue()
            != CatalogConstants.PRODUCT_AVAILABILITY_NOT_IN_STOCK_SELL) {
      Inventory inventory = productSku.getInventory();
      // TODO 没有库存的全设置为0
      if (inventory == null) {
        inventory = new Inventory();
        inventory.setProductSku(productSku);
        inventory.setQuantityOnHand(0);
        inventory.setAllocatedQuantity(0);
        inventory.setReservedQuantity(0);
        inventory.setPreOrBackOrderedQty(0);
      }
      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());
      jsonInventory.put(
          "expectedRestockDate",
          inventory.getExpectedRestockDate() == null
              ? ""
              : DateUtil.convertDateToString(inventory.getExpectedRestockDate()));
      jsonInventory.put("preOrBackOrderedQty", inventory.getPreOrBackOrderedQty());
      jsonProductSku.put("inventory", jsonInventory);
    }
    if (skuOptionAndValues != null && skuOptionAndValues.size() > 0) {
      JSONArray jsonSkuOptions = new JSONArray();
      Set<SkuOption> skuOptions = skuOptionAndValues.keySet();
      for (SkuOption skuOption : skuOptions) {
        JSONObject jsonSkuOption = new JSONObject();
        jsonSkuOption.put("id", skuOption.getId());
        jsonSkuOption.put("vid", skuOptionAndValues.get(skuOption).getId());
        jsonSkuOptions.add(jsonSkuOption);
      }
      jsonProductSku.put("skuOptions", jsonSkuOptions);
    }
    return jsonProductSku;
  }
  // @RequestMapping(value={"/*_p{pId}_{cId}.html","/*_p{pId}.html",})
  @RequestMapping(value = "/product/*.html")
  public ModelAndView defaultAction(HttpServletRequest request, HttpServletResponse response) {
    Store store = ConfigUtil.getInstance().getStore();
    String uri = request.getRequestURI();
    request.setAttribute("uri", uri);
    CatalogHelper catalogHelper = CatalogHelper.getInstance();
    Integer pIdcId[] = catalogHelper.getProductIdByUri(uri);
    Integer productId = pIdcId[0];
    Integer categoryId = pIdcId[1];
    // 查找产品
    Product product = productManager.getById(productId);
    // 没有找到相应产品或草稿状态的不能访问,直接进入找不到或已删除页面
    if (product == null) {
      return notFoundPage(request, response);
    }
    // 获取导航目录
    // 获取产品主目录
    Category category = null;
    if (categoryId != null) {
      Category temp_category =
          catalogHelper.getCategoryById4Front(Constants.CATEGORY_TYPE_CATALOG, categoryId);
      if (temp_category != null) {
        Set<ProductCategory> productCategorySet = product.getProductCategorys();
        for (ProductCategory productCategory : productCategorySet) {
          if (productCategory.getCategory().getCatalogId().intValue() == store.getCatalogId()
              && productCategory.getCategory().getId().intValue() == temp_category.getId()) {
            category = temp_category;
            break;
          }
        }
      }
    }
    // 指定目录不存在的直接获取产品主目录
    if (category == null) {
      Category mainCategory = product.getMainCategory();
      // 任何时候都从所以目录中查找,因为产品任何状态在前台都是可见的,
      /*			if(mainCategory!=null)
      category=catalogHelper.getCategoryById4Front(Constants.CATEGORY_TYPE_CATALOG,mainCategory.getCategoryId());*/
      // 缓存不存在该目录的,直接获取数据库的目录
      if (category == null && mainCategory != null) {
        category =
            catalogHelper.getCategoryById4Front(
                Constants.CATEGORY_TYPE_CATALOG, mainCategory.getCategoryId());
      }
    }
    // 检查请求的URI内的产品名是否正确,不正确的重定向到正确的URI
    // 目录已删除的不需要检查
    if (category != null) {
      String productUri =
          catalogHelper.getProductUrl(product, store.getCatalogId(), category.getCategoryId());
      try {
        if (!URLDecoder.decode(uri, "UTF-8").equals(request.getContextPath() + productUri)) {
          return new ModelAndView(new RedirectView301(productUri, true));
        }
      } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
      }
    }
    if (category == null) {
      return notFoundPage(request, response);
    }

    List<Category> navigatorCategorys = null;
    // 当目录为空的就不显示该目录相关信息,只显示产品数据
    if (category != null) {
      // 获取产品导航目录
      navigatorCategorys = category.getNavigatorCategorys();
    }

    // 获取产品媒体
    //
    //	List<ProductMedia>productMoreImages=productMediaManager.findProductMediaByProductIdAndType(product.getProductId(), CatalogConstants.PRODUCT_MEDIA_TYPE_MORE_IMAGE);
    List<ProductMedia> productMoreImages =
        new ArrayList<ProductMedia>(product.getDefaultProductSku().getProductMedias());

    List<ProductMediaUp> productMoreImagesUp =
        productMediaUpManager.findProductMediaByProductIdAndType(
            product.getProductId(), CatalogConstants.PRODUCT_MEDIA_TYPE_MORE_IMAGE);

    // 产品媒体附件
    List<ProductMedia> productaccessories =
        productMediaManager.findProductMediaByProductIdAndType(
            product.getProductId(), CatalogConstants.PRODUCT_MEDIA_TYPE_ACCESSORIES);

    // 获取自定义属性组及值
    List<ProductAttGroup> productAttGroups =
        productMainManager.findAttGroupAndProductAttrValueByProduct(product);
    // 获取库存信息
    //		Inventory inventory=inventoryService.getInventoryBySku(product.getDefaultProductSkuId());
    Inventory inventory = product.getDefaultProductSku().getInventory();

    ModelAndView modelAndView = null;
    // 激活状态下完整显示产品
    String defaultView = "catalog/productTemplate";
    if (product.getStatus().intValue() == Constants.STATUS_ACTIVE.intValue()) {
      String view = this.getTemplatePath(defaultView, product.getTemplatePath());
      modelAndView = getModelAndView(view);

      JSONObject jsonProductModel = new JSONObject();
      // 是否变种产品,变种产品时,显示带有sku选项
      if (product.getProductKind().intValue()
          == CatalogConstants.PRODUCT_KIND_VARIATION.intValue()) {
        // SkuOption及值
        Map<SkuOption, List<SkuOptionValue>> productSkuOptionAndValues =
            productMainManager.findSkuOptionsByProduct(productId);
        modelAndView.addObject("productSkuOptionAndValues", productSkuOptionAndValues);
        // 变种信息
        List<ProductSku> productSkuList =
            productSkuManager.findActiveProductSkusByProductId(productId);
        // 为productSku设置促销价
        promoService.appendPromoInfo(productSkuList);

        JSONArray jsonOptionAndSkuList = new JSONArray();
        JSONArray jsonSkuOptionList = new JSONArray();
        JSONArray jsonSkuOptionNameList = new JSONArray();
        // 获取shu产品相关信息
        for (ProductSku productSku : productSkuList) {
          // 设置价格显示方式
          catalogHelper.setPriceViewType(productSku);
          // 获取sku的选项及值,SkuOption及SkuOptionValue
          Map<SkuOption, SkuOptionValue> skuOptionAndValues =
              productMainManager.findSkuOptionAndValuesByProductSku(productSku.getId());
          Set<Entry<SkuOption, SkuOptionValue>> skuOptionAndValue = skuOptionAndValues.entrySet();
          JSONArray temp_jsonSkuData = new JSONArray();
          for (Entry<SkuOption, SkuOptionValue> entry : skuOptionAndValue) {
            temp_jsonSkuData.add(entry.getValue().getSkuOptionValueId());
          }
          temp_jsonSkuData.add(productSku.getId());
          jsonOptionAndSkuList.add(temp_jsonSkuData);
          if (jsonSkuOptionList.size() < 1) {
            Set<SkuOption> skuOptions = skuOptionAndValues.keySet();
            for (SkuOption skuOption : skuOptions) {
              jsonSkuOptionList.add(skuOption.getId());
              jsonSkuOptionNameList.add(skuOption.getSkuOptionName());
            }
          }
        }
        jsonProductModel.put("jsonOptionAndSkuList", jsonOptionAndSkuList);
        jsonProductModel.put("jsonSkuOptionList", jsonSkuOptionList);
        jsonProductModel.put("jsonSkuOptionNameList", jsonSkuOptionNameList);
        jsonProductModel.put("jsonProduct", productJSONData(product, productSkuList));
        modelAndView.addObject("jsonProductModel", jsonProductModel.toString());
        modelAndView.addObject("jsonProduct", productJSONData(product, productSkuList));
      } else {
        // 普通产品或产品包
        // 为productSku设置促销价
        ProductSku defaultProductSku = product.getDefaultProductSku();
        promoService.appendPromoInfo(defaultProductSku);
        // 设置价格显示方式
        catalogHelper.setPriceViewType(defaultProductSku);
      }
    } else if (product.getStatus().intValue() == Constants.STATUS_INACTIVE) {
      // 非激活状态下,简单显示产品
      modelAndView = getModelAndView(defaultView);
    } else {
      response.setStatus(HttpServletResponse.SC_GONE);
      return getModelAndView("catalog/categoryErrorPage");
    }
    // 获取产品评论项
    List<ProductRateItem> productRateItemList =
        productRateItemManager.findProductRateItemsByProductType(product.getProductTypeId());
    modelAndView.addObject("productRateItemList", productRateItemList);

    // 获取产品附件组,及相应的附件项
    List<Map.Entry<AccessoryGroup, List<Accessory>>> productAccessoryList =
        productManager.getProductAccessoryMap(product.getProductId());
    modelAndView.addObject("productAccessoryList", productAccessoryList);

    // 获取产品对应的促销信息(待性能提升)
    Vector<PRule> rules = pruleManager.getCartPromotionRules();
    List<PRule> productRules = new ArrayList<PRule>();
    for (PRule prule : rules) {
      short conditionOperator = prule.getConditionOperator();
      if (prule.getRuleType().equals(PromoRule.PROMOTION_TYPE_CATALOGPROMOTION)) {
        conditionOperator += 2;
      }
      ConditionMaintainHandler conditionMaintainManager =
          new ConditionMaintainHandler(conditionOperator, prule.getConditions());
      if (conditionMaintainManager.run(product)) {
        productRules.add(prule);
      }
    }
    modelAndView.addObject("productRules", productRules);

    modelAndView.addObject("product", product);
    modelAndView.addObject("category", category);
    modelAndView.addObject("navigatorCategorys", navigatorCategorys);
    modelAndView.addObject("productMoreImages", productMoreImages);
    modelAndView.addObject("productMoreImagesUp", productMoreImagesUp);
    modelAndView.addObject("productaccessories", productaccessories);
    modelAndView.addObject("productAttGroups", productAttGroups);
    modelAndView.addObject("inventory", inventory);

    return modelAndView;
  }