解决商品不存在时的扣减出错问题
This commit is contained in:
parent
38a1ce0c66
commit
2e7612ac93
@ -5321,16 +5321,15 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
if (Arrays.asList(1001, 1002).contains(order_item_inventory_lock)) {
|
||||
Long item_id = order_item_row.getItem_id();
|
||||
ShopProductItem shopProductItem = shopProductItemService.get(item_id);
|
||||
if (shopProductItem == null) {
|
||||
throw new ApiException(I18nUtil._("无法获取订单中的商品,请检查!"));
|
||||
}
|
||||
|
||||
Integer item_quantity_frozen = shopProductItem.getItem_quantity_frozen();
|
||||
int quantity_frozen = item_quantity_frozen - order_item_quantity;
|
||||
shopProductItem.setItem_quantity_frozen(quantity_frozen > 0 ? quantity_frozen : 0);
|
||||
|
||||
if (!shopProductItemService.edit(shopProductItem)) {
|
||||
throw new ApiException(I18nUtil._("修改商品冻结库存失败!"));
|
||||
if (shopProductItem != null) {
|
||||
logger.info("无法获取订单中的商品,请检查!");//商品存在才执行库存扣减
|
||||
// throw new ApiException(I18nUtil._("无法获取订单中的商品,请检查!"));
|
||||
Integer item_quantity_frozen = shopProductItem.getItem_quantity_frozen();
|
||||
int quantity_frozen = item_quantity_frozen - order_item_quantity;
|
||||
shopProductItem.setItem_quantity_frozen(quantity_frozen > 0 ? quantity_frozen : 0);
|
||||
if (!shopProductItemService.edit(shopProductItem)) {
|
||||
throw new ApiException(I18nUtil._("修改商品冻结库存失败!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user