...
|
...
|
@@ -10,11 +10,8 @@ import com.yohobuy.ufo.model.order.common.BidSkupStatus; |
|
|
import com.yohobuy.ufo.model.response.BidStoragePriceResp;
|
|
|
import com.yohoufo.dal.product.BidStoragePriceMapper;
|
|
|
import com.yohoufo.dal.product.ProductMapper;
|
|
|
import com.yohoufo.dal.product.StorageMapper;
|
|
|
import com.yohoufo.dal.product.StoragePriceMapper;
|
|
|
import com.yohoufo.dal.product.model.BidStoragePrice;
|
|
|
import com.yohoufo.dal.product.model.Product;
|
|
|
import com.yohoufo.dal.product.model.Storage;
|
|
|
import com.yohoufo.dal.product.model.StoragePrice;
|
|
|
import com.yohoufo.product.cache.UfoProductCacheKeyEnum;
|
|
|
import com.yohoufo.product.cache.UfoProductCacheService;
|
...
|
...
|
@@ -47,12 +44,8 @@ public class BidProductService { |
|
|
@Autowired
|
|
|
private BidStoragePriceMapper bidStoragePriceMapper;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
private StorageMapper storageMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private StoragePriceMapper storagePriceMapper;
|
|
|
private StoragePriceService storagePriceService;
|
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -221,32 +214,32 @@ public class BidProductService { |
|
|
/**
|
|
|
* 获取统计价格
|
|
|
* 现货最低价,现货最高求购价
|
|
|
*
|
|
|
* @param storageIds
|
|
|
* @return
|
|
|
*/
|
|
|
public List<BidStoragePriceResp> getStatisticalPrice(Set<Integer> storageIds) {
|
|
|
if (CollectionUtils.isEmpty(storageIds)) {
|
|
|
return Lists.newArrayList();
|
|
|
}
|
|
|
|
|
|
List<Storage> storageList = storageMapper.selectByIds(storageIds);
|
|
|
if (CollectionUtils.isEmpty(storageList)) {
|
|
|
public List<BidStoragePriceResp> getStatisticalPrice(int productId, Set<Integer> storageIds) {
|
|
|
if (productId < 0 || CollectionUtils.isEmpty(storageIds)) {
|
|
|
return Lists.newArrayList();
|
|
|
}
|
|
|
|
|
|
List<StoragePrice> storagePrices = storagePriceMapper.selectBatchLeastPrice(storageIds);
|
|
|
|
|
|
List<BidStoragePrice> bidStoragePrices = bidStoragePriceMapper.selectHighestPrices(storageIds);
|
|
|
|
|
|
Map<Integer, BigDecimal> priceMap = storagePrices.stream().collect(Collectors.toMap(StoragePrice::getStorageId, StoragePrice::getPrice));
|
|
|
Map<Integer, BigDecimal> bidPriceMap = bidStoragePrices.stream().collect(Collectors.toMap(BidStoragePrice::getStorageId, BidStoragePrice::getPrice));
|
|
|
//现货最低价
|
|
|
Map<Integer, StoragePrice> storagePriceMap = storagePriceService.selectInStockLeastP(productId);
|
|
|
//现货最高求购价
|
|
|
Map<Integer, BidStoragePrice> bidStoragePriceMap = this.selectInStockLeastP(productId);
|
|
|
|
|
|
List<BidStoragePriceResp> resp = Lists.newArrayList();
|
|
|
storageList.stream().forEach(item -> {
|
|
|
|
|
|
storageIds.stream().forEach(storageId -> {
|
|
|
BidStoragePriceResp bidStoragePriceResp = new BidStoragePriceResp();
|
|
|
bidStoragePriceResp.setStorageId(item.getId());
|
|
|
bidStoragePriceResp.setLeastPrice(priceMap.get(item.getId()));
|
|
|
bidStoragePriceResp.setBidHighestPrice(bidPriceMap.get(item.getId()));
|
|
|
bidStoragePriceResp.setStorageId(storageId);
|
|
|
StoragePrice storagePrice = storagePriceMap.get(storageId);
|
|
|
if (storagePrice != null) {
|
|
|
bidStoragePriceResp.setLeastPrice(storagePrice.getPrice());
|
|
|
}
|
|
|
BidStoragePrice bidStoragePrice = bidStoragePriceMap.get(storageId);
|
|
|
if (bidStoragePrice != null) {
|
|
|
bidStoragePriceResp.setBidHighestPrice(bidStoragePrice.getPrice());
|
|
|
}
|
|
|
resp.add(bidStoragePriceResp);
|
|
|
});
|
|
|
return resp;
|
...
|
...
|
|