1
|
package com.yohoufo.product.service.impl;
|
1
|
package com.yohoufo.product.service.impl;
|
2
|
|
2
|
|
|
|
3
|
+import com.google.common.collect.Lists;
|
3
|
import com.yohobuy.ufo.model.GoodsSize;
|
4
|
import com.yohobuy.ufo.model.GoodsSize;
|
4
|
import com.yohobuy.ufo.model.ProductInfo;
|
5
|
import com.yohobuy.ufo.model.ProductInfo;
|
5
|
import com.yohoufo.common.utils.DateUtil;
|
6
|
import com.yohoufo.common.utils.DateUtil;
|
6
|
import com.yohoufo.dal.product.BrandSeriesMapper;
|
7
|
import com.yohoufo.dal.product.BrandSeriesMapper;
|
7
|
import com.yohoufo.dal.product.ProductMapper;
|
8
|
import com.yohoufo.dal.product.ProductMapper;
|
8
|
-import com.yohoufo.dal.product.model.Brand;
|
|
|
9
|
-import com.yohoufo.dal.product.model.BrandSeries;
|
|
|
10
|
-import com.yohoufo.dal.product.model.Product;
|
9
|
+import com.yohoufo.dal.product.ProductSortMapper;
|
|
|
10
|
+import com.yohoufo.dal.product.SizeMapper;
|
|
|
11
|
+import com.yohoufo.dal.product.model.*;
|
11
|
import com.yohoufo.product.cache.UfoProductCacheKeyEnum;
|
12
|
import com.yohoufo.product.cache.UfoProductCacheKeyEnum;
|
12
|
import com.yohoufo.product.cache.UfoProductCacheService;
|
13
|
import com.yohoufo.product.cache.UfoProductCacheService;
|
13
|
import com.yohoufo.product.service.cache.BrandCacheService;
|
14
|
import com.yohoufo.product.service.cache.BrandCacheService;
|
|
@@ -19,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
@@ -19,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
19
|
import org.springframework.stereotype.Service;
|
20
|
import org.springframework.stereotype.Service;
|
20
|
import org.springframework.util.CollectionUtils;
|
21
|
import org.springframework.util.CollectionUtils;
|
21
|
import java.math.BigDecimal;
|
22
|
import java.math.BigDecimal;
|
|
|
23
|
+import java.util.ArrayList;
|
22
|
import java.util.List;
|
24
|
import java.util.List;
|
23
|
import java.util.Objects;
|
25
|
import java.util.Objects;
|
24
|
import java.util.Optional;
|
26
|
import java.util.Optional;
|
|
@@ -46,6 +48,12 @@ public class ProductHelpService { |
|
@@ -46,6 +48,12 @@ public class ProductHelpService { |
46
|
@Autowired
|
48
|
@Autowired
|
47
|
private BidProductService bidProductService;
|
49
|
private BidProductService bidProductService;
|
48
|
|
50
|
|
|
|
51
|
+ @Autowired
|
|
|
52
|
+ private ProductSortMapper productSortMapper;
|
|
|
53
|
+
|
|
|
54
|
+ @Autowired
|
|
|
55
|
+ private SizeMapper sizeMapper;
|
|
|
56
|
+
|
49
|
public ProductInfo convertProductInfo(Product product) {
|
57
|
public ProductInfo convertProductInfo(Product product) {
|
50
|
ProductInfo productInfo = new ProductInfo();
|
58
|
ProductInfo productInfo = new ProductInfo();
|
51
|
productInfo.setProductId(product.getId());
|
59
|
productInfo.setProductId(product.getId());
|
|
@@ -143,4 +151,23 @@ public class ProductHelpService { |
|
@@ -143,4 +151,23 @@ public class ProductHelpService { |
143
|
productInfo.setMosterPrice(mosterPrice);
|
151
|
productInfo.setMosterPrice(mosterPrice);
|
144
|
}
|
152
|
}
|
145
|
}
|
153
|
}
|
|
|
154
|
+
|
|
|
155
|
+ public List<Size> getAllSizeBySortId(Integer sortId) {
|
|
|
156
|
+ List<Size> cache = productCacheService.getListCacheByString(UfoProductCacheKeyEnum.ALL_SIZE_BY_SORTID_KEY, Size.class, sortId);
|
|
|
157
|
+ if (CollectionUtils.isEmpty(cache)) {
|
|
|
158
|
+ ProductSort sort = productSortMapper.selectByPrimaryKey(sortId);
|
|
|
159
|
+ List<Size> sizes = Lists.newArrayList();
|
|
|
160
|
+ if (sort != null) {
|
|
|
161
|
+ List<Integer> idList = new ArrayList<>();
|
|
|
162
|
+ idList.add(sortId);
|
|
|
163
|
+ if (sort.getParentId() != null && sort.getParentId() > 0) {
|
|
|
164
|
+ idList.add(sort.getParentId());
|
|
|
165
|
+ }
|
|
|
166
|
+ sizes = sizeMapper.selectAllSizeBySortIdList(idList);
|
|
|
167
|
+ }
|
|
|
168
|
+ productCacheService.setCacheByString(UfoProductCacheKeyEnum.ALL_SIZE_BY_SORTID_KEY, sizes, sortId);
|
|
|
169
|
+ return sizes;
|
|
|
170
|
+ }
|
|
|
171
|
+ return cache;
|
|
|
172
|
+ }
|
146
|
} |
173
|
} |