// +---------------------------------------------------------------------- namespace App\Http\Controllers\Admin; use App\Services\Common\GoodsService; /** * 商品管理-控制器 * @author laravel开发员 * @since 2020/11/11 * Class GoodsController * @package App\Http\Controllers */ class GoodsController extends Backend { /** * 构造函数 * @author laravel开发员 * @since 2020/11/11 * GoodsController constructor. */ public function __construct() { parent::__construct(); $this->service = new GoodsService(); } /** * 列表(商品审核列表) * @return array */ public function index() { $pageSize = request()->get('limit', 15); $params = request()->all(); $params['store_id'] = $this->storeId; $list = $this->service->getDataList($params, $pageSize); $message = array( "msg" => '操作成功', "code" => 0, "data" => isset($list['list']) ? $list['list'] : [], "count" => isset($list['total']) ? $list['total'] : 0, ); return $message; } /** * 获取详情 * @return array */ public function info() { return $this->service->info($this->storeId); } /** * 添加商品 * @return array */ public function add() { return $this->service->add($this->storeId); } /** * 编辑商品 * @return array */ public function edit() { return $this->service->edit($this->storeId); } /** * 审核商品 * @return array */ public function confirm() { // 权限检查:只有总后台管理员才能审核,商户用户无法审核 if ($this->storeId > 0) { return message('商户用户无权进行审核操作', false); } $params = request()->post(); if ($this->service->confirm($this->userId, $params)) { return message($this->service->getError(), true); } else { return message($this->service->getError(), false); } } /** * 批量上下架 * @return array */ public function launch() { if ($this->storeId > 0) { return message('商户用户无权进行审核操作', false); } $params = request()->post(); if ($this->service->launch($this->userId, $params)) { return message($this->service->getError(), true); } else { return message($this->service->getError(), false); } } /** * 删除数据 * @return mixed * @since 2020/11/11 * @author laravel开发员 */ public function delete() { $result = $this->service->delete($this->storeId); return $result; } /** * 选项列表(用于下拉选择) * @return array */ public function options() { // 这里可以返回商品选项,如果需要的话 return message('操作成功', true, []); } }