|
|
@@ -45,22 +45,42 @@ class StoreProduct extends AuthController
|
|
|
public function index()
|
|
|
{
|
|
|
$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));
|
|
|
- //出售中产品
|
|
|
- $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;
|
|
|
$this->assign(compact('type', 'onsale', 'forsale', 'warehouse', 'outofstock', 'policeforce', 'recycle'));
|
|
|
return $this->fetch();
|