diff --git a/app/common/dao/system/merchant/MerchantDao.php b/app/common/dao/system/merchant/MerchantDao.php index bb364a5e..0ad51e11 100644 --- a/app/common/dao/system/merchant/MerchantDao.php +++ b/app/common/dao/system/merchant/MerchantDao.php @@ -294,4 +294,14 @@ class MerchantDao extends BaseDao ]); } + public function getValidMerchant($where) + { + $where = array_merge([ + 'is_del' => 0, + 'status' => 1, + 'mer_state' => 1, + ], $where); + return $this->getModel()::getInstance()->where($where); + } + } diff --git a/app/controller/api/store/product/StoreMicro.php b/app/controller/api/store/product/StoreMicro.php index 2c3e447b..d89e915e 100644 --- a/app/controller/api/store/product/StoreMicro.php +++ b/app/controller/api/store/product/StoreMicro.php @@ -1,5 +1,7 @@ where('mer_id',$mer_id)->value('category_id'); - $mer_id=Db::name('merchant')->where('category_id',$category_id)->where('type_id',13)->value('mer_id'); + $platformMerId = app()->make(MerchantDao::class)->getValidMerchant(['category_id' => $category_id, 'type_id' => Merchant::TypePlatform], 'mer_id')->value('mer_id'); + $productWhere = ['is_show' => 1, 'status' => 1, 'mer_status' => 1, 'is_del' => 0]; if($code!=''){ - $product_id_arr=Db::name('store_product_attr_value')->where('mer_id',$mer_id)->where('bar_code',$code)->column('product_id'); + $product_id_arr=Db::name('store_product_attr_value')->where('mer_id',$platformMerId)->where('bar_code',$code)->column('product_id'); $product_id_arr=implode(',',$product_id_arr); - $find=Db::name('store_product')->where('product_id',$product_id_arr)->select(); + $find=Db::name('store_product')->where('product_id',$product_id_arr)->where($productWhere)->select(); }else{ - $find=Db::name('store_product')->where('mer_id',$mer_id)->where('store_name','like','%'.$name.'%')->select(); + $find=Db::name('store_product')->where('mer_id',$platformMerId)->where('store_name','like','%'.$name.'%')->where($productWhere)->select(); } if (count($find)==0){ if($code!=''){