Authored by mali

二手筛选项

... ... @@ -20,6 +20,8 @@ public enum UfoProductCacheKeyEnum {
PRODUCT_STORAGE_INFO_KEY("ufo:product:storageInfo:", "商品SKU信息", 15, TimeUnit.MINUTES),
PRODUCT_STORAGE_BASE_INFO_KEY("ufo:product:baseStorageInfo:", "商品SKU基本信息", 15, TimeUnit.MINUTES),
SIZE_LIST_CACHE_KEY("ufo:product:sizeList:", "尺码列表", 15, TimeUnit.MINUTES),
STORAGE_PRICE_IN_STOCK_INFO_KEY("ufo:product:storagePrice:inStock", "商品现货价格信息", 5, TimeUnit.MINUTES),
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.product.service.cache;
import com.google.common.collect.Maps;
import com.yoho.core.cache.LocalCache;
import com.yoho.core.cache.LocalCacheCallback;
import com.yohoufo.common.helper.ImageUrlAssist;
import com.yohoufo.dal.product.BrandMapper;
import com.yohoufo.dal.product.model.Brand;
import com.yohoufo.product.cache.UfoProductCacheKeyEnum;
... ... @@ -68,6 +69,7 @@ public class BrandCacheService implements LocalCacheService {
LOG.warn("No data in database table (brand).");
collect = Maps.newHashMap();
} else {
brandList.forEach(item -> item.setBrandLogo(ImageUrlAssist.getAllProductPicUrl(item.getBrandLogo(), "brandLogo", "center", "d2hpdGU=")));
collect = brandList.stream().collect(Collectors.toMap(Brand::getId, Function.identity()));
}
LOG.info("end load allBrand, costTime:{}", System.currentTimeMillis()-beginTime);
... ...
... ... @@ -18,6 +18,8 @@ import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.OrikaUtils;
import com.yohoufo.dal.product.*;
import com.yohoufo.dal.product.model.*;
import com.yohoufo.product.service.cache.BrandCacheService;
import com.yohoufo.product.service.cache.SizeCacheService;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
... ... @@ -89,6 +91,9 @@ public class ProductServiceImpl implements ProductService {
private BrandMapper brandMapper;
@Autowired
private BrandCacheService brandCacheService;
@Autowired
private BrandSeriesMapper brandSeriesMapper;
@Autowired
... ... @@ -166,6 +171,9 @@ public class ProductServiceImpl implements ProductService {
@Autowired
private BidProductService bidProductService;
@Autowired
private SizeCacheService sizeCacheService;
@Override
public ProductDetailResp queryProductDetailById(Integer productId) {
ProductDetailResp productDetailResp = new ProductDetailResp();
... ... @@ -1610,10 +1618,15 @@ public class ProductServiceImpl implements ProductService {
@Override
public JSONObject querySecondHandProductListFilter(Integer storageId) {
Storage storage = storageMapper.selectByPrimaryKey(storageId);
Size size = sizeMapper.selectByPrimaryKey(storage.getSizeId());
Product product = productMapper.selectByPrimaryKey(storage.getProductId());
Brand brand = brandMapper.selectByPrimaryKey(product.getBrandId());
Storage storage = storageService.selectStorageByCache(storageId);
//Storage storage = storageMapper.selectByPrimaryKey(storageId);
// Size size = sizeMapper.selectByPrimaryKey(storage.getSizeId());
String sizeName = sizeCacheService.queryNameBySizeId(storage.getSizeId());
Product product = productHelpService.selectByIdCache(storage.getProductId());
//Product product = productMapper.selectByPrimaryKey(storage.getProductId());
//Brand brand = brandMapper.selectByPrimaryKey(product.getBrandId());
Brand brand = brandCacheService.queryByBrandId(product.getBrandId());
List<Integer> type = storagePriceMapper.selectSecondHandType(storageId);
JSONObject jo = new JSONObject();
... ... @@ -1644,7 +1657,7 @@ public class ProductServiceImpl implements ProductService {
JSONArray filterSizeItemArray = new JSONArray();
JSONObject filterSizeItem = new JSONObject();
filterSizeItem.put("itemId", storageId);
filterSizeItem.put("itemName", size.getSizeName());
filterSizeItem.put("itemName", sizeName);
filterSizeItemArray.add(filterSizeItem);
filterSize.put("itemList", filterSizeItemArray);
filterArray.add(filterSize);
... ... @@ -1657,7 +1670,7 @@ public class ProductServiceImpl implements ProductService {
JSONObject filterBrandItem = new JSONObject();
filterBrandItem.put("itemId", brand.getId());
filterBrandItem.put("itemName", brand.getBrandName());
filterBrandItem.put("itemUrl", ImageUrlAssist.getAllProductPicUrl(brand.getBrandLogo(), "brandLogo", "center", "d2hpdGU="));
filterBrandItem.put("itemUrl", brand.getBrandLogo());
filterBrandItemArray.add(filterBrandItem);
filterBrand.put("itemList", filterBrandItemArray);
filterArray.add(filterBrand);
... ...
... ... @@ -79,4 +79,14 @@ public class StorageService {
productCacheService.setCacheByString(UfoProductCacheKeyEnum.PRODUCT_STORAGE_INFO_KEY, result, goodsBO.getId());
return result;
}
public Storage selectStorageByCache(Integer storageId) {
Storage cacheById = productCacheService.getCacheByString(UfoProductCacheKeyEnum.PRODUCT_STORAGE_BASE_INFO_KEY, Storage.class, storageId);
if (null != cacheById) {
return cacheById;
}
Storage storage = storageMapper.selectByPrimaryKey(storageId);
productCacheService.setCacheByString(UfoProductCacheKeyEnum.PRODUCT_STORAGE_BASE_INFO_KEY, storage, storageId);
return storage;
}
}
... ...