...
|
...
|
@@ -55,6 +55,7 @@ import java.math.BigDecimal; |
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
import java.util.function.Predicate;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
...
|
...
|
@@ -601,14 +602,35 @@ public class ProductController { |
|
|
private void clearBatchProductCache(List<Integer> skupList) {
|
|
|
try {
|
|
|
LOG.info("in clearBatchProductCache skupList = {}", skupList);
|
|
|
List<StoragePrice> spList = productService.getStoragePriceBySkupList(skupList);
|
|
|
List<Integer> productIdList = spList.stream().map(StoragePrice::getProductId).distinct().collect(Collectors.toList());
|
|
|
List<Integer> storageIdList = spList.stream().map(StoragePrice::getStorageId).distinct().collect(Collectors.toList());
|
|
|
List<StoragePrice> storagePriceList = productService.getStoragePriceBySkupList(skupList);
|
|
|
List<Integer> productIdList = storagePriceList.stream().map(StoragePrice::getProductId).distinct().collect(Collectors.toList());
|
|
|
List<Integer> storageIdList = storagePriceList.stream().map(StoragePrice::getStorageId).distinct().collect(Collectors.toList());
|
|
|
if (CollectionUtils.isNotEmpty(productIdList)) {
|
|
|
for (Integer productId : productIdList) {
|
|
|
LOG.info("Batch clearCache queryProductDetailById productId = {}, ", productId);
|
|
|
|
|
|
storagePriceService.publishPriceUpdateEvent(productId);
|
|
|
storagePriceService.publishPriceUpdateEventIf(productId, oldPrices -> {
|
|
|
// 缓存不存在,需要更新
|
|
|
if (CollectionUtils.isEmpty(oldPrices)) {
|
|
|
return true;
|
|
|
}
|
|
|
// 比最低价要低,需要更新
|
|
|
if(storagePriceList.stream()
|
|
|
.filter(e -> Objects.equals(e.getProductId(), productId))
|
|
|
.anyMatch(newPrice -> oldPrices.stream()
|
|
|
.filter(oldPrice -> Objects.equals(newPrice.getStorageId(), oldPrice.getStorageId()))
|
|
|
.anyMatch(oldPrice -> newPrice.getPrice().compareTo(oldPrice.getPrice()) < 0))){
|
|
|
return true;
|
|
|
}
|
|
|
// 如果当前skup为缓存中商品,需要更新
|
|
|
if(storagePriceList.stream()
|
|
|
.filter(e -> Objects.equals(e.getProductId(), productId))
|
|
|
.anyMatch(newPrice -> oldPrices.stream()
|
|
|
.anyMatch(oldPrice -> Objects.equals(newPrice.getSkup(), oldPrice.getSkup())))){
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
//商品详情
|
|
|
cacheAop.clearCache(
|
...
|
...
|
@@ -659,7 +681,7 @@ public class ProductController { |
|
|
}
|
|
|
}
|
|
|
Map<String, StoragePrice> distinctStorage = new HashMap<>();
|
|
|
for(StoragePrice sp : spList) {
|
|
|
for(StoragePrice sp : storagePriceList) {
|
|
|
Integer skup = sp.getSkup();
|
|
|
Integer storageId = sp.getStorageId();
|
|
|
if (sp.getPreSaleFlag() != null && (sp.getPreSaleFlag() == 5 || sp.getPreSaleFlag() == 6)) {
|
...
|
...
|
|