WIN-2308041133\Administrator hace 1 mes
padre
commit
9c4681425e
Se han modificado 1 ficheros con 34 adiciones y 14 borrados
  1. 34 14
      app/admin/controller/store/StoreProduct.php

+ 34 - 14
app/admin/controller/store/StoreProduct.php

@@ -45,22 +45,42 @@ class StoreProduct extends AuthController
     public function index()
     public function index()
     {
     {
         $type = $this->request->param('type');
         $type = $this->request->param('type');
+        $admin_id=$this->adminId;
+        $mer_id = SystemAdmin::where('id',$admin_id)->value('mer_id');
         //获取分类
         //获取分类
         $this->assign('cate', CategoryModel::getTierList(null, 1));
         $this->assign('cate', CategoryModel::getTierList(null, 1));
-        //出售中产品
-        $onsale = ProductModel::where('is_del', 0)->where('is_show', 1)->count();
-        //待上架产品
-        $forsale = ProductModel::where('is_del', 0)->where('is_show', 0)->count();
-        //仓库中产品
-        $warehouse = ProductModel::where('is_del', 0)->count();
-        //已经售馨产品
-        $outofstock = ProductModel::getModelObject()->where(ProductModel::setData(4))->where('pav.type', 0)->count('DISTINCT id');
-        //警戒库存
-        $store_stock = sys_config('store_stock');
-        if ($store_stock < 0) $store_stock = 2;
-        $policeforce = ProductModel::getModelObject()->where(ProductModel::setData(5))->where('p.stock', '<=', $store_stock)->where('pav.type', 0)->count('DISTINCT id');
-        //回收站
-        $recycle = ProductModel::where('is_del', 1)->count();
+        if ($mer_id>0){
+            //出售中产品
+            $onsale = ProductModel::where('is_del', 0)->where('is_show', 1)->where('mer_id', $mer_id)->count();
+            //待上架产品
+            $forsale = ProductModel::where('is_del', 0)->where('is_show', 0)->where('mer_id', $mer_id)->count();
+            //仓库中产品
+            $warehouse = ProductModel::where('is_del', 0)->where('mer_id', $mer_id)->count();
+            //已经售馨产品
+            $outofstock = ProductModel::getModelObject()->where(ProductModel::setData(4))->where('pav.type', 0)->where('mer_id',$mer_id)->count('DISTINCT id');
+            //警戒库存
+            $store_stock = sys_config('store_stock');
+            if ($store_stock < 0) $store_stock = 2;
+            $policeforce = ProductModel::getModelObject()->where(ProductModel::setData(5))->where('p.stock', '<=', $store_stock)->where('pav.type', 0)->where('mer_id',$mer_id)->count('DISTINCT id');
+            //回收站
+            $recycle = ProductModel::where('is_del', 1)->where('mer_id',$mer_id)->count();
+        }else{
+            //出售中产品
+            $onsale = ProductModel::where('is_del', 0)->where('is_show', 1)->count();
+            //待上架产品
+            $forsale = ProductModel::where('is_del', 0)->where('is_show', 0)->count();
+            //仓库中产品
+            $warehouse = ProductModel::where('is_del', 0)->count();
+            //已经售馨产品
+            $outofstock = ProductModel::getModelObject()->where(ProductModel::setData(4))->where('pav.type', 0)->count('DISTINCT id');
+            //警戒库存
+            $store_stock = sys_config('store_stock');
+            if ($store_stock < 0) $store_stock = 2;
+            $policeforce = ProductModel::getModelObject()->where(ProductModel::setData(5))->where('p.stock', '<=', $store_stock)->where('pav.type', 0)->count('DISTINCT id');
+            //回收站
+            $recycle = ProductModel::where('is_del', 1)->count();
+        }
+
         if ($type == null) $type = 1;
         if ($type == null) $type = 1;
         $this->assign(compact('type', 'onsale', 'forsale', 'warehouse', 'outofstock', 'policeforce', 'recycle'));
         $this->assign(compact('type', 'onsale', 'forsale', 'warehouse', 'outofstock', 'policeforce', 'recycle'));
         return $this->fetch();
         return $this->fetch();