...
|
...
|
@@ -2,6 +2,7 @@ package com.yohoufo.product.service.impl; |
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
...
|
...
|
@@ -29,6 +30,7 @@ import com.yohoufo.dal.product.BrandSeriesMapper; |
|
|
import com.yohoufo.dal.product.GoodsImagesMapper;
|
|
|
import com.yohoufo.dal.product.GoodsMapper;
|
|
|
import com.yohoufo.dal.product.ProductMapper;
|
|
|
import com.yohoufo.dal.product.SaleCategoryMapper;
|
|
|
import com.yohoufo.dal.product.SizeMapper;
|
|
|
import com.yohoufo.dal.product.StorageMapper;
|
|
|
import com.yohoufo.dal.product.StoragePriceMapper;
|
...
|
...
|
@@ -37,6 +39,7 @@ import com.yohoufo.dal.product.model.BrandSeries; |
|
|
import com.yohoufo.dal.product.model.Goods;
|
|
|
import com.yohoufo.dal.product.model.GoodsImages;
|
|
|
import com.yohoufo.dal.product.model.Product;
|
|
|
import com.yohoufo.dal.product.model.SaleCategory;
|
|
|
import com.yohoufo.dal.product.model.Size;
|
|
|
import com.yohoufo.dal.product.model.Storage;
|
|
|
import com.yohoufo.dal.product.model.StoragePrice;
|
...
|
...
|
@@ -51,6 +54,7 @@ import com.yohoufo.product.response.ProductDetailResp; |
|
|
import com.yohoufo.product.response.ProductSeriesTemplateResp;
|
|
|
import com.yohoufo.product.response.ProductSimpleResp;
|
|
|
import com.yohoufo.product.response.ProductSortTemplateResp;
|
|
|
import com.yohoufo.product.response.SaleCategoryBo;
|
|
|
import com.yohoufo.product.response.StorageDataResp;
|
|
|
import com.yohoufo.product.response.StorageLeastPriceResp;
|
|
|
import com.yohoufo.product.service.ProductService;
|
...
|
...
|
@@ -84,7 +88,10 @@ public class ProductServiceImpl implements ProductService{ |
|
|
|
|
|
@Autowired
|
|
|
private SizeMapper sizeMapper;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
private SaleCategoryMapper saleCategoryMapper;
|
|
|
|
|
|
@Override
|
|
|
public ProductDetailResp queryProductDetailById(Integer productId) {
|
|
|
ProductDetailResp productDetailResp = new ProductDetailResp();
|
...
|
...
|
@@ -641,6 +648,14 @@ public class ProductServiceImpl implements ProductService{ |
|
|
return url;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private String buildSaleCategoryFullUrl(String url) {
|
|
|
if (!StringUtils.startsWith(url, "http")){
|
|
|
return ImagesHelper.template2(url, "salecategoryimg").replaceAll("extent\\/\\{width}x\\{height}\\/","");
|
|
|
}else{
|
|
|
return url;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ProductSimpleResp queryPriceLimit(Integer productId) {
|
...
|
...
|
@@ -683,4 +698,48 @@ public class ProductServiceImpl implements ProductService{ |
|
|
public int sellerBatchUpdatePrice(List<Integer> skupList, Double price) {
|
|
|
return storagePriceMapper.updateBatchPrice(skupList, price);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<SaleCategoryBo> querySaleCategory() {
|
|
|
// 查数据库List
|
|
|
List<SaleCategory> dbData = saleCategoryMapper.selectValid();
|
|
|
List<SaleCategoryBo> result = new ArrayList<>();
|
|
|
dbData.forEach(data -> {
|
|
|
result.add(exchange(data));
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<SaleCategoryBo> querySaleCategoryDetail(Integer id) {
|
|
|
List<SaleCategoryBo> result = new ArrayList<>();
|
|
|
List<SaleCategory> secondCat = saleCategoryMapper.selectByPidList(Arrays.asList(id));
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(secondCat)) {
|
|
|
secondCat.forEach(data -> {
|
|
|
result.add(exchange(data));
|
|
|
});
|
|
|
Map<Integer, SaleCategoryBo> map = result.stream().collect(Collectors.toMap(SaleCategoryBo::getId, Function.identity()));
|
|
|
List<Integer> secondCatIds = secondCat.stream().map(SaleCategory::getId).collect(Collectors.toList());
|
|
|
List<SaleCategory> thirdCat = saleCategoryMapper.selectByPidList(secondCatIds);
|
|
|
thirdCat.forEach(t -> {
|
|
|
SaleCategoryBo bo = map.get(t.getParentId());
|
|
|
if (bo != null) {
|
|
|
bo.getSub().add(exchange(t));
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
private SaleCategoryBo exchange(SaleCategory data) {
|
|
|
SaleCategoryBo sc = new SaleCategoryBo();
|
|
|
sc.setId(data.getId());
|
|
|
sc.setName(data.getCategoryName());
|
|
|
sc.setLinkType(data.getLinkType());
|
|
|
sc.setLink(data.getLinkDetail());
|
|
|
sc.setImage(buildSaleCategoryFullUrl(data.getImageUrl()));
|
|
|
sc.setSub(new ArrayList<>());
|
|
|
return null;
|
|
|
}
|
|
|
} |
...
|
...
|
|