|
@@ -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);
|