@Override @Transactional public void updateStatus(Long objectId, int status) { ProductCategory category = new ProductCategory(); category.setObjectId(objectId); category.setStatus(status); productCategoryDao.updateStatus(category); }
/** * 判断一个分类是否置为无效 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; }