|
|
package com.yohoufo.product.service.impl;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yohobuy.ufo.model.GoodsSize;
|
|
|
import com.yohobuy.ufo.model.ProductInfo;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.product.BrandSeriesMapper;
|
|
|
import com.yohoufo.dal.product.ProductMapper;
|
|
|
import com.yohoufo.dal.product.model.Brand;
|
|
|
import com.yohoufo.dal.product.model.BrandSeries;
|
|
|
import com.yohoufo.dal.product.model.Product;
|
|
|
import com.yohoufo.dal.product.ProductSortMapper;
|
|
|
import com.yohoufo.dal.product.SizeMapper;
|
|
|
import com.yohoufo.dal.product.model.*;
|
|
|
import com.yohoufo.product.cache.UfoProductCacheKeyEnum;
|
|
|
import com.yohoufo.product.cache.UfoProductCacheService;
|
|
|
import com.yohoufo.product.service.cache.BrandCacheService;
|
...
|
...
|
@@ -19,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
import java.util.Optional;
|
...
|
...
|
@@ -46,6 +48,12 @@ public class ProductHelpService { |
|
|
@Autowired
|
|
|
private BidProductService bidProductService;
|
|
|
|
|
|
@Autowired
|
|
|
private ProductSortMapper productSortMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private SizeMapper sizeMapper;
|
|
|
|
|
|
public ProductInfo convertProductInfo(Product product) {
|
|
|
ProductInfo productInfo = new ProductInfo();
|
|
|
productInfo.setProductId(product.getId());
|
...
|
...
|
@@ -143,4 +151,23 @@ public class ProductHelpService { |
|
|
productInfo.setMosterPrice(mosterPrice);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public List<Size> getAllSizeBySortId(Integer sortId) {
|
|
|
List<Size> cache = productCacheService.getListCacheByString(UfoProductCacheKeyEnum.ALL_SIZE_BY_SORTID_KEY, Size.class, sortId);
|
|
|
if (CollectionUtils.isEmpty(cache)) {
|
|
|
ProductSort sort = productSortMapper.selectByPrimaryKey(sortId);
|
|
|
List<Size> sizes = Lists.newArrayList();
|
|
|
if (sort != null) {
|
|
|
List<Integer> idList = new ArrayList<>();
|
|
|
idList.add(sortId);
|
|
|
if (sort.getParentId() != null && sort.getParentId() > 0) {
|
|
|
idList.add(sort.getParentId());
|
|
|
}
|
|
|
sizes = sizeMapper.selectAllSizeBySortIdList(idList);
|
|
|
}
|
|
|
productCacheService.setCacheByString(UfoProductCacheKeyEnum.ALL_SIZE_BY_SORTID_KEY, sizes, sortId);
|
|
|
return sizes;
|
|
|
}
|
|
|
return cache;
|
|
|
}
|
|
|
} |
...
|
...
|
|