思迅同步库存问题修改,分隔符问题

This commit is contained in:
liyj 2025-10-17 16:55:53 +08:00
parent bc9c1d2023
commit 4774ab8aab
2 changed files with 6 additions and 6 deletions

View File

@ -3303,7 +3303,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
// RMK 第三方数据同步相关redis 给这个商品减去对应的库存 // RMK 第三方数据同步相关redis 给这个商品减去对应的库存
Map<String, Integer> stockDeltaMap = new HashMap<>(); Map<String, Integer> stockDeltaMap = new HashMap<>();
stockDeltaMap.put(item_src_id + "_" + order_item_row.getOrder_id(), -order_item_quantity); stockDeltaMap.put(item_src_id + "-" + order_item_row.getOrder_id(), -order_item_quantity);
syncThirdDataService.incrProductStockToRedis(stockDeltaMap); syncThirdDataService.incrProductStockToRedis(stockDeltaMap);
} }
} }
@ -4226,7 +4226,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
log.debug("释放库存Item_src_id:{},数量:{}", shopProductItem.getItem_src_id(), order_item_quantity); log.debug("释放库存Item_src_id:{},数量:{}", shopProductItem.getItem_src_id(), order_item_quantity);
// RMK 第三方数据同步相关redis 给这个商品加上对应的库存 // RMK 第三方数据同步相关redis 给这个商品加上对应的库存
Map<String, Integer> stockDeltaMap = new HashMap<>(); Map<String, Integer> stockDeltaMap = new HashMap<>();
stockDeltaMap.put(shopProductItem.getItem_src_id() + "_" + order_item_row.getOrder_id(), order_item_quantity); stockDeltaMap.put(shopProductItem.getItem_src_id() + "-" + order_item_row.getOrder_id(), order_item_quantity);
syncThirdDataService.incrProductStockToRedis(stockDeltaMap); syncThirdDataService.incrProductStockToRedis(stockDeltaMap);
} }
} }
@ -7254,7 +7254,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
// RMK 第三方数据同步相关redis 给这个商品减去上对应的库存 // RMK 第三方数据同步相关redis 给这个商品减去上对应的库存
log.debug("减库存Item_src_id:{},数量:{}", item_src_id, cart_quantity); log.debug("减库存Item_src_id:{},数量:{}", item_src_id, cart_quantity);
Map<String, Integer> stockDeltaMap = new HashMap<>(); Map<String, Integer> stockDeltaMap = new HashMap<>();
stockDeltaMap.put(item_src_id + "_" + order_id, -cart_quantity); stockDeltaMap.put(item_src_id + "-" + order_id, -cart_quantity);
syncThirdDataService.incrProductStockToRedis(stockDeltaMap); syncThirdDataService.incrProductStockToRedis(stockDeltaMap);
} }

View File

@ -894,7 +894,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
List<ProductQuantityConsumption> productQuantityConsumptionList=new ArrayList<>(); List<ProductQuantityConsumption> productQuantityConsumptionList=new ArrayList<>();
redisHash.forEach((k, v)->{ redisHash.forEach((k, v)->{
ProductQuantityConsumption productQuantityConsumption=new ProductQuantityConsumption(); ProductQuantityConsumption productQuantityConsumption=new ProductQuantityConsumption();
String[] productKeyArrys=k.split("_"); String[] productKeyArrys=k.split("-");
if(productKeyArrys.length!=2){ if(productKeyArrys.length!=2){
return; return;
} }
@ -929,7 +929,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
if (StrUtil.isBlank(productKey) || delta == null) { if (StrUtil.isBlank(productKey) || delta == null) {
continue; continue;
} }
String[] productKeyArrys=productKey.split("_"); String[] productKeyArrys=productKey.split("-");
if(productKeyArrys.length!=2){ if(productKeyArrys.length!=2){
continue; continue;
} }
@ -959,7 +959,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
String name = Convert.toStr(item.get("name")); String name = Convert.toStr(item.get("name"));
BigDecimal itemQuaryty = getBigDecimal(delta, name); BigDecimal itemQuaryty = getBigDecimal(delta, name);
// 使用 Redis HINCRBY 保证原子性和高性能 // 使用 Redis HINCRBY 保证原子性和高性能
redisTemplate.opsForHash().increment(key, itemId+"_"+orderId, itemQuaryty.doubleValue()); redisTemplate.opsForHash().increment(key, itemId+"-"+orderId, itemQuaryty.doubleValue());
} catch (Exception e) { } catch (Exception e) {
logger.error("库存累计失败productKey={}, delta={}, error={}", productKey, delta, e.getMessage(), e); logger.error("库存累计失败productKey={}, delta={}, error={}", productKey, delta, e.getMessage(), e);
} }