refactor(admin): 优化商品库存校验逻辑

- 修改了库存校验的条件判断,使用取反逻辑
- 提高了代码的可读性和逻辑清晰度
- 确保在库存不足时抛出正确的异常信息
This commit is contained in:
mkm 2025-02-07 11:02:18 +08:00
parent c06ca03681
commit 100a3c9f82

View File

@ -385,7 +385,7 @@ class BeforehandOrderLogic extends BaseLogic
}
foreach ($storege_arr as $key => $value) {
if ($value['is_verify']==1 && $v['product_id'] == $value['product_id']) {
if ($v['cart_num'] < $value['nums']) {
if (($v['cart_num'] < $value['nums'])==false) {
$store_name=StoreProduct::where('id', $v['product_id'])->withTrashed()->value('store_name');
throw new BusinessException('商品:'.$store_name.'已开启强制库存校验,库存不足,库存数量' . $value['nums'].',需求数量:' . $v['cart_num']);
}