multi-store/app/api/controller/product/ProductController.php

64 lines
1.6 KiB
PHP

<?php
namespace app\api\controller\product;
use app\api\controller\BaseApiController;
use app\api\lists\product\ProductLists;
use app\api\lists\product\ProductWholesaleLists;
use app\api\lists\product\StoreProductLists;
use app\common\model\system_store\SystemStoreStaff;
use app\common\model\user\User;
class ProductController extends BaseApiController
{
public $notNeedLogin = ['lists'];
/**
* 商品列表
*/
public function lists()
{
return $this->dataLists(new ProductLists());
}
/**
* 批发商品列表
*/
public function wholesale_lists()
{
if ($this->userId) {
$label_id = User::where('id', $this->userId)->value('label_id');
if ($label_id != 99) {
return $this->fail('您没有权限访问该列表');
}
} else {
return $this->fail('请登陆后访问');
}
return $this->dataLists(new ProductWholesaleLists());
}
/**
* 商品列表
*/
public function mer_list()
{
$this->request->__set('store_id', $this->request->userInfo['store_id'] ?? 0);
return $this->dataLists(new ProductLists());
}
/**
* 商品列表
*/
public function store_lists()
{
$store_id = SystemStoreStaff::where('uid', $this->userId)->where('is_admin', 1)->value('store_id');
if ($store_id > 0) {
$this->request->__set('store_id', $store_id);
return $this->dataLists(new StoreProductLists());
} else {
return $this->data(['lists' => []]);
}
}
}