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
  /**
   * 根据订单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.º 3
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);
 }