Explorar o código

fix(store): 解决商品下架状态检查逻辑问题

- 添加商品是否显示的状态检查,防止已下架商品加入购物车
- 当商品 is_show 字段为 0 时表示已下架并抛出验证异常
shichen hai 2 meses
pai
achega
b37c53ae06
Modificáronse 1 ficheiros con 1 adicións e 0 borrados
  1. 1 0
      app/controller/api/store/order/StoreCart.php

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

@@ -99,6 +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
         $res = $value_make->getOptionByUnique($data['product_attr_unique']);
103
         $res = $value_make->getOptionByUnique($data['product_attr_unique']);
103
         if(!$res) throw new ValidateException('SKU不存在');
104
         if(!$res) throw new ValidateException('SKU不存在');
104
         if($res['product_id'] != $data['product_id']) throw new ValidateException('数据不一致');
105
         if($res['product_id'] != $data['product_id']) throw new ValidateException('数据不一致');