优化批量更新同步商品匹配操作

This commit is contained in:
liyj 2025-07-31 09:15:26 +08:00
parent 77a994bcfe
commit 085799d908
4 changed files with 20 additions and 13 deletions

View File

@ -124,7 +124,6 @@ public class StoreDbConfig implements Serializable {
private String priorityMode="1";
@TableField(value = "shop_gap_time",updateStrategy = FieldStrategy.NOT_EMPTY)
@ApiModelProperty(value = "商品同步间隔时间,由于商品同步时异步,要等同步完成才同步商品和活动,所以要设置间隔时间")
@NotBlank(message = "商品同步间隔时间不能为空")
private String shopGapTime;
}

View File

@ -5364,7 +5364,9 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
Integer product_state_id = Integer.valueOf(existBaseIdAndState[1]);
base.setProduct_id(existId);
base.setProduct_src_id(existId);
base.setProduct_state_id(product_state_id);
if(!(base.getProduct_state_id()==StateCode.PRODUCT_STATE_OFF_THE_SHELF_UNCHECK)){//重新分配
base.setProduct_state_id(product_state_id);
}
shopProductBaseList.get(i).setProduct_id(existId);
//shopProductIndexList.get(i).setProduct_id(existId);
// shopProductIndexList.get(i).setProduct_unit_points(BigDecimal.ZERO);
@ -5622,14 +5624,14 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
logger.info("处理成功,新增{}条,更新{}条", newProducts.size(), updateProducts.size());
//计算规格
if (CollUtil.isNotEmpty(newProducts)) {
productMappingService.computeProductMapping(newProducts, newProducts.get(0).getStore_id(),shopProductSpecItemMap,ShopBaseProductSpecMap,productMappingMap, isUpdatePrice,DicEnum.YESORNO_0.getCode());
}
if (CollUtil.isNotEmpty(updateProducts)) {//如果时自动优先则按平台规则切割商品
if (DicEnum.PRIORITY_MODE_2.getCode().equals(priorityMode)) {
productMappingService.computeProductMapping(updateProducts, updateProducts.get(0).getStore_id(),shopProductSpecItemMap,ShopBaseProductSpecMap,productMappingMap, true,DicEnum.YESORNO_0.getCode());
}
}
// if (CollUtil.isNotEmpty(newProducts)) {
// productMappingService.computeProductMapping(newProducts, newProducts.get(0).getStore_id(),shopProductSpecItemMap,ShopBaseProductSpecMap,productMappingMap, isUpdatePrice,DicEnum.YESORNO_0.getCode());
// }
// if (CollUtil.isNotEmpty(updateProducts)) {//如果时自动优先则按平台规则切割商品
// if (DicEnum.PRIORITY_MODE_2.getCode().equals(priorityMode)) {
// productMappingService.computeProductMapping(updateProducts, updateProducts.get(0).getStore_id(),shopProductSpecItemMap,ShopBaseProductSpecMap,productMappingMap, true,DicEnum.YESORNO_0.getCode());
// }
// }
return Pair.of(true, String.format("处理成功,新增%d条更新%d条",
newProducts.size(), updateProducts.size()));
} catch (RuntimeException e) {

View File

@ -184,8 +184,14 @@ public class ProductMappingServiceImpl extends BaseServiceImpl<ProductMappingMap
if(stateId!=StateCode.PRODUCT_STATE_NORMAL){
shopProductBaseList.get(i).setProduct_state_id(StateCode.PRODUCT_STATE_OFF_THE_SHELF);
shopProductIndex.setProduct_state_id(StateCode.PRODUCT_STATE_OFF_THE_SHELF);
shopProductItems.get(i).setItem_enable(StateCode.PRODUCT_STATE_OFF_THE_SHELF);
// shopProductItems.get(i).setItem_enable(StateCode.PRODUCT_STATE_OFF_THE_SHELF);
}
if(StringUtils.isNotEmpty(shopProductBaseList.get(i).getProduct_image())){
shopProductBaseList.get(i).setProduct_state_id(StateCode.PRODUCT_STATE_NORMAL);
shopProductIndex.setProduct_state_id(StateCode.PRODUCT_STATE_NORMAL);
shopProductItems.get(i).setItem_enable(StateCode.PRODUCT_STATE_NORMAL);
}
}
shopProductItems.get(i).setItem_is_default(1);
if(shopProductSpecItem.isUpdate()){
@ -282,7 +288,7 @@ public class ProductMappingServiceImpl extends BaseServiceImpl<ProductMappingMap
item.setItem_spec(item_spec);
shopProductInfo.setProduct_spec(productSpec);
}
String product_uniqid=ShopJsonUtils.generateJsonWithOrgJson(item.getSpec_item_ids(),new Object[]{item.getItem_id(),item.getItem_unit_price(),"",1002});
String product_uniqid=ShopJsonUtils.generateJsonWithOrgJson(item.getSpec_item_ids(),new Object[]{item.getItem_id(),item.getItem_unit_price(),"",item.getItem_enable()});
shopProductInfo.setProduct_uniqid(product_uniqid);
}

View File

@ -673,7 +673,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
// } catch (RuntimeException e) {
// logger.error("同步时间失败" + e.getMessage());
// }
productMappingService.syncAllProductMapping(Integer.valueOf(storeId),DicEnum.YESORNO_0.getCode());
syncShopImages(Integer.valueOf(storeId));//同时商品图库数据
}