...
|
...
|
@@ -3,7 +3,6 @@ package com.yoho.ufo.service.impl; |
|
|
import com.yoho.core.common.utils.DateUtil;
|
|
|
import com.yoho.ufo.dal.SaleCategoryMapper;
|
|
|
import com.yoho.ufo.exception.CommonException;
|
|
|
import com.yoho.ufo.model.commoditybasicrole.category.ProductSort;
|
|
|
import com.yoho.ufo.model.salecategory.SaleCategory;
|
|
|
import com.yoho.ufo.service.ISaleCategoryService;
|
|
|
import com.yoho.ufo.util.OrikaUtils;
|
...
|
...
|
@@ -40,6 +39,35 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService { |
|
|
@Autowired
|
|
|
private SaleCategoryMapper saleCategoryMapper;
|
|
|
|
|
|
@Override
|
|
|
public void updateStatus(SaleCategoryResponseBo saleCategoryResponseBo){
|
|
|
log.info("updateStatus param = {}", saleCategoryResponseBo);
|
|
|
|
|
|
SaleCategory db_saleCategory = saleCategoryMapper.selectById(saleCategoryResponseBo.getId());
|
|
|
if(db_saleCategory==null){
|
|
|
throw new CommonException(201, "找不到销售类目!");
|
|
|
}
|
|
|
Integer newStatus = saleCategoryResponseBo.getStatus();
|
|
|
if(db_saleCategory.getStatus().equals(newStatus)){
|
|
|
return ;
|
|
|
}
|
|
|
|
|
|
//关闭就直接关闭,开启需要检查上一级是否开启,如果上一级没开启就提示,需要先开启上一级
|
|
|
if(newStatus==0){
|
|
|
//检查上一级
|
|
|
if(db_saleCategory.getLevel()>PRODUCT_SORT_LEVEL_1){
|
|
|
SaleCategory parent_saleCategory = saleCategoryMapper.selectById(saleCategoryResponseBo.getParentId());
|
|
|
if(parent_saleCategory!=null&&!parent_saleCategory.getStatus().equals(0)){
|
|
|
throw new CommonException(201, "请先开启上级类目!");
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
newStatus = 1;
|
|
|
}
|
|
|
saleCategoryMapper.updateStatusById(saleCategoryResponseBo.getId(),newStatus,DateUtil.currentTimeSeconds());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void saveOrUpdateSaleCategory(SaleCategoryResponseBo saleCategoryResponseBo){
|
|
|
log.info("saveOrUpdateSaleCategory param = {}", saleCategoryResponseBo);
|
|
|
SaleCategory saleCategory = OrikaUtils.map(saleCategoryResponseBo, SaleCategory.class);
|
...
|
...
|
@@ -70,6 +98,9 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService { |
|
|
} else {
|
|
|
// 更新
|
|
|
SaleCategory db_saleCategory = saleCategoryMapper.selectById(saleCategory.getId());
|
|
|
if(db_saleCategory==null){
|
|
|
throw new CommonException(201, "找不到销售类目!");
|
|
|
}
|
|
|
db_saleCategory.setCategoryName(saleCategoryResponseBo.getCategoryName());
|
|
|
db_saleCategory.setOrderBy(saleCategoryResponseBo.getOrderBy());
|
|
|
db_saleCategory.setUpdateTime(DateUtil.currentTimeSeconds());
|
...
|
...
|
@@ -87,6 +118,7 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService { |
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public SaleCategoryResponseBo getSaleCategoryById(Integer id){
|
|
|
log.info("enter getSaleCategoryById param = {}",id);
|
|
|
SaleCategory saleCategory = saleCategoryMapper.selectById(id);
|
...
|
...
|
@@ -96,6 +128,7 @@ public class SaleCategoryServiceImpl implements ISaleCategoryService { |
|
|
return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<SaleCategoryTreeViewResponseBo> getSaleCategoryList() {
|
|
|
log.info("enter getSaleCategoryList param = {}");
|
|
|
List<SaleCategory> productSorts = saleCategoryMapper.selectAll();
|
...
|
...
|
|