Ejemplo n.º 1
0
  @RequestMapping(value = "/product/title/update", method = RequestMethod.POST)
  public void updateTitle(
      @RequestParam("productId") Integer productId,
      @RequestParam("productCode") String productCode,
      @RequestParam("name") String name,
      @RequestParam("description") String description,
      @RequestParam("tagType") String tagType,
      HttpServletResponse response)
      throws IOException {
    try {
      Product product = productService.getProductById(productId);
      product.setName(name);
      product.setDescription(description);
      product.setProductCode(productCode);
      product.setTagType(getTagType(tagType));
      productService.updateProduct(product);

      productService.notifyProductUpdate(productId);
    } catch (Exception e) {
      logger.error("商品管理的更新商品信息异常:" + e);
      new JsonResult(false, "更新商品信息出错").toJson(response);
      return;
    }
    new JsonResult(true).toJson(response);
  }
Ejemplo n.º 2
0
 @RequestMapping(value = "/product/html/new", method = RequestMethod.POST)
 public void crateHtmlDesc(Html html, HttpServletResponse response) throws IOException {
   try {
     HtmlDesc htmlDesc = productService.getHtmlDesc(html.getProductId());
     if (htmlDesc.hasHtml(html.getName())) {
       new JsonResult(false, "名字重复了").toJson(response);
       return;
     }
     productService.createHtml(html);
   } catch (Exception e) {
     logger.error("商品管理的添加描述信息异常:" + e);
     new JsonResult(false, "添加描述信息出错").toJson(response);
     return;
   }
   new JsonResult(true).toJson(response);
 }
Ejemplo n.º 3
0
  /**
   * 根据订单Id查询Sku列表
   *
   * @param orderId
   * @return
   */
  @RequestMapping(value = "/order/sku/{orderId}")
  public void skuGrid(@PathVariable("orderId") int orderId, HttpServletResponse response)
      throws IOException {
    List<OrderItem> orderItems =
        tradeCenterBossClient.queryOrderItemWithoutBackingNumberByOrderId(orderId);
    List<ProductSku> list = new ArrayList<ProductSku>();
    for (OrderItem orderItem : orderItems) {
      ProductSku sku = new ProductSku();
      sku.setNumber(orderItem.getNumber());
      sku.setSkuId(orderItem.getSkuId());
      sku.setProductId(orderItem.getProductId());
      sku.setSkuState(orderItem.getOrderState().serviceDesc());
      sku.setShipmentNum(orderItem.getShipmentNum());
      sku.setBackNumber(orderItem.getBackNum());
      sku.setBarCode(orderItem.getBarCode());
      StockKeepingUnit stockKeepingUnit = skuService.getStockKeepingUnit(orderItem.getSkuId());
      if (stockKeepingUnit != null) {
        Product product = productService.getProductById(stockKeepingUnit.getProductId());
        Money money = new Money();
        money.setCent(stockKeepingUnit.getPrice());
        sku.setSkuPrice(money.toString());
        sku.setProductName(product.getName());
        sku.setAttribute(skuService.getSkuPropertyToString(stockKeepingUnit));
        sku.setProductCode(stockKeepingUnit.getSkuCode()); // product.getProductCode());
      } else {
        sku.setProductName("没有此 SKU! 被删除或重新生成过.");
      }

      list.add(sku);
    }
    new JsonResult(true)
        .addData("totalCount", list.size())
        .addData("result", list)
        .toJson(response);
  }
Ejemplo n.º 4
0
 @RequestMapping(value = "/product/html/list/{productId}")
 public void productHtmlDesc(
     @PathVariable("productId") int productId, HttpServletResponse response) throws IOException {
   HtmlDesc htmlDesc = productService.getHtmlDesc(productId);
   new JsonResult(true)
       .addData("totalCount", htmlDesc.getHtmlList().size())
       .addData("result", htmlDesc.getHtmlList())
       .toJson(response);
 }
Ejemplo n.º 5
0
 /**
  * 通过商品编码查询
  *
  * @param code
  * @param response
  * @throws IOException
  */
 @RequestMapping(value = "/product/list/code")
 public void productListByCode(String code, HttpServletResponse response) throws IOException {
   Product productByCode = productService.getProductByCode(code);
   List<Product> list = new LinkedList<Product>();
   if (productByCode != null) {
     list.add(productByCode);
   }
   List<ProductModel> productGrid = createProductGrid(list);
   new JsonResult(true).addData("totalCount", 1).addData("result", productGrid).toJson(response);
 }
Ejemplo n.º 6
0
 @RequestMapping(value = "/product/html/update", method = RequestMethod.POST)
 public void updateHtmlDesc(Html html, HttpServletResponse response) throws IOException {
   try {
     productService.updateHtml(html);
   } catch (Exception e) {
     logger.error("商品管理的更新描述信息异常:" + e);
     new JsonResult(false, "更新描述信息出错").toJson(response);
     return;
   }
   new JsonResult(true).toJson(response);
 }
Ejemplo n.º 7
0
 @RequestMapping(value = "/product/deleteBrandNameForAllProduct", method = RequestMethod.POST)
 public void deleteBrandNameForAllProduct(HttpServletResponse response) throws IOException {
   try {
     int changeCount = productService.deleteBrandNameForAllProduct();
     new JsonResult(
             true, changeCount > 0 ? "商品名更新成功! 共更新" + changeCount + "个产品名称." : "未匹配到需要更新的商品名!")
         .toJson(response);
   } catch (Exception e) {
     logger.error("更新常数时异常:" + e.getMessage());
     new JsonResult(false, e.getMessage()).toJson(response);
   }
 }
Ejemplo n.º 8
0
 @RequestMapping(value = "/product/html/delete", method = RequestMethod.POST)
 public void deleteHtmlDesc(
     @RequestParam("productId") Integer productId,
     @RequestParam("names") String[] names,
     HttpServletResponse response)
     throws IOException {
   try {
     productService.deleteHtmlDesc(productId, names);
   } catch (Exception e) {
     logger.error("商品管理的删除描述信息异常:" + e);
     new JsonResult(false, "删除描述信息出错").toJson(response);
     return;
   }
   new JsonResult(true).toJson(response);
 }
Ejemplo n.º 9
0
 /**
  * 带状态的商品列表
  *
  * @param start
  * @param limit
  * @param online
  * @param response
  * @throws IOException
  */
 @RequestMapping(value = "/product/list/status")
 public void productOnlineStatusList(
     @RequestParam int start,
     @RequestParam int limit,
     boolean online,
     HttpServletResponse response)
     throws IOException {
   Page<Product> productPage =
       productService.queryProductsByOnlineStatus(
           online, new Page<Product>(start / limit + 1, limit));
   List<ProductModel> productGrid = createProductGrid(productPage.getResult());
   new JsonResult(true)
       .addData("totalCount", productPage.getTotalCount())
       .addData("result", productGrid)
       .toJson(response);
 }
Ejemplo n.º 10
0
 /**
  * 读取产品列表
  *
  * @param productQuery
  * @return
  */
 @RequestMapping(value = "/product/list")
 public void productList(ProductQuery productQuery, HttpServletResponse response)
     throws IOException {
   List<Product> productList = new ArrayList<Product>();
   int total = 0;
   if (productQuery.isProductId()) { // 如果有ID筛选
     Product product = productService.getProductById(NumberUtils.toInt(productQuery.getSearch()));
     if (product != null) {
       productList.add(product);
       total = 1;
     }
   } else if (productQuery.getSearch().length() > 0) { // 模糊查询
     Page<Product> page;
     page =
         productService.queryProductByFuzzyPage(
             productQuery.getSearch(), productQuery.getPageNo(), productQuery.getLimit());
     productList = page.getResult();
     total = page.getTotalCount();
   } else {
     Page<Product> page;
     if (productQuery.getCategoryId() > 0) {
       page =
           productService.queryProductsByCategoryIdByPage(
               productQuery.getCategoryId(), productQuery.getPageNo(), productQuery.getLimit());
     } else if (productQuery.getCustomerId() > 0) {
       page =
           productService.queryProductsByCustomerIdByPage(
               productQuery.getCustomerId(), productQuery.getPageNo(), productQuery.getLimit());
     } else if (productQuery.getBrandId() > 0) {
       page =
           productService.queryProductsByBrandIdByPage(
               productQuery.getBrandId(), productQuery.getPageNo(), productQuery.getLimit());
     } else if (productQuery.getStoreId() > 0) {
       page =
           productService.queryProductsByStoreIdByPage(
               productQuery.getStoreId(), productQuery.getPageNo(), productQuery.getLimit());
     } else {
       page =
           productService.queryAllProductsByPage(
               productQuery.getPageNo(), productQuery.getLimit());
     }
     productList = page.getResult();
     total = page.getTotalCount();
   }
   List<ProductModel> productGrid = createProductGrid(productList);
   new JsonResult(true)
       .addData("totalCount", total)
       .addData("result", productGrid)
       .toJson(response);
 }