|
|
@@ -935,9 +935,9 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService {
|
|
|
private int syncProductWindow(LocalDateTime windowBegin, LocalDateTime windowEnd, int pageSize) {
|
|
|
int pageIndex = 1;
|
|
|
int syncCount = 0;
|
|
|
- boolean hasNext = true;
|
|
|
+ Set<String> syncedSkuIds = new HashSet<>();
|
|
|
|
|
|
- while (hasNext) {
|
|
|
+ while (true) {
|
|
|
ProductQueryRequestDTO queryDTO = new ProductQueryRequestDTO();
|
|
|
queryDTO.setModifiedBegin(formatDateTime(windowBegin));
|
|
|
queryDTO.setModifiedEnd(formatDateTime(windowEnd));
|
|
|
@@ -950,14 +950,25 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
+ int currentPageNewSkuCount = 0;
|
|
|
for (ProductResponseDTO.ProductInfo erpProduct : response.getDatas()) {
|
|
|
if (StringUtils.isBlank(erpProduct.getSkuId())) {
|
|
|
continue;
|
|
|
}
|
|
|
+ if (!syncedSkuIds.add(erpProduct.getSkuId())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ currentPageNewSkuCount++;
|
|
|
syncCount += syncSingleProductFromErp(erpProduct);
|
|
|
}
|
|
|
|
|
|
- hasNext = Boolean.TRUE.equals(response.getHasNext());
|
|
|
+ Integer pageCount = response.getPageCount();
|
|
|
+ if ((pageCount != null && pageIndex >= pageCount)
|
|
|
+ || !Boolean.TRUE.equals(response.getHasNext())
|
|
|
+ || response.getDatas().size() < pageSize
|
|
|
+ || currentPageNewSkuCount == 0) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
pageIndex++;
|
|
|
}
|
|
|
return syncCount;
|
|
|
@@ -1060,6 +1071,9 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService {
|
|
|
}
|
|
|
|
|
|
private void updateAttrValueByErpData(FsStoreProduct product,FsStoreProductAttrValue attr, ProductResponseDTO.ProductInfo erpProduct) {
|
|
|
+ if (!hasAttrValueUpdateData(erpProduct)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
FsStoreProductAttrValue updateAttr = new FsStoreProductAttrValue();
|
|
|
updateAttr.setId(attr.getId());
|
|
|
updateAttr.setPrice(erpProduct.getSalePrice());
|
|
|
@@ -1072,6 +1086,14 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService {
|
|
|
syncProductAttrDefinition(product.getProductId());
|
|
|
}
|
|
|
|
|
|
+ private boolean hasAttrValueUpdateData(ProductResponseDTO.ProductInfo erpProduct) {
|
|
|
+ return erpProduct.getSalePrice() != null
|
|
|
+ || erpProduct.getCostPrice() != null
|
|
|
+ || erpProduct.getMarketPrice() != null
|
|
|
+ || StringUtils.isNotBlank(erpProduct.getPic())
|
|
|
+ || erpProduct.getWeight() != null;
|
|
|
+ }
|
|
|
+
|
|
|
private Long getStoreIdByErpBrand(String brand) {
|
|
|
if (StringUtils.isBlank(brand)) {
|
|
|
return null;
|