Authored by mali

二手封面

@@ -76,4 +76,28 @@ public class GoodsService { @@ -76,4 +76,28 @@ public class GoodsService {
76 goodsImageBO.setImageUrl(ImageUrlAssist.getAllProductPicUrl(imageUrl, "goodsimg", "center", "d2hpdGU=")); 76 goodsImageBO.setImageUrl(ImageUrlAssist.getAllProductPicUrl(imageUrl, "goodsimg", "center", "d2hpdGU="));
77 return goodsImageBO; 77 return goodsImageBO;
78 } 78 }
  79 +
  80 + public String getGoodsDeafultImage(Integer goodsId) {
  81 + List<GoodsImages> goodsImages = goodsImagesMapper.selectByGoodsId(goodsId);
  82 + String defaultYImage = null;
  83 + String fistImage = null;
  84 + for(GoodsImages image : goodsImages) {
  85 + if(StringUtils.isNotBlank(image.getImageUrl())) {
  86 + if(StringUtils.isBlank(fistImage)) {
  87 + fistImage = image.getImageUrl();
  88 + }
  89 + if(StringUtils.equals(image.getIsDefault(), "Y")) {
  90 + defaultYImage = image.getImageUrl();
  91 + break;
  92 + }
  93 + }
  94 + }
  95 + if(StringUtils.isNotBlank(defaultYImage)) {
  96 + return ImageUrlAssist.getAllProductPicUrl(defaultYImage, "goodsimg", "center", "d2hpdGU=");
  97 + } else if(StringUtils.isNotBlank(fistImage)) {
  98 + return ImageUrlAssist.getAllProductPicUrl(fistImage, "goodsimg", "center", "d2hpdGU=");
  99 + } else {
  100 + return "";
  101 + }
  102 + }
79 } 103 }
@@ -1754,16 +1754,19 @@ public class ProductServiceImpl implements ProductService { @@ -1754,16 +1754,19 @@ public class ProductServiceImpl implements ProductService {
1754 resp.setStatus(sp.getStatus()); 1754 resp.setStatus(sp.getStatus());
1755 Integer storageId = sp.getStorageId(); 1755 Integer storageId = sp.getStorageId();
1756 Integer productId = sp.getProductId(); 1756 Integer productId = sp.getProductId();
1757 - Storage storage = storageMapper.selectByPrimaryKey(storageId); 1757 +
  1758 + Storage storage = storageService.selectStorageByCache(storageId);
1758 Goods goods = goodsMapper.selectByPrimaryKey(storage.getGoodsId()); 1759 Goods goods = goodsMapper.selectByPrimaryKey(storage.getGoodsId());
1759 - Product product = productMapper.selectByPrimaryKey(productId);  
1760 - Size size = sizeMapper.selectByPrimaryKey(storage.getSizeId());  
1761 - Brand brand = brandMapper.selectByPrimaryKey(product.getBrandId()); 1760 + Product product = productHelpService.selectByIdCache(productId);
  1761 +
  1762 + String sizeName = sizeCacheService.queryNameBySizeId(storage.getSizeId());
  1763 + Brand brand = brandCacheService.queryByBrandId(product.getBrandId());
1762 List<SecondhandImages> secondhandImagesList = secondhandImagesMapper.selectBySkup(skup); 1764 List<SecondhandImages> secondhandImagesList = secondhandImagesMapper.selectBySkup(skup);
1763 SecondhandInfo secondhandInfo = secondhandInfoMapper.selectBySkup(skup); 1765 SecondhandInfo secondhandInfo = secondhandInfoMapper.selectBySkup(skup);
1764 resp.setProductId(productId); 1766 resp.setProductId(productId);
1765 1767
1766 - resp.setImage(getGoodsDeafultImage(goods.getId())); 1768 +
  1769 + resp.setImage(goodsService.getGoodsDeafultImage(goods.getId()));
1767 resp.setImageList(secondhandImagesList.stream().map(image -> com.yohoufo.common.helper.ImagesHelper.getImageAbsoluteUrl(image.getImageUrl(), "goodsimg")).collect(Collectors.toList())); 1770 resp.setImageList(secondhandImagesList.stream().map(image -> com.yohoufo.common.helper.ImagesHelper.getImageAbsoluteUrl(image.getImageUrl(), "goodsimg")).collect(Collectors.toList()));
1768 resp.setGender(productHelpService.getGenderName(product.getGender())); 1771 resp.setGender(productHelpService.getGenderName(product.getGender()));
1769 1772
@@ -1775,7 +1778,7 @@ public class ProductServiceImpl implements ProductService { @@ -1775,7 +1778,7 @@ public class ProductServiceImpl implements ProductService {
1775 resp.setSavePrice(inStockLeastPrice.subtract(sp.getPrice()).toString()); 1778 resp.setSavePrice(inStockLeastPrice.subtract(sp.getPrice()).toString());
1776 } 1779 }
1777 1780
1778 - resp.setSizeName(size.getSizeName() + "码"); 1781 + resp.setSizeName(sizeName + "码");
1779 resp.setProductName(product.getProductName()); 1782 resp.setProductName(product.getProductName());
1780 resp.setProductCode(product.getProductCode()); 1783 resp.setProductCode(product.getProductCode());
1781 resp.setColorName(goods.getGoodsName()); 1784 resp.setColorName(goods.getGoodsName());
@@ -2007,31 +2010,6 @@ public class ProductServiceImpl implements ProductService { @@ -2007,31 +2010,6 @@ public class ProductServiceImpl implements ProductService {
2007 } 2010 }
2008 return sizeIdList; 2011 return sizeIdList;
2009 } 2012 }
2010 -  
2011 -  
2012 - private String getGoodsDeafultImage(Integer goodsId) {  
2013 - List<GoodsImages> goodsImages = goodsImagesMapper.selectByGoodsId(goodsId);  
2014 - String defaultYImage = null;  
2015 - String fistImage = null;  
2016 - for(GoodsImages image : goodsImages) {  
2017 - if(StringUtils.isNotBlank(image.getImageUrl())) {  
2018 - if(StringUtils.isBlank(fistImage)) {  
2019 - fistImage = image.getImageUrl();  
2020 - }  
2021 - if(StringUtils.equals(image.getIsDefault(), "Y")) {  
2022 - defaultYImage = image.getImageUrl();  
2023 - break;  
2024 - }  
2025 - }  
2026 - }  
2027 - if(StringUtils.isNotBlank(defaultYImage)) {  
2028 - return ImageUrlAssist.getAllProductPicUrl(defaultYImage, "goodsimg", "center", "d2hpdGU=");  
2029 - } else if(StringUtils.isNotBlank(fistImage)) {  
2030 - return ImageUrlAssist.getAllProductPicUrl(fistImage, "goodsimg", "center", "d2hpdGU=");  
2031 - } else {  
2032 - return "";  
2033 - }  
2034 - }  
2035 2013
2036 private void setProductProfitRate(ProductInfo productInfo, Integer productId) { 2014 private void setProductProfitRate(ProductInfo productInfo, Integer productId) {
2037 if (null == productId) { 2015 if (null == productId) {