...
|
...
|
@@ -4,6 +4,7 @@ import com.yoho.ufo.dal.*; |
|
|
import com.yoho.ufo.dal.model.Goods;
|
|
|
import com.yoho.ufo.dal.model.Product;
|
|
|
import com.yoho.ufo.dal.model.Storage;
|
|
|
import com.yoho.ufo.dal.model.StoragePrice;
|
|
|
import com.yoho.ufo.model.brand.Brand;
|
|
|
import com.yoho.ufo.model.commoditybasicrole.category.ProductSort;
|
|
|
import com.yoho.ufo.model.commoditybasicrole.color.ProductColor;
|
...
|
...
|
@@ -15,6 +16,7 @@ import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
...
|
...
|
@@ -26,9 +28,6 @@ import java.util.Map; |
|
|
public class ProductAssistService {
|
|
|
|
|
|
@Autowired
|
|
|
private ProductSortMapper productSortMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private ProductMapper productMapper;
|
|
|
|
|
|
@Autowired
|
...
|
...
|
@@ -38,12 +37,6 @@ public class ProductAssistService { |
|
|
private GoodsMapper goodsMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private GoodsImagesMapper goodsImagesMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private UfoProductColorMapper productColorMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private StorageMapper storageMapper;
|
|
|
|
|
|
@Autowired
|
...
|
...
|
@@ -138,4 +131,36 @@ public class ProductAssistService { |
|
|
});
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
public ProductAssistService fillSkupInfo(List<ProductResponceBo> productResponceBos) {
|
|
|
if (CollectionUtils.isEmpty(productResponceBos)) {
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
Map<Integer, ProductResponceBo> productMap = CollectionUtil.extractMap(productResponceBos, ProductResponceBo::getId);
|
|
|
|
|
|
List<Integer> productIdList = CollectionUtil.distinct(productResponceBos, ProductResponceBo::getId);
|
|
|
List<StoragePrice> storagePriceList = storagePriceMapper.selectByProductIds(productIdList);
|
|
|
|
|
|
storagePriceList.stream().forEach(item -> {
|
|
|
ProductResponceBo productResponceBo = productMap.get(item.getProductId());
|
|
|
|
|
|
productResponceBo.setCurrentPrice(minPrice(productResponceBo.getCurrentPrice(), item.getPrice()));
|
|
|
|
|
|
productResponceBo.setStorage(null == productResponceBo.getStorage() ? 1 :productResponceBo.getStorage() + 1);
|
|
|
});
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
private String minPrice(String currentPrice, BigDecimal skupPrice) {
|
|
|
if (StringUtils.isEmpty(currentPrice)) {
|
|
|
return skupPrice.toString();
|
|
|
}
|
|
|
|
|
|
if (new BigDecimal(currentPrice).compareTo(skupPrice) > 0) {
|
|
|
return skupPrice.toString();
|
|
|
} else {
|
|
|
return currentPrice;
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|