Authored by mali

二手筛选项

@@ -20,6 +20,8 @@ public enum UfoProductCacheKeyEnum { @@ -20,6 +20,8 @@ public enum UfoProductCacheKeyEnum {
20 20
21 PRODUCT_STORAGE_INFO_KEY("ufo:product:storageInfo:", "商品SKU信息", 15, TimeUnit.MINUTES), 21 PRODUCT_STORAGE_INFO_KEY("ufo:product:storageInfo:", "商品SKU信息", 15, TimeUnit.MINUTES),
22 22
  23 + PRODUCT_STORAGE_BASE_INFO_KEY("ufo:product:baseStorageInfo:", "商品SKU基本信息", 15, TimeUnit.MINUTES),
  24 +
23 SIZE_LIST_CACHE_KEY("ufo:product:sizeList:", "尺码列表", 15, TimeUnit.MINUTES), 25 SIZE_LIST_CACHE_KEY("ufo:product:sizeList:", "尺码列表", 15, TimeUnit.MINUTES),
24 26
25 STORAGE_PRICE_IN_STOCK_INFO_KEY("ufo:product:storagePrice:inStock", "商品现货价格信息", 5, TimeUnit.MINUTES), 27 STORAGE_PRICE_IN_STOCK_INFO_KEY("ufo:product:storagePrice:inStock", "商品现货价格信息", 5, TimeUnit.MINUTES),
@@ -3,6 +3,7 @@ package com.yohoufo.product.service.cache; @@ -3,6 +3,7 @@ package com.yohoufo.product.service.cache;
3 import com.google.common.collect.Maps; 3 import com.google.common.collect.Maps;
4 import com.yoho.core.cache.LocalCache; 4 import com.yoho.core.cache.LocalCache;
5 import com.yoho.core.cache.LocalCacheCallback; 5 import com.yoho.core.cache.LocalCacheCallback;
  6 +import com.yohoufo.common.helper.ImageUrlAssist;
6 import com.yohoufo.dal.product.BrandMapper; 7 import com.yohoufo.dal.product.BrandMapper;
7 import com.yohoufo.dal.product.model.Brand; 8 import com.yohoufo.dal.product.model.Brand;
8 import com.yohoufo.product.cache.UfoProductCacheKeyEnum; 9 import com.yohoufo.product.cache.UfoProductCacheKeyEnum;
@@ -68,6 +69,7 @@ public class BrandCacheService implements LocalCacheService { @@ -68,6 +69,7 @@ public class BrandCacheService implements LocalCacheService {
68 LOG.warn("No data in database table (brand)."); 69 LOG.warn("No data in database table (brand).");
69 collect = Maps.newHashMap(); 70 collect = Maps.newHashMap();
70 } else { 71 } else {
  72 + brandList.forEach(item -> item.setBrandLogo(ImageUrlAssist.getAllProductPicUrl(item.getBrandLogo(), "brandLogo", "center", "d2hpdGU=")));
71 collect = brandList.stream().collect(Collectors.toMap(Brand::getId, Function.identity())); 73 collect = brandList.stream().collect(Collectors.toMap(Brand::getId, Function.identity()));
72 } 74 }
73 LOG.info("end load allBrand, costTime:{}", System.currentTimeMillis()-beginTime); 75 LOG.info("end load allBrand, costTime:{}", System.currentTimeMillis()-beginTime);
@@ -18,6 +18,8 @@ import com.yohoufo.common.exception.UfoServiceException; @@ -18,6 +18,8 @@ import com.yohoufo.common.exception.UfoServiceException;
18 import com.yohoufo.common.utils.OrikaUtils; 18 import com.yohoufo.common.utils.OrikaUtils;
19 import com.yohoufo.dal.product.*; 19 import com.yohoufo.dal.product.*;
20 import com.yohoufo.dal.product.model.*; 20 import com.yohoufo.dal.product.model.*;
  21 +import com.yohoufo.product.service.cache.BrandCacheService;
  22 +import com.yohoufo.product.service.cache.SizeCacheService;
21 import org.apache.commons.collections.MapUtils; 23 import org.apache.commons.collections.MapUtils;
22 import org.apache.commons.lang.ArrayUtils; 24 import org.apache.commons.lang.ArrayUtils;
23 import org.apache.commons.lang3.StringUtils; 25 import org.apache.commons.lang3.StringUtils;
@@ -89,6 +91,9 @@ public class ProductServiceImpl implements ProductService { @@ -89,6 +91,9 @@ public class ProductServiceImpl implements ProductService {
89 private BrandMapper brandMapper; 91 private BrandMapper brandMapper;
90 92
91 @Autowired 93 @Autowired
  94 + private BrandCacheService brandCacheService;
  95 +
  96 + @Autowired
92 private BrandSeriesMapper brandSeriesMapper; 97 private BrandSeriesMapper brandSeriesMapper;
93 98
94 @Autowired 99 @Autowired
@@ -165,6 +170,9 @@ public class ProductServiceImpl implements ProductService { @@ -165,6 +170,9 @@ public class ProductServiceImpl implements ProductService {
165 170
166 @Autowired 171 @Autowired
167 private BidProductService bidProductService; 172 private BidProductService bidProductService;
  173 +
  174 + @Autowired
  175 + private SizeCacheService sizeCacheService;
168 176
169 @Override 177 @Override
170 public ProductDetailResp queryProductDetailById(Integer productId) { 178 public ProductDetailResp queryProductDetailById(Integer productId) {
@@ -1610,10 +1618,15 @@ public class ProductServiceImpl implements ProductService { @@ -1610,10 +1618,15 @@ public class ProductServiceImpl implements ProductService {
1610 1618
1611 @Override 1619 @Override
1612 public JSONObject querySecondHandProductListFilter(Integer storageId) { 1620 public JSONObject querySecondHandProductListFilter(Integer storageId) {
1613 - Storage storage = storageMapper.selectByPrimaryKey(storageId);  
1614 - Size size = sizeMapper.selectByPrimaryKey(storage.getSizeId());  
1615 - Product product = productMapper.selectByPrimaryKey(storage.getProductId());  
1616 - Brand brand = brandMapper.selectByPrimaryKey(product.getBrandId()); 1621 + Storage storage = storageService.selectStorageByCache(storageId);
  1622 + //Storage storage = storageMapper.selectByPrimaryKey(storageId);
  1623 + // Size size = sizeMapper.selectByPrimaryKey(storage.getSizeId());
  1624 + String sizeName = sizeCacheService.queryNameBySizeId(storage.getSizeId());
  1625 + Product product = productHelpService.selectByIdCache(storage.getProductId());
  1626 + //Product product = productMapper.selectByPrimaryKey(storage.getProductId());
  1627 + //Brand brand = brandMapper.selectByPrimaryKey(product.getBrandId());
  1628 + Brand brand = brandCacheService.queryByBrandId(product.getBrandId());
  1629 +
1617 List<Integer> type = storagePriceMapper.selectSecondHandType(storageId); 1630 List<Integer> type = storagePriceMapper.selectSecondHandType(storageId);
1618 1631
1619 JSONObject jo = new JSONObject(); 1632 JSONObject jo = new JSONObject();
@@ -1644,7 +1657,7 @@ public class ProductServiceImpl implements ProductService { @@ -1644,7 +1657,7 @@ public class ProductServiceImpl implements ProductService {
1644 JSONArray filterSizeItemArray = new JSONArray(); 1657 JSONArray filterSizeItemArray = new JSONArray();
1645 JSONObject filterSizeItem = new JSONObject(); 1658 JSONObject filterSizeItem = new JSONObject();
1646 filterSizeItem.put("itemId", storageId); 1659 filterSizeItem.put("itemId", storageId);
1647 - filterSizeItem.put("itemName", size.getSizeName()); 1660 + filterSizeItem.put("itemName", sizeName);
1648 filterSizeItemArray.add(filterSizeItem); 1661 filterSizeItemArray.add(filterSizeItem);
1649 filterSize.put("itemList", filterSizeItemArray); 1662 filterSize.put("itemList", filterSizeItemArray);
1650 filterArray.add(filterSize); 1663 filterArray.add(filterSize);
@@ -1657,7 +1670,7 @@ public class ProductServiceImpl implements ProductService { @@ -1657,7 +1670,7 @@ public class ProductServiceImpl implements ProductService {
1657 JSONObject filterBrandItem = new JSONObject(); 1670 JSONObject filterBrandItem = new JSONObject();
1658 filterBrandItem.put("itemId", brand.getId()); 1671 filterBrandItem.put("itemId", brand.getId());
1659 filterBrandItem.put("itemName", brand.getBrandName()); 1672 filterBrandItem.put("itemName", brand.getBrandName());
1660 - filterBrandItem.put("itemUrl", ImageUrlAssist.getAllProductPicUrl(brand.getBrandLogo(), "brandLogo", "center", "d2hpdGU=")); 1673 + filterBrandItem.put("itemUrl", brand.getBrandLogo());
1661 filterBrandItemArray.add(filterBrandItem); 1674 filterBrandItemArray.add(filterBrandItem);
1662 filterBrand.put("itemList", filterBrandItemArray); 1675 filterBrand.put("itemList", filterBrandItemArray);
1663 filterArray.add(filterBrand); 1676 filterArray.add(filterBrand);
@@ -79,4 +79,14 @@ public class StorageService { @@ -79,4 +79,14 @@ public class StorageService {
79 productCacheService.setCacheByString(UfoProductCacheKeyEnum.PRODUCT_STORAGE_INFO_KEY, result, goodsBO.getId()); 79 productCacheService.setCacheByString(UfoProductCacheKeyEnum.PRODUCT_STORAGE_INFO_KEY, result, goodsBO.getId());
80 return result; 80 return result;
81 } 81 }
  82 +
  83 + public Storage selectStorageByCache(Integer storageId) {
  84 + Storage cacheById = productCacheService.getCacheByString(UfoProductCacheKeyEnum.PRODUCT_STORAGE_BASE_INFO_KEY, Storage.class, storageId);
  85 + if (null != cacheById) {
  86 + return cacheById;
  87 + }
  88 + Storage storage = storageMapper.selectByPrimaryKey(storageId);
  89 + productCacheService.setCacheByString(UfoProductCacheKeyEnum.PRODUCT_STORAGE_BASE_INFO_KEY, storage, storageId);
  90 + return storage;
  91 + }
82 } 92 }