...
|
...
|
@@ -5,9 +5,12 @@ import java.util.HashSet; |
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.yoho.ufo.util.CollectionUtil;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.elasticsearch.common.collect.Lists;
|
|
|
import org.elasticsearch.common.collect.Maps;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -102,8 +105,14 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
|
|
|
|
@Override
|
|
|
public PageResponseBO<SecondhandRsp> querySecondhandSkupList(SecondhandReq req) {
|
|
|
|
|
|
int total = storagePriceMapper.selectSecondTotalByCondition(req);
|
|
|
if (StringUtils.isNotBlank(req.getProductCode())) {
|
|
|
List<Product> productList = productMapper.selectByProductCode(req.getProductCode());
|
|
|
if (productList.isEmpty()) {
|
|
|
return null;
|
|
|
}
|
|
|
req.setProductIdList(CollectionUtil.distinct(productList, Product::getId));
|
|
|
}
|
|
|
int total = storagePriceMapper.selectSecondTotalByCondition(req);
|
|
|
if(total == 0) {
|
|
|
return null;
|
|
|
}
|
...
|
...
|
@@ -130,7 +139,7 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
|
//查询product
|
|
|
List<Integer> productIdList = storagePriceList.stream().map(StoragePrice::getProductId).collect(Collectors.toList());
|
|
|
List<Product> productList = productMapper.selectProductListByIds(productIdList);
|
|
|
Map<Integer, String> productIdNameMap = productList.stream().collect(Collectors.toMap(Product::getId, Product::getProductName));
|
|
|
Map<Integer, Product> productMap = productList.stream().collect(Collectors.toMap(Product::getId, Function.identity()));
|
|
|
|
|
|
//查询secondhand_flaw
|
|
|
List<String> flawIdStrList = infoList.stream().map(SecondhandInfo::getFlawId).collect(Collectors.toList());
|
...
|
...
|
@@ -142,7 +151,7 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
|
Map<Integer, String> goodsIdImageMap = goodsImagesList.stream().collect(Collectors.toMap(GoodsImages::getProductId, GoodsImages::getImageUrl));
|
|
|
|
|
|
//组装
|
|
|
List<SecondhandRsp> respList = convertToResp(storagePriceList, skupImageMap, secondhandInfoMap, sellerGoodsMap, productIdNameMap, flawMap, goodsIdImageMap);
|
|
|
List<SecondhandRsp> respList = convertToResp(storagePriceList, skupImageMap, secondhandInfoMap, sellerGoodsMap, productMap, flawMap, goodsIdImageMap);
|
|
|
|
|
|
PageResponseBO<SecondhandRsp> result=new PageResponseBO<>();
|
|
|
result.setList(respList);
|
...
|
...
|
@@ -234,8 +243,8 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
|
}
|
|
|
|
|
|
private List<SecondhandRsp> convertToResp(List<StoragePrice> storagePriceList, Map<Integer, List<SecondhandImages>> skupImageMap,
|
|
|
Map<Integer, SecondhandInfo> infoMap, Map<Integer, SellerOrderGoods> sellerGoodsMap,
|
|
|
Map<Integer, String> productIdNameMap, Map<Integer, String> flawMap, Map<Integer, String> goodsIdImageMap){
|
|
|
Map<Integer, SecondhandInfo> infoMap, Map<Integer, SellerOrderGoods> sellerGoodsMap,
|
|
|
Map<Integer, Product> productMap, Map<Integer, String> flawMap, Map<Integer, String> goodsIdImageMap){
|
|
|
List<SecondhandRsp> respList = Lists.newArrayList();
|
|
|
for(StoragePrice item : storagePriceList) {
|
|
|
SecondhandRsp rsp = new SecondhandRsp();
|
...
|
...
|
@@ -251,7 +260,11 @@ public class SecondhandProductService implements ISecondhandProductService{ |
|
|
rsp.setPrice(String.valueOf(item.getPrice()));
|
|
|
rsp.setStatus(item.getStatus());
|
|
|
rsp.setSku(item.getStorageId());
|
|
|
rsp.setProductName(productIdNameMap.get(item.getProductId()));
|
|
|
Product p = productMap.get(item.getProductId());
|
|
|
if (p != null) {
|
|
|
rsp.setProductName(p.getProductName());
|
|
|
rsp.setProductCode(p.getProductCode());
|
|
|
}
|
|
|
|
|
|
SellerOrderGoods sellerGoods = sellerGoodsMap.get(skup);
|
|
|
if(null != sellerGoods) {
|
...
|
...
|
|