@Override
 @Transactional
 public void updateStatus(Long objectId, int status) {
   ProductCategory category = new ProductCategory();
   category.setObjectId(objectId);
   category.setStatus(status);
   productCategoryDao.updateStatus(category);
 }
 /**
  * 构造商品运营分类Left tree的结构
  *
  * @param 商品运营分类List
  * @return Left tree的HTML
  */
 @Override
 public ProductCategory getProductCategoryByFirstId(String firstId) {
   ProductCategory sample = new ProductCategory();
   sample.setFirstId(firstId);
   sample.setLayer(1);
   List<ProductCategory> list = getBySample(sample);
   if (list.size() > 0) {
     return list.get(0);
   }
   return null;
 }
 /**
  * 根据三级分类ID得到三级分类
  *
  * @param 三级分类ID
  * @return 三级分类
  */
 @Override
 public ProductCategory getProductCategoryByThirdId(String thirdId) {
   ProductCategory productCategory = new ProductCategory();
   productCategory.setThirdId(thirdId);
   productCategory.setLayer(3);
   List<ProductCategory> list = getBySample(productCategory);
   if (list.size() > 0) {
     return list.get(0);
   }
   return null;
 }
 @Override
 @Transactional
 public void updateSortNoByObjectId(String objectIds, String sortNos) {
   String[] ids = objectIds.split(",");
   String[] nos = sortNos.split(",");
   for (int i = 0; i < ids.length; i++) {
     try {
       Long objectId = Long.parseLong(ids[i]);
       Double sortNo = Double.parseDouble(nos[i]);
       ProductCategory category = new ProductCategory();
       category.setSortNo(sortNo);
       category.setObjectId(objectId);
       productCategoryDao.updateSortNo(category);
     } catch (Exception e) {
       LOGGER.error("updateSortNoByObjectId", e);
     }
   }
 }
  /** 保存时三级分类ID的序列化 */
  @Override
  @Transactional
  public ProductCategory save(ProductCategory entity) {
    if (entity.getLayer() == 1) {
      if (StringUtils.isBlank(entity.getFirstId())) {
        String firstId = sequenceManager.getNextId("SEQ_FIRST_ID").toString();
        entity.setFirstId(firstId);
      }
    } else if (entity.getLayer() == 2) {
      if (StringUtils.isBlank(entity.getSecondId())) {
        String secondId = sequenceManager.getNextId("SEQ_SECOND_ID").toString();
        entity.setSecondId(secondId);
      }
    } else if (entity.getLayer() == 3) {
      if (StringUtils.isBlank(entity.getThirdId())) {
        String thirdId = sequenceManager.getNextId("SEQ_THIRD_ID").toString();
        entity.setThirdId(thirdId);
      }
    } else {

    }
    return super.save(entity);
  }
 /**
  * 判断一个分类是否置为无效 1.二级分类下面有有效分类一级分类不能为无效 2.三级分类下面全部为无效则二级可为无效 3.关联的福利商城分类有效则三级分类不能无效
  * 4.该分类下面有商品(无论商品是什么状态)都不能置为无效
  *
  * @param objectId
  * @return
  */
 @Override
 public boolean canInvalid(Long objectId) {
   if (objectId == null) {
     return true;
   }
   ProductCategory category = getByObjectId(objectId);
   if (category.getLayer() == 1) {
     ProductCategory sample = new ProductCategory();
     sample.setFirstId(category.getFirstId());
     sample.setStatus(IBSConstants.EFFECTIVE);
     sample.setLayer(2);
     long count = getObjectCount(sample);
     if (count != 0) {
       return false;
     }
   } else if (category.getLayer() == 2) {
     ProductCategory sample = new ProductCategory();
     sample.setSecondId(category.getSecondId());
     sample.setStatus(IBSConstants.EFFECTIVE);
     sample.setLayer(3);
     long count = getObjectCount(sample);
     if (count != 0) {
       return false;
     }
   } else {
     // 是否有关联的福利商城的分类
     long mallCategoryCount =
         productMallCategoryDao.getRelatedProductMallCategoryByCategoryId(objectId);
     if (mallCategoryCount != 0) {
       return false;
     }
     Product sample = new Product();
     sample.setCategoryId(objectId);
     sample.setDeleted(IBSConstants.STATUS_NO);
     long count = productManager.getObjectCount(sample);
     if (count != 0) {
       return false;
     }
   }
   return true;
 }
 /**
  * 判断一个分类是否能被删除 1.该分类下面有商品(无论商品是什么状态)都不能删除 2.二级分类下面有三级分类(无论状态是什么)不能删除该二级分类
  * 3.一级分类下面有二级分类(无论状态是什么)不能删除该一级分类
  *
  * @param objectId
  * @return
  */
 @Override
 public boolean canDelete(Long objectId) {
   if (objectId == null) {
     return false;
   }
   ProductCategory category = getByObjectId(objectId);
   if (category.getLayer() == 1) {
     ProductCategory sample = new ProductCategory();
     sample.setFirstId(category.getFirstId());
     sample.setLayer(2);
     long count = getObjectCount(sample);
     if (count != 0) {
       return false;
     }
   } else if (category.getLayer() == 2) {
     ProductCategory sample = new ProductCategory();
     sample.setSecondId(category.getSecondId());
     sample.setLayer(3);
     long count = getObjectCount(sample);
     if (count != 0) {
       return false;
     }
   } else {
     Product sample = new Product();
     sample.setCategoryId(objectId);
     sample.setDeleted(IBSConstants.STATUS_NO);
     long count = productManager.getObjectCount(sample);
     if (count != 0) {
       return false;
     }
   }
   return true;
 }