Преглед изворни кода

fix(store): 修复商品下架状态检查逻辑

- 修正了商品下架状态判断条件,移除注释并启用验证
- 当商品 is_show 字段为 0 时抛出商品已下架异常
- 确保购物车操作时正确验证商品上下架状态
shichen пре 2 месеци
родитељ
комит
73e68b676c
1 измењених фајлова са 1 додато и 1 уклоњено
  1. 1 1
      app/controller/api/store/order/StoreCart.php

+ 1 - 1
app/controller/api/store/order/StoreCart.php

@@ -99,7 +99,7 @@ class StoreCart extends BaseController
99
         if( $data['cart_num'] < 0 ) throw new ValidateException('数量必须大于0');
99
         if( $data['cart_num'] < 0 ) throw new ValidateException('数量必须大于0');
100
         $product = $product_make->getWhere(['product_id' => $data['product_id']],'*');
100
         $product = $product_make->getWhere(['product_id' => $data['product_id']],'*');
101
         if(!$product) throw new ValidateException('商品不存在');
101
         if(!$product) throw new ValidateException('商品不存在');
102
-        // if (!$product['is_show'] == 0) throw new ValidateException('商品已下架');
102
+        if ($product['is_show'] == 0) throw new ValidateException('商品已下架');
103
         $res = $value_make->getOptionByUnique($data['product_attr_unique']);
103
         $res = $value_make->getOptionByUnique($data['product_attr_unique']);
104
         if(!$res) throw new ValidateException('SKU不存在');
104
         if(!$res) throw new ValidateException('SKU不存在');
105
         if($res['product_id'] != $data['product_id']) throw new ValidateException('数据不一致');
105
         if($res['product_id'] != $data['product_id']) throw new ValidateException('数据不一致');