WIN-2308041133\Administrator 5 months ago
parent
commit
3af5d4d9df

+ 11 - 11
app/common/dao/store/product/SpuDao.php

@@ -83,18 +83,18 @@ class SpuDao extends  BaseDao
             ->when(isset($where['product_ids']) && $where['product_ids'] !== '',function($query)use($where){
                 $query->whereIn('P.product_id',$where['product_ids']);
             })
-            ->when(isset($where['type']) && $where['type'] !== '',function($query)use($where){
-                $query->whereIn('P.type',$where['type']);
-            })
-//            ->when(isset($where['type']), function($query) use($where) {
-//                if ($where['type'] === '') {
-//                    $query->whereIn('P.type', [0,1,2,3,4]);
-//                } else {
-//                    $query->where('P.type', (int)$where['type']);
-//                }
-//            }, function($query) {
-//                $query->whereIn('P.type', [0,1,2,3,4]);
+//            ->when(isset($where['type']) && $where['type'] !== '',function($query)use($where){
+//                $query->whereIn('P.type',$where['type']);
 //            })
+            ->when(isset($where['type']), function($query) use($where) {
+                if ($where['type'] === '') {
+                    $query->whereIn('P.type', [0,1,2,3,4]);
+                } else {
+                    $query->where('P.type', (int)$where['type']);
+                }
+            }, function($query) {
+                $query->whereIn('P.type', [0,1,2,3,4]);
+            })
             ->when(isset($where['keyword']) && $where['keyword'] !== '',function($query)use($where){
                 if (is_numeric($where['keyword'])) {
                     $query->whereLike("S.store_name|S.keyword|S.product_id", "%{$where['keyword']}%");

+ 2 - 2
app/common/repositories/store/product/ProductRepository.php

@@ -2760,7 +2760,7 @@ class ProductRepository extends BaseRepository
             if (($data['cart_num'] + $count) > $product['once_max_count'])
                 throw new ValidateException('[超出限购总数:' . $product['once_max_count'] . ']' . mb_substr($product['store_name'], 0, 10) . '...');
         }
-        if ($product['type'] && !$data['is_new']) throw new ValidateException('虚拟商品不可加入购物车');
+        if ($product['type']==4 && !$data['is_new']) throw new ValidateException('虚拟商品不可加入购物车');
         if ($product['type'] == self::DEFINE_TYPE_CARD && $data['cart_num'] != 1)
             throw new ValidateException('卡密商品只能单个购买');
 
@@ -4020,7 +4020,7 @@ class ProductRepository extends BaseRepository
                     throw new ValidateException('[超出限购总数:' . $product['once_max_count'] . ']' . mb_substr($product['store_name'], 0, 10) . '...');
             }
         }
-        if ($product['type'] && !$data['is_new']) throw new ValidateException('虚拟商品不可加入购物车');
+        if ($product['type'] ==4&& !$data['is_new']) throw new ValidateException('虚拟商品不可加入购物车');
         if ($product['type'] == self::DEFINE_TYPE_CARD && $data['cart_num'] != 1)
             throw new ValidateException('卡密商品只能单个购买');
         $value_make = app()->make(ProductAttrValueRepository::class);