牟新芬 3 years ago
parent
commit
7da9441bde
2 changed files with 6 additions and 1 deletions
  1. 5 1
      app/model/system/Product.php
  2. 1 0
      app/system/controller/v1/Product.php

+ 5 - 1
app/model/system/Product.php

@@ -37,7 +37,8 @@ class Product extends BaseModel
         $model = (new Product)->getWhere($where)->field([
             '*',
             '(SELECT SUM(stock) FROM table_product_attr_value WHERE product_id = table_product.id AND type = 0) as stock',
-            '(SELECT SUM(sales) FROM table_product_attr_value WHERE product_id = table_product.id AND type = 0) as sales'
+            '(SELECT SUM(sales) FROM table_product_attr_value WHERE product_id = table_product.id AND type = 0) as sales',
+            '(SELECT name FROM table_merchant WHERE id = table_product.factory_id) as factory'
         ]);
         $model = $model->page((int)$where['page'], (int)$where['limit']);
         $data = ($data = $model->select()) && count($data) ? $data->toArray() : [];
@@ -101,6 +102,9 @@ class Product extends BaseModel
             if (isset($where['cate_id']) && $where['cate_id'] != '') {
                 $model = $model->where('cate_id', $where['cate_id']);
             }
+            if (isset($where['factory_id']) && $where['factory_id'] != '') {
+                $model = $model->where('factory_id', $where['factory_id']);
+            }
             if (isset($where['label']) && $where['label'] != '') {
                 if($where['label'] == '4'){
                     $model = $model->where('is_new', 1);

+ 1 - 0
app/system/controller/v1/Product.php

@@ -52,6 +52,7 @@ class Product extends BaseController
             ['limit', 20],
             ['store_name', ''],
             ['cate_id', ''],
+            ['factory_id', ''],
             ['label', ''],
             ['excel', 0],
             ['type', 1]