2024-06-03 16:11:14 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\api\controller\product;
|
2024-09-17 10:00:39 +08:00
|
|
|
|
2024-06-03 16:11:14 +08:00
|
|
|
use app\api\controller\BaseApiController;
|
|
|
|
use app\api\lists\product\ProductLists;
|
2024-09-03 17:55:14 +08:00
|
|
|
use app\api\lists\product\ProductWholesaleLists;
|
2024-07-13 09:25:33 +08:00
|
|
|
use app\api\lists\product\StoreProductLists;
|
|
|
|
use app\common\model\system_store\SystemStoreStaff;
|
2024-09-17 10:00:39 +08:00
|
|
|
use app\common\model\user\User;
|
|
|
|
|
|
|
|
class ProductController extends BaseApiController
|
|
|
|
{
|
2024-06-03 16:11:14 +08:00
|
|
|
|
|
|
|
public $notNeedLogin = ['lists'];
|
2024-09-03 17:55:14 +08:00
|
|
|
|
2024-06-03 16:11:14 +08:00
|
|
|
/**
|
|
|
|
* 商品列表
|
|
|
|
*/
|
2024-09-17 10:00:39 +08:00
|
|
|
public function lists()
|
|
|
|
{
|
2024-06-03 16:11:14 +08:00
|
|
|
|
2024-06-19 17:40:41 +08:00
|
|
|
return $this->dataLists(new ProductLists());
|
2024-06-03 16:11:14 +08:00
|
|
|
}
|
|
|
|
|
2024-09-03 17:55:14 +08:00
|
|
|
/**
|
|
|
|
* 批发商品列表
|
|
|
|
*/
|
2024-09-17 10:00:39 +08:00
|
|
|
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('请登陆后访问');
|
|
|
|
}
|
2024-09-03 17:55:14 +08:00
|
|
|
return $this->dataLists(new ProductWholesaleLists());
|
|
|
|
}
|
2024-06-06 14:58:20 +08:00
|
|
|
/**
|
2024-06-03 16:11:14 +08:00
|
|
|
* 商品列表
|
|
|
|
*/
|
2024-09-17 10:00:39 +08:00
|
|
|
public function mer_list()
|
|
|
|
{
|
|
|
|
$this->request->__set('store_id', $this->request->userInfo['store_id'] ?? 0);
|
2024-06-03 16:11:14 +08:00
|
|
|
return $this->dataLists(new ProductLists());
|
|
|
|
}
|
2024-07-13 09:25:33 +08:00
|
|
|
/**
|
|
|
|
* 商品列表
|
|
|
|
*/
|
2024-09-17 10:00:39 +08:00
|
|
|
public function store_lists()
|
|
|
|
{
|
2024-07-13 09:25:33 +08:00
|
|
|
|
2024-09-17 10:00:39 +08:00
|
|
|
$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);
|
2024-07-13 09:25:33 +08:00
|
|
|
return $this->dataLists(new StoreProductLists());
|
2024-09-17 10:00:39 +08:00
|
|
|
} else {
|
|
|
|
return $this->data(['lists' => []]);
|
2024-07-13 09:25:33 +08:00
|
|
|
}
|
|
|
|
}
|
2024-06-04 16:51:26 +08:00
|
|
|
}
|