下单或支付后,给第三方同步程序,商品SKU 加减库存
This commit is contained in:
parent
a030b8cd4c
commit
0698c35a5f
@ -93,6 +93,7 @@ import com.suisung.mall.shop.order.vo.OrderReturnItemInputVo;
|
||||
import com.suisung.mall.shop.product.pojo.vo.FixOrderVo;
|
||||
import com.suisung.mall.shop.product.service.*;
|
||||
import com.suisung.mall.shop.store.service.*;
|
||||
import com.suisung.mall.shop.sync.service.SyncThirdDataService;
|
||||
import com.suisung.mall.shop.user.service.*;
|
||||
import io.seata.common.util.StringUtils;
|
||||
import io.seata.core.context.RootContext;
|
||||
@ -297,6 +298,9 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
@Autowired
|
||||
private LakalaApiService lakalaApiService;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private SyncThirdDataService syncThirdDataService;
|
||||
|
||||
@Value("${sf-express.enable}")
|
||||
private Integer enable_sf_express;
|
||||
@ -3161,6 +3165,11 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
logger.error("更改: {} 冻结库存失败!", item_id);
|
||||
throw new ApiException(String.format(I18nUtil._("更改: %s 冻结库存失败!"), item_id));
|
||||
}
|
||||
|
||||
// RMK 第三方数据同步相关:redis 给这个商品减去对应的库存
|
||||
Map<String, Integer> stockDeltaMap = new HashMap<>();
|
||||
stockDeltaMap.put(Convert.toStr(item_src_id), -order_item_quantity);
|
||||
syncThirdDataService.incrProductStockToRedis(stockDeltaMap);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4069,6 +4078,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
}
|
||||
|
||||
// start 释放冻结库存
|
||||
// order_item_inventory_lock: 库存锁定(ENUM):1001-下单锁定;1002-支付锁定;
|
||||
Integer order_item_inventory_lock = order_item_row.getOrder_item_inventory_lock();
|
||||
if (ObjectUtil.equal(order_item_inventory_lock, 1001) || ObjectUtil.equal(order_item_inventory_lock, 1002)) {
|
||||
Long item_id = order_item_row.getItem_id();
|
||||
@ -4078,6 +4088,11 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
if (!shopProductItemService.edit(shopProductItem)) {
|
||||
throw new ApiException(String.format(I18nUtil._("释放: %s 冻结库存失败!"), order_item_row.getItem_id()));
|
||||
}
|
||||
|
||||
// RMK 第三方数据同步相关:redis 给这个商品加上对应的库存
|
||||
Map<String, Integer> stockDeltaMap = new HashMap<>();
|
||||
stockDeltaMap.put(Convert.toStr(shopProductItem.getItem_src_id()), order_item_quantity);
|
||||
syncThirdDataService.incrProductStockToRedis(stockDeltaMap);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6994,6 +7009,12 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
if (shopProductItemService.lockSkuStock(item_id, cart_quantity) <= 0) {
|
||||
throw new ApiException(String.format(I18nUtil._("更改: %s 冻结库存失败!"), item.get("item_id")));
|
||||
}
|
||||
|
||||
// RMK 第三方数据同步相关:redis 给这个商品减去上对应的库存
|
||||
Map<String, Integer> stockDeltaMap = new HashMap<>();
|
||||
stockDeltaMap.put(Convert.toStr(item_src_id), -cart_quantity);
|
||||
syncThirdDataService.incrProductStockToRedis(stockDeltaMap);
|
||||
|
||||
}
|
||||
// end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user