| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace addons\StarChain\backend\controllers;
- use addons\StarChain\common\services\CategorysService;
- use addons\StarChain\common\services\SpuService;
- /**
- * 商品
- */
- class GoodsController extends BaseController
- {
- /**
- * 商品列表
- *
- * @return string
- */
- public function actionIndex()
- {
- if ($this->request->isAjax) {
- $params = $this->request->getBodyParams();
- unset($params['_csrf']);
-
- $service = new SpuService(['mall_id' => $this->mall_id]);
- $data = $service->getSpuList($params);
- return $data
- ? $this->success('ok', $data)
- : $this->error($service->error);
- }
- return $this->render($this->action->id);
- }
- /**
- * 获取分类
- *
- * @return string
- */
- public function actionCategory()
- {
- if ($this->request->isAjax) {
- $pid = $this->request->getQueryParam('pid', 0);
- $service = new CategorysService(['mall_id' => $this->mall_id]);
- return $this->success('ok', $service->list($pid));
- }
- }
-
- /**
- * 商品导入
- *
- * @return string
- */
- public function actionStorageAdd()
- {
- if ($this->request->isAjax) {
- $ids = $this->request->getBodyParam('ids');
- $service = new SpuService(['mall_id' => $this->mall_id]);
- return $service->import($ids)
- ? $this->success('ok')
- : $this->error($service->error);
- }
- }
- }
|